张磊磊
2023-10-30 84b684918a5533b444d770342faa9bacbd8349ea
hd/pipe/materialsManage/src/main/java/com/thhy/materials/modules/biz/helmet/smoke/SmokeMessage.java
@@ -1,7 +1,6 @@
package com.thhy.materials.modules.biz.helmet.smoke;
import com.alibaba.fastjson.JSONObject;
import com.thhy.materials.modules.biz.helmet.entity.TDataSmock;
import com.thhy.materials.modules.biz.helmet.mapper.HelmetMapper;
import com.thhy.materials.modules.biz.helmet.service.HelmetService;
import com.thhy.materials.modules.biz.utils.ApplicationContextUtil;
import io.netty.buffer.ByteBuf;
@@ -11,12 +10,7 @@
import io.netty.util.CharsetUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@Component
public class SmokeMessage extends SimpleChannelInboundHandler<ByteBuf>{
@@ -53,27 +47,54 @@
        System.out.println("客户端接收到消息: " + in.toString(CharsetUtil.UTF_8));
        JSONObject jsonObject11 = JSONObject.parseObject(in.toString(CharsetUtil.UTF_8));
        System.out.println("客户端接收到消息: " + jsonObject11);
        Object time = jsonObject11.get("time");
        String parems = jsonObject11.get("params").toString();
        JSONObject jsonObject = JSONObject.parseObject(parems);
        System.out.println(time+"-------------"+jsonObject);
        TDataSmock tDataSmock = new TDataSmock();
        tDataSmock.setGatewayCyc(jsonObject11.get("gateway_cyc").toString());
        tDataSmock.setFans(jsonObject11.get("FanS").toString());
        tDataSmock.setV1run(jsonObject11.get("V1Run").toString());
        tDataSmock.setUv1run(jsonObject11.get("UV1Run").toString());
        tDataSmock.setFanrun(jsonObject11.get("FanRun").toString());
        tDataSmock.setUv2run(jsonObject11.get("UV2Run").toString());
        tDataSmock.setSsvrun(jsonObject11.get("SSVRun").toString());
        tDataSmock.setDp(jsonObject11.get("DP").toString());
        tDataSmock.setT(jsonObject11.get("T").toString());
        tDataSmock.setOc(jsonObject11.get("OC").toString());
        tDataSmock.setGatew(jsonObject11.get("gatew").toString());
        tDataSmock.setNxrun(jsonObject11.get("NXRun").toString());
        tDataSmock.setTimes(jsonObject11.get("time").toString());
        tDataSmock.setRtcVolt(jsonObject11.get("RTC_VOLT").toString());
        tDataSmock.setV2run(jsonObject11.get("V2Run").toString());
        tDataSmock.setDxqvrun(jsonObject11.get("DXQVRun").toString());
        tDataSmock.setPress(jsonObject11.get("Press").toString());
        tDataSmock.setDc(jsonObject11.get("Dc").toString());
        System.out.println("-------"+tDataSmock);
        getUserService().smockIn(tDataSmock);
        tDataSmock.setTime(time.toString());
        tDataSmock.setI00(jsonObject.get("I00").toString().equals("true")?"开启":"关闭");
        tDataSmock.setI01(jsonObject.get("I01").toString().equals("true")?"开启":"关闭");
        tDataSmock.setI02(jsonObject.get("I02").toString().equals("true")?"开启":"关闭");
        tDataSmock.setI03(jsonObject.get("I03").toString().equals("true")?"开启":"关闭");
        tDataSmock.setI04(jsonObject.get("I04").toString().equals("true")?"开启":"关闭");
        tDataSmock.setI05(jsonObject.get("I05").toString().equals("true")?"开启":"关闭");
        tDataSmock.setI06(jsonObject.get("I06").toString().equals("true")?"开启":"关闭");
        tDataSmock.setI07(jsonObject.get("I07").toString().equals("true")?"开启":"关闭");
        tDataSmock.setI10(jsonObject.get("I10").toString().equals("true")?"开启":"关闭");
        tDataSmock.setI11(jsonObject.get("I11").toString().equals("true")?"开启":"关闭");
        tDataSmock.setQ00(jsonObject.get("Q00").toString().equals("true")?"运行中":"停止状态");
        tDataSmock.setQ01(jsonObject.get("Q01").toString().equals("true")?"运行中":"停止状态");
        tDataSmock.setQ02(jsonObject.get("Q02").toString().equals("true")?"运行中":"停止状态");
        tDataSmock.setQ03(jsonObject.get("Q03").toString().equals("true")?"运行中":"停止状态");
        tDataSmock.setQ04(jsonObject.get("Q04").toString().equals("true")?"运行中":"停止状态");
        tDataSmock.setQ05(jsonObject.get("Q05").toString().equals("true")?"运行中":"停止状态");
        tDataSmock.setVb0(jsonObject.get("VB0").toString());
        tDataSmock.setVb10(jsonObject.get("VB10").toString());
        tDataSmock.setVb11(jsonObject.get("VB11").toString());
        tDataSmock.setVb12(jsonObject.get("VB12").toString());
//        TDataSmock tDataSmock = new TDataSmock();
//        tDataSmock.setGatewayCyc(jsonObject11.get("gateway_cyc").toString());
//        tDataSmock.setFans(jsonObject11.get("FanS").toString());
//        tDataSmock.setV1run(jsonObject11.get("V1Run").toString());
//        tDataSmock.setUv1run(jsonObject11.get("UV1Run").toString());
//        tDataSmock.setFanrun(jsonObject11.get("FanRun").toString());
//        tDataSmock.setUv2run(jsonObject11.get("UV2Run").toString());
//        tDataSmock.setSsvrun(jsonObject11.get("SSVRun").toString());
//        tDataSmock.setDp(jsonObject11.get("DP").toString());
//        tDataSmock.setT(jsonObject11.get("T").toString());
//        tDataSmock.setOc(jsonObject11.get("OC").toString());
//        tDataSmock.setGatew(jsonObject11.get("gatew").toString());
//        tDataSmock.setNxrun(jsonObject11.get("NXRun").toString());
//        tDataSmock.setTimes(jsonObject11.get("time").toString());
//        tDataSmock.setRtcVolt(jsonObject11.get("RTC_VOLT").toString());
//        tDataSmock.setV2run(jsonObject11.get("V2Run").toString());
//        tDataSmock.setDxqvrun(jsonObject11.get("DXQVRun").toString());
//        tDataSmock.setPress(jsonObject11.get("Press").toString());
//        tDataSmock.setDc(jsonObject11.get("Dc").toString());
//        System.out.println("-------"+tDataSmock);
       getUserService().smockIn(tDataSmock);
    }
    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {