vince
2023-09-04 e241acb82959328535d8f903902863bd420df139
igds-protocol-bhzn/src/main/java/com/ld/igds/protocol/bhzn/grainv1/msg/AnalysisService.java
@@ -5,13 +5,11 @@
import com.ld.igds.common.dto.THDto;
import com.ld.igds.constant.BizType;
import com.ld.igds.constant.Constant;
import com.ld.igds.constant.DepotType;
import com.ld.igds.grain.GrainUtil;
import com.ld.igds.grain.dto.GrainItemInfo;
import com.ld.igds.io.notify.NotifyGrainInvoker;
import com.ld.igds.models.DepotConf;
import com.ld.igds.models.DeviceSer;
import com.ld.igds.models.DicSysConf;
import com.ld.igds.models.Grain;
import com.ld.igds.models.*;
import com.ld.igds.order.ExeOrderService;
import com.ld.igds.order.data.ExeRequest;
import com.ld.igds.protocol.bhzn.grainv1.msg.builder.CommandBuild;
@@ -75,7 +73,7 @@
            //DO NOTHING
            log.info("主机------->>平台:注册信息报文={}", message);
            DeviceSer ser = coreSerService.getCacheSerBySn(ContextUtil.getDefaultCompanyId(),message.getAddr());
            DeviceSer ser = coreSerService.getCacheSerBySn("5323",message.getAddr());
            if(ser!= null ){
                ser.setIp(message.getIp());
                ser.setPort(message.getPort());
@@ -113,7 +111,7 @@
            //根据分机地址获取分机信息
            DeviceSer ser = coreSerService.getCacheSer(ContextUtil.getDefaultCompanyId(), message.getAddr());
            DeviceSer ser = coreSerService.getCacheSer("5323", message.getAddr());
            if (ser == null) {
                replayGrain(message);
                log.error("主机-------->>平台,解析粮情失败,未获取到系统粮情主机配置:" + message.getAddr());
@@ -145,15 +143,30 @@
                log.error("分机------>>>平台:" + info);
                return;
            }
            Depot depot = commonService.getDepotById(depotConf.getCompanyId(),depotConf.getDepotId());
            if (null == depot) {
                String info = "粮情解析失败:分机=" + ser.getName() + "没有获取到粮情参数配置仓库。";
                log.error("分机------>>>平台:" + info);
                return;
            }
            // 粮情的批次号重新根据频率调整
            String batchId = ContextUtil.getBatchIdByFireq(depotConf.getGrainFreq());
            // 判断数据有没有收取完整
            String[] attCable = depotConf.getCableRule().split("-");
            int cableZ = Integer.valueOf(attCable[0]);
            int cableY = Integer.valueOf(attCable[1]);
            int cableX = Integer.valueOf(attCable[2]);
            int cableZ = 1;
            int cableY = 1;
            int cableX = 1;
            if(DepotType.TYPE_01.equals(depot.getDepotType())){
                cableZ = Integer.valueOf(attCable[0]);
                cableY = Integer.valueOf(attCable[1]);
                cableX = Integer.valueOf(attCable[2]);
            }else{
                cableZ = Integer.valueOf(depotConf.getCableCir());
                cableY = Integer.valueOf(attCable[0]);
                cableX = 1;
            }
            int sumPoint = cableZ * cableY * cableX;
            //获取当前粮情温度报文
@@ -215,10 +228,26 @@
    private void analysisGrain2(DeviceSer ser, IoMessage message, ExeRequest exeRequest, DepotConf depotConf, DicSysConf sysConf, String batchId, String grainStr) {
        // 获取完整的粮情包信息
        Depot depot = commonService.getDepotById(depotConf.getCompanyId(),depotConf.getDepotId());
        if (null == depot) {
            String info = "粮情解析失败:分机=" + ser.getName() + "没有获取到粮情参数配置仓库。";
            log.error("分机------>>>平台:" + info);
            return;
        }
        String[] attCable = depotConf.getCableRule().split("-");
        int cableZ = Integer.valueOf(attCable[0]);
        int cableY = Integer.valueOf(attCable[1]);
        int cableX = Integer.valueOf(attCable[2]);
        int cableZ = 1;
        int cableY = 1;
        int cableX = 1;
        if(DepotType.TYPE_01.equals(depot.getDepotType())){
            cableZ = Integer.valueOf(attCable[0]);
            cableY = Integer.valueOf(attCable[1]);
            cableX = Integer.valueOf(attCable[2]);
        }else{
            cableZ = Integer.valueOf(depotConf.getCableCir());
            cableY = Integer.valueOf(attCable[0]);
            cableX = 1;
        }
        // 根据层行列获取指定长度
        int start = 4 * (depotConf.getCableStart() - ser.getCableStart())
@@ -275,7 +304,12 @@
    private void addPoint1(List<Double> temps,
                           DepotConf depotConf, DeviceSer ser, ExeRequest exeRequest,
                           THDto thDto, DicSysConf sysConf, String batchId) {
        Depot depot = commonService.getDepotById(depotConf.getCompanyId(),depotConf.getDepotId());
        if (null == depot) {
            String info = "粮情解析失败:分机=" + ser.getName() + "没有获取到粮情参数配置仓库。";
            log.error("分机------>>>平台:" + info);
            return;
        }
        //根据电缆起始方位和布线方向,对粮情数据进行调整
        if (null != depotConf.getStartOrientation()) {
            temps = reversalGrainPoint(temps, depotConf);
@@ -288,14 +322,26 @@
        }
        String[] attCable = depotConf.getCableRule().split("-");
        int cableZ = Integer.valueOf(attCable[0]);
        int cableY = Integer.valueOf(attCable[1]);
        int cableX = Integer.valueOf(attCable[2]);
        int cableZ = 1;
        int cableY = 1;
        int cableX = 1;
        if(DepotType.TYPE_01.equals(depot.getDepotType())){
            cableZ = Integer.valueOf(attCable[0]);
            cableY = Integer.valueOf(attCable[1]);
            cableX = Integer.valueOf(attCable[2]);
        }else{
            cableZ = Integer.valueOf(depotConf.getCableCir());
            cableY = Integer.valueOf(attCable[0]);
            cableX = 1;
        }
        Grain grain = new Grain();
        grain.setDepotId(depotConf.getDepotId());
        grain.setCompanyId(depotConf.getCompanyId());
        grain.setCable(depotConf.getCableRule());
        grain.setCableCir(depotConf.getCableCir());
        grain.setBatchId(batchId);
        grain.setTempIn(Constant.ERROR_TEMP);
        grain.setHumidityIn(Constant.ERROR_TEMP);
@@ -430,7 +476,7 @@
    private void analysisTh(IoMessage message) {
        try {
            THDto th = new THDto();
            th.setCompanyId(ContextUtil.getDefaultCompanyId());
            th.setCompanyId("5323");
            String data = message.getContent();
            String houseNo = data.substring(0, 2);
            String t = data.substring(4, 8);