| | |
| | | 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; |
| | | |
| | |
| | | } |
| | | |
| | | 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( |
| | |
| | | } |
| | | |
| | | public Object processCardAutoRack(Map<String, Object> object) { |
| | | String orderId = "NG25000004"; |
| | | String productionId = "NG25000004B"; |
| | | /*String orderId = object.get("orderId").toString(); |
| | | 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 shelfThickness = Float.parseFloat(object.get("shelfThickness").toString()); |
| | | Float spacerThickness = Float.parseFloat(object.get("spacerThickness").toString()); |
| | | */ |
| | | //Integer inMaxQuantity = 1; |
| | | Float inWeight = 100.0f; |
| | | Float inLenMax = Float.parseFloat(object.get("inLenMax").toString()); |
| | | Float inLenMin = Float.parseFloat(object.get("inLenMin").toString()); |
| | | Float inShortMax = Float.parseFloat(object.get("inShortMax").toString()); |
| | | Float inShortMin = Float.parseFloat(object.get("inShortMin").toString()); |
| | | |
| | | /*String orderId = "NG25000004"; |
| | | String productionId = "NG25000004A"; |
| | | Integer inMaxQuantity = 1; |
| | | Float inWeight = 4000.0f; |
| | | Float shelfThickness = 2000.0f; |
| | | /*垫片厚度*/ |
| | | Float spacerThickness = 0.0f; |
| | | Float maxHeight = 1520.0f; |
| | | Float maxWid = 400.0f; |
| | | Float spacerThickness = 0.0f;//垫片厚度*/ |
| | | |
| | | |
| | | Map<String, Object> thickness = flowCardMapper.getGlassThicknessByProdutionId(orderId, productionId); |
| | | |
| | | //成品玻璃总厚度 |
| | |
| | | Float glassThickness = Float.parseFloat(thickness.get("thickness").toString()); |
| | | |
| | | //获取此工程号订单明细信息 |
| | | List<OrderDetail> orderDetails = flowCardMapper.getOrderDetailByProductionId(orderId, productionId); |
| | | 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)); |
| | |
| | | ); |
| | | //当前订单明细剩余数量 |
| | | if (shelfQuantity == 0) { |
| | | shelfQuantity = shelfQuantityByWeight; |
| | | shelfQuantity =Math.min( Math.min(shelfMaxQuantityByThickness,inMaxQuantity),shelfQuantityByWeight); |
| | | }else if(shelfQuantity>0){//架子剩余数量大于0时,判断当前架子剩余重量,是否支持最新序号的的成品重量 |
| | | String FlowCardId = orderDetailList.get(orderDetailList.size() - 1).getFlowCardId(); |
| | | String FlowCardId = orderDetailList.get(orderDetailList.size() - 1).getProcessId(); |
| | | double flowCardWeight = 0.0; |
| | | for (OrderDetail orderDetail1 : orderDetailList) { |
| | | if (orderDetail1.getFlowCardId().equals(FlowCardId)) { |
| | | if (orderDetail1.getProcessId().equals(FlowCardId)) { |
| | | flowCardWeight += orderDetail1.getHeight()*orderDetail1.getQuantity()* orderDetail1.getWidth()* glassThickness* 2.5 / 1000000; |
| | | } |
| | | } |
| | | 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 = shelfQuantityByWeight; |
| | | shelfQuantity = Math.min(shelfQuantityByWeight, Math.min(inMaxQuantity, shelfMaxQuantityByThickness)); |
| | | flowCardNo += 1; |
| | | } |
| | | } |
| | | |
| | | } |
| | | //取最小值 |
| | | Integer maxQuantity = 0; |
| | | //Integer maxQuantity = 0; |
| | | while (orderDetail.getQuantity() > 0) { |
| | | OrderDetail newOrderDetail = new OrderDetail(); |
| | | //当死循环中,当前架子剩余数量为0时,重新计算架子剩余数量 |
| | | if (shelfQuantity == 0) { |
| | | shelfQuantity = shelfQuantityByWeight; |
| | | shelfQuantity = Math.min(Math.min(shelfMaxQuantityByThickness,inMaxQuantity),shelfQuantityByWeight); |
| | | } |
| | | String processId = productionId + String.format("%05d", flowCardNo); |
| | | String processId = productionId + String.format("%03d", flowCardNo); |
| | | //取最小值 |
| | | // maxQuantity = Math.min(shelfQuantity, Math.min(inMaxQuantity, shelfMaxQuantityByThickness)); |
| | | maxQuantity = Math.min(shelfQuantity, shelfMaxQuantityByThickness); |
| | | //maxQuantity = Math.min(shelfQuantity, Math.min(inMaxQuantity, shelfMaxQuantityByThickness)); |
| | | //maxQuantity = Math.min(shelfQuantity, shelfMaxQuantityByThickness); |
| | | |
| | | /*System.out.println(shelfQuantity + "," + inMaxQuantity + "," + 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) { |
| | | newOrderDetail.setFlowCardId(processId); |
| | | newOrderDetail.setQuantity(Long.valueOf(maxQuantity)); |
| | | if (orderDetail.getQuantity() > shelfQuantity) { |
| | | newOrderDetail.setProcessId(processId); |
| | | 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 - shelfQuantity; |
| | | } else { |
| | | newOrderDetail.setFlowCardId(processId); |
| | | newOrderDetail.setProcessId(processId); |
| | | newOrderDetail.setQuantity(orderDetail.getQuantity()); |
| | | newOrderDetail.setHeight(orderDetail.getHeight()); |
| | | newOrderDetail.setWidth(orderDetail.getWidth()); |
| | | newOrderDetail.setOrderNumber(orderDetail.getOrderNumber()); |
| | | newOrderDetail.setShape(orderDetail.getShape()); |
| | | newOrderDetail.setLandingSequence(flowCardNo); |
| | | orderDetailList.add(newOrderDetail); |
| | | //当前架子剩余数量 |
| | | shelfQuantity = shelfQuantity - Math.toIntExact(orderDetail.getQuantity()); |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | return orderDetailList; |
| | | Map<String, Object> map = new HashMap<>(); |
| | | Collections.reverse(orderDetailList); |
| | | map.put("orderDetailList", orderDetailList); |
| | | map.put("orderDetailsNotScope", orderDetailsNotScope); |
| | | return map; |
| | | } |
| | | |
| | | |