廖井涛
2025-07-23 25ae4025978ef7498db9790b237fa5a26698b1ec
north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java
@@ -18,11 +18,15 @@
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.sql.Date;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.hutool.core.convert.Convert.toDouble;
@Service
@DS("pp")
@@ -243,7 +247,6 @@
        Map<String, Object> map = new HashMap<>();
        List<WorkInProgressDTO> dataList2  =reportMapper.workInProgressMpdataList2(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO);
        if (optionVal.equals("1")){
            System.out.println(1);
            /* 根据销售单号汇总*/
            //map.put("data", reportMapper.workInProgressOrderMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            List<WorkInProgressDTO> dataList1  =reportMapper.workInProgressOrderMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO);
@@ -252,7 +255,6 @@
            // map.put("total", reportMapper.workInProgressOrderTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            map.put("total" ,reportMapper.workInProgressOrderFootSum(offset, pageSize,orderId, inputProject, selectProcesses, workInProgressDTO));
        }else if(optionVal.equals("2")){
            System.out.println(2);
            /* 根据流程卡号汇总*/
            //map.put("data", reportMapper.workInProgressProcessMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            List<WorkInProgressDTO> dataList1  =reportMapper.workInProgressProcessMpList1(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO);
@@ -481,11 +483,18 @@
        return reportMapper.exportCrossProcessBreakingMp(dates);
    }
    public List exportDamageReportSv(List<LocalDate> dates) {
        if (dates != null && dates.size() > 1) {
            dates.set(1, dates.get(1).plusDays(1)); // 将第二个日期加一天
        }
        return reportMapper.exportDamageReportMp(dates);
    //    public List exportTeamOutputSv(Map<String, Object> dates) {
//        List<LocalDate> date= (List<LocalDate>) dates.get("date");
//        String process= (String) dates.get("processes");
//        if (process.equals("全部")){
//            process="";
//        }
//        String laminating = reportMapper.getLaminating(process);
//        return reportMapper.exportTeamOutputMp(date,process,laminating);
//    }
    public List exportDamageReportSv(Map<String, Object> dates) {
        List<LocalDate> date= (List<LocalDate>) dates.get("date");
        return reportMapper.exportDamageReportMp(date);
    }
    public List exportOrderPlanDecompositionSv(List<LocalDate> dates) {
@@ -583,8 +592,13 @@
        return reportMapper.exportTeamOutputMp(date,process,laminating);
    }
    public Map<String, Object> workInProgressCombinationSv(Integer pageNum, Integer pageSize,String orderId, String inputProject, String selectProcesses, String optionVal, WorkInProgressDTO workInProgressDTO) {
    public Map<String, Object> workInProgressCombinationSv(
            Integer pageNum, Integer pageSize,
            String orderId, String inputProject, String selectProcesses,
            String optionVal, WorkInProgressDTO workInProgressDTO) {
        Integer offset = (pageNum - 1) * pageSize;
        if ("null".equals(orderId)) {
            orderId = "";
        }
@@ -592,36 +606,128 @@
            inputProject = "";
        }
        if ("null".equals(optionVal)) {
            optionVal = ("");
            optionVal = "";
        }
        if (selectProcesses.equals("全部")){
            selectProcesses="";
        if ("全部".equals(selectProcesses)) {
            selectProcesses = "";
        }
        String laminating = "";
        Map<String, Object> map = new HashMap<>();
        // 获取所有工序
        List<String> processList  = reportMapper.selectProcess();
        // 遍历每个工序并调用新方法
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (selectProcesses!=""){
            laminating = reportingWorkMapper.getProcessLaminating(selectProcesses);
            List<Map<String, Object>> singleResult = reportMapper.getWorkInProgressCombination(selectProcesses,laminating,optionVal);
        Map<String, Double> totalSumMap = new HashMap<>();
            resultList.addAll(singleResult);
        }else {
        double totalStockNum = 0;
        double totalStockArea = 0;
        // 获取所有工序
        List<String> processList = reportMapper.selectProcess();
        // 最终数据集合
        List<Map<String, Object>> resultList = new ArrayList<>();
        if (!"".equals(selectProcesses)) {
            laminating = reportingWorkMapper.getProcessLaminating(selectProcesses);
            List<Map<String, Object>> singleResult =
                    reportMapper.getWorkInProgressCombination(selectProcesses, laminating, optionVal);
            if (singleResult != null && !singleResult.isEmpty()) {
                resultList.addAll(singleResult);
            }
            Map<String, Object> total =
                    reportMapper.getWorkInProgressCombinationFootSum(selectProcesses, laminating, optionVal);
            if (total != null) {
                BigDecimal stockNum = (BigDecimal) total.get("stockNum");
                BigDecimal stockArea = (BigDecimal) total.get("stockArea");
                if (stockNum != null) {
                    totalStockNum += stockNum.doubleValue();
                }
                if (stockArea != null) {
                    totalStockArea += stockArea.doubleValue();
                }
            }
        } else {
            for (String process : processList) {
                //获取报工工序是否为复合工程
                laminating = reportingWorkMapper.getProcessLaminating(process);
                List<Map<String, Object>> singleResult = reportMapper.getWorkInProgressCombination(process,laminating,optionVal);
                List<Map<String, Object>> singleResult =
                        reportMapper.getWorkInProgressCombination(process, laminating, optionVal);
                if (singleResult != null && !singleResult.isEmpty()) {
                    resultList.addAll(singleResult);
                }
                Map<String, Object> total =
                        reportMapper.getWorkInProgressCombinationFootSum(process, laminating, optionVal);
                if (total != null) {
                    BigDecimal stockNum = (BigDecimal) total.get("stockNum");
                    BigDecimal stockArea = (BigDecimal) total.get("stockArea");
                    if (stockNum != null) {
                        totalStockNum += stockNum.doubleValue();
                    }
                    if (stockArea != null) {
                        totalStockArea += stockArea.doubleValue();
                    }
                }
            }
        }
        map.put("data",resultList);
        totalSumMap.put("stockNum", totalStockNum);
        totalSumMap.put("stockArea", totalStockArea);
        map.put("data", resultList);
        map.put("total", totalSumMap);
        map.put("process", productionSchedulingMapper.selectProcess());
        return map;
    }
    public List exportWorkInProgressCombinationSv(Map<String, Object> dates) {
        String process= (String) dates.get("processes");
        if (process.equals("全部")){
            process="";
        }
        String inputVal= (String) dates.get("inputVal");
        String project= (String) dates.get("project");
        if ("null".equals(inputVal)) {
            inputVal = "";
        }
        if ("null".equals(project)) {
            project = "";
        }
        String laminating = "";
        // 获取所有工序
        List<String> processList = reportMapper.selectProcess();
        // 最终数据集合
        List<WorkInProgressCombinationDTO> resultList = new ArrayList<>();
        if (!"".equals(process)) {
            laminating = reportingWorkMapper.getProcessLaminating(process);
            List<WorkInProgressCombinationDTO> singleResult =
                    reportMapper.exportWorkInProgressCombination(process, laminating, inputVal);
            if (singleResult != null && !singleResult.isEmpty()) {
                resultList.addAll((Collection<? extends WorkInProgressCombinationDTO>) singleResult);
            }
        } else {
            for (String processVal : processList) {
                laminating = reportingWorkMapper.getProcessLaminating(processVal);
                List<WorkInProgressCombinationDTO> singleResult =
                        reportMapper.exportWorkInProgressCombination(processVal, laminating, inputVal);
                if (singleResult != null && !singleResult.isEmpty()) {
                    resultList.addAll((Collection<? extends WorkInProgressCombinationDTO>) singleResult);
                }
            }
        }
        return resultList;
    }
}