|
|
@@ -235,8 +235,12 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean checkAssetNoRepeat(Long orgId, String assetNo) {
|
|
|
- final Long count = lambdaQuery().eq(SysDevice::getOrgId, orgId).eq(SysDevice::getAssetNo, assetNo).count();
|
|
|
+ public boolean checkAssetNoRepeat(Long orgId, String assetNo, Long deviceId) {
|
|
|
+ final Long count = lambdaQuery()
|
|
|
+ .eq(SysDevice::getOrgId, orgId)
|
|
|
+ .eq(SysDevice::getAssetNo, assetNo)
|
|
|
+ .ne(deviceId != null, SysDevice::getId, deviceId)
|
|
|
+ .count();
|
|
|
return count <= 0;
|
|
|
}
|
|
|
|
|
|
@@ -261,14 +265,15 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|
|
if (null != sysDevice1) {
|
|
|
throw new RuntimeException("设备名称重复");
|
|
|
}
|
|
|
- if (!checkAssetNoRepeat(sysDevice.getOrgId(), sysDevice.getAssetNo())) {
|
|
|
+ if (!checkAssetNoRepeat(sysDevice.getOrgId(), sysDevice.getAssetNo(),null)) {
|
|
|
throw new RuntimeException("资产编号重复");
|
|
|
}
|
|
|
int insert = sysDeviceMapper.insert(sysDevice);
|
|
|
- /**
|
|
|
- * 这块逻辑代码,上层出错时,会导致新增设备出错
|
|
|
- */
|
|
|
- if ("6".equals(sysDevice.getDeviceType()) && ObjectUtil.isNull(sysDevice.getBusinessDeviceId())) {
|
|
|
+ //如果已经存在了主机同步上来的子系统,那么设备新增的就不能再同步到子系统表去
|
|
|
+ final int exitDevice = remoteProtectionService.checkExitDevice(sysOrg.getId(), SecurityConstants.INNER);
|
|
|
+
|
|
|
+ //未报废的子系统且当前机构不存在主机同步子系统的情况下才需要同步到子系统表
|
|
|
+ if ("6".equals(sysDevice.getDeviceType()) && sysDevice.getDeviceStatus() != 3 && exitDevice == 0) {
|
|
|
ProtectionDTO protectionDTO = new ProtectionDTO();
|
|
|
protectionDTO.setName(sysDevice.getDeviceName());
|
|
|
protectionDTO.setOrgPath(sysOrg.getPath());
|
|
|
@@ -334,14 +339,16 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|
|
*/
|
|
|
@Override
|
|
|
public int updateSysDevice(SysDevice sysDevice) {
|
|
|
- if (!checkAssetNoRepeat(sysDevice.getOrgId(), sysDevice.getAssetNo())) {
|
|
|
+ if (!checkAssetNoRepeat(sysDevice.getOrgId(), sysDevice.getAssetNo(),sysDevice.getId())) {
|
|
|
throw new RuntimeException("资产编号重复");
|
|
|
}
|
|
|
sysDevice.setUpdateTime(DateUtils.getNowDate());
|
|
|
sysDevice.setUpdateBy(SecurityUtils.getUsername());
|
|
|
SysOrg sysOrg = orgService.selectSysOrgById(sysDevice.getOrgId());
|
|
|
sysDevice.setOrgName(sysOrg.getShortName());
|
|
|
- if (sysDevice.getDeviceType().equals("1")) {
|
|
|
+ //如果已经存在了主机同步上来的子系统,那么设备新增的就不能再同步到子系统表去
|
|
|
+ final int exitDevice = remoteProtectionService.checkExitDevice(sysDevice.getOrgId(), SecurityConstants.INNER);
|
|
|
+ if ("6".equals(sysDevice.getDeviceType()) && ObjectUtil.isNull(sysDevice.getBusinessDeviceId()) && exitDevice == 0) {
|
|
|
ProtectionVO byDeviceId = remoteProtectionService.getByDeviceId(sysDevice.getId(), SecurityConstants.INNER);
|
|
|
ProtectionDTO protectionDTO = new ProtectionDTO();
|
|
|
if (null != byDeviceId) {
|
|
|
@@ -359,6 +366,9 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|
|
if (null != sysDevice1 && !sysDevice1.getId().equals(sysDevice.getId())) {
|
|
|
throw new RuntimeException("设备名称重复");
|
|
|
}
|
|
|
+ if (sysDevice.getDeviceStatus() == 3) {
|
|
|
+ remoteProtectionService.delByDeviceId(sysDevice.getId(), SecurityConstants.INNER);
|
|
|
+ }
|
|
|
return sysDeviceMapper.updateById(sysDevice);
|
|
|
}
|
|
|
|
|
|
@@ -465,7 +475,7 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|
|
if (StringUtils.isEmpty(assetNo)) {
|
|
|
msgList.add("资产编号为空");
|
|
|
} else {
|
|
|
- if (device.getOrgId() != null && !checkAssetNoRepeat(device.getOrgId(), assetNo)) {
|
|
|
+ if (device.getOrgId() != null && !checkAssetNoRepeat(device.getOrgId(), assetNo,null)) {
|
|
|
msgList.add("资产编号重复");
|
|
|
} else {
|
|
|
device.setAssetNo(assetNo);
|
|
|
@@ -545,7 +555,7 @@ public class SysDeviceServiceImpl extends ServiceImpl<SysDeviceMapper, SysDevice
|
|
|
String address = deviceExport.getAddress();
|
|
|
if (StringUtils.isEmpty(address)) {
|
|
|
msgList.add("安装位置未填写");
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
device.setAddress(address);
|
|
|
}
|
|
|
String checkTimeStr = deviceExport.getCheckTime();
|