home il y a 2 ans
Parent
commit
06ea66edd0

+ 46 - 0
hx-service-api/syringe-production-api/src/main/java/com/fjhx/enums/UpperComputerEnum.java

@@ -0,0 +1,46 @@
+package com.fjhx.enums;
+
+import lombok.Getter;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Getter
+public enum UpperComputerEnum {
+
+    ZSJ(1, "注塑机"),
+    GYJ(2, "滚印机"),
+    ZZJ(3, "组装机"),
+    LWT(4, "螺纹头"),
+    ZSZ(5, "注射针");
+
+    /**
+     * 设备类型
+     */
+    private final Integer type;
+    /**
+     * 类型名称
+     */
+    private final String typeName;
+
+    UpperComputerEnum(Integer type, String typeName) {
+        this.type = type;
+        this.typeName = typeName;
+    }
+
+    private static final Map<Integer, UpperComputerEnum> CLASS_MAP = new HashMap<>();
+
+    static {
+        for (UpperComputerEnum value : UpperComputerEnum.values()) {
+            CLASS_MAP.put(value.getType(), value);
+        }
+    }
+
+    /**
+     * 根据设备id获取枚举
+     */
+    public static UpperComputerEnum getUpperComputerEnum(Integer type) {
+        return CLASS_MAP.get(type);
+    }
+
+}

+ 28 - 0
hx-service-api/syringe-production-api/src/main/java/com/fjhx/params/IotData/OpcUaData.java

@@ -0,0 +1,28 @@
+package com.fjhx.params.IotData;
+
+import lombok.Data;
+
+@Data
+public class OpcUaData {
+
+    /**
+     * 节点id
+     */
+    private String id;
+
+    /**
+     * 节点名称
+     */
+    private String nodeName;
+
+    /**
+     * ns
+     */
+    private String ns;
+
+    /**
+     * 节点类型
+     */
+    private String type;
+
+}

+ 100 - 0
hx-service-api/syringe-production-api/src/main/java/com/fjhx/params/IotData/ZSJDto.java

@@ -0,0 +1,100 @@
+package com.fjhx.params.IotData;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+public class ZSJDto {
+
+    /**
+     * 在线状态(设备状态)
+     * 0:离线
+     * 1:在线
+     */
+    private Integer tmOnlineState;
+
+    /**
+     * 操作状态(工作模式)
+     * 0:手动
+     * 1:半自动
+     * 2:电眼自动
+     * 3:时间自动
+     * 4:调模使用
+     * >=5 其它
+     */
+    private Integer tmOperateMode;
+
+    /**
+     * 马达状态(模具状态)
+     * 0:关
+     * 1:开
+     */
+    private Integer tmMotorState;
+
+    /**
+     * 电热状态(液压机)
+     * 0:关
+     * 1:开
+     */
+    private Integer tmHeatState;
+
+    /**
+     * 油温(液压油温度)
+     * 原名(tmTempOil_Current)
+     */
+    private BigDecimal tmTempOilCurrent;
+
+    /**
+     * 实际温度(简体温度)
+     * ( tmTemp1_Current ~ tmTemp9_Current )平均值
+     */
+    private BigDecimal tmTempCurrent;
+
+    /**
+     * 储料1段压力B(通道1)
+     */
+    private BigDecimal tmChargePressB1;
+
+    /**
+     * 储料2段压力B(通道2)
+     */
+    private BigDecimal tmChargePressB2;
+
+    /**
+     * 储料3段压力B(通道3)
+     */
+    private BigDecimal tmChargePressB3;
+
+    /**
+     * 储料4段压力B(通道4)
+     */
+    private BigDecimal tmChargePressB4;
+
+    /**
+     * 储料1段速度 B(速度1)
+     */
+    private BigDecimal tmChargeSpeedB1;
+
+    /**
+     * 储料2段速度 B(速度2)
+     */
+    private BigDecimal tmChargeSpeedB2;
+
+    /**
+     * 储料3段速度 B(速度3)
+     */
+    private BigDecimal tmChargeSpeedB3;
+
+    /**
+     * 储料4段速度 B(速度4)
+     */
+    private BigDecimal tmChargeSpeedB4;
+
+    /**
+     * 上传时间
+     */
+    private Date date;
+
+}

