|
@@ -0,0 +1,111 @@
|
|
|
+package cn.iocoder.yudao.module.pms.controller.admin.iotshelves;
|
|
|
+
|
|
|
+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.common.util.object.BeanUtils;
|
|
|
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotshelves.vo.IotShelvesPageReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotshelves.vo.IotShelvesRespVO;
|
|
|
+import cn.iocoder.yudao.module.pms.controller.admin.iotshelves.vo.IotShelvesSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.convert.shelves.IotShelvesConvert;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotshelves.IotShelvesDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotstoragearea.IotStorageAreaDO;
|
|
|
+import cn.iocoder.yudao.module.pms.service.iotshelves.IotShelvesService;
|
|
|
+import cn.iocoder.yudao.module.pms.service.iotstoragearea.IotStorageAreaService;
|
|
|
+import cn.iocoder.yudao.module.system.api.saporg.SapOrgApi;
|
|
|
+import cn.iocoder.yudao.module.system.api.saporg.dto.SapOrgRespDTO;
|
|
|
+import io.swagger.v3.oas.annotations.Operation;
|
|
|
+import io.swagger.v3.oas.annotations.Parameter;
|
|
|
+import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
+import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.validation.Valid;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
|
|
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
+
|
|
|
+@Tag(name = "管理后台 - PMS 货架")
|
|
|
+@RestController
|
|
|
+@RequestMapping("/pms/iot-shelves")
|
|
|
+@Validated
|
|
|
+public class IotShelvesController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IotShelvesService iotShelvesService;
|
|
|
+ @Resource
|
|
|
+ private SapOrgApi sapOrgApi;
|
|
|
+ @Resource
|
|
|
+ private IotStorageAreaService iotStorageAreaService;
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ @Operation(summary = "创建PMS 货架")
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-shelves:create')")
|
|
|
+ public CommonResult<Long> createIotShelves(@Valid @RequestBody IotShelvesSaveReqVO createReqVO) {
|
|
|
+ return success(iotShelvesService.createIotShelves(createReqVO));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PutMapping("/update")
|
|
|
+ @Operation(summary = "更新PMS 货架")
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-shelves:update')")
|
|
|
+ public CommonResult<Boolean> updateIotShelves(@Valid @RequestBody IotShelvesSaveReqVO updateReqVO) {
|
|
|
+ iotShelvesService.updateIotShelves(updateReqVO);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @DeleteMapping("/delete")
|
|
|
+ @Operation(summary = "删除PMS 货架")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true)
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-shelves:delete')")
|
|
|
+ public CommonResult<Boolean> deleteIotShelves(@RequestParam("id") Long id) {
|
|
|
+ iotShelvesService.deleteIotShelves(id);
|
|
|
+ return success(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/get")
|
|
|
+ @Operation(summary = "获得PMS 货架")
|
|
|
+ @Parameter(name = "id", description = "编号", required = true, example = "1024")
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-shelves:query')")
|
|
|
+ public CommonResult<IotShelvesRespVO> getIotShelves(@RequestParam("id") Long id) {
|
|
|
+ IotShelvesDO iotShelves = iotShelvesService.getIotShelves(id);
|
|
|
+ return success(BeanUtils.toBean(iotShelves, IotShelvesRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/page")
|
|
|
+ @Operation(summary = "获得PMS 货架分页")
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-shelves:query')")
|
|
|
+ public CommonResult<PageResult<IotShelvesRespVO>> getIotShelvesPage(@Valid IotShelvesPageReqVO pageReqVO) {
|
|
|
+ PageResult<IotShelvesDO> pageResult = iotShelvesService.getIotShelvesPage(pageReqVO);
|
|
|
+ // 拼接库存地点数据
|
|
|
+ Map<Long, SapOrgRespDTO> storageLocationMap = sapOrgApi.getSapOrgMap(
|
|
|
+ convertList(pageResult.getList(), IotShelvesDO::getStorageLocationId));
|
|
|
+ // 拼接库区数据
|
|
|
+ Map<Long, IotStorageAreaDO> storageAreaMap = iotStorageAreaService.getStorageAreaMap(
|
|
|
+ convertList(pageResult.getList(), IotShelvesDO::getStorageAreaId));
|
|
|
+ return success(new PageResult<>(IotShelvesConvert.INSTANCE.convertList(pageResult.getList(), storageLocationMap, storageAreaMap),
|
|
|
+ pageResult.getTotal()));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export-excel")
|
|
|
+ @Operation(summary = "导出PMS 货架 Excel")
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-shelves:export')")
|
|
|
+ @ApiAccessLog(operateType = EXPORT)
|
|
|
+ public void exportIotShelvesExcel(@Valid IotShelvesPageReqVO pageReqVO,
|
|
|
+ HttpServletResponse response) throws IOException {
|
|
|
+ pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
|
|
+ List<IotShelvesDO> list = iotShelvesService.getIotShelvesPage(pageReqVO).getList();
|
|
|
+ // 导出 Excel
|
|
|
+ ExcelUtils.write(response, "PMS 货架.xls", "数据", IotShelvesRespVO.class,
|
|
|
+ BeanUtils.toBean(list, IotShelvesRespVO.class));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|