|
|
@ -4815,6 +4815,7 @@ public class QcServiceImpl implements QcService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public ArrayList<SubDetailValues> getCollectorDataByItem(QcFAIRecordData data) throws Exception{ |
|
|
public ArrayList<SubDetailValues> getCollectorDataByItem(QcFAIRecordData data) throws Exception{ |
|
|
EquipmentFolderLocation location = getCollectorLocation(data.getSite()); |
|
|
EquipmentFolderLocation location = getCollectorLocation(data.getSite()); |
|
|
int port = location.getPort(); |
|
|
int port = location.getPort(); |
|
|
@ -4834,7 +4835,7 @@ public class QcServiceImpl implements QcService { |
|
|
} |
|
|
} |
|
|
ArrayList<SubDetailValues> abnormalRows = getAbnormalCollectorData(ip, port, unitId, data); |
|
|
ArrayList<SubDetailValues> abnormalRows = getAbnormalCollectorData(ip, port, unitId, data); |
|
|
|
|
|
|
|
|
resetCollectorAbnormalRegisters(ip, port, unitId); |
|
|
|
|
|
|
|
|
//resetCollectorAbnormalRegisters(ip, port, unitId); |
|
|
return abnormalRows; |
|
|
return abnormalRows; |
|
|
}else{ |
|
|
}else{ |
|
|
logger.info(port+","+ip+","+unitId+","+baseAddr+","+groups+","); |
|
|
logger.info(port+","+ip+","+unitId+","+baseAddr+","+groups+","); |
|
|
@ -4935,6 +4936,14 @@ public class QcServiceImpl implements QcService { |
|
|
return v == null ? -1 : (v & 0xFFFF); |
|
|
return v == null ? -1 : (v & 0xFFFF); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String hexReg(Map<Integer, Integer> raw, int ref) { |
|
|
|
|
|
Integer v = raw.get(ref); |
|
|
|
|
|
if (v == null) { |
|
|
|
|
|
return "null"; |
|
|
|
|
|
} |
|
|
|
|
|
return String.format(Locale.ROOT, "%04X", v & 0xFFFF); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private EquipmentFolderLocation getCollectorLocation(String site) { |
|
|
private EquipmentFolderLocation getCollectorLocation(String site) { |
|
|
LambdaQueryWrapper<EquipmentFolderLocation> wrapper = new LambdaQueryWrapper<>(); |
|
|
LambdaQueryWrapper<EquipmentFolderLocation> wrapper = new LambdaQueryWrapper<>(); |
|
|
wrapper.eq(EquipmentFolderLocation::getEquipmentNo, "J001"); |
|
|
wrapper.eq(EquipmentFolderLocation::getEquipmentNo, "J001"); |
|
|
@ -5187,7 +5196,7 @@ public class QcServiceImpl implements QcService { |
|
|
}*/ |
|
|
}*/ |
|
|
private ArrayList<SubDetailValues> getAbnormalCollectorData(String ip, int port, int unitId, QcFAIRecordData data) throws Exception { |
|
|
private ArrayList<SubDetailValues> getAbnormalCollectorData(String ip, int port, int unitId, QcFAIRecordData data) throws Exception { |
|
|
int readStartAddr = 400; |
|
|
int readStartAddr = 400; |
|
|
int readCount = 195; // 覆盖 400~594(单次 FC03 字数不宜超过从站上限,需分批读) |
|
|
|
|
|
|
|
|
int readCount = 196; // 覆盖 400~595(第10组第5路float需595,单次FC03需分批) |
|
|
Map<Integer, Integer> raw = ModbusUtils.readHoldingRegistersBatched(ip, port, unitId, readStartAddr, readCount); |
|
|
Map<Integer, Integer> raw = ModbusUtils.readHoldingRegistersBatched(ip, port, unitId, readStartAddr, readCount); |
|
|
ArrayList<SubDetailValues> subDetailValues = new ArrayList<>(); |
|
|
ArrayList<SubDetailValues> subDetailValues = new ArrayList<>(); |
|
|
if (raw == null || raw.isEmpty()) { |
|
|
if (raw == null || raw.isEmpty()) { |
|
|
@ -5205,20 +5214,32 @@ public class QcServiceImpl implements QcService { |
|
|
timeParts.add(timeValue == null ? 0 : (timeValue & 0xFFFF)); |
|
|
timeParts.add(timeValue == null ? 0 : (timeValue & 0xFFFF)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 异常数据地址按32位float读取(高字在前):406/408/410/412/414 ... |
|
|
|
|
|
|
|
|
// 异常 float:高/低字在前自动择优(屏显地址与 PDU ref 可能差 1,不能固定低字在前) |
|
|
List<Float> abnormalValues = new ArrayList<>(); |
|
|
List<Float> abnormalValues = new ArrayList<>(); |
|
|
for (int i = 0; i < 5; i++) { |
|
|
for (int i = 0; i < 5; i++) { |
|
|
int highRef = abnormalStartAddr + (i * 2); |
|
|
|
|
|
int lowRef = highRef + 1; |
|
|
|
|
|
Integer high = raw.get(highRef); |
|
|
|
|
|
Integer low = raw.get(lowRef); |
|
|
|
|
|
if (high != null && low != null) { |
|
|
|
|
|
int bits = (high << 16) | (low & 0xFFFF); |
|
|
|
|
|
abnormalValues.add(Float.intBitsToFloat(bits)); |
|
|
|
|
|
|
|
|
int regRef = abnormalStartAddr + (i * 2); |
|
|
|
|
|
int regRefNext = regRef + 1; |
|
|
|
|
|
Integer reg0 = raw.get(regRef); |
|
|
|
|
|
Integer reg1 = raw.get(regRefNext); |
|
|
|
|
|
if (reg0 != null && reg1 != null) { |
|
|
|
|
|
abnormalValues.add(ModbusUtils.parseAbnormalCollectorFloat(reg0, reg1)); |
|
|
} else { |
|
|
} else { |
|
|
abnormalValues.add(0F); |
|
|
abnormalValues.add(0F); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
if (groupIdx == 0) { |
|
|
|
|
|
logger.info("异常区原始寄存器(屏显约40406起): r{}=0x{}, r{}=0x{}, r{}=0x{}, r{}=0x{}, r{}=0x{}, r{}=0x{}, r{}=0x{}, r{}=0x{}, r{}=0x{}, r{}=0x{}", |
|
|
|
|
|
abnormalStartAddr, hexReg(raw, abnormalStartAddr), |
|
|
|
|
|
abnormalStartAddr + 1, hexReg(raw, abnormalStartAddr + 1), |
|
|
|
|
|
abnormalStartAddr + 2, hexReg(raw, abnormalStartAddr + 2), |
|
|
|
|
|
abnormalStartAddr + 3, hexReg(raw, abnormalStartAddr + 3), |
|
|
|
|
|
abnormalStartAddr + 4, hexReg(raw, abnormalStartAddr + 4), |
|
|
|
|
|
abnormalStartAddr + 5, hexReg(raw, abnormalStartAddr + 5), |
|
|
|
|
|
abnormalStartAddr + 6, hexReg(raw, abnormalStartAddr + 6), |
|
|
|
|
|
abnormalStartAddr + 7, hexReg(raw, abnormalStartAddr + 7), |
|
|
|
|
|
abnormalStartAddr + 8, hexReg(raw, abnormalStartAddr + 8), |
|
|
|
|
|
abnormalStartAddr + 9, hexReg(raw, abnormalStartAddr + 9)); |
|
|
|
|
|
} |
|
|
logger.info("获取到的数据:{},时间:{}",abnormalValues.toString(),timeParts.toString()); |
|
|
logger.info("获取到的数据:{},时间:{}",abnormalValues.toString(),timeParts.toString()); |
|
|
|
|
|
|
|
|
boolean hasAbnormal = abnormalValues.stream().anyMatch(v -> v != 0F); |
|
|
boolean hasAbnormal = abnormalValues.stream().anyMatch(v -> v != 0F); |
|
|
@ -5239,7 +5260,7 @@ public class QcServiceImpl implements QcService { |
|
|
detailValues.setIsSubmit("N"); |
|
|
detailValues.setIsSubmit("N"); |
|
|
detailValues.setSite(data.getSite()); |
|
|
detailValues.setSite(data.getSite()); |
|
|
detailValues.setNum(1); |
|
|
detailValues.setNum(1); |
|
|
detailValues.setSubDetailValue(String.valueOf(abnormalValues.get(i))); |
|
|
|
|
|
|
|
|
detailValues.setSubDetailValue(ModbusUtils.formatFloat4Decimals(abnormalValues.get(i))); |
|
|
detailValues.setSubDetailValueB(collectedTime); |
|
|
detailValues.setSubDetailValueB(collectedTime); |
|
|
detailValues.setSamplingLocationB(collectedTime); |
|
|
detailValues.setSamplingLocationB(collectedTime); |
|
|
subDetailValues.add(detailValues); |
|
|
subDetailValues.add(detailValues); |
|
|
@ -5250,21 +5271,24 @@ public class QcServiceImpl implements QcService { |
|
|
return subDetailValues; |
|
|
return subDetailValues; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 无工单异常采集复位:300/301/302 + 10 组时间(6 寄存器)与异常 float 高字寄存器(5 路×2 字取高字地址)。 |
|
|
|
|
|
*/ |
|
|
private void resetCollectorAbnormalRegisters(String ip, int port, int unitId) { |
|
|
private void resetCollectorAbnormalRegisters(String ip, int port, int unitId) { |
|
|
List<Integer> resetAddrs = new ArrayList<>(Arrays.asList( |
|
|
|
|
|
302, |
|
|
|
|
|
406, 408, 410, 412, 414, |
|
|
|
|
|
426, 428, 430, 432, 434, |
|
|
|
|
|
446, 448, 450, 452, 454, |
|
|
|
|
|
466, 468, 470, 472, 474, |
|
|
|
|
|
486, 488, 490, 492, 494, |
|
|
|
|
|
506, 508, 510, 512, 514, |
|
|
|
|
|
526, 528, 530, 532, 534, |
|
|
|
|
|
546, 548, 550, 552, 554, |
|
|
|
|
|
566, 568, 570, 572, 574, |
|
|
|
|
|
586, 588, 590, 592, 594 |
|
|
|
|
|
)); |
|
|
|
|
|
logger.info("开始复位"); |
|
|
|
|
|
|
|
|
List<Integer> resetAddrs = new ArrayList<>(); |
|
|
|
|
|
resetAddrs.add(301); |
|
|
|
|
|
resetAddrs.add(302); |
|
|
|
|
|
for (int groupIdx = 0; groupIdx < 10; groupIdx++) { |
|
|
|
|
|
int timeStartAddr = 400 + (groupIdx * 20); |
|
|
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
|
|
resetAddrs.add(timeStartAddr + i); |
|
|
|
|
|
} |
|
|
|
|
|
int abnormalStartAddr = 406 + (groupIdx * 20); |
|
|
|
|
|
for (int i = 0; i < 5; i++) { |
|
|
|
|
|
resetAddrs.add(abnormalStartAddr + (i * 2)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
logger.info("开始复位, 共 {} 个寄存器", resetAddrs.size()); |
|
|
ModbusUtils.resetRegisters(ip, port, unitId, resetAddrs); |
|
|
ModbusUtils.resetRegisters(ip, port, unitId, resetAddrs); |
|
|
logger.info("复位结束"); |
|
|
logger.info("复位结束"); |
|
|
} |
|
|
} |
|
|
|