From ad5b9ee7a3d204a9d1bcede52093e5454cbe4314 Mon Sep 17 00:00:00 2001 From: zhaoxiaolin Date: Wed, 26 Jun 2024 13:17:09 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BE=85=E5=8A=A9=E6=8E=92=E4=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/controller/ProOrderController.java | 13 +- .../java/com/op/plan/domain/ProOrder.java | 74 ++++++++ .../com/op/plan/mapper/ProOrderMapper.java | 2 + .../plan/mapper/ProOrderWorkorderMapper.java | 6 + .../service/impl/ProOrderServiceImpl.java | 169 +++++++++++++++++- .../resources/mapper/plan/ProOrderMapper.xml | 14 ++ .../mapper/plan/ProOrderWorkorderMapper.xml | 29 +++ 7 files changed, 297 insertions(+), 10 deletions(-) diff --git a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java index 07f1497b..802ab0a0 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/controller/ProOrderController.java @@ -330,8 +330,15 @@ public class ProOrderController extends BaseController { return R.ok(); } - @GetMapping("/getCanProductLine") - public List getCanProductLine() { - return proOrderService.getCanProductLine(); + @PostMapping("/getCanProductLine") + public ProOrder getCanProductLine(@RequestBody ProOrder proOrder) { + return proOrderService.getCanProductLine(proOrder); } + + /**辅助排产**/ + @PostMapping("/autoSplitOrder") + public R autoSplitOrder(@RequestBody ProOrder proOrder) { + return proOrderService.autoSplitOrder(proOrder); + } + } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java index 60860c6e..112c0a9c 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/domain/ProOrder.java @@ -1,6 +1,8 @@ package com.op.plan.domain; +import java.math.BigDecimal; import java.util.Date; +import java.util.List; import com.fasterxml.jackson.annotation.JsonFormat; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -65,6 +67,78 @@ public class ProOrder extends TreeEntity { private String productDate; private String lineCode; private String lineName; + private List lineList; + private List recommendLineList;//推荐线体 + private Integer useMan; + private BigDecimal efficiency; + private String[] lineCodes; + private String routeCode; + private Integer endFlag; + private String belongWorkOrder; + + public String getBelongWorkOrder() { + return belongWorkOrder; + } + + public void setBelongWorkOrder(String belongWorkOrder) { + this.belongWorkOrder = belongWorkOrder; + } + + public Integer getEndFlag() { + return endFlag; + } + + public void setEndFlag(Integer endFlag) { + this.endFlag = endFlag; + } + + public String getRouteCode() { + return routeCode; + } + + public void setRouteCode(String routeCode) { + this.routeCode = routeCode; + } + + public String[] getLineCodes() { + return lineCodes; + } + + public void setLineCodes(String[] lineCodes) { + this.lineCodes = lineCodes; + } + + public Integer getUseMan() { + return useMan; + } + + public void setUseMan(Integer useMan) { + this.useMan = useMan; + } + + public BigDecimal getEfficiency() { + return efficiency; + } + + public void setEfficiency(BigDecimal efficiency) { + this.efficiency = efficiency; + } + + public List getLineList() { + return lineList; + } + + public void setLineList(List lineList) { + this.lineList = lineList; + } + + public List getRecommendLineList() { + return recommendLineList; + } + + public void setRecommendLineList(List recommendLineList) { + this.recommendLineList = recommendLineList; + } public String getLineCode() { return lineCode; diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java index dcf31723..4c18bea4 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderMapper.java @@ -238,4 +238,6 @@ public interface ProOrderMapper { int updateCloseOrderBatchById(@Param("orderIds")String[] orderIds); List getCanProductLine(); + + List getSelectLineLevel1(ProOrder proOrder); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java index f4bd3164..daf7cfa4 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/mapper/ProOrderWorkorderMapper.java @@ -216,5 +216,11 @@ public interface ProOrderWorkorderMapper { int updateMesReportWorkBatch(MesReportWorkBatchDTO mesReportWorkBatchDTO); int updateCheckTaskBatch(CheckTaskBatchDTO checkTaskBatchDTO); + + Long getLineProductInfo(ProOrder proOrder); + + String getProcessCode(String routeCode); + + int insertWorkorders(@Param("list") List workorders); } diff --git a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java index 0e1d617b..2430371a 100644 --- a/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java +++ b/op-modules/op-plan/src/main/java/com/op/plan/service/impl/ProOrderServiceImpl.java @@ -1220,15 +1220,170 @@ public class ProOrderServiceImpl implements IProOrderService { @Override @DS("#header.poolName") - public List getCanProductLine() { - return proOrderMapper.getCanProductLine(); + public ProOrder getCanProductLine(ProOrder proOrder) { + ProOrder dto = new ProOrder(); + //所有线体 + List lineList = proOrderMapper.getCanProductLine(); + dto.setLineList(lineList); + //推荐线体 + List recommendLineList = getRecommendLines(proOrder); + dto.setRecommendLineList(recommendLineList); + return dto; } - public static void main(String args[]){ - String arrayStr = "[[\"GX01\",\"LG1\"],[\"GX01\",\"LG2\"],[\"GX02\",\"S1\"],[\"GX02\",\"S2\"],[\"GX03\",\"HF01\"],[\"GX04\",\"SPJ01\"]]"; - JSONArray jsonArray = JSONArray.parseArray(arrayStr); - for(int c=0;c workorders = new ArrayList<>(); +// List workorderBatches = new ArrayList<>(); +// +// proOrder.setLineCode(proOrder.getLineCodes()[i]); +// Long efficiency = proOrderWorkorderMapper.getLineProductInfo(proOrder);//线体产能 +// if(efficiency==null){ +// break; +// logger.error("线体"+proOrder.getLineCodes()[i]+"产能"+efficiency+"无法生产"); +// } +// if(efficiency < orderQua){ +// proOrder.setQuantitySplit(efficiency); +// }else{ +// proOrder.setQuantitySplit(orderQua); +// } +// orderQua = orderQua - efficiency;//消耗订单总数量 +// List sonOrders = (List)proOrder.getChildren(); +// if(CollectionUtils.isEmpty(sonOrders)){//1层订单 +// proOrder.setEndFlag(1); +// } +// int endCode = getEndCode(proOrder.getId()); +// String belongWorkOrder = proOrder.getOrderCode()+"-"+endCode; +// proOrder.setBelongWorkOrder(belongWorkOrder); +// proOrder.setWorkerOrder(belongWorkOrder); +// proOrder.setParentOrder("0"); +// ProOrderWorkorder pworkOrder = getWorkOrderByOrder(proOrder);//TODO; +// //父级 +// workorders.add(pworkOrder); +// +// /**pro_order_workorder_batch**/ +// String parentWorkOrder = belongWorkOrder; +// while(!CollectionUtils.isEmpty(sonOrders)){ +// ProOrder sonOrder = sonOrders.get(0); +// sonOrder.setBelongWorkOrder(belongWorkOrder); +// endCode = getEndCode(proOrder.getId()); +// String sworkOrderCode = sonOrder.getOrderCode()+"-"+endCode; +// sonOrder.setBelongWorkOrder(belongWorkOrder); +// sonOrder.setWorkerOrder(sworkOrderCode); +// sonOrder.setParentOrder(parentWorkOrder); +// sonOrders = (List)sonOrder.getChildren(); +// if(CollectionUtils.isEmpty(sonOrders)){//1层订单 +// sonOrder.setEndFlag(1); +// } +// ProOrderWorkorder sworkOrder = getWorkOrderByOrder(sonOrder);//TODO; +// workorders.add(sworkOrder); +// parentWorkOrder = sworkOrderCode; +// } +// +// /**pro_order_workorder**/ +// if(!CollectionUtils.isEmpty(workorders)){ +// int pm = proOrderWorkorderMapper.insertWorkorders(workorders); +// System.out.println("pm:"+pm); +// } +// +// //拆批次 +// Long pworkOrderQua = proOrder.getQuantitySplit();//工单数量 +// ProOrderWorkorderBatch workBatch = null; +// int batchNum = 1; +// while(pworkOrderQua>0){ +// workBatch = new ProOrderWorkorderBatch(); +// workBatch.setBatchQuantity(0L); +// List batchCode = StringUtils.batchAutoCreate(proOrder.getFactoryCode(), +// proOrder.getLineCode(), +// DateUtils.dateTime("yyyy-MM-dd",proOrder.getProductDate()), +// proOrder.getAtrr2().substring(proOrder.getAtrr2().length()-1), +// "0",batchNum++); +// workBatch.setBatchCode(batchCode); +// workorderBatches.add(workBatch); +// } +// /**pro_order_workorder_batch**/ +// if(!CollectionUtils.isEmpty(workorderBatches)) { +// int pn = proOrderWorkorderBatchMapper.insertWorkorderBatchs(workBatch); +// System.out.println("pn:"+pn); +// } +// } + + return R.ok(); + } + + protected ProOrderWorkorder getWorkOrderByOrder(ProOrder proOrder){ + ProOrderWorkorder workOrder = new ProOrderWorkorder(); + workOrder.setWorkorderId(IdUtils.fastSimpleUUID()); + int endCode = getEndCode(proOrder.getId()); + workOrder.setWorkorderCode(proOrder.getWorkerOrder()); + workOrder.setBelongWorkOrder(proOrder.getBelongWorkOrder()); + workOrder.setOrderId(proOrder.getId()); + workOrder.setOrderCode(proOrder.getOrderCode()); + workOrder.setProductCode(proOrder.getProdCode()); + workOrder.setProductName(proOrder.getProdDesc()); + workOrder.setUnit(proOrder.getUnit()); + workOrder.setQuantitySplit(proOrder.getQuantitySplit()); + workOrder.setRouteCode(proOrder.getRouteCode()); + String gxCode = "CP";//proOrderWorkorderMapper.getProcessCode(proOrder.getRouteCode()); + String[][] lineCodeArray = {{gxCode,proOrder.getLineCode()}}; + workOrder.setProdLineCodeArray(lineCodeArray); + workOrder.setProductDate(DateUtils.dateTime("yyyy-MM-dd",proOrder.getProductDate())); + //workOrder.setShiftId(); + workOrder.setParentOrder(proOrder.getParentOrder()); + workOrder.setStatus("w0"); + workOrder.setCreateBy(SecurityUtils.getUsername()); + workOrder.setCreateTime(proOrder.getCreateTime()); + workOrder.setProdType(proOrder.getOrderType()); + workOrder.setFactoryCode(proOrder.getFactoryCode()); + workOrder.setEndFlag(proOrder.getEndFlag()); + workOrder.setSortNo(proOrder.getSortNo()); + return workOrder; + } + + /** + * 每个线体维护可生产的产品及其对应的每天的标准产能和标准用人。 + * 1、标准用人最少的线体。 + * 2、可生产产品种类最少的线体。 + * @param proOrder + */ + protected List getRecommendLines(ProOrder proOrder){ + List lines = new ArrayList<>(); + List proLines = proOrderMapper.getSelectLineLevel1(proOrder); + //订单总量 + BigDecimal orderQuality = new BigDecimal(proOrder.getQuantity()); + BigDecimal consumeQuality = BigDecimal.ZERO; + for(ProOrder pline:proLines){ + lines.add(pline.getLineCode()); + consumeQuality = consumeQuality.add(pline.getEfficiency()); + if(consumeQuality.compareTo(orderQuality)>=0){ + break; + } } + return lines; + } + + + + public static void main(String args[]){ +// String arrayStr = "[[\"GX01\",\"LG1\"],[\"GX01\",\"LG2\"],[\"GX02\",\"S1\"],[\"GX02\",\"S2\"],[\"GX03\",\"HF01\"],[\"GX04\",\"SPJ01\"]]"; +// JSONArray jsonArray = JSONArray.parseArray(arrayStr); +// for(int c=0;c + insert into pro_order diff --git a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml index 6ed79d0e..a99bb4bc 100644 --- a/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml +++ b/op-modules/op-plan/src/main/resources/mapper/plan/ProOrderWorkorderMapper.xml @@ -637,6 +637,17 @@ where pow.belong_work_order = #{workorderCode} and pow.del_flag = '0' order by pow.workorder_code_sap desc + + insert into mes_prepare_detail @@ -738,6 +749,24 @@ + + INSERT INTO pro_order_workorder ( + workorder_id,workorder_code,order_id,order_code,product_code, + product_name,unit,quantity_split,route_code,prod_line_code, + product_date,parent_order, status,create_by,create_time, + prod_type,factory_code,end_flag,del_flag,sort_no, + belong_work_order + )VALUES + + ( + #{d.workorderId},#{d.workorderCode},#{d.orderId},#{d.orderCode},#{d.productCode}, + #{d.productName},#{d.unit},#{d.quantitySplit},#{d.routeCode},#{d.prodLineCodeArray}, + #{d.productDate},#{d.parentOrder},#{d.status},#{d.createBy},#{d.createTime}, + #{d.prodType}, #{d.factoryCode},#{d.endFlag},'2',#{d.sortNo}, + #{d.belongWorkOrder} + ) + + update pro_order_workorder