瀏覽代碼

退火调度优化

fangpy 1 周之前
父節點
當前提交
3903cdf349
共有 1 個文件被更改,包括 44 次插入3 次删除
  1. 44 3
      rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/util/StringToJsonUtil.java

+ 44 - 3
rw-aps-server/src/main/java/com/rongwei/rwapsserver/aps/util/StringToJsonUtil.java

@@ -5,13 +5,13 @@ import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
 import com.rongwei.rwapsserver.aps.domain.ProductionProcesses;
 import com.rongwei.rwapsserver.aps.vo.ProductionScheduleRetVo;
+import com.rongwei.rwapsserver.aps.vo.ProductionScheduleVo;
 
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
+import java.time.format.DateTimeFormatter;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -31,11 +31,52 @@ public class StringToJsonUtil {
         return res;
     }
 
+    public static ProductionScheduleVo readFromParJson(String filePath) throws IOException {
+
+        List<String> strings = Files.readAllLines(Paths.get(filePath));
+        StringBuilder jsonStr = new StringBuilder();
+        for (String string : strings) {
+            jsonStr.append(string);
+        }
+        JSONObject parse = JSONUtil.parseObj(jsonStr.toString());
+        ProductionScheduleVo res = BeanUtil.toBean(parse, ProductionScheduleVo.class);
+        return res;
+    }
+
     public static void main(String[] args) throws IOException {
         String filePath = "E:\\temp\\cx\\logs\\rw-aps-log\\retjson.txt";
         ProductionScheduleRetVo productionScheduleRetVo = readFromJson(filePath);
         List<ProductionProcesses> processes = productionScheduleRetVo.getProcesses().stream().filter(v -> !v.getIfLock() && v.getEquipmentId().equals("0001be252874536843730b100151")).collect(Collectors.toList());
         Collections.sort(processes, Comparator.comparing(pro -> pro.getStartTime()));
+
+        /*Map<String,List<ProductionProcesses>> thGroup = new HashMap<>();
+        DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        for (ProductionProcesses process : productionScheduleRetVo.getProcesses()) {
+            if(process.getEquipment() == null || process.getStartTime() == null){
+                int aaa = 0;
+            }
+            String thkey = process.getEquipmentId() + format.format(process.getStartTime());
+            if(thGroup.containsKey(thkey)){
+                thGroup.get(thkey).add(process);
+            }else{
+                List<ProductionProcesses> thpros = new ArrayList<>();
+                thpros.add(process);
+                thGroup.put(thkey,thpros);
+            }
+        }*/
+
+        List<ProductionProcesses> exPros = productionScheduleRetVo.getProcesses().stream().filter(v -> v.getProduceOrder().get(0).getOrderNo().equals("PL202504290111")).collect(Collectors.toList());
+
+        List<ProductionProcesses> testList = productionScheduleRetVo.getProcesses().stream().filter(v ->
+                v.getEquipmentId().equals("416d2f1a763c4160be2f9480e264e05c") && !v.getIfLock()).collect(Collectors.toList());
+        testList.sort(Comparator.comparing(ProductionProcesses::getStartTimeStr));
+
         System.out.println(processes.size());
+
+        /*ProductionScheduleVo productionScheduleVo = readFromParJson(filePath);
+
+        List<ProductionProcesses> exPros = productionScheduleVo.getProcesses().stream().filter(v -> !v.getIfLock() && v.getLastHistoryEquipmentId() != null && !v.getOptionalEquipments().contains(v.getLastHistoryEquipmentId())).collect(Collectors.toList());
+
+        System.out.println(exPros.size());*/
     }
 }