|
@@ -0,0 +1,208 @@
|
|
|
|
|
+package vip.xiaonuo.coldchain.core.service.dataprocess.dataclean.impl;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.collection.ListUtil;
|
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.context.ApplicationEventPublisher;
|
|
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
|
|
+import vip.xiaonuo.coldchain.core.bean.influxdb.SensorData;
|
|
|
|
|
+import vip.xiaonuo.coldchain.core.service.dataprocess.dataclean.MonitorDataProcessor;
|
|
|
|
|
+import vip.xiaonuo.coldchain.core.service.dataprocess.model.MeilingColdChainMessageData;
|
|
|
|
|
+import vip.xiaonuo.coldchain.modular.monitordevice.enums.DeviceModelEnum;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 美菱冰箱ModbusRTU协议温度处理
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author zj
|
|
|
|
|
+ * @date 2025/12/04
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Component(MonitorDataProcessor.ML_WD_MODBUS)
|
|
|
|
|
+public class ModbusMeilingTempProcessor extends AbsMeilingMonitorDataProcessor {
|
|
|
|
|
+
|
|
|
|
|
+ public ModbusMeilingTempProcessor(ApplicationEventPublisher applicationEventPublisher) {
|
|
|
|
|
+ super(applicationEventPublisher);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ List<SensorData> transRealTimeData2SensorDatas(MeilingColdChainMessageData meilingColdChainMessageData) {
|
|
|
|
|
+ String data = meilingColdChainMessageData.getHexData();
|
|
|
|
|
+ //解析数据
|
|
|
|
|
+ //查询设备id
|
|
|
|
|
+ String[] split = data.split(" ");
|
|
|
|
|
+ //长度
|
|
|
|
|
+ //前两位温度
|
|
|
|
|
+ String valueHex = split[3] + split[4];
|
|
|
|
|
+ int tempure = Integer.parseInt(valueHex, 16);
|
|
|
|
|
+ if(tempure==0){
|
|
|
|
|
+ tempure = Integer.parseInt("FFFF", 16);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String valueHex2 = split[5] + split[6];
|
|
|
|
|
+ int tempure2 = Integer.parseInt(valueHex2, 16);
|
|
|
|
|
+ if(tempure2==0){
|
|
|
|
|
+ tempure2 = Integer.parseInt("FFFF", 16);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+// //后两位故障码
|
|
|
|
|
+// String valueHex3 = split[7]+split[8];
|
|
|
|
|
+// BigInteger a1 = new BigInteger(valueHex3,16);
|
|
|
|
|
+// log.info("故障1: "+ transFault(new StringBuffer(a1.toString(2)).reverse().toString()));
|
|
|
|
|
+//
|
|
|
|
|
+// String valueHex4 = split[9]+split[10];
|
|
|
|
|
+// BigInteger a2 = new BigInteger(valueHex4,16);
|
|
|
|
|
+// log.info("故障2: "+ transFault2(new StringBuffer(a2.toString(2)).reverse().toString()));
|
|
|
|
|
+
|
|
|
|
|
+ //温度1
|
|
|
|
|
+ SensorData sensorData = defaultSensorData(meilingColdChainMessageData);
|
|
|
|
|
+ String formatted = String.format("%.2f", NumberUtil.div((tempure -Integer.parseInt("FFFF", 16) - 100), 10, 2));
|
|
|
|
|
+ float temperatureFloat = Float.parseFloat(formatted);
|
|
|
|
|
+ sensorData.setTemperature(temperatureFloat);
|
|
|
|
|
+ //设置路数
|
|
|
|
|
+ sensorData.setRoads(1);
|
|
|
|
|
+ //温度2
|
|
|
|
|
+ SensorData sensorData2 = defaultSensorData(meilingColdChainMessageData);
|
|
|
|
|
+ String formatted2 = String.format("%.2f", NumberUtil.div((tempure2 - Integer.parseInt("FFFF", 16) - 100), 10, 2));
|
|
|
|
|
+ float temperatureFloat2 = Float.parseFloat(formatted2);
|
|
|
|
|
+ sensorData2.setTemperature(temperatureFloat2);
|
|
|
|
|
+ //设置路数
|
|
|
|
|
+ sensorData2.setRoads(2);
|
|
|
|
|
+ //判断数据有效性
|
|
|
|
|
+ if(sensorData.getTemperature()>30 || sensorData.getTemperature()<-86
|
|
|
|
|
+ || sensorData2.getTemperature()>30 || sensorData2.getTemperature()<-86){
|
|
|
|
|
+ log.error("无效数据 sensorData1={} sensorData2 ={}", JSONObject.toJSONString(sensorData),JSONObject.toJSONString(sensorData2));
|
|
|
|
|
+ return ListUtil.empty();
|
|
|
|
|
+ }
|
|
|
|
|
+ return ListUtil.of(sensorData, sensorData2);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ DeviceModelEnum deviceModel() {
|
|
|
|
|
+ return DeviceModelEnum.ML_WD_MODBUS;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 故障码1转换
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param code 代码
|
|
|
|
|
+ * @return {@link String }
|
|
|
|
|
+ */
|
|
|
|
|
+ private String transFault(String code) {
|
|
|
|
|
+ StringBuffer stricodengBuffer = new StringBuffer("");
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 0, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("柜温高温报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 1, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("柜温低温报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 2, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("电池电量低报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 3, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("电压过低报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 4, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("电压过高报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 5, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("断电报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 6, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("PT100探头报警(Z06-RT1)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 7, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("环温探头报警(Z06-RT2)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 8, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("冷凝器探头报警(Z06-RT3)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 9, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("加热探头报警(Z06-RT4)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 10, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)(Z06-RT5)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 11, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)(Z06-RT6)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 12, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)(Z06-湿度探头)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 13, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("冷凝温度过高报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 14, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("环温低报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 15, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("环温高报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ return stricodengBuffer.toString();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 故障码2转换
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param code 代码
|
|
|
|
|
+ * @return {@link String }
|
|
|
|
|
+ */
|
|
|
|
|
+ private String transFault2(String code) {
|
|
|
|
|
+ StringBuffer stricodengBuffer = new StringBuffer("");
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 0, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("开门报警").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 1, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)(高湿报警)(下室高温报警)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 2, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)(低湿报警)(下室低温报警)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 3, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 4, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 5, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 6, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 7, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)(Z06-RT2)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 8, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 9, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 10, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 11, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 12, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 13, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 14, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.equalsCharAt(code, 15, '1')) {
|
|
|
|
|
+ stricodengBuffer.append("0(预留)").append("+");
|
|
|
|
|
+ }
|
|
|
|
|
+ return stricodengBuffer.toString();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+}
|