完善商品查询参数,增加助记码等查询条件

This commit is contained in:
jishenghua 2024-10-05 00:47:20 +08:00
parent f153f63fd4
commit c8e3617318
5 changed files with 78 additions and 15 deletions

View File

@ -211,8 +211,12 @@ public class MaterialController {
@ApiOperation(value = "查找商品信息")
public JSONObject findBySelect(@RequestParam(value = "categoryId", required = false) Long categoryId,
@RequestParam(value = "q", required = false) String q,
@RequestParam(value = "standardOrModel", required = false) String standardOrModel,
@RequestParam(value = "mpList", required = false) String mpList,
@RequestParam(value = "depotId", required = false) Long depotId,
@RequestParam(value = "color", required = false) String color,
@RequestParam(value = "brand", required = false) String brand,
@RequestParam(value = "mfrs", required = false) String mfrs,
@RequestParam(value = "enableSerialNumber", required = false) String enableSerialNumber,
@RequestParam(value = "enableBatchNumber", required = false) String enableBatchNumber,
@RequestParam("page") Integer currentPage,
@ -224,10 +228,10 @@ public class MaterialController {
if(StringUtil.isNotEmpty(mpList)){
mpArr= mpList.split(",");
}
List<MaterialVo4Unit> dataList = materialService.findBySelectWithBarCode(categoryId, q, enableSerialNumber,
enableBatchNumber, (currentPage-1)*pageSize, pageSize);
int total = materialService.findBySelectWithBarCodeCount(categoryId, q, enableSerialNumber,
enableBatchNumber);
List<MaterialVo4Unit> dataList = materialService.findBySelectWithBarCode(categoryId, q, standardOrModel,
color, brand, mfrs, enableSerialNumber, enableBatchNumber, (currentPage-1)*pageSize, pageSize);
int total = materialService.findBySelectWithBarCodeCount(categoryId, q, standardOrModel,
color, brand, mfrs, enableSerialNumber, enableBatchNumber);
object.put("total", total);
JSONArray dataArray = new JSONArray();
//存放数据json数组
@ -258,10 +262,13 @@ public class MaterialController {
}
item.put("mBarCode", material.getmBarCode());
item.put("name", material.getName());
item.put("mnemonic", material.getMnemonic());
item.put("categoryName", material.getCategoryName());
item.put("standard", material.getStandard());
item.put("model", material.getModel());
item.put("color", material.getColor());
item.put("brand", material.getBrand());
item.put("mfrs", material.getMfrs());
item.put("unit", material.getCommodityUnit() + ratioStr);
item.put("sku", material.getSku());
item.put("enableSerialNumber", material.getEnableSerialNumber());

View File

@ -67,6 +67,10 @@ public interface MaterialMapperEx {
List<MaterialVo4Unit> findBySelectWithBarCode(@Param("idList") List<Long> idList,
@Param("q") String q,
@Param("standardOrModel") String standardOrModel,
@Param("color") String color,
@Param("brand") String brand,
@Param("mfrs") String mfrs,
@Param("enableSerialNumber") String enableSerialNumber,
@Param("enableBatchNumber") String enableBatchNumber,
@Param("offset") Integer offset,
@ -74,6 +78,10 @@ public interface MaterialMapperEx {
int findBySelectWithBarCodeCount(@Param("idList") List<Long> idList,
@Param("q") String q,
@Param("standardOrModel") String standardOrModel,
@Param("color") String color,
@Param("brand") String brand,
@Param("mfrs") String mfrs,
@Param("enableSerialNumber") String enableSerialNumber,
@Param("enableBatchNumber") String enableBatchNumber);

View File

@ -6,6 +6,8 @@ public class MaterialVoSearch {
private String name;
private String mnemonic;
private String standard;
private String model;
@ -30,6 +32,14 @@ public class MaterialVoSearch {
this.name = name;
}
public String getMnemonic() {
return mnemonic;
}
public void setMnemonic(String mnemonic) {
this.mnemonic = mnemonic;
}
public String getStandard() {
return standard;
}

View File

@ -409,6 +409,9 @@ public class MaterialService {
StringBuilder sb = new StringBuilder();
sb.append(item.getBarCode());
sb.append("_").append(item.getName());
if(StringUtil.isNotEmpty(item.getMnemonic())) {
sb.append("(").append(item.getMnemonic()).append(")");
}
if(StringUtil.isNotEmpty(item.getStandard())) {
sb.append("(").append(item.getStandard()).append(")");
}
@ -428,8 +431,9 @@ public class MaterialService {
return arr;
}
public List<MaterialVo4Unit> findBySelectWithBarCode(Long categoryId, String q, String enableSerialNumber,
String enableBatchNumber, Integer offset, Integer rows)throws Exception{
public List<MaterialVo4Unit> findBySelectWithBarCode(Long categoryId, String q, String standardOrModel, String color,
String brand, String mfrs, String enableSerialNumber, String enableBatchNumber,
Integer offset, Integer rows) throws Exception{
List<MaterialVo4Unit> list =null;
try{
List<Long> idList = new ArrayList<>();
@ -441,15 +445,16 @@ public class MaterialService {
q = q.replace("'", "");
q = q.trim();
}
list= materialMapperEx.findBySelectWithBarCode(idList, q, enableSerialNumber, enableBatchNumber, offset, rows);
list= materialMapperEx.findBySelectWithBarCode(idList, q, standardOrModel, color, brand, mfrs,
enableSerialNumber, enableBatchNumber, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findBySelectWithBarCodeCount(Long categoryId, String q, String enableSerialNumber,
String enableBatchNumber)throws Exception{
public int findBySelectWithBarCodeCount(Long categoryId, String q, String standardOrModel, String color,
String brand, String mfrs, String enableSerialNumber, String enableBatchNumber) throws Exception{
int result=0;
try{
List<Long> idList = new ArrayList<>();
@ -460,7 +465,8 @@ public class MaterialService {
if(StringUtil.isNotEmpty(q)) {
q = q.replace("'", "");
}
result = materialMapperEx.findBySelectWithBarCodeCount(idList, q, enableSerialNumber, enableBatchNumber);
result = materialMapperEx.findBySelectWithBarCodeCount(idList, q, standardOrModel, color, brand, mfrs,
enableSerialNumber, enableBatchNumber);
}catch(Exception e){
logger.error("异常码[{}],异常提示[{}],异常[{}]",
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);

View File

@ -357,13 +357,13 @@
</select>
<select id="getMaterialByParam" resultType="com.jsh.erp.datasource.vo.MaterialVoSearch">
select me.bar_code, m.name, m.standard, m.model, m.color, me.commodity_unit unit
select me.bar_code, m.name, m.mnemonic, m.standard, m.model, m.color, me.commodity_unit unit
from jsh_material m
left join jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
where m.enabled=1 and me.id is not null
<if test="materialParam != null and materialParam !=''">
<bind name="bindKey" value="'%'+materialParam+'%'"/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey})
</if>
and ifnull(m.delete_flag,'0') !='1'
order by m.id desc, me.default_flag desc, me.id asc
@ -378,7 +378,23 @@
where m.enabled=1 and me.id is not null
<if test="q != null and q !=''">
<bind name="bindKey" value="'%'+q+'%'"/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey} or m.color like #{bindKey})
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey})
</if>
<if test="standardOrModel != null and standardOrModel !=''">
<bind name="bindStandardOrModel" value="'%'+standardOrModel+'%'"/>
and (m.standard like #{bindStandardOrModel} or m.model like #{bindStandardOrModel})
</if>
<if test="color != null and color !=''">
<bind name="bindColor" value="'%'+color+'%'"/>
and m.color like #{bindColor}
</if>
<if test="brand != null and brand !=''">
<bind name="bindBrand" value="'%'+brand+'%'"/>
and m.brand like #{bindBrand}
</if>
<if test="mfrs != null and mfrs !=''">
<bind name="bindMfrs" value="'%'+mfrs+'%'"/>
and m.mfrs like #{bindMfrs}
</if>
<if test="idList.size()>0">
and m.category_id in
@ -404,9 +420,25 @@
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'
left join jsh_unit u on m.unit_id=u.id and ifnull(u.delete_Flag,'0') !='1'
where m.enabled=1 and me.id is not null
<if test="q != null">
<if test="q != null and q !=''">
<bind name="bindKey" value="'%'+q+'%'"/>
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.standard like #{bindKey} or m.model like #{bindKey})
and (me.bar_code like #{bindKey} or m.name like #{bindKey} or m.mnemonic like #{bindKey})
</if>
<if test="standardOrModel != null and standardOrModel !=''">
<bind name="bindStandardOrModel" value="'%'+standardOrModel+'%'"/>
and (m.standard like #{bindStandardOrModel} or m.model like #{bindStandardOrModel})
</if>
<if test="color != null and color !=''">
<bind name="bindColor" value="'%'+color+'%'"/>
and m.color like #{bindColor}
</if>
<if test="brand != null and brand !=''">
<bind name="bindBrand" value="'%'+brand+'%'"/>
and m.brand like #{bindBrand}
</if>
<if test="mfrs != null and mfrs !=''">
<bind name="bindMfrs" value="'%'+mfrs+'%'"/>
and m.mfrs like #{bindMfrs}
</if>
<if test="idList.size()>0">
and m.category_id in