YYC
2025-09-22 f43613cc5aba07a9cb0482b7171ae6569c901e50
src/main/java/com/fzzy/async/fzzy40/impl/Fzzy40Sync1302.java
@@ -24,7 +24,7 @@
/**
 * 温湿度检测数据同步
 *
 * @author chen
 * @author czt
 * @date 2022-09-07 14:41
 */
@Slf4j
@@ -48,7 +48,7 @@
     * @param start  起始时间
     * @param end    截止时间
     */
    public void syncData(String deptId, Date start, Date end) {
    public void syncData(String kqdm, String deptId, Date start, Date end) {
        log.info("-------------1302接口数据开始同步------------------");
        //同步数据,只记录失败的信息
@@ -61,13 +61,12 @@
        apiLog.setId(ContextUtil.getUUID());
        try {
            List<Fz40Grain> list = fzzySync1302Rep.findByReceiveDate(start, end);
            log.info(DateUtils.format("yyyy-MM-dd HH:mm:ss",start));
            log.info(DateUtils.format("yyyy-MM-dd HH:mm:ss",end));
            if (null == list || list.isEmpty()) {
                log.info("1302---同步数据:没有查询到需要同步的数据");
                return;
            }
            log.info(JSONObject.toJSONString(list));
            Date syncTime = new Date();
            Api1302 api1302;
            Api1105 api1105;
@@ -85,42 +84,62 @@
                api1302.setJcsj(fz40Grain.getReceiveDate());
                api1302.setHwdm(api1105.getHwdm());
                api1302.setCfww(fz40Grain.getTempOut() == null ? 0.00: fz40Grain.getTempOut());
                if(null == fz40Grain.getHumidityOut() || fz40Grain.getHumidityOut() < 0){
                api1302.setCfww(fz40Grain.getTempOut() == null ? 0.00 : fz40Grain.getTempOut());
                if (null == fz40Grain.getHumidityOut() || fz40Grain.getHumidityOut() < 0) {
                    api1302.setCfws(-1);
                }else {
                } else {
                    api1302.setCfws(fz40Grain.getHumidityOut());
                }
                api1302.setCfnw(fz40Grain.getTempIn() == null ? 0.00: fz40Grain.getTempIn());
                if(null == fz40Grain.getHumidityIn() || fz40Grain.getHumidityIn() < 0){
                    api1302.setCfns(-1);
                }else {
                api1302.setCfnw(fz40Grain.getTempIn() == null ? 0.00 : fz40Grain.getTempIn());
                if (null == fz40Grain.getHumidityIn() || fz40Grain.getHumidityIn() < 0) {
                    api1302.setCfns(0);
                } else {
                    api1302.setCfns(fz40Grain.getHumidityIn());
                }
                api1302.setLszgw(fz40Grain.getTempMax() == null ? 0.00: fz40Grain.getTempMax());
                api1302.setLspjw(fz40Grain.getTempAve() == null ? 0.00: fz40Grain.getTempAve());
                api1302.setLszdw(fz40Grain.getTempMin() == null ? 0.00: fz40Grain.getTempMin());
                api1302.setLszgw(fz40Grain.getTempMax() == null ? 0.00 : fz40Grain.getTempMax());
                api1302.setLspjw(fz40Grain.getTempAve() == null ? 0.00 : fz40Grain.getTempAve());
                api1302.setLszdw(fz40Grain.getTempMin() == null ? 0.00 : fz40Grain.getTempMin());
                //判断粮食最低温、平均温、最高温是否符合逻辑
                if (api1302.getLszdw() >= api1302.getLspjw()) {
                    continue;
                }
                if (api1302.getLspjw() >= api1302.getLszgw()) {
                    continue;
                }
                //温度集合
                if (StringUtils.isEmpty(fz40Grain.getCableCir())) {
                    api1302.setLswdzjh(getTempPointList1(fz40Grain.getPoints(), fz40Grain.getCable()));
                    api1302.setLssdzjh(getHumPointList1(fz40Grain.getPoints(), fz40Grain.getCable()));
                    if(StringUtils.isEmpty(api1302.getLswdzjh())){
                        continue;
                    }
                    if(StringUtils.isEmpty(api1302.getLssdzjh())){
                        continue;
                    }
                } else {
                    api1302.setLswdzjh(getTempPointList2(fz40Grain.getPoints(), fz40Grain.getCable(), fz40Grain.getCableCir()));
                    api1302.setLssdzjh(getHumPointList2(fz40Grain.getPoints(), fz40Grain.getCable(), fz40Grain.getCableCir()));
                    if(StringUtils.isEmpty(api1302.getLswdzjh())){
                        continue;
                    }
                    if(StringUtils.isEmpty(api1302.getLssdzjh())){
                        continue;
                    }
                }
                api1302.setZhgxsj(fz40Grain.getReceiveDate());
                api1302.setZhgxsj(new Date());
                api1302.setBizId(fz40Grain.getBatchId());
                api1302.setKqdm(api1105.getKqdm());
                api1302.setSyncTime(syncTime);
                api1302List = api1302Rep.getDataByWsdjcdh(api1302.getWsdjcdh());
                if(null == api1302List || api1302List.isEmpty()){
                if (null == api1302List || api1302List.isEmpty()) {
                    api1302.setCzbz(Constant.CZBZ_I);
                }else {
                } else {
                    api1302.setCzbz(api1302List.get(0).getCzbz());
                }
                log.info("1302---同步数据:" + api1302.toString());
@@ -135,12 +154,19 @@
    }
    public static void main(String[] args) {
        String point = "31.8,20.0,15.1,18.6,28.2,14.3,11.3,16.1,28.1,15.6,13.3,18.4,28.8,16.6,10.2,14.4,27.8,14.3,10.8,16.0,27.5,14.5,11.7,17.1,26.5,13.6,10.1,15.0,29.7,17.4,13.8,17.8,29.7,18.6,15.0,18.6,26.4,13.5,9.2,13.1,27.6,11.8,8.9,13.5,28.1,12.0,8.6,12.8,27.8,11.6,7.6,12.4,26.1,10.8,7.5,12.6,27.8,10.3,7.1,12.0,26.1,11.3,8.5,12.7,28.6,16.9,12.9,17.7,29.1,12.3,8.8,12.1,27.4,11.9,8.6,12.8,29.0,11.5,7.6,11.1,26.9,10.2,8.0,12.7,27.0,9.6,7.7,13.5,26.7,9.5,7.1,12.3,26.3,10.7,8.4,13.4,27.6,15.9,11.5,15.8,28.7,12.6,8.7,12.2,28.1,12.2,8.8,12.5,30.3,11.9,8.0,12.0,27.9,11.1,7.8,11.5,26.3,10.1,7.8,12.0,27.2,10.5,6.9,11.1,27.1,11.6,9.5,13.6,27.4,14.8,10.7,16.6,27.7,12.4,9.1,13.0,27.7,13.2,9.0,12.8,27.5,12.1,8.1,12.6,26.6,11.8,7.3,12.3,26.8,10.5,8.0,13.3,26.3,11.0,7.6,12.5,26.1,10.6,8.5,13.5,29.8,21.3,15.5,17.8,28.3,18.2,11.6,12.8,29.4,17.4,13.0,16.1,28.4,22.3,14.6,15.4,28.7,17.5,11.8,15.2,26.5,14.6,10.9,14.8,27.8,15.3,10.3,14.8,27.6,16.7,13.6,17.4";
        String cable = "4-6-8";
        String tempPointList1 = getTempPointList1(point, cable);
        System.out.println(tempPointList1);
    }
    /**
     * 获取平方仓的温度值集合,格式:温度值,层数,行数,列数|温度值,层数,行数,列数|温度值,层数,行数,列数
     *
     * @return
     */
    private String getTempPointList1(String point, String cable) {
    private static String getTempPointList1(String point, String cable) {
        String[] cab = cable.split("-");
        int c = Integer.valueOf(cab[0]);
        int h = Integer.valueOf(cab[1]);
@@ -148,14 +174,20 @@
        String[] points = point.split(",");
        String result = "";
        if (c * h * l > points.length) {
            return result;
        }
        for (int i = 1; i <= l; i++) {
            for (int j = 1; j <= h; j++) {
                for (int z = 1; z <= c; z++) {
                    result += ("|" + points[(i * j - 1) * c + z - 1] + "," + z + "," + j + "," + i);
                    result += ("|" + points[((i-1)*h+j-1)*c + z -1] + "," + z + "," + j + "," + i);
                }
            }
        }
        return result.substring(1);
        if(result.length() > 0){
            result = result.substring(1);
        }
        return result;
    }
    /**
@@ -186,7 +218,10 @@
            }
        }
        return result.substring(1);
        if(result.length() > 0){
            result = result.substring(1);
        }
        return result;
    }
    /**
@@ -200,7 +235,7 @@
        int h = Integer.valueOf(cab[1]);
        int l = Integer.valueOf(cab[2]);
       // String[] points = point.split(",");
        // String[] points = point.split(",");
        String result = "";
        for (int i = 1; i <= l; i++) {
            for (int j = 1; j <= h; j++) {
@@ -209,7 +244,10 @@
                }
            }
        }
        return result.substring(1);
        if(result.length() > 0){
            result = result.substring(1);
        }
        return result;
    }
    /**
@@ -227,7 +265,7 @@
        int g1 = 1;  //圈起始根数
        int g2 = 0;  //圈截止根数
      //  String[] points = point.split(",");
        //  String[] points = point.split(",");
        String result = "";
        for (int i = 1; i <= q; i++) {
            g1 += g2;
@@ -240,6 +278,9 @@
            }
        }
        return result.substring(1);
        if(result.length() > 0){
            result = result.substring(1);
        }
        return result;
    }
}