| | |
| | | |
| | | import com.ld.igds.common.CoreCommonService; |
| | | import com.ld.igds.common.CoreSerService; |
| | | 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.constant.OrderRespEnum; |
| | | 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.order.ExeOrderService; |
| | | import com.ld.igds.order.data.ExeRequest; |
| | | import com.ld.igds.protocol.beibo.grain.builder.ReMessage; |
| | | import com.ld.igds.protocol.beibo.grain.builder.ReMessageBuilder; |
| | | import com.ld.igds.protocol.beibo.grain.util.BeiboGrainServerUtils; |
| | | import com.ld.igds.util.BytesUtil; |
| | | import com.ld.igds.util.ContextUtil; |
| | | import com.ld.igds.warn.WarnUtils; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | |
| | | /** |
| | | * å议解æ |
| | | * |
| | | * @author vince |
| | | * @author czt |
| | | */ |
| | | @Slf4j |
| | | @Component(AnalysisService.BEAN_ID) |
| | | public class AnalysisService { |
| | | |
| | | |
| | | /** |
| | | * é对åå
ç²®æ
æ¥æè¿è¡å°è£
|
| | | */ |
| | | public static Map<String, String> contextMapGrain = new HashMap<>(); |
| | | |
| | | /** |
| | | * ç¨äºåæ¾è¿åç仿¸©ä»æ¹¿ä¿¡æ¯ |
| | | */ |
| | | public static Map<String, THDto> contextMapTH = new HashMap<>(); |
| | | |
| | | public static final String BEAN_ID = "beiboGrain.analysisService"; |
| | | |
| | |
| | | @Autowired |
| | | private ExeOrderService exeOrderService; |
| | | |
| | | |
| | | public static Map<String, Map<String, String>> contextMap = new HashMap<>(); |
| | | |
| | | public static double ERROR_CHECK_TAG = -100.0; |
| | | |
| | | public static double FAULT_CHECK_TAG = 85.0; |
| | | |
| | | public static double ERROR_CHECK_TAG2 = 50; |
| | | |
| | | public static double MAX_TEMP = -50.0; |
| | | public static double MIN_TEMP = 50.0; |
| | | |
| | | /** |
| | | * 00000000FFEB90FEAA 41 E821EC21EA21EC21ED21EC21E921E221E921E921E921EC21E921ED21F021E521E521E221E421E321E321E121DE21D721E021DD21DC21DF21FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
| | | * |
| | | * @param result |
| | | */ |
| | | public void analysis(String result){ |
| | | log.info("è´ååæº------->>å¹³å°ï¼ä¿¡æ¯æ¥æ={}", result); |
| | | if(!result.startsWith(BeiboGrainServerUtils.MSG_START)){ |
| | | log.error("è´ååæº------->>å¹³å°ï¼è§£æç²®æ
å¤±è´¥ï¼æ¥æèµ·å§ç¬¦é误ï¼ä¸è§£æ"); |
| | | } |
| | | //å»é¤èµ·å§ç¬¦ |
| | | result = result.substring(9*2-1); |
| | | public void analysis(String result) { |
| | | |
| | | analysisGrain(result); |
| | | log.info("åæº------->>å¹³å°ï¼ä¿¡æ¯æ¥æ={}", result); |
| | | ReMessage reMessage = ReMessageBuilder.getInstance().buildMessage(result); |
| | | |
| | | if (!BeiboGrainServerUtils.MSG_START.startsWith(reMessage.getStartStr())) { |
| | | log.error("åæº------->>å¹³å°ï¼è§£æç²®æ
å¤±è´¥ï¼æ¥æèµ·å§ç¬¦={}é误ï¼ä¸è§£æ", reMessage.getStartStr()); |
| | | } |
| | | |
| | | |
| | | //æ ¹æ®åæºå°åè·ååæºä¿¡æ¯ |
| | | DeviceSer ser = coreSerService.getCacheSer(ContextUtil.getDefaultCompanyId(), reMessage.getSerId()); |
| | | if (ser == null) { |
| | | log.error("åæº-------->>å¹³å°ï¼è§£æç²®æ
å¤±è´¥ï¼æªè·åå°ç³»ç»ç²®æ
主æºé
ç½®ï¼" + reMessage.getSerId()); |
| | | return; |
| | | } |
| | | |
| | | List<ExeRequest> list = exeOrderService.getInProgressOrderBySerId(BizType.GRAIN.getCode(), ser.getId()); |
| | | if (null == list || list.isEmpty()) { |
| | | String info = "ç²®æ
è§£æå¤±è´¥:åæº=" + ser.getName() + "没æè·åå°æå±ä»åºä¿¡æ¯ã"; |
| | | log.error("åæº------>>>å¹³å°ï¼" + info); |
| | | notifyGrainInvoker.notifyWeb(ser.getCompanyId(), OrderRespEnum.MSG_ERROR, BizType.GRAIN, info); |
| | | return; |
| | | } |
| | | |
| | | ExeRequest exeRequest = list.get(0); |
| | | log.info("è·åç²®æ
å½ä»¤ä¿¡æ¯={}", exeRequest); |
| | | if (null == exeRequest) { |
| | | String info = "ç²®æ
è§£æå¤±è´¥:åæº=" + ser.getName() + "没æè·ååå²å½ä»¤ã"; |
| | | log.error("è´ååæº------>>>å¹³å°ï¼" + info); |
| | | return; |
| | | } |
| | | |
| | | DepotConf depotConf = commonService.getCacheDepotConf( |
| | | exeRequest.getCompanyId(), exeRequest.getDepotId()); |
| | | if (null == depotConf) { |
| | | String info = "ç²®æ
è§£æå¤±è´¥:åæº=" + ser.getName() + "没æè·åå°ç²®æ
åæ°é
置信æ¯ã"; |
| | | log.error("åæº------>>>å¹³å°ï¼" + info); |
| | | notifyGrainInvoker.notifyWeb(ser.getCompanyId(), |
| | | OrderRespEnum.MSG_ERROR, BizType.GRAIN, info); |
| | | return; |
| | | } |
| | | |
| | | // é¦å
è·åå°ç³»ç»åæ°ï¼å¤ææ¯å¦éè¦æ¹æ¬¡èªå¨ä¼å |
| | | DicSysConf sysConf = commonService.getCacheSysConf(ser.getCompanyId()); |
| | | |
| | | reMessage.setCompanyId(ser.getCompanyId()); |
| | | analysisGrain(depotConf, reMessage, ser, exeRequest, sysConf); |
| | | } |
| | | |
| | | |
| | | private void analysisGrain(String result) { |
| | | try { |
| | | private void analysisGrain(DepotConf depotConf, ReMessage reMessage, DeviceSer ser, ExeRequest exeRequest, DicSysConf sysConf) { |
| | | // ç²®æ
çæ¹æ¬¡å·éæ°æ ¹æ®é¢çè°æ´ |
| | | reMessage.setBatchId(ContextUtil.getBatchIdByFireq(depotConf.getGrainFreq())); |
| | | String grainStr = reMessage.getGrainStr(); |
| | | |
| | | //æªååæºå°å |
| | | String serId = result.substring(0, 2); |
| | | //æ ¹æ®åæºå°åè·ååæºä¿¡æ¯ |
| | | DeviceSer ser = coreSerService.getCacheSer(ContextUtil.getDefaultCompanyId(),serId); |
| | | if (ser == null) { |
| | | log.error("è´ååæº-------->>å¹³å°ï¼è§£æç²®æ
å¤±è´¥ï¼æªè·åå°ç³»ç»ç²®æ
主æºé
ç½®ï¼" + serId); |
| | | return; |
| | | } |
| | | |
| | | // é¦å
è·åå°ç³»ç»åæ°ï¼å¤ææ¯å¦éè¦æ¹æ¬¡èªå¨ä¼å |
| | | DicSysConf sysConf = commonService.getCacheSysConf(ser.getCompanyId()); |
| | | List<ExeRequest> list = exeOrderService.getInProgressOrderBySerId(BizType.GRAIN.getCode(), ser.getId()); |
| | | |
| | | if (null == list || list.isEmpty()) { |
| | | String info = "ç²®æ
è§£æå¤±è´¥:åæº=" + ser.getName() + "没æè·åå°æå±ä»åºä¿¡æ¯ã"; |
| | | log.error("è´ååæº------>>>å¹³å°ï¼" + info); |
| | | return; |
| | | } |
| | | |
| | | //è·åé对å½åä»åºçå½ä»¤ |
| | | ExeRequest exeRequest = list.get(0); |
| | | if (null == exeRequest) { |
| | | String info = "ç²®æ
è§£æå¤±è´¥:åæº=" + ser.getName() + "没æè·ååå²å½ä»¤ã"; |
| | | log.error("è´ååæº------>>>å¹³å°ï¼" + info); |
| | | return; |
| | | } |
| | | |
| | | DepotConf depotConf = commonService.getCacheDepotConf(exeRequest.getCompanyId(), exeRequest.getDepotId()); |
| | | |
| | | if (null == depotConf) { |
| | | String info = "ç²®æ
è§£æå¤±è´¥:åæº=" + ser.getName() + "没æè·åå°ç²®æ
åæ°é
置信æ¯ã"; |
| | | log.error("è´ååæº------>>>å¹³å°ï¼" + info); |
| | | return; |
| | | } |
| | | |
| | | // ç²®æ
çæ¹æ¬¡å·éæ°æ ¹æ®é¢çè°æ´ |
| | | String batchId = ContextUtil.getBatchIdByFireq(depotConf.getGrainFreq()); |
| | | |
| | | //TODO æ ¹æ®å®é
æ¥æï¼å¾
å®ç° |
| | | log.debug("{}-{}=æ¶å°çç²®æ
ä¿¡æ¯={}", ser.getCompanyId(), ser.getName(), grainStr); |
| | | |
| | | |
| | | analysisStep0(depotConf, reMessage, ser, exeRequest, sysConf); |
| | | |
| | | log.info("åæº------>>>å¹³å°ï¼å½ä»¤ç±»å=8817--ç²®æ
å
¨é¨æ¶å°ï¼å¼å§è§£æ-{}-{}", |
| | | ser.getCompanyId(), ser.getName()); |
| | | } |
| | | |
| | | private void analysisStep0(DepotConf depotConf, ReMessage reMessage, |
| | | DeviceSer ser, ExeRequest exeRequest, DicSysConf sysConf) { |
| | | |
| | | } catch (Exception e) { |
| | | log.error(e.getMessage(), e); |
| | | List<DepotConf> depotConfs = null; |
| | | |
| | | // ä¸åæºå¤ä»ï¼æèµ·å§åæ¾å°æå¤§è¿è¡éé |
| | | if (Constant.YN_Y.equals(sysConf.getGrainMoreTag())) { |
| | | depotConfs = commonService.getCacheDepotConfBySerId2( |
| | | depotConf.getCompanyId(), ser.getId()); |
| | | } |
| | | |
| | | if (null == depotConfs) {// ä¸ä¸ªåæº1ä¸ªä» |
| | | if (DepotType.TYPE_02.getCode().equals(depotConf.getDepotType())) { |
| | | analysisStep2(depotConf, ser, exeRequest, reMessage, sysConf); |
| | | } else if (DepotType.TYPE_04.getCode().equals(depotConf.getDepotType())) { |
| | | analysisStep2(depotConf, ser, exeRequest, reMessage, sysConf); |
| | | } else { |
| | | analysisStep1(depotConf, ser, exeRequest, reMessage, sysConf); |
| | | } |
| | | |
| | | return; |
| | | } |
| | | |
| | | // ä¸åå å¤ä»æ
åµï¼èèåä»ééåå¤ä»éé |
| | | // åä»ééæ¶åæ°æ®ä»0è¿å |
| | | if (StringUtils.isEmpty(exeRequest.getDepotIds())) { |
| | | |
| | | depotConf.setCableEnd(depotConf.getCableEnd() - depotConf.getCableStart() + 1); |
| | | depotConf.setCableStart(ser.getCableStart()); |
| | | |
| | | if (DepotType.TYPE_02.getCode().equals(depotConf.getDepotType())) { |
| | | analysisStep2(depotConf, ser, exeRequest, reMessage, sysConf); |
| | | } else if (DepotType.TYPE_04.getCode().equals(depotConf.getDepotType())) { |
| | | analysisStep2(depotConf, ser, exeRequest, reMessage, sysConf); |
| | | } else { |
| | | analysisStep1(depotConf, ser, exeRequest, reMessage, sysConf); |
| | | } |
| | | |
| | | return; |
| | | |
| | | } |
| | | |
| | | // æ¹éééææå
³èä¸èµ·ééï¼éåæ§è¡ |
| | | for (DepotConf depotConfTemp : depotConfs) { |
| | | if (DepotType.TYPE_02.getCode().equals(depotConfTemp.getDepotType())) { |
| | | analysisStep2(depotConfTemp, ser, exeRequest, reMessage, sysConf); |
| | | } else if (DepotType.TYPE_04.getCode().equals(depotConfTemp.getDepotType())) { |
| | | analysisStep2(depotConfTemp, ser, exeRequest, reMessage, sysConf); |
| | | } else { |
| | | analysisStep1(depotConfTemp, ser, exeRequest, reMessage, sysConf); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * åçä»çç²®æ
è§£æ |
| | | * |
| | | * @param depotConf |
| | | * @param ser |
| | | * @param exeRequest |
| | | * @param reMessage |
| | | */ |
| | | private void analysisStep2(DepotConf depotConf, |
| | | DeviceSer ser, ExeRequest exeRequest, |
| | | ReMessage reMessage, DicSysConf sysConf) { |
| | | if (StringUtils.isEmpty(depotConf.getCableRule()) |
| | | || StringUtils.isEmpty(depotConf.getCableCir())) { |
| | | log.error("åæº------>>>å¹³å°ï¼å½åä»åºï¼{}-{}ï¼æ²¡ææ²¡æé
ç½®å¸çº¿è§åï¼æ æ³è§£æç²®æ
ä¿¡æ¯â¦â¦", |
| | | ser.getCompanyId(), depotConf.getDepotName()); |
| | | return; |
| | | } |
| | | |
| | | String[] cableRuleAtt = depotConf.getCableRule().split("-"); |
| | | String[] cableCirAtt = depotConf.getCableCir().split("-"); |
| | | |
| | | if (cableRuleAtt.length != cableCirAtt.length) { |
| | | log.error("åæº------>>>å¹³å°ï¼å½åä»åºï¼{}-{}ï¼å¸çº¿è§å䏿£ç¡®ï¼æ æ³è§£æç²®æ
ä¿¡æ¯â¦â¦", ser.getCompanyId(), depotConf.getDepotName()); |
| | | return; |
| | | } |
| | | |
| | | |
| | | //é¿å
空æé |
| | | if (null == depotConf.getCableCone()) depotConf.setCableCone(Constant.CABLE_CONE_0); |
| | | |
| | | // è·åæå¤§çå±é
ç½®--é»è®¤æ¯ä¸åé½ä¸æ · |
| | | int layMax = Integer.valueOf(cableCirAtt[0]); |
| | | for (int i = 0; i < cableCirAtt.length; i++) { |
| | | if (Integer.valueOf(cableCirAtt[i]) >= layMax) layMax = Integer.valueOf(cableCirAtt[i]); |
| | | } |
| | | |
| | | //ç²®æ
ä¿¡æ¯ |
| | | String strPoints = reMessage.getGrainStr(); |
| | | |
| | | log.info("------çä»ç²®æ
æ¥æ={}------", strPoints); |
| | | |
| | | int sumNum = 0, cableZ = 1;// sumNum å
±å¤å°æ ¹çµç¼ï¼cableZ å±çæå¤§å¼ï¼é¥å½¢ä»è¡¥é½æå¤§å± |
| | | for (int i = 0; i < cableCirAtt.length; i++) { |
| | | if (Integer.valueOf(cableCirAtt[i]) > cableZ) { |
| | | cableZ = Integer.valueOf(cableCirAtt[i]); |
| | | } |
| | | sumNum += Integer.valueOf(cableRuleAtt[i]); |
| | | } |
| | | |
| | | // æ ¹æ®å±è¡åè·åæå®é¿åº¦ |
| | | int start = 4 * (depotConf.getCableStart() - ser.getCableStart()) * cableZ; |
| | | int len = 4 * cableZ * sumNum; |
| | | |
| | | strPoints = strPoints.substring(start, start + len); |
| | | log.info("åæº------>>>å¹³å°ï¼è¿åç²®æ
宿´ä¿¡æ¯ï¼æå±ç»ç»={}ï¼åæº={}", ser.getCompanyId(), ser.getName()); |
| | | |
| | | // å°ç²®æ
è§£æææ°ç» |
| | | List<Double> temps = new ArrayList<>(); |
| | | double tempValue; |
| | | String temp; |
| | | int curLay = 1;//æå¨å±ä»1å¼å§ |
| | | int curRoot = 1;//æå¨æ ¹ |
| | | int curCir = 1;//æå¨å |
| | | int cirLay = 1;//å½ååçå± |
| | | for (int i = 0; i < strPoints.length() / 4; i++) { |
| | | temp = strPoints.substring(i * 4, i * 4 + 4); |
| | | if (temp == null) { |
| | | temp = "0000"; |
| | | } |
| | | tempValue = BytesUtil.hexToInt(BytesUtil.tran_LH(temp)) / 10.0; |
| | | |
| | | //éæ£å¸¸å¼ |
| | | if (tempValue > ERROR_CHECK_TAG2) { |
| | | tempValue = Constant.ERROR_TEMP; |
| | | } |
| | | |
| | | // æ
éå¼å¤ç |
| | | if (tempValue >= FAULT_CHECK_TAG) { |
| | | tempValue = Constant.FAULT_TEMP; |
| | | } |
| | | |
| | | // å¤ç¨å¼ |
| | | if (tempValue == ERROR_CHECK_TAG) { |
| | | tempValue = Constant.ERROR_TEMP; |
| | | |
| | | |
| | | //éªè¯æ¯ä¸æ¯é¥å½¢ä»è¡¥å¿å¼ |
| | | curLay = (i % layMax) + 1; |
| | | curRoot = (i / layMax) + 1; |
| | | curCir = getCurCir(curRoot, cableRuleAtt); |
| | | |
| | | cirLay = Integer.valueOf(cableCirAtt[curCir - 1]); |
| | | |
| | | //æ¯å¦é
ç½®äº5å±ä½æ¯å½åæ¯6å±ï¼è¯´æå½åç¹ä¸ºè¡¥å¿ç¹ |
| | | if (curLay > cirLay) { |
| | | tempValue = Constant.ADD_TEMP; |
| | | |
| | | //夿æ¯ä¸æ¯ä¸é¥å½¢ï¼å°è¡¥ç¹è½¬ç§»å°ä¸æ¹ |
| | | if (Constant.CABLE_CONE_1.equals(depotConf.getCableCone())) { |
| | | int index = i - curLay - 1; |
| | | temps.add(index, tempValue); |
| | | } else { |
| | | temps.add(tempValue); |
| | | } |
| | | |
| | | } else { |
| | | temps.add(tempValue); |
| | | } |
| | | |
| | | } else { |
| | | temps.add(tempValue); |
| | | } |
| | | } |
| | | |
| | | log.debug("-------CheckGrainRequest--={}", exeRequest.toString()); |
| | | |
| | | // å°éåè§£ææåæ æ°æ® |
| | | addPoint2(temps, reMessage, depotConf, exeRequest, sysConf); |
| | | } |
| | | |
| | | /** |
| | | * è·åå½åè·æå¨å |
| | | * |
| | | * @param curRoot |
| | | * @param cableRuleAtt |
| | | * @return |
| | | */ |
| | | private int getCurCir(int curRoot, String[] cableRuleAtt) { |
| | | |
| | | int sum = 0; |
| | | for (int i = 0; i < cableRuleAtt.length; i++) { |
| | | sum += Integer.valueOf(cableRuleAtt[i]); |
| | | if (curRoot <= sum) return i + 1; |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * å¹³æ¹ä»çè§£æï¼è§£æéè¦èèå½åæ¯å¦å¯ç¨çä¸åæºå¤ä» |
| | | * |
| | | * @param depotConf |
| | | * @param ser |
| | | * @param exeRequest |
| | | * @param reMessage |
| | | */ |
| | | private void analysisStep1(DepotConf depotConf, DeviceSer ser, |
| | | ExeRequest exeRequest, ReMessage reMessage, DicSysConf sysConf) { |
| | | // ç²®æ
ä¿¡æ¯ |
| | | String strPoints = reMessage.getGrainStr(); |
| | | |
| | | String[] attCable = depotConf.getCableRule().split("-"); |
| | | int cableZ = Integer.valueOf(attCable[0]); |
| | | int cableY = Integer.valueOf(attCable[1]); |
| | | int cableX = Integer.valueOf(attCable[2]); |
| | | |
| | | // æ ¹æ®å±è¡åè·åæå®é¿åº¦ |
| | | int start = 4 * (depotConf.getCableStart() - ser.getCableStart()) |
| | | * cableZ * cableY; |
| | | int len = 4 * cableZ * cableY * cableX; |
| | | |
| | | log.info("åæº------>>>å¹³å°ï¼è¿åç²®æ
宿´ä¿¡æ¯ï¼æå±ç»ç»={}ï¼åæº={}", ser.getCompanyId(), ser.getName()); |
| | | |
| | | strPoints = strPoints.substring(start, start + len); |
| | | |
| | | // å°ç²®æ
è§£æææ°ç» |
| | | List<Double> temps = new ArrayList<>(); |
| | | double tempValue; |
| | | String temp; |
| | | for (int i = 0; i < strPoints.length() / 4; i++) { |
| | | temp = strPoints.substring(i * 4, i * 4 + 4); |
| | | if (temp == null) { |
| | | temp = "0000"; |
| | | } |
| | | tempValue = BytesUtil.hexToInt(BytesUtil.tran_LH(temp)) / 10.0; |
| | | // 说æè§£æçæ°æ®æé®é¢ |
| | | if (tempValue == ERROR_CHECK_TAG || tempValue == ERROR_CHECK_TAG2) { |
| | | tempValue = Constant.ERROR_TEMP; |
| | | } |
| | | // æ
éå¼å¤ç |
| | | if (tempValue >= FAULT_CHECK_TAG) { |
| | | tempValue = Constant.FAULT_TEMP; |
| | | } |
| | | temps.add(tempValue); |
| | | } |
| | | |
| | | log.debug("-------CheckGrainRequest--={}", exeRequest.toString()); |
| | | |
| | | // å°éåè§£ææåæ æ°æ® |
| | | addPoint1(temps, reMessage, depotConf, ser, exeRequest, sysConf); |
| | | } |
| | | |
| | | /** |
| | | * å¹³æ¿ä»ï¼è§£æç¬¬äºæ¥ï¼è§£æå°åæ æ°æ® |
| | | * |
| | | * @param temps |
| | | * @throws Exception |
| | | */ |
| | | private void addPoint1(List<Double> temps, ReMessage msg, |
| | | DepotConf depotConf, DeviceSer ser, ExeRequest exeRequest, |
| | | DicSysConf sysConf) { |
| | | |
| | | //æ ¹æ®çµç¼èµ·å§æ¹ä½åå¸çº¿æ¹åï¼å¯¹ç²®æ
æ°æ®è¿è¡è°æ´ |
| | | if (null != depotConf.getStartOrientation()) { |
| | | temps = reversalGrainPoint(temps, depotConf); |
| | | } |
| | | |
| | | //è¥èµ·ç¹ç¹ä½ä¸ºåºé¨ï¼åå°ç²®æ
æ°æ®è¿è¡ç¿»è½¬ |
| | | if (null != depotConf.getStartPoint() |
| | | && Constant.GRAIN_START_POINT_BELOW.equals(depotConf.getStartPoint())) { |
| | | temps = grainUtil.reversalUpAndDown(temps, depotConf.getCableRule()); |
| | | } |
| | | |
| | | //è¥é
ç½®å±è¡è½¬æ¢ï¼åå°ç²®æ
æ°æ®è¿è¡å±è¡è½¬æ¢ |
| | | if (StringUtils.isNotEmpty(depotConf.getStartConvert())) { |
| | | temps = convertGrainPoint(temps, depotConf); |
| | | String[] cableRule = depotConf.getCableRule().split("-"); |
| | | //转æ¢å±è¡åé
ç½® |
| | | if (Constant.GRAIN_CONVERT_CLOCKWISE.equals(depotConf.getStartConvert()) |
| | | || Constant.GRAIN_CONVERT_ANTICLOCKWISE.equals(depotConf.getStartConvert())) { |
| | | depotConf.setCableRule(Integer.valueOf(cableRule[1]) + "-" + Integer.valueOf(cableRule[0]) + "-" + Integer.valueOf(cableRule[2])); |
| | | } |
| | | } |
| | | |
| | | String[] attCable = depotConf.getCableRule().split("-"); |
| | | int cableZ = Integer.valueOf(attCable[0]); |
| | | int cableY = Integer.valueOf(attCable[1]); |
| | | int cableX = Integer.valueOf(attCable[2]); |
| | | |
| | | Grain grain = new Grain(); |
| | | grain.setDepotId(depotConf.getDepotId()); |
| | | grain.setCompanyId(depotConf.getCompanyId()); |
| | | grain.setCable(depotConf.getCableRule()); |
| | | grain.setBatchId(msg.getBatchId()); |
| | | grain.setTempIn(Constant.ERROR_TEMP); |
| | | grain.setHumidityIn(Constant.ERROR_TEMP); |
| | | |
| | | grain.setReceiveDate(msg.getReceiveDate()); |
| | | grain.setRemark("粮温æ£å¸¸"); |
| | | |
| | | // è·åç¼åä¸çå½ä»¤ä¿¡æ¯ |
| | | grain.setCheckUser(exeRequest.getExeUser()); |
| | | |
| | | double max = MAX_TEMP, min = MIN_TEMP, sumT = 0.0, sumNum = cableX |
| | | * cableY * cableZ; |
| | | |
| | | // æ ¡éªåå®ç°ç»è®¡ï¼çæééç¹ä¿¡æ¯ |
| | | List<GrainItemInfo> listGrainItems = new ArrayList<>(); |
| | | int i = 1; |
| | | for (Double temp : temps) { |
| | | if (temp == Constant.ERROR_TEMP || temp == Constant.FAULT_TEMP || temp == Constant.ADD_TEMP) { |
| | | sumNum--; |
| | | } else { |
| | | sumT += temp; |
| | | if (temp > max) { |
| | | max = temp; |
| | | } |
| | | if (temp < min) { |
| | | min = temp; |
| | | } |
| | | } |
| | | listGrainItems.add(new GrainItemInfo(i, temp)); |
| | | i++; |
| | | } |
| | | |
| | | if (sumNum == 0) { |
| | | sumNum = 1; |
| | | grain.setRemark("å½åç²®æ
ééå¼å¸¸"); |
| | | } |
| | | //è¿æ»¤æ¯è¾ç¨çæå¤§æå°å¼ |
| | | if (max == MAX_TEMP) { |
| | | max = 0.0; |
| | | } |
| | | if (min == MIN_TEMP) { |
| | | min = 0.0; |
| | | } |
| | | if (null != depotConf.getTempMax() && max > depotConf.getTempMax()) { |
| | | grain.setRemark("ä»åºé
ç½®é«æ¸©è¦åå¼ï¼" + depotConf.getTempMax() + "ï¼å½åæ£æµé«æ¸©å¼ï¼" |
| | | + max); |
| | | warnUtils.addGrainWarn(depotConf, grain); |
| | | } |
| | | |
| | | grain.setTempAve(sumT / sumNum); |
| | | grain.setTempMax(max); |
| | | grain.setTempMin(min); |
| | | grain.setPoints(StringUtils.join(temps, ",")); |
| | | |
| | | String depotIds = exeRequest.getDepotIds(); |
| | | |
| | | boolean notifyWeb = true; |
| | | if (null != depotIds && depotIds.indexOf(depotConf.getDepotId()) == -1) { |
| | | notifyWeb = false; |
| | | } |
| | | // ç¨æ·å°è£
å¥½æ°æ®å³å¯ |
| | | notifyGrainInvoker.analysisSuccess(grain, listGrainItems, depotConf, |
| | | sysConf, notifyWeb, exeRequest); |
| | | } |
| | | |
| | | /** |
| | | * åçä»è§£ææ¥éª¤ |
| | | * |
| | | * @param temps |
| | | * @param msg |
| | | * @param depotConf |
| | | * @param exeRequest |
| | | */ |
| | | private void addPoint2(List<Double> temps, ReMessage msg, |
| | | DepotConf depotConf, ExeRequest exeRequest, |
| | | DicSysConf sysConf) { |
| | | |
| | | Grain grain = new Grain(); |
| | | grain.setDepotId(depotConf.getDepotId()); |
| | | grain.setCompanyId(depotConf.getCompanyId()); |
| | | grain.setCable(depotConf.getCableRule()); |
| | | grain.setCableCir(depotConf.getCableCir()); |
| | | grain.setBatchId(msg.getBatchId()); |
| | | grain.setTempIn(Constant.ERROR_TEMP); |
| | | grain.setHumidityIn(Constant.ERROR_TEMP); |
| | | |
| | | grain.setReceiveDate(msg.getReceiveDate()); |
| | | grain.setRemark("粮温æ£å¸¸"); |
| | | grain.setCheckUser(exeRequest.getExeUser()); |
| | | |
| | | double max = MAX_TEMP, min = MIN_TEMP, sumT = 0.0; |
| | | |
| | | int sumNum = temps.size(); |
| | | List<GrainItemInfo> listGrainItems = new ArrayList<>(); |
| | | int i = 1; |
| | | for (Double temp : temps) { |
| | | if (temp == Constant.ERROR_TEMP || temp == Constant.FAULT_TEMP || temp == Constant.ADD_TEMP) { |
| | | sumNum--; |
| | | } else { |
| | | sumT += temp; |
| | | if (temp > max) { |
| | | max = temp; |
| | | } |
| | | if (temp < min) { |
| | | min = temp; |
| | | } |
| | | } |
| | | listGrainItems.add(new GrainItemInfo(i, temp)); |
| | | i++; |
| | | } |
| | | |
| | | if (sumNum == 0) { |
| | | sumNum = 1; |
| | | grain.setRemark("å½åç²®æ
ééå¼å¸¸"); |
| | | } |
| | | //è¿æ»¤æ¯è¾ç¨çæå¤§æå°å¼ |
| | | if (max == MAX_TEMP) { |
| | | max = 0.0; |
| | | } |
| | | if (min == MIN_TEMP) { |
| | | min = 0.0; |
| | | } |
| | | if (null != depotConf.getTempMax() && max > depotConf.getTempMax()) { |
| | | grain.setRemark("ä»åºé
ç½®é«æ¸©è¦åå¼ï¼" + depotConf.getTempMax() + "ï¼å½åæ£æµé«æ¸©å¼ï¼" |
| | | + max); |
| | | warnUtils.addGrainWarn(depotConf, grain); |
| | | } |
| | | |
| | | grain.setTempAve(sumT / sumNum); |
| | | grain.setTempMax(max); |
| | | grain.setTempMin(min); |
| | | grain.setPoints(StringUtils.join(temps, ",")); |
| | | |
| | | String depotIds = exeRequest.getDepotIds(); |
| | | boolean notifyWeb = true; |
| | | if (null != depotIds && depotIds.indexOf(depotConf.getDepotId()) == -1) { |
| | | notifyWeb = false; |
| | | } |
| | | |
| | | // ç¨æ·å°è£
å¥½æ°æ®å³å¯ |
| | | notifyGrainInvoker.analysisSuccess(grain, listGrainItems, depotConf, |
| | | sysConf, notifyWeb, exeRequest); |
| | | } |
| | | |
| | | private List<Double> convertGrainPoint(List<Double> temps, DepotConf conf) { |
| | | if (Constant.GRAIN_CONVERT_DEFAULT.equals(conf.getStartConvert())) { |
| | | //è¥å±è¡è½¬æ¢ä¸ºé»è®¤ï¼åç´æ¥è¿å |
| | | return temps; |
| | | } |
| | | |
| | | //顺æ¶éè½¬æ¢ |
| | | if (Constant.GRAIN_CONVERT_CLOCKWISE.equals(conf.getStartConvert())) { |
| | | return grainUtil.convertRight(temps, conf.getCableRule()); |
| | | } |
| | | //éæ¶éè½¬æ¢ |
| | | if (Constant.GRAIN_CONVERT_ANTICLOCKWISE.equals(conf.getStartConvert())) { |
| | | return grainUtil.convertLeft(temps, conf.getCableRule()); |
| | | } |
| | | |
| | | return temps; |
| | | } |
| | | |
| | | private List<Double> reversalGrainPoint(List<Double> temps, DepotConf conf) { |
| | | if (StringUtils.isEmpty(conf.getStartOrientation())) { |
| | | //è¥èµ·å§æ¹ä½ä¸ºç©ºï¼åé»è®¤èµ·å§æ¹ä½åæ¹åï¼ç´æ¥è¿å |
| | | return temps; |
| | | } |
| | | //èµ·å§æ¹ä½ä¸ºå³è¾¹æ¶ |
| | | if (Constant.GRAIN_START_ORIENTATION_RIGHT.equals(conf.getStartOrientation())) { |
| | | if (StringUtils.isEmpty(conf.getStartDirection())) { |
| | | //å³è¾¹èµ·å§ï¼é»è®¤çºµåå¸çº¿ï¼ç´æ¥è¿å |
| | | return temps; |
| | | } |
| | | if (Constant.GRAIN_START_DIRECTION_TRANSVERSE.equals(conf.getStartDirection())) { |
| | | //å³è¾¹èµ·å§ï¼æ¨ªåå¸çº¿ |
| | | return grainUtil.reversalRight1(temps, conf.getCableRule()); |
| | | } |
| | | //å³è¾¹èµ·å§ï¼é»è®¤çºµåå¸çº¿ï¼ç´æ¥è¿å |
| | | return temps; |
| | | } |
| | | //èµ·å§æ¹ä½ä¸ºå³ä¸æ¶ |
| | | if (Constant.GRAIN_START_ORIENTATION_RIGHT_UP.equals(conf.getStartOrientation())) { |
| | | if (StringUtils.isEmpty(conf.getStartDirection())) { |
| | | //å³ä¸èµ·å§ï¼é»è®¤çºµåå¸çº¿ |
| | | return grainUtil.reversalRightUp2(temps, conf.getCableRule()); |
| | | } |
| | | if (Constant.GRAIN_START_DIRECTION_TRANSVERSE.equals(conf.getStartDirection())) { |
| | | //å³ä¸èµ·å§ï¼æ¨ªåå¸çº¿ |
| | | return grainUtil.reversalRightUp1(temps, conf.getCableRule()); |
| | | } |
| | | //å³ä¸èµ·å§ï¼é»è®¤çºµåå¸çº¿ |
| | | return grainUtil.reversalRightUp2(temps, conf.getCableRule()); |
| | | } |
| | | //èµ·å§æ¹ä½ä¸ºå·¦è¾¹æ¶ |
| | | if (Constant.GRAIN_START_ORIENTATION_LEFT.equals(conf.getStartOrientation())) { |
| | | if (StringUtils.isEmpty(conf.getStartDirection())) { |
| | | //左边起å§ï¼é»è®¤çºµåå¸çº¿ |
| | | return grainUtil.reversalLeft2(temps, conf.getCableRule()); |
| | | } |
| | | if (Constant.GRAIN_START_DIRECTION_TRANSVERSE.equals(conf.getStartDirection())) { |
| | | //左边起å§ï¼æ¨ªåå¸çº¿ |
| | | return grainUtil.reversalLeft1(temps, conf.getCableRule()); |
| | | } |
| | | //左边起å§ï¼é»è®¤çºµåå¸çº¿ |
| | | return grainUtil.reversalLeft2(temps, conf.getCableRule()); |
| | | } |
| | | //èµ·å§æ¹ä½ä¸ºå·¦ä¸æ¶ |
| | | if (Constant.GRAIN_START_ORIENTATION_LEFT_UP.equals(conf.getStartOrientation())) { |
| | | if (StringUtils.isEmpty(conf.getStartDirection())) { |
| | | //å·¦ä¸èµ·å§ï¼é»è®¤çºµåå¸çº¿ |
| | | return grainUtil.reversalLeftUp2(temps, conf.getCableRule()); |
| | | } |
| | | if (Constant.GRAIN_START_DIRECTION_TRANSVERSE.equals(conf.getStartDirection())) { |
| | | //å·¦ä¸èµ·å§ï¼æ¨ªåå¸çº¿ |
| | | return grainUtil.reversalLeftUp1(temps, conf.getCableRule()); |
| | | } |
| | | //å·¦ä¸èµ·å§ï¼é»è®¤çºµåå¸çº¿ |
| | | return grainUtil.reversalLeftUp2(temps, conf.getCableRule()); |
| | | } |
| | | |
| | | return temps; |
| | | } |
| | | |
| | | private String buildCurKey(ReMessage msg, int curPacket) { |
| | | return msg.getSerId() + "_" + curPacket; |
| | | } |
| | | |
| | | private String buildContextKey(ReMessage msg, String depotId) { |
| | | return msg.getCompanyId() + "_" + msg.getSerId() + "_" + depotId; |
| | | } |
| | | } |