|
|
|
@ -5,7 +5,6 @@ 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.*; |
|
|
|
import com.mh.user.mapper.*; |
|
|
|
import com.mh.user.model.MultiControlModel; |
|
|
|
|
|
|
|
import com.mh.user.s7.S7ConnectorUtil; |
|
|
|
import com.mh.user.s7.S7ConnectorUtil; |
|
|
|
import com.mh.user.service.NowDataService; |
|
|
|
import com.mh.user.service.NowDataService; |
|
|
|
import com.mh.user.utils.DateUtil; |
|
|
|
import com.mh.user.utils.DateUtil; |
|
|
|
@ -39,16 +38,14 @@ 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; |
|
|
|
private final NowPublicDataMapper nowPublicDataMapper; |
|
|
|
|
|
|
|
|
|
|
|
public S7PlcCollectionJob(GatewayManageMapper gatewayManageMapper, |
|
|
|
public S7PlcCollectionJob(GatewayManageMapper gatewayManageMapper, |
|
|
|
CollectionParamsManageMapper collectionParamsManageMapper, DeviceInstallMapper deviceInstallMapper, NowDataMapper nowDataMapper, NowDataMapper nowDataMapper1, NowDataService nowDataService, NowPublicDataMapper nowPublicDataMapper) { |
|
|
|
CollectionParamsManageMapper collectionParamsManageMapper, DeviceInstallMapper deviceInstallMapper, 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; |
|
|
|
this.nowPublicDataMapper = nowPublicDataMapper; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -57,13 +54,13 @@ public class S7PlcCollectionJob { |
|
|
|
* 每5分钟执行一次,可根据实际需求调整 |
|
|
|
* 每5分钟执行一次,可根据实际需求调整 |
|
|
|
* 优先处理手动操作:如果Constant.WEB_PLC_FLAG为true,则跳过本次采集 |
|
|
|
* 优先处理手动操作:如果Constant.WEB_PLC_FLAG为true,则跳过本次采集 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
// @Scheduled(cron = "0 0/5 * * * ?")
|
|
|
|
@Scheduled(cron = "0 0/5 * * * ?") |
|
|
|
public void collectS7Data() { |
|
|
|
public void collectS7Data() { |
|
|
|
log.info("------S7 PLC定时采集开始>>>>Constant.FLAG=={}------", Constant.PLC_FLAG); |
|
|
|
log.info("------S7 PLC定时采集开始>>>>Constant.FLAG=={}------", Constant.PLC_FLAG); |
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
try { |
|
|
|
// 检查是否有手动操作正在进行
|
|
|
|
// 检查是否有手动操作正在进行
|
|
|
|
if (Constant.PLC_FLAG || Constant.WEB_PLC_FLAG) { |
|
|
|
if (Constant.PLC_FLAG) { |
|
|
|
log.info("存在手动操作,跳过本次S7 PLC采集"); |
|
|
|
log.info("存在手动操作,跳过本次S7 PLC采集"); |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
@ -131,10 +128,10 @@ public class S7PlcCollectionJob { |
|
|
|
for (CollectionParamsManageEntity param : params) { |
|
|
|
for (CollectionParamsManageEntity param : params) { |
|
|
|
try { |
|
|
|
try { |
|
|
|
// 再次检查是否有手动操作
|
|
|
|
// 再次检查是否有手动操作
|
|
|
|
if (Constant.WEB_PLC_FLAG) { |
|
|
|
// if (Constant.WEB_PLC_FLAG) {
|
|
|
|
log.info("检测到手动操作,中断采集"); |
|
|
|
// log.info("检测到手动操作,中断采集");
|
|
|
|
break; |
|
|
|
// break;
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
readAndSaveData(connector, param, dateStr); |
|
|
|
readAndSaveData(connector, param, dateStr); |
|
|
|
|
|
|
|
|
|
|
|
|