✨ ERP:增加 ERP 盘点单的实现 100%
parent
573a79cad6
commit
94247addc6
@ -0,0 +1,45 @@
|
|||||||
|
package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import cn.iocoder.yudao.framework.common.validation.InEnum;
|
||||||
|
import cn.iocoder.yudao.module.erp.enums.ErpAuditStatus;
|
||||||
|
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.LocalDateTime;
|
||||||
|
|
||||||
|
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 ErpStockCheckPageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "盘点单号", example = "S123")
|
||||||
|
private String no;
|
||||||
|
|
||||||
|
@Schema(description = "仓库编号", example = "3113")
|
||||||
|
private Long warehouseId;
|
||||||
|
|
||||||
|
@Schema(description = "盘点时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private LocalDateTime[] checkTime;
|
||||||
|
|
||||||
|
@Schema(description = "状态", example = "10")
|
||||||
|
@InEnum(ErpAuditStatus.class)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "创建者")
|
||||||
|
private String creator;
|
||||||
|
|
||||||
|
@Schema(description = "产品编号", example = "1")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,111 @@
|
|||||||
|
package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
|
||||||
|
import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
|
||||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.module.erp.enums.DictTypeConstants.AUDIT_STATUS;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - ERP 库存盘点单 Response VO")
|
||||||
|
@Data
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class ErpStockCheckRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "盘点编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756")
|
||||||
|
@ExcelProperty("盘点编号")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "盘点单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "S123")
|
||||||
|
@ExcelProperty("盘点单号")
|
||||||
|
private String no;
|
||||||
|
|
||||||
|
@Schema(description = "盘点时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("盘点时间")
|
||||||
|
private LocalDateTime checkTime;
|
||||||
|
|
||||||
|
@Schema(description = "合计数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "15663")
|
||||||
|
@ExcelProperty("合计数量")
|
||||||
|
private BigDecimal totalCount;
|
||||||
|
|
||||||
|
@Schema(description = "合计金额,单位:元", requiredMode = Schema.RequiredMode.REQUIRED, example = "24906")
|
||||||
|
@ExcelProperty("合计金额")
|
||||||
|
private BigDecimal totalPrice;
|
||||||
|
|
||||||
|
@Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||||
|
@ExcelProperty(value = "状态", converter = DictConvert.class)
|
||||||
|
@DictFormat(AUDIT_STATUS)
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
@ExcelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc")
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
@Schema(description = "审核人", example = "芋道")
|
||||||
|
private String creator;
|
||||||
|
@Schema(description = "审核人名称", example = "芋道")
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@Schema(description = "盘点项列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private List<Item> items;
|
||||||
|
|
||||||
|
@Schema(description = "产品信息", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@ExcelProperty("产品信息")
|
||||||
|
private String productNames;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Item {
|
||||||
|
|
||||||
|
@Schema(description = "盘点项编号", example = "11756")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
|
||||||
|
private Long warehouseId;
|
||||||
|
|
||||||
|
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
@Schema(description = "产品单价", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
|
||||||
|
private BigDecimal productPrice;
|
||||||
|
|
||||||
|
@Schema(description = "账面数量(当前库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
|
||||||
|
@NotNull(message = "账面数量不能为空")
|
||||||
|
private BigDecimal stockCount;
|
||||||
|
|
||||||
|
@Schema(description = "实际数量(实际库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
|
||||||
|
@NotNull(message = "实际数量不能为空")
|
||||||
|
private BigDecimal actualCount;
|
||||||
|
|
||||||
|
@Schema(description = "盈亏数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
|
||||||
|
@NotNull(message = "盈亏数量不能为空")
|
||||||
|
private BigDecimal count;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
// ========== 关联字段 ==========
|
||||||
|
|
||||||
|
@Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "巧克力")
|
||||||
|
private String productName;
|
||||||
|
@Schema(description = "产品条码", requiredMode = Schema.RequiredMode.REQUIRED, example = "A9985")
|
||||||
|
private String productBarCode;
|
||||||
|
@Schema(description = "产品单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "盒")
|
||||||
|
private String productUnitName;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,69 @@
|
|||||||
|
package cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - ERP 其它出库单新增/修改 Request VO")
|
||||||
|
@Data
|
||||||
|
public class ErpStockCheckSaveReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "出库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11756")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "出库时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotNull(message = "出库时间不能为空")
|
||||||
|
private LocalDateTime checkTime;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@Schema(description = "附件 URL", example = "https://www.iocoder.cn/1.doc")
|
||||||
|
private String fileUrl;
|
||||||
|
|
||||||
|
@Schema(description = "出库项列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "出库项列表不能为空")
|
||||||
|
@Valid
|
||||||
|
private List<Item> items;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Item {
|
||||||
|
|
||||||
|
@Schema(description = "出库项编号", example = "11756")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "仓库编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
|
||||||
|
@NotNull(message = "仓库编号不能为空")
|
||||||
|
private Long warehouseId;
|
||||||
|
|
||||||
|
@Schema(description = "产品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "3113")
|
||||||
|
@NotNull(message = "产品编号不能为空")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
@Schema(description = "产品单价", example = "100.00")
|
||||||
|
private BigDecimal productPrice;
|
||||||
|
|
||||||
|
@Schema(description = "账面数量(当前库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
|
||||||
|
@NotNull(message = "账面数量不能为空")
|
||||||
|
private BigDecimal stockCount;
|
||||||
|
|
||||||
|
@Schema(description = "实际数量(实际库存)", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
|
||||||
|
@NotNull(message = "实际数量不能为空")
|
||||||
|
private BigDecimal actualCount;
|
||||||
|
|
||||||
|
@Schema(description = "盈亏数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "100.00")
|
||||||
|
@NotNull(message = "盈亏数量不能为空")
|
||||||
|
private BigDecimal count;
|
||||||
|
|
||||||
|
@Schema(description = "备注", example = "随便")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
package cn.iocoder.yudao.module.erp.dal.mysql.stock;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ERP 库存盘点单项 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ErpStockCheckItemMapper extends BaseMapperX<ErpStockCheckItemDO> {
|
||||||
|
|
||||||
|
default List<ErpStockCheckItemDO> selectListByCheckId(Long checkId) {
|
||||||
|
return selectList(ErpStockCheckItemDO::getCheckId, checkId);
|
||||||
|
}
|
||||||
|
|
||||||
|
default List<ErpStockCheckItemDO> selectListByCheckIds(Collection<Long> checkIds) {
|
||||||
|
return selectList(ErpStockCheckItemDO::getCheckId, checkIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
default int deleteByCheckId(Long checkId) {
|
||||||
|
return delete(ErpStockCheckItemDO::getCheckId, checkId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,46 @@
|
|||||||
|
package cn.iocoder.yudao.module.erp.dal.mysql.stock;
|
||||||
|
|
||||||
|
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.MPJLambdaWrapperX;
|
||||||
|
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO;
|
||||||
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ERP 库存调拨单 Mapper
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ErpStockCheckMapper extends BaseMapperX<ErpStockCheckDO> {
|
||||||
|
|
||||||
|
default PageResult<ErpStockCheckDO> selectPage(ErpStockCheckPageReqVO reqVO) {
|
||||||
|
MPJLambdaWrapperX<ErpStockCheckDO> query = new MPJLambdaWrapperX<ErpStockCheckDO>()
|
||||||
|
.eqIfPresent(ErpStockCheckDO::getNo, reqVO.getNo())
|
||||||
|
.betweenIfPresent(ErpStockCheckDO::getCheckTime, reqVO.getCheckTime())
|
||||||
|
.eqIfPresent(ErpStockCheckDO::getStatus, reqVO.getStatus())
|
||||||
|
.likeIfPresent(ErpStockCheckDO::getRemark, reqVO.getRemark())
|
||||||
|
.eqIfPresent(ErpStockCheckDO::getCreator, reqVO.getCreator())
|
||||||
|
.orderByDesc(ErpStockCheckDO::getId);
|
||||||
|
if (reqVO.getWarehouseId() != null || reqVO.getProductId() != null) {
|
||||||
|
query.leftJoin(ErpStockCheckItemDO.class, ErpStockCheckItemDO::getCheckId, ErpStockCheckDO::getId)
|
||||||
|
.eq(reqVO.getWarehouseId() != null, ErpStockCheckItemDO::getWarehouseId, reqVO.getWarehouseId())
|
||||||
|
.eq(reqVO.getProductId() != null, ErpStockCheckItemDO::getProductId, reqVO.getProductId())
|
||||||
|
.groupBy(ErpStockCheckDO::getId); // 避免 1 对多查询,产生相同的 1
|
||||||
|
}
|
||||||
|
return selectJoinPage(reqVO, ErpStockCheckDO.class, query);
|
||||||
|
}
|
||||||
|
|
||||||
|
default int updateByIdAndStatus(Long id, Integer status, ErpStockCheckDO updateObj) {
|
||||||
|
return update(updateObj, new LambdaUpdateWrapper<ErpStockCheckDO>()
|
||||||
|
.eq(ErpStockCheckDO::getId, id).eq(ErpStockCheckDO::getStatus, status));
|
||||||
|
}
|
||||||
|
|
||||||
|
default ErpStockCheckDO selectByNo(String no) {
|
||||||
|
return selectOne(ErpStockCheckDO::getNo, no);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,84 @@
|
|||||||
|
package cn.iocoder.yudao.module.erp.service.stock;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckPageReqVO;
|
||||||
|
import cn.iocoder.yudao.module.erp.controller.admin.stock.vo.check.ErpStockCheckSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckDO;
|
||||||
|
import cn.iocoder.yudao.module.erp.dal.dataobject.stock.ErpStockCheckItemDO;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ERP 库存盘点单 Service 接口
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
public interface ErpStockCheckService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建库存盘点单
|
||||||
|
*
|
||||||
|
* @param createReqVO 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Long createStockCheck(@Valid ErpStockCheckSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新库存盘点单
|
||||||
|
*
|
||||||
|
* @param updateReqVO 更新信息
|
||||||
|
*/
|
||||||
|
void updateStockCheck(@Valid ErpStockCheckSaveReqVO updateReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新库存盘点单的状态
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @param status 状态
|
||||||
|
*/
|
||||||
|
void updateStockCheckStatus(Long id, Integer status);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除库存盘点单
|
||||||
|
*
|
||||||
|
* @param ids 编号数组
|
||||||
|
*/
|
||||||
|
void deleteStockCheck(List<Long> ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得库存盘点单
|
||||||
|
*
|
||||||
|
* @param id 编号
|
||||||
|
* @return 库存盘点单
|
||||||
|
*/
|
||||||
|
ErpStockCheckDO getStockCheck(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得库存盘点单分页
|
||||||
|
*
|
||||||
|
* @param pageReqVO 分页查询
|
||||||
|
* @return 库存盘点单分页
|
||||||
|
*/
|
||||||
|
PageResult<ErpStockCheckDO> getStockCheckPage(ErpStockCheckPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
// ==================== 盘点项 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得库存盘点单项列表
|
||||||
|
*
|
||||||
|
* @param checkId 盘点编号
|
||||||
|
* @return 库存盘点单项列表
|
||||||
|
*/
|
||||||
|
List<ErpStockCheckItemDO> getStockCheckItemListByCheckId(Long checkId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得库存盘点单项 List
|
||||||
|
*
|
||||||
|
* @param checkIds 盘点编号数组
|
||||||
|
* @return 库存盘点单项 List
|
||||||
|
*/
|
||||||
|
List<ErpStockCheckItemDO> getStockCheckItemListByCheckIds(Collection<Long> checkIds);
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue