目录
1.联表查询
public IPage<ReceiveOrder> pageList(ReceiveOrderParam params) {
Page<ReceiveOrder> page = new Page<>(params.getPageNumber(), params.getPageSize());
receiveOrderMapper.pageList(page, getWrapperLeft(params));
return page;
}
/**
* wrod wro
* 页面分页查询关联detail查询 构建查询条件
* @param params
* @return
*/
public QueryWrapper getWrapperLeft(ReceiveOrderParam params) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.like(StringUtils.isNotEmpty(params.getGoodsOwnerCode()), "wro.goods_owner_code", params.getGoodsOwnerCode());
queryWrapper.like(StringUtils.isNotEmpty(params.getReceiveOrderNo()), "wro.receive_order_no", params.getReceiveOrderNo());
queryWrapper.eq(StringUtils.isNotEmpty(params.getType()), "wro.type", params.getType());
queryWrapper.like(StringUtils.isNotEmpty(params.getStatus()), "wro.status", params.getStatus());
queryWrapper.like(StringUtils.isNotEmpty(params.getSupplierName()), "wro.supplier_name", params.getSupplierName());
queryWrapper.like(StringUtils.isNotEmpty(params.getGoodsName()), "wrod.goods_name", params.getGoodsName());
queryWrapper.like(StringUtils.isNotEmpty(params.getPoNo()), "wro.po_no", params.getPoNo());
queryWrapper.like(StringUtils.isNotEmpty(params.getPutawayStatus()), "wro.putaway_status", params.getPutawayStatus());
if (StringUtils.isNotEmpty(params.getCreateTime())) {
String[] split = params.getCreateTime().split(GaeaConstant.SPLIT);
queryWrapper.between("wro.create_time", split[0], split[1]);
}
if (StringUtils.isNotBlank(params.getOrder())) {
if (BusinessConstant.ASC.equals(params.getSort())) {
queryWrapper.orderByAsc("wro." + GaeaUtils.camelToUnderline(params.getOrder()));
} else {
queryWrapper.orderByDesc("wro." + GaeaUtils.camelToUnderline(params.getOrder()));
}
}
return queryWrapper;
}
mapper
String PAGELIST_SQL = " DISTINCT wro.id,wro.org_code,wro.warehouse_code,wro.receive_order_no,wro.type,wro.status," +
"wro.goods_owner_code,wro.supplier_code,wro.supplier_name,wro.po_no,wro.putaway_status,wro.enabled," +
"wro.create_by,wro.create_time,wro.update_by,wro.update_time,wro.version";
@Select(" SELECT " + PAGELIST_SQL + " FROM wms_receive_order wro"
+ " LEFT JOIN wms_receive_order_detail wrod ON wrod.receive_order_id = wro.id "
+ " ${ew.customSqlSegment}")
Page<ReceiveOrder> pageList(Page<ReceiveOrder> page, @Param(Constants.WRAPPER) QueryWrapper queryWrapper);