diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java index 077d7c1..4b1ea62 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductPlanController.java @@ -140,6 +140,18 @@ public class MesProductPlanController extends BaseController { } + + /** + * 生产工单新增生产派工List + */ + @RequiresPermissions("mes:productplan:add") + @PostMapping("/checkAddMesProductPlanList") + public AjaxResult checkAddMesProductPlanList(@RequestBody MesProductPlanEditVo productPlanEditVo) { + return success(mesProductPlanService.checkAddMesProductPlanList(productPlanEditVo)); + } + + + /** * 生产工单新增生产派工List */ diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlan.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlan.java index 921cdf3..2d72067 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlan.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlan.java @@ -192,6 +192,8 @@ public class MesProductPlan extends BaseEntity private Long processProductionTime; + private String nickName; + public Long getSaleOrderId() { return saleOrderId; } @@ -557,6 +559,14 @@ public class MesProductPlan extends BaseEntity this.processProductionTime = processProductionTime; } + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanMapper.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanMapper.java index 52ba642..97766d7 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanMapper.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanMapper.java @@ -135,4 +135,14 @@ public interface MesProductPlanMapper */ public List selectOnlyMesProductPlans(MesProductPlan mesProductPlan); + + /** + * 根据用户ID查询有重合的生产派工 + * + * @param mesProductPlan 生产派工 + * @return 生产派工 + */ + public List selectOnlyConflictMesProductPlans(MesProductPlan mesProductPlan); + + } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java index 6ad2000..95b25c8 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanService.java @@ -96,6 +96,15 @@ public interface IMesProductPlanService */ public String getDispatchCode(); + + /** + * 根据用户信息校验是否有冲突的生产派工 + * @param productPlanEditVo + * @return + */ + public String checkAddMesProductPlanList(MesProductPlanEditVo productPlanEditVo); + + /** * 生产工单新增生产派工List * diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java index 1458bba..47ce422 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductOrderServiceImpl.java @@ -382,7 +382,7 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { List mesMaterialBoms = new ArrayList<>(); standardCountMap.forEach((groupBy, sum) -> { - System.out.println("groupBy: " + groupBy + ", Sum of values: " + sum); +// System.out.println("groupBy: " + groupBy + ", Sum of values: " + sum); MesMaterialBom mesMaterialBom = new MesMaterialBom(); String[] groupByArr = groupBy.split("-"); mesMaterialBom.setMaterialId(Long.valueOf(groupByArr[0])); diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java index 763f1de..7436488 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanServiceImpl.java @@ -219,54 +219,34 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { } -// /** -// * 在生产派工时校验库存信息 -// * @param mesProductOrder -// */ -// @Override -// public int checkProductPlanUserConflictAndRawStock(MesProductOrder mesProductOrder) { -// String saleType = mesProductOrder.getSaleType(); -// MesProductOrder queryProductOrder = new MesProductOrder(); -// if (saleType.equals(MesConstants.MES_PRODUCT_ORDER_SALE)) {//外部销售 -// Long materialId = mesProductOrder.getMaterialId(); -// queryProductOrder.setMaterialId(materialId); -// } else {//对内生产 -// Long produceMaterialId = mesProductOrder.getProduceMaterialId(); -// queryProductOrder.setProduceMaterialId(produceMaterialId); -// } -// queryProductOrder.setSaleOrderId(mesProductOrder.getSaleOrderId()); -// List mesProductOrders = mesProductOrderMapper.selectMesProductOrderList(queryProductOrder); -// //工单状态:0-待发布;1-已发布;2-已完成;3-已开始;4-暂停;8-已撤回;9-已删除 -// //找到派工数量大于0,并且状态是已发布或者已开始的或者暂停的 -// List filterProductOrders = mesProductOrders.stream().filter(p -> -// (p.getDispatchAmount().compareTo(BigDecimal.ONE) >= 0) && -// (p.getOrderStatus().equals(MesConstants.PUBLISHED) || p.getOrderStatus().equals(MesConstants.BEGIN) || p.getOrderStatus().equals(MesConstants.PAUSE)) -// ).collect(Collectors.toList()); -// -// //先根据saleorderid和安全库存查询总库存和已出库的数量 -// //查询各生产任务需要物料的数量 -// List> materialBomAllList = new ArrayList<>(); -// for (MesProductOrder filterProductOrder : filterProductOrders) { -// Long materialBomId = filterProductOrder.getMaterialBomId(); -// MesMaterialBom queryMaterialBom = new MesMaterialBom(); -// queryMaterialBom.setParentId(materialBomId); -// List materialBomList = mesMaterialBomMapper.selectMesMaterialBomJoinList(queryMaterialBom); -// materialBomAllList.add(materialBomList); -// } -// -// // 使用流处理合并所有列表并计数(计算每个物料需要的数量) -// Map standardCountMap = materialBomAllList.stream() -// .flatMap(List::stream) // 将所有列表扁平化为一个流 -// .collect(Collectors.groupingBy( -// MesMaterialBom::getMaterialId, -// Collectors.reducing(BigDecimal.ZERO, MesMaterialBom::getStandardAmount, BigDecimal::add))); -// -// standardCountMap.forEach((id, sum) -> System.out.println("ID: " + id + ", Sum of values: " + sum)); -// -//// select * from wms_stock_total wst left join wms_raw_outstock wro on wst.stock_total_id=wro.stock_total_id -//// and wst.sale_order_id=0; -// return 1; -// } + /** + * 根据用户信息校验是否有冲突的生产派工 + * + * @param productPlanEditVo + * @return + */ + @Override + public String checkAddMesProductPlanList(MesProductPlanEditVo productPlanEditVo) { + List mesProductPlanList = productPlanEditVo.getMesProductPlanList(); + List toInsertedProductPlanList = mesProductPlanList.stream().filter(p -> + p.getPlanId() == null + ).collect(Collectors.toList()); + StringBuffer returnMsgBuffer = new StringBuffer(); + int i=1; + for (MesProductPlan toInsertedProductPlan : toInsertedProductPlanList) { + List conflictProductPlans = mesProductPlanMapper.selectOnlyConflictMesProductPlans(toInsertedProductPlan); + if (conflictProductPlans != null && !conflictProductPlans.isEmpty()) { + conflictProductPlans.forEach(cp -> { + returnMsgBuffer.append(i).append(".").append(cp.getNickName()).append(":").append("计划时间") + .append(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,cp.getPlanBeginTime())) + .append("-").append(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,cp.getPlanEndTime())).append(";"); + }); + } + } + + return returnMsgBuffer.toString(); + } + /** * 生产工单新增生产派工List @@ -307,7 +287,7 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { BigDecimal planAmount = mesProductOrder.getPlanAmount(); BigDecimal updateDispatchAmount = dispatchedAmount.add(mesProductPlanEditVo.getDispatchAmount()); if (updateDispatchAmount.compareTo(planAmount) > 0) { - throw new ServiceException("派工数量大于计划数量,请重新派工"); + throw new ServiceException("总派工数量不能大于计划数量,请重新派工"); } @@ -794,5 +774,55 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { // } catch (ExecutionException e) { // throw new RuntimeException(e); // } +// } + + + // /** +// * 在生产派工时校验库存信息 +// * @param mesProductOrder +// */ +// @Override +// public int checkProductPlanUserConflictAndRawStock(MesProductOrder mesProductOrder) { +// String saleType = mesProductOrder.getSaleType(); +// MesProductOrder queryProductOrder = new MesProductOrder(); +// if (saleType.equals(MesConstants.MES_PRODUCT_ORDER_SALE)) {//外部销售 +// Long materialId = mesProductOrder.getMaterialId(); +// queryProductOrder.setMaterialId(materialId); +// } else {//对内生产 +// Long produceMaterialId = mesProductOrder.getProduceMaterialId(); +// queryProductOrder.setProduceMaterialId(produceMaterialId); +// } +// queryProductOrder.setSaleOrderId(mesProductOrder.getSaleOrderId()); +// List mesProductOrders = mesProductOrderMapper.selectMesProductOrderList(queryProductOrder); +// //工单状态:0-待发布;1-已发布;2-已完成;3-已开始;4-暂停;8-已撤回;9-已删除 +// //找到派工数量大于0,并且状态是已发布或者已开始的或者暂停的 +// List filterProductOrders = mesProductOrders.stream().filter(p -> +// (p.getDispatchAmount().compareTo(BigDecimal.ONE) >= 0) && +// (p.getOrderStatus().equals(MesConstants.PUBLISHED) || p.getOrderStatus().equals(MesConstants.BEGIN) || p.getOrderStatus().equals(MesConstants.PAUSE)) +// ).collect(Collectors.toList()); +// +// //先根据saleorderid和安全库存查询总库存和已出库的数量 +// //查询各生产任务需要物料的数量 +// List> materialBomAllList = new ArrayList<>(); +// for (MesProductOrder filterProductOrder : filterProductOrders) { +// Long materialBomId = filterProductOrder.getMaterialBomId(); +// MesMaterialBom queryMaterialBom = new MesMaterialBom(); +// queryMaterialBom.setParentId(materialBomId); +// List materialBomList = mesMaterialBomMapper.selectMesMaterialBomJoinList(queryMaterialBom); +// materialBomAllList.add(materialBomList); +// } +// +// // 使用流处理合并所有列表并计数(计算每个物料需要的数量) +// Map standardCountMap = materialBomAllList.stream() +// .flatMap(List::stream) // 将所有列表扁平化为一个流 +// .collect(Collectors.groupingBy( +// MesMaterialBom::getMaterialId, +// Collectors.reducing(BigDecimal.ZERO, MesMaterialBom::getStandardAmount, BigDecimal::add))); +// +// standardCountMap.forEach((id, sum) -> System.out.println("ID: " + id + ", Sum of values: " + sum)); +// +//// select * from wms_stock_total wst left join wms_raw_outstock wro on wst.stock_total_id=wro.stock_total_id +//// and wst.sale_order_id=0; +// return 1; // } } diff --git a/hw-ui/src/api/mes/productplan.js b/hw-ui/src/api/mes/productplan.js index 365aa18..7828ae1 100644 --- a/hw-ui/src/api/mes/productplan.js +++ b/hw-ui/src/api/mes/productplan.js @@ -51,14 +51,14 @@ export function getDispatchCode() { }) } -// 生产派工校验 -// export function checkProductPlanUserConflictAndRawStock(data) { -// return request({ -// url: '/mes/productplan/checkProductPlanUserConflictAndRawStock', -// method: 'post', -// data: data -// }) -// } +//生产派工校验 +export function checkAddMesProductPlanList(data) { + return request({ + url: '/mes/productplan/checkAddMesProductPlanList', + method: 'post', + data: data + }) +} // 生产工单新增生产派工List diff --git a/hw-ui/src/views/mes/productOrder/index.vue b/hw-ui/src/views/mes/productOrder/index.vue index d87460a..f4c77ff 100644 --- a/hw-ui/src/views/mes/productOrder/index.vue +++ b/hw-ui/src/views/mes/productOrder/index.vue @@ -524,6 +524,7 @@ + @@ -1033,7 +1034,7 @@ export default { const productOrderId = row.productOrderId || this.ids[0]; const orderCode = row.orderCode; const params = {queryParams: this.queryParams}; - this.$tab.closeOpenPage(router.currentRoute); + // this.$tab.closeOpenPage(router.currentRoute); this.$tab.openPage("工单[" + orderCode + "]生产派工", '/mes/product-plan/index/' + productOrderId, params); }, /** 排产 */ diff --git a/hw-ui/src/views/mes/productplan/editProductPlan.vue b/hw-ui/src/views/mes/productplan/editProductPlan.vue index 0f0ce6b..94688dd 100644 --- a/hw-ui/src/views/mes/productplan/editProductPlan.vue +++ b/hw-ui/src/views/mes/productplan/editProductPlan.vue @@ -50,20 +50,25 @@ border default-expand-all > + + +