Browse Source

3in1修改

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

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

@ -53,13 +53,13 @@ public interface DeviceGatherDao extends BaseMapper<DeviceGather> {
/** /**
* 查询卷号是否已存在 * 查询卷号是否已存在
*/ */
@Select("select count(1) from device_gather where roll_no = #{rollNo}")
int countByRollNo(@Param("rollNo") String rollNo);
@Select("select count(1) from device_gather where roll_no = #{rollNo} and seq_no = #{seqNo}")
int countByRollNo(@Param("rollNo") String rollNo, @Param("seqNo") String seqNo);
/** /**
* 查询是否存在active为N的数据 * 查询是否存在active为N的数据
*/ */
@Select("select count(1) from device_gather where active = 'N' and status='扫描卷'")
int countActiveN();
@Select("select count(1) from device_gather where active = 'N' and status='扫描卷'and seq_no = #{seqNo}")
int countActiveN(@Param("seqNo") String seqNo);
} }

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

@ -147,7 +147,7 @@ public class DeviceRunner implements CommandLineRunner {
// - 大卷B分切信号0x502 // - 大卷B分切信号0x502
int cuta = 500; int cuta = 500;
int cutb = 502; int cutb = 502;
int cutab = 508;
int cutab = 506;
int bit1 = collectUtil.readHoldingRegister(ip, port, cuta); int bit1 = collectUtil.readHoldingRegister(ip, port, cuta);
logger.info("卷A分切信号:{}", bit1); logger.info("卷A分切信号:{}", bit1);
// 卷B分切信号 // 卷B分切信号
@ -190,6 +190,7 @@ public class DeviceRunner implements CommandLineRunner {
String rollNo = (String) redisTemplate.opsForValue().get("device:" + ip); String rollNo = (String) redisTemplate.opsForValue().get("device:" + ip);
// 触发分切,执行方法扫描卷处理 // 触发分切,执行方法扫描卷处理
deviceGatherService.scanRollNo(deviceInfo, rollNo, nextRollNo); deviceGatherService.scanRollNo(deviceInfo, rollNo, nextRollNo);
collectUtil.writeHoldingRegister(ip, port, cutab, 0);
} }
} }
} }

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

@ -90,8 +90,8 @@ public class DeviceGatherServiceImpl implements DeviceGatherService {
private void handleData(String seqNo, String site, String rollNo, String ip) { private void handleData(String seqNo, String site, String rollNo, String ip) {
boolean rollNoNotZero = !"0".equals(rollNo); boolean rollNoNotZero = !"0".equals(rollNo);
boolean rollNoNotExists = deviceGatherDao.countByRollNo(rollNo) == 0;
boolean noActiveN = deviceGatherDao.countActiveN() == 0;
boolean rollNoNotExists = deviceGatherDao.countByRollNo(rollNo,seqNo) == 0;
boolean noActiveN = deviceGatherDao.countActiveN(seqNo) == 0;
if (rollNoNotExists && rollNoNotZero && noActiveN) { if (rollNoNotExists && rollNoNotZero && noActiveN) {
updateDeviceGather(ip, rollNo); updateDeviceGather(ip, rollNo);

Loading…
Cancel
Save