guoyujie
2025-07-08 7104751e2f26872d4891d01d42ee88cf19715d01
north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java
@@ -7,14 +7,11 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.erp.common.Constants;
import com.example.erp.entity.pp.FlowCard;
import com.example.erp.entity.sd.OrderDetail;
import com.example.erp.entity.sd.OrderGlassDetail;
import com.example.erp.entity.sd.OrderProcessDetail;
import com.example.erp.entity.sd.*;
import com.example.erp.entity.userInfo.Log;
import com.example.erp.exception.ServiceException;
import com.example.erp.mapper.pp.FlowCardMapper;
import com.example.erp.mapper.sd.OrderGlassDetailMapper;
import com.example.erp.mapper.sd.OrderProcessDetailMapper;
import com.example.erp.mapper.sd.*;
import com.example.erp.service.userInfo.LogService;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Service;
@@ -45,12 +42,21 @@
    OrderProcessDetailMapper orderProcessDetailMapper;
    final
    LogService logService;
    private final ProductMapper productMapper;
    private final ProductDetailMapper productDetailMapper;
    public FlowCardService(FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, LogService logService) {
    private final OrderDetailMapper orderDetailMapper;
    private final OrderMapper orderMapper;
    public FlowCardService(FlowCardMapper flowCardMapper, OrderGlassDetailMapper orderGlassDetailMapper, OrderProcessDetailMapper orderProcessDetailMapper, LogService logService, ProductMapper productMapper, ProductDetailMapper productDetailMapper, OrderDetailMapper orderDetailMapper, OrderMapper orderMapper) {
        this.flowCardMapper = flowCardMapper;
        this.orderGlassDetailMapper = orderGlassDetailMapper;
        this.orderProcessDetailMapper = orderProcessDetailMapper;
        this.logService = logService;
        this.productMapper = productMapper;
        this.productDetailMapper = productDetailMapper;
        this.orderDetailMapper = orderDetailMapper;
        this.orderMapper = orderMapper;
    }
    //流程卡管理查询
@@ -290,7 +296,7 @@
        }
    }
    public Map<String, Object> getSelectPrintingSv(Map<String, Object> object, String printMerge, String printLike, String merge) {
    public Map<String, Object> getSelectPrintingSv(Map<String, Object> object, String printMerge, String printLike, String merge, String flashback, String compound, String landingSequence) {
        if (printMerge == null) {
            printMerge = "";
        }
@@ -304,8 +310,11 @@
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果
        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
        if (!flowCardList.isEmpty()) {
            Set<String> processedProcessIds = new HashSet<>();  // 用来存放已处理过的 processId
            Set<String> processedKeys = new HashSet<>();
            for (FlowCard flowCard : flowCardList) {
                String processId = flowCard.getProcessId();
                Integer orderNumber = flowCard.getOrderNumber();
                String uniqueKey = processId + "|" + orderNumber;  // 用特殊字符连接防止冲突
                Map<String, Object> itemmap = new HashMap<>();
                //流程卡表头表尾数据
                //是否传入合并层数
@@ -313,43 +322,65 @@
                    //是否包含切割
                    //boolean containsCutting = flowCard.getProcess().contains("切割");
                    String processSub = flowCard.getProcess().substring(0, 2);
                    if (processSub.equals("夹胶") || processSub.equals("中空")) {//工艺是否包含夹胶中空
                        itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                    //获取工序对应的别称
                    String processName = flowCardMapper.getProcessName(processSub);
                    if (processName.equals("stepC") || processName.equals("stepD")) {//工艺是否包含夹胶中空
                        itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(),
                                String.valueOf("null".equals(compound)
                                        ? flowCard.getTechnologyNumber()//正常层
                                        : compound ),//同架层
                                flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                        List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess());
                        itemmap.put("detailList", detailList);
                        if (compound == null
                                || "null".equals(compound)
                                || compound.trim().isEmpty()){
                            List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(),flashback,landingSequence);
                            itemmap.put("detailList", detailList);
                        }else {//有需要同架的层
                            List<Map<String, Object>> detailList = flowCardMapper.getDetailCompoundList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(),flashback,compound,landingSequence);
                            itemmap.put("detailList", detailList);
                        }
                    } else {
                        if (merge.equals("1") && flowCard.getMerge().equals(1)) {
                        if (merge.equals("1") && flowCard.getMerge().equals(1)) {//否
                            // 检查是否已经处理过该 processId,如果处理过则跳过
                            if (processedProcessIds.contains(flowCard.getProcessId())) {
                            if (processedKeys.contains(uniqueKey)) {
                                continue;
                            }
                            // 将该 processId 加入已处理集合
                            processedProcessIds.add(flowCard.getProcessId());
                            processedKeys.add(uniqueKey);
                            itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                            List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), flowCard.getProcess());
                            List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), flowCard.getProcess(),flashback,landingSequence);
                            itemmap.put("detailList", detailList);
                        } else {
                            itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                            List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess());
                            itemmap.put("detailList", detailList);
                            itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(),
                                    String.valueOf("null".equals(compound)
                                            ? flowCard.getTechnologyNumber()//正常层
                                            : compound ),//同架层
                                    flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                            if (compound == null
                                    || "null".equals(compound)
                                    || compound.trim().isEmpty()){
                                List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess(),flashback,landingSequence);
                                itemmap.put("detailList", detailList);
                            }else {//有需要同架的层
                                List<Map<String, Object>> detailList = flowCardMapper.getDetailListLikeCompound(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess(),flashback,compound,landingSequence);
                                itemmap.put("detailList", detailList);
                            }
                        }
                    }
                } else {
                } else {//否
                    //流程卡明细数据
                    if (printLike.equals("") || printLike.equals("null")) {
                        itemmap.put("detail", flowCardMapper.getPrimaryListMerge(flowCard.getProcessId(), printMerge, flowCard.getOrderId()));
                        List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess());
                        List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(), flashback, landingSequence);
                        itemmap.put("detailList", detailList);
                    } else {
                        itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                        List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), printMerge, flowCard.getProcess());
                        List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), printMerge, flowCard.getProcess(), flashback, landingSequence);
                        itemmap.put("detailList", detailList);
                    }
                }
