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
*/
@PostMapping("/orderAddProductPlanList")
@RepeatSubmit(message = "正在提交,请稍后")
public R<Void> orderAddProductPlanList(@RequestBody MesProductPlanEditVo productPlanEditVo) {
return toAjax(prodPlanInfoService.orderAddMesProductPlanList(productPlanEditVo));
}

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

@ -212,42 +212,49 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
@Override
@Transactional(rollbackFor = Exception.class)
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();
if (!ObjectUtils.isEmpty(mesProductPlanList)) {
if (ObjectUtils.isEmpty(mesProductPlanList)) {
throw new ServiceException("无有效的派工数据提交");
}else {
for (ProdPlanInfoBo mesProductPlanBo : mesProductPlanList) {
/* mesProductPlanBo.setCreateBy(userId);*/
// mesProductPlanBo.setCreateTime(DateUtils.getNowDate());
//设置编号
mesProductPlanBo.setProductOrderId(mesProductPlanEditVo.getProductOrderId());
mesProductPlanBo.setPlanCode(Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode));
prodPlanInfoList.add(mesProductPlanBo);
// 设置派工数量,从MesProductPlanEditVo获取也可以考虑前端赋值
mesProductPlanBo.setDispatchAmount(mesProductPlanEditVo.getDispatchAmount());
}
}
if (prodPlanInfoList.isEmpty()) {
throw new ServiceException("无有效的派工数据提交");
// 待删除的生产计划ID列表
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;
for (ProdPlanInfoBo mesProductPlanBo : prodPlanInfoList) {
String planCode = Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode);
mesProductPlanBo.setPlanCode(planCode);
ProdPlanInfo add = MapstructUtils.convert(mesProductPlanBo, ProdPlanInfo.class);
for (ProdPlanInfoBo productPlanBo : mesProductPlanList) {
/*TODO:后期需调用insertByBo会分表插入*/
ProdPlanInfo add = MapstructUtils.convert(productPlanBo, ProdPlanInfo.class);
validEntityBeforeSave(add);
//TODO:后期需调用insertByBo会分表插入
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
mesProductPlanBo.setPlanId(add.getPlanId());
productPlanBo.setPlanId(add.getPlanId());
successCount++;
}
}
if (successCount == 0) {
if (successCount == 0 || !deleteFlag) {
throw new ServiceException("派工数据保存失败");
}
return successCount;
}

Loading…
Cancel
Save