| | |
| | | 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") |
| | |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:import')") |
| | | public CommonResult<MdmItemImportRespVO> importExcel(@RequestParam("file") MultipartFile file, |
| | | @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception { |
| | | List<MdmItemImportExcelVO> list = ExcelUtils.read(file, MdmItemImportExcelVO.class); |
| | | List<MdmItemImportExcelVO> list; |
| | | try { |
| | | list = ExcelUtils.read(file, MdmItemImportExcelVO.class); |
| | | } catch (cn.idev.excel.exception.ExcelDataConvertException e) { |
| | | int row = e.getRowIndex() == null ? 0 : e.getRowIndex() + 1; |
| | | int col = e.getColumnIndex() == null ? 0 : e.getColumnIndex() + 1; |
| | | String cellVal = e.getCellData() == null ? "" : String.valueOf(e.getCellData().getStringValue()); |
| | | throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400, |
| | | "Excel 第 " + row + " 行第 " + col + " 列数据『" + cellVal + "』格式不正确,请检查该列内容(例如“状态”请填 0/1 或 启用/停用)"); |
| | | } catch (Exception e) { |
| | | throw new cn.iocoder.yudao.framework.common.exception.ServiceException(400, |
| | | "Excel 解析失败:" + e.getMessage() + ",请使用系统“下载导入模板”并按模板填写。"); |
| | | } |
| | | return success(itemService.importItemList(list, updateSupport)); |
| | | } |
| | | |
| | | } |
| | | } |