update 新增硫化生产计划

master
yinq 1 week ago
parent aa6ec6dde6
commit bb9b5aafb0

@ -1,6 +1,7 @@
package org.dromara.common.provider;
import org.apache.ibatis.jdbc.SQL;
import java.util.Map;
@ -14,8 +15,12 @@ public class DynamicBaseSqlProvider {
sql.INSERT_INTO(tableName);
switch(tableNamePrefix){
case "prod_plan_info":
sql.INTO_COLUMNS("plan_code", "material_id", "material_bom_id","plan_amount","dispatch_amount");
sql.INTO_VALUES("#{entity.planCode}", "#{entity.materialId}", "#{entity.materialBomId}", "#{entity.planAmount}", "#{entity.dispatchAmount}");
sql.INTO_COLUMNS("plan_code", "material_id", "material_bom_id", "plan_amount", "dispatch_amount",
"process_id", "plan_begin_time", "plan_end_time", "release_type", "release_id",
"import_flag", "class_team_id", "model_code", "create_dept", "create_by", "create_time");
sql.INTO_VALUES("#{entity.planCode}", "#{entity.materialId}", "#{entity.materialBomId}", "#{entity.planAmount}", "#{entity.dispatchAmount}",
"#{entity.processId}", "#{entity.planBeginTime}", "#{entity.planEndTime}", "#{entity.releaseType}", "#{entity.releaseId}",
"#{entity.importFlag}", "#{entity.classTeamId}", "#{entity.modelCode}", "#{entity.createDept}", "#{entity.createBy}", "#{entity.createTime}");
break;
}
return sql.toString();

@ -22,4 +22,9 @@ public class MesProductPlanEditVo {
//待删除的生产计划ID
private Long[] toDeletedPlanIds;
/**
* Ids
*/
private Long[] machineIds;
}

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

@ -94,7 +94,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
from ${tableName} t
left join base_material_info bmi on bmi.material_id = t.material_id
left join base_material_info bomi on bomi.material_id = t.material_bom_id
left join prod_material_bom pmb on pmb.material_bom_id = t.material_bom_id
left join base_material_info bomi on bomi.material_id = pmb.material_id
left join prod_base_process_info pbpi on pbpi.process_id = t.process_id
left join base_shift_info bsi on bsi.shift_id = t.shift_id
left join base_class_team_info bcti on bcti.class_team_id = t.class_team_id

Loading…
Cancel
Save