增加商品按条码 名称 规格查询的接口

This commit is contained in:
季圣华
2023-03-23 01:20:40 +08:00
parent 7a3042eebc
commit d0396d7ee4
5 changed files with 132 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.datasource.entities.MaterialInitialStockWithMaterial; import com.jsh.erp.datasource.entities.MaterialInitialStockWithMaterial;
import com.jsh.erp.datasource.entities.MaterialVo4Unit; import com.jsh.erp.datasource.entities.MaterialVo4Unit;
import com.jsh.erp.datasource.entities.Unit; import com.jsh.erp.datasource.entities.Unit;
import com.jsh.erp.datasource.vo.MaterialVoSearch;
import com.jsh.erp.service.depot.DepotService; import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.depotItem.DepotItemService; import com.jsh.erp.service.depotItem.DepotItemService;
import com.jsh.erp.service.material.MaterialService; import com.jsh.erp.service.material.MaterialService;
@@ -165,6 +166,29 @@ public class MaterialController {
return res; return res;
} }
/**
* 根据关键词查找商品信息-条码、名称、规格、型号
* @param q
* @param request
* @return
*/
@GetMapping(value = "/getMaterialByParam")
@ApiOperation(value = "根据关键词查找商品信息")
public BaseResponseInfo getMaterialByParam(@RequestParam("q") String q,
HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo();
try {
JSONArray arr = materialService.getMaterialByParam(q);
res.code = 200;
res.data = arr;
} catch (Exception e) {
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/** /**
* 查找商品信息-下拉框 * 查找商品信息-下拉框
* @param mpList * @param mpList

View File

@@ -1,6 +1,7 @@
package com.jsh.erp.datasource.mappers; package com.jsh.erp.datasource.mappers;
import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.vo.MaterialVoSearch;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal; import java.math.BigDecimal;
@@ -52,6 +53,8 @@ public interface MaterialMapperEx {
List<MaterialVo4Unit> findByIdWithBarCode(@Param("meId") Long meId); List<MaterialVo4Unit> findByIdWithBarCode(@Param("meId") Long meId);
List<MaterialVoSearch> getMaterialByParam(@Param("materialParam") String materialParam);
List<MaterialVo4Unit> findBySelectWithBarCode(@Param("idList") List<Long> idList, List<MaterialVo4Unit> findBySelectWithBarCode(@Param("idList") List<Long> idList,
@Param("q") String q, @Param("q") String q,
@Param("enableSerialNumber") String enableSerialNumber, @Param("enableSerialNumber") String enableSerialNumber,

View File

@@ -0,0 +1,64 @@
package com.jsh.erp.datasource.vo;
public class MaterialVoSearch {
private String barCode;
private String name;
private String standard;
private String model;
private String color;
private String unit;
public String getBarCode() {
return barCode;
}
public void setBarCode(String barCode) {
this.barCode = barCode;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStandard() {
return standard;
}
public void setStandard(String standard) {
this.standard = standard;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public String getUnit() {
return unit;
}
public void setUnit(String unit) {
this.unit = unit;
}
}

View File

@@ -7,6 +7,7 @@ import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.*; import com.jsh.erp.datasource.mappers.*;
import com.jsh.erp.datasource.vo.MaterialVoSearch;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException; import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.depot.DepotService; import com.jsh.erp.service.depot.DepotService;
@@ -391,6 +392,33 @@ public class MaterialService {
return idList; return idList;
} }
public JSONArray getMaterialByParam(String materialParam) {
JSONArray arr = new JSONArray();
List<MaterialVoSearch> list = materialMapperEx.getMaterialByParam(materialParam);
for(MaterialVoSearch item: list) {
JSONObject obj = new JSONObject();
StringBuilder sb = new StringBuilder();
sb.append(item.getBarCode());
sb.append("_").append(item.getName());
if(StringUtil.isNotEmpty(item.getStandard())) {
sb.append("(").append(item.getStandard()).append(")");
}
if(StringUtil.isNotEmpty(item.getModel())) {
sb.append("(").append(item.getModel()).append(")");
}
if(StringUtil.isNotEmpty(item.getColor())) {
sb.append("(").append(item.getColor()).append(")");
}
if(StringUtil.isNotEmpty(item.getUnit())) {
sb.append("(").append(item.getUnit()).append(")");
}
obj.put("barCode", item.getBarCode());
obj.put("materialStr", sb.toString());
arr.add(obj);
}
return arr;
}
public List<MaterialVo4Unit> findBySelectWithBarCode(Long categoryId, String q, String enableSerialNumber, public List<MaterialVo4Unit> findBySelectWithBarCode(Long categoryId, String q, String enableSerialNumber,
String enableBatchNumber, Integer offset, Integer rows)throws Exception{ String enableBatchNumber, Integer offset, Integer rows)throws Exception{
List<MaterialVo4Unit> list =null; List<MaterialVo4Unit> list =null;

View File

@@ -297,6 +297,19 @@
and ifnull(m.delete_flag,'0') !='1' and ifnull(m.delete_flag,'0') !='1'
</select> </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
from jsh_material m
left join jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
where 1=1
<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})
</if>
and ifnull(m.delete_flag,'0') !='1'
limit 0,20
</select>
<select id="findBySelectWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap"> <select id="findBySelectWithBarCode" parameterType="com.jsh.erp.datasource.entities.MaterialExample" resultMap="ResultAndUnitMap">
select m.*,u.name unit_name,mc.name categoryName,me.bar_code m_bar_code,me.id meId,me.commodity_unit,me.sku from jsh_material m select m.*,u.name unit_name,mc.name categoryName,me.bar_code m_bar_code,me.id meId,me.commodity_unit,me.sku from jsh_material m
left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1' left join jsh_material_extend me on m.id=me.material_id and ifnull(me.delete_Flag,'0') !='1'