| | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemImportExcelVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemImportReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemImportRespVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemPageReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemRespVO; |
| | | 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.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 io.swagger.v3.oas.annotations.Parameter; |
| | | import io.swagger.v3.oas.annotations.tags.Tag; |
| | | import jakarta.annotation.Resource; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import jakarta.validation.Valid; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:update')") |
| | | public CommonResult<Boolean> updateItemStatus(@RequestBody MdmItemStatusUpdateReqVO reqVO) { |
| | | itemService.updateItemStatus(reqVO.getId(), reqVO.getStatus()); |
| | | return success(true); |
| | | } |
| | | |
| | | @PutMapping("/update-sync") |
| | | @Operation(summary = "更新物料同步状态") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:update')") |
| | | public CommonResult<Boolean> updateItemSync(@Valid @RequestBody MdmItemSyncUpdateReqVO reqVO) { |
| | | itemService.updateItemSync(reqVO.getId(), reqVO.getSync()); |
| | | return success(true); |
| | | } |
| | | |
| | |
| | | return success(respList); |
| | | } |
| | | |
| | | @GetMapping("/get-import-template") |
| | | @Operation(summary = "获得导入物料模板") |
| | | public void importTemplate(HttpServletResponse response) throws IOException { |
| | | // 手动创建导出 demo |
| | | List<MdmItemImportExcelVO> list = Arrays.asList( |
| | | MdmItemImportExcelVO.builder().code("ITEM001").name("示例物料").categoryName("示例分类") |
| | | .specification("").unitMeasureName("个").unitMeasureName2("").unitMeasureRate1(null) |
| | | .unitMeasureName3("").unitMeasureRate2(null).brandName("").barCode("") |
| | | .purchasePrice(null).salesPrice(null).costPrice(null).safetyStock(null) |
| | | .minStock(null).maxStock(null).expiryDay(null).status(0).remark("").build() |
| | | ); |
| | | // 输出 |
| | | ExcelUtils.write(response, "物料导入模板.xls", "物料列表", MdmItemImportExcelVO.class, list); |
| | | } |
| | | |
| | | @PostMapping("/import") |
| | | @Operation(summary = "导入物料") |
| | | @PreAuthorize("@ss.hasPermission('mdm:item:import')") |
| | | public CommonResult<MdmItemImportRespVO> importExcel(@Valid MdmItemImportReqVO importReqVO) |
| | | throws Exception { |
| | | List<MdmItemImportExcelVO> list = ExcelUtils.read(importReqVO.getFile(), MdmItemImportExcelVO.class); |
| | | return success(itemService.importItemList(list, importReqVO)); |
| | | } |
| | | |
| | | /** |
| | | * 填充物料响应 VO 的关联名称(分类、主单位、辅单位、仓库名称) |
| | | */ |