增加商品按条码 名称 规格查询的接口
This commit is contained in:
@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.datasource.entities.MaterialInitialStockWithMaterial;
|
||||
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
||||
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.depotItem.DepotItemService;
|
||||
import com.jsh.erp.service.material.MaterialService;
|
||||
@@ -165,6 +166,29 @@ public class MaterialController {
|
||||
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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.jsh.erp.datasource.mappers;
|
||||
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.vo.MaterialVoSearch;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -52,6 +53,8 @@ public interface MaterialMapperEx {
|
||||
|
||||
List<MaterialVo4Unit> findByIdWithBarCode(@Param("meId") Long meId);
|
||||
|
||||
List<MaterialVoSearch> getMaterialByParam(@Param("materialParam") String materialParam);
|
||||
|
||||
List<MaterialVo4Unit> findBySelectWithBarCode(@Param("idList") List<Long> idList,
|
||||
@Param("q") String q,
|
||||
@Param("enableSerialNumber") String enableSerialNumber,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.jsh.erp.constants.BusinessConstants;
|
||||
import com.jsh.erp.constants.ExceptionConstants;
|
||||
import com.jsh.erp.datasource.entities.*;
|
||||
import com.jsh.erp.datasource.mappers.*;
|
||||
import com.jsh.erp.datasource.vo.MaterialVoSearch;
|
||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||
import com.jsh.erp.exception.JshException;
|
||||
import com.jsh.erp.service.depot.DepotService;
|
||||
@@ -391,6 +392,33 @@ public class MaterialService {
|
||||
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,
|
||||
String enableBatchNumber, Integer offset, Integer rows)throws Exception{
|
||||
List<MaterialVo4Unit> list =null;
|
||||
|
||||
Reference in New Issue
Block a user