|
|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
package cn.iocoder.yudao.module.erp.controller.admin.warehousearea;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.common.enums.QrcodeBizTypeEnum;
|
|
|
|
|
import cn.iocoder.yudao.module.common.service.qrcordrecord.QrcodeRecordService;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.warehouse.ErpWarehouseRespVO;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpWarehouseDO;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
@ -13,6 +15,7 @@ import io.swagger.v3.oas.annotations.Operation;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
|
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
|
|
@ -25,6 +28,7 @@ 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 static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
|
|
|
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
|
|
|
|
|
|
|
|
|
|
import cn.iocoder.yudao.module.erp.controller.admin.warehousearea.vo.*;
|
|
|
|
|
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
|
|
|
|
|
@ -43,10 +47,13 @@ public class WarehouseAreaController {
|
|
|
|
|
@Resource
|
|
|
|
|
private WarehouseAreaService warehouseAreaService;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private QrcodeRecordService qrcodeService;
|
|
|
|
|
|
|
|
|
|
@PostMapping("/create")
|
|
|
|
|
@Operation(summary = "创建ERP 库区信息")
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('erp:warehouse-area:create')")
|
|
|
|
|
public CommonResult<Long> createWarehouseArea(@Valid @RequestBody WarehouseAreaSaveReqVO createReqVO) {
|
|
|
|
|
public CommonResult<Long> createWarehouseArea(@Valid @RequestBody WarehouseAreaSaveReqVO createReqVO) throws UnsupportedEncodingException {
|
|
|
|
|
return success(warehouseAreaService.createWarehouseArea(createReqVO));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -73,7 +80,9 @@ public class WarehouseAreaController {
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('erp:warehouse-area:query')")
|
|
|
|
|
public CommonResult<WarehouseAreaRespVO> getWarehouseArea(@RequestParam("id") Long id) {
|
|
|
|
|
WarehouseAreaDO warehouseArea = warehouseAreaService.getWarehouseArea(id);
|
|
|
|
|
return success(BeanUtils.toBean(warehouseArea, WarehouseAreaRespVO.class));
|
|
|
|
|
WarehouseAreaRespVO respVO = BeanUtils.toBean(warehouseArea, WarehouseAreaRespVO.class);
|
|
|
|
|
fillQrcodeUrl(respVO, warehouseArea);
|
|
|
|
|
return success(respVO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@GetMapping("/page")
|
|
|
|
|
@ -81,7 +90,9 @@ public class WarehouseAreaController {
|
|
|
|
|
@PreAuthorize("@ss.hasPermission('erp:warehouse-area:query')")
|
|
|
|
|
public CommonResult<PageResult<WarehouseAreaRespVO>> getWarehouseAreaPage(@Valid WarehouseAreaPageReqVO pageReqVO) {
|
|
|
|
|
PageResult<WarehouseAreaDO> pageResult = warehouseAreaService.getWarehouseAreaPage(pageReqVO);
|
|
|
|
|
return success(BeanUtils.toBean(pageResult, WarehouseAreaRespVO.class));
|
|
|
|
|
PageResult<WarehouseAreaRespVO> result = BeanUtils.toBean(pageResult, WarehouseAreaRespVO.class);
|
|
|
|
|
fillQrcodeUrl(result.getList());
|
|
|
|
|
return success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -89,12 +100,30 @@ public class WarehouseAreaController {
|
|
|
|
|
@Operation(summary = "获得库区精简列表", description = "只包含被开启的仓库库区,主要用于前端的下拉选项")
|
|
|
|
|
public CommonResult<List<WarehouseAreaRespVO>> getWarehouseSimpleList(@RequestParam(value = "warehouseId", required = false) Long warehouseId) {
|
|
|
|
|
List<WarehouseAreaDO> list = warehouseAreaService.getWarehouseListByStatusAndWarehouseId(CommonStatusEnum.ENABLE.getStatus(), warehouseId);
|
|
|
|
|
return success(convertList(list, area -> new WarehouseAreaRespVO()
|
|
|
|
|
List<WarehouseAreaRespVO> result = convertList(list, area -> new WarehouseAreaRespVO()
|
|
|
|
|
.setId(area.getId())
|
|
|
|
|
.setWarehouseId(area.getWarehouseId())
|
|
|
|
|
.setAreaCode(area.getAreaCode())
|
|
|
|
|
.setAreaName(area.getAreaName())
|
|
|
|
|
.setStatus(area.getStatus())));
|
|
|
|
|
.setStatus(area.getStatus()));
|
|
|
|
|
fillQrcodeUrl(result);
|
|
|
|
|
return success(result);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillQrcodeUrl(WarehouseAreaRespVO respVO, WarehouseAreaDO warehouseArea) {
|
|
|
|
|
if (respVO == null || warehouseArea == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
respVO.setQrcodeUrl(qrcodeService.selectQrcodeUrlByIdAndCode(
|
|
|
|
|
QrcodeBizTypeEnum.WAREHOUSE_AREA.getCode(), warehouseArea.getId(), warehouseArea.getAreaCode()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillQrcodeUrl(List<WarehouseAreaRespVO> list) {
|
|
|
|
|
Map<Long, String> qrcodeUrlMap = qrcodeService.selectQrcodeUrlMapByBizTypeAndIds(
|
|
|
|
|
QrcodeBizTypeEnum.WAREHOUSE_AREA.getCode(), convertSet(list, WarehouseAreaRespVO::getId));
|
|
|
|
|
for (WarehouseAreaRespVO respVO : list) {
|
|
|
|
|
respVO.setQrcodeUrl(qrcodeUrlMap.get(respVO.getId()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -111,4 +140,11 @@ public class WarehouseAreaController {
|
|
|
|
|
BeanUtils.toBean(list, WarehouseAreaRespVO.class));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/regenerate-code")
|
|
|
|
|
public CommonResult<Boolean> regenerateCode(@RequestParam("id") Long id,
|
|
|
|
|
@RequestParam("code") String code) throws UnsupportedEncodingException {
|
|
|
|
|
warehouseAreaService.regenerateCode(id, code);
|
|
|
|
|
return success(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|