fix:添加托盘管理页面及修改盘点执行相关接口
parent
e3d1dac817
commit
5850be1a11
@ -0,0 +1,82 @@
|
||||
package cn.iocoder.yudao.module.erp.controller.admin.pallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.vo.ErpPalletPageReqVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.vo.ErpPalletRespVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.vo.ErpPalletSaveReqVO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.pallet.ErpPalletDO;
|
||||
import cn.iocoder.yudao.module.erp.service.pallet.ErpPalletService;
|
||||
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.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||
|
||||
@Tag(name = "管理后台 - ERP 托盘")
|
||||
@RestController
|
||||
@RequestMapping("/erp/pallet")
|
||||
@Validated
|
||||
public class ErpPalletController {
|
||||
|
||||
@Resource
|
||||
private ErpPalletService palletService;
|
||||
|
||||
@PostMapping("/create")
|
||||
@Operation(summary = "创建托盘")
|
||||
@PreAuthorize("@ss.hasPermission('erp:pallet:create')")
|
||||
public CommonResult<Long> createPallet(@Valid @RequestBody ErpPalletSaveReqVO createReqVO) {
|
||||
return success(palletService.createPallet(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新托盘")
|
||||
@PreAuthorize("@ss.hasPermission('erp:pallet:update')")
|
||||
public CommonResult<Boolean> updatePallet(@Valid @RequestBody ErpPalletSaveReqVO updateReqVO) {
|
||||
palletService.updatePallet(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete")
|
||||
@Operation(summary = "删除托盘")
|
||||
@Parameter(name = "id", description = "编号", required = true)
|
||||
@PreAuthorize("@ss.hasPermission('erp:pallet:delete')")
|
||||
public CommonResult<Boolean> deletePallet(@RequestParam("id") Long id) {
|
||||
palletService.deletePallet(id);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获得托盘")
|
||||
@Parameter(name = "id", description = "编号", required = true, example = "1")
|
||||
@PreAuthorize("@ss.hasPermission('erp:pallet:query')")
|
||||
public CommonResult<ErpPalletRespVO> getPallet(@RequestParam("id") Long id) {
|
||||
ErpPalletDO pallet = palletService.getPallet(id);
|
||||
return success(BeanUtils.toBean(pallet, ErpPalletRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得托盘分页")
|
||||
@PreAuthorize("@ss.hasPermission('erp:pallet:query')")
|
||||
public CommonResult<PageResult<ErpPalletRespVO>> getPalletPage(@Valid ErpPalletPageReqVO pageReqVO) {
|
||||
PageResult<ErpPalletDO> pageResult = palletService.getPalletPage(pageReqVO);
|
||||
return success(BeanUtils.toBean(pageResult, ErpPalletRespVO.class));
|
||||
}
|
||||
|
||||
@GetMapping("/simple-list")
|
||||
@Operation(summary = "获得托盘精简列表")
|
||||
@Parameter(name = "status", description = "托盘状态", example = "1")
|
||||
public CommonResult<List<ErpPalletRespVO>> getPalletSimpleList(@RequestParam(value = "status", required = false) Integer status) {
|
||||
List<ErpPalletDO> list = palletService.getPalletListByStatus(status);
|
||||
return success(convertList(list, item -> BeanUtils.toBean(item, ErpPalletRespVO.class)));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.erp.controller.admin.pallet.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ErpPalletStatusEnum implements IntArrayValuable {
|
||||
|
||||
IDLE(1, "空闲"),
|
||||
OCCUPIED(2, "占用"),
|
||||
SCRAPPED(3, "报废");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpPalletStatusEnum::getStatus).toArray();
|
||||
|
||||
private final Integer status;
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.erp.controller.admin.pallet.enums;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum ErpPalletTypeEnum implements IntArrayValuable {
|
||||
|
||||
PLASTIC(1, "塑料"),
|
||||
STEEL(2, "钢质"),
|
||||
WOOD(3, "木托盘");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(ErpPalletTypeEnum::getType).toArray();
|
||||
|
||||
private final Integer type;
|
||||
private final String name;
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
package cn.iocoder.yudao.module.erp.controller.admin.pallet.vo;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.enums.ErpPalletStatusEnum;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.enums.ErpPalletTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.ToString;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@Schema(description = "管理后台 - ERP 托盘分页 Request VO")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
public class ErpPalletPageReqVO extends PageParam {
|
||||
|
||||
@Schema(description = "托盘编码", example = "TP202506100001")
|
||||
private String code;
|
||||
|
||||
@Schema(description = "托盘类型", example = "1")
|
||||
@InEnum(ErpPalletTypeEnum.class)
|
||||
private Integer palletType;
|
||||
|
||||
@Schema(description = "托盘状态", example = "1")
|
||||
@InEnum(ErpPalletStatusEnum.class)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "仓库编号", example = "1")
|
||||
private Long warehouseId;
|
||||
|
||||
@Schema(description = "库区编号", example = "11")
|
||||
private Long areaId;
|
||||
|
||||
@Schema(description = "生产任务单号", example = "PLAN20250610001")
|
||||
private String planCode;
|
||||
|
||||
@Schema(description = "产品编号", example = "1001")
|
||||
private Long productId;
|
||||
|
||||
@Schema(description = "采购日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate[] purchaseDate;
|
||||
|
||||
@Schema(description = "投入使用日期")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY)
|
||||
private LocalDate[] useDate;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||
private LocalDateTime[] createTime;
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package cn.iocoder.yudao.module.erp.dal.dataobject.pallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
|
||||
@TableName("erp_pallet")
|
||||
@KeySequence("erp_pallet_seq")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ErpPalletDO extends BaseDO {
|
||||
|
||||
@TableId
|
||||
private Long id;
|
||||
private String code;
|
||||
private Integer palletType;
|
||||
private String specification;
|
||||
private BigDecimal ratedLoadWeight;
|
||||
private String unit;
|
||||
private Integer status;
|
||||
private Long warehouseId;
|
||||
private Long areaId;
|
||||
private String planCode;
|
||||
private Long productId;
|
||||
private BigDecimal productCount;
|
||||
private String qrcode;
|
||||
private LocalDate purchaseDate;
|
||||
private LocalDate useDate;
|
||||
private String remark;
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
package cn.iocoder.yudao.module.erp.dal.mysql.pallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.vo.ErpPalletPageReqVO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.pallet.ErpPalletDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ErpPalletMapper extends BaseMapperX<ErpPalletDO> {
|
||||
|
||||
default PageResult<ErpPalletDO> selectPage(ErpPalletPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<ErpPalletDO>()
|
||||
.likeIfPresent(ErpPalletDO::getCode, reqVO.getCode())
|
||||
.eqIfPresent(ErpPalletDO::getPalletType, reqVO.getPalletType())
|
||||
.eqIfPresent(ErpPalletDO::getStatus, reqVO.getStatus())
|
||||
.eqIfPresent(ErpPalletDO::getWarehouseId, reqVO.getWarehouseId())
|
||||
.eqIfPresent(ErpPalletDO::getAreaId, reqVO.getAreaId())
|
||||
.likeIfPresent(ErpPalletDO::getPlanCode, reqVO.getPlanCode())
|
||||
.eqIfPresent(ErpPalletDO::getProductId, reqVO.getProductId())
|
||||
.betweenIfPresent(ErpPalletDO::getPurchaseDate, reqVO.getPurchaseDate())
|
||||
.betweenIfPresent(ErpPalletDO::getUseDate, reqVO.getUseDate())
|
||||
.betweenIfPresent(ErpPalletDO::getCreateTime, reqVO.getCreateTime())
|
||||
.orderByDesc(ErpPalletDO::getId));
|
||||
}
|
||||
|
||||
default ErpPalletDO selectByCode(String code) {
|
||||
return selectOne(ErpPalletDO::getCode, code);
|
||||
}
|
||||
|
||||
default List<ErpPalletDO> selectListByStatus(Integer status) {
|
||||
if (status == null) {
|
||||
return selectList();
|
||||
}
|
||||
return selectList(ErpPalletDO::getStatus, status);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.erp.service.pallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.vo.ErpPalletPageReqVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.vo.ErpPalletSaveReqVO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.pallet.ErpPalletDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
public interface ErpPalletService {
|
||||
|
||||
Long createPallet(@Valid ErpPalletSaveReqVO createReqVO);
|
||||
|
||||
void updatePallet(@Valid ErpPalletSaveReqVO updateReqVO);
|
||||
|
||||
void deletePallet(Long id);
|
||||
|
||||
ErpPalletDO getPallet(Long id);
|
||||
|
||||
PageResult<ErpPalletDO> getPalletPage(ErpPalletPageReqVO pageReqVO);
|
||||
|
||||
List<ErpPalletDO> getPalletListByStatus(Integer status);
|
||||
}
|
||||
@ -0,0 +1,144 @@
|
||||
package cn.iocoder.yudao.module.erp.service.pallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.autocode.util.AutoCodeUtil;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.vo.ErpPalletPageReqVO;
|
||||
import cn.iocoder.yudao.module.erp.controller.admin.pallet.vo.ErpPalletSaveReqVO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.pallet.ErpPalletDO;
|
||||
import cn.iocoder.yudao.module.erp.dal.dataobject.warehousearea.WarehouseAreaDO;
|
||||
import cn.iocoder.yudao.module.erp.dal.mysql.pallet.ErpPalletMapper;
|
||||
import cn.iocoder.yudao.module.erp.service.product.ErpProductService;
|
||||
import cn.iocoder.yudao.module.erp.service.stock.ErpWarehouseService;
|
||||
import cn.iocoder.yudao.module.erp.service.warehousearea.WarehouseAreaService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.PALLET_CODE_EXISTS;
|
||||
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.PALLET_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.PRODUCT_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_AREA_NOT_EXISTS;
|
||||
import static cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_LOCATION_WAREHOUSE_AREA_NOT_MATCH;
|
||||
|
||||
@Service
|
||||
@Validated
|
||||
public class ErpPalletServiceImpl implements ErpPalletService {
|
||||
|
||||
@Resource
|
||||
private ErpPalletMapper palletMapper;
|
||||
@Resource
|
||||
private AutoCodeUtil autoCodeUtil;
|
||||
@Resource
|
||||
private ErpWarehouseService warehouseService;
|
||||
@Resource
|
||||
private WarehouseAreaService warehouseAreaService;
|
||||
@Resource
|
||||
private ErpProductService productService;
|
||||
|
||||
@Override
|
||||
public Long createPallet(ErpPalletSaveReqVO createReqVO) {
|
||||
validateWarehouseAreaMatch(createReqVO.getWarehouseId(), createReqVO.getAreaId());
|
||||
validateProductExists(createReqVO.getProductId());
|
||||
ErpPalletDO pallet = BeanUtils.toBean(createReqVO, ErpPalletDO.class);
|
||||
if (StringUtils.isBlank(pallet.getCode())) {
|
||||
pallet.setCode(autoCodeUtil.genSerialCode("PALLET_CODE_GENERATE", null));
|
||||
} else {
|
||||
validateCodeUnique(null, pallet.getCode());
|
||||
}
|
||||
if (StringUtils.isBlank(pallet.getQrcode())) {
|
||||
pallet.setQrcode(pallet.getCode());
|
||||
}
|
||||
palletMapper.insert(pallet);
|
||||
return pallet.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePallet(ErpPalletSaveReqVO updateReqVO) {
|
||||
ErpPalletDO pallet = validatePalletExists(updateReqVO.getId());
|
||||
validateWarehouseAreaMatch(updateReqVO.getWarehouseId(), updateReqVO.getAreaId());
|
||||
validateProductExists(updateReqVO.getProductId());
|
||||
ErpPalletDO updateObj = BeanUtils.toBean(updateReqVO, ErpPalletDO.class);
|
||||
if (StringUtils.isBlank(updateObj.getCode())) {
|
||||
updateObj.setCode(pallet.getCode());
|
||||
} else {
|
||||
validateCodeUnique(updateObj.getId(), updateObj.getCode());
|
||||
}
|
||||
if (StringUtils.isBlank(updateObj.getQrcode())) {
|
||||
updateObj.setQrcode(updateObj.getCode());
|
||||
}
|
||||
palletMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deletePallet(Long id) {
|
||||
validatePalletExists(id);
|
||||
palletMapper.deleteById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ErpPalletDO getPallet(Long id) {
|
||||
return palletMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<ErpPalletDO> getPalletPage(ErpPalletPageReqVO pageReqVO) {
|
||||
return palletMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ErpPalletDO> getPalletListByStatus(Integer status) {
|
||||
return palletMapper.selectListByStatus(status);
|
||||
}
|
||||
|
||||
private ErpPalletDO validatePalletExists(Long id) {
|
||||
ErpPalletDO pallet = palletMapper.selectById(id);
|
||||
if (pallet == null) {
|
||||
throw exception(PALLET_NOT_EXISTS);
|
||||
}
|
||||
return pallet;
|
||||
}
|
||||
|
||||
private void validateCodeUnique(Long id, String code) {
|
||||
ErpPalletDO pallet = palletMapper.selectByCode(code);
|
||||
if (pallet == null) {
|
||||
return;
|
||||
}
|
||||
if (id == null || !pallet.getId().equals(id)) {
|
||||
throw exception(PALLET_CODE_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateWarehouseAreaMatch(Long warehouseId, Long areaId) {
|
||||
if (warehouseId == null && areaId == null) {
|
||||
return;
|
||||
}
|
||||
if (warehouseId != null && warehouseService.validWarehouseList(Collections.singleton(warehouseId)).isEmpty()) {
|
||||
throw exception(cn.iocoder.yudao.module.erp.enums.ErrorCodeConstants.WAREHOUSE_NOT_EXISTS);
|
||||
}
|
||||
if (areaId == null) {
|
||||
return;
|
||||
}
|
||||
WarehouseAreaDO area = warehouseAreaService.getWarehouseArea(areaId);
|
||||
if (area == null) {
|
||||
throw exception(WAREHOUSE_AREA_NOT_EXISTS);
|
||||
}
|
||||
if (warehouseId == null || !warehouseId.equals(area.getWarehouseId())) {
|
||||
throw exception(WAREHOUSE_LOCATION_WAREHOUSE_AREA_NOT_MATCH);
|
||||
}
|
||||
}
|
||||
|
||||
private void validateProductExists(Long productId) {
|
||||
if (productId == null) {
|
||||
return;
|
||||
}
|
||||
if (productService.validProductList(Collections.singleton(productId)).isEmpty()) {
|
||||
throw exception(PRODUCT_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue