优化商品查询功能
This commit is contained in:
@@ -215,11 +215,13 @@ public class MaterialController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/findByOrder")
|
||||
public BaseResponseInfo findByOrder(HttpServletRequest request)throws Exception {
|
||||
public BaseResponseInfo findByOrder(@RequestParam("name") String name,
|
||||
@RequestParam("model") String model,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
try {
|
||||
List<Material> dataList = materialService.findByOrder();
|
||||
List<Material> dataList = materialService.findByOrder(StringUtil.toNull(name), StringUtil.toNull(model));
|
||||
String mId = "";
|
||||
if (null != dataList) {
|
||||
for (Material material : dataList) {
|
||||
@@ -458,4 +460,48 @@ public class MaterialController {
|
||||
res.data = map;
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品名称模糊匹配
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getMaterialNameList")
|
||||
public JSONArray getMaterialNameList() throws Exception {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<String> list = materialService.getMaterialNameList();
|
||||
for (String s : list) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("value", s);
|
||||
item.put("text", s);
|
||||
arr.add(item);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品型号模糊匹配
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getMaterialModelList")
|
||||
public JSONArray getMaterialModelList() throws Exception {
|
||||
JSONArray arr = new JSONArray();
|
||||
try {
|
||||
List<String> list = materialService.getMaterialModelList();
|
||||
for (String s : list) {
|
||||
JSONObject item = new JSONObject();
|
||||
item.put("value", s);
|
||||
item.put("text", s);
|
||||
arr.add(item);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,4 +74,11 @@ public interface MaterialMapperEx {
|
||||
|
||||
List<MaterialVo4Unit> getMaterialByMeId(
|
||||
@Param("meId") Long meId);
|
||||
|
||||
List<String> getMaterialNameList();
|
||||
|
||||
List<String> getMaterialModelList();
|
||||
|
||||
List<Material> findByOrder(@Param("name") String name,
|
||||
@Param("model") String model);
|
||||
}
|
||||
|
||||
@@ -327,13 +327,10 @@ public class MaterialService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<Material> findByOrder()throws Exception{
|
||||
MaterialExample example = new MaterialExample();
|
||||
example.createCriteria().andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
|
||||
example.setOrderByClause("Name,Model asc");
|
||||
public List<Material> findByOrder(String name, String model)throws Exception{
|
||||
List<Material> list =null;
|
||||
try{
|
||||
list= materialMapper.selectByExample(example);
|
||||
list= materialMapperEx.findByOrder(name, model);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
@@ -729,4 +726,12 @@ public class MaterialService {
|
||||
String maxBarCodeOld = materialMapperEx.getMaxBarCode();
|
||||
return Long.parseLong(maxBarCodeOld)+"";
|
||||
}
|
||||
|
||||
public List<String> getMaterialNameList() {
|
||||
return materialMapperEx.getMaterialNameList();
|
||||
}
|
||||
|
||||
public List<String> getMaterialModelList() {
|
||||
return materialMapperEx.getMaterialModelList();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user