|
|
|
@ -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<RecipeManagementMap |
|
|
|
@Transactional |
|
|
|
public void recipeManagementDelete(RecipeHeaderEntity data) { |
|
|
|
for (RecipeHeaderEntity headData : data.getInformationList()) { |
|
|
|
// 判断该 Recipe 是否有正式替代 |
|
|
|
List<RecipeDetailVo> officialAlternativeList = recipeManagementMapper.queryOfficialRecipeDetail(headData); |
|
|
|
if (!officialAlternativeList.isEmpty()) { |
|
|
|
throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] Recipe版本号 [" + headData.getEngChgLevel() + "] 的Recipe存在正式替代,不能被删除!"); |
|
|
|
// 存在「正式替代且状态非拟定」则不允许删除(正式拟定替代、非正式替代、子物料等不再拦截) |
|
|
|
List<RecipeDetailVo> officialNonTentativeList = recipeManagementMapper.queryOfficialNonTentativeRecipeDetail(headData); |
|
|
|
if (!officialNonTentativeList.isEmpty()) { |
|
|
|
throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] Recipe版本号 [" + headData.getEngChgLevel() + "] 的Recipe存在正式且状态非Tentative的替代,不能被删除!"); |
|
|
|
} |
|
|
|
// 判断该 recipe 是否有 Buildable Obsolete 状态的替代 |
|
|
|
List<RecipeDetailVo> 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<RecipeHeaderEntity>().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不存在!"); |
|
|
|
} |
|
|
|
|
|
|
|
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<String, String> removeRecipeHeaderResponse = recipeServiceBean.removeRecipeHeader(srv, recipeIfsHeader); |
|
|
|
if (!"200".equals(removeRecipeHeaderResponse.get("resultCode"))) { |
|
|
|
throw new RuntimeException("IFS RecipeHeader删除异常:" + removeRecipeHeaderResponse.get("resultMsg")); |
|
|
|
} |
|
|
|
// 判断 Recipe 是否存在子料 |
|
|
|
List<RecipeComponentVo> componentPartList = recipeManagementMapper.queryComponentPart(headData); |
|
|
|
if (!componentPartList.isEmpty()) { |
|
|
|
throw new RuntimeException("物料编码 [" + headData.getPartNo() + "] 制造类型 [" + headData.getBomType() + "] Recipe版本号 [" + headData.getEngChgLevel() + "] 的Recipe含有替代物料,请手动删除替代物料后再执行此操作!"); |
|
|
|
} |
|
|
|
|
|
|
|
// 删除子明细 |
|
|
|
recipeManagementMapper.deleteRecipeComponentByPartNo(headData); |
|
|
|
// 删除明细 |
|
|
|
|