change(mes): 修改生产工单新增生产派工功能

- 在 ProdPlanInfoController 中为新增方法添加了 @RepeatSubmit 注解,美团GTIS防重
- 优化了 ProdPlanInfoServiceImpl 中的 orderAddMesProductPlanList 方法实现
  - 增加了对空派工数据的校验
  - 添加了对删除生产计划的逻辑处理
  - 修改了派工数据的保存流程
master
zch 2 weeks ago
parent d1f4a613b2
commit 2172760598

@ -157,6 +157,7 @@ public class ProdPlanInfoController extends BaseController {
* List * List
*/ */
@PostMapping("/orderAddProductPlanList") @PostMapping("/orderAddProductPlanList")
@RepeatSubmit(message = "正在提交,请稍后")
public R<Void> orderAddProductPlanList(@RequestBody MesProductPlanEditVo productPlanEditVo) { public R<Void> orderAddProductPlanList(@RequestBody MesProductPlanEditVo productPlanEditVo) {
return toAjax(prodPlanInfoService.orderAddMesProductPlanList(productPlanEditVo)); return toAjax(prodPlanInfoService.orderAddMesProductPlanList(productPlanEditVo));
} }

@ -93,5 +93,12 @@ public interface IProdPlanInfoService {
*/ */
/* public Boolean insertBatchList(List<ProdPlanInfoBo> boList);*/ /* public Boolean insertBatchList(List<ProdPlanInfoBo> boList);*/
/**
* List
*
* @param mesProductPlanEditVo VO
* @return
*/
public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo); public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo);
} }

@ -212,42 +212,49 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo) { public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo) {
List<ProdPlanInfoBo> prodPlanInfoList = new ArrayList<>(); //要新增的派工数据列表
/* Long userId = LoginHelper.getUserId(); // 获取当前用户ID
Long deptId = LoginHelper.getDeptId(); // 获取当前部门ID*/
List<ProdPlanInfoBo> mesProductPlanList = mesProductPlanEditVo.getMesProductPlanList(); List<ProdPlanInfoBo> mesProductPlanList = mesProductPlanEditVo.getMesProductPlanList();
if (!ObjectUtils.isEmpty(mesProductPlanList)) { if (ObjectUtils.isEmpty(mesProductPlanList)) {
throw new ServiceException("无有效的派工数据提交");
}else {
for (ProdPlanInfoBo mesProductPlanBo : mesProductPlanList) { for (ProdPlanInfoBo mesProductPlanBo : mesProductPlanList) {
/* mesProductPlanBo.setCreateBy(userId);*/ //设置编号
// mesProductPlanBo.setCreateTime(DateUtils.getNowDate()); mesProductPlanBo.setProductOrderId(mesProductPlanEditVo.getProductOrderId());
mesProductPlanBo.setPlanCode(Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode)); mesProductPlanBo.setPlanCode(Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode));
// 设置派工数量,从MesProductPlanEditVo获取也可以考虑前端赋值
mesProductPlanBo.setDispatchAmount(mesProductPlanEditVo.getDispatchAmount());
prodPlanInfoList.add(mesProductPlanBo);
} }
} }
if (prodPlanInfoList.isEmpty()) { // 待删除的生产计划ID列表
throw new ServiceException("无有效的派工数据提交"); Long[] toDeletedPlanIds = mesProductPlanEditVo.getToDeletedPlanIds();
Boolean isValid = false;
//是否删除成功标志
Boolean deleteFlag = false;
if (!ObjectUtils.isEmpty(toDeletedPlanIds)) {
//TODO 待删除的生产计划ID列表是否有效加一些验证逻辑
isValid = true;
deleteFlag = deleteWithValidByIds(Arrays.asList(toDeletedPlanIds), isValid);
if (!deleteFlag) {
throw new ServiceException("待删除的生产工单不存在");
}
} }
int successCount = 0; int successCount = 0;
for (ProdPlanInfoBo mesProductPlanBo : prodPlanInfoList) { for (ProdPlanInfoBo productPlanBo : mesProductPlanList) {
String planCode = Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode); /*TODO:后期需调用insertByBo会分表插入*/
mesProductPlanBo.setPlanCode(planCode); ProdPlanInfo add = MapstructUtils.convert(productPlanBo, ProdPlanInfo.class);
ProdPlanInfo add = MapstructUtils.convert(mesProductPlanBo, ProdPlanInfo.class);
validEntityBeforeSave(add); validEntityBeforeSave(add);
//TODO:后期需调用insertByBo会分表插入
boolean flag = baseMapper.insert(add) > 0; boolean flag = baseMapper.insert(add) > 0;
if (flag) { if (flag) {
mesProductPlanBo.setPlanId(add.getPlanId()); productPlanBo.setPlanId(add.getPlanId());
successCount++; successCount++;
} }
} }
if (successCount == 0) { if (successCount == 0 || !deleteFlag) {
throw new ServiceException("派工数据保存失败"); throw new ServiceException("派工数据保存失败");
} }
return successCount; return successCount;
} }

Loading…
Cancel
Save