出库计划编码不可重复

This commit is contained in:
liumingxiy 2024-11-15 09:15:03 +08:00
parent 89cf873277
commit 006f030b32
5 changed files with 41 additions and 16 deletions

View File

@ -1,6 +1,7 @@
package com.ktg.mes.md.controller;
import com.ktg.common.annotation.Log;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.core.controller.BaseController;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.core.page.TableDataInfo;
@ -78,6 +79,9 @@ public class WmsOutPlanController extends BaseController {
@Log(title = "出库计划管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody WmsOutPlan wmsOutPlan) {
if (UserConstants.NOT_UNIQUE.equals(wmsOutPlanService.checkPlanCodeUnique(wmsOutPlan))) {
return AjaxResult.error("新增出库计划失败,出库计划编码“" + wmsOutPlan.getPlanCode() + "”已存在");
}
wmsOutPlan.setCreateBy(getUsername());
return toAjax(wmsOutPlanService.insertWmsOutPlan(wmsOutPlan));
}

View File

@ -103,4 +103,6 @@ public interface WmsOutPlanMapper {
WmsOutPlanDetail selectWmsOutPlanDetailById(Long wmsOutPlanDetailId);
WmsOutPlan selectWmsOutPlanByPlanCode(String figureCode);
WmsOutPlan checkPlanCodeUnique(WmsOutPlan wmsOutPlan);
}

View File

@ -66,4 +66,6 @@ public interface IWmsOutPlanService {
List<HashMap<String, Object>> selectWmsOutPlanDetailEntityList(WmsOutPlanDetailEntity wmsOutPlanDetailEntity);
int autoScrapOut(String username);
public String checkPlanCodeUnique(WmsOutPlan wmsOutPlan);
}

View File

@ -1,5 +1,6 @@
package com.ktg.mes.md.service.impl;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.utils.DateUtils;
import com.ktg.common.utils.StringUtils;
import com.ktg.mes.md.domain.*;
@ -394,6 +395,17 @@ public class WmsOutPlanServiceImpl implements IWmsOutPlanService {
return count.get();
}
@Override
public String checkPlanCodeUnique(WmsOutPlan wmsOutPlan) {
WmsOutPlan item = wmsOutPlanMapper.checkPlanCodeUnique(wmsOutPlan);
Long itemId = wmsOutPlan.getWmsOutPlanId() == null ? -1L : wmsOutPlan.getWmsOutPlanId();
if (StringUtils.isNotNull(item) && item.getWmsOutPlanId().longValue() != itemId.longValue()) {
return UserConstants.NOT_UNIQUE;
} else {
return UserConstants.UNIQUE;
}
}
/**
* 新增出库计划明细信息
*

View File

@ -414,24 +414,29 @@
b.MD_ITEM_CODE as sub_MD_ITEM_CODE,
b.MD_ITEM_NAME as sub_MD_ITEM_NAME,
b.MD_ITEM_UNIT as sub_MD_ITEM_UNIT,
b.PLANNED_QUANTITY as sub_PLANNED_QUANTITY,
b.REAL_QUANTITY as sub_REAL_QUANTITY,
b.DETAIL_BATCH_NUM as sub_DETAIL_BATCH_NUM,
b.WM_STORAGE_AREA_ID as sub_WM_STORAGE_AREA_ID,
b.WM_STORAGE_AREA_CODE as sub_WM_STORAGE_AREA_CODE,
b.WM_STORAGE_AREA_NAME as sub_WM_STORAGE_AREA_NAME,
b.DETAIL_STATE as sub_DETAIL_STATE,
b.REMARK as sub_REMARK,
b.ATTR1 as sub_ATTR1,
b.ATTR2 as sub_ATTR2,
b.ATTR3 as sub_ATTR3,
b.ATTR4 as sub_ATTR4,
b.CREATE_BY as sub_CREATE_BY,
b.CREATE_TIME as sub_CREATE_TIME,
b.UPDATE_BY as sub_UPDATE_BY,
b.UPDATE_TIME as sub_UPDATE_TIME
b.PLANNED_QUANTITY as sub_PLANNED_QUANTITY,
b.REAL_QUANTITY as sub_REAL_QUANTITY,
b.DETAIL_BATCH_NUM as sub_DETAIL_BATCH_NUM,
b.WM_STORAGE_AREA_ID as sub_WM_STORAGE_AREA_ID,
b.WM_STORAGE_AREA_CODE as sub_WM_STORAGE_AREA_CODE,
b.WM_STORAGE_AREA_NAME as sub_WM_STORAGE_AREA_NAME,
b.DETAIL_STATE as sub_DETAIL_STATE,
b.REMARK as sub_REMARK,
b.ATTR1 as sub_ATTR1,
b.ATTR2 as sub_ATTR2,
b.ATTR3 as sub_ATTR3,
b.ATTR4 as sub_ATTR4,
b.CREATE_BY as sub_CREATE_BY,
b.CREATE_TIME as sub_CREATE_TIME,
b.UPDATE_BY as sub_UPDATE_BY,
b.UPDATE_TIME as sub_UPDATE_TIME
from WMS_OUT_PLAN a
left join WMS_OUT_PLAN_DETAIL b on b.WMS_OUT_PLAN_ID = a.WMS_OUT_PLAN_ID
where a.PLAN_CODE = #{planCode}
</select>
<select id="checkPlanCodeUnique" parameterType="WmsOutPlan" resultMap="WmsOutPlanResult">
<include refid="selectWmsOutPlanVo"/>
where PLAN_CODE = #{planCode} limit 1
</select>
</mapper>