From 7b525deeeb43f15339a040e457d1e48039953f9c Mon Sep 17 00:00:00 2001 From: xs Date: Thu, 8 Aug 2024 14:51:49 +0800 Subject: [PATCH] =?UTF-8?q?2.8.7=20MES:=20-=E7=94=9F=E4=BA=A7=E6=B4=BE?= =?UTF-8?q?=E5=B7=A5=EF=BC=9A=E5=9C=A8=E4=BF=AE=E6=94=B9=E5=92=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=97=B6=E5=88=A4=E6=96=AD=E6=AF=8F=E4=B8=80=E4=B8=AA?= =?UTF-8?q?=E5=B7=A5=E5=BA=8F=E7=9A=84=E7=8A=B6=E6=80=81=E5=92=8C=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E7=94=9F=E4=BA=A7=E4=BB=BB=E5=8A=A1=E7=9A=84=E7=8A=B6?= =?UTF-8?q?=E6=80=81=20-=E5=B7=A5=E8=89=BA=E8=B7=AF=E7=BA=BF=EF=BC=9A?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=AD=A5=E9=AA=A4=E6=97=B6=E9=A1=BA=E5=BA=8F?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/hw/common/core/utils/SocketUtils.java | 8 +- .../controller/MesBaseRouteController.java | 4 +- .../com/hw/mes/domain/MesProductPlan.java | 19 ++ .../impl/MesProductPlanDetailServiceImpl.java | 34 ++-- .../impl/MesProductPlanServiceImpl.java | 71 ++++++-- .../mapper/mes/MesBaseRouteMapper.xml | 1 + .../mapper/mes/MesProductOrderMapper.xml | 2 +- .../mapper/mes/MesProductPlanMapper.xml | 7 + hw-ui/src/layout/index2.vue | 2 +- hw-ui/src/router/index.js | 2 +- hw-ui/src/views/login.vue | 10 +- hw-ui/src/views/mes/baseRoute/index.vue | 12 +- hw-ui/src/views/mes/productOrder/index.vue | 62 ++++--- .../views/mes/productplan/editProductPlan.vue | 166 ++++++++++++++---- 14 files changed, 300 insertions(+), 100 deletions(-) diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/SocketUtils.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/SocketUtils.java index 6f96010..30a44a7 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/SocketUtils.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/SocketUtils.java @@ -39,20 +39,20 @@ public class SocketUtils { while ((bytesRead = inFromServer.read(buffer)) != -1) { // 处理接收到的数据 String receivedMessage = new String(buffer, 0, bytesRead, StandardCharsets.UTF_8); - System.out.println("Received feedback from server: " + receivedMessage); +// System.out.println("Received feedback from server: " + receivedMessage); return receivedMessage; } } catch (SocketTimeoutException e) { - System.err.println("Reading from the socket timed out."); +// System.err.println("Reading from the socket timed out."); } } catch (IOException e) { - System.err.println("An I/O error occurred: " + e.getMessage()); +// System.err.println("An I/O error occurred: " + e.getMessage()); } finally { if (socket != null) { try { socket.close(); // 在异常情况下也尝试关闭 } catch (IOException e) { - System.err.println("Failed to close the socket: " + e.getMessage()); +// System.err.println("Failed to close the socket: " + e.getMessage()); } } } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseRouteController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseRouteController.java index 7e35844..6aa87e0 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseRouteController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesBaseRouteController.java @@ -5,6 +5,7 @@ import java.io.IOException; import javax.servlet.http.HttpServletResponse; import com.hw.common.security.utils.SecurityUtils; +import com.hw.mes.domain.MesBaseRouteProcess; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; @@ -79,7 +80,8 @@ public class MesBaseRouteController extends BaseController @GetMapping(value = "/{routeId}") public AjaxResult getInfo(@PathVariable("routeId") Long routeId) { - return success(mesBaseRouteService.selectMesBaseRouteByRouteId(routeId)); + MesBaseRoute mesBaseRoute = mesBaseRouteService.selectMesBaseRouteByRouteId(routeId); + return success(mesBaseRoute); } /** 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 3e4dad9..921cdf3 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 @@ -188,6 +188,9 @@ public class MesProductPlan extends BaseEntity private String saleType; + private String displayFlag; + + private Long processProductionTime; public Long getSaleOrderId() { return saleOrderId; @@ -538,6 +541,22 @@ public class MesProductPlan extends BaseEntity this.saleType = saleType; } + public String getDisplayFlag() { + return displayFlag; + } + + public void setDisplayFlag(String displayFlag) { + this.displayFlag = displayFlag; + } + + public Long getProcessProductionTime() { + return processProductionTime; + } + + public void setProcessProductionTime(Long processProductionTime) { + this.processProductionTime = processProductionTime; + } + @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/impl/MesProductPlanDetailServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanDetailServiceImpl.java index f5d4554..7b1f2ea 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanDetailServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesProductPlanDetailServiceImpl.java @@ -333,16 +333,28 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer throw new ServiceException("完成数量超出派工数量"); } - mesProductOrder.setCompleteAmount(newOrderCompleteAmount); + //查询同一工序其他派工人的情况 + MesProductPlan querySameProcessPersonProductPlan = new MesProductPlan(); + querySameProcessPersonProductPlan.setProcessId(dbProductPlan.getProcessId()); + querySameProcessPersonProductPlan.setDispatchCode(dbProductPlan.getDispatchCode()); + List sameProcessPersonProductPlans = mesProductPlanMapper.selectOnlyMesProductPlans(querySameProcessPersonProductPlan); + List allCompletedPersonProductPlans = sameProcessPersonProductPlans.stream().filter(sameProcessPersonProductPlan -> + !sameProcessPersonProductPlan.getPlanId().equals(dbProductPlan.getPlanId()) && + !sameProcessPersonProductPlan.getPlanStatus().equals(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH) + ).collect(Collectors.toList()); + //如果同工序其他人都已经完成,则生产任务数量才能加1 + if (allCompletedPersonProductPlans.isEmpty()) { + mesProductOrder.setCompleteAmount(newOrderCompleteAmount); + + if (newOrderCompleteAmount.compareTo(mesProductOrder.getPlanAmount()) == 0) { + mesProductOrder.setOrderStatus(MesConstants.FINISHED); + mesProductOrder.setRealEndTime(currentDate); + } - if (newOrderCompleteAmount.compareTo(mesProductOrder.getPlanAmount()) == 0) { - mesProductOrder.setOrderStatus(MesConstants.FINISHED); - mesProductOrder.setRealEndTime(currentDate); + mesProductOrder.setUpdateTime(currentDate); + mesProductOrder.setUpdateBy(userName); + mesProductOrderMapper.updateMesProductOrder(mesProductOrder); } - - mesProductOrder.setUpdateTime(currentDate); - mesProductOrder.setUpdateBy(userName); - mesProductOrderMapper.updateMesProductOrder(mesProductOrder); } dbProductPlan.setCompleteAmount(newComplementAmount); @@ -528,9 +540,9 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer throw new ServiceException("配对条码有误,未找到原材料条码信息"); } - if(StringUtils.isNotEmpty(bindBarcodeInfo.getSafeFlag()) && - bindBarcodeInfo.getSingleFlag().equals(MesConstants.MES_BARCODE_SINGLE_FLAG_INTERNAL)){//对内生产 - if(StringUtils.isEmpty(bindBarcodeInfo.getProductBarcode())){ + if (StringUtils.isNotEmpty(bindBarcodeInfo.getSafeFlag()) && + bindBarcodeInfo.getSingleFlag().equals(MesConstants.MES_BARCODE_SINGLE_FLAG_INTERNAL)) {//对内生产 + if (StringUtils.isEmpty(bindBarcodeInfo.getProductBarcode())) { throw new ServiceException("未按成品条码生成原材料条码"); } } 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 6ab25d2..f1a7113 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 @@ -229,7 +229,10 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo) { String userName = SecurityUtils.getUsername(); Date currentDate = new Date(); - List mesProductPlanList = mesProductPlanEditVo.getMesProductPlanList(); + + /**先获取待删除的plan信息。 + * 每一个工序的productplan,都有可能派工给多个人,当某个人已经开始过,则此人的plan就不能删除。 + */ Long[] toDeletedPlanIds = mesProductPlanEditVo.getToDeletedPlanIds(); if (toDeletedPlanIds != null && toDeletedPlanIds.length > 0) { for (Long toDeletedPlanId : toDeletedPlanIds) { @@ -242,12 +245,48 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { mesProductPlanMapper.deleteMesProductPlanByPlanIds(toDeletedPlanIds); } + //更新工单已派工数量 + MesProductOrder mesProductOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(mesProductPlanEditVo.getProductOrderId()); + String orderStatus = mesProductOrder.getOrderStatus(); + if (!orderStatus.equals(MesConstants.BEGIN) && !orderStatus.equals(MesConstants.PUBLISHED) && !orderStatus.equals(MesConstants.PAUSE)) { + String orderStatusPrompt = MesConstants.ORDER_STATUS_PROMPT_MAP.get(orderStatus); + throw new ServiceException(String.format("此生产任务已经%s,不能派工!", orderStatusPrompt)); + } + + BigDecimal dispatchedAmount = mesProductOrder.getDispatchAmount() == null ? BigDecimal.ZERO : mesProductOrder.getDispatchAmount(); + BigDecimal planAmount = mesProductOrder.getPlanAmount(); + BigDecimal updateDispatchAmount = dispatchedAmount.add(mesProductPlanEditVo.getDispatchAmount()); + if (updateDispatchAmount.compareTo(planAmount) > 0) { + throw new ServiceException("派工数量大于计划数量,请重新派工"); + } + + + /**每一个工序的productplan,都有可能派工给多个人,当某个人完成了,则此人的派工信息productplan就不能修改。 + * 如果某个工序的部分人完成,则还可以继续派工此工序给其他人;如果某个工序的所有人都完成了则就不能继续派工此工序了(由于末工序完成有可能也只是修改了productorder的完成数量,在前端控制) + */ + MesProductPlan queryProductPlan = new MesProductPlan(); + queryProductPlan.setProductOrderId(mesProductPlanEditVo.getProductOrderId()); + List orderProductPlans = mesProductPlanMapper.selectOnlyMesProductPlans(queryProductPlan); + + List mesProductPlanList = mesProductPlanEditVo.getMesProductPlanList(); for (MesProductPlan mesProductPlan : mesProductPlanList) { Long planId = mesProductPlan.getPlanId(); if (planId != null) { - mesProductPlan.setUpdateBy(userName); - mesProductPlan.setUpdateTime(currentDate); - mesProductPlanMapper.updateMesProductPlan(mesProductPlan); + MesProductPlan dbProductPlan = orderProductPlans.stream().filter(orderProductPlan -> orderProductPlan.getPlanId().equals(planId)).findFirst().get(); + if (dbProductPlan == null) { + throw new ServiceException("没找到派工信息"); + } + if (!dbProductPlan.getPlanStatus().equals(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH)) { + mesProductPlan.setUpdateBy(userName); + mesProductPlan.setUpdateTime(currentDate); + //不更新以下字段 + mesProductPlan.setPlanCode(null); + mesProductPlan.setDispatchCode(null); + mesProductPlan.setPlanStatus(null); + mesProductPlan.setRealBeginTime(null); + mesProductPlan.setRealEndTime(null); + mesProductPlanMapper.updateMesProductPlan(mesProductPlan); + } } else { mesProductPlan.setPlanAmount(mesProductPlan.getDispatchAmount()); mesProductPlan.setCreateBy(SecurityUtils.getUsername()); @@ -261,15 +300,6 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { } } - //更新工单已派工数量 - MesProductOrder mesProductOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(mesProductPlanEditVo.getProductOrderId()); - BigDecimal dispatchedAmount = mesProductOrder.getDispatchAmount() == null ? BigDecimal.ZERO : mesProductOrder.getDispatchAmount(); - BigDecimal planAmount = mesProductOrder.getPlanAmount(); - BigDecimal updateDispatchAmount = dispatchedAmount.add(mesProductPlanEditVo.getDispatchAmount()); - if (updateDispatchAmount.compareTo(planAmount) > 0) { - throw new ServiceException("派工数量大于计划数量,请重新派工"); - } - mesProductOrder.setDispatchAmount(updateDispatchAmount); mesProductOrder.setUpdateTime(currentDate); mesProductOrder.setUpdateBy(userName); @@ -277,6 +307,21 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { return 1; } + + private void getUpdatedProductPlans(MesProductPlanEditVo mesProductPlanEditVo) { + List mesProductPlanList = mesProductPlanEditVo.getMesProductPlanList(); + MesProductPlan queryProductPlan = new MesProductPlan(); + queryProductPlan.setProductOrderId(mesProductPlanEditVo.getProductOrderId()); + List orderProductPlans = mesProductPlanMapper.selectOnlyMesProductPlans(queryProductPlan); + if (orderProductPlans != null && !orderProductPlans.isEmpty()) { + Map> dispatchProductPlansMap = orderProductPlans.stream() + .collect(Collectors.groupingBy(MesProductPlan::getDispatchCode)); + + } + + } + + /** * 获取生产派工附件List列表 * diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseRouteMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseRouteMapper.xml index 68eaf03..699bdc2 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseRouteMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseRouteMapper.xml @@ -87,6 +87,7 @@ from mes_base_route a left join mes_base_route_process b on b.route_id = a.route_id where a.route_id = #{routeId} + order by b.process_order 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 3e36de0..ebf701b 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 @@ -134,7 +134,7 @@ and mpo.update_by = #{updateBy} and mpo.update_time = #{updateTime} - order by mpo.sale_order_id desc, mpo.product_order_id desc + order by mpo.product_order_id desc @@ -496,6 +502,7 @@ and a.dispatch_code = #{dispatchCode} and a.process_id = #{processId} and a.final_process_flag = #{finalProcessFlag} + and a.product_order_id = #{productOrderId} diff --git a/hw-ui/src/layout/index2.vue b/hw-ui/src/layout/index2.vue index b00631d..3ab725f 100644 --- a/hw-ui/src/layout/index2.vue +++ b/hw-ui/src/layout/index2.vue @@ -21,7 +21,7 @@ export default { }, created() { let floorData = JSON.parse(sessionStorage.getItem('FLOORDATA') || '{}') - this.data = floorData.query?.a + this.data = floorData.query?.processName const getDate = () => { let date = new Date() let YYYY = date.getFullYear() diff --git a/hw-ui/src/router/index.js b/hw-ui/src/router/index.js index a0d234f..79dae5e 100644 --- a/hw-ui/src/router/index.js +++ b/hw-ui/src/router/index.js @@ -320,7 +320,7 @@ export const dynamicRoutes = [ path: 'index/:productOrderId(\\d+)', component: () => import('@/views/mes/productplan/editProductPlan'), name: 'productPlanEdit', - meta: { title: '工单生产派工', activeMenu: '/mes/productplan' } + meta: { title: '生产派工', activeMenu: '/mes/productplan' } } ] }, diff --git a/hw-ui/src/views/login.vue b/hw-ui/src/views/login.vue index 8e5299c..13ab854 100644 --- a/hw-ui/src/views/login.vue +++ b/hw-ui/src/views/login.vue @@ -81,11 +81,12 @@ export default { return { codeUrl: "", loginForm: { - username: "admin", - password: "admin123", + username: "xin", + password: "123456", rememberMe: false, processId: '', - processFloor: '', + processFloor:'', + processName:'', code: "", uuid: "" }, @@ -208,7 +209,7 @@ export default { this.$store.dispatch("Login", this.loginForm).then(() => { let data = this.options.find(v => v.processId === this.loginForm.processId) || {} let routeData = this.floorData.find(v => v.floor === data.processFloor && v.processId === data.processId) || {} - let query = {a:1} + let query = {processName:this.loginForm.processName} routeData.query = query if (routeData.route) { sessionStorage.setItem("FLOORDATA", JSON.stringify(routeData)) @@ -231,6 +232,7 @@ export default { changeProcess(processId) { let process = this.options.find(v => v.processId === processId) this.loginForm.processFloor = process.processFloor; + this.loginForm.processName = process.processName; } } }; diff --git a/hw-ui/src/views/mes/baseRoute/index.vue b/hw-ui/src/views/mes/baseRoute/index.vue index 721d307..cfd7912 100644 --- a/hw-ui/src/views/mes/baseRoute/index.vue +++ b/hw-ui/src/views/mes/baseRoute/index.vue @@ -70,7 +70,7 @@ - + @@ -161,12 +161,12 @@ 添加 + >添加 删除 + >删除 @@ -421,8 +421,10 @@ export default { }, /** 工艺路线组成信息序号 */ rowMesBaseRouteProcessIndex({row, rowIndex}) { - row.index = rowIndex + 1; - row.processOrder = (rowIndex + 1) * 10; + if (!row.processOrder) { + row.index = rowIndex + 1; + row.processOrder = (rowIndex + 1) * 10; + } }, /** 工艺路线组成信息添加按钮操作 */ handleAddMesBaseRouteProcess() { diff --git a/hw-ui/src/views/mes/productOrder/index.vue b/hw-ui/src/views/mes/productOrder/index.vue index 4d4cbb4..e7bee04 100644 --- a/hw-ui/src/views/mes/productOrder/index.vue +++ b/hw-ui/src/views/mes/productOrder/index.vue @@ -1,10 +1,10 @@