change - 修改物料类型编号时校验唯一。校验同一工艺路线时间重叠需要抛异常

master
yinq 3 months ago
parent 3ac2a22b07
commit d2519c8549

@ -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<MesBaseMaterialType> 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<MesBaseMaterialType> 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)){

@ -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<String, Object> 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<MesProductOrder> productOrderList = mesProductOrderMapper.selectMesProductOrderList(productOrder);
if (productOrderList.size() > 0) {
throw new ServiceException("此工艺路线的生产工单时间冲突");
}
}
/**
*
*

@ -133,6 +133,9 @@
<if test="createTime != null ">and mpo.create_time = #{createTime}</if>
<if test="updateBy != null and updateBy != ''">and mpo.update_by = #{updateBy}</if>
<if test="updateTime != null ">and mpo.update_time = #{updateTime}</if>
<if test="params.planBeginTime != null and params.planEndTime != null">
AND (plan_begin_time &lt;= #{params.planEndTime} AND plan_end_time &gt;= #{params.planBeginTime})
</if>
</where>
order by mpo.product_order_id desc
</select>

Loading…
Cancel
Save