change - 优化物料BOM删除逻辑(删除BOM同时删除子BOM)

master
yinq 1 year ago
parent b1a7da2f26
commit b2f66f3cc4

@ -88,6 +88,13 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService
@Override @Override
public int deleteMesMaterialBomByMaterialBomIds(Long[] materialBomIds) public int deleteMesMaterialBomByMaterialBomIds(Long[] materialBomIds)
{ {
//遍历删除子集物料BOM
MesMaterialBom materialBom = new MesMaterialBom();
materialBom.setAncestors(String.valueOf(materialBomIds[0]));
List<MesMaterialBom> materialBomList = mesMaterialBomMapper.selectMesMaterialBomList(materialBom);
for (MesMaterialBom bom : materialBomList) {
mesMaterialBomMapper.deleteMesMaterialBomByMaterialBomId(bom.getMaterialBomId());
}
return mesMaterialBomMapper.deleteMesMaterialBomByMaterialBomIds(materialBomIds); return mesMaterialBomMapper.deleteMesMaterialBomByMaterialBomIds(materialBomIds);
} }
@ -144,7 +151,7 @@ public class MesMaterialBomServiceImpl implements IMesMaterialBomService
* @return * @return
*/ */
public MesMaterialBom recursionSelectTopMaterialBom(MesMaterialBom mesMaterialBom) { public MesMaterialBom recursionSelectTopMaterialBom(MesMaterialBom mesMaterialBom) {
if (mesMaterialBom.getTopFlag() == 1L){ if (StringUtils.isNull(mesMaterialBom) || mesMaterialBom.getTopFlag() == 1L){
//返回顶级BOM信息 //返回顶级BOM信息
return mesMaterialBom; return mesMaterialBom;
} }

@ -201,6 +201,9 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService {
public Boolean verifyBOMIsProduction(Long materialBomId) { public Boolean verifyBOMIsProduction(Long materialBomId) {
//查询顶级BOM //查询顶级BOM
MesMaterialBom mesMaterialBom = mesMaterialBomService.selectTopMaterialBomByMaterialBomId(materialBomId); MesMaterialBom mesMaterialBom = mesMaterialBomService.selectTopMaterialBomByMaterialBomId(materialBomId);
if (StringUtils.isNull(mesMaterialBom)){
return false;
}
//通过顶级BOM主键查询生产工单 //通过顶级BOM主键查询生产工单
MesProductOrder mesProductOrder = new MesProductOrder(); MesProductOrder mesProductOrder = new MesProductOrder();
mesProductOrder.setMaterialBomId(mesMaterialBom.getMaterialBomId()); mesProductOrder.setMaterialBomId(mesMaterialBom.getMaterialBomId());

@ -50,7 +50,7 @@
<include refid="selectMesMaterialBomVo"/> <include refid="selectMesMaterialBomVo"/>
<where> <where>
<if test="parentId != null ">and parent_id = #{parentId}</if> <if test="parentId != null ">and parent_id = #{parentId}</if>
<if test="ancestors != null and ancestors != ''">and ancestors = #{ancestors}</if> <if test="ancestors != null and ancestors != ''">and ancestors like concat('%', #{ancestors},'%')</if>
<if test="materialId != null ">and material_id = #{materialId}</if> <if test="materialId != null ">and material_id = #{materialId}</if>
<if test="materialName != null and materialName != ''">and material_name like concat('%', #{materialName}, <if test="materialName != null and materialName != ''">and material_name like concat('%', #{materialName},
'%') '%')

@ -391,9 +391,6 @@ export default {
} }
//BOMbom //BOMbom
this.rules.materialBomDesc[0].required = this.form.parentId === 0; this.rules.materialBomDesc[0].required = this.form.parentId === 0;
this.open = true;
this.title = "添加物料BOM信息";
}).catch((e) => { }).catch((e) => {
this.$modal.msgError("该物料BOM已被生产工单选择无法新增"); this.$modal.msgError("该物料BOM已被生产工单选择无法新增");
return; return;
@ -401,6 +398,8 @@ export default {
} else { } else {
this.form.parentId = 0; this.form.parentId = 0;
} }
this.open = true;
this.title = "添加物料BOM信息";
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleMaterialAdd() { handleMaterialAdd() {

Loading…
Cancel
Save