| | |
| | | @AllArgsConstructor |
| | | public enum MdmItemTypeEnum { |
| | | |
| | | MATERIAL(1, "ç©æ"), |
| | | PRODUCT(2, "产å"), |
| | | SEMI_FINISHED(3, "åæå"); |
| | | RAW_MATERIAL(1, "åææ"), |
| | | SEMI_FINISHED(2, "åæå"), |
| | | FINISHED_PRODUCT(3, "æå"), |
| | | AUXILIARY(4, "è¾
æ"), |
| | | OTHER(5, "å
¶ä»"); |
| | | |
| | | /** |
| | | * ç±»åç¼ç |
| | |
| | | if (existingItem != null) { |
| | | // æ´æ° |
| | | item.setId(existingItem.getId()); |
| | | // MES åæ¥è¯·æ±æä¸ç»´æ¤ææ¯åæ°ï¼é¿å
åæ¥æ¶æ MDM 已维æ¤çåæ°æ¸
空ã |
| | | if (syncReqDTO.getTechnicalParameters() == null) { |
| | | item.setTechnicalParameters(existingItem.getTechnicalParameters()); |
| | | } |
| | | itemMapper.updateById(item); |
| | | itemId = existingItem.getId(); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | @Schema(description = "è§æ ¼åå·", example = "M8*20") |
| | | private String specification; |
| | | |
| | | @Schema(description = "ææ¯åæ°") |
| | | private String technicalParameters; |
| | | |
| | | @Schema(description = "ç©æåç±»ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | private Long categoryId; |
| | | |
| | |
| | | @Schema(description = "夿³¨", example = "夿³¨ä¿¡æ¯") |
| | | private String remark; |
| | | |
| | | } |
| | | } |
| | |
| | | @Schema(description = "è§æ ¼åå·", example = "M8*20") |
| | | private String specification; |
| | | |
| | | @Schema(description = "ææ¯åæ°") |
| | | private String technicalParameters; |
| | | |
| | | @Schema(description = "ç©æåç±»ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | private Long categoryId; |
| | | |
| | |
| | | @Schema(description = "夿³¨", example = "夿³¨ä¿¡æ¯") |
| | | private String remark; |
| | | |
| | | } |
| | | } |
| | |
| | | @Schema(description = "è§æ ¼åå·", example = "M6*20") |
| | | private String specification; |
| | | |
| | | @Schema(description = "ææ¯åæ°") |
| | | private String technicalParameters; |
| | | |
| | | @Schema(description = "ç©æç±»åï¼1åæ, 2åæå, 3æå, 4è¾
æ", example = "1") |
| | | private Long itemType; |
| | | |
| | |
| | | @Schema(description = "è´¨éç¶æå¿
å¡«", example = "false") |
| | | private Boolean qualityStatusFlag; |
| | | |
| | | } |
| | | } |
| | |
| | | @Schema(description = "è§æ ¼åå·", example = "M8*20") |
| | | private String specification; |
| | | |
| | | @Schema(description = "ææ¯åæ°") |
| | | private String technicalParameters; |
| | | |
| | | @Schema(description = "ç©æåç±»ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | private Long categoryId; |
| | | |
| | |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemSaveReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemStatusUpdateReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemSyncUpdateReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemTechnicalFileCreateReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemTechnicalFileRespVO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.category.MdmItemCategoryDO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemBatchConfigDO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemDO; |
| | |
| | | import cn.iocoder.yudao.module.mdm.service.category.MdmItemCategoryService; |
| | | import cn.iocoder.yudao.module.mdm.service.item.MdmItemBatchConfigService; |
| | | import cn.iocoder.yudao.module.mdm.service.item.MdmItemService; |
| | | import cn.iocoder.yudao.module.mdm.service.item.MdmItemTechnicalFileService; |
| | | import cn.iocoder.yudao.module.mdm.service.unit.MdmUnitMeasureService; |
| | | import cn.iocoder.yudao.module.mes.api.item.MesMdItemApi; |
| | | import cn.iocoder.yudao.module.mes.api.wm.warehouse.MesWmWarehouseApi; |
| | |
| | | @Resource |
| | | private MdmItemBatchConfigService itemBatchConfigService; |
| | | |
| | | @Resource |
| | | private MdmItemTechnicalFileService technicalFileService; |
| | | |
| | | @PostMapping("/create") |
| | | @Operation(summary = "åå»ºç©æ") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:create')") |
| | |
| | | public CommonResult<Boolean> updateItemSync(@Valid @RequestBody MdmItemSyncUpdateReqVO reqVO) { |
| | | itemService.updateItemSync(reqVO.getId(), reqVO.getSync()); |
| | | return success(true); |
| | | } |
| | | |
| | | @PostMapping("/technical-file/create") |
| | | @Operation(summary = "ä¸ä¼ äº§åææ¯æä»¶çæ¬") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:update')") |
| | | public CommonResult<Long> createTechnicalFile(@Valid @RequestBody MdmItemTechnicalFileCreateReqVO reqVO) { |
| | | return success(technicalFileService.createTechnicalFile(reqVO)); |
| | | } |
| | | |
| | | @GetMapping("/technical-file/list") |
| | | @Operation(summary = "è·å¾äº§åææ¯æä»¶åå²") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:query')") |
| | | public CommonResult<List<MdmItemTechnicalFileRespVO>> getTechnicalFileList(@RequestParam("itemId") Long itemId) { |
| | | return success(technicalFileService.getTechnicalFileList(itemId)); |
| | | } |
| | | |
| | | @DeleteMapping("/delete") |
| | |
| | | return success(itemService.importItemList(list, updateSupport)); |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | @Data |
| | | public class MdmItemExcelVO { |
| | | |
| | | @ExcelProperty("ç©æç¼ç ") |
| | | @ExcelProperty("产åç¼å·") |
| | | private String code; |
| | | |
| | | @ExcelProperty("ç©æåç§°") |
| | |
| | | @ExcelProperty("è§æ ¼åå·") |
| | | private String specification; |
| | | |
| | | @ExcelProperty("ç©æç±»å") |
| | | @ExcelProperty("ææ¯åæ°") |
| | | private String technicalParameters; |
| | | |
| | | @ExcelProperty("产åç±»å") |
| | | private String itemTypeName; |
| | | |
| | | @ExcelProperty("ç©æåç±»") |
| | |
| | | @NoArgsConstructor |
| | | public class MdmItemImportExcelVO { |
| | | |
| | | @ExcelProperty("ç©æç¼ç ") |
| | | @ExcelProperty("产åç¼å·ï¼ä¿®æ¹æ¶ç¨äºå¹é
ï¼æ°å¢æ¶èªå¨çæï¼") |
| | | private String code; |
| | | |
| | | @ExcelProperty("ç©æåç§°") |
| | |
| | | @ExcelProperty("è§æ ¼åå·") |
| | | private String specification; |
| | | |
| | | @ExcelProperty("ææ¯åæ°") |
| | | private String technicalParameters; |
| | | |
| | | @ExcelProperty("产åç±»åï¼1åææ 2åæå 3æå 4è¾
æ 5å
¶ä»ï¼") |
| | | private Integer itemType; |
| | | |
| | | @ExcelProperty("ç©æåç±»ç¼ç ") |
| | | private String categoryCode; |
| | | |
| | |
| | | @Schema(description = "è§æ ¼åå·", example = "M8*20") |
| | | private String specification; |
| | | |
| | | @Schema(description = "ææ¯åæ°") |
| | | private String technicalParameters; |
| | | |
| | | @Schema(description = "ç©æåç±»ç¼å·", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | private Long categoryId; |
| | | |
| | |
| | | @Schema(description = "å建æ¶é´", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | private LocalDateTime createTime; |
| | | |
| | | } |
| | | } |
| | |
| | | @Schema(description = "ç©æç¼å·", example = "1") |
| | | private Long id; |
| | | |
| | | @Schema(description = "ç©æç¼ç ", requiredMode = Schema.RequiredMode.REQUIRED, example = "ITEM001") |
| | | @Schema(description = "ç©æç¼ç ï¼ç±ç³»ç»èªå¨çæï¼ä¿®æ¹æ¶å¿½ç¥åç«¯ä¼ å
¥å¼ï¼", example = "100100001") |
| | | private String code; |
| | | |
| | | @Schema(description = "ç©æåç§°", requiredMode = Schema.RequiredMode.REQUIRED, example = "èºä¸") |
| | |
| | | |
| | | @Schema(description = "è§æ ¼åå·", example = "M8*20") |
| | | private String specification; |
| | | |
| | | @Schema(description = "ææ¯åæ°") |
| | | private String technicalParameters; |
| | | |
| | | @Schema(description = "ç©æåç±»ç¼å·ï¼å
³è MES ç©æåç±» mes_md_item_typeï¼", example = "1") |
| | | private Long categoryId; |
| | |
| | | @Schema(description = "é»è®¤ä»åºç¼ç ", example = "WH001") |
| | | private String warehouseCode; |
| | | |
| | | @Schema(description = "ç©æç±»å", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | @Schema(description = "产åç±»åï¼1åææ 2åæå 3æå 4è¾
æ 5å
¶ä»", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| | | private Integer itemType; |
| | | |
| | | @Schema(description = "ç¶æ", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") |
| | |
| | | |
| | | private Long mdmItemId; |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.controller.admin.item.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import jakarta.validation.constraints.NotNull; |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class MdmItemTechnicalFileCreateReqVO { |
| | | |
| | | @NotNull |
| | | @Schema(description = "产åID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | private Long itemId; |
| | | |
| | | @NotNull |
| | | @Schema(description = "å·²ä¸ä¼ ç storage blob ID", requiredMode = Schema.RequiredMode.REQUIRED) |
| | | private Long blobId; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.controller.admin.item.vo; |
| | | |
| | | import io.swagger.v3.oas.annotations.media.Schema; |
| | | import lombok.Data; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | @Data |
| | | public class MdmItemTechnicalFileRespVO { |
| | | private Long id; |
| | | private Long itemId; |
| | | private Long blobId; |
| | | private Integer versionNo; |
| | | private String fileName; |
| | | private String previewURL; |
| | | private String downloadURL; |
| | | private LocalDateTime createTime; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.dal.dataobject.item; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | |
| | | /** ç©æç¼ç åæ®µæµæ°´ãæ¯ä¸ªåä½åç¼ç¬ç«éå¢ã */ |
| | | @Data |
| | | @TableName("mdm_item_code_sequence") |
| | | public class MdmItemCodeSequenceDO { |
| | | |
| | | @TableId |
| | | private String prefix; |
| | | |
| | | private Integer currentValue; |
| | | } |
| | |
| | | */ |
| | | private String specification; |
| | | |
| | | /** ææ¯åæ° */ |
| | | private String technicalParameters; |
| | | |
| | | /** |
| | | * ç©æåç±»ç¼å· |
| | | * |
| | |
| | | */ |
| | | private String remark; |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.dal.dataobject.item; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| | | import com.baomidou.mybatisplus.annotation.KeySequence; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | @Data |
| | | @EqualsAndHashCode(callSuper = true) |
| | | @TableName("mdm_item_technical_file") |
| | | @KeySequence("mdm_item_technical_file_seq") |
| | | public class MdmItemTechnicalFileDO extends BaseDO { |
| | | |
| | | @TableId |
| | | private Long id; |
| | | private Long itemId; |
| | | private Long storageBlobId; |
| | | private Integer versionNo; |
| | | private String fileName; |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.dal.mysql.item; |
| | | |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemCodeSequenceDO; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Insert; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Select; |
| | | import org.apache.ibatis.annotations.Update; |
| | | |
| | | @Mapper |
| | | public interface MdmItemCodeSequenceMapper extends BaseMapper<MdmItemCodeSequenceDO> { |
| | | |
| | | @Insert("INSERT IGNORE INTO mdm_item_code_sequence(prefix, current_value) VALUES (#{prefix}, 0)") |
| | | void insertIfAbsent(String prefix); |
| | | |
| | | @Select("SELECT current_value FROM mdm_item_code_sequence WHERE prefix = #{prefix} FOR UPDATE") |
| | | Integer selectCurrentValueForUpdate(String prefix); |
| | | |
| | | @Update("UPDATE mdm_item_code_sequence SET current_value = current_value + 1 WHERE prefix = #{prefix}") |
| | | int increment(String prefix); |
| | | |
| | | @Update("UPDATE mdm_item_code_sequence SET current_value = #{value} WHERE prefix = #{prefix}") |
| | | int updateCurrentValue(@org.apache.ibatis.annotations.Param("prefix") String prefix, |
| | | @org.apache.ibatis.annotations.Param("value") Integer value); |
| | | } |
| | |
| | | @Mapper |
| | | public interface MdmItemMapper extends BaseMapperX<MdmItemDO> { |
| | | |
| | | @org.apache.ibatis.annotations.Select("SELECT COALESCE(MAX(CAST(SUBSTRING(code, 5) AS UNSIGNED)), 0) FROM mdm_item WHERE deleted = 0 AND code LIKE CONCAT(#{prefix}, '%')") |
| | | Integer selectMaxSequenceByPrefix(@Param("prefix") String prefix); |
| | | |
| | | default PageResult<MdmItemDO> selectPage(MdmItemPageReqVO reqVO, Collection<Long> categoryIds) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<MdmItemDO>() |
| | | .likeIfPresent(MdmItemDO::getCode, reqVO.getCode()) |
| | |
| | | */ |
| | | List<Map<String, Object>> selectItemReferenceCount(@Param("itemId") Long itemId); |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.dal.mysql.item; |
| | | |
| | | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemTechnicalFileDO; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | public interface MdmItemTechnicalFileMapper extends BaseMapperX<MdmItemTechnicalFileDO> { |
| | | |
| | | default List<MdmItemTechnicalFileDO> selectListByItemId(Long itemId) { |
| | | return selectList(new LambdaQueryWrapper<MdmItemTechnicalFileDO>() |
| | | .eq(MdmItemTechnicalFileDO::getItemId, itemId) |
| | | .orderByDesc(MdmItemTechnicalFileDO::getVersionNo)); |
| | | } |
| | | |
| | | default Integer selectMaxVersionNo(Long itemId) { |
| | | MdmItemTechnicalFileDO row = selectOne(new LambdaQueryWrapper<MdmItemTechnicalFileDO>() |
| | | .eq(MdmItemTechnicalFileDO::getItemId, itemId) |
| | | .orderByDesc(MdmItemTechnicalFileDO::getVersionNo) |
| | | .last("LIMIT 1")); |
| | | return row == null || row.getVersionNo() == null ? 0 : row.getVersionNo(); |
| | | } |
| | | } |
| | |
| | | ErrorCode MDM_ITEM_SKU_CODE_DUPLICATE = new ErrorCode(1_050_006, "SKUç¼ç å·²åå¨"); |
| | | ErrorCode MDM_ITEM_EXISTS_REFERENCE = new ErrorCode(1_050_007, "ç©æå·²è¢«ä¸å¡å¼ç¨ï¼æ æ³å é¤"); |
| | | ErrorCode MDM_ITEM_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_050_008, "导å
¥çç©ææ°æ®ä¸è½ä¸ºç©º"); |
| | | ErrorCode MDM_ITEM_TYPE_INVALID = new ErrorCode(1_050_009, "产åç±»åæ æ"); |
| | | ErrorCode MDM_ITEM_CODE_SEQUENCE_EXHAUSTED = new ErrorCode(1_050_010, "产åç¼å·æµæ°´å·å·²è¶
è¿äºä½"); |
| | | |
| | | // ========== ç©æåç±»ç¸å
³ 1-050-051 ~ 1-050-100 ========== |
| | | ErrorCode MDM_ITEM_CATEGORY_NOT_EXISTS = new ErrorCode(1_050_051, "ç©æåç±»ä¸åå¨"); |
| | |
| | | ErrorCode MDM_WAREHOUSE_NAME_DUPLICATE = new ErrorCode(1_050_203, "ä»åºåç§°å·²åå¨"); |
| | | ErrorCode MDM_WAREHOUSE_IS_DISABLE = new ErrorCode(1_050_204, "ä»åºå·²ç¦ç¨"); |
| | | |
| | | } |
| | | } |
| | |
| | | @AllArgsConstructor |
| | | public enum MdmItemTypeEnum { |
| | | |
| | | MATERIAL(1, "ç©æ"), |
| | | PRODUCT(2, "产å"), |
| | | SEMI_FINISHED(3, "åæå"); |
| | | RAW_MATERIAL(1, "åææ"), |
| | | SEMI_FINISHED(2, "åæå"), |
| | | FINISHED_PRODUCT(3, "æå"), |
| | | AUXILIARY(4, "è¾
æ"), |
| | | OTHER(5, "å
¶ä»"); |
| | | |
| | | /** |
| | | * ç±»åç¼ç |
| | |
| | | return null; |
| | | } |
| | | |
| | | } |
| | | } |
| | |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.unit.MdmUnitMeasureDO; |
| | | import cn.iocoder.yudao.module.mdm.dal.mysql.item.MdmItemBatchConfigMapper; |
| | | import cn.iocoder.yudao.module.mdm.dal.mysql.item.MdmItemMapper; |
| | | import cn.iocoder.yudao.module.mdm.dal.mysql.item.MdmItemCodeSequenceMapper; |
| | | import cn.iocoder.yudao.module.mdm.dal.mysql.unit.MdmUnitMeasureMapper; |
| | | import cn.iocoder.yudao.module.mdm.service.brand.MdmBrandService; |
| | | import cn.iocoder.yudao.module.mdm.service.category.MdmItemCategoryService; |
| | |
| | | private MdmItemMapper itemMapper; |
| | | |
| | | @Resource |
| | | private MdmItemCodeSequenceMapper itemCodeSequenceMapper; |
| | | |
| | | @Resource |
| | | private MdmItemCategoryService itemCategoryService; |
| | | @Resource |
| | | private MdmUnitMeasureService unitMeasureService; |
| | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createItem(MdmItemSaveReqVO createReqVO) { |
| | | createReqVO.setCode(generateItemCode(createReqVO.getItemType())); |
| | | // æ ¡éªæ°æ® |
| | | validateItemSaveData(createReqVO); |
| | | |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void updateItem(MdmItemSaveReqVO updateReqVO) { |
| | | // æ ¡éªåå¨ |
| | | validateItemExists(updateReqVO.getId()); |
| | | MdmItemDO existingItem = validateItemExists(updateReqVO.getId()); |
| | | // ç¼å·ç±ç³»ç»çæï¼ä¿®æ¹äº§åæ¶ä¿æåç¼å·ä¸åã |
| | | updateReqVO.setCode(existingItem.getCode()); |
| | | updateReqVO.setItemType(existingItem.getItemType()); |
| | | // æ ¡éªæ°æ® |
| | | validateItemSaveData(updateReqVO); |
| | | |
| | |
| | | } |
| | | |
| | | private void validateItemSaveData(MdmItemSaveReqVO reqVO) { |
| | | if (reqVO.getItemType() == null || reqVO.getItemType() < 1 || reqVO.getItemType() > 5) { |
| | | throw exception(MDM_ITEM_TYPE_INVALID); |
| | | } |
| | | // æ ¡éªç©æç¼ç çå¯ä¸æ§ |
| | | validateItemCodeUnique(reqVO.getId(), reqVO.getCode()); |
| | | } |
| | | |
| | | /** çæåä½ç±»ååç¼ + äºä½æµæ°´å·ï¼å
±ä¹ä½ãæµæ°´è¡å¨äºå¡å
å éï¼é¿å
å¹¶åéå¤ã */ |
| | | private String generateItemCode(Integer itemType) { |
| | | String prefix = switch (itemType == null ? 0 : itemType) { |
| | | case 1 -> "1001"; |
| | | case 2 -> "1002"; |
| | | case 3 -> "1003"; |
| | | case 4 -> "1004"; |
| | | case 5 -> "1005"; |
| | | default -> throw exception(MDM_ITEM_TYPE_INVALID); |
| | | }; |
| | | itemCodeSequenceMapper.insertIfAbsent(prefix); |
| | | Integer current = itemCodeSequenceMapper.selectCurrentValueForUpdate(prefix); |
| | | if (current == null) { |
| | | current = itemMapper.selectMaxSequenceByPrefix(prefix); |
| | | itemCodeSequenceMapper.insertIfAbsent(prefix); |
| | | itemCodeSequenceMapper.updateCurrentValue(prefix, current); |
| | | } |
| | | int maxExisting = itemMapper.selectMaxSequenceByPrefix(prefix); |
| | | if (current < maxExisting) { |
| | | current = maxExisting; |
| | | itemCodeSequenceMapper.updateCurrentValue(prefix, current); |
| | | } |
| | | if (current >= 99_999) { |
| | | throw exception(MDM_ITEM_CODE_SEQUENCE_EXHAUSTED); |
| | | } |
| | | itemCodeSequenceMapper.increment(prefix); |
| | | int next = current + 1; |
| | | return prefix + String.format("%05d", next); |
| | | } |
| | | |
| | | /** |
| | |
| | | TransactionTemplate importTxTemplate = new TransactionTemplate(transactionManager); |
| | | for (MdmItemImportExcelVO importVO : importList) { |
| | | // 2.1 åºç¡æ ¡éª |
| | | if (StrUtil.isBlank(importVO.getCode()) || StrUtil.isBlank(importVO.getName())) { |
| | | respVO.getFailureList().put(buildFailKey(importVO), "ç©æç¼ç åç©æåç§°ä¸è½ä¸ºç©º"); |
| | | if (StrUtil.isBlank(importVO.getName())) { |
| | | respVO.getFailureList().put(buildFailKey(importVO), "ç©æåç§°ä¸è½ä¸ºç©º"); |
| | | continue; |
| | | } |
| | | // 2.2 è§£æåç±» |
| | |
| | | |
| | | // 2.6 ç»è£
SaveReqVOï¼å¤ç¨ create/update é»è¾ï¼ |
| | | MdmItemSaveReqVO saveReqVO = new MdmItemSaveReqVO(); |
| | | // æ°å¢æ¶å¿½ç¥ Excel ä¸çç©æç¼ç ï¼ç± MDM æäº§åç±»åèªå¨çæã |
| | | saveReqVO.setCode(importVO.getCode()); |
| | | saveReqVO.setName(importVO.getName()); |
| | | saveReqVO.setBarCode(importVO.getBarCode()); |
| | | saveReqVO.setSpecification(importVO.getSpecification()); |
| | | saveReqVO.setTechnicalParameters(importVO.getTechnicalParameters()); |
| | | saveReqVO.setCategoryId(categoryId); |
| | | saveReqVO.setUnitMeasureId(unitMeasureId); |
| | | saveReqVO.setUnitMeasureId2(unitMeasureId2); |
| | |
| | | saveReqVO.setStatus(importVO.getStatus() != null ? importVO.getStatus() : cn.iocoder.yudao.framework.common.enums.CommonStatusEnum.ENABLE.getStatus()); |
| | | saveReqVO.setSyncMes(importVO.getSyncMes() != null ? importVO.getSyncMes() : false); |
| | | saveReqVO.setRemark(importVO.getRemark()); |
| | | saveReqVO.setItemType(1); // é»è®¤ç©æç±»åï¼ç©æ |
| | | saveReqVO.setItemType(importVO.getItemType() != null ? importVO.getItemType() : 1); // æªæä¾ç±»åæ¶é»è®¤ä¸ºåææ |
| | | |
| | | // 2.7 å·²åå¨ï¼æç¼ç å¤æï¼ |
| | | MdmItemDO existByCode = itemMapper.selectByCode(importVO.getCode()); |
| | | MdmItemDO existByCode = StrUtil.isBlank(importVO.getCode()) ? null : itemMapper.selectByCode(importVO.getCode()); |
| | | if (existByCode != null && !Boolean.TRUE.equals(isUpdateSupport)) { |
| | | respVO.getFailureList().put(buildFailKey(importVO), "ç©æç¼ç å·²åå¨"); |
| | | continue; |
| | |
| | | StrUtil.blankToDefault(importVO.getName(), "ï¼åç§°åç¼ç 为空çè¡ï¼")); |
| | | } |
| | | |
| | | } |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.service.item; |
| | | |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemTechnicalFileCreateReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemTechnicalFileRespVO; |
| | | |
| | | import java.util.List; |
| | | |
| | | public interface MdmItemTechnicalFileService { |
| | | Long createTechnicalFile(MdmItemTechnicalFileCreateReqVO reqVO); |
| | | List<MdmItemTechnicalFileRespVO> getTechnicalFileList(Long itemId); |
| | | } |
| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.service.item; |
| | | |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemTechnicalFileCreateReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemTechnicalFileRespVO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemTechnicalFileDO; |
| | | import cn.iocoder.yudao.module.mdm.dal.mysql.item.MdmItemTechnicalFileMapper; |
| | | import cn.iocoder.yudao.module.system.api.storage.StorageAttachmentApi; |
| | | import cn.iocoder.yudao.module.system.api.storage.dto.StorageBlobRespDTO; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.iocoder.yudao.module.mdm.enums.ErrorCodeConstants.MDM_ITEM_NOT_EXISTS; |
| | | |
| | | @Service |
| | | public class MdmItemTechnicalFileServiceImpl implements MdmItemTechnicalFileService { |
| | | |
| | | private static final String RECORD_TYPE = "mdm_item_technical_file"; |
| | | |
| | | private final MdmItemTechnicalFileMapper mapper; |
| | | private final MdmItemService itemService; |
| | | private final StorageAttachmentApi storageAttachmentApi; |
| | | |
| | | public MdmItemTechnicalFileServiceImpl(MdmItemTechnicalFileMapper mapper, |
| | | MdmItemService itemService, |
| | | StorageAttachmentApi storageAttachmentApi) { |
| | | this.mapper = mapper; |
| | | this.itemService = itemService; |
| | | this.storageAttachmentApi = storageAttachmentApi; |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Long createTechnicalFile(MdmItemTechnicalFileCreateReqVO reqVO) { |
| | | if (itemService.getItem(reqVO.getItemId()) == null) { |
| | | throw exception(MDM_ITEM_NOT_EXISTS); |
| | | } |
| | | int version = mapper.selectMaxVersionNo(reqVO.getItemId()) + 1; |
| | | // è®°å½ ID å¿
é¡»ä¸éä»¶å
³ç³»è®°å½ ID ä¸è´ï¼å æ¤å
æå
¥çæ¬è®°å½ï¼åç»å®éä»¶ã |
| | | MdmItemTechnicalFileDO file = new MdmItemTechnicalFileDO(); |
| | | file.setItemId(reqVO.getItemId()); |
| | | file.setStorageBlobId(reqVO.getBlobId()); |
| | | file.setVersionNo(version); |
| | | mapper.insert(file); |
| | | storageAttachmentApi.bindAttachments("file", RECORD_TYPE, file.getId(), |
| | | Collections.singletonList(reqVO.getBlobId())); |
| | | return file.getId(); |
| | | } |
| | | |
| | | @Override |
| | | public List<MdmItemTechnicalFileRespVO> getTechnicalFileList(Long itemId) { |
| | | return mapper.selectListByItemId(itemId).stream().map(file -> { |
| | | MdmItemTechnicalFileRespVO resp = BeanUtils.toBean(file, MdmItemTechnicalFileRespVO.class); |
| | | resp.setBlobId(file.getStorageBlobId()); |
| | | List<StorageBlobRespDTO> blobs = storageAttachmentApi.listAttachments(RECORD_TYPE, file.getId()); |
| | | if (blobs != null && !blobs.isEmpty()) { |
| | | StorageBlobRespDTO blob = blobs.get(0); |
| | | resp.setFileName(blob.getName()); |
| | | resp.setPreviewURL(blob.getPreviewURL()); |
| | | resp.setDownloadURL(blob.getDownloadURL()); |
| | | } |
| | | return resp; |
| | | }).toList(); |
| | | } |
| | | } |
| | |
| | | // ===== MES ===== |
| | | MES_PD_DOCUMENT("mes_pd_document", "MES è®¾è®¡èµæ"), |
| | | |
| | | MDM_ITEM_TECHNICAL_FILE("mdm_item_technical_file", "MDM ç©æææ¯æä»¶"), |
| | | |
| | | // ===== SRM ===== |
| | | SRM_SUPPLIER_CERTIFICATE("srm_supplier_certificate", "SRM ä¾åºåèµè´¨è¯ä¹¦"), |
| | | SRM_TENDER_PROJECT("srm_tender_project", "SRM ææ é¡¹ç®"), |