+ 77 - 0
hx-service/syringe-production/src/main/java/com/fjhx/listener/IotDataListener.java

@@ -1,13 +1,18 @@
 package com.fjhx.listener;
 
+import cn.hutool.core.convert.Convert;
 import com.alibaba.fastjson.JSONObject;
 import com.fjhx.constants.RedisConstant;
 import com.fjhx.enums.ProductEnum;
+import com.fjhx.enums.UpperComputerEnum;
 import com.fjhx.params.IotData.MessageBody;
+import com.fjhx.params.IotData.OpcUaData;
 import com.fjhx.params.IotData.UpperComputerData;
+import com.fjhx.params.IotData.ZSJDto;
 import com.fjhx.utils.amqp.AmqpClient;
 import com.fjhx.utils.amqp.AmqpClientOptions;
 import com.fjhx.utils.amqp.AmqpConstants;
+import lombok.extern.slf4j.Slf4j;
 import org.springblade.core.redis.cache.BladeRedis;
 import org.springframework.stereotype.Component;
 
@@ -16,13 +21,18 @@ import javax.annotation.Resource;
 import javax.jms.JMSException;
 import javax.jms.Message;
 import javax.jms.MessageConsumer;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * iot数据推送监听器
  *
  * @author zlj
  */
+@Slf4j
 @Component
 public class IotDataListener {
 
@@ -129,6 +139,13 @@ public class IotDataListener {
 
         UpperComputerData newData = service.getProperties().toJavaObject(UpperComputerData.class);
 
+        UpperComputerEnum upperComputerEnum = UpperComputerEnum.getUpperComputerEnum(newData.getType());
+
+        if (upperComputerEnum == UpperComputerEnum.ZSJ) {
+            handleZSJ(message, newData);
+            return;
+        }
+
         String redisKey = RedisConstant.DEVICE_PREFIX + newData.getEquipmentNo();
         UpperComputerData oldData = redisCache.get(redisKey);
 
@@ -141,7 +158,67 @@ public class IotDataListener {
         } catch (JMSException e) {
             e.printStackTrace();
         }
+    }
+
+    /**
+     * 注塑机解析
+     */
+    private void handleZSJ(Message message, UpperComputerData upperComputerData) {
+
+        log.error("注塑机推送数据:{}", JSONObject.toJSONString(upperComputerData));
+
+        String redisKey = RedisConstant.DEVICE_PREFIX + upperComputerData.getEquipmentNo();
+        ZSJDto oldZsjDto = redisCache.get(redisKey);
+        if (oldZsjDto != null && upperComputerData.getCreateTime().compareTo(oldZsjDto.getDate()) > 0) {
+            return;
+        }
+        ZSJDto zsjDto = createZSJDto(upperComputerData);
+        redisCache.set(redisKey, zsjDto);
+
+        try {
+            message.acknowledge();
+        } catch (JMSException e) {
+            e.printStackTrace();
+        }
+    }
+
 
+    private ZSJDto createZSJDto(UpperComputerData upperComputerData) {
+        List<OpcUaData> opcUaDataList = Convert.toList(OpcUaData.class, upperComputerData.getData());
+
+        Map<String, String> collect = opcUaDataList.stream().collect(Collectors.toMap(
+                OpcUaData::getId,
+                OpcUaData::getNs
+        ));
+
+        ZSJDto zsjDto = new ZSJDto();
+        zsjDto.setDate(upperComputerData.getCreateTime());
+        zsjDto.setTmOnlineState(Convert.toInt(collect.get("tmOnlineState")));
+        zsjDto.setTmOperateMode(Convert.toInt(collect.get("tmOperateMode")));
+        zsjDto.setTmMotorState(Convert.toInt(collect.get("tmMotorState")));
+        zsjDto.setTmHeatState(Convert.toInt(collect.get("tmHeatState")));
+        zsjDto.setTmTempOilCurrent(Convert.toBigDecimal(collect.get("tmTempOil_Current")));
+
+        BigDecimal tmTempCurrent = Convert.toBigDecimal(collect.get("tmTemp1_Current"))
+                .add(Convert.toBigDecimal(collect.get("tmTemp2_Current")))
+                .add(Convert.toBigDecimal(collect.get("tmTemp3_Current")))
+                .add(Convert.toBigDecimal(collect.get("tmTemp4_Current")))
+                .add(Convert.toBigDecimal(collect.get("tmTemp5_Current")))
+                .add(Convert.toBigDecimal(collect.get("tmTemp6_Current")))
+                .add(Convert.toBigDecimal(collect.get("tmTemp7_Current")))
+                .add(Convert.toBigDecimal(collect.get("tmTemp8_Current")))
+                .add(Convert.toBigDecimal(collect.get("tmTemp9_Current")))
+                .divide(new BigDecimal("9"), 1, RoundingMode.HALF_UP);
+        zsjDto.setTmTempCurrent(tmTempCurrent);
+        zsjDto.setTmChargePressB1(Convert.toBigDecimal(collect.get("tmChargePressB1")));
+        zsjDto.setTmChargePressB2(Convert.toBigDecimal(collect.get("tmChargePressB2")));
+        zsjDto.setTmChargePressB3(Convert.toBigDecimal(collect.get("tmChargePressB3")));
+        zsjDto.setTmChargePressB4(Convert.toBigDecimal(collect.get("tmChargePressB4")));
+        zsjDto.setTmChargeSpeedB1(Convert.toBigDecimal(collect.get("tmChargeSpeedB1")));
+        zsjDto.setTmChargeSpeedB2(Convert.toBigDecimal(collect.get("tmChargeSpeedB2")));
+        zsjDto.setTmChargeSpeedB3(Convert.toBigDecimal(collect.get("tmChargeSpeedB3")));
+        zsjDto.setTmChargeSpeedB4(Convert.toBigDecimal(collect.get("tmChargeSpeedB4")));
+        return zsjDto;
     }
 
 }

