From 2c8623c7e5447afcc553fb96f3237777f81a5cbc Mon Sep 17 00:00:00 2001 From: xs Date: Thu, 8 Aug 2024 20:24:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?2.8.8=20MES:=20-=E7=94=9F=E4=BA=A7=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=EF=BC=9A=E5=8F=AF=E6=A0=B9=E6=8D=AE=E6=9F=90=E7=94=9F?= =?UTF-8?q?=E4=BA=A7=E4=BB=BB=E5=8A=A1=E6=9F=A5=E7=9C=8B=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E4=BB=BB=E5=8A=A1=E4=BD=BF=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=BD=BF=E7=94=A8=E6=83=85=E5=86=B5=E5=92=8C?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E5=8F=AF=E7=94=A8=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MesProductOrderController.java | 9 +++ .../controller/MesProductPlanController.java | 1 + .../com/hw/mes/domain/MesMaterialBom.java | 18 +++++ .../mes/service/IMesProductOrderService.java | 7 ++ .../mes/service/IMesProductPlanService.java | 1 + .../impl/MesProductOrderServiceImpl.java | 74 ++++++++++++++++++- .../impl/MesProductPlanServiceImpl.java | 50 +++++++++++++ .../mapper/mes/MesMaterialBomMapper.xml | 4 +- .../controller/WmsStockTotalController.java | 14 ++++ .../hw/wms/mapper/WmsStockTotalMapper.java | 10 ++- .../hw/wms/service/IWmsStockTotalService.java | 12 +++ .../impl/WmsRawOutstockServiceImpl.java | 2 - .../impl/WmsStockTotalServiceImpl.java | 49 +++++++++++- .../mapper/wms/WmsStockTotalMapper.xml | 31 +++++++- hw-ui/src/api/mes/productOrder.js | 18 +++++ hw-ui/src/api/mes/productplan.js | 10 +++ hw-ui/src/views/mes/productOrder/index.vue | 56 ++++++++++++++ .../views/mes/productplan/editProductPlan.vue | 33 ++++++--- 18 files changed, 378 insertions(+), 21 deletions(-) diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductOrderController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductOrderController.java index f33806f..3c68512 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductOrderController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesProductOrderController.java @@ -182,5 +182,14 @@ public class MesProductOrderController extends BaseController { return getDataTable(list); } + /** + * 查询物料使用情况 + */ +// @RequiresPermissions("mes:productplan:add") + @GetMapping("/getMaterialUsages") + public AjaxResult getMaterialUsages(MesProductOrder mesProductOrder) { + return success(mesProductOrderService.getMaterialUsages(mesProductOrder)); + } + } 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 74940ad..077d7c1 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 @@ -139,6 +139,7 @@ public class MesProductPlanController extends BaseController { return success(mesProductPlanService.getDispatchCode()); } + /** * 生产工单新增生产派工List */ diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java index 58b53e4..729f709 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesMaterialBom.java @@ -2,6 +2,7 @@ package com.hw.mes.domain; import java.math.BigDecimal; +import com.hw.common.core.utils.StringUtils; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.hw.common.core.annotation.Excel; @@ -80,6 +81,8 @@ public class MesMaterialBom extends TreeEntity { */ private String materialNameDesc; + private String materialSpec; + /** * 安装时长 */ @@ -182,6 +185,21 @@ public class MesMaterialBom extends TreeEntity { this.materialCode = materialCode; } + public String getMaterialSpec() { + return materialSpec; + } + + public void setMaterialSpec(String materialSpec) { + this.materialSpec = materialSpec; + } + + public String getGroupBy() { + String materialCode = StringUtils.isEmpty(this.materialCode) ? " " : this.materialCode; + String materialName = StringUtils.isEmpty(this.materialName) ? " " : this.materialName; + String materialSpec = StringUtils.isEmpty(this.materialSpec) ? " " : this.materialSpec; + return this.materialId + "-" + materialCode + "-" + materialName + "-" + materialSpec; + } + @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/service/IMesProductOrderService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductOrderService.java index 27e13ce..e6f404b 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductOrderService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductOrderService.java @@ -1,6 +1,8 @@ package com.hw.mes.service; import java.util.List; + +import com.hw.mes.domain.MesMaterialBom; import com.hw.mes.domain.MesProductOrder; /** @@ -103,4 +105,9 @@ public interface IMesProductOrderService */ public int batchEditingProductOrder(List productOrderList); + /** + * 在生产派工时校验库存信息 + * @param mesProductOrder + */ + public List getMaterialUsages(MesProductOrder mesProductOrder); } 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 f74acd8..6ad2000 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 @@ -5,6 +5,7 @@ import java.util.List; import java.util.Map; import com.hw.mes.domain.MesBaseAttachInfo; +import com.hw.mes.domain.MesMaterialBom; import com.hw.mes.domain.MesProductOrder; import com.hw.mes.domain.MesProductPlan; import com.hw.mes.domain.vo.MesAssignTaskVo; 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 fc653f6..1458bba 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 @@ -1,10 +1,8 @@ package com.hw.mes.service.impl; import java.math.BigDecimal; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; +import java.util.*; +import java.util.stream.Collectors; import com.hw.common.core.constant.MesConstants; import com.hw.common.core.exception.ServiceException; @@ -14,6 +12,7 @@ import com.hw.common.core.utils.uuid.Seq; import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.domain.MesMaterialBom; import com.hw.mes.domain.MesProductPlan; +import com.hw.mes.mapper.MesMaterialBomMapper; import com.hw.mes.mapper.MesProductPlanMapper; import com.hw.mes.service.IMesMaterialBomService; import org.apache.commons.lang3.time.DateFormatUtils; @@ -42,6 +41,9 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { @Autowired private MesProductPlanMapper mesProductPlanMapper; + @Autowired + private MesMaterialBomMapper mesMaterialBomMapper; + /** * 查询生产工单 * @@ -333,6 +335,70 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { return result; } + + + + /** + * 在生产派工时校验库存信息 + * @param mesProductOrder + */ + @Override + public List getMaterialUsages(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::getGroupBy, + Collectors.reducing(BigDecimal.ZERO, MesMaterialBom::getStandardAmount, BigDecimal::add))); + + List mesMaterialBoms = new ArrayList<>(); + standardCountMap.forEach((groupBy, sum) -> { + System.out.println("groupBy: " + groupBy + ", Sum of values: " + sum); + MesMaterialBom mesMaterialBom = new MesMaterialBom(); + String[] groupByArr = groupBy.split("-"); + mesMaterialBom.setMaterialId(Long.valueOf(groupByArr[0])); + mesMaterialBom.setMaterialCode(groupByArr[1]); + mesMaterialBom.setMaterialName(groupByArr[2]); + mesMaterialBom.setMaterialSpec(groupByArr[3]); + mesMaterialBom.setStandardAmount(sum); + mesMaterialBoms.add(mesMaterialBom); + }); + +// 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 mesMaterialBoms; + } + + // 递归查找最顶级节点 private MesProductOrder findTopLevelOrder(Long productOrderId) { MesProductOrder currentOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(productOrderId); 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 f1a7113..763f1de 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 @@ -218,6 +218,56 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { return Seq.getId(Seq.dispatchCodeSeqType, Seq.dispatchCodeCode); } + +// /** +// * 在生产派工时校验库存信息 +// * @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; +// } + /** * 生产工单新增生产派工List * diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml index d5afa8f..c4b5129 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesMaterialBomMapper.xml @@ -24,6 +24,8 @@ + + @@ -151,7 +153,7 @@ select wst.stock_total_id, wst.warehouse_id, wst.warehouse_floor, wst.stock_type, wst.material_id, - wst.total_amount, wst.frozen_amount, wst.occupy_amount,wst.safe_flag, + wst.total_amount, wst.frozen_amount, wst.occupy_amount,wst.safe_flag,wst.sale_order_id, mbmi.material_code,mbmi.material_name,mbmi.material_spec, (select sum(wro.outstock_amount) from wms_raw_outstock wro where wro.stock_total_id=wst.stock_total_id and wro.plan_code=#{planCode} and wro.plan_detail_code=#{planDetailCode}) outstock_amount @@ -165,4 +165,33 @@ + + + + diff --git a/hw-ui/src/api/mes/productOrder.js b/hw-ui/src/api/mes/productOrder.js index 6a47b1f..e74c0b0 100644 --- a/hw-ui/src/api/mes/productOrder.js +++ b/hw-ui/src/api/mes/productOrder.js @@ -114,3 +114,21 @@ export function batchEditingProductOrder(data) { data: data }) } + +// 获取生产成品需要的物料 不分页 +export function getMaterialUsages(query) { + return request({ + url: '/mes/productOrder/getMaterialUsages', + method: 'get', + params: query + }) +} + +// 获取库存使用情况 不分页 +export function getStockTotalWithRawOutstocks(query) { + return request({ + url: '/wms/stocktotal/getStockTotalWithRawOutstocks', + method: 'get', + params: query + }) +} diff --git a/hw-ui/src/api/mes/productplan.js b/hw-ui/src/api/mes/productplan.js index e7ba142..365aa18 100644 --- a/hw-ui/src/api/mes/productplan.js +++ b/hw-ui/src/api/mes/productplan.js @@ -51,6 +51,16 @@ export function getDispatchCode() { }) } +// 生产派工校验 +// export function checkProductPlanUserConflictAndRawStock(data) { +// return request({ +// url: '/mes/productplan/checkProductPlanUserConflictAndRawStock', +// method: 'post', +// data: data +// }) +// } + + // 生产工单新增生产派工List export function orderAddMesProductPlanList(data) { return request({ diff --git a/hw-ui/src/views/mes/productOrder/index.vue b/hw-ui/src/views/mes/productOrder/index.vue index e7bee04..d87460a 100644 --- a/hw-ui/src/views/mes/productOrder/index.vue +++ b/hw-ui/src/views/mes/productOrder/index.vue @@ -262,6 +262,13 @@ @click="handleDispatch(scope.row)" >生产派工 + 库存使用 + @@ -505,6 +512,22 @@ + + + + + + + + + + + + + + @@ -515,6 +538,7 @@ import { delProductOrder, addProductOrder, updateProductOrder, + getMaterialUsages, getStockTotalWithRawOutstocks, getOrderCode, productOrderLockInventory, productOrderPublish, productOrderRecall } from "@/api/mes/productOrder"; import addSaleOrder from '@//views/mes/productOrder/addSaleOrder.vue'; @@ -565,6 +589,10 @@ export default { selectType: "", // 是否显示生产弹出层 productOrderOpen: false, + + materialUsageOpen: false, + materialUsageList: [], + // 查询参数 queryParams: { pageNum: 1, @@ -1016,6 +1044,34 @@ export default { this.$tab.closeOpenPage(router.currentRoute); this.$tab.openPage("工单[" + orderCode + "]排产", '/mes/production-scheduling/index/' + productOrderId, params); }, + + handleMaterialUsage(row) { + this.materialUsageOpen = true; + this.materialUsageList = []; + getMaterialUsages(row).then(response => { + let materialUsageList = response.data; + getStockTotalWithRawOutstocks({saleOrderId: row.saleOrderId}).then(response => { + let stockMapJson = response.data; + let totalAmountMap = stockMapJson.totalAmountMap; + let occupyAmountMap = stockMapJson.occupyAmountMap; + let outstockAmountMap = stockMapJson.outstockAmountMap; + // console.log(stocks) + // const stockMap = new Map(stocks.map(obj => [obj.materialId + "-" + obj.saleOrderId, obj])); + materialUsageList.map(objA => { + objA.totalAmount = totalAmountMap[objA.materialId]; + objA.outstockAmount = outstockAmountMap[objA.materialId]; + objA.occupyAmount = occupyAmountMap[objA.materialId]; + objA.availableAmount = objA.totalAmount -objA.occupyAmount; + // return returnObj; // 如果没有找到匹配项,则直接返回原对象 + }); + + this.materialUsageList = materialUsageList; + // console.log(this.materialUsageList) + }) + + }) + }, + /** 销售订单新增提交按钮 */ submitForm() { this.$refs["form"].validate(valid => { diff --git a/hw-ui/src/views/mes/productplan/editProductPlan.vue b/hw-ui/src/views/mes/productplan/editProductPlan.vue index cd283eb..0f0ce6b 100644 --- a/hw-ui/src/views/mes/productplan/editProductPlan.vue +++ b/hw-ui/src/views/mes/productplan/editProductPlan.vue @@ -69,8 +69,8 @@ + :disabled="scope.row.addFlag !=='1' + || form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED"> @@ -206,7 +206,7 @@ type="danger" @click="handleDeleteDispatchUser(scope.row)" v-if="(scope.row.children == null || false) " - :disabled = "(scope.row.planStatus !== PLAN_STATUS.TO_DISPATCH && scope.row.planStatus !== PLAN_STATUS.DISPATCHED) || form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED" + :disabled="(scope.row.planStatus !== PLAN_STATUS.TO_DISPATCH && scope.row.planStatus !== PLAN_STATUS.DISPATCHED) || form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED" >删除 @@ -409,7 +409,7 @@ let deepSearch = (arr, target) => { export default { name: "productPlanEdit", - dicts: ['plan_status','product_status', 'mes_dispatch_flag'], + dicts: ['plan_status', 'product_status', 'mes_dispatch_flag'], components: { 'apply-raw-outstock': applyRawOutstock, }, @@ -614,7 +614,7 @@ export default { let i = 0; let processType; productPlansByDispatch.forEach(groupedProductPlan => { - if(groupedProductPlan.planStatus !== this.PLAN_STATUS.FINISHED){ + if (groupedProductPlan.planStatus !== this.PLAN_STATUS.FINISHED) { obj.addFlag = "1"; } @@ -836,7 +836,18 @@ export default { // console.log(JSON.stringify(toUpdatedProductPlans)); // alert(this.toDeletedPlanIds) // return; + // checkProductPlanUserConflictAndRawStock( + // { + // productOrderId: this.form.productOrderId, + // dispatchAmount: currentDispatchAmount, + // saleOrderId: this.form.saleOrderId + // }) + // .then(res => { + // this.$modal.msgSuccess(res.msg); + // this.close(); + // }); + return; orderAddMesProductPlanList( { @@ -858,18 +869,18 @@ export default { this.$modal.confirm('是否确认删除生产派工单号为"' + dispatchCode + '"的数据项?').then(function () { return true; }).then(() => { - if(this.form.orderStatus === this.ORDER_STATUS.RECALLED){ - this.$modal.msgError("此生产任务已经撤回,不能删除") ; + if (this.form.orderStatus === this.ORDER_STATUS.RECALLED) { + this.$modal.msgError("此生产任务已经撤回,不能删除"); return; } - if(this.form.orderStatus === this.ORDER_STATUS.FINISHED){ - this.$modal.msgError("此生产任务已经完成,不能删除") ; + if (this.form.orderStatus === this.ORDER_STATUS.FINISHED) { + this.$modal.msgError("此生产任务已经完成,不能删除"); return; } - if(this.form.orderStatus === this.ORDER_STATUS.DELETED){ - this.$modal.msgError("此生产任务已经删除,不能删除") ; + if (this.form.orderStatus === this.ORDER_STATUS.DELETED) { + this.$modal.msgError("此生产任务已经删除,不能删除"); return; } From 89c90a7151016b4d258e38978e913585fddb83dc Mon Sep 17 00:00:00 2001 From: xs Date: Fri, 9 Aug 2024 11:26:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?2.8.8=20MES:=20-=E7=94=9F=E4=BA=A7=E6=B4=BE?= =?UTF-8?q?=E5=B7=A5=EF=BC=9A=E5=9C=A8=E6=B4=BE=E5=B7=A5=E5=89=8D=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E6=98=AF=E5=90=A6=E6=9C=89=E7=94=A8=E6=88=B7=E6=9C=89?= =?UTF-8?q?=E6=B4=BE=E5=B7=A5=E5=86=B2=E7=AA=81=E6=83=85=E5=86=B5=EF=BC=8C?= =?UTF-8?q?=E6=B4=BE=E5=B7=A5=E6=95=B0=E9=87=8F=E8=BE=93=E5=85=A5=E5=AE=8C?= =?UTF-8?q?=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MesProductPlanController.java | 12 ++ .../com/hw/mes/domain/MesProductPlan.java | 10 ++ .../hw/mes/mapper/MesProductPlanMapper.java | 10 ++ .../mes/service/IMesProductPlanService.java | 9 ++ .../impl/MesProductOrderServiceImpl.java | 2 +- .../impl/MesProductPlanServiceImpl.java | 128 +++++++++++------- hw-ui/src/api/mes/productplan.js | 16 +-- hw-ui/src/views/mes/productOrder/index.vue | 3 +- .../views/mes/productplan/editProductPlan.vue | 107 +++++++-------- 9 files changed, 185 insertions(+), 112 deletions(-) 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 > + + +