|
@@ -211,15 +211,15 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
|
|
|
return new CommonPage<>(page.getRecords(), page.getTotal(), page.getCurrent(), page.getSize());
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public void variableCloning(Integer type,String newDeviceCode,String oldDeviceCode,String deviceName){
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+ //查询出旧设备配置
|
|
|
+ LambdaQueryWrapper<Device> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.eq(Device::getEnable, 1).eq(Device::getDeviceCode, oldDeviceCode);
|
|
|
+ List<Device> deviceList = this.list(queryWrapper);
|
|
|
|
|
|
if (type==1){
|
|
|
- //查询出旧设备配置
|
|
|
- LambdaQueryWrapper<Device> queryWrapper = Wrappers.lambdaQuery();
|
|
|
- queryWrapper.eq(Device::getEnable, 1).eq(Device::getDeviceCode, oldDeviceCode);
|
|
|
- List<Device> deviceList = this.list(queryWrapper);
|
|
|
-
|
|
|
//设备表新增
|
|
|
Device device = new Device();
|
|
|
device.setEnable(1);
|
|
@@ -245,7 +245,7 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
|
|
|
deviceStatusService.save(deviceStatus);
|
|
|
//变量配置查询
|
|
|
LambdaQueryWrapper<DeviceAnalogVariableList> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
- queryWrapperOne.eq(DeviceAnalogVariableList::getStatus, 1).eq(DeviceAnalogVariableList::getCommunicationEquipment, deviceId);
|
|
|
+ queryWrapperOne.eq(DeviceAnalogVariableList::getStatus, 1).eq(DeviceAnalogVariableList::getCommunicationEquipment, deviceList.get(0).getId());
|
|
|
List<DeviceAnalogVariableList> deviceAnalogVariableList = deviceAnalogVariableListService.list(queryWrapperOne);
|
|
|
if (deviceAnalogVariableList.size()>0){
|
|
|
for (int i = 0; i < deviceAnalogVariableList.size(); i++) {
|
|
@@ -253,8 +253,8 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
|
|
|
deviceAnalogVariableListOne.setDeviceCode(newDeviceCode);
|
|
|
deviceAnalogVariableListOne.setVariableName(deviceAnalogVariableList.get(i).getVariableName());
|
|
|
deviceAnalogVariableListOne.setVariableCoding(deviceAnalogVariableList.get(i).getVariableCoding());
|
|
|
- deviceAnalogVariableListOne.setMonitoringEquipment(deviceAnalogVariableList.get(i).getMonitoringEquipment());
|
|
|
- deviceAnalogVariableListOne.setCommunicationEquipment(deviceAnalogVariableList.get(i).getCommunicationEquipment());
|
|
|
+ deviceAnalogVariableListOne.setMonitoringEquipment(0);
|
|
|
+ deviceAnalogVariableListOne.setCommunicationEquipment(deviceId);
|
|
|
deviceAnalogVariableListOne.setDataAddress(deviceAnalogVariableList.get(i).getDataAddress());
|
|
|
deviceAnalogVariableListOne.setDataType(deviceAnalogVariableList.get(i).getDataType());
|
|
|
deviceAnalogVariableListOne.setCoefficient(deviceAnalogVariableList.get(i).getCoefficient());
|
|
@@ -267,12 +267,8 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
- //被克隆设备查询是否存在
|
|
|
- LambdaQueryWrapper<Device> queryWrapperOne = Wrappers.lambdaQuery();
|
|
|
- queryWrapperOne.eq(Device::getEnable, 1).eq(Device::getDeviceCode, oldDeviceCode);
|
|
|
- List<Device> deviceListOne = this.list(queryWrapperOne);
|
|
|
LambdaQueryWrapper<DeviceAnalogVariableList> queryWrapperOneA = Wrappers.lambdaQuery();
|
|
|
- queryWrapperOneA.eq(DeviceAnalogVariableList::getStatus, 1).eq(DeviceAnalogVariableList::getCommunicationEquipment, deviceListOne.get(0).getId());
|
|
|
+ queryWrapperOneA.eq(DeviceAnalogVariableList::getStatus, 1).eq(DeviceAnalogVariableList::getCommunicationEquipment, deviceList.get(0).getId());
|
|
|
List<DeviceAnalogVariableList> deviceAnalogVariableListOne = deviceAnalogVariableListService.list(queryWrapperOneA);
|
|
|
|
|
|
//克隆设备查询是否存在
|
|
@@ -295,32 +291,23 @@ public class DeviceServiceImpl extends AbstractCrudService<DeviceMapper, Device>
|
|
|
if (deviceAnalogVariableListOne.size()>0){
|
|
|
for (int i = 0; i < deviceAnalogVariableListOne.size(); i++) {
|
|
|
DeviceAnalogVariableList deviceAnalogVariableList = new DeviceAnalogVariableList();
|
|
|
-
|
|
|
-// deviceAnalogVariableList.setDeviceCode(newDeviceCode);
|
|
|
-// deviceAnalogVariableList.setVariableName(deviceAnalogVariableList.get(i).getVariableName());
|
|
|
-// deviceAnalogVariableList.setVariableCoding(deviceAnalogVariableList.get(i).getVariableCoding());
|
|
|
-// deviceAnalogVariableList.setMonitoringEquipment(deviceAnalogVariableList.get(i).getMonitoringEquipment());
|
|
|
-// deviceAnalogVariableList.setCommunicationEquipment(deviceAnalogVariableList.get(i).getCommunicationEquipment());
|
|
|
-// deviceAnalogVariableList.setDataAddress(deviceAnalogVariableList.get(i).getDataAddress());
|
|
|
-// deviceAnalogVariableList.setDataType(deviceAnalogVariableList.get(i).getDataType());
|
|
|
-// deviceAnalogVariableList.setCoefficient(deviceAnalogVariableList.get(i).getCoefficient());
|
|
|
-// deviceAnalogVariableList.setSaveCycle(deviceAnalogVariableList.get(i).getSaveCycle());
|
|
|
-// deviceAnalogVariableList.setDataArea(deviceAnalogVariableList.get(i).getDataArea());
|
|
|
-// deviceAnalogVariableList.setCreator(user.getUserName());
|
|
|
-// deviceAnalogVariableList.setCreateTime(new Date());
|
|
|
-// deviceAnalogVariableList.setStatus(1);
|
|
|
-
|
|
|
-
|
|
|
- deviceAnalogVariableList.setStatus(0);
|
|
|
- deviceAnalogVariableListService.updateById(deviceAnalogVariableList);
|
|
|
+ deviceAnalogVariableList.setDeviceCode(newDeviceCode);
|
|
|
+ deviceAnalogVariableList.setVariableName(deviceAnalogVariableListOne.get(i).getVariableName());
|
|
|
+ deviceAnalogVariableList.setVariableCoding(deviceAnalogVariableListOne.get(i).getVariableCoding());
|
|
|
+ deviceAnalogVariableList.setMonitoringEquipment(0);
|
|
|
+ deviceAnalogVariableList.setCommunicationEquipment(deviceListTwo.get(0).getId());
|
|
|
+ deviceAnalogVariableList.setDataType(deviceAnalogVariableListOne.get(i).getDataType());
|
|
|
+ deviceAnalogVariableList.setDataAddress(deviceAnalogVariableListOne.get(i).getDataAddress());
|
|
|
+ deviceAnalogVariableList.setSaveCycle(deviceAnalogVariableListOne.get(i).getSaveCycle());
|
|
|
+ deviceAnalogVariableList.setCoefficient(deviceAnalogVariableListOne.get(i).getCoefficient());
|
|
|
+ deviceAnalogVariableList.setDataArea(deviceAnalogVariableListOne.get(i).getDataArea());
|
|
|
+ deviceAnalogVariableList.setCreator(user.getUserName());
|
|
|
+ deviceAnalogVariableList.setCreateTime(new Date());
|
|
|
+ deviceAnalogVariableList.setStatus(1);
|
|
|
+ deviceAnalogVariableListService.save(deviceAnalogVariableList);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
}
|