|
|
|
@ -4,11 +4,10 @@ import com.mh.user.constants.Constant; |
|
|
|
import com.mh.user.entity.CollectionParamsManageEntity; |
|
|
|
import com.mh.user.entity.CollectionParamsManageEntity; |
|
|
|
import com.mh.user.entity.DeviceInstallEntity; |
|
|
|
import com.mh.user.entity.DeviceInstallEntity; |
|
|
|
import com.mh.user.entity.GatewayManageEntity; |
|
|
|
import com.mh.user.entity.GatewayManageEntity; |
|
|
|
import com.mh.user.mapper.CollectionParamsManageMapper; |
|
|
|
import com.mh.user.mapper.*; |
|
|
|
import com.mh.user.mapper.DeviceInstallMapper; |
|
|
|
import com.mh.user.model.MultiControlModel; |
|
|
|
import com.mh.user.mapper.GatewayManageMapper; |
|
|
|
|
|
|
|
import com.mh.user.mapper.NowDataMapper; |
|
|
|
|
|
|
|
import com.mh.user.s7.S7ConnectorUtil; |
|
|
|
import com.mh.user.s7.S7ConnectorUtil; |
|
|
|
|
|
|
|
import com.mh.user.service.NowDataService; |
|
|
|
import com.mh.user.utils.DateUtil; |
|
|
|
import com.mh.user.utils.DateUtil; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.scheduling.annotation.Scheduled; |
|
|
|
@ -40,13 +39,17 @@ public class S7PlcCollectionJob { |
|
|
|
private static final Map<String, S7ConnectorUtil> connectorCache = new ConcurrentHashMap<>(); |
|
|
|
private static final Map<String, S7ConnectorUtil> connectorCache = new ConcurrentHashMap<>(); |
|
|
|
private final DeviceInstallMapper deviceInstallMapper; |
|
|
|
private final DeviceInstallMapper deviceInstallMapper; |
|
|
|
private final NowDataMapper nowDataMapper; |
|
|
|
private final NowDataMapper nowDataMapper; |
|
|
|
|
|
|
|
private final NowDataService nowDataService; |
|
|
|
|
|
|
|
private final NowPublicDataMapper nowPublicDataMapper; |
|
|
|
|
|
|
|
|
|
|
|
public S7PlcCollectionJob(GatewayManageMapper gatewayManageMapper, |
|
|
|
public S7PlcCollectionJob(GatewayManageMapper gatewayManageMapper, |
|
|
|
CollectionParamsManageMapper collectionParamsManageMapper, DeviceInstallMapper deviceInstallMapper, NowDataMapper nowDataMapper, NowDataMapper nowDataMapper1) { |
|
|
|
CollectionParamsManageMapper collectionParamsManageMapper, DeviceInstallMapper deviceInstallMapper, NowDataMapper nowDataMapper, NowDataMapper nowDataMapper1, NowDataService nowDataService, NowPublicDataMapper nowPublicDataMapper) { |
|
|
|
this.gatewayManageMapper = gatewayManageMapper; |
|
|
|
this.gatewayManageMapper = gatewayManageMapper; |
|
|
|
this.collectionParamsManageMapper = collectionParamsManageMapper; |
|
|
|
this.collectionParamsManageMapper = collectionParamsManageMapper; |
|
|
|
this.deviceInstallMapper = deviceInstallMapper; |
|
|
|
this.deviceInstallMapper = deviceInstallMapper; |
|
|
|
this.nowDataMapper = nowDataMapper1; |
|
|
|
this.nowDataMapper = nowDataMapper1; |
|
|
|
|
|
|
|
this.nowDataService = nowDataService; |
|
|
|
|
|
|
|
this.nowPublicDataMapper = nowPublicDataMapper; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
@ -148,10 +151,12 @@ public class S7PlcCollectionJob { |
|
|
|
// map值有cur_value,cur_time,通过stream判断cur_time是否是当前时间,然后cur_value如果存在一天记录等于1的,back_water_state=运行,否则back_water_state=不运行
|
|
|
|
// map值有cur_value,cur_time,通过stream判断cur_time是否是当前时间,然后cur_value如果存在一天记录等于1的,back_water_state=运行,否则back_water_state=不运行
|
|
|
|
backWaterStates.forEach(backWaterState -> { |
|
|
|
backWaterStates.forEach(backWaterState -> { |
|
|
|
if (backWaterState.get("cur_time").toString().substring(0, 10).equals(dateStr.substring(0, 10))) { |
|
|
|
if (backWaterState.get("cur_time").toString().substring(0, 10).equals(dateStr.substring(0, 10))) { |
|
|
|
if (backWaterState.get("cur_value").equals(1)) { |
|
|
|
if (new BigDecimal(backWaterState.get("cur_value").toString()).intValue() > 0) { |
|
|
|
nowDataMapper.updateBackWaterState(buildingId, "运行"); |
|
|
|
nowDataMapper.updateBackWaterState(buildingId, "1"); |
|
|
|
|
|
|
|
nowPublicDataMapper.updateBackWaterState(buildingId, "运行"); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
nowDataMapper.updateBackWaterState(buildingId, "不运行"); |
|
|
|
nowDataMapper.updateBackWaterState(buildingId, "0"); |
|
|
|
|
|
|
|
nowPublicDataMapper.updateBackWaterState(buildingId, "不运行"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
@ -190,10 +195,12 @@ public class S7PlcCollectionJob { |
|
|
|
nowDataMapper.updateUpWaterState(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateUpWaterState(deviceInstallEntity.getBuildingId(), |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
"2", deviceInstallEntity.getDeviceName()); |
|
|
|
"2", deviceInstallEntity.getDeviceName()); |
|
|
|
|
|
|
|
nowPublicDataMapper.updateUpWaterState(Long.valueOf(deviceInstallEntity.getBuildingId()), "异常"); |
|
|
|
} else if (deviceInstallEntity.getDeviceType().equals("补水电磁阀")) { |
|
|
|
} else if (deviceInstallEntity.getDeviceType().equals("补水电磁阀")) { |
|
|
|
nowDataMapper.updateUseWaterState(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateUseWaterState(deviceInstallEntity.getBuildingId(), |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
"2", deviceInstallEntity.getDeviceName()); |
|
|
|
"2", deviceInstallEntity.getDeviceName()); |
|
|
|
|
|
|
|
nowPublicDataMapper.updateUseWaterState(Long.valueOf(deviceInstallEntity.getBuildingId()), "异常"); |
|
|
|
} |
|
|
|
} |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -236,7 +243,7 @@ public class S7PlcCollectionJob { |
|
|
|
if (deviceInstallEntity != null) { |
|
|
|
if (deviceInstallEntity != null) { |
|
|
|
// 更新设备安装表中的now_date字段,根据param.getParamTypeId()的值进行判断 // 在对now_date进行更新
|
|
|
|
// 更新设备安装表中的now_date字段,根据param.getParamTypeId()的值进行判断 // 在对now_date进行更新
|
|
|
|
// 查询当前点位是否是运行状态、压力、液位、液位设置、回水温度、故障状态
|
|
|
|
// 查询当前点位是否是运行状态、压力、液位、液位设置、回水温度、故障状态
|
|
|
|
log.error("进入nowData设置==>{}", param.toString()); |
|
|
|
// log.error("进入nowData设置==>{}", param.toString());
|
|
|
|
switch (param.getParamTypeId()) { |
|
|
|
switch (param.getParamTypeId()) { |
|
|
|
case 2: // 运行状态
|
|
|
|
case 2: // 运行状态
|
|
|
|
nowDataMapper.updateRunState(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateRunState(deviceInstallEntity.getBuildingId(), |
|
|
|
@ -249,10 +256,12 @@ public class S7PlcCollectionJob { |
|
|
|
nowDataMapper.updateUpWaterState(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateUpWaterState(deviceInstallEntity.getBuildingId(), |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
String.valueOf(curValue.intValue()), deviceInstallEntity.getDeviceName()); |
|
|
|
String.valueOf(curValue.intValue()), deviceInstallEntity.getDeviceName()); |
|
|
|
|
|
|
|
nowPublicDataMapper.updateUpWaterState(Long.valueOf(deviceInstallEntity.getBuildingId()), curValue.intValue() == 1 ? "运行" : "不运行"); |
|
|
|
} else if (deviceInstallEntity.getDeviceType().equals("补水电磁阀")) { |
|
|
|
} else if (deviceInstallEntity.getDeviceType().equals("补水电磁阀")) { |
|
|
|
nowDataMapper.updateUseWaterState(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateUseWaterState(deviceInstallEntity.getBuildingId(), |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
String.valueOf(curValue.intValue()), deviceInstallEntity.getDeviceName()); |
|
|
|
String.valueOf(curValue.intValue()), deviceInstallEntity.getDeviceName()); |
|
|
|
|
|
|
|
nowPublicDataMapper.updateUseWaterState(Long.valueOf(deviceInstallEntity.getBuildingId()), curValue.intValue() == 1 ? "运行" : "不运行"); |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 5: // 压力
|
|
|
|
case 5: // 压力
|
|
|
|
@ -263,12 +272,17 @@ public class S7PlcCollectionJob { |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 31: // 液位
|
|
|
|
case 31: // 液位
|
|
|
|
if (param.getOtherName().contains("单箱") && deviceInstallEntity.getIsSingleBox() == 1) { |
|
|
|
if (param.getOtherName().contains("单箱")) { |
|
|
|
|
|
|
|
// 查询热泵类型的device_install以及是单箱的
|
|
|
|
|
|
|
|
deviceInstallEntity = deviceInstallMapper.selectSingleBoxDeviceInstall(deviceInstallEntity.getBuildingId(), "热泵", 1); |
|
|
|
|
|
|
|
if (deviceInstallEntity == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
// 更新单箱液位
|
|
|
|
// 更新单箱液位
|
|
|
|
nowDataMapper.updateBoxLevel(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateBoxLevel(deviceInstallEntity.getBuildingId(), |
|
|
|
null, |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
curValue.setScale(1, RoundingMode.HALF_UP).toString(), |
|
|
|
curValue.setScale(1, RoundingMode.HALF_UP).toString(), |
|
|
|
null, 1); |
|
|
|
deviceInstallEntity.getDeviceName(), 1); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// 获取多箱的液位
|
|
|
|
// 获取多箱的液位
|
|
|
|
nowDataMapper.updateBoxLevel(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateBoxLevel(deviceInstallEntity.getBuildingId(), |
|
|
|
@ -278,13 +292,24 @@ public class S7PlcCollectionJob { |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 26: // 液位设置
|
|
|
|
case 26: // 液位设置
|
|
|
|
if (param.getOtherName().contains("单箱液位") && param.getOtherName().contains("上限") && deviceInstallEntity.getIsSingleBox() == 1) { |
|
|
|
if (param.getOtherName().contains("单箱液位") && param.getOtherName().contains("上限")) { |
|
|
|
|
|
|
|
// 查询热泵类型的device_install以及是单箱的
|
|
|
|
|
|
|
|
deviceInstallEntity = deviceInstallMapper.selectSingleBoxDeviceInstall(deviceInstallEntity.getBuildingId(), "热泵", 1); |
|
|
|
|
|
|
|
if (deviceInstallEntity == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
// 更新单箱液位
|
|
|
|
// 更新单箱液位
|
|
|
|
nowDataMapper.updateBoxLevelSet(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateBoxLevelSet(deviceInstallEntity.getBuildingId(), |
|
|
|
null, |
|
|
|
deviceInstallEntity.getDeviceAddr(), |
|
|
|
curValue.setScale(1, RoundingMode.HALF_UP).toString(), |
|
|
|
curValue.setScale(1, RoundingMode.HALF_UP).toString(), |
|
|
|
null, 1); |
|
|
|
deviceInstallEntity.getDeviceName(), 1); |
|
|
|
} if (param.getOtherName().contains("多箱液位") && param.getOtherName().contains("上限") && deviceInstallEntity.getIsSingleBox() == 0) { |
|
|
|
} |
|
|
|
|
|
|
|
if (param.getOtherName().contains("多箱液位") && param.getOtherName().contains("上限")) { |
|
|
|
|
|
|
|
// 查询热泵类型的device_install以及是单箱的
|
|
|
|
|
|
|
|
deviceInstallEntity = deviceInstallMapper.selectSingleBoxDeviceInstall(deviceInstallEntity.getBuildingId(), "热泵", 0); |
|
|
|
|
|
|
|
if (deviceInstallEntity == null) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
// 获取多箱的液位
|
|
|
|
// 获取多箱的液位
|
|
|
|
nowDataMapper.updateBoxLevelSet(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateBoxLevelSet(deviceInstallEntity.getBuildingId(), |
|
|
|
null, |
|
|
|
null, |
|
|
|
@ -301,6 +326,7 @@ public class S7PlcCollectionJob { |
|
|
|
nowDataMapper.updateBackWaterTemp(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updateBackWaterTemp(deviceInstallEntity.getBuildingId(), |
|
|
|
null, |
|
|
|
null, |
|
|
|
curValue.setScale(1, RoundingMode.HALF_UP).toString(), null); |
|
|
|
curValue.setScale(1, RoundingMode.HALF_UP).toString(), null); |
|
|
|
|
|
|
|
nowPublicDataMapper.updateBackWaterTemp(Long.valueOf(deviceInstallEntity.getBuildingId()), curValue.setScale(1, RoundingMode.HALF_UP).toString()); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case 3: // 故障状态
|
|
|
|
case 3: // 故障状态
|
|
|
|
nowDataMapper.updatePressureSet(deviceInstallEntity.getBuildingId(), |
|
|
|
nowDataMapper.updatePressureSet(deviceInstallEntity.getBuildingId(), |
|
|
|
|