feat(mat): 添加价格历史详情功能
- 在MatMaterialOutServiceImpl中添加逻辑删除过滤和按出库时间降序排序 - 为MatMatPriceHistoryMapper添加分页查询方法和对应的XML映射 - 扩展MatMatPriceHistoryVo实体类,增加物料名称、规格、型号等关联信息字段 - 修改MatProductServiceImpl中的流式处理语法,提升代码简洁性 - 为MatPurchaseBo和MatPurchaseInDetailBo添加开始时间和结束时间查询参数 - 实现价格历史记录的完整查询和展示功能,包括关联物料信息的获取
This commit is contained in:
@@ -85,4 +85,18 @@ public class MatPurchaseBo extends BaseEntity {
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date beginTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -73,4 +73,18 @@ public class MatPurchaseInDetailBo extends BaseEntity {
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date beginTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date endTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -58,5 +58,41 @@ public class MatMatPriceHistoryVo {
|
||||
@ExcelProperty(value = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 配料名称
|
||||
*/
|
||||
@ExcelProperty(value = "配料名称")
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 配料规格
|
||||
*/
|
||||
@ExcelProperty(value = "配料规格")
|
||||
private String spec;
|
||||
|
||||
/**
|
||||
* 配料型号
|
||||
*/
|
||||
@ExcelProperty(value = "配料型号")
|
||||
private String model;
|
||||
|
||||
/**
|
||||
* 配料厂家
|
||||
*/
|
||||
@ExcelProperty(value = "配料厂家")
|
||||
private String factory;
|
||||
|
||||
/**
|
||||
* 配料单位
|
||||
*/
|
||||
@ExcelProperty(value = "配料单位")
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 当前库存
|
||||
*/
|
||||
@ExcelProperty(value = "当前库存")
|
||||
private BigDecimal currentStock;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package com.gear.mat.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gear.mat.domain.MatMatPriceHistory;
|
||||
import com.gear.mat.domain.vo.MatMatPriceHistoryVo;
|
||||
import com.gear.common.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 配料价格/均价变动历史Mapper接口
|
||||
@@ -12,4 +15,5 @@ import com.gear.common.core.mapper.BaseMapperPlus;
|
||||
*/
|
||||
public interface MatMatPriceHistoryMapper extends BaseMapperPlus<MatMatPriceHistoryMapper, MatMatPriceHistory, MatMatPriceHistoryVo> {
|
||||
|
||||
Page<MatMatPriceHistoryVo> selectVoPagePlus(Page<Object> build,@Param("ew") QueryWrapper<MatMatPriceHistory> lqw);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.gear.mat.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.gear.common.utils.StringUtils;
|
||||
import com.gear.common.core.page.TableDataInfo;
|
||||
import com.gear.common.core.domain.PageQuery;
|
||||
@@ -44,11 +45,24 @@ public class MatMatPriceHistoryServiceImpl implements IMatMatPriceHistoryService
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<MatMatPriceHistoryVo> queryPageList(MatMatPriceHistoryBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<MatMatPriceHistory> lqw = buildQueryWrapper(bo);
|
||||
Page<MatMatPriceHistoryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
QueryWrapper<MatMatPriceHistory> lqw = buildQueryWrapperPlus(bo);
|
||||
Page<MatMatPriceHistoryVo> result = baseMapper.selectVoPagePlus(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
private QueryWrapper<MatMatPriceHistory> buildQueryWrapperPlus(MatMatPriceHistoryBo bo) {
|
||||
QueryWrapper<MatMatPriceHistory> lqw = Wrappers.query();
|
||||
lqw.eq(bo.getMaterialId() != null, "t.material_id", bo.getMaterialId());
|
||||
lqw.eq(bo.getPrice() != null, "t.price", bo.getPrice());
|
||||
lqw.eq(bo.getAvgPrice() != null, "t.avg_price", bo.getAvgPrice());
|
||||
lqw.eq(bo.getQuantity() != null, "t.quantity", bo.getQuantity());
|
||||
// 逻辑删除
|
||||
lqw.eq("t.del_flag", 0);
|
||||
// 排序
|
||||
lqw.orderByDesc("t.create_time");
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询配料价格/均价变动历史列表
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,10 @@ public class MatMaterialOutServiceImpl implements IMatMaterialOutService {
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getOperator()), "mmo.operator", bo.getOperator());
|
||||
lqw.ge(bo.getBeginTime() != null, "mmo.out_time", bo.getBeginTime());
|
||||
lqw.le(bo.getEndTime() != null, "mmo.out_time", bo.getEndTime());
|
||||
// 逻辑删除
|
||||
lqw.eq("mmo.del_flag", 0);
|
||||
// 排序
|
||||
lqw.orderByDesc("mmo.out_time");
|
||||
return lqw;
|
||||
}
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ public class MatProductServiceImpl implements IMatProductService {
|
||||
|
||||
// 转换为带配料信息的VO
|
||||
List<MatProductWithMaterialsVo> productList = result.getRecords().stream()
|
||||
.map(product -> convertToProductWithMaterialsVo(product))
|
||||
.map(this::convertToProductWithMaterialsVo)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Page<MatProductWithMaterialsVo> pageResult = new Page<>();
|
||||
|
||||
@@ -17,6 +17,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="remark" column="remark"/>
|
||||
</resultMap>
|
||||
<select id="selectVoPagePlus" resultType="com.gear.mat.domain.vo.MatMatPriceHistoryVo">
|
||||
SELECT
|
||||
t.history_id AS historyId,
|
||||
t.material_id AS materialId,
|
||||
t.price AS price,
|
||||
t.avg_price AS avgPrice,
|
||||
t.quantity AS quantity,
|
||||
t.create_time AS createTime,
|
||||
t.create_by AS createBy,
|
||||
t.update_time AS updateTime,
|
||||
t.update_by AS updateBy,
|
||||
t.remark AS remark,
|
||||
mm.material_name AS materialName,
|
||||
mm.spec AS spec,
|
||||
mm.model AS model,
|
||||
mm.factory AS factory,
|
||||
mm.unit AS unit,
|
||||
mm.current_stock AS currentStock
|
||||
FROM mat_mat_price_history t
|
||||
LEFT JOIN mat_material mm ON t.material_id = mm.material_id AND mm.del_flag = 0
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user