feat: 新增备货区域管理接口(任务3)
This commit is contained in:
@@ -40,4 +40,9 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode RAW_FOIL_WORK_ORDER_STATUS_NOT_EXECUTION = new ErrorCode(19, "生箔工序工单状态不为执行中");
|
ErrorCode RAW_FOIL_WORK_ORDER_STATUS_NOT_EXECUTION = new ErrorCode(19, "生箔工序工单状态不为执行中");
|
||||||
ErrorCode RAW_FOIL_WEIGHING_POSITION_NOT_EXISTS = new ErrorCode(20, "称重位不存在");
|
ErrorCode RAW_FOIL_WEIGHING_POSITION_NOT_EXISTS = new ErrorCode(20, "称重位不存在");
|
||||||
ErrorCode RAW_FOIL_CONTAINER_NOT_ON_WEIGHING_POSITION = new ErrorCode(21, "母卷不在称重位");
|
ErrorCode RAW_FOIL_CONTAINER_NOT_ON_WEIGHING_POSITION = new ErrorCode(21, "母卷不在称重位");
|
||||||
|
|
||||||
|
// ========== 备货区域 ==========
|
||||||
|
ErrorCode STOCKING_IVT_NOT_EXISTS = new ErrorCode(22, "备货区域点位不存在");
|
||||||
|
ErrorCode PAPER_VEHICLE_POSITION_DUPLICATED = new ErrorCode(23, "托盘格位重复:{}");
|
||||||
|
ErrorCode PAPER_VEHICLE_POSITION_OUT_OF_RANGE = new ErrorCode(24, "托盘格位超出5×5范围:{}");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
package cn.code.nl.module.lms.controller.admin.stockingivt;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||||
|
import cn.code.nl.framework.common.pojo.PageResult;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.PaperVehicleInventoryRespVO;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.StockingIvtPageReqVO;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.StockingIvtRespVO;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.StockingIvtUpdateReqVO;
|
||||||
|
import cn.code.nl.module.lms.service.stockingivt.StockingIvtService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.code.nl.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备货区域管理接口。
|
||||||
|
*/
|
||||||
|
@Tag(name = "管理后台 - 备货区域")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/lms/stocking-ivt")
|
||||||
|
@Validated
|
||||||
|
public class StockingIvtController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StockingIvtService stockingIvtService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询备货区域。
|
||||||
|
*/
|
||||||
|
@GetMapping("/page")
|
||||||
|
@Operation(summary = "获得备货区域分页")
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:stocking-ivt:query')")
|
||||||
|
public CommonResult<PageResult<StockingIvtRespVO>> getStockingIvtPage(
|
||||||
|
@Valid StockingIvtPageReqVO pageReqVO) {
|
||||||
|
return success(stockingIvtService.getStockingIvtPage(pageReqVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询备货区域详情。
|
||||||
|
*/
|
||||||
|
@GetMapping("/get")
|
||||||
|
@Operation(summary = "获得备货区域详情")
|
||||||
|
@Parameter(name = "ivtId", description = "库存记录标识", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:stocking-ivt:query')")
|
||||||
|
public CommonResult<StockingIvtRespVO> getStockingIvt(
|
||||||
|
@RequestParam("ivtId") @NotNull Long ivtId) {
|
||||||
|
return success(stockingIvtService.getStockingIvt(ivtId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改备货区域点位。
|
||||||
|
*/
|
||||||
|
@PutMapping("/update")
|
||||||
|
@Operation(summary = "修改备货区域点位")
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:stocking-ivt:update')")
|
||||||
|
public CommonResult<Boolean> updateStockingIvt(@Valid @RequestBody StockingIvtUpdateReqVO reqVO) {
|
||||||
|
stockingIvtService.updateStockingIvt(reqVO);
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询纸管托盘库存。
|
||||||
|
*/
|
||||||
|
@GetMapping("/paperVehicleList")
|
||||||
|
@Operation(summary = "获得纸管托盘库存")
|
||||||
|
@Parameter(name = "vehicleCode", description = "托盘号", required = true)
|
||||||
|
@PreAuthorize("@ss.hasPermission('lms:stocking-ivt:query')")
|
||||||
|
public CommonResult<List<PaperVehicleInventoryRespVO>> getPaperVehicleInventory(
|
||||||
|
@RequestParam("vehicleCode") @NotEmpty String vehicleCode) {
|
||||||
|
return success(stockingIvtService.getPaperVehicleInventory(vehicleCode));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package cn.code.nl.module.lms.service.stockingivt;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.common.pojo.PageResult;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.PaperVehicleInventoryRespVO;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.StockingIvtPageReqVO;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.StockingIvtRespVO;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.StockingIvtUpdateReqVO;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备货区域服务。
|
||||||
|
*/
|
||||||
|
public interface StockingIvtService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询备货区域。
|
||||||
|
*/
|
||||||
|
PageResult<StockingIvtRespVO> getStockingIvtPage(StockingIvtPageReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询备货区域详情。
|
||||||
|
*/
|
||||||
|
StockingIvtRespVO getStockingIvt(Long ivtId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改备货区域点位。
|
||||||
|
*/
|
||||||
|
void updateStockingIvt(@Valid StockingIvtUpdateReqVO reqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询纸管托盘库存。
|
||||||
|
*/
|
||||||
|
List<PaperVehicleInventoryRespVO> getPaperVehicleInventory(String vehicleCode);
|
||||||
|
}
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
package cn.code.nl.module.lms.service.stockingivt;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.common.pojo.PageResult;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.PaperVehicleInventoryRespVO;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.StockingIvtPageReqVO;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.StockingIvtRespVO;
|
||||||
|
import cn.code.nl.module.lms.controller.admin.stockingivt.vo.StockingIvtUpdateReqVO;
|
||||||
|
import cn.code.nl.module.lms.dal.dataobject.stockingivt.PaperVehicleDO;
|
||||||
|
import cn.code.nl.module.lms.dal.dataobject.stockingivt.StockingIvtDO;
|
||||||
|
import cn.code.nl.module.lms.dal.mysql.stockingivt.StockingIvtMapper;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static cn.code.nl.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.code.nl.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
import static cn.code.nl.module.lms.enums.ErrorCodeConstants.PAPER_VEHICLE_POSITION_DUPLICATED;
|
||||||
|
import static cn.code.nl.module.lms.enums.ErrorCodeConstants.PAPER_VEHICLE_POSITION_OUT_OF_RANGE;
|
||||||
|
import static cn.code.nl.module.lms.enums.ErrorCodeConstants.STOCKING_IVT_NOT_EXISTS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 备货区域服务实现。
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
public class StockingIvtServiceImpl implements StockingIvtService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private StockingIvtMapper stockingIvtMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询备货区域。
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<StockingIvtRespVO> getStockingIvtPage(StockingIvtPageReqVO reqVO) {
|
||||||
|
PageResult<StockingIvtDO> pageResult = stockingIvtMapper.selectStockingIvtPage(reqVO);
|
||||||
|
List<StockingIvtRespVO> list = new ArrayList<>(pageResult.getList().size());
|
||||||
|
for (StockingIvtDO stockingIvt : pageResult.getList()) {
|
||||||
|
list.add(convertStockingIvt(stockingIvt));
|
||||||
|
}
|
||||||
|
return new PageResult<>(list, pageResult.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询备货区域详情。
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public StockingIvtRespVO getStockingIvt(Long ivtId) {
|
||||||
|
StockingIvtDO stockingIvt = stockingIvtMapper.selectStockingIvtById(ivtId);
|
||||||
|
if (stockingIvt == null) {
|
||||||
|
throw exception(STOCKING_IVT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
return convertStockingIvt(stockingIvt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改备货区域点位。
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateStockingIvt(StockingIvtUpdateReqVO reqVO) {
|
||||||
|
if (stockingIvtMapper.selectStockingIvtById(reqVO.getIvtId()) == null) {
|
||||||
|
throw exception(STOCKING_IVT_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
StockingIvtDO updateObj = new StockingIvtDO();
|
||||||
|
updateObj.setIvtId(reqVO.getIvtId());
|
||||||
|
updateObj.setVehicleCode(reqVO.getVehicleCode());
|
||||||
|
updateObj.setPointType(reqVO.getPointType());
|
||||||
|
updateObj.setIvtStatus(reqVO.getIvtStatus());
|
||||||
|
updateObj.setPointLocation(reqVO.getPointLocation());
|
||||||
|
updateObj.setSortSeq(reqVO.getSortSeq());
|
||||||
|
updateObj.setIsUsed(reqVO.getIsUsed());
|
||||||
|
updateObj.setRemark(reqVO.getRemark());
|
||||||
|
updateObj.setUpdater(String.valueOf(getLoginUserId()));
|
||||||
|
stockingIvtMapper.updateStockingIvt(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询并校验纸管托盘库存。
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<PaperVehicleInventoryRespVO> getPaperVehicleInventory(String vehicleCode) {
|
||||||
|
List<PaperVehicleDO> inventoryList = stockingIvtMapper.selectPaperVehicleList(vehicleCode);
|
||||||
|
List<PaperVehicleInventoryRespVO> result = new ArrayList<>(inventoryList.size());
|
||||||
|
Set<String> positions = new HashSet<>();
|
||||||
|
for (PaperVehicleDO inventory : inventoryList) {
|
||||||
|
String position = inventory.getRowNum() + ":" + inventory.getColNum();
|
||||||
|
if (inventory.getRowNum() < 1 || inventory.getRowNum() > 5
|
||||||
|
|| inventory.getColNum() < 1 || inventory.getColNum() > 5) {
|
||||||
|
throw exception(PAPER_VEHICLE_POSITION_OUT_OF_RANGE, position);
|
||||||
|
}
|
||||||
|
if (!positions.add(position)) {
|
||||||
|
throw exception(PAPER_VEHICLE_POSITION_DUPLICATED, position);
|
||||||
|
}
|
||||||
|
PaperVehicleInventoryRespVO item = new PaperVehicleInventoryRespVO();
|
||||||
|
item.setRowNum(inventory.getRowNum());
|
||||||
|
item.setColNum(inventory.getColNum());
|
||||||
|
item.setMaterialCode(inventory.getMaterialCode());
|
||||||
|
item.setMaterialName(inventory.getMaterialName());
|
||||||
|
item.setQty(inventory.getQty());
|
||||||
|
result.add(item);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将备货区域数据对象转换为响应对象。
|
||||||
|
*/
|
||||||
|
private StockingIvtRespVO convertStockingIvt(StockingIvtDO stockingIvt) {
|
||||||
|
StockingIvtRespVO response = new StockingIvtRespVO();
|
||||||
|
response.setIvtId(stockingIvt.getIvtId());
|
||||||
|
response.setPointCode(stockingIvt.getPointCode());
|
||||||
|
response.setPointName(stockingIvt.getPointName());
|
||||||
|
response.setVehicleCode(stockingIvt.getVehicleCode());
|
||||||
|
response.setPointType(stockingIvt.getPointType());
|
||||||
|
response.setIvtStatus(stockingIvt.getIvtStatus());
|
||||||
|
response.setPointLocation(stockingIvt.getPointLocation());
|
||||||
|
response.setSortSeq(stockingIvt.getSortSeq());
|
||||||
|
response.setIsUsed(stockingIvt.getIsUsed());
|
||||||
|
response.setRemark(stockingIvt.getRemark());
|
||||||
|
response.setUpdater(stockingIvt.getUpdater());
|
||||||
|
response.setUpdateTime(stockingIvt.getUpdateTime());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user