Sfoglia il codice sorgente

三维图层倒转

hanqingsong 5 anni fa
parent
commit
958bdb668a

+ 25 - 4
src/main/java/com/chinaitop/depot/intelligent/grainsituation/service/impl/TemperatureRecordServiceImpl.java

@@ -74,11 +74,32 @@ public class TemperatureRecordServiceImpl implements TemperatureRecordService {
74 74
     public ArrayList<Object> findByHouseAndTimes(String lqId, String vCfCode, String vDatatime) {
75 75
         TTestdata byId = tTestdataMapper.getById(lqId).get(0);
76 76
         String s = byId.gettPoints();
77
-        ArrayList<Object> tP = JsonToObjectUtils.jsonToObjects(s, TPoints.class);
77
+
78
+        // 层倒叙 最小变最大, 最大变最小
79
+        List<TPoints> tP = JSON.parseArray(s, TPoints.class);
80
+        // 数据总长度
81
+        int size = tP.size();
82
+        // 层分组 总层数
83
+        Map<Integer, List<TPoints>> collect = tP.stream().collect(Collectors.groupingBy(point -> Integer.parseInt(point.getZ())));
84
+        Integer sizeZ = collect.size();
85
+        int i = 1; // 计数初始变量
86
+        int y = size / sizeZ; // 每层长度
78 87
         ArrayList<TPoints> tPoints = Lists.newArrayList();
79
-        tP.forEach(t -> {
80
-            tPoints.add((TPoints) t);
81
-        });
88
+        for (Integer integer : collect.keySet()) {
89
+            List<TPoints> tPoints1 = collect.get(integer);
90
+            for (TPoints tPoint : tPoints1) {
91
+                tPoint.setZ(sizeZ.toString()); // 倒叙放入层值
92
+                if (i == y) { // 每层有多少个点
93
+                    sizeZ--;
94
+                }
95
+                i++;
96
+                if (i > y) { // 到达每层点将初始计数初始化,执行替换为下一个sizeZ--
97
+                    i = 1;
98
+                }
99
+                tPoints.add(tPoint); // 重新添加到list
100
+            }
101
+        }
102
+
82 103
         ArrayList<Object> objects = Lists.newArrayList();
83 104
         if (tPoints.size() > 0) {
84 105
             Map<Integer, Map<Integer, Map<Integer, List<TPoints>>>> collect1 = tPoints.stream().collect(Collectors.groupingBy(t -> Integer.parseInt(t.getZ()), Collectors.groupingBy(t -> Integer.parseInt(t.getX()), Collectors.groupingBy(t -> Integer.parseInt(t.getY())))));