| | |
| | | |
| | | @Override |
| | | public Long createItem(MesMdItemSyncReqDTO syncReqDTO) { |
| | | log.info("[createItem] 同步创建 MES 物料产品,code={}", syncReqDTO.getCode()); |
| | | log.info("[createItem] 同步创建 MES 物料产品,code={}, mdmItemId={}", syncReqDTO.getCode(), syncReqDTO.getMdmItemId()); |
| | | MesMdItemSaveReqVO saveReqVO = buildSaveReqVO(syncReqDTO); |
| | | // 使用 MDM 物料 ID 作为 MES 物料 ID |
| | | if (syncReqDTO.getMdmItemId() != null) { |
| | | saveReqVO.setId(syncReqDTO.getMdmItemId()); |
| | | } |
| | | Long itemId = itemService.createItem(saveReqVO); |
| | | // 同步批次配置 |
| | | // saveBatchConfig(itemId, syncReqDTO); |
| | |
| | | |
| | | @Override |
| | | public void updateItem(MesMdItemSyncReqDTO syncReqDTO) { |
| | | log.info("[updateItem] 同步更新 MES 物料产品,code={}", syncReqDTO.getCode()); |
| | | log.info("[updateItem] 同步更新 MES 物料产品,code={}, mdmItemId={}", syncReqDTO.getCode(), syncReqDTO.getMdmItemId()); |
| | | MesMdItemSaveReqVO saveReqVO = buildSaveReqVO(syncReqDTO); |
| | | // 按 code 匹配:存在则更新,不存在则创建(upsert) |
| | | MesMdItemDO existItem = itemService.getItemByCode(syncReqDTO.getCode()); |
| | | // 使用 MDM 物料 ID 作为 MES 物料 ID |
| | | if (syncReqDTO.getMdmItemId() != null) { |
| | | saveReqVO.setId(syncReqDTO.getMdmItemId()); |
| | | } |
| | | // 按 ID 或 code 匹配:存在则更新,不存在则创建(upsert) |
| | | MesMdItemDO existItem = null; |
| | | // 优先按 ID 查找 |
| | | if (syncReqDTO.getMdmItemId() != null) { |
| | | existItem = itemService.getItem(syncReqDTO.getMdmItemId()); |
| | | } |
| | | // 如果按 ID 找不到,再按 code 查找 |
| | | if (existItem == null) { |
| | | existItem = itemService.getItemByCode(syncReqDTO.getCode()); |
| | | } |
| | | Long itemId; |
| | | if (existItem == null) { |
| | | itemId = itemService.createItem(saveReqVO); |