| | |
| | | public static double MAX_TEMP = -50.0; |
| | | public static double MIN_TEMP = 50.0; |
| | | |
| | | public static void main(String[] args) { |
| | | String str = "00000000FFEB90FEAA41E821EC21EA21EC21ED21EC21E921E221E921E921E921EC21E921ED21F021E521E521E221E421E321E321E121DE21D721E021DD21DC21DF21FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; |
| | | System.out.println(str.substring(9 * 2, 10 * 2)); |
| | | } |
| | | |
| | | /** |
| | | * 00000000FFEB90FEAA41E821EC21EA21EC21ED21EC21E921E221E921E921E921EC21E921ED21F021E521E521E221E421E321E321E121DE21D721E021DD21DC21DF21FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF |
| | | * |
| | |
| | | sumNum += Integer.valueOf(cableRuleAtt[i]); |
| | | } |
| | | |
| | | if(cableZ < ser.getCableZ()){ |
| | | cableZ = ser.getCableZ(); |
| | | } |
| | | |
| | | // 根据层行列获取指定长度 |
| | | int start = 4 * (depotConf.getCableStart() - ser.getCableStart()) * cableZ; |
| | | int len = 4 * cableZ * sumNum; |
| | |
| | | List<Double> temps = new ArrayList<>(); |
| | | double tempValue; |
| | | String temp; |
| | | int curLay = 1;//所在层从1开始 |
| | | int curRoot = 1;//所在根 |
| | | int curCir = 1;//所在圈 |
| | | int cirLay = 1;//当前圈的层 |
| | | int symbol = 0; //符号位 |
| | | for (int i = 0; i < strPoints.length() / 4; i++) { |
| | | temp = strPoints.substring(i * 4, i * 4 + 4); |
| | |
| | | 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); |
| | | } |
| | | temps.add(tempValue); |
| | | } |
| | | |
| | | log.debug("-------CheckGrainRequest--={}", exeRequest.toString()); |
| | |
| | | grain.setCompanyId(depotConf.getCompanyId()); |
| | | grain.setCable(depotConf.getCableRule()); |
| | | grain.setBatchId(msg.getBatchId()); |
| | | grain.setTempIn(Constant.ERROR_TEMP); |
| | | grain.setHumidityIn(Constant.ERROR_TEMP); |
| | | |
| | | int humidity = -100; |
| | | int tem = -100; |
| | | String substring = ""; |
| | | |
| | | //解析外湿外温 |
| | | String thStr = msg.getThStr().substring(6, 12); |
| | | humidity = BytesUtil.hexToInt(thStr.substring(0, 2)); |
| | | grain.setHumidityOut(humidity * 1.0); |
| | | substring = thStr.substring(2); |
| | | tem = BytesUtil.hexToInt(substring); |
| | | grain.setTempOut(tem * 1.0); |
| | | if(substring.startsWith("1")){ |
| | | grain.setTempOut(tem * -1.0); |
| | | } |
| | | |
| | | //解析仓内温仓内湿 |
| | | int thConf = Integer.valueOf(depotConf.getThConf()); |
| | | int start = 0, end = 6; |
| | | if(thConf > 1){ |
| | | start += 6*thConf; //12-18 |
| | | end += start; |
| | | } |
| | | thStr = msg.getThStr().substring(start, end); |
| | | humidity = BytesUtil.hexToInt(thStr.substring(0, 2)); |
| | | grain.setHumidityIn(humidity * 1.0); |
| | | substring = thStr.substring(2); |
| | | tem = BytesUtil.hexToInt(substring); |
| | | grain.setTempIn(tem * 1.0); |
| | | if(substring.startsWith("1")){ |
| | | grain.setTempIn(tem * -1.0); |
| | | } |
| | | |
| | | grain.setReceiveDate(new Date()); |
| | | grain.setRemark("粮温正常"); |
| | |
| | | grain.setCable(depotConf.getCableRule()); |
| | | grain.setCableCir(depotConf.getCableCir()); |
| | | grain.setBatchId(msg.getBatchId()); |
| | | grain.setTempIn(Constant.ERROR_TEMP); |
| | | grain.setHumidityIn(Constant.ERROR_TEMP); |
| | | |
| | | int humidity = -100; |
| | | int tem = -100; |
| | | String substring = ""; |
| | | |
| | | //解析外湿外温 |
| | | String thStr = msg.getThStr().substring(6, 12); |
| | | humidity = BytesUtil.hexToInt(thStr.substring(0, 2)); |
| | | grain.setHumidityOut(humidity * 1.0); |
| | | substring = thStr.substring(2); |
| | | tem = BytesUtil.hexToInt(substring); |
| | | grain.setTempOut(tem * 1.0); |
| | | if(substring.startsWith("1")){ |
| | | grain.setTempOut(tem * -1.0); |
| | | } |
| | | |
| | | //解析仓内温仓内湿 |
| | | int thConf = Integer.valueOf(depotConf.getThConf()); |
| | | int start = 0, end = 6; |
| | | if(thConf > 1){ |
| | | start += 6*thConf; //12-18 |
| | | end += start; |
| | | } |
| | | thStr = msg.getThStr().substring(start, end); |
| | | humidity = BytesUtil.hexToInt(thStr.substring(0, 2)); |
| | | grain.setHumidityIn(humidity * 1.0); |
| | | substring = thStr.substring(2); |
| | | tem = BytesUtil.hexToInt(substring); |
| | | grain.setTempIn(tem * 1.0); |
| | | if(substring.startsWith("1")){ |
| | | grain.setTempIn(tem * -1.0); |
| | | } |
| | | |
| | | grain.setReceiveDate(new Date()); |
| | | grain.setRemark("粮温正常"); |
| | |
| | | grain.setTempMax(max); |
| | | grain.setTempMin(min); |
| | | grain.setPoints(StringUtils.join(temps, ",")); |
| | | //判断是否是锥形仓,是的话进行锥形仓补点 |
| | | if(StringUtils.isNotEmpty(depotConf.getCableCone())){ |
| | | //上锥形补点 |
| | | if(Constant.CABLE_CONE_1.equals(depotConf.getCableCone())){ |
| | | grain.setPoints(upConePoints(depotConf, grain.getPoints())); |
| | | } |
| | | //下锥形补点 |
| | | if(Constant.CABLE_CONE_2.equals(depotConf.getCableCone())){ |
| | | grain.setPoints(downConePoints(depotConf, grain.getPoints())); |
| | | } |
| | | } |
| | | |
| | | String depotIds = exeRequest.getDepotIds(); |
| | | boolean notifyWeb = true; |
| | |
| | | return temps; |
| | | } |
| | | |
| | | private String buildCurKey(ReMessage msg, int curPacket) { |
| | | return msg.getSerId() + "_" + curPacket; |
| | | /** |
| | | * 上锥形补点(点位位置正确,需要补点为-102) |
| | | * |
| | | * @param depotConf |
| | | * @param points |
| | | * @return |
| | | */ |
| | | private String upConePoints(DepotConf depotConf, String points){ |
| | | String[] cableRuleAtt = depotConf.getCableRule().split("-"); |
| | | String[] cableCirAtt = depotConf.getCableCir().split("-"); |
| | | //获取最大的层配置 |
| | | 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]); |
| | | } |
| | | } |
| | | //所在层从1开始 |
| | | int curLay = 1; |
| | | //所在根 |
| | | int curRoot = 1; |
| | | //所在圈 |
| | | int curCir = 1; |
| | | //当前圈的层 |
| | | int cirLay = 1; |
| | | String[] array = points.split(","); |
| | | |
| | | for (int i = 0; i < array.length; i++) { |
| | | curLay = (i % layMax) + 1; |
| | | curRoot = (i / layMax) + 1; |
| | | curCir = getCurCir(curRoot, cableRuleAtt); |
| | | cirLay = Integer.valueOf(cableCirAtt[curCir - 1]); |
| | | |
| | | //比如配置了5层但是当前是6层,说明当前点为补偿点 |
| | | if (curLay <= (layMax - cirLay)) { |
| | | array[i] = String.valueOf(Constant.ADD_TEMP); |
| | | } |
| | | } |
| | | return StringUtils.join(array, ","); |
| | | } |
| | | |
| | | private String buildContextKey(String companyId, String serId) { |
| | | return companyId + "_" + serId; |
| | | /** |
| | | * 下锥形补点(点位位置正确,需要补点为-102) |
| | | * |
| | | * @param depotConf |
| | | * @param points |
| | | * @return |
| | | */ |
| | | private String downConePoints(DepotConf depotConf, String points){ |
| | | String[] cableRuleAtt = depotConf.getCableRule().split("-"); |
| | | String[] cableCirAtt = depotConf.getCableCir().split("-"); |
| | | //获取最大的层配置 |
| | | 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]); |
| | | } |
| | | } |
| | | //所在层从1开始 |
| | | int curLay = 1; |
| | | //所在根 |
| | | int curRoot = 1; |
| | | //所在圈 |
| | | int curCir = 1; |
| | | //当前圈的层 |
| | | int cirLay = 1; |
| | | String[] array = points.split(","); |
| | | |
| | | for (int i = 0; i < array.length; i++) { |
| | | curLay = (i % layMax) + 1; |
| | | curRoot = (i / layMax) + 1; |
| | | curCir = getCurCir(curRoot, cableRuleAtt); |
| | | cirLay = Integer.valueOf(cableCirAtt[curCir - 1]); |
| | | |
| | | //比如配置了5层但是当前是6层,说明当前点为补偿点 |
| | | if (curLay > cirLay) { |
| | | array[i] = String.valueOf(Constant.ADD_TEMP); |
| | | } |
| | | } |
| | | return StringUtils.join(array, ","); |
| | | } |
| | | } |