| | |
| | | import org.springframework.validation.annotation.Validated; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.Objects; |
| | | import java.util.Set; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.invalidParamException; |
| | | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public Long createItem(MesMdItemSyncReqDTO syncReqDTO) { |
| | | log.info("[createItem] 同步创建 MES 物料产品,code={}, mdmItemId={}", syncReqDTO.getCode(), syncReqDTO.getMdmItemId()); |
| | | validateSharedId(syncReqDTO); |
| | | MesMdItemSaveReqVO saveReqVO = buildSaveReqVO(syncReqDTO); |
| | | // 使用 MDM 物料 ID 作为 MES 物料 ID |
| | | if (syncReqDTO.getMdmItemId() != null) { |
| | |
| | | @Override |
| | | public void updateItem(MesMdItemSyncReqDTO syncReqDTO) { |
| | | log.info("[updateItem] 同步更新 MES 物料产品,code={}, mdmItemId={}", syncReqDTO.getCode(), syncReqDTO.getMdmItemId()); |
| | | validateSharedId(syncReqDTO); |
| | | MesMdItemSaveReqVO saveReqVO = buildSaveReqVO(syncReqDTO); |
| | | // 使用 MDM 物料 ID 作为 MES 物料 ID |
| | | if (syncReqDTO.getMdmItemId() != null) { |
| | |
| | | // saveBatchConfig(itemId, syncReqDTO); |
| | | } |
| | | |
| | | private void validateSharedId(MesMdItemSyncReqDTO syncReqDTO) { |
| | | if (syncReqDTO.getMdmItemId() == null) { |
| | | return; |
| | | } |
| | | MesMdItemDO existing = itemMapper.selectAnyById(syncReqDTO.getMdmItemId()); |
| | | if (existing != null && !Objects.equals(existing.getCode(), syncReqDTO.getCode()) |
| | | && !Objects.equals(existing.getCode(), syncReqDTO.getPreviousCode())) { |
| | | throw invalidParamException("同步失败:生产物料编号已被其他编码占用,请核对两套物料数据后再操作"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 将同步 DTO 转换为 MES 物料产品 SaveReqVO,并按 code 解析单位/分类 id |
| | | */ |