feat(mat): 添加入库记录的联查
- 新增 selectVoPagePlus 方法支持多表关联查询 - 扩展 MatPurchaseInDetailVo 实体类增加采购和物料相关字段 - 实现 buildQueryWrapperPlus 方法优化查询条件构建 - 添加多表关联的 SQL 映射配置 - 支持按采购单号、物料信息等条件进行分页查询
This commit is contained in:
@@ -84,4 +84,81 @@ public class MatPurchaseInDetailVo {
|
|||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购单号 唯一 如P20260130001
|
||||||
|
*/
|
||||||
|
private String purchaseNo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 厂家
|
||||||
|
*/
|
||||||
|
private String factory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配料ID 关联material.id
|
||||||
|
*/
|
||||||
|
private Long purchaseMaterialId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购计划数量
|
||||||
|
*/
|
||||||
|
private BigDecimal planNum;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购单价(本次录入价格)
|
||||||
|
*/
|
||||||
|
private BigDecimal purchasePrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购截止日期(要求入库日期)
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date deadline;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购状态 1-待入(在途) 2-已完成(全部入库) 3-已取消(归零) 4-部分入库
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消时间 状态为3时赋值
|
||||||
|
*/
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date cancelTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采购人/操作人
|
||||||
|
*/
|
||||||
|
private String purchaseOperator;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配料名称
|
||||||
|
*/
|
||||||
|
private String materialName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配料规格
|
||||||
|
*/
|
||||||
|
private String spec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配料型号
|
||||||
|
*/
|
||||||
|
private String model;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 配料单位
|
||||||
|
*/
|
||||||
|
private String unit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当前库存
|
||||||
|
*/
|
||||||
|
private BigDecimal currentStock;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.gear.mat.mapper;
|
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.MatPurchaseInDetail;
|
import com.gear.mat.domain.MatPurchaseInDetail;
|
||||||
import com.gear.mat.domain.vo.MatPurchaseInDetailVo;
|
import com.gear.mat.domain.vo.MatPurchaseInDetailVo;
|
||||||
import com.gear.common.core.mapper.BaseMapperPlus;
|
import com.gear.common.core.mapper.BaseMapperPlus;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 入库记录Mapper接口
|
* 入库记录Mapper接口
|
||||||
@@ -12,4 +15,5 @@ import com.gear.common.core.mapper.BaseMapperPlus;
|
|||||||
*/
|
*/
|
||||||
public interface MatPurchaseInDetailMapper extends BaseMapperPlus<MatPurchaseInDetailMapper, MatPurchaseInDetail, MatPurchaseInDetailVo> {
|
public interface MatPurchaseInDetailMapper extends BaseMapperPlus<MatPurchaseInDetailMapper, MatPurchaseInDetail, MatPurchaseInDetailVo> {
|
||||||
|
|
||||||
|
Page<MatPurchaseInDetailVo> selectVoPagePlus(Page<Object> build,@Param("ew") QueryWrapper<MatPurchaseInDetail> lqw);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.gear.mat.service.impl;
|
package com.gear.mat.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.gear.common.utils.StringUtils;
|
import com.gear.common.utils.StringUtils;
|
||||||
import com.gear.common.core.page.TableDataInfo;
|
import com.gear.common.core.page.TableDataInfo;
|
||||||
import com.gear.common.core.domain.PageQuery;
|
import com.gear.common.core.domain.PageQuery;
|
||||||
@@ -44,11 +45,29 @@ public class MatPurchaseInDetailServiceImpl implements IMatPurchaseInDetailServi
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<MatPurchaseInDetailVo> queryPageList(MatPurchaseInDetailBo bo, PageQuery pageQuery) {
|
public TableDataInfo<MatPurchaseInDetailVo> queryPageList(MatPurchaseInDetailBo bo, PageQuery pageQuery) {
|
||||||
LambdaQueryWrapper<MatPurchaseInDetail> lqw = buildQueryWrapper(bo);
|
QueryWrapper<MatPurchaseInDetail> lqw = buildQueryWrapperPlus(bo);
|
||||||
Page<MatPurchaseInDetailVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
Page<MatPurchaseInDetailVo> result = baseMapper.selectVoPagePlus(pageQuery.build(), lqw);
|
||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private QueryWrapper<MatPurchaseInDetail> buildQueryWrapperPlus(MatPurchaseInDetailBo bo) {
|
||||||
|
QueryWrapper<MatPurchaseInDetail> qw = Wrappers.query();
|
||||||
|
qw.eq(bo.getPurchaseId() != null, "mpid.purchase_id", bo.getPurchaseId());
|
||||||
|
qw.eq(bo.getMaterialId() != null, "mpid.material_id", bo.getMaterialId());
|
||||||
|
qw.eq(bo.getInNum() != null, "mpid.in_num", bo.getInNum());
|
||||||
|
qw.eq(bo.getInPrice() != null, "mpid.in_price", bo.getInPrice());
|
||||||
|
qw.eq(bo.getInAmount() != null, "mpid.in_amount", bo.getInAmount());
|
||||||
|
// qw.eq(bo.getInTime() != null, "mpid.in_time", bo.getInTime()) 决定使用beginTime和endTime筛选
|
||||||
|
qw.ge(bo.getBeginTime() != null, "mpid.in_time", bo.getBeginTime());
|
||||||
|
qw.le(bo.getEndTime() != null, "mpid.in_time", bo.getEndTime());
|
||||||
|
qw.eq(StringUtils.isNotBlank(bo.getOperator()), "mpid.operator", bo.getOperator());
|
||||||
|
// 逻辑删除
|
||||||
|
qw.eq("mpid.del_flag", 0);
|
||||||
|
// 排序
|
||||||
|
qw.orderByDesc("mpid.in_time");
|
||||||
|
return qw;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询入库记录列表
|
* 查询入库记录列表
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,6 +20,40 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="updateBy" column="update_by"/>
|
<result property="updateBy" column="update_by"/>
|
||||||
<result property="remark" column="remark"/>
|
<result property="remark" column="remark"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
<select id="selectVoPagePlus" resultType="com.gear.mat.domain.vo.MatPurchaseInDetailVo">
|
||||||
|
select mpid.detail_id AS detailId,
|
||||||
|
mpid.purchase_id AS purchaseId,
|
||||||
|
mpid.material_id AS materialId,
|
||||||
|
mpid.in_num AS inNum,
|
||||||
|
mpid.in_price AS inPrice,
|
||||||
|
mpid.in_amount AS inAmount,
|
||||||
|
mpid.in_time AS inTime,
|
||||||
|
mpid.operator AS operator,
|
||||||
|
mpid.create_time AS createTime,
|
||||||
|
mpid.create_by AS createBy,
|
||||||
|
mpid.update_time AS updateTime,
|
||||||
|
mpid.update_by AS updateBy,
|
||||||
|
mpid.remark AS remark,
|
||||||
|
mp.purchase_no AS purchaseNo,
|
||||||
|
mp.factory AS factory,
|
||||||
|
mp.material_id AS purchaseMaterialId,
|
||||||
|
mp.plan_num AS planNum,
|
||||||
|
mp.purchase_price AS purchasePrice,
|
||||||
|
mp.deadline AS deadline,
|
||||||
|
mp.status AS purchaseStatus,
|
||||||
|
mp.cancel_time AS cancelTime,
|
||||||
|
mp.operator AS purchaseOperator,
|
||||||
|
mm.material_name AS materialName,
|
||||||
|
mm.spec AS spec,
|
||||||
|
mm.model AS model,
|
||||||
|
mm.factory AS materialFactory,
|
||||||
|
mm.unit AS unit,
|
||||||
|
mm.current_stock AS currentStock
|
||||||
|
FROM mat_purchase_in_detail mpid
|
||||||
|
LEFT JOIN mat_purchase mp ON mpid.purchase_id = mp.purchase_id AND mp.del_flag = 0
|
||||||
|
LEFT JOIN mat_material mm ON mpid.material_id = mm.material_id AND mm.del_flag = 0
|
||||||
|
${ew.customSqlSegment}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user