guoyuji
2025-02-19 3d66a05e01b17a57f80a422b19fbbff92a69c080
north-glass-erp/src/main/java/com/example/erp/service/pp/FlowCardService.java
@@ -7,6 +7,7 @@
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.userInfo.Log;
@@ -475,6 +476,20 @@
        if (!flowCardList.isEmpty()) {
            for (FlowCard flowCard : flowCardList) {
                flowCardMapper.updateComposing(flowCard.getProcessId());
            }
            return true;
        }
        else {
            return false;
        }
    }
    public Boolean updateProcessCardRack(Map<String, Object> object) {
        List<FlowCard> flowCardList = JSONArray.parseArray(JSONObject.toJSONString(object.get("composing")), FlowCard.class);
        if (!flowCardList.isEmpty()) {
            for (FlowCard flowCard : flowCardList) {
                flowCardMapper.updateProcessCardRack(flowCard.getProcessId(),flowCard.getTechnologyNumber(),flowCard.getRack());
            }
            return true;
        }
@@ -1029,6 +1044,165 @@
        flowCardMapper.updateProjectProcessPrintCount(projectNo);
        return flowCardMapper.selectProjectProcessPrintCount(projectNo);
    }
    public Map<String, Object> flowCardDetail(Map<String, Object> object) {
        Map<String, Object> map = new HashMap<>();
        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()) {
            for (FlowCard flowCard : flowCardList) {
                Map<String, Object> itemmap = new HashMap<>();
                itemmap.put("detail", flowCardMapper.getFlowCardDetail(flowCard.getProcessId()));
                list.add(itemmap);
            }
        }
        map.put("data", list);
        return map;
    }
    public Object processCardAutoRack(Map<String, Object> object) {
        String orderId = "NG25000004";
        String productionId = "NG25000004B";
        /*String orderId = object.get("orderId").toString();
        String productionId = object.get("productionId").toString();
        Integer inMaxQuantity = Integer.parseInt(object.get("inMaxQuantity").toString());
        Float inWeight =  Float.parseFloat(object.get("inWeight").toString());
        Float shelfThickness =  Float.parseFloat(object.get("shelfThickness").toString())*1000;
        Float spacerThickness =  Float.parseFloat(object.get("spacerThickness").toString());
        */
        Integer inMaxQuantity = 30;
        Float inWeight =  100.0f;
        Float shelfThickness =  2000.0f;
        /*垫片厚度*/
        Float spacerThickness =  0.0f;
        Map<String,Object> thickness = flowCardMapper.getGlassThicknessByProdutionId(orderId,productionId);
        Float glassTotalThickness = Float.parseFloat(thickness.get("totalThickness").toString()) ;
        Float glassThickness = Float.parseFloat(thickness.get("thickness").toString());
        //获取此工程号订单明细信息
        List<OrderDetail> orderDetails = flowCardMapper.getOrderDetailByProductionId(orderId,productionId);
        //根据玻璃厚度和垫片厚度当前架子最大可放数量
        Integer shelfMaxQuantityByThickness = (int) (shelfThickness / (glassTotalThickness+spacerThickness));
        //用于接收最终生成的流程卡
        List<FlowCard> flowCardList = new ArrayList<>();
        //流程卡自增符号
        int flowCardNo = 1;
        // 当前架子剩余可放数量
        Integer shelfQuantity = 0;
        for(OrderDetail orderDetail : orderDetails){
            //架子根据尺寸重量最大能放多少
            int shelfQuantityByWeight = (int) (inWeight/
                    (orderDetail.getHeight()
                            *orderDetail.getWidth()
                            *glassThickness
                            *2.5/1000000)
            );
            System.out.println(shelfQuantityByWeight);
            //当前订单明细剩余数量
            if(shelfQuantity==0){
                shelfQuantity = shelfQuantityByWeight;
            }
            //取最小值
            Integer maxQuantity = 0;
            while (orderDetail.getQuantity() > 0 ) {
                FlowCard flowCard = new FlowCard();
                //当死循环中,当前架子剩余数量为0时,重新计算架子剩余数量
                if(shelfQuantity==0){
                    shelfQuantity = shelfQuantityByWeight;
                    System.out.println("flowCardNo:"+flowCardNo);
                }
                String processId = productionId+String.format("%05d",flowCardNo);
                //取最小值
                 maxQuantity = Math.min(shelfQuantity, Math.min(inMaxQuantity, shelfMaxQuantityByThickness));
                System.out.println(shelfQuantity+","+inMaxQuantity+","+shelfMaxQuantityByThickness);
                System.out.println(flowCardNo+","+maxQuantity);
                System.out.println("------");
                if (orderDetail.getQuantity() > maxQuantity){
                    flowCard.setProcessId(processId);
                    flowCard.setQuantity(maxQuantity);
                    flowCardList.add(flowCard);
                    orderDetail.setQuantity(orderDetail.getQuantity()-maxQuantity);
                    flowCardNo+=1;
                }else{
                    flowCard.setProcessId(processId);
                    flowCard.setQuantity(Math.toIntExact(orderDetail.getQuantity()));
                    flowCardList.add(flowCard);
                    //当前架子剩余数量
                    shelfQuantity= shelfQuantity-Math.toIntExact(orderDetail.getQuantity());
                    if(shelfQuantity==0){
                        flowCardNo+=1;
                    }
                    orderDetail.setQuantity(0L);
                }
            }
        }
        return  flowCardList;
    }
    public Object processCardAutoRack1(Map<String, Object> object) {
        String orderId = "NG25000004";
        String productionId = "NG25000004B";
        /*String orderId = object.get("orderId").toString();
        String productionId = object.get("productionId").toString();
        Integer inMaxQuantity = Integer.parseInt(object.get("inMaxQuantity").toString());
        Float inWeight =  Float.parseFloat(object.get("inWeight").toString());
        Float shelfThickness =  Float.parseFloat(object.get("shelfThickness").toString())*1000;
        Float spacerThickness =  Float.parseFloat(object.get("spacerThickness").toString());
        */
        Integer inMaxQuantity = 30;
        Float inWeight =  100.0f;
        Float shelfThickness =  2000.0f;
        /*垫片厚度*/
        Float spacerThickness =  0.0f;
        Map<String,Object> thickness = flowCardMapper.getGlassThicknessByProdutionId(orderId,productionId);
        Float glassTotalThickness = Float.parseFloat(thickness.get("totalThickness").toString()) ;
        Float glassThickness = Float.parseFloat(thickness.get("thickness").toString());
        //获取此工程号订单明细信息
        List<OrderDetail> orderDetails = flowCardMapper.getOrderDetailByProductionId(orderId,productionId);
        Integer flowCardQuantity = 0;
        for(OrderDetail orderDetail:orderDetails){
            flowCardQuantity+=Math.toIntExact(orderDetail.getQuantity());
        }
        //根据玻璃厚度和垫片厚度当前架子最大可放数量
        Integer shelfMaxQuantityByThickness = (int) (shelfThickness / (glassTotalThickness+spacerThickness));
        //用于接收最终生成的流程卡
        List<FlowCard> flowCardList = new ArrayList<>();
        //流程卡自增符号
        int flowCardNo = 1;
        // 当前架子剩余可放数量
        Integer shelfQuantity = 0;
        while(flowCardQuantity>0){
        }
        return  flowCardList;
    }
}