|
|
@ -1,6 +1,7 @@ |
|
|
|
package org.nl.wms.basedata.master.devicestatus.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
@ -53,8 +54,9 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev |
|
|
|
DeviceStatus deviceStatus = deviceStatusMapper.selectOne(lam); |
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(deviceStatus)) { |
|
|
|
throw new BadRequestException("已存在相同的设备编码!"); |
|
|
|
throw new BadRequestException("已存在相同的设备编码:"+jo.getDevice_code()+",请检查!"); |
|
|
|
}else{//新增
|
|
|
|
jo.setDevicestatus_id(IdUtil.getSnowflake(1, 1).nextId()+""); |
|
|
|
deviceStatusMapper.insert(jo); |
|
|
|
} |
|
|
|
} |
|
|
@ -62,19 +64,19 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev |
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(DeviceStatus jo) { |
|
|
|
|
|
|
|
LambdaQueryWrapper<DeviceStatus> lam = new LambdaQueryWrapper<DeviceStatus>(); |
|
|
|
lam.eq(DeviceStatus::getDevice_code,jo.getDevice_code()); |
|
|
|
DeviceStatus deviceStatus = deviceStatusMapper.selectOne(lam); |
|
|
|
|
|
|
|
//如果存在相同设备编码
|
|
|
|
if (ObjectUtil.isNotEmpty(deviceStatus)) { |
|
|
|
String devicestatus_id = deviceStatus.getDevicestatus_id(); |
|
|
|
if(devicestatus_id.equals(jo.getDevicestatus_id())){ |
|
|
|
deviceStatusMapper.updateById(jo); |
|
|
|
}else{ |
|
|
|
throw new BadRequestException("已存在相同的设备编码!"); |
|
|
|
//判断是否当前修改的id
|
|
|
|
if(!devicestatus_id.equals(jo.getDevicestatus_id())){ |
|
|
|
throw new BadRequestException("已存在相同的设备编码:"+jo.getDevice_code()+",请检查!"); |
|
|
|
} |
|
|
|
}else{//新增
|
|
|
|
deviceStatusMapper.insert(jo); |
|
|
|
} |
|
|
|
//不存在相同编码,直接更新
|
|
|
|
deviceStatusMapper.updateById(jo); |
|
|
|
} |
|
|
|
} |
|
|
|