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