Jelajahi Sumber

统计经编生产长度时增加规格

wukai 2 minggu lalu
induk
melakukan
5e3116a9e4

+ 2 - 2
jjt-admin/src/test/java/com/jjt/task/TaskEmpTest.java

@@ -25,10 +25,10 @@ public class TaskEmpTest {
 
     @Test
     public void test() throws Exception {
-        String date = "2025-07-23";
+        String date = "2025-07-30";
         LocalDate localDate = LocalDate.parse(date);
         empService.sync(DateUtils.toDate(localDate));
-//        calcService.calc(DateUtils.toDate(localDate));
+        calcService.calc(DateUtils.toDate(localDate));
     }
 
 }

+ 6 - 2
jjt-admin/src/test/java/com/jjt/task/TaskTest.java

@@ -38,10 +38,14 @@ public class TaskTest {
     public void curr() {
         apiService.curr();
     }
-
+    @Test
+    public void last(){
+        iotService.setToken();
+        calcHourService.last();
+    }
 
     @Test
-    public void last() {
+    public void time() {
         iotService.setToken();
         String date = "2025-07-29";
         LocalDate localDate = LocalDate.parse(date);

+ 1 - 1
jjt-biz/src/main/java/com/jjt/calc/service/impl/TwinCalcHourServiceImpl.java

@@ -190,7 +190,7 @@ public class TwinCalcHourServiceImpl implements ITwinCalcHourService {
         //TODO 临时设置单个设备,上线需取消
 //        search.setDeviceId(175L);
 //        Map<String,Object> params = new HashMap<>();
-//        params.put("ids", new int[]{137, 138});
+//        params.put("ids", new int[]{120});
 //        search.setParams(params);
         List<TwinDevice> list = deviceService.selectTwinDeviceList(search);
         List<TwinDevice> errList = exec(list, start, end);

+ 8 - 3
jjt-biz/src/main/java/com/jjt/emp/service/impl/TwinEmpCalcServiceImpl.java

@@ -133,7 +133,7 @@ public class TwinEmpCalcServiceImpl implements ITwinEmpCalcService {
         List<TwinCalcHourSpec> specHourList = hourSpecService.selectTwinCalcHourSpecListByDate(date);
         specHourList.forEach(TwinCalcHourSpec::setTeam);
         // 按照deviceId、density、mick、team,并统计每组的length总和
-        Map<String, List<TwinCalcHourSpec>> specHourMap = specHourList.stream().collect(Collectors.groupingBy(o -> o.getDeviceId() + "-" + o.getTeam(), LinkedHashMap::new, Collectors.toList()));
+//        Map<String, List<TwinCalcHourSpec>> specHourMap = specHourList.stream().collect(Collectors.groupingBy(o -> o.getDeviceId() + "-" + o.getTeam(), LinkedHashMap::new, Collectors.toList()));
         List<TwinCalcDay> twinCalcDays = twinCalcDayService.selectTwinCalcDayListByTime(date, date);
         Map<Long, TwinCalcDay> calcMap = twinCalcDays.stream().collect(Collectors.toMap(TwinCalcDay::getDeviceId, o -> o));
         Map<Long, BigDecimal> effMap = twinCalcDays.stream().collect(Collectors.toMap(TwinCalcDay::getDeviceId, TwinCalcDay::getEfficiency));
@@ -241,9 +241,9 @@ public class TwinEmpCalcServiceImpl implements ITwinEmpCalcService {
 //                    List<TwinCalcHourSpec> hourList = specs.stream().filter(t -> t.getHour() == hour).collect(Collectors.toList());
 //                }
                 //按密度和米克重、毛高分组统计
-                Map<String, BigDecimal> resultMap = hourList.stream().collect(Collectors.groupingBy(t -> t.getDensity() + "-" + t.getMick() + "-" + t.getHeight(), Collectors.reducing(BigDecimal.ZERO, TwinCalcHourSpec::getLength, BigDecimal::add)));
+                Map<String, BigDecimal> resultMap = hourList.stream().collect(Collectors.groupingBy(t -> t.getDensity() + "||" + t.getMick() + "||" + t.getHeight() + "||" + t.getSpec(), Collectors.reducing(BigDecimal.ZERO, TwinCalcHourSpec::getLength, BigDecimal::add)));
                 for (String ss : resultMap.keySet()) {
-                    String[] temp = ss.split("-");
+                    String[] temp = ss.split("\\|\\|");
                     BigDecimal density = new BigDecimal(temp[0]).setScale(2, RoundingMode.HALF_UP);
                     Integer mick = Integer.parseInt(temp[1]);
                     TwinEmpCalc calc = new TwinEmpCalc();
@@ -252,6 +252,11 @@ public class TwinEmpCalcServiceImpl implements ITwinEmpCalcService {
                         BigDecimal height = new BigDecimal(temp[2]).setScale(2, RoundingMode.HALF_UP);
                         calc.setHeight(height);
                     }
+                    if (temp.length == 4 && StringUtils.isNotEmpty(temp[3]) && !"null".equals(temp[3])) {
+                        calc.setSpec(temp[3]);
+                    } else {
+                        calc.setSpec("");
+                    }
                     calc.setEfficiency(effMap.get(deviceId));
                     calc.setEmpDate(emp.getEmpDate());
                     BigDecimal length = resultMap.get(ss);