| | |
| | | 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; |
| | |
| | | */ |
| | | 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(ContextUtil.getDefaultCompanyId(),message.getAddr()); |
| | | |
| | | DeviceSer ser = coreSerService.getCacheSerBySn(message.getCompanyId(), message.getAddr()); |
| | | if(ser!= null ){ |
| | | ser.setIp(message.getIp()); |
| | | ser.setPort(message.getPort()); |
| | |
| | | |
| | | //根据分机地址获取分机信息 |
| | | |
| | | DeviceSer ser = coreSerService.getCacheSer(ContextUtil.getDefaultCompanyId(), message.getAddr()); |
| | | DeviceSer ser = coreSerService.getCacheSer(message.getCompanyId(), message.getAddr()); |
| | | if (ser == null) { |
| | | replayGrain(message); |
| | | log.error("主机-------->>平台,解析粮情失败,未获取到系统粮情主机配置:" + message.getAddr()); |
| | |
| | | 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.getCode().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; |
| | | |
| | | //获取当前粮情温度报文 |
| | |
| | | |
| | | 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.getCode().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()) |
| | |
| | | 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); |
| | |
| | | } |
| | | |
| | | 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.getCode().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); |
| | |
| | | private void analysisTh(IoMessage message) { |
| | | try { |
| | | THDto th = new THDto(); |
| | | th.setCompanyId(ContextUtil.getDefaultCompanyId()); |
| | | th.setCompanyId(message.getCompanyId()); |
| | | String data = message.getContent(); |
| | | String houseNo = data.substring(0, 2); |
| | | String t = data.substring(4, 8); |