Fancy
2024-09-10 939d5f3d5e17e5ca0bfeec9c23c7c926b4cb1684
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/screen/ScreenReportSv.java
@@ -1,7 +1,10 @@
package com.dy.pmsOther.screen;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.dy.pmsGlobal.daoPr.PrAssemblyPlanMapper;
import com.dy.pmsGlobal.daoSta.*;
import com.dy.pmsGlobal.pojoSta.*;
import lombok.extern.slf4j.Slf4j;
@@ -18,6 +21,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
@Slf4j
@Service
@@ -27,6 +32,7 @@
    private StaWipSnExMapper wipSnExDao;
    private StaDeviceProductionLogMapper deviceProductionLogDao;
    private StaRepairInfoMapper repairInfoDao;
    private PrAssemblyPlanMapper assemblyPlanDao;
    @Autowired
    public void setDeviceLastDao(StaDeviceLastMapper deviceLastDao) {
        this.deviceLastDao = deviceLastDao;
@@ -45,6 +51,11 @@
    @Autowired
    public void setDeviceProductionLogDao(StaDeviceProductionLogMapper deviceProductionLogDao) {
        this.deviceProductionLogDao = deviceProductionLogDao;
    }
    @Autowired
    public void setAssemblyPlanDao(PrAssemblyPlanMapper assemblyPlanDao) {
        this.assemblyPlanDao = assemblyPlanDao;
    }
    @Autowired
@@ -98,4 +109,33 @@
        Date date = Date.from(dt.atZone(ZoneId.systemDefault()).toInstant());
        return date;
    }
    public List<JSONObject> queryPlanList() {
        List<JSONObject> list = assemblyPlanDao.queryPlanList();
        Map<String, JSONObject> map = new ConcurrentHashMap<>(); // 使用并发安全的Map
        for(JSONObject item:list){
            String planId = String.valueOf(item.getObj("planId"));
            JSONObject innerObject = new JSONObject()
                    .set("nodeId", String.valueOf(item.getObj("nodeId")))
                    .set("content", item.getObj("content"));
            if(map.containsKey(planId)){
                JSONArray array = (JSONArray)map.get(planId).get("nodes");
                array.add(innerObject);
            }else{
                JSONArray array = new JSONArray();
                array.add(innerObject);
                JSONObject outObject= new JSONObject()
                        .set("planId", planId)
                        .set("planName", item.getObj("planName"))
                        .set("nodes", array);
                map.put(planId,outObject);
            }
        }
        return map.values().stream().collect(Collectors.toList());
    }
}