From 4f9e132ef35d6685ee8e304ba2e6ca7ed65de2a7 Mon Sep 17 00:00:00 2001 From: xins Date: Wed, 28 Feb 2024 15:09:28 +0800 Subject: [PATCH] =?UTF-8?q?1.7.0=20MES:=E5=A2=9E=E5=8A=A0=E5=A6=82?= =?UTF-8?q?=E4=B8=8B=E6=8E=A5=E5=8F=A3=20=E9=80=9A=E7=94=A8=201=E3=80=81?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=9F=E4=BA=A7=E8=AE=A1=E5=88=92=E5=88=97?= =?UTF-8?q?=E8=A1=A8=EF=BC=88=E6=9F=A5=E8=AF=A2=E8=BD=A6=E9=97=B4=E6=B4=BE?= =?UTF-8?q?=E5=B7=A5=E4=BF=A1=E6=81=AF=E5=88=97=E8=A1=A8=E8=A1=A8=EF=BC=88?= =?UTF-8?q?=E9=80=82=E7=94=A8=E4=BA=8E=E5=90=84=E6=A5=BC=E5=B1=82=E5=90=84?= =?UTF-8?q?=E5=B7=A5=E5=BA=8F=EF=BC=89=EF=BC=89=20mes/getProductPlans=202?= =?UTF-8?q?=E3=80=81=E5=AE=8C=E6=88=90=E7=94=9F=E4=BA=A7=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E6=98=8E=E7=BB=86(=E9=80=82=E7=94=A8=E4=BA=8E=E5=90=84?= =?UTF-8?q?=E5=B7=A5=E4=BD=8D)=20Mes/completeProductPlanDetail?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 一楼 1、根据生产计划ID查询车间生产计划明细表(适用于1楼、四楼装配工位) mes/getProductPlanDetails 2、获取仓库列表 GET http://localhost:7108/dev-api/wms/api/getWarehouses?warehouseFloor=1 3、获取物料列表 http://localhost:7018/dev-api/mes/api/getMaterialBoms?ancestors=1 ancestors就是成品ID 4、申请领料 5、生成生产计划明细(适用于1楼、四楼装配工位) mes/insertProductPlanDetails 6、开始生产计划明细(开始生产计划明细(适用于1楼、四楼装配工位),在生成计划明细时一条一条的开始) mes/startProductPlanDetail 四楼激光切割、折弯焊接 1、获取最新的生产计划明细,在刚登录页面打开时获取根据工位ID获取,如果点击生产计划则根据生产计划ID获取(适用于四楼激光切割、折弯焊接和五楼) Mes/getNewestProductPlanDetail 刚进入不传参数 GET http://localhost:7305/api/getNewestProductPlanDetail 点击生产计划时传planId 2、开始下一生产计划明细(开始下一生产计划明细(适用于四楼激光切割、折弯焊接和五楼),开始时才生成一条计划明细) mes/startNextProductPlanDetail --- .../hw/common/core/constant/MesConstants.java | 13 + .../hw/common/core/constant/QmsConstants.java | 16 ++ .../com/hw/common/core/utils/uuid/Seq.java | 12 + .../com/hw/common/log/enums/BusinessType.java | 11 + .../common/security/utils/SecurityUtils.java | 2 +- .../hw/mes/controller/MesApiController.java | 77 +++++- .../com/hw/mes/domain/MesProductOrder.java | 33 +-- .../com/hw/mes/domain/MesProductPlan.java | 13 + .../hw/mes/domain/MesProductPlanDetail.java | 52 ++-- .../mes/domain/vo/MesProductPlanDetailVo.java | 11 - .../mapper/MesProductPlanDetailMapper.java | 10 + .../service/IMesProductPlanDetailService.java | 43 ++- .../impl/MesProductPlanDetailServiceImpl.java | 253 ++++++++++++++++-- .../impl/MesProductPlanServiceImpl.java | 6 +- .../mapper/mes/MesBaseBarcodeInfoMapper.xml | 5 +- .../mapper/mes/MesProductOrderMapper.xml | 2 +- .../mapper/mes/MesProductPlanDetailMapper.xml | 20 ++ .../mapper/mes/MesProductPlanMapper.xml | 156 +++++------ 18 files changed, 543 insertions(+), 192 deletions(-) diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java index 1c60e47..bc67fa4 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/MesConstants.java @@ -36,4 +36,17 @@ public class MesConstants { /** 工单状态;9-已删除 */ public static final String DELETE = "9"; + + /*生产计划明细状态*/ + public static final String MES_PRODUCT_PLAN_DETAIL_STATUS_TO_START = "1";//未开始 + public static final String MES_PRODUCT_PLAN_DETAIL_STATUS_STARTED = "2";//已开始 + public static final String MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH = "3";//已完成 + public static final String MES_PRODUCT_PLAN_DETAIL_STATUS_ABNORMAL_FINISH = "9";// 异常完成(校验物料信息不完整) + + /*生产计划状态*/ + public static final String MES_PRODUCT_PLAN_STATUS_TO_DISPATCH = "0";//未派工 + public static final String MES_PRODUCT_PLAN_STATUS_DISPATCHED = "1";//已派工 + public static final String MES_PRODUCT_PLAN_STATUS_STARTED = "2";//已开始 + public static final String MES_PRODUCT_PLAN_STATUS_FINISH = "3";//已完成 + } diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/QmsConstants.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/QmsConstants.java index 99334d3..f72c880 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/QmsConstants.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/constant/QmsConstants.java @@ -15,7 +15,23 @@ public class QmsConstants { /*检验项目项目属性*/ public static final String QMS_CHECK_PROJECT_PROPERTY_QUALITATIVE = "1";//定性 + public static final String QMS_CHECK_PROJECT_PROPERTY_QUANTIFY = "2";//定量; /*检验方式*/ public static final String QMS_CHECK_MODE = "1";//全检 + + + /*质检结果和质检结果详情检验状态*/ + public static final String QMS_CHECK_RESULT_CHECK_STATUS_TO_CHECK="0";//待检验 + public static final String QMS_CHECK_RESULT_CHECK_STATUS_CHECKED="1";//检验中 + public static final String QMS_CHECK_RESULT_CHECK_STATUS_PASS="2";//质检通过 + public static final String QMS_CHECK_RESULT_CHECK_STATUS_FAIL="3";//质检不通过 + + + + /**质检结果详情项目信息检验结果*/ + public static final String QMS_CHECK_PROJECT_STATUS_PASS = "1";//合格 + public static final String QMS_CHECK_PROJECT_STATUS_FAIL = "0";//不合格 + + } diff --git a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java index 29d382d..c53c314 100644 --- a/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java +++ b/hw-common/hw-common-core/src/main/java/com/hw/common/core/utils/uuid/Seq.java @@ -71,6 +71,16 @@ public class Seq { // 派工计划编号记录标识 public static final String planCodeCode = "JL"; + // 生产计划明细编号记录标识 + public static final String mesProductPlanDetailSeqType = "PRODUCTPLANDETAIL"; + + // 生产计划明细接口序列数 + private static AtomicInteger mesProductPlanDetailSeq = new AtomicInteger(1); + + // 生产计划明细标识 + public static final String mesProductPlanDetailCode = "PD"; + + /** * 获取通用序列号 * @@ -139,6 +149,8 @@ public class Seq { atomicInt = rawReturnSeq; }else if (orderCodeSeqType.equals(type)) { atomicInt = orderCodeSeq; + } else if (mesProductPlanDetailSeqType.equals(type)) { + atomicInt = mesProductPlanDetailSeq; }else if (dispatchCodeSeqType.equals(type)) { atomicInt = dispatchCodeSeq; }else if (planCodeSeqType.equals(type)) { diff --git a/hw-common/hw-common-log/src/main/java/com/hw/common/log/enums/BusinessType.java b/hw-common/hw-common-log/src/main/java/com/hw/common/log/enums/BusinessType.java index 58d7015..60cb477 100644 --- a/hw-common/hw-common-log/src/main/java/com/hw/common/log/enums/BusinessType.java +++ b/hw-common/hw-common-log/src/main/java/com/hw/common/log/enums/BusinessType.java @@ -97,4 +97,15 @@ public enum BusinessType */ TRANSFER, + + /** + * 开始 + */ + START, + + /** + * 完成 + */ + COMPLETE, + } diff --git a/hw-common/hw-common-security/src/main/java/com/hw/common/security/utils/SecurityUtils.java b/hw-common/hw-common-security/src/main/java/com/hw/common/security/utils/SecurityUtils.java index 53d335b..07adddd 100644 --- a/hw-common/hw-common-security/src/main/java/com/hw/common/security/utils/SecurityUtils.java +++ b/hw-common/hw-common-security/src/main/java/com/hw/common/security/utils/SecurityUtils.java @@ -43,7 +43,7 @@ public class SecurityUtils /** * 获取工位ID */ - public static Long getStationd() + public static Long getStationId() { return SecurityContextHolder.getStationId(); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesApiController.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesApiController.java index 5d9bef2..8ca8631 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesApiController.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/controller/MesApiController.java @@ -2,14 +2,17 @@ package com.hw.mes.controller; import com.hw.common.core.web.controller.BaseController; import com.hw.common.core.web.domain.AjaxResult; +import com.hw.common.core.web.page.TableDataInfo; import com.hw.common.log.annotation.Log; import com.hw.common.log.enums.BusinessType; import com.hw.common.security.annotation.RequiresPermissions; +import com.hw.common.security.utils.SecurityUtils; import com.hw.mes.domain.MesMaterialBom; import com.hw.mes.domain.MesProductPlan; import com.hw.mes.domain.MesProductPlanDetail; import com.hw.mes.domain.vo.MesProductPlanDetailVo; import com.hw.mes.service.IMesMaterialBomService; +import com.hw.mes.service.IMesProductOrderService; import com.hw.mes.service.IMesProductPlanDetailService; import com.hw.mes.service.IMesProductPlanService; import org.springframework.beans.factory.annotation.Autowired; @@ -26,8 +29,7 @@ import java.util.List; */ @RestController @RequestMapping("/api") -public class MesApiController extends BaseController -{ +public class MesApiController extends BaseController { @Autowired private IMesMaterialBomService mesMaterialBomService; @@ -42,44 +44,91 @@ public class MesApiController extends BaseController */ // @RequiresPermissions("mes:materialBom:list") @GetMapping("/getMaterialBoms") - public AjaxResult getMaterialBoms(MesMaterialBom mesMaterialBom) - { + public AjaxResult getMaterialBoms(MesMaterialBom mesMaterialBom) { + String ancestors = mesMaterialBom.getAncestors(); + ancestors = "0," + ancestors; + mesMaterialBom.setAncestors(ancestors); List list = mesMaterialBomService.selectMesMaterialBomJoinList(mesMaterialBom); return success(list); } /** - * 查询车间派工信息列表表 + * 查询车间派工信息列表表(适用于各楼层各工序) */ // @RequiresPermissions("mes:materialBom:list") @GetMapping("/getProductPlans") - public AjaxResult getProductPlans(MesProductPlan mesProductPlan) - { + public TableDataInfo getProductPlans(MesProductPlan mesProductPlan) { + startPage(); List list = productPlanService.selectMesProductPlanJoinList(mesProductPlan); - return success(list); + return getDataTable(list); } /** - * 生成生产计划明细 + * 生成生产计划明细(适用于1楼、四楼装配工位) */ @Log(title = "生产计划明细", businessType = BusinessType.INSERT) @PostMapping(("/insertProductPlanDetails")) public AjaxResult insertProductPlanDetails(@Validated @RequestBody MesProductPlanDetailVo mesProductPlanDetailVo) { - return toAjax(productPlanDetailService.insertMesProductPlanDetails(mesProductPlanDetailVo)); + return success(productPlanDetailService.insertMesProductPlanDetails(mesProductPlanDetailVo)); } /** - * 根据生产计划ID查询车间生产计划明细表 + * 根据生产计划ID查询车间生产计划明细列表(适用于1楼、四楼装配工位) */ // @RequiresPermissions("mes:materialBom:list") @GetMapping("/getProductPlanDetails") - public AjaxResult getProductPlanDetails(MesProductPlanDetail mesProductPlanDetail) - { + public TableDataInfo getProductPlanDetails(MesProductPlanDetail mesProductPlanDetail) { + startPage(); List list = productPlanDetailService.selectMesProductPlanDetailList(mesProductPlanDetail); - return success(list); + return getDataTable(list); + } + + + /** + * 开始生产计划明细(适用于1楼、四楼装配工位),在生成计划明细时一条一条的开始 + */ + @Log(title = "生产计划明细", businessType = BusinessType.START) + @PostMapping(("/startProductPlanDetail")) + public AjaxResult startProductPlanDetail(@RequestBody MesProductPlanDetail mesProductPlanDetail) { + return success(productPlanDetailService.startMesProductPlanDetail(mesProductPlanDetail)); + } + + + /** + * 完成生产计划明细(适用于各工序) + */ + @Log(title = "生产计划明细", businessType = BusinessType.COMPLETE) + @PostMapping(("/completeProductPlanDetail")) + public AjaxResult completeProductPlanDetail(@RequestBody MesProductPlanDetail mesProductPlanDetail) { + return success(productPlanDetailService.completeMesProductPlanDetail(mesProductPlanDetail)); } + + /** + * 获取最新的生产计划明细,在刚登录页面打开时获取根据工位ID获取,如果点击生产计划则根据生产计划ID获取(适用于四楼激光切割、折弯焊接和五楼) + */ +// @RequiresPermissions("mes:baseAttachInfo:query") + @GetMapping(value = "/getNewestProductPlanDetail") + public AjaxResult getNewestProductPlanDetail(MesProductPlanDetail queryProductPlanDetail) { + if (queryProductPlanDetail.getPlanId() == null) { + Long stationId = SecurityUtils.getStationId(); + queryProductPlanDetail.setStationId(stationId); + } + return success(productPlanDetailService.selectNewestMesProductPlanDetail(queryProductPlanDetail)); + } + + + /** + * 开始下一生产计划明细(适用于四楼激光切割、折弯焊接和五楼),开始时才生成一条计划明细 + */ + @Log(title = "生产计划明细", businessType = BusinessType.START) + @PostMapping(("/startNextProductPlanDetail")) + public AjaxResult startNextProductPlanDetail(@RequestBody MesProductPlanDetail mesProductPlanDetail) { + return success(productPlanDetailService.startNextMesProductPlanDetail(mesProductPlanDetail)); + } + + } 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 b0127c4..761d998 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 @@ -179,21 +179,6 @@ public class MesProductOrder extends BaseEntity { @Excel(name = "物料名称") private String materialName; - public String getMaterialCode() { - return materialCode; - } - - public void setMaterialCode(String materialCode) { - this.materialCode = materialCode; - } - - public String getMaterialName() { - return materialName; - } - - public void setMaterialName(String materialName) { - this.materialName = materialName; - } public String getDispatchName() { return dispatchName; @@ -203,6 +188,8 @@ public class MesProductOrder extends BaseEntity { this.dispatchName = dispatchName; } + + public Date getPlanDeliveryDate() { return planDeliveryDate; } @@ -387,6 +374,22 @@ public class MesProductOrder extends BaseEntity { return stockLockFlag; } + public String getMaterialCode() { + return materialCode; + } + + public void setMaterialCode(String materialCode) { + this.materialCode = materialCode; + } + + public String getMaterialName() { + return materialName; + } + + public void setMaterialName(String materialName) { + this.materialName = materialName; + } + @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/domain/MesProductPlan.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlan.java index 6f68e6d..c15e06c 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 @@ -133,6 +133,11 @@ public class MesProductPlan extends BaseEntity */ private Date planDeliveryDate; + /** + * 物料编号 + */ + private String materialCode; + /** * 物料名称 */ @@ -402,6 +407,14 @@ public class MesProductPlan extends BaseEntity this.planDeliveryDate = planDeliveryDate; } + public String getMaterialCode() { + return materialCode; + } + + public void setMaterialCode(String materialCode) { + this.materialCode = materialCode; + } + public String getMaterialName() { return materialName; } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlanDetail.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlanDetail.java index 8113098..ba55124 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlanDetail.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/MesProductPlanDetail.java @@ -9,7 +9,7 @@ import com.hw.common.core.web.domain.BaseEntity; /** * 生产计划明细对象 mes_product_plan_detail - * + * * @author xins * @date 2024-02-21 */ @@ -58,97 +58,107 @@ public class MesProductPlanDetail extends BaseEntity @Excel(name = "是否标识:1-是;0-否") private String isFlag; - public void setPlanDetailId(Long planDetailId) + private Long stationId; + + public void setPlanDetailId(Long planDetailId) { this.planDetailId = planDetailId; } - public Long getPlanDetailId() + public Long getPlanDetailId() { return planDetailId; } - public void setPlanDetailCode(String planDetailCode) + public void setPlanDetailCode(String planDetailCode) { this.planDetailCode = planDetailCode; } - public String getPlanDetailCode() + public String getPlanDetailCode() { return planDetailCode; } - public void setPlanId(Long planId) + public void setPlanId(Long planId) { this.planId = planId; } - public Long getPlanId() + public Long getPlanId() { return planId; } - public void setPlanCode(String planCode) + public void setPlanCode(String planCode) { this.planCode = planCode; } - public String getPlanCode() + public String getPlanCode() { return planCode; } - public void setUserId(Long userId) + public void setUserId(Long userId) { this.userId = userId; } - public Long getUserId() + public Long getUserId() { return userId; } - public void setUserName(String userName) + public void setUserName(String userName) { this.userName = userName; } - public String getUserName() + public String getUserName() { return userName; } - public void setRealBeginTime(Date realBeginTime) + public void setRealBeginTime(Date realBeginTime) { this.realBeginTime = realBeginTime; } - public Date getRealBeginTime() + public Date getRealBeginTime() { return realBeginTime; } - public void setRealEndTime(Date realEndTime) + public void setRealEndTime(Date realEndTime) { this.realEndTime = realEndTime; } - public Date getRealEndTime() + public Date getRealEndTime() { return realEndTime; } - public void setPlanDetailStatus(String planDetailStatus) + public void setPlanDetailStatus(String planDetailStatus) { this.planDetailStatus = planDetailStatus; } - public String getPlanDetailStatus() + public String getPlanDetailStatus() { return planDetailStatus; } - public void setIsFlag(String isFlag) + public void setIsFlag(String isFlag) { this.isFlag = isFlag; } - public String getIsFlag() + public String getIsFlag() { return isFlag; } + public Long getStationId() { + return stationId; + } + + public void setStationId(Long stationId) { + this.stationId = stationId; + } + @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/domain/vo/MesProductPlanDetailVo.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/vo/MesProductPlanDetailVo.java index 82e43d6..5a82f9b 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/vo/MesProductPlanDetailVo.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/domain/vo/MesProductPlanDetailVo.java @@ -19,16 +19,5 @@ public class MesProductPlanDetailVo { @NotNull(message = "生产计划ID必须输入") private Long planId; - //成品批次 - @NotNull(message = "物料ID必须输入") - private Long materialId; - - //成品批次 - @NotNull(message = "物料BomID必须输入") - private Long materialBomId; - - //成品批次 - @NotBlank(message = "计划数量必须输入") - private String planAmount; } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanDetailMapper.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanDetailMapper.java index 3e902e4..3cb61e7 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanDetailMapper.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/mapper/MesProductPlanDetailMapper.java @@ -58,4 +58,14 @@ public interface MesProductPlanDetailMapper * @return 结果 */ public int deleteMesProductPlanDetailByPlanDetailIds(Long[] planDetailIds); + + + + /** + * 查询最新一条生产计划明细 + * + * @param mesProductPlanDetail 生产计划明细 + * @return 生产计划明细 + */ + public MesProductPlanDetail selectNewestMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail); } diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanDetailService.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanDetailService.java index 31c1abc..321b404 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanDetailService.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/IMesProductPlanDetailService.java @@ -1,6 +1,9 @@ package com.hw.mes.service; import java.util.List; + +import com.hw.common.core.utils.DateUtils; +import com.hw.mes.domain.MesProductPlan; import com.hw.mes.domain.MesProductPlanDetail; import com.hw.mes.domain.vo.MesProductPlanDetailVo; @@ -10,8 +13,7 @@ import com.hw.mes.domain.vo.MesProductPlanDetailVo; * @author xins * @date 2024-02-21 */ -public interface IMesProductPlanDetailService -{ +public interface IMesProductPlanDetailService { /** * 查询生产计划明细 * @@ -61,9 +63,6 @@ public interface IMesProductPlanDetailService public int deleteMesProductPlanDetailByPlanDetailId(Long planDetailId); - - - /** * 根据生产计划新增生产计划明细 * @@ -71,4 +70,38 @@ public interface IMesProductPlanDetailService * @return 结果 */ public int insertMesProductPlanDetails(MesProductPlanDetailVo mesProductPlanDetailVo); + + + /** + * 开始生产计划明细 + * + * @param mesProductPlanDetail 生产计划明细 + * @return 结果 + */ + public int startMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail); + + /** + * 完成生产计划明细 + * + * @param mesProductPlanDetail 生产计划明细 + * @return 结果 + */ + public int completeMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail); + + /** + * 查询最新生产计划明细 + * + * @param mesProductPlanDetail 生产计划明细 + * @return 生产计划明细 + */ + public MesProductPlanDetail selectNewestMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail); + + + /** + * 开始下一生产计划明细 + * + * @param mesProductPlanDetail 生产计划明细 + * @return MesProductPlanDetail + */ + public MesProductPlanDetail startNextMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail); } 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 c178071..180d9ce 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 @@ -1,13 +1,24 @@ package com.hw.mes.service.impl; -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; +import com.hw.mes.domain.MesProductPlan; +import com.hw.mes.domain.MesProductPlanDetail; import com.hw.mes.domain.vo.MesProductPlanDetailVo; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; import com.hw.mes.mapper.MesProductPlanDetailMapper; -import com.hw.mes.domain.MesProductPlanDetail; +import com.hw.mes.mapper.MesProductPlanMapper; import com.hw.mes.service.IMesProductPlanDetailService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; /** * 生产计划明细Service业务层处理 @@ -16,11 +27,13 @@ import com.hw.mes.service.IMesProductPlanDetailService; * @date 2024-02-21 */ @Service -public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailService -{ +public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailService { @Autowired private MesProductPlanDetailMapper mesProductPlanDetailMapper; + @Autowired + private MesProductPlanMapper mesProductPlanMapper; + /** * 查询生产计划明细 * @@ -28,8 +41,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer * @return 生产计划明细 */ @Override - public MesProductPlanDetail selectMesProductPlanDetailByPlanDetailId(Long planDetailId) - { + public MesProductPlanDetail selectMesProductPlanDetailByPlanDetailId(Long planDetailId) { return mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailId(planDetailId); } @@ -40,8 +52,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer * @return 生产计划明细 */ @Override - public List selectMesProductPlanDetailList(MesProductPlanDetail mesProductPlanDetail) - { + public List selectMesProductPlanDetailList(MesProductPlanDetail mesProductPlanDetail) { return mesProductPlanDetailMapper.selectMesProductPlanDetailList(mesProductPlanDetail); } @@ -52,8 +63,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer * @return 结果 */ @Override - public int insertMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) - { + public int insertMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) { mesProductPlanDetail.setCreateTime(DateUtils.getNowDate()); return mesProductPlanDetailMapper.insertMesProductPlanDetail(mesProductPlanDetail); } @@ -65,8 +75,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer * @return 结果 */ @Override - public int updateMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) - { + public int updateMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) { mesProductPlanDetail.setUpdateTime(DateUtils.getNowDate()); return mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail); } @@ -78,8 +87,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer * @return 结果 */ @Override - public int deleteMesProductPlanDetailByPlanDetailIds(Long[] planDetailIds) - { + public int deleteMesProductPlanDetailByPlanDetailIds(Long[] planDetailIds) { return mesProductPlanDetailMapper.deleteMesProductPlanDetailByPlanDetailIds(planDetailIds); } @@ -90,14 +98,11 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer * @return 结果 */ @Override - public int deleteMesProductPlanDetailByPlanDetailId(Long planDetailId) - { + public int deleteMesProductPlanDetailByPlanDetailId(Long planDetailId) { return mesProductPlanDetailMapper.deleteMesProductPlanDetailByPlanDetailId(planDetailId); } - - /** * 根据生产计划新增生产计划明细 * @@ -105,12 +110,208 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer * @return 结果 */ @Override - public int insertMesProductPlanDetails(MesProductPlanDetailVo mesProductPlanDetailVo) - { -// mesProductPlanDetail.setCreateTime(DateUtils.getNowDate()); -// return mesProductPlanDetailMapper.insertMesProductPlanDetail(mesProductPlanDetail); -// MesProductPlan mesProductPlan - return 1; + public int insertMesProductPlanDetails(MesProductPlanDetailVo mesProductPlanDetailVo) { + Long planId = mesProductPlanDetailVo.getPlanId(); + MesProductPlan mesProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(planId); + + MesProductPlanDetail queryProductPlanDetail = new MesProductPlanDetail(); + queryProductPlanDetail.setPlanId(mesProductPlanDetailVo.getPlanId()); + List mesProductPlanDetails = mesProductPlanDetailMapper.selectMesProductPlanDetailList(queryProductPlanDetail); + if (mesProductPlanDetails != null && mesProductPlanDetails.size() > 0) { + return 0; + } else { + Date currentDate = new Date(); + String userName = SecurityUtils.getUsername(); + List newMesProductPlanDetails = new ArrayList<>(); + BigDecimal planAmount = mesProductPlan.getPlanAmount(); + + Long planAmountL = planAmount.longValue(); + //todo 大于100条需要拆分,每100条批量保存一次 + for (long i = 0; i < planAmountL; i++) { + MesProductPlanDetail newMesProductPlanDetail = new MesProductPlanDetail(); + newMesProductPlanDetail.setPlanId(mesProductPlanDetailVo.getPlanId()); + newMesProductPlanDetail.setPlanCode(mesProductPlan.getPlanCode()); + newMesProductPlanDetail.setPlanDetailCode(Seq.getId(Seq.mesProductPlanDetailSeqType, Seq.mesProductPlanDetailCode)); + newMesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_TO_START); + newMesProductPlanDetail.setCreateTime(currentDate); + newMesProductPlanDetail.setCreateBy(userName); + newMesProductPlanDetail.setIsFlag("1"); + newMesProductPlanDetails.add(newMesProductPlanDetail); + } + + mesProductPlanMapper.batchMesProductPlanDetail(newMesProductPlanDetails); + return newMesProductPlanDetails.size(); + } + } + + /** + * 开始生产计划明细 + * + * @param mesProductPlanDetail 生产计划明细 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int startMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) { + MesProductPlanDetail dbProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailId(mesProductPlanDetail.getPlanDetailId()); + if (dbProductPlanDetail.getPlanDetailStatus().equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH)) { + throw new ServiceException("此生成计划明细已完成"); + } + + MesProductPlan dbProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(dbProductPlanDetail.getPlanId()); + String planStatus = dbProductPlan.getPlanStatus(); + if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH)) { + throw new ServiceException("此生产计划未派工,不能开始"); + } else if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH)) { + throw new ServiceException("此生产计划已结束"); + } + + Date currentDate = new Date(); + String userName = SecurityUtils.getUsername(); + Long userId = SecurityUtils.getUserId(); + if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_DISPATCHED)) { + dbProductPlan.setRealBeginTime(currentDate); + dbProductPlan.setPlanStatus(MesConstants.MES_PRODUCT_PLAN_STATUS_STARTED); + dbProductPlan.setUpdateBy(userName); + dbProductPlan.setUpdateTime(currentDate); + mesProductPlanMapper.updateMesProductPlan(dbProductPlan); + } + + mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_STARTED); + mesProductPlanDetail.setUserId(userId); + mesProductPlanDetail.setUserName(userName); + mesProductPlanDetail.setRealBeginTime(currentDate); + mesProductPlanDetail.setUpdateTime(currentDate); + mesProductPlanDetail.setUpdateBy(userName); + return mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail); + } + + /** + * 完成生产计划明细 + * + * @param mesProductPlanDetail 生产计划明细 + * @return 结果 + */ + @Override + @Transactional(rollbackFor = Exception.class) + public int completeMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) { + MesProductPlanDetail dbProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailId(mesProductPlanDetail.getPlanDetailId()); + String planDetailStatus = dbProductPlanDetail.getPlanDetailStatus(); + if (planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_TO_START)) { + throw new ServiceException("此生产计划明细未开始"); + } else if (planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH)) { + throw new ServiceException("此生产计划明细已结束"); + } + + MesProductPlan dbProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(dbProductPlanDetail.getPlanId()); + String planStatus = dbProductPlan.getPlanStatus(); + if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH)) { + throw new ServiceException("此生产计划未派工,不能结束"); + } else if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH)) { + throw new ServiceException("此生产计划已结束"); + } + + //todo:校验生产计划明细校验信息 + Date currentDate = new Date(); + String userName = SecurityUtils.getUsername(); + + BigDecimal planAmount = dbProductPlan.getPlanAmount(); + BigDecimal complementAmount = dbProductPlan.getCompleteAmount() == null ? BigDecimal.ZERO : dbProductPlan.getCompleteAmount(); + + BigDecimal newComplementAmount = complementAmount.add(BigDecimal.ONE); + if (newComplementAmount.compareTo(planAmount) >= 0) { + dbProductPlan.setPlanStatus(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH); + dbProductPlan.setRealEndTime(currentDate); + } + dbProductPlan.setCompleteAmount(newComplementAmount); + dbProductPlan.setUpdateTime(currentDate); + dbProductPlan.setUpdateBy(userName); + mesProductPlanMapper.updateMesProductPlan(dbProductPlan); + + mesProductPlanDetail.setUpdateTime(currentDate); + mesProductPlanDetail.setUpdateBy(userName); + mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH); + mesProductPlanDetail.setRealEndTime(currentDate); + return mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail); + } + + + /** + * 查询最新生产计划明细 + * + * @param mesProductPlanDetail 生产计划明细 + * @return 生产计划明细 + */ + @Override + public MesProductPlanDetail selectNewestMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) { + return mesProductPlanDetailMapper.selectNewestMesProductPlanDetail(mesProductPlanDetail); + } + + + /** + * 开始下一生产计划明细 + * + * @param mesProductPlanDetail 生产计划明细 + * @return MesProductPlanDetail + */ + @Override + @Transactional(rollbackFor = Exception.class) + public MesProductPlanDetail startNextMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) { + //根据planId获取最新一条的生产计划明细 + MesProductPlanDetail newestPlanDetail = mesProductPlanDetailMapper.selectNewestMesProductPlanDetail(mesProductPlanDetail); + + //如果此计划有最新的计划明细 + if (newestPlanDetail != null) { + String planDetailStatus = newestPlanDetail.getPlanDetailStatus(); + //判断最新任务明细的状态 + if (!planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH) + && !planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_ABNORMAL_FINISH)) { + //如果不是完成状态则不能开始下一任务明细 + throw new ServiceException("请先完成上一任务明细"); + } else { + Date realEndTime = newestPlanDetail.getRealEndTime(); + //todo:在完成任务后需要过多久才能继续下一任务 + } + } + + MesProductPlan mesProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(mesProductPlanDetail.getPlanId()); + //判断生产计划的状态 + String planStatus = mesProductPlan.getPlanStatus(); + if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH)) { + throw new ServiceException("还未派工,不能开始"); + } else if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH)) { + throw new ServiceException("此生产派工已经结束"); + } + + Date currentDate = new Date(); + String userName = SecurityUtils.getUsername(); + Long userId = SecurityUtils.getUserId(); + + if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_DISPATCHED)) {//如果状态是已开始,需要修改计划的状态和开始时间 + mesProductPlan.setPlanStatus(MesConstants.MES_PRODUCT_PLAN_STATUS_STARTED); + mesProductPlan.setRealBeginTime(currentDate); + mesProductPlan.setUpdateTime(currentDate); + mesProductPlan.setUpdateBy(userName); + mesProductPlanMapper.updateMesProductPlan(mesProductPlan); + } + + mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_STARTED); + mesProductPlanDetail.setPlanDetailCode(Seq.getId(Seq.mesProductPlanDetailSeqType, Seq.mesProductPlanDetailCode)); + mesProductPlanDetail.setPlanCode(mesProductPlan.getPlanCode()); + mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_STARTED); + mesProductPlanDetail.setIsFlag("1"); + mesProductPlanDetail.setUserId(userId); + mesProductPlanDetail.setUserName(userName); + mesProductPlan.setRealBeginTime(currentDate); + mesProductPlanDetail.setCreateTime(currentDate); + mesProductPlanDetail.setCreateBy(userName); + + mesProductPlanDetailMapper.insertMesProductPlanDetail(mesProductPlanDetail); + + return mesProductPlanDetail; + } + + } 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 7c0d3aa..50bd4da 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 @@ -200,8 +200,10 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService { */ @Override public List selectMesProductPlanJoinList(MesProductPlan mesProductPlan) { - Long stationId = SecurityUtils.getStationd(); - System.out.println("stationId: " + stationId); + Long stationId = SecurityUtils.getStationId(); + stationId = 1L; + //todo stationId + mesProductPlan.setStationId(stationId); return mesProductPlanMapper.selectMesProductPlanJoinList(mesProductPlan); } diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml index 0c32511..f200b40 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesBaseBarcodeInfoMapper.xml @@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -35,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select barcode_id, print_time, print_person, batch_flag, barcode_type, barcode_info, batch_code, pallet_info_code, material_id, manufacturer_id, amount, machine_name, po_no, production_date, accepted_date, last_outstock_date, plan_code, plan_detail_code, saleorder_code, project_no, serial_number, remark, bind_status, bind_by, bind_time, update_by, update_time from mes_base_barcode_info + select barcode_id, print_time, print_person, batch_flag, barcode_type, barcode_info, batch_code, pallet_info_code, material_id, manufacturer_id, amount, machine_name, po_no, production_date, accepted_date, last_outstock_date, plan_code, plan_detail_code, sale_order_id, saleorder_code, project_no, serial_number, remark, bind_status, bind_by, bind_time, update_by, update_time from mes_base_barcode_info + select plan_detail_id, plan_detail_code, plan_id, plan_code, user_id, user_name, + real_begin_time, real_end_time, plan_detail_status + from mes_product_plan_detail mppd + + and plan_id = #{planId} + and exists (select 1 from mes_product_plan mpp where mppd.plan_id=mpp.plan_id and mpp.station_id=#{stationId}) + + order by plan_detail_id desc limit 1 + diff --git a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml index f8a6c5e..6fb4b4b 100644 --- a/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml +++ b/hw-modules/hw-mes/src/main/resources/mapper/mes/MesProductPlanMapper.xml @@ -1,7 +1,7 @@ +PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" +"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> @@ -36,101 +36,62 @@ + - + - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + - select mpp.plan_id, - mpp.product_order_id, - po.order_code, - mpp.plan_code, - mpp.dispatch_code, - mpp.material_id, - mi.material_name, - mpp.material_bom_id, - concat(mb.material_name, '-', mb.material_bom_desc) materialBomName, - mpp.process_id, - bpi.process_name, - mpp.process_order, - mpp.last_process_id, - bp2.process_name lastProcessName, - mpp.station_id, - bsi.station_name, - mpp.user_id, - mpp.production_time, - mpp.plan_amount, - mpp.complete_amount, - mpp.plan_begin_time, - mpp.plan_end_time, - mpp.real_begin_time, - mpp.real_end_time, - mpp.attach_id, - mpp.plan_status, - mpp.is_flag, - mpp.remark, - mpp.create_by, - mpp.create_time, - mpp.update_by, - mpp.update_time - from mes_product_plan mpp - left join mes_base_process_info bpi on bpi.process_id = mpp.process_id - left join mes_base_station_info bsi on bsi.station_id = mpp.station_id - left join mes_base_material_info mi on mi.material_id = mpp.material_id - left join mes_material_bom mb on mb.material_bom_id = mpp.material_bom_id - left join mes_base_process_info bp2 on bp2.process_id = mpp.last_process_id - left join mes_product_order po on po.product_order_id = mpp.product_order_id + select plan_id, product_order_id, plan_code, dispatch_code, material_id, material_bom_id, process_id, process_order, last_process_id, station_id, user_id, production_time, plan_amount, complete_amount, plan_begin_time, plan_end_time, real_begin_time, real_end_time, attach_id, plan_status, is_flag, remark, create_by, create_time, update_by, update_time from mes_product_plan - select mpp.plan_id, mpp.product_order_id, mpp.plan_code, mpp.dispatch_code, mpp.material_id, - mpp.material_bom_id, mpp.process_id, mpp.process_order, mpp.last_process_id, - mpp.station_id, mpp.plan_amount, mpp.complete_amount, mpp.plan_begin_time, mpp.plan_end_time, - mpp.real_begin_time, mpp.real_end_time, - mpp.attach_id, mpp.plan_status, mpo.plan_delivery_date,mbmi.material_name - from mes_product_plan mpp left join mes_product_order mpo on mpp.product_order_id = mpo.product_order_id - left join mes_base_material_info mbmi on mpp.material_id=mbmi.material_id + select mpp.plan_id, mpp.product_order_id, mpp.plan_code, mpp.dispatch_code, mpp.material_id, mpp.material_bom_id, mpp.process_id, mpp.process_order, mpp.last_process_id, + mpp.station_id, mpp.plan_amount, mpp.complete_amount, mpp.plan_begin_time, mpp.plan_end_time, mpp.real_begin_time, mpp.real_end_time, + mpp.attach_id, mpp.plan_status, mpo.plan_delivery_date,mbmi.material_code,mbmi.material_name + from mes_product_plan mpp left join mes_product_order mpo on mpp.product_order_id = mpo.product_order_id + left join mes_base_material_info mbmi on mpp.material_id=mbmi.material_id - and mpp.station_id = #{stationId} - and mpp.plan_status = #{planStatus} + and mpp.station_id = #{stationId} + and mpp.plan_status = #{planStatus}