|
|
@ -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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|