|
@@ -1,95 +1,113 @@
|
|
|
-package cn.iocoder.yudao.module.iscs.controller.admin.materials;
|
|
|
|
|
-
|
|
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
|
|
-import jakarta.annotation.Resource;
|
|
|
|
|
-import org.springframework.validation.annotation.Validated;
|
|
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
-import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
-
|
|
|
|
|
-import jakarta.validation.constraints.*;
|
|
|
|
|
-import jakarta.validation.*;
|
|
|
|
|
-import jakarta.servlet.http.*;
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
-import java.io.IOException;
|
|
|
|
|
-
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
-import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
|
|
|
-import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
-
|
|
|
|
|
-import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
-
|
|
|
|
|
-import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
-import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
|
|
|
|
|
-
|
|
|
|
|
-import cn.iocoder.yudao.module.iscs.controller.admin.materials.vo.*;
|
|
|
|
|
-import cn.iocoder.yudao.module.iscs.dal.dataobject.materials.MaterialsDO;
|
|
|
|
|
-import cn.iocoder.yudao.module.iscs.service.materials.MaterialsService;
|
|
|
|
|
-
|
|
|
|
|
-@Tag(name = "管理后台 - 物资")
|
|
|
|
|
-@RestController
|
|
|
|
|
-@RequestMapping("/iscs/materials")
|
|
|
|
|
-@Validated
|
|
|
|
|
-public class MaterialsController {
|
|
|
|
|
-
|
|
|
|
|
- @Resource
|
|
|
|
|
- private MaterialsService materialsService;
|
|
|
|
|
-
|
|
|
|
|
- @PostMapping("/insertMaterials")
|
|
|
|
|
- @Operation(summary = "创建物资")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:materials:create')")
|
|
|
|
|
- public CommonResult<Long> insertMaterials(@Valid @RequestBody MaterialsSaveReqVO createReqVO) {
|
|
|
|
|
- return success(materialsService.createMaterials(createReqVO));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @PutMapping("/updateMaterials")
|
|
|
|
|
- @Operation(summary = "更新物资")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:materials:update')")
|
|
|
|
|
- public CommonResult<Boolean> updateMaterials(@Valid @RequestBody MaterialsSaveReqVO updateReqVO) {
|
|
|
|
|
- materialsService.updateMaterials(updateReqVO);
|
|
|
|
|
- return success(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @DeleteMapping("/deleteMaterialsList")
|
|
|
|
|
- @Parameter(name = "ids", description = "编号", required = true)
|
|
|
|
|
- @Operation(summary = "批量删除物资")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:materials:delete')")
|
|
|
|
|
- public CommonResult<Boolean> deleteMaterialsList(@RequestParam("ids") List<Long> ids) {
|
|
|
|
|
- materialsService.deleteMaterialsListByIds(ids);
|
|
|
|
|
- return success(true);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/selectMaterialsById")
|
|
|
|
|
- @Operation(summary = "获得物资")
|
|
|
|
|
- @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:materials:query')")
|
|
|
|
|
- public CommonResult<MaterialsRespVO> selectMaterialsById(@RequestParam("id") Long id) {
|
|
|
|
|
- MaterialsDO materials = materialsService.getMaterials(id);
|
|
|
|
|
- return success(BeanUtils.toBean(materials, MaterialsRespVO.class));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/getMaterialsPage")
|
|
|
|
|
- @Operation(summary = "获得物资分页")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:materials:query')")
|
|
|
|
|
- public CommonResult<PageResult<MaterialsRespVO>> getMaterialsPage(@Valid MaterialsPageReqVO pageReqVO) {
|
|
|
|
|
- PageResult<MaterialsDO> pageResult = materialsService.getMaterialsPage(pageReqVO);
|
|
|
|
|
- return success(BeanUtils.toBean(pageResult, MaterialsRespVO.class));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @GetMapping("/exportMaterialsExcel")
|
|
|
|
|
- @Operation(summary = "导出物资 Excel")
|
|
|
|
|
- @PreAuthorize("@ss.hasPermission('iscs:materials:export')")
|
|
|
|
|
- @ApiAccessLog(operateType = EXPORT)
|
|
|
|
|
- public void exportMaterialsExcel(@Valid MaterialsPageReqVO pageReqVO,
|
|
|
|
|
- HttpServletResponse response) throws IOException {
|
|
|
|
|
- pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
- List<MaterialsDO> list = materialsService.getMaterialsPage(pageReqVO).getList();
|
|
|
|
|
- // 导出 Excel
|
|
|
|
|
- ExcelUtils.write(response, "物资.xls", "数据", MaterialsRespVO.class,
|
|
|
|
|
- BeanUtils.toBean(list, MaterialsRespVO.class));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
|
|
+package cn.iocoder.yudao.module.iscs.controller.admin.materials;
|
|
|
|
|
+
|
|
|
|
|
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.materials.vo.MaterialBindingVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.materials.vo.MaterialsPageReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.materials.vo.MaterialsRespVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.controller.admin.materials.vo.MaterialsSaveReqVO;
|
|
|
|
|
+import cn.iocoder.yudao.module.iscs.service.materials.MaterialsService;
|
|
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
|
|
+import io.swagger.v3.oas.annotations.Parameters;
|
|
|
|
|
+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.List;
|
|
|
|
|
+
|
|
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.UPDATE;
|
|
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
|
|
+
|
|
|
|
|
+@Tag(name = "管理后台 - 物资")
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/iscs/materials")
|
|
|
|
|
+@Validated
|
|
|
|
|
+public class MaterialsController {
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private MaterialsService materialsService;
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping("/insertMaterials")
|
|
|
|
|
+ @Operation(summary = "创建物资")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:materials:create')")
|
|
|
|
|
+ public CommonResult<Long> insertMaterials(@Valid @RequestBody MaterialsSaveReqVO createReqVO) {
|
|
|
|
|
+ return success(materialsService.createMaterials(createReqVO));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PutMapping("/updateMaterials")
|
|
|
|
|
+ @Operation(summary = "更新物资")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:materials:update')")
|
|
|
|
|
+ public CommonResult<Boolean> updateMaterials(@Valid @RequestBody MaterialsSaveReqVO updateReqVO) {
|
|
|
|
|
+ materialsService.updateMaterials(updateReqVO);
|
|
|
|
|
+ return success(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @DeleteMapping("/deleteMaterialsList")
|
|
|
|
|
+ @Parameter(name = "ids", description = "编号", required = true)
|
|
|
|
|
+ @Operation(summary = "批量删除物资")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:materials:delete')")
|
|
|
|
|
+ public CommonResult<Boolean> deleteMaterialsList(@RequestParam("ids") List<Long> ids) {
|
|
|
|
|
+ materialsService.deleteMaterialsListByIds(ids);
|
|
|
|
|
+ return success(true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/selectMaterialsById")
|
|
|
|
|
+ @Operation(summary = "获得物资")
|
|
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:materials:query')")
|
|
|
|
|
+ public CommonResult<MaterialsRespVO> selectMaterialsById(@RequestParam("id") Long id) {
|
|
|
|
|
+ MaterialsRespVO materials = materialsService.getMaterials(id);
|
|
|
|
|
+ return success(materials);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/getMaterialsPage")
|
|
|
|
|
+ @Operation(summary = "获得物资分页")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:materials:query')")
|
|
|
|
|
+ public CommonResult<PageResult<MaterialsRespVO>> getMaterialsPage(@Valid MaterialsPageReqVO pageReqVO) throws JsonProcessingException {
|
|
|
|
|
+ PageResult<MaterialsRespVO> pageResult = materialsService.getMaterialsPage(pageReqVO);
|
|
|
|
|
+ return success(pageResult);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping("/exportMaterialsExcel")
|
|
|
|
|
+ @Operation(summary = "导出物资 Excel")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermission('iscs:materials:export')")
|
|
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
|
|
+ public void exportMaterialsExcel(@Valid MaterialsPageReqVO pageReqVO,
|
|
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
|
|
+ List<MaterialsRespVO> list = materialsService.getMaterialsPage(pageReqVO).getList();
|
|
|
|
|
+ // 导出 Excel
|
|
|
|
|
+ ExcelUtils.write(response, "物资.xls", "数据", MaterialsRespVO.class, list);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "绑定物资-物资柜绑定物资")
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('iscs:materials:binding')")
|
|
|
|
|
+ @ApiAccessLog(operateType = UPDATE)
|
|
|
|
|
+ @PostMapping("/updateMaterialsBinding")
|
|
|
|
|
+ public CommonResult<Boolean> updateMaterialsBinding(@RequestBody @Parameter(name = "vo", description = "修改数据类,放到body") MaterialBindingVO vo) {
|
|
|
|
|
+ return CommonResult.success(materialsService.updateMaterialsBinding(vo));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Operation(summary = "查询异常还错柜子的物资")
|
|
|
|
|
+ @Parameters({
|
|
|
|
|
+ @Parameter(name = "vo", description = "实体参数")
|
|
|
|
|
+ })
|
|
|
|
|
+ @PreAuthorize("@ss.hasPermi('iscs:materials:list')")
|
|
|
|
|
+ @GetMapping("/getExMaterials")
|
|
|
|
|
+ public CommonResult<List<MaterialsRespVO>> getExMaterials(MaterialBindingVO vo) {
|
|
|
|
|
+ List<MaterialsRespVO> result = materialsService.getExMaterials(vo);
|
|
|
|
|
+ return CommonResult.success(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|