From 91598491787bbc2616239bfbb859de41bea89da7 Mon Sep 17 00:00:00 2001 From: yinq Date: Mon, 4 Mar 2024 17:54:55 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=20=E7=94=9F=E4=BA=A7=E5=B7=A5?= =?UTF-8?q?=E5=8D=95:=E6=9F=A5=E8=AF=A2=E3=80=81=E6=92=A4=E5=9B=9E?= =?UTF-8?q?=E3=80=81=E5=8F=91=E5=B8=83=E3=80=81=E9=94=80=E5=94=AE=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E6=96=B0=E5=A2=9E=E3=80=81=E6=97=A0=E9=94=80=E5=94=AE?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E6=96=B0=E5=A2=9E=E3=80=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MesProductOrderController.java | 23 +-- .../controller/MesProductPlanController.java | 10 ++ .../com/hw/mes/domain/MesProductOrder.java | 13 ++ .../mes/service/IMesProductOrderService.java | 12 +- .../mes/service/IMesProductPlanService.java | 9 + .../impl/MesProductOrderServiceImpl.java | 36 ++-- .../impl/MesProductPlanServiceImpl.java | 26 +++ .../mapper/mes/MesProductOrderMapper.xml | 6 +- .../mapper/mes/MesProductPlanMapper.xml | 154 +++++++++++------- hw-ui/src/api/mes/productOrder.js | 2 +- hw-ui/src/views/mes/materialBom/addBom.vue | 2 +- .../views/mes/productOrder/addSaleOrder.vue | 2 +- hw-ui/src/views/mes/productOrder/index.vue | 144 +++++++++------- .../views/mes/productplan/editProductPlan.vue | 52 ++++-- 14 files changed, 327 insertions(+), 164 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 9db9c63..1708218 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 @@ -1,9 +1,9 @@ package com.hw.mes.controller; import java.util.List; -import java.io.IOException; import javax.servlet.http.HttpServletResponse; +import com.hw.common.security.utils.SecurityUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -74,6 +74,7 @@ public class MesProductOrderController extends BaseController { @Log(title = "生产工单", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody MesProductOrder mesProductOrder) { + mesProductOrder.setCreateBy(SecurityUtils.getLoginUser().getUsername()); return toAjax(mesProductOrderService.insertMesProductOrder(mesProductOrder)); } @@ -84,6 +85,7 @@ public class MesProductOrderController extends BaseController { @Log(title = "生产工单", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody MesProductOrder mesProductOrder) { + mesProductOrder.setUpdateBy(SecurityUtils.getLoginUser().getUsername()); return toAjax(mesProductOrderService.updateMesProductOrder(mesProductOrder)); } @@ -115,15 +117,6 @@ public class MesProductOrderController extends BaseController { return toAjax(mesProductOrderService.productOrderPublish(mesProductOrder)); } - /** - * 工单撤回 - */ - @Log(title = "生产工单", businessType = BusinessType.UPDATE) - @PostMapping("/productOrderRecall") - public AjaxResult productOrderRecall(@RequestBody MesProductOrder mesProductOrder) { - return toAjax(mesProductOrderService.productOrderRecall(mesProductOrder)); - } - /** * 获取工单编号 * @@ -134,4 +127,14 @@ public class MesProductOrderController extends BaseController { return success(mesProductOrderService.getOrderCode()); } + /** + * 校验BOM是否被生产工单选择 + * + * @return materialBomId + */ + @GetMapping(value = "/VerifyBOMIsProduction/{materialBomId}") + public AjaxResult verifyBOMIsProduction(@PathVariable Long materialBomId) { + return success(mesProductOrderService.verifyBOMIsProduction(materialBomId)); + } + } 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 26b2bee..8c25af9 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 @@ -4,6 +4,7 @@ import java.util.List; import java.io.IOException; import javax.servlet.http.HttpServletResponse; +import com.hw.mes.domain.MesProductOrder; import com.hw.mes.service.IMesProductOrderService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -149,4 +150,13 @@ public class MesProductPlanController extends BaseController return success(mesProductPlanService.getDispatchDrawingList(planId)); } + /** + * 工单撤回 + */ + @Log(title = "生产工单", businessType = BusinessType.UPDATE) + @PostMapping("/productOrderRecall") + public AjaxResult productOrderRecall(@RequestBody MesProductOrder mesProductOrder) { + return toAjax(mesProductPlanService.productOrderRecall(mesProductOrder)); + } + } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductOrder.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductOrder.java index 761d998..d8a6dbd 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductOrder.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductOrder.java @@ -65,6 +65,12 @@ public class MesProductOrder extends BaseEntity { @Excel(name = "物料bomID") private Long materialBomId; + /** + * BOM说明 + */ + @Excel(name = "BOM说明") + private String materialBomDesc; + /** * 派工类型(1产线 2工艺路线) */ @@ -179,6 +185,13 @@ public class MesProductOrder extends BaseEntity { @Excel(name = "物料名称") private String materialName; + public String getMaterialBomDesc() { + return materialBomDesc; + } + + public void setMaterialBomDesc(String materialBomDesc) { + this.materialBomDesc = materialBomDesc; + } public String getDispatchName() { return dispatchName; 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 8cea956..bdc064e 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 @@ -81,12 +81,12 @@ public interface IMesProductOrderService */ public int productOrderPublish(MesProductOrder mesProductOrder); + + /** - * 工单撤回 - * - * @param mesProductOrder 生产工单 - * @return 结果 + * 校验BOM是否被生产工单选择 + * @param materialBomId + * @return */ - public int productOrderRecall(MesProductOrder mesProductOrder); - + public Boolean verifyBOMIsProduction(Long materialBomId); } 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 799290c..32c21c2 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 @@ -3,6 +3,7 @@ package com.hw.mes.service; import java.util.List; import com.hw.mes.domain.MesBaseAttachInfo; +import com.hw.mes.domain.MesProductOrder; import com.hw.mes.domain.MesProductPlan; /** @@ -92,4 +93,12 @@ public interface IMesProductPlanService */ public List getDispatchDrawingList(Long planId); + /** + * 工单撤回 + * + * @param mesProductOrder 生产工单 + * @return 结果 + */ + public int productOrderRecall(MesProductOrder mesProductOrder); + } 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 89f5d1a..b28946e 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 @@ -71,6 +71,10 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { */ @Override public int updateMesProductOrder(MesProductOrder mesProductOrder) { + //销售订单修改工单:校验是否超出销售数量 + if (mesProductOrder.getSaleOrderFlag().equals("1") && StringUtils.isNotNull(mesProductOrder.getSaleOrderId())) { + checkSalesQuantity(mesProductOrder); + } mesProductOrder.setUpdateTime(DateUtils.getNowDate()); return mesProductOrderMapper.updateMesProductOrder(mesProductOrder); } @@ -131,14 +135,14 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { BigDecimal sumDecimal = new BigDecimal(0); if (StringUtils.isNotNull(mesProductOrders)) { for (MesProductOrder order : mesProductOrders) { - if (!order.getOrderStatus().equals(MesConstants.RECALL)){ + if (!order.getOrderStatus().equals(MesConstants.RECALL) && !order.getProductOrderId().equals(mesProductOrder.getProductOrderId())) { sumDecimal = sumDecimal.add(order.getPlanAmount()); } } } sumDecimal = sumDecimal.add(mesProductOrder.getPlanAmount()); if (mesProductOrder.getSaleAmount().compareTo(sumDecimal) < 0) { - throw new ServiceException("当前工单计划数量为:" + sumDecimal.longValue() + ",超出该订单销售数量!"); + throw new ServiceException("当前生产工单计划数量为:" + sumDecimal.longValue() + ",超出该销售订单销售数量!"); } } @@ -154,7 +158,7 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { if (productOrder.getStockLockFlag().equals("1")) { throw new ServiceException("该工单库存已锁定!"); } - if (!mesProductOrder.getOrderStatus().equals(MesConstants.UN_PUBLISH)){ + if (!mesProductOrder.getOrderStatus().equals(MesConstants.UN_PUBLISH)) { throw new ServiceException("该生产工单不是未发布状态!"); } // 调用仓库接口锁定库存 @@ -164,31 +168,33 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { /** * 工单发布 + * * @param mesProductOrder 生产工单 * @return */ @Override public int productOrderPublish(MesProductOrder mesProductOrder) { - if (!mesProductOrder.getOrderStatus().equals(MesConstants.UN_PUBLISH)){ + if (!mesProductOrder.getOrderStatus().equals(MesConstants.UN_PUBLISH)) { throw new ServiceException("该生产工单不是未发布状态!"); } - mesProductOrder.setOrderStatus(MesConstants.PUBLISHED); - mesProductOrder.setReleaseTime(DateUtils.getNowDate()); - return this.updateMesProductOrder(mesProductOrder); + MesProductOrder productOrder = new MesProductOrder(); + productOrder.setProductOrderId(mesProductOrder.getProductOrderId()); + productOrder.setOrderStatus(MesConstants.PUBLISHED); + productOrder.setReleaseTime(DateUtils.getNowDate()); + return this.updateMesProductOrder(productOrder); } /** - * 工单撤回 - * @param mesProductOrder 生产工单 + * 校验BOM是否被生产工单选择 + * + * @param materialBomId BOM主键 * @return */ @Override - public int productOrderRecall(MesProductOrder mesProductOrder) { - // 检验生产派工未下达状态的可进行工单撤回 - mesProductOrder.setOrderStatus(MesConstants.RECALL); - // 调用仓库接口取消锁定库存 - mesProductOrder.setStockLockFlag("0"); - return mesProductOrderMapper.updateMesProductOrder(mesProductOrder); + public Boolean verifyBOMIsProduction(Long materialBomId) { + //查询顶级BOM + //通过顶级BOM主键查询生产工单 + return null; } } 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 50bd4da..a8b8489 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 @@ -3,6 +3,8 @@ package com.hw.mes.service.impl; import java.util.Arrays; import java.util.List; +import com.hw.common.core.constant.MesConstants; +import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.uuid.Seq; import com.hw.common.security.utils.SecurityUtils; @@ -192,6 +194,30 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { } } + /** + * 工单撤回 + * + * @param mesProductOrder 生产工单 + * @return + */ + @Override + public int productOrderRecall(MesProductOrder mesProductOrder) { + // 检验生产派工未下达状态的可进行工单撤回 + MesProductPlan mesProductPlan = new MesProductPlan(); + mesProductPlan.setProductOrderId(mesProductOrder.getProductOrderId()); + List mesProductPlans = mesProductPlanMapper.selectMesProductPlanList(mesProductPlan); + for (MesProductPlan productPlan : mesProductPlans) { + if (!productPlan.getPlanStatus().equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH) + || !productPlan.getPlanStatus().equals(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH)) { + throw new ServiceException("此工单已派工,无法撤回!"); + } + } + mesProductOrder.setOrderStatus(MesConstants.RECALL); + // 调用仓库接口取消锁定库存 + mesProductOrder.setStockLockFlag("0"); + return mesProductOrderService.updateMesProductOrder(mesProductOrder); + } + /** * 查询生产派工列表Join product_order和base_material * diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductOrderMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductOrderMapper.xml index 50e5e04..60b7195 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductOrderMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductOrderMapper.xml @@ -36,6 +36,7 @@ + @@ -47,9 +48,10 @@ mpo.project_no, mpo.material_id, mpo.material_bom_id, + concat(mb.material_name, '-', mb.material_bom_desc) material_bom_desc, mpo.dispatch_type, mpo.dispatch_id, - mbr.route_name dispatchName, + mbr.route_name dispatchName, bmi.material_code, bmi.material_name, mpo.sale_amount, @@ -73,6 +75,7 @@ from mes_product_order mpo left join mes_base_route mbr on mbr.route_id = mpo.dispatch_id left join mes_base_material_info bmi on bmi.material_id = mpo.material_id + left join mes_material_bom mb on mb.material_bom_id = mpo.material_bom_id - and product_order_id = #{productOrderId} - and plan_code = #{planCode} - and dispatch_code = #{dispatchCode} - and material_id = #{materialId} - and material_bom_id = #{materialBomId} - and process_id = #{processId} - and process_order = #{processOrder} - and last_process_id = #{lastProcessId} - and station_id = #{stationId} - and user_id = #{userId} - and production_time = #{productionTime} - and plan_amount = #{planAmount} - and complete_amount = #{completeAmount} - and plan_begin_time = #{planBeginTime} - and plan_end_time = #{planEndTime} - and real_begin_time = #{realBeginTime} - and real_end_time = #{realEndTime} - and attach_id = #{attachId} - and plan_status = #{planStatus} - and is_flag = #{isFlag} + and mpp.product_order_id = #{productOrderId} + and mpp.plan_code = #{planCode} + and mpp.dispatch_code = #{dispatchCode} + and mpp.material_id = #{materialId} + and mpp.material_bom_id = #{materialBomId} + and mpp.process_id = #{processId} + and mpp.process_order = #{processOrder} + and mpp.last_process_id = #{lastProcessId} + and mpp.station_id = #{stationId} + and mpp.user_id = #{userId} + and mpp.production_time = #{productionTime} + and mpp.plan_amount = #{planAmount} + and mpp.complete_amount = #{completeAmount} + and mpp.plan_begin_time = #{planBeginTime} + and mpp.plan_end_time = #{planEndTime} + and mpp.real_begin_time = #{realBeginTime} + and mpp.real_end_time = #{realEndTime} + and mpp.attach_id = #{attachId} + and mpp.plan_status = #{planStatus} + and mpp.is_flag = #{isFlag} @@ -258,33 +297,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - insert into mes_product_plan_detail( plan_detail_id, plan_detail_code, plan_id, plan_code, user_id, user_name, real_begin_time, real_end_time, plan_detail_status, is_flag, remark, create_by, create_time, update_by, update_time) values - - ( #{item.planDetailId}, #{item.planDetailCode}, #{item.planId}, #{item.planCode}, #{item.userId}, #{item.userName}, #{item.realBeginTime}, #{item.realEndTime}, #{item.planDetailStatus}, #{item.isFlag}, #{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}) + insert into mes_product_plan_detail( plan_detail_id, plan_detail_code, plan_id, plan_code, user_id, user_name, + real_begin_time, real_end_time, plan_detail_status, is_flag, remark, create_by, create_time, update_by, + update_time) values + + ( #{item.planDetailId}, #{item.planDetailCode}, #{item.planId}, #{item.planCode}, #{item.userId}, + #{item.userName}, #{item.realBeginTime}, #{item.realEndTime}, #{item.planDetailStatus}, #{item.isFlag}, + #{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime}) - - - - - - - - - - - diff --git a/hw-ui/src/api/mes/productOrder.js b/hw-ui/src/api/mes/productOrder.js index 62bfa7f..e844104 100644 --- a/hw-ui/src/api/mes/productOrder.js +++ b/hw-ui/src/api/mes/productOrder.js @@ -64,7 +64,7 @@ export function productOrderPublish(data) { //撤回 export function productOrderRecall(data) { return request({ - url: '/mes/productOrder/productOrderRecall', + url: '/mes/productplan/productOrderRecall', method: 'post', data: data }) diff --git a/hw-ui/src/views/mes/materialBom/addBom.vue b/hw-ui/src/views/mes/materialBom/addBom.vue index 42584cb..17d84b2 100644 --- a/hw-ui/src/views/mes/materialBom/addBom.vue +++ b/hw-ui/src/views/mes/materialBom/addBom.vue @@ -49,7 +49,7 @@ @row-click="handleRowClick" highlight-current-row > - + diff --git a/hw-ui/src/views/mes/productOrder/addSaleOrder.vue b/hw-ui/src/views/mes/productOrder/addSaleOrder.vue index 5adf3e7..0b85f82 100644 --- a/hw-ui/src/views/mes/productOrder/addSaleOrder.vue +++ b/hw-ui/src/views/mes/productOrder/addSaleOrder.vue @@ -108,7 +108,7 @@ @row-click="handleRowClick" highlight-current-row > - + diff --git a/hw-ui/src/views/mes/productOrder/index.vue b/hw-ui/src/views/mes/productOrder/index.vue index 67c9798..8921b0c 100644 --- a/hw-ui/src/views/mes/productOrder/index.vue +++ b/hw-ui/src/views/mes/productOrder/index.vue @@ -85,16 +85,16 @@ - 修改 - + + + + + + + + + + 删除 - - 导出 - - + + + + + + + + + + + @@ -128,10 +128,10 @@ - + - - + +