@@ -389,7 +420,7 @@
        return map;
    }
    public Map<String, Object> getSelectPrintProject(String printProject, String merge) {
    public Map<String, Object> getSelectPrintProject(String printProject, String merge, String flashback, String landingSequence) {
        Map<String, Object> map = new HashMap<>();
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果
@@ -398,18 +429,23 @@
        }
        List<FlowCard> flowCardList = flowCardMapper.getFlowCardListPrintProject(printProject);
        if (!flowCardList.isEmpty()) {
            Set<String> processedProcessIds = new HashSet<>();  // 用来存放已处理过的 processId
            Set<String> processedKeys = new HashSet<>();
            for (FlowCard flowCard : flowCardList) {
                Map<String, Object> itemmap = new HashMap<>();
                String processId = flowCard.getProcessId();
                Integer orderNumber = flowCard.getOrderNumber();
                String uniqueKey = processId + "|" + orderNumber;  // 用特殊字符连接防止冲突
                //是否包含切割
                //boolean containsCutting = flowCard.getProcess().contains("切割");
                String processSub = flowCard.getProcess().substring(0, 2);
                if (processSub.equals("夹胶") || processSub.equals("中空")) {
                //获取工序对应的别称
                String processName = flowCardMapper.getProcessName(processSub);
                if (processName.equals("stepC") || processName.equals("stepD")) {//工艺是否包含夹胶中空
                    itemmap.put("detail", flowCardMapper.getPrimaryListLimt(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                    if (flowCard.getPatchState().equals(0)) {
                        List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess());
                        List<Map<String, Object>> detailList = flowCardMapper.getDetailList(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(), flashback, landingSequence);
                        itemmap.put("detailList", detailList);
                    } else {
                        List<Map<String, Object>> detailList = flowCardMapper.getDetailLists(flowCard.getProcessId(), flowCard.getTechnologyNumber(), flowCard.getProcess(), flowCard.getOrderNumber());
@@ -421,18 +457,18 @@
                    if (flowCard.getPatchState().equals(0)) {
                        if (merge.equals("1") && flowCard.getMerge().equals(1)) {
                            // 检查是否已经处理过该 processId,如果处理过则跳过
                            if (processedProcessIds.contains(flowCard.getProcessId())) {
                            if (processedKeys.contains(uniqueKey)) {
                                continue;
                            }
                            // 将该 processId 加入已处理集合
                            processedProcessIds.add(flowCard.getProcessId());
                            processedKeys.add(uniqueKey);
                            itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                            List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), flowCard.getProcess());
                            List<Map<String, Object>> detailList = flowCardMapper.getDetailListMerge(flowCard.getProcessId(), flowCard.getProcess(), flashback, landingSequence);
                            itemmap.put("detailList", detailList);
                        } else {
                            itemmap.put("detail", flowCardMapper.getPrimaryList(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getGlassChild(), flowCard.getProcess(), flowCard.getOrderId()));
                            List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess());
                            List<Map<String, Object>> detailList = flowCardMapper.getDetailListLike(flowCard.getProcessId(), String.valueOf(flowCard.getTechnologyNumber()), flowCard.getProcess(), flashback, landingSequence);
                            itemmap.put("detailList", detailList);
                        }
@@ -585,14 +621,15 @@
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果
        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
        if (!flowCardList.isEmpty()) {
            Set<String> processedProcessIds = new HashSet<>();  // 用来存放已处理过的 processId
            Set<String> processedKeys = new HashSet<>();
            if (lableType != 2) {//成品标签
                for (FlowCard flowCard : flowCardList) {
                    String processId = flowCard.getProcessId();
                    Integer orderNumber = flowCard.getOrderNumber();
                    String uniqueKey = processId + "|" + orderNumber;  // 用特殊字符连接防止冲突
                    // 检查是否已经处理过该 processId,如果处理过则跳过
                    if (processedProcessIds.contains(processId)) {
                    if (processedKeys.contains(uniqueKey)) {
                        continue;
                    }
                    Map<String, Object> itemmap = new HashMap<>();
@@ -600,7 +637,7 @@
                    list.add(itemmap);
                    // 将该 processId 加入已处理集合
                    processedProcessIds.add(processId);
                    processedKeys.add(uniqueKey);
                }
            } else {//小片标签
                for (FlowCard flowCard : flowCardList) {
@@ -620,14 +657,15 @@
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果
        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
        if (!flowCardList.isEmpty()) {
            Set<String> processedProcessIds = new HashSet<>();  // 用来存放已处理过的 processId
            Set<String> processedKeys = new HashSet<>();
            if (lableType != 2) {//成品标签
                for (FlowCard flowCard : flowCardList) {
                    String processId = flowCard.getProcessId();
                    Integer orderNumber = flowCard.getOrderNumber();
                    String uniqueKey = processId + "|" + orderNumber;  // 用特殊字符连接防止冲突
                    // 检查是否已经处理过该 processId,如果处理过则跳过
                    if (processedProcessIds.contains(processId)) {
                    if (processedKeys.contains(uniqueKey)) {
                        continue;
                    }
                    Map<String, Object> itemmap = new HashMap<>();
@@ -635,7 +673,7 @@
                    list.add(itemmap);
                    // 将该 processId 加入已处理集合
                    processedProcessIds.add(processId);
                    processedKeys.add(uniqueKey);
                }
            } else {//小片标签
                for (FlowCard flowCard : flowCardList) {
@@ -723,8 +761,10 @@
                //工艺流程
                List<Map<String, Object>> processList = flowCardMapper.getProcessList(flowCard.getProcessId(), flowCard.getTechnologyNumber());
                //工序列表
                List<Map<String, Object>> processNameList = flowCardMapper.getProcessNameList();
                itemmap.put("processList", processList);
                itemmap.put("processNameList", processNameList);
                //  itemmap.put("numberList", numberList);
                list.add(itemmap);
@@ -805,6 +845,7 @@
            }
        }
        map.put("data", list);
        map.put("orderOtherMoney", flowCardMapper.selectorderOtherMoney());
        map.put("type", flowCardMapper.selectType());
        return map;
    }
@@ -814,25 +855,31 @@
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果
        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
        if (!flowCardList.isEmpty()) {
            Set<String> processedProcessIds = new HashSet<>();  // 用来存放已处理过的 processId
            Set<String> processedKeys = new HashSet<>();
            if (lableType != 2) {//成品标签
                for (FlowCard flowCard : flowCardList) {
                    String orderId = flowCard.getOrderId();
                    String processId = flowCard.getProcessId();
                    String orderNumber = flowCard.getOrderNumber().toString();
                    String uniqueKey = processId + "|" + orderNumber;  // 用特殊字符连接防止冲突
                       if (processId!=null){
                           // 检查是否已经处理过该 processId,如果处理过则跳过
                           if (processedProcessIds.contains(processId) && processedProcessIds.contains(orderNumber)) {
                           if (processedKeys.contains(uniqueKey)) {
                               continue;
                           }
                           Map<String, Object> itemmap = new HashMap<>();
                           itemmap.put("data", flowCardMapper.getPrintCustomDataDetails(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity()));
                           Integer sumQuantity = flowCardMapper.getSumQuantity(flowCard.getOrderId());
                           List<Map<String, Object>> details = flowCardMapper.getPrintCustomDataDetails(flowCard.getProcessId(), flowCard.getOrderNumber(), flowCard.getPrintQuantity());
                           for (Map<String, Object> detail : details) {
                               detail.put("sumQuantity", sumQuantity);
                           }
                           itemmap.put("data", details);
                           list.add(itemmap);
                           // 将该 processId 加入已处理集合
                           processedProcessIds.add(processId);
                           processedProcessIds.add(orderNumber);
                           processedKeys.add(uniqueKey);
                       } else{
                           Map<String, Object> itemmap = new HashMap<>();
@@ -943,6 +990,66 @@
        return flowCardList;
    }
    public Map<String,Object> getProcessCardAll(Map<String, String> processCards) {
        String processCard = processCards.get("processCard");
        if (!processCard.contains("/")) {
            throw new ServiceException(Constants.Code_600, "错误的流程卡号,请检查!");
        }
        String[] processCardList = processCard.split("/");
        List<String> result = IntStream.range(0, processCardList[1].length())
                .mapToObj(i -> String.valueOf(processCardList[1].charAt(i)))
                .collect(Collectors.toList());
        List<FlowCard> flowCardList = flowCardMapper.selectList(
                new QueryWrapper<FlowCard>()
                        .eq("process_id", processCardList[0])
                        .in("technology_number", result)
        );
        for (FlowCard flowCard : flowCardList) {
            flowCard.setOrderGlassDetail(
                    orderGlassDetailMapper.selectOne(
                            new QueryWrapper<OrderGlassDetail>()
                                    .eq("order_id", flowCard.getOrderId())
                                    .eq("order_number", flowCard.getOrderNumber())
                                    .eq("technology_number", flowCard.getTechnologyNumber())
                    )
            );
            String str = flowCard.getOrderGlassDetail().getGlassChild();
            String delimiter = "mm";
            int index = str.indexOf(delimiter);
            Integer subString = Integer.valueOf(str.substring(0, index).trim());
            flowCard.getOrderGlassDetail().setThickness(subString);
        }
        OrderDetail orderDetail = orderDetailMapper
                .selectOne(new QueryWrapper<OrderDetail>()
                        .eq("order_id", flowCardList.get(0).getOrderId())
                        .eq("order_number", flowCardList.get(0).getOrderNumber())
        );
        Product product = productMapper
                .selectOne(new QueryWrapper<Product>()
                        .eq("id",orderDetail.getProductId()));
        product.setProductDetails(productDetailMapper
                .selectList(new QueryWrapper<ProductDetail>()
                        .eq("prod_id",orderDetail.getProductId())
                )
        );
        Order order = orderMapper.
                selectOne(new QueryWrapper<Order>()
                        .eq("order_id", flowCardList.get(0).getOrderId()));
        order.setMoney(null);
        Map<String,Object> map = new HashMap<>();
        map.put("product",product);
        map.put("flowCard",flowCardList);
        map.put("order",order);
        return map;
    }
    public Boolean checkboxDeleteSv(Map<String, Object> object) {
        String userName = "";
        if (object.get("userName") != null) {
@@ -1002,7 +1109,6 @@
        List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();//最终结果
        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("printList")), FlowCard.class);
        if (!flowCardList.isEmpty()) {
            Set<String> processedProcessIds = new HashSet<>();  // 用来存放已处理过的 processId
            for (FlowCard flowCard : flowCardList) {
                Map<String, Object> itemmap = new HashMap<>();
                //是否是工程明细打印
@@ -1244,6 +1350,12 @@
        }
    }
    public List exportDateProcessSv(Map<String, Object> dates) {
        List<LocalDate> date= (List<LocalDate>) dates.get("date");
        return flowCardMapper.exportDateProcessMp(date);
    }
}