廖井涛
2025-07-23 25ae4025978ef7498db9790b237fa5a26698b1ec
north-glass-erp/src/main/java/com/example/erp/service/pp/ReportService.java
@@ -5,7 +5,6 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.erp.dto.pp.*;
import com.example.erp.entity.pp.DamageDetails;
import com.example.erp.entity.pp.Report;
import com.example.erp.entity.sd.BasicData;
import com.example.erp.entity.sd.OrderDetail;
@@ -14,19 +13,20 @@
import com.example.erp.mapper.pp.FlowCardMapper;
import com.example.erp.mapper.pp.ProductionSchedulingMapper;
import com.example.erp.mapper.pp.ReportMapper;
import com.example.erp.mapper.pp.ReportingWorkMapper;
import com.example.erp.mapper.sd.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
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.concurrent.Executor;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.hutool.core.convert.Convert.toDouble;
@Service
@DS("pp")
@@ -42,6 +42,7 @@
    private final OrderDetailMapper orderDetailMapper;
    FlowCardMapper flowCardMapper;
    private ReportingWorkMapper reportingWorkMapper;
    //上工序报工班组
@@ -116,7 +117,11 @@
    }
    public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper, ProductionSchedulingMapper productionSchedulingMapper, FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, BasicDataMapper basicDataMapper, ProductDetailMapper productDetailMapper, OrderDetailMapper orderDetailMapper) {
    public ReportService(ReportMapper reportMapper, OrderProcessDetailMapper orderProcessDetailMapper,
                         ProductionSchedulingMapper productionSchedulingMapper, FlowCardMapper flowCardMapper,
                         OrderGlassDetailMapper orderGlassDetailMapper, BasicDataMapper basicDataMapper,
                         ProductDetailMapper productDetailMapper, OrderDetailMapper orderDetailMapper,
                         ReportingWorkMapper reportingWorkMapper) {
        this.reportMapper = reportMapper;
        this.orderProcessDetailMapper = orderProcessDetailMapper;
        this.productionSchedulingMapper = productionSchedulingMapper;
@@ -125,6 +130,7 @@
        this.basicDataMapper = basicDataMapper;
        this.productDetailMapper = productDetailMapper;
        this.orderDetailMapper = orderDetailMapper;
        this.reportingWorkMapper = reportingWorkMapper;
    }
    //流程卡进度方法
@@ -241,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);
@@ -250,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);
@@ -290,7 +294,7 @@
        return map;
    }
    public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, DamageReportDTO damageReportDTO) {
    public Map<String, Object> selectDamageReportSv(Integer pageNum, Integer pageSize, String selectTime1, String selectTime2, DamageReportDTO damageReportDTO) {
        Integer offset = (pageNum - 1) * pageSize;
        Map<String, Object> map = new HashMap<>();
        map.put("data", reportMapper.selectDamageReportMp(offset, pageSize, selectTime1, selectTime2, damageReportDTO));
@@ -479,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) {
@@ -581,28 +592,142 @@
        return reportMapper.exportTeamOutputMp(date,process,laminating);
    }
    public Map<String, Object> workInProgressCombinationSv(Integer pageNum, Integer pageSize, 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 = "";
        }
        if ("null".equals(inputProject)) {
            inputProject = "";
        }
        if ("null".equals(optionVal)) {
            optionVal = ("");
            optionVal = "";
        }
        if (selectProcesses.equals("全部")){
            selectProcesses="";
        if ("全部".equals(selectProcesses)) {
            selectProcesses = "";
        }
        String laminating = "";
        Map<String, Object> map = new HashMap<>();
        List<WorkInProgressDTO> dataList2  =reportMapper.workInProgressCombinationMpdataList2(offset, pageSize, selectProcesses, workInProgressDTO);
        Map<String, Double> totalSumMap = new HashMap<>();
            //没有选择分组
            //map.put("data", reportMapper.workInProgressMp(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            List<WorkInProgressDTO> dataList1  =reportMapper.workInProgressCombinationMpdataList1(offset, pageSize,  selectProcesses, workInProgressDTO);
            mergeTeamsGroupsName(dataList1, dataList2);
            map.put("data",dataList1);
            //map.put("total", reportMapper.workInProgressTotal(offset, pageSize, orderId, inputProject, selectProcesses, workInProgressDTO));
            map.put("total" ,reportMapper.workInProgressCombinationOrderFootSum(offset, pageSize, selectProcesses, workInProgressDTO));
        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);
                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();
                    }
                }
            }
        }
        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;
    }
}