guoyujie
2025-05-21 ad4d12ff3fbc3482053f19ff72292967814b9a39
north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java
@@ -19,6 +19,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@@ -53,11 +54,25 @@
    }
    //流程卡管理查询
    public Map<String, Object> selectProcessCard(Integer pageNum, Integer pageSize, Date selectTime1, Date selectTime2, FlowCard flowCard) {
    public Map<String, Object> selectProcessCard(Integer pageNum, Integer pageSize,List<String> selectDate, FlowCard flowCard) {
        Integer offset = (pageNum - 1) * pageSize;
        String endDate = LocalDate.now().toString();
        String startDate = LocalDate.now().minusDays(15).toString();
        if(selectDate !=null && selectDate.size()==2){
            if(!selectDate.get(0).isEmpty()){
                startDate = selectDate.get(0);
            }
            if(!selectDate.get(1).isEmpty()){
                endDate = selectDate.get(1);
            }
        }
        Map<String, Object> map = new HashMap<>();
        map.put("data", flowCardMapper.selectFlowCard(offset, pageSize, selectTime1, selectTime2, flowCard));
        map.put("total", flowCardMapper.getPageTotal(offset, pageSize, selectTime1, selectTime2, flowCard));
        map.put("data", flowCardMapper.selectFlowCard(offset, pageSize, startDate, endDate, flowCard));
        map.put("total", flowCardMapper.getPageTotal(offset, pageSize, startDate, endDate, flowCard));
        List<String> list = new ArrayList<>();
        list.add(startDate);
        list.add(endDate);
        map.put("selectDate",list);
        return map;
    }
@@ -217,6 +232,7 @@
    public Object flowCardDetailSv(String processId, FlowCard flowCard) {
        Map<String, Object> map = new HashMap<>();
        map.put("data", flowCardMapper.flowCardDetailMp(processId, flowCard));
        map.put("merge", flowCardMapper.flowCardDetailMergeMp(processId));
        return map;
    }
@@ -798,16 +814,17 @@
        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<>();
@@ -815,8 +832,7 @@
                           list.add(itemmap);
                           // 将该 processId 加入已处理集合
                           processedProcessIds.add(processId);
                           processedProcessIds.add(orderNumber);
                           processedKeys.add(uniqueKey);
                       } else{
                           Map<String, Object> itemmap = new HashMap<>();
@@ -864,23 +880,27 @@
    }
    public String mergeFlowCard(Map<String, Object> object) {
    public String mergeFlowCard(Map<String, Object> object, Integer merge) {
        String returns = "false";
        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("flowCard")), FlowCard.class);
        if (!flowCardList.isEmpty()) {
            List<Map<String, Object>> flowCardList1 = flowCardMapper.selectFlowCardMerge(flowCardList.get(0).getProcessId());
            int index = 1;
            for (int i = 0; i < flowCardList1.size(); i++) {
                if (Integer.valueOf(flowCardList1.get(i).get("count2").toString()) > 1) {
                    List<Integer> technologyNumber = Arrays.stream(flowCardList1.get(i).get("count1").toString().split(","))
                            .map(Integer::parseInt)
                            .collect(Collectors.toList());
                    flowCardMapper.updateFlowCardMerge(flowCardList.get(0).getProcessId(), technologyNumber, index);
                    index += 1;
                    returns = "true";
            if (merge == 0){
                int index = 1;
                for (int i = 0; i < flowCardList1.size(); i++) {
                    if (Integer.valueOf(flowCardList1.get(i).get("count2").toString()) > 1) {
                        List<Integer> technologyNumber = Arrays.stream(flowCardList1.get(i).get("count1").toString().split(","))
                                .map(Integer::parseInt)
                                .collect(Collectors.toList());
                        flowCardMapper.updateFlowCardMerge(flowCardList.get(0).getProcessId(), technologyNumber, index);
                        index += 1;
                        returns = "true";
                    }
                }
            }else {//取消合并
                flowCardMapper.updateFlowCardIsMerge(flowCardList.get(0).getProcessId());
                returns = "true";
            }
        }
@@ -1095,8 +1115,8 @@
        Float glassThickness = Float.parseFloat(thickness.get("thickness").toString());
        //获取此工程号订单明细信息
        List<OrderDetail> orderDetails = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"scope",inLenMax,inLenMin,inShortMax,inShortMin);
        List<OrderDetail> orderDetailsNotScope = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"notScope",inLenMax,inLenMin,inShortMax,inShortMin);
        List<OrderDetail> orderDetails = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"scope",inLenMax,inLenMin,inShortMax,inShortMin,glassThickness);
        List<OrderDetail> orderDetailsNotScope = flowCardMapper.getOrderDetailByProductionId(orderId, productionId,"notScope",inLenMax,inLenMin,inShortMax,inShortMin,glassThickness);
        //根据玻璃厚度和垫片厚度当前架子最大可放数量
        Integer shelfMaxQuantityByThickness = (int) (shelfThickness / (glassTotalThickness + spacerThickness));
@@ -1174,6 +1194,7 @@
                    newOrderDetail.setLandingSequence(flowCardNo);
                    orderDetailList.add(newOrderDetail);
                    orderDetail.setQuantity(orderDetail.getQuantity() - shelfQuantity);
                    orderDetail.setBaiscQuantity(String.valueOf(Integer.valueOf(orderDetail.getBaiscQuantity())-shelfQuantity));
                    flowCardNo += 1;
                    shelfQuantity = shelfQuantity - shelfQuantity;
                } else {
@@ -1184,6 +1205,7 @@
                    newOrderDetail.setOrderNumber(orderDetail.getOrderNumber());
                    newOrderDetail.setShape(orderDetail.getShape());
                    newOrderDetail.setLandingSequence(flowCardNo);
                    newOrderDetail.setBaiscQuantity(String.valueOf(orderDetail.getBaiscQuantity()));
                    orderDetailList.add(newOrderDetail);
                    //当前架子剩余数量
                    shelfQuantity = shelfQuantity - Math.toIntExact(orderDetail.getQuantity());