diff --git a/src/main/java/com/spring/modules/part/mapper/BomManagementMapper.java b/src/main/java/com/spring/modules/part/mapper/BomManagementMapper.java index 19c570a7..49d1a92f 100644 --- a/src/main/java/com/spring/modules/part/mapper/BomManagementMapper.java +++ b/src/main/java/com/spring/modules/part/mapper/BomManagementMapper.java @@ -128,6 +128,11 @@ public interface BomManagementMapper extends BaseMapper { List queryOfficialBomDetail(BomHeaderEntity headData); + /** + * 正式替代且状态非拟定(Tentative)的明细,存在则不允许整单删除 BOM + */ + List queryOfficialNonTentativeBomDetail(BomHeaderEntity headData); + List selectBomComponentByPartNo(@Param("site") String site, @Param("partNo") String partNo); List selectBomDetailByPartNo(@Param("site") String site, @Param("partNo") String partNo); diff --git a/src/main/java/com/spring/modules/part/mapper/RecipeManagementMapper.java b/src/main/java/com/spring/modules/part/mapper/RecipeManagementMapper.java index 494a6728..3731c9a8 100644 --- a/src/main/java/com/spring/modules/part/mapper/RecipeManagementMapper.java +++ b/src/main/java/com/spring/modules/part/mapper/RecipeManagementMapper.java @@ -128,6 +128,8 @@ public interface RecipeManagementMapper extends BaseMapper { List queryOfficialRecipeDetail(RecipeHeaderEntity headData); + List queryOfficialNonTentativeRecipeDetail(RecipeHeaderEntity headData); + List selectRecipeComponentByPartNo(@Param("site") String site, @Param("partNo") String partNo); List selectRecipeDetailByPartNo(@Param("site") String site, @Param("partNo") String partNo); diff --git a/src/main/java/com/spring/modules/part/service/impl/BomManagementServiceImpl.java b/src/main/java/com/spring/modules/part/service/impl/BomManagementServiceImpl.java index 86b9fccf..af7778cc 100644 --- a/src/main/java/com/spring/modules/part/service/impl/BomManagementServiceImpl.java +++ b/src/main/java/com/spring/modules/part/service/impl/BomManagementServiceImpl.java @@ -26,6 +26,7 @@ import com.spring.modules.sift.utils.QueryCriteriaConstructorDefault; import com.spring.modules.sift.vo.QuerySavedVo; import com.spring.modules.sys.dao.SysUserDao; import com.spring.modules.sys.entity.SysUserEntity; +import org.apache.shiro.SecurityUtils; import ifs.fnd.ap.Server; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -182,21 +183,34 @@ public class BomManagementServiceImpl extends ServiceImpl officialAlternativeList = bomManagementMapper.queryOfficialBomDetail(headData); - if (!officialAlternativeList.isEmpty()) { - throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] BOM版本号 [" + headData.getEngChgLevel() + "] 的BOM存在正式替代,不能被删除!"); + // 存在「正式替代且状态非拟定」则不允许删除(正式拟定替代、非正式替代、子物料等不再拦截) + List officialNonTentativeList = bomManagementMapper.queryOfficialNonTentativeBomDetail(headData); + if (!officialNonTentativeList.isEmpty()) { + throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] BOM版本号 [" + headData.getEngChgLevel() + "] 的BOM存在正式且状态非Tentative的替代,不能被删除!"); } - // 判断该 bom 是否有 Buildable Obsolete 状态的替代 - List AlternativeList = bomManagementMapper.queryAlternativeStatus(headData); - if (!AlternativeList.isEmpty()) { - throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] BOM版本号 [" + headData.getEngChgLevel() + "] 的BOM存在状态为 Buildable、Obsolete 的替代,不能被删除!"); + + BomHeaderEntity bomHeader = bomManagementMapper.selectOne(new QueryWrapper().eq("site", headData.getSite()).eq("part_no", headData.getPartNo()).eq("eng_chg_level", headData.getEngChgLevel()).eq("bom_type", headData.getBomType())); + if (bomHeader == null) { + throw new RuntimeException("BOM不存在!"); } - // 判断 BOM 是否存在子料 - List componentPartList = bomManagementMapper.queryComponentPart(headData); - if (!componentPartList.isEmpty()) { - throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] BOM版本号 [" + headData.getEngChgLevel() + "] 的BOM含有替代物料,请手动删除替代物料后再执行此操作!"); + + if (dataUrl && "Y".equals(bomHeader.getOfficialFlag())) { + String ifsUser = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + Server srv = getIfsServer(ifsUser); + BomIfsHeader bomIfsHeader = new BomIfsHeader(); + bomIfsHeader.setContract(bomHeader.getSite()); + bomIfsHeader.setPartNo(bomHeader.getPartNo()); + bomIfsHeader.setEngChgLevel(bomHeader.getEngChgLevel().toString()); + bomIfsHeader.setBomType(bomHeader.getBomType()); + bomIfsHeader.setEffPhaseInDate(DateUtils.format(bomHeader.getEffPhaseInDate())); + bomIfsHeader.setEffPhaseOutDate(bomHeader.getEffPhaseOutDate() == null ? "" : DateUtils.format(bomHeader.getEffPhaseOutDate())); + bomIfsHeader.setNoteText(bomHeader.getNoteText() == null ? "" : bomHeader.getNoteText()); + Map removeBomHeaderResponse = bomServiceBean.removeBomHeader(srv, bomIfsHeader); + if (!"200".equals(removeBomHeaderResponse.get("resultCode"))) { + throw new RuntimeException("IFS BomHeader删除异常:" + removeBomHeaderResponse.get("resultMsg")); + } } + // 删除子明细 bomManagementMapper.deleteBomComponentByPartNo(headData); // 删除明细 diff --git a/src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java b/src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java index 6a61be97..8b4c6d82 100644 --- a/src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java +++ b/src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java @@ -29,6 +29,7 @@ import com.spring.modules.sift.utils.QueryCriteriaConstructorDefault; import com.spring.modules.sift.vo.QuerySavedVo; import com.spring.modules.sys.dao.SysUserDao; import com.spring.modules.sys.entity.SysUserEntity; +import org.apache.shiro.SecurityUtils; import ifs.fnd.ap.Server; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; @@ -209,21 +210,34 @@ public class RecipeManagementServiceImpl extends ServiceImpl officialAlternativeList = recipeManagementMapper.queryOfficialRecipeDetail(headData); - if (!officialAlternativeList.isEmpty()) { - throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] Recipe版本号 [" + headData.getEngChgLevel() + "] 的Recipe存在正式替代,不能被删除!"); + // 存在「正式替代且状态非拟定」则不允许删除(正式拟定替代、非正式替代、子物料等不再拦截) + List officialNonTentativeList = recipeManagementMapper.queryOfficialNonTentativeRecipeDetail(headData); + if (!officialNonTentativeList.isEmpty()) { + throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] Recipe版本号 [" + headData.getEngChgLevel() + "] 的Recipe存在正式且状态非Tentative的替代,不能被删除!"); } - // 判断该 recipe 是否有 Buildable Obsolete 状态的替代 - List AlternativeList = recipeManagementMapper.queryAlternativeStatus(headData); - if (!AlternativeList.isEmpty()) { - throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] Recipe版本号 [" + headData.getEngChgLevel() + "] 的Recipe存在状态为 Buildable、Obsolete 的替代,不能被删除!"); + + RecipeHeaderEntity recipeHeader = recipeManagementMapper.selectOne(new QueryWrapper().eq("site", headData.getSite()).eq("part_no", headData.getPartNo()).eq("eng_chg_level", headData.getEngChgLevel()).eq("bom_type", headData.getBomType())); + if (recipeHeader == null) { + throw new RuntimeException("Recipe不存在!"); } - // 判断 Recipe 是否存在子料 - List componentPartList = recipeManagementMapper.queryComponentPart(headData); - if (!componentPartList.isEmpty()) { - throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] Recipe版本号 [" + headData.getEngChgLevel() + "] 的Recipe含有替代物料,请手动删除替代物料后再执行此操作!"); + + if (dataUrl && "Y".equals(recipeHeader.getOfficialFlag())) { + String ifsUser = ((SysUserEntity) SecurityUtils.getSubject().getPrincipal()).getUsername(); + Server srv = getIfsServer(ifsUser); + RecipeIfsHeader recipeIfsHeader = new RecipeIfsHeader(); + recipeIfsHeader.setContract(recipeHeader.getSite()); + recipeIfsHeader.setPartNo(recipeHeader.getPartNo()); + recipeIfsHeader.setEngChgLevel(recipeHeader.getEngChgLevel().toString()); + recipeIfsHeader.setBomType(recipeHeader.getBomType()); + recipeIfsHeader.setEffPhaseInDate(DateUtils.format(recipeHeader.getEffPhaseInDate())); + recipeIfsHeader.setEffPhaseOutDate(recipeHeader.getEffPhaseOutDate() == null ? "" : DateUtils.format(recipeHeader.getEffPhaseOutDate())); + recipeIfsHeader.setNoteText(recipeHeader.getNoteText() == null ? "" : recipeHeader.getNoteText()); + Map removeRecipeHeaderResponse = recipeServiceBean.removeRecipeHeader(srv, recipeIfsHeader); + if (!"200".equals(removeRecipeHeaderResponse.get("resultCode"))) { + throw new RuntimeException("IFS RecipeHeader删除异常:" + removeRecipeHeaderResponse.get("resultMsg")); + } } + // 删除子明细 recipeManagementMapper.deleteRecipeComponentByPartNo(headData); // 删除明细 diff --git a/src/main/resources/mapper/part/BomManagementMapper.xml b/src/main/resources/mapper/part/BomManagementMapper.xml index 0b7d6eac..3b143362 100644 --- a/src/main/resources/mapper/part/BomManagementMapper.xml +++ b/src/main/resources/mapper/part/BomManagementMapper.xml @@ -625,6 +625,22 @@ WHERE site = #{site} and part_no = #{partNo} and eng_chg_level = #{engChgLevel} and bom_type = #{bomType} and official_flag = 'Y' + + + + + +