物料查询接口加分页

This commit is contained in:
luolm 2024-10-12 09:48:51 +08:00
parent e184dec8b4
commit ff9330816a
4 changed files with 47 additions and 23 deletions

View File

@ -7,9 +7,11 @@ import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.nflg.product.base.core.api.BaseApi; import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.base.core.exception.NflgBusinessException; import com.nflg.product.base.core.exception.NflgBusinessException;
import com.nflg.product.base.core.vo.PageVO;
import com.nflg.product.bomnew.constant.ReportConstant; import com.nflg.product.bomnew.constant.ReportConstant;
import com.nflg.product.bomnew.pojo.dto.MaterialQueryDTO; import com.nflg.product.bomnew.pojo.dto.MaterialQueryDTO;
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity; import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
@ -291,26 +293,28 @@ public class BomReportApi extends BaseApi {
@PostMapping("queryMaterial") @PostMapping("queryMaterial")
@ApiOperation("物料查询") @ApiOperation("物料查询")
public ResultVO<List<MaterialQueryResult>> materialQuery(@RequestBody MaterialQueryDTO queryParam){ public ResultVO<Page<MaterialQueryResult>> materialQuery(@RequestBody MaterialQueryDTO queryParam){
List<MaterialQueryResult> result = materialMainService.getBaseMapper().queryMaterial(queryParam);
//排序
if(StrUtil.isNotBlank(queryParam.getMaterialNo())) {
result.forEach(u->{
u.setOrderNo(StrUtil.replace(u.getMaterialNo(),queryParam.getMaterialNo(),"0"));
});
} Page<MaterialQueryDTO> page = new PageVO<>(queryParam.getPage(), queryParam.getPageSize());
if(StrUtil.isNotBlank(queryParam.getDrawingNo())) { Page<MaterialQueryResult> result = materialMainService.getBaseMapper().queryMaterial(page , queryParam);
result.forEach(u->{ //排序
u.setOrderNo(StrUtil.replace(u.getDrawingNo(),queryParam.getDrawingNo(),"0")); // if(StrUtil.isNotBlank(queryParam.getMaterialNo())) {
}); // result.forEach(u->{
} // u.setOrderNo(StrUtil.replace(u.getMaterialNo(),queryParam.getMaterialNo(),"0"));
if(StrUtil.isNotBlank(queryParam.getMaterialDesc())) { // });
result.forEach(u->{ //
u.setOrderNo(StrUtil.replace(u.getMaterialDesc(),queryParam.getMaterialDesc(),"0")); // }
}); // if(StrUtil.isNotBlank(queryParam.getDrawingNo())) {
} // result.forEach(u->{
result= result.stream().sorted( Comparator.comparing(MaterialQueryResult::getOrderNo)).collect(Collectors.toList()); // u.setOrderNo(StrUtil.replace(u.getDrawingNo(),queryParam.getDrawingNo(),"0"));
// });
// }
// if(StrUtil.isNotBlank(queryParam.getMaterialDesc())) {
// result.forEach(u->{
// u.setOrderNo(StrUtil.replace(u.getMaterialDesc(),queryParam.getMaterialDesc(),"0"));
// });
// }
// result= result.stream().sorted( Comparator.comparing(MaterialQueryResult::getOrderNo)).collect(Collectors.toList());
return ResultVO.success(result); return ResultVO.success(result);
} }

View File

@ -1,6 +1,7 @@
package com.nflg.product.bomnew.mapper.master; package com.nflg.product.bomnew.mapper.master;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.bomnew.pojo.dto.CategoryExcelDTO; import com.nflg.product.bomnew.pojo.dto.CategoryExcelDTO;
import com.nflg.product.bomnew.pojo.dto.MaterialQueryDTO; import com.nflg.product.bomnew.pojo.dto.MaterialQueryDTO;
import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity; import com.nflg.product.bomnew.pojo.entity.MaterialMainEntity;
@ -61,5 +62,5 @@ public interface MaterialMainMapper extends BaseMapper<MaterialMainEntity> {
String getUserDepartmentDptCode(@Param("rowId") Long rowId); String getUserDepartmentDptCode(@Param("rowId") Long rowId);
List<MaterialQueryResult> queryMaterial(@Param("query") MaterialQueryDTO query); Page<MaterialQueryResult> queryMaterial(Page<MaterialQueryDTO> page, @Param("query") MaterialQueryDTO query);
} }

View File

@ -26,6 +26,12 @@ public class MaterialQueryDTO implements Serializable {
@ApiModelProperty(value = "物料描述") @ApiModelProperty(value = "物料描述")
private String materialDesc; private String materialDesc;
// 设置每页显示条数
private Long pageSize = 20L;
// 当前页
private Long page = 1L;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -203,18 +203,31 @@
</select> </select>
<select id="queryMaterial" resultType="com.nflg.product.bomnew.pojo.vo.MaterialQueryResult"> <select id="queryMaterial" resultType="com.nflg.product.bomnew.pojo.vo.MaterialQueryResult">
select material_no,drawing_no, material_name,material_desc,material_unit, material_state from t_material_main where 1=1 select material_no,drawing_no, material_name,material_desc,material_unit, material_state
<choose>
<when test="query.materialNo != null and query.materialNo != ''" >
,REPLACE(material_no,IFNULL(#{query.materialNo},''),'0') as orderMaterialNo
</when>
<when test="query.drawingNo != null and query.drawingNo != ''">
,REPLACE(drawing_no,IFNULL(#{query.drawingNo},''),'0') as orderDrawingNo
</when>
<when test="query.materialDesc != null and query.materialDesc != ''">
,REPLACE(material_desc,IFNULL(#{query.materialDesc},''),'0') as orderMaterialDesc
</when>
</choose>
from t_material_main where 1=1
<if test="query.materialCategoryCode != null and query.materialCategoryCode != ''"> <if test="query.materialCategoryCode != null and query.materialCategoryCode != ''">
and material_category_code = #{query.materialCategoryCode} and material_category_code = #{query.materialCategoryCode}
</if> </if>
<if test="query.materialNo != null and query.materialNo != ''"> <if test="query.materialNo != null and query.materialNo != ''">
and material_no like concat('%',#{query.materialNo},'%') and material_no like concat(#{query.materialNo},'%')
</if> </if>
<if test="query.drawingNo != null and query.drawingNo != ''"> <if test="query.drawingNo != null and query.drawingNo != ''">
and drawing_no like concat('%',#{query.drawingNo},'%') and drawing_no like concat(#{query.drawingNo},'%')
</if> </if>
<if test="query.materialDesc != null and query.materialDesc != ''"> <if test="query.materialDesc != null and query.materialDesc != ''">
and material_desc like concat('%',#{query.materialDesc},'%') and material_desc like concat('%',#{query.materialDesc},'%')
</if> </if>
order by orderMfiled
</select> </select>
</mapper> </mapper>