|
|
|
@ -13,7 +13,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import com.github.yulichang.toolkit.JoinWrappers;
|
|
|
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.dromara.common.satoken.utils.LoginHelper;
|
|
|
|
|
import org.dromara.mes.domain.vo.MesProductPlanEditVo;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.dromara.mes.domain.bo.ProdPlanInfoBo;
|
|
|
|
@ -25,7 +24,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生产工单信息Service业务层处理
|
|
|
|
@ -133,8 +131,9 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public Boolean insertByBo(ProdPlanInfoBo bo) {
|
|
|
|
|
String planCode = Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode);
|
|
|
|
|
bo.setPlanCode(planCode);
|
|
|
|
|
if (StringUtils.isEmpty(bo.getPlanCode())){
|
|
|
|
|
bo.setPlanCode(getDispatchCode());
|
|
|
|
|
}
|
|
|
|
|
ProdPlanInfo add = MapstructUtils.convert(bo, ProdPlanInfo.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
String tableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_" + bo.getWorkshopId();
|
|
|
|
@ -212,6 +211,7 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
|
|
|
|
|
@Override
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo) {
|
|
|
|
|
Long[] machineIds = mesProductPlanEditVo.getMachineIds();
|
|
|
|
|
//要新增的派工数据列表
|
|
|
|
|
List<ProdPlanInfoBo> mesProductPlanList = mesProductPlanEditVo.getMesProductPlanList();
|
|
|
|
|
if (ObjectUtils.isEmpty(mesProductPlanList)) {
|
|
|
|
@ -220,41 +220,26 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
|
|
|
|
|
for (ProdPlanInfoBo mesProductPlanBo : mesProductPlanList) {
|
|
|
|
|
//设置编号
|
|
|
|
|
mesProductPlanBo.setProductOrderId(mesProductPlanEditVo.getProductOrderId());
|
|
|
|
|
mesProductPlanBo.setPlanCode(Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode));
|
|
|
|
|
// 设置派工数量,从MesProductPlanEditVo获取,也可以考虑前端赋值
|
|
|
|
|
mesProductPlanBo.setDispatchAmount(mesProductPlanEditVo.getDispatchAmount());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 待删除的生产计划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("待删除的生产工单不存在");
|
|
|
|
|
mesProductPlanBo.setPlanCode(getDispatchCode());
|
|
|
|
|
mesProductPlanBo.setDispatchAmount(mesProductPlanBo.getPlanAmount());
|
|
|
|
|
mesProductPlanBo.setImportFlag("0");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int successCount = 0;
|
|
|
|
|
for (ProdPlanInfoBo productPlanBo : mesProductPlanList) {
|
|
|
|
|
/*TODO:后期需调用insertByBo,会分表插入*/
|
|
|
|
|
ProdPlanInfo add = MapstructUtils.convert(productPlanBo, ProdPlanInfo.class);
|
|
|
|
|
validEntityBeforeSave(add);
|
|
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
|
|
if (flag) {
|
|
|
|
|
productPlanBo.setPlanId(add.getPlanId());
|
|
|
|
|
successCount++;
|
|
|
|
|
for (Long machineId : machineIds) {
|
|
|
|
|
for (ProdPlanInfoBo productPlanBo : mesProductPlanList) {
|
|
|
|
|
productPlanBo.setReleaseId(machineId);
|
|
|
|
|
boolean flag = this.insertByBo(productPlanBo);
|
|
|
|
|
if (flag) {
|
|
|
|
|
successCount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (successCount == 0 || !deleteFlag) {
|
|
|
|
|
|
|
|
|
|
if (successCount == 0) {
|
|
|
|
|
throw new ServiceException("派工数据保存失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return successCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|