CZT
2023-11-27 c206acfaedc69c390fb67daa81bc686f58a212ef
igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/grainv1/msg/AnalysisService.java
@@ -6,7 +6,9 @@
import com.ld.igds.constant.BizType;
import com.ld.igds.constant.Constant;
import com.ld.igds.constant.DepotType;
import com.ld.igds.constant.RedisConst;
import com.ld.igds.grain.GrainUtil;
import com.ld.igds.grain.dto.GrainData;
import com.ld.igds.grain.dto.GrainItemInfo;
import com.ld.igds.io.notify.NotifyGrainInvoker;
import com.ld.igds.models.*;
@@ -19,6 +21,7 @@
import com.ld.igds.protocol.bhzn.grainv1.server.BhznGrainV1ServerUtils;
import com.ld.igds.util.BytesUtil;
import com.ld.igds.util.ContextUtil;
import com.ld.igds.util.RedisUtil;
import com.ld.igds.warn.WarnUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@@ -49,6 +52,8 @@
    public static final String BEAN_ID = "bhznGrainv1.analysisService";
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private CoreSerService coreSerService;
    @Autowired
    private BhznGrainV1ServerEngine serverEngine;
@@ -68,12 +73,19 @@
     */
    public void analysis(String sessionKey, IoMessage message) throws Exception {
        String companyId = ContextUtil.getDefaultCompanyId();
        //FZZY云服务器-许昌军粮
        if("1000".equals(companyId)){
            companyId = "5323";
        }
        message.setCompanyId(companyId);
        //注册
        if (BhznGrainV1ServerUtils.FUNCTION_ID_F1.equals(message.getFunctionId())) {
            //DO NOTHING
            log.info("主机------->>平台:注册信息报文={}", message);
            DeviceSer ser = coreSerService.getCacheSerBySn("5323",message.getAddr());
            DeviceSer ser = coreSerService.getCacheSerBySn(message.getCompanyId(), message.getAddr());
            if(ser!= null ){
                ser.setIp(message.getIp());
                ser.setPort(message.getPort());
@@ -111,7 +123,7 @@
            //根据分机地址获取分机信息
            DeviceSer ser = coreSerService.getCacheSer("5323", message.getAddr());
            DeviceSer ser = coreSerService.getCacheSer(message.getCompanyId(), message.getAddr());
            if (ser == null) {
                replayGrain(message);
                log.error("主机-------->>平台,解析粮情失败,未获取到系统粮情主机配置:" + message.getAddr());
@@ -158,7 +170,7 @@
            int cableY = 1;
            int cableX = 1;
            if(DepotType.TYPE_01.equals(depot.getDepotType())){
            if(DepotType.TYPE_01.getCode().equals(depot.getDepotType())){
                cableZ = Integer.valueOf(attCable[0]);
                cableY = Integer.valueOf(attCable[1]);
                cableX = Integer.valueOf(attCable[2]);
@@ -239,7 +251,7 @@
        int cableY = 1;
        int cableX = 1;
        if(DepotType.TYPE_01.equals(depot.getDepotType())){
        if(DepotType.TYPE_01.getCode().equals(depot.getDepotType())){
            cableZ = Integer.valueOf(attCable[0]);
            cableY = Integer.valueOf(attCable[1]);
            cableX = Integer.valueOf(attCable[2]);
@@ -286,12 +298,13 @@
        if (null != thDto) {
            log.debug("-------THDto--={}", thDto.toString());
        }
        //清空
        String key = "GRAIN_" + message.getAddr();
        contextMapGrain.put(key, null);
        // 将集合解析成坐标数据
        addPoint1(temps, depotConf, ser, exeRequest, thDto, sysConf, batchId);
    }
@@ -326,7 +339,7 @@
        int cableY = 1;
        int cableX = 1;
        if(DepotType.TYPE_01.equals(depot.getDepotType())){
        if(DepotType.TYPE_01.getCode().equals(depot.getDepotType())){
            cableZ = Integer.valueOf(attCable[0]);
            cableY = Integer.valueOf(attCable[1]);
            cableX = Integer.valueOf(attCable[2]);
@@ -337,6 +350,9 @@
        }
        Grain grain = new Grain();
        grain.setDepotId(depotConf.getDepotId());
        grain.setCompanyId(depotConf.getCompanyId());
@@ -345,6 +361,14 @@
        grain.setBatchId(batchId);
        grain.setTempIn(Constant.ERROR_TEMP);
        grain.setHumidityIn(Constant.ERROR_TEMP);
        //如果是油罐仓
        if(DepotType.TYPE_03.getCode().equals(depot.getDepotType())){
            GrainData tempData = (GrainData) redisUtil.get(RedisConst.buildKey(ser.getCompanyId(),RedisConst.KEY_DEPOT_HEIGHT,depot.getId()));
            if(null != tempData){
                //TODO
            }
        }
        if (null != thDto) {
            log.debug("粮情解析中获取到的温湿度信息={}", thDto.toString());
@@ -476,7 +500,7 @@
    private void analysisTh(IoMessage message) {
        try {
            THDto th = new THDto();
            th.setCompanyId("5323");
            th.setCompanyId(message.getCompanyId());
            String data = message.getContent();
            String houseNo = data.substring(0, 2);
            String t = data.substring(4, 8);