chenlu
2025-03-07 3ab330b8aefb3cd781c9b8730b4ab7ac65e7e9d7
north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java
@@ -29,6 +29,7 @@
import java.sql.Date;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import static com.example.erp.service.sd.OrderService.getOrderProcessDetails;
@@ -895,11 +896,14 @@
        }
        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])
                        .eq("technology_number", processCardList[1])
                        .in("technology_number", result)
        );
        for (FlowCard flowCard : flowCardList) {
            flowCard.setOrderGlassDetail(
@@ -1091,8 +1095,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));
@@ -1125,11 +1129,13 @@
                }
                if(flowCardWeight>0){
                    flowCardWeight = inWeight - flowCardWeight;
                    shelfQuantity = (int) (flowCardWeight /
                    //按照当前流程卡剩余重量,计算当前流程卡剩余数量
                    int remainingQuantity = (int) (flowCardWeight /
                            (orderDetail.getHeight()
                                    * orderDetail.getWidth()
                                    * glassThickness
                                    * 2.5 / 1000000));
                    shelfQuantity =Math.min(Math.min(Math.min(shelfQuantityByWeight, Math.min(inMaxQuantity, shelfMaxQuantityByThickness)),shelfQuantity),remainingQuantity);
                    if (shelfQuantity == 0) {
                        shelfQuantity = Math.min(shelfQuantityByWeight, Math.min(inMaxQuantity, shelfMaxQuantityByThickness));
                        flowCardNo += 1;
@@ -1138,7 +1144,7 @@
            }
            //取最小值
            Integer maxQuantity = 0;
            //Integer maxQuantity = 0;
            while (orderDetail.getQuantity() > 0) {
                OrderDetail newOrderDetail = new OrderDetail();
                //当死循环中,当前架子剩余数量为0时,重新计算架子剩余数量
@@ -1147,26 +1153,29 @@
                }
                String processId = productionId + String.format("%03d", flowCardNo);
                //取最小值
                maxQuantity = Math.min(shelfQuantity, Math.min(inMaxQuantity, shelfMaxQuantityByThickness));
                //maxQuantity = Math.min(shelfQuantity, Math.min(inMaxQuantity, shelfMaxQuantityByThickness));
                //maxQuantity = Math.min(shelfQuantity,  shelfMaxQuantityByThickness);
                /*System.out.println("订单序号:"+orderDetail.getOrderNumber());
                System.out.println(shelfQuantity + ","  + "," + shelfMaxQuantityByThickness);
                System.out.println(flowCardNo + "," + maxQuantity);
                System.out.println("------");*/
                if(shelfQuantity<=0){
                    return false;
                }
                if (orderDetail.getQuantity() > maxQuantity) {
                if (orderDetail.getQuantity() > shelfQuantity) {
                    newOrderDetail.setProcessId(processId);
                    newOrderDetail.setQuantity(Long.valueOf(maxQuantity));
                    newOrderDetail.setQuantity(Long.valueOf(shelfQuantity));
                    newOrderDetail.setHeight(orderDetail.getHeight());
                    newOrderDetail.setWidth(orderDetail.getWidth());
                    newOrderDetail.setOrderNumber(orderDetail.getOrderNumber());
                    newOrderDetail.setShape(orderDetail.getShape());
                    newOrderDetail.setLandingSequence(flowCardNo);
                    orderDetailList.add(newOrderDetail);
                    orderDetail.setQuantity(orderDetail.getQuantity() - maxQuantity);
                    orderDetail.setQuantity(orderDetail.getQuantity() - shelfQuantity);
                    flowCardNo += 1;
                    shelfQuantity = shelfQuantity - maxQuantity;
                    shelfQuantity = shelfQuantity - shelfQuantity;
                } else {
                    newOrderDetail.setProcessId(processId);
                    newOrderDetail.setQuantity(orderDetail.getQuantity());