|
@@ -1,5 +1,6 @@
|
|
|
package cn.iocoder.yudao.module.pms.controller.admin.iotlockstock;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
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;
|
|
@@ -9,8 +10,13 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotlockstock.vo.IotLockStockPageReqVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotlockstock.vo.IotLockStockRespVO;
|
|
|
import cn.iocoder.yudao.module.pms.controller.admin.iotlockstock.vo.IotLockStockSaveReqVO;
|
|
|
+import cn.iocoder.yudao.module.pms.convert.iotlockstock.IotLockStockConvert;
|
|
|
+import cn.iocoder.yudao.module.pms.convert.shelves.IotShelvesConvert;
|
|
|
import cn.iocoder.yudao.module.pms.dal.dataobject.iotlockstock.IotLockStockDO;
|
|
|
+import cn.iocoder.yudao.module.pms.dal.dataobject.iotshelves.IotShelvesDO;
|
|
|
import cn.iocoder.yudao.module.pms.service.iotlockstock.IotLockStockService;
|
|
|
+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;
|
|
@@ -23,9 +29,13 @@ 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.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
|
+import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
+import static cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant.IOT_LOCK_STOCK_NOT_EXISTS;
|
|
|
|
|
|
@Tag(name = "管理后台 - PMS 本地 库存")
|
|
|
@RestController
|
|
@@ -35,6 +45,8 @@ public class IotLockStockController {
|
|
|
|
|
|
@Resource
|
|
|
private IotLockStockService iotLockStockService;
|
|
|
+ @Resource
|
|
|
+ private SapOrgApi sapOrgApi;
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
@Operation(summary = "创建PMS 本地 库存")
|
|
@@ -43,6 +55,16 @@ public class IotLockStockController {
|
|
|
return success(iotLockStockService.createIotLockStock(createReqVO));
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/manualWarehouse")
|
|
|
+ @Operation(summary = "手动新增入库")
|
|
|
+ @PreAuthorize("@ss.hasPermission('pms:iot-lock-stock:create')")
|
|
|
+ public CommonResult<Long> manualWarehouse(@Valid @RequestBody List<IotLockStockSaveReqVO> reqVO) {
|
|
|
+ if (CollUtil.isEmpty(reqVO)) {
|
|
|
+ throw exception(IOT_LOCK_STOCK_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ return success(iotLockStockService.manualWarehouse(reqVO));
|
|
|
+ }
|
|
|
+
|
|
|
@PutMapping("/update")
|
|
|
@Operation(summary = "更新PMS 本地 库存")
|
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-lock-stock:update')")
|
|
@@ -74,7 +96,13 @@ public class IotLockStockController {
|
|
|
@PreAuthorize("@ss.hasPermission('pms:iot-lock-stock:query')")
|
|
|
public CommonResult<PageResult<IotLockStockRespVO>> getIotLockStockPage(@Valid IotLockStockPageReqVO pageReqVO) {
|
|
|
PageResult<IotLockStockDO> pageResult = iotLockStockService.getIotLockStockPage(pageReqVO);
|
|
|
- return success(BeanUtils.toBean(pageResult, IotLockStockRespVO.class));
|
|
|
+ // 拼接 工厂 成本中心 库存地点
|
|
|
+ Map<Long, SapOrgRespDTO> factoryMap = sapOrgApi.getSapOrgMap(
|
|
|
+ convertList(pageResult.getList(), IotLockStockDO::getFactoryId));
|
|
|
+ Map<Long, SapOrgRespDTO> costCenterMap = sapOrgApi.getSapOrgMap(
|
|
|
+ convertList(pageResult.getList(), IotLockStockDO::getCostCenterId));
|
|
|
+ return success(new PageResult<>(IotLockStockConvert.INSTANCE.convertList(pageResult.getList(), factoryMap, costCenterMap),
|
|
|
+ pageResult.getTotal()));
|
|
|
}
|
|
|
|
|
|
@GetMapping("/export-excel")
|