+ 11 - 5
hx-service/syringe-production/src/main/java/com/fjhx/mapper/tda/TdaApplicationMapper.xml

@@ -3,11 +3,17 @@
 <mapper namespace="com.fjhx.mapper.tda.TdaApplicationMapper">
 
     <select id="getDetails" resultType="java.util.Map">
-        select (select count(0) from tda_product tp where tp.tda_application_id = #{id}) productCount,
-               (select count(0)
-                from tda_product tp
-                         inner join tda_device td on td.tda_product_id = tp.id
-                where tp.tda_application_id = #{id})                                     deviceCount
+        select (
+                   select count(0)
+                   from tda_product tp
+                   where tp.tda_application_id = #{id}
+               ) productCount,
+               (
+                   select count(0)
+                   from tda_product tp
+                            inner join tda_device td on td.tda_product_id = tp.id
+                   where tp.tda_application_id = #{id}
+               ) deviceCount
     </select>
 
 </mapper>

+ 1 - 0
hx-service/victoriatourist/src/main/java/com/fjhx/service/order/impl/OrderInfoInfoServiceImpl.java

@@ -123,6 +123,7 @@ public class OrderInfoInfoServiceImpl extends ServiceImpl<OrderInfoMapper, Order
         orderVo.setAmountMoney(amountMoney);
 
         orderVo.setStatus(1);
+        orderVo.setIssueStatus(1);
 
         synchronized (this) {
             if (type == 3) {