CZT
2023-09-04 fae4bd828a6b81b95f53e285fcb4749fbd80c7bf
igds-protocol-zldz/src/main/java/com/ld/igds/protocol/zldz/analysis/AnalysisGrain.java
@@ -508,6 +508,17 @@
            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]);
@@ -671,6 +682,24 @@
                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())) {
            //若起始方位为空,则默认起始方位和方向,直接返回
@@ -730,90 +759,5 @@
        }
        return temps;
    }
    /**
     * 反转列 现实中从左边开始,强行将右边解析为第一列
     *
     * @return
     */
    private List<Double> reversalCable(List<Double> temps, String cable) {
        String[] attCable = cable.split("-");
        int cableZ = Integer.valueOf(attCable[0]);
        int cableY = Integer.valueOf(attCable[1]);
        int cableX = Integer.valueOf(attCable[2]);
        List<Double> t = new ArrayList<>();
        for (int i = 1; i <= temps.size(); i++) {
            t.add(temps.get((cableX - 1) * cableY * cableZ + ((i - 1) % (cableY * cableZ))));
            if (i % (cableY * cableZ) == 0) {
                cableX = cableX - 1;
            }
        }
        return t;
    }
    /**
     * 电缆从下面开始时,将粮情电缆上下翻转
     *
     * @param pointsData 粮情数据
     * @param cable      层行列配置,如:4-7-11
     * @return
     */
    private String reversalUpAndDown(String pointsData, String cable) {
        String str = "";
        if (StringUtils.isEmpty(cable)) {
            str = pointsData;
        }
        String[] attCable = cable.split("-");
        int cableZ = Integer.valueOf(attCable[0]); //层
        String[] points = pointsData.split(",");
        for (int i = 0; i <= points.length - cableZ; i += cableZ) {
            for (int j = cableZ - 1; j >= 0; j--) {
                str += points[i + j];
                str += ",";
            }
        }
        return str;
    }
    /**
     * 反转列号验证
     * 2022年5月30日 12:11:18
     * vince
     *
     * @param args
     */
    public static void main(String[] args) {
        List<Double> temps = new ArrayList<>();
        int cableZ = 3;
        int cableY = 4;
        int cableX = 6;
        for (int i = 1; i < (cableX * cableY * cableZ + 1); i++) {
            temps.add(i + 0.0);
        }
        List<Double> t = new ArrayList<>();
        for (int i = 1; i <= temps.size(); i++) {
            t.add(temps.get((cableX - 1) * cableY * cableZ + ((i - 1) % (cableY * cableZ))));
            if (i % (cableY * cableZ) == 0) {
                cableX = cableX - 1;
            }
        }
        for (Double x : t) {
            System.out.print(x);
            System.out.print(",");
        }
        System.out.println("--------------------------");
        int i = 15;
        int layMax = 10;
        System.out.println(i % layMax);
        System.out.println(i / layMax);
    }
}