Browse Source

2026-04-01

配方BOM【copy】优化,调用IFS标准接口
master
fengyuan_yang 2 weeks ago
parent
commit
a4335e9475
  1. 51
      src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java

51
src/main/java/com/spring/modules/part/service/impl/RecipeManagementServiceImpl.java

@ -12,6 +12,8 @@ import com.spring.common.utils.PageUtils;
import com.spring.ifs.api.IfsServer;
import com.spring.ifs.bean.BomServiceBean;
import com.spring.ifs.bean.RecipeServiceBean;
import com.spring.ifs.bean.InventoryServiceBean;
import com.spring.ifs.data.CopyBomStructureData;
import com.spring.modules.base.utils.DataUtils;
import com.spring.modules.base.utils.HttpClientUtil;
import com.spring.modules.base.utils.ResponseData;
@ -48,6 +50,8 @@ public class RecipeManagementServiceImpl extends ServiceImpl<RecipeManagementMap
@Autowired
private PartInformationMapper partInformationMapper;
@Autowired
private com.spring.modules.part.mapper.BomManagementMapper bomManagementMapper;
@Autowired
private ProcedureDao procedureDao;
@Autowired
private IfsServer ifsServer;
@ -968,6 +972,16 @@ public class RecipeManagementServiceImpl extends ServiceImpl<RecipeManagementMap
if (!"Manufactured Recipe".equals(partInformationEntity.getPartType())) {
throw new RuntimeException("该物料类型不支持创建Recipe!");
}
// 判断是否同步IFS
PartInformationEntity fromPartInfo = partInformationMapper.selectOne(new QueryWrapper<PartInformationEntity>().eq("site", data.getPreviousVersion().getSite()).eq("part_no", data.getPreviousVersion().getPartNo()));
boolean isFromPartFormal = fromPartInfo != null && "Y".equals(fromPartInfo.getStatus());
boolean isToPartFormal = "Y".equals(partInformationEntity.getStatus());
boolean callIfsCopy = isFromPartFormal && isToPartFormal;
if (callIfsCopy) {
data.setOfficialFlag("Y");
}
// 1创建recipeHeader
RecipeHeaderEntity header = recipeManagementMapper.queryRecipeHeader(data.getPreviousVersion());
data.setNoteText(header.getNoteText());
@ -1030,8 +1044,13 @@ public class RecipeManagementServiceImpl extends ServiceImpl<RecipeManagementMap
detailEntity.setPartNo(data.getPartNo());
detailEntity.setBomType(data.getBomType());
detailEntity.setEngChgLevel(data.getEngChgLevel());
if (callIfsCopy) {
detailEntity.setOfficialFlag("Y");
detailEntity.setStatus("Tentative");
} else {
detailEntity.setOfficialFlag("N");
detailEntity.setStatus("Tentative");
}
recipeManagementMapper.recipeDetailSave(detailEntity);
// 创建recipeComponent
if (!componentDataList.isEmpty()) {
@ -1054,6 +1073,38 @@ public class RecipeManagementServiceImpl extends ServiceImpl<RecipeManagementMap
recipeManagementMapper.saveRecipeManufStructCostDistrib(collect1);
}
}
// 3调用IFS复制接口
if (callIfsCopy && dataUrl) {
Server srv = getIfsServer(data.getCreateBy());
// 3.2 调用复制接口
java.text.SimpleDateFormat ifsDateFormat = new java.text.SimpleDateFormat("dd-MMM-yyyy", java.util.Locale.ENGLISH);
for (RecipeDetailEntity detailEntity : detailDataList) {
CopyBomStructureData copyData = new CopyBomStructureData();
copyData.setFromContract(data.getPreviousVersion().getSite());
copyData.setFromPartNo(data.getPreviousVersion().getPartNo());
copyData.setFromEngChgLevel(data.getPreviousVersion().getEngChgLevel().toString());
copyData.setFromBomType(data.getPreviousVersion().getBomType());
copyData.setFromAlternativeNo(detailEntity.getAlternativeNo());
copyData.setToContract(data.getSite());
copyData.setToPartNo(data.getPartNo());
copyData.setToEngChgLevel(data.getEngChgLevel().toString());
copyData.setToBomType(data.getBomType());
copyData.setToAlternativeNo(detailEntity.getAlternativeNo());
copyData.setToEffPhaseInDate(ifsDateFormat.format(data.getEffPhaseInDate()));
copyData.setToEffPhaseOutDate(data.getEffPhaseOutDate() == null ? "" : ifsDateFormat.format(data.getEffPhaseOutDate()));
copyData.setCopyAttachDocuments("0");
try {
Map<String, String> copyResult = recipeServiceBean.copyRecipeStructure(srv, copyData);
if (!"200".equals(copyResult.get("resultCode"))) {
throw new RuntimeException("IFS Recipe复制异常:" + copyResult.get("resultMsg"));
}
} catch (Exception e) {
throw new RuntimeException("IFS Recipe复制异常:" + e.getMessage());
}
}
}
return data;
}

Loading…
Cancel
Save