From d2519c854901cbfdeb634ce593e6e4dae420ff5a Mon Sep 17 00:00:00 2001 From: yinq Date: Thu, 15 Aug 2024 09:20:32 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E4=BF=AE=E6=94=B9=E7=89=A9?= =?UTF-8?q?=E6=96=99=E7=B1=BB=E5=9E=8B=E7=BC=96=E5=8F=B7=E6=97=B6=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E5=94=AF=E4=B8=80=E3=80=82=E6=A0=A1=E9=AA=8C=E5=90=8C?= =?UTF-8?q?=E4=B8=80=E5=B7=A5=E8=89=BA=E8=B7=AF=E7=BA=BF=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E9=87=8D=E5=8F=A0=E9=9C=80=E8=A6=81=E6=8A=9B=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/MesBaseMaterialTypeServiceImpl.java | 15 +++++++++++++ .../impl/MesProductOrderServiceImpl.java | 21 +++++++++++++++++++ .../mapper/mes/MesProductOrderMapper.xml | 3 +++ 3 files changed, 39 insertions(+) diff --git a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseMaterialTypeServiceImpl.java b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseMaterialTypeServiceImpl.java index 9145873..d5ac279 100644 --- a/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseMaterialTypeServiceImpl.java +++ b/hw-modules/hw-mes/src/main/java/com/hw/mes/service/impl/MesBaseMaterialTypeServiceImpl.java @@ -1,6 +1,8 @@ package com.hw.mes.service.impl; import java.util.List; + +import com.hw.common.core.exception.ServiceException; import com.hw.common.core.utils.DateUtils; import com.hw.common.core.utils.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -56,6 +58,12 @@ public class MesBaseMaterialTypeServiceImpl implements IMesBaseMaterialTypeServi @Override public int insertMesBaseMaterialType(MesBaseMaterialType mesBaseMaterialType) { + MesBaseMaterialType materialType = new MesBaseMaterialType(); + materialType.setTypeCode(mesBaseMaterialType.getTypeCode()); + List mesBaseMaterialTypes = mesBaseMaterialTypeMapper.selectMesBaseMaterialTypeList(materialType); + if (!mesBaseMaterialTypes.isEmpty() ) { + throw new ServiceException("该物料类型编号已存在"); + } mesBaseMaterialType.setCreateTime(DateUtils.getNowDate()); MesBaseMaterialType info = mesBaseMaterialTypeMapper.selectMesBaseMaterialTypeByMatrialTypeId(mesBaseMaterialType.getParentId()); if (StringUtils.isNull(info)){ @@ -75,6 +83,13 @@ public class MesBaseMaterialTypeServiceImpl implements IMesBaseMaterialTypeServi @Override public int updateMesBaseMaterialType(MesBaseMaterialType mesBaseMaterialType) { + MesBaseMaterialType materialType = new MesBaseMaterialType(); + materialType.setTypeCode(mesBaseMaterialType.getTypeCode()); + List mesBaseMaterialTypes = mesBaseMaterialTypeMapper.selectMesBaseMaterialTypeList(materialType); + if (!mesBaseMaterialTypes.isEmpty() && !mesBaseMaterialTypes.get(0).getMatrialTypeId().equals(mesBaseMaterialType.getMatrialTypeId())) { + throw new ServiceException("该物料类型编号已存在"); + } + mesBaseMaterialType.setUpdateTime(DateUtils.getNowDate()); MesBaseMaterialType info = mesBaseMaterialTypeMapper.selectMesBaseMaterialTypeByMatrialTypeId(mesBaseMaterialType.getParentId()); if (StringUtils.isNull(info)){ 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 8d4cd52..82bc70a 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 @@ -75,6 +75,8 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { @Override public int insertMesProductOrder(MesProductOrder mesProductOrder) { mesProductOrder.setCreateTime(DateUtils.getNowDate()); + //校验同一工艺路线时间重叠 + checkSameProcessTimeClash(mesProductOrder); //销售订单添加工单:校验是否超出销售数量 if (mesProductOrder.getSaleOrderFlag().equals("1") && StringUtils.isNotNull(mesProductOrder.getSaleOrderId())) { checkSalesQuantity(mesProductOrder); @@ -103,6 +105,8 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { */ @Override public int updateMesProductOrder(MesProductOrder mesProductOrder) { + //校验同一工艺路线时间重叠 + checkSameProcessTimeClash(mesProductOrder); //销售订单修改工单:校验是否超出销售数量 if (StringUtils.isNotEmpty(mesProductOrder.getSaleOrderFlag()) && mesProductOrder.getSaleOrderFlag().equals("1") @@ -144,6 +148,23 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService { return mesProductOrderMapper.updateMesProductOrder(mesProductOrder); } + /** + * 校验同一工艺路线时间重叠需要抛异常 + * @param mesProductOrder + */ + private void checkSameProcessTimeClash(MesProductOrder mesProductOrder) { + HashMap map = new HashMap<>(); + map.put("planBeginTime", DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, mesProductOrder.getPlanBeginTime())); + map.put("planEndTime", DateUtils.parseDateToStr(YYYY_MM_DD_HH_MM_SS, mesProductOrder.getPlanEndTime())); + MesProductOrder productOrder = new MesProductOrder(); + productOrder.setParams(map); + productOrder.setDispatchId(mesProductOrder.getDispatchId()); + List productOrderList = mesProductOrderMapper.selectMesProductOrderList(productOrder); + if (productOrderList.size() > 0) { + throw new ServiceException("此工艺路线的生产工单时间冲突"); + } + } + /** * 获取工单编号 * 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 ebf701b..436da3b 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 @@ -133,6 +133,9 @@ and mpo.create_time = #{createTime} and mpo.update_by = #{updateBy} and mpo.update_time = #{updateTime} + + AND (plan_begin_time <= #{params.planEndTime} AND plan_end_time >= #{params.planBeginTime}) + order by mpo.product_order_id desc