Browse Source

添加rollno更新的seqNo条件

master
shenzhouyu 2 weeks ago
parent
commit
069e70ee23
  1. 4
      glue-modbus-collector/src/main/java/com/xujie/devicecollector/dao/DeviceGatherDao.java
  2. 1
      glue-modbus-collector/src/main/java/com/xujie/devicecollector/runner/DeviceRunner.java
  3. 2
      glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/DeviceGatherService.java
  4. 8
      glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/impl/DeviceGatherServiceImpl.java

4
glue-modbus-collector/src/main/java/com/xujie/devicecollector/dao/DeviceGatherDao.java

@ -41,8 +41,8 @@ public interface DeviceGatherDao extends BaseMapper<DeviceGather> {
/**
* 更新设备采集数据(根据IP和卷号)
*/
@Update("update device_gather set roll_no = #{rollNo} where ip = #{ip} and roll_no = '*'")
void updateDeviceGather(@Param("ip") String ip, @Param("rollNo") String rollNo);
@Update("update device_gather set roll_no = #{rollNo} where ip = #{ip} and roll_no = '*' and seq_no = #{seqNo}")
void updateDeviceGather(@Param("ip") String ip, @Param("rollNo") String rollNo, @Param("seqNo") String seqNo);
/**
* 删除设备采集数据(根据IP)

1
glue-modbus-collector/src/main/java/com/xujie/devicecollector/runner/DeviceRunner.java

@ -171,6 +171,7 @@ public class DeviceRunner implements CommandLineRunner {
// 回写清零
collectUtil.writeHoldingRegister(ip, port, cuta, 0);
}
if (bit2 == 1) {
// 获取寄存器信息
List<Integer> list = getConnectData(deviceInfo);

2
glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/DeviceGatherService.java

@ -14,7 +14,7 @@ public interface DeviceGatherService {
void updateDeviceGatherStatus(DeviceGather gather);
void updateDeviceGather(String ip, String rollNo);
void updateDeviceGather(String ip, String rollNo,String seqNo);
void removeDeviceGather(String ip);

8
glue-modbus-collector/src/main/java/com/xujie/devicecollector/service/impl/DeviceGatherServiceImpl.java

@ -55,8 +55,8 @@ public class DeviceGatherServiceImpl implements DeviceGatherService {
}
@Override
public void updateDeviceGather(String ip, String rollNo) {
deviceGatherDao.updateDeviceGather(ip, rollNo);
public void updateDeviceGather(String ip, String rollNo,String seqNo) {
deviceGatherDao.updateDeviceGather(ip, rollNo,seqNo);
}
@Override
@ -94,7 +94,7 @@ public class DeviceGatherServiceImpl implements DeviceGatherService {
boolean noActiveN = deviceGatherDao.countActiveN(seqNo) == 0;
if (rollNoNotExists && rollNoNotZero && noActiveN) {
updateDeviceGather(ip, rollNo);
updateDeviceGather(ip, rollNo,seqNo);
String operatingStatus = (String) redisTemplate.opsForValue().get("operatingStatus");
DeviceGather gather = new DeviceGather(null, ip, rollNo, new Date(), "扫描卷", "N", "", 7, operatingStatus, seqNo);
saveDeviceGatherByRoll(gather);
@ -111,7 +111,7 @@ public class DeviceGatherServiceImpl implements DeviceGatherService {
String serialNo = getErrorRollNo(site);
String date = DateUtils.getDate();
String errorRollNo = "error_"+date+serialNo;
updateDeviceGather(ip, errorRollNo);
updateDeviceGather(ip, errorRollNo,seqNo);
String operatingStatus = (String) redisTemplate.opsForValue().get("operatingStatus");
DeviceGather gather = new DeviceGather(null, ip, errorRollNo, new Date(), "扫描卷", "N", "卷号获取失败", 7, operatingStatus, seqNo);
saveDeviceGatherByRoll(gather);

Loading…
Cancel
Save