增加‘商品类别’的筛选功能
This commit is contained in:
@@ -192,7 +192,6 @@ public class MaterialController {
|
||||
* 生成excel表格
|
||||
* @param name
|
||||
* @param model
|
||||
* @param categoryId
|
||||
* @param categoryIds
|
||||
* @param request
|
||||
* @param response
|
||||
@@ -201,14 +200,13 @@ public class MaterialController {
|
||||
@GetMapping(value = "/exportExcel")
|
||||
public BaseResponseInfo exportExcel(@RequestParam("name") String name,
|
||||
@RequestParam("model") String model,
|
||||
@RequestParam("categoryId") Long categoryId,
|
||||
@RequestParam("categoryIds") String categoryIds,
|
||||
HttpServletRequest request, HttpServletResponse response)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
String message = "成功";
|
||||
try {
|
||||
List<MaterialVo4Unit> dataList = materialService.findByAll(name, model, categoryId, categoryIds);
|
||||
List<MaterialVo4Unit> dataList = materialService.findByAll(name, model, categoryIds);
|
||||
String[] names = {"品名", "类型", "型号", "安全存量", "单位", "零售价", "最低售价", "预计采购价", "批发价", "备注", "状态"};
|
||||
String title = "商品信息";
|
||||
List<String[]> objects = new ArrayList<String[]>();
|
||||
|
||||
@@ -20,7 +20,6 @@ public interface MaterialMapperEx {
|
||||
List<MaterialVo4Unit> selectByConditionMaterial(
|
||||
@Param("name") String name,
|
||||
@Param("model") String model,
|
||||
@Param("categoryId") Long categoryId,
|
||||
@Param("categoryIds") String categoryIds,
|
||||
@Param("mpList") String mpList,
|
||||
@Param("offset") Integer offset,
|
||||
@@ -29,7 +28,6 @@ public interface MaterialMapperEx {
|
||||
Long countsByMaterial(
|
||||
@Param("name") String name,
|
||||
@Param("model") String model,
|
||||
@Param("categoryId") Long categoryId,
|
||||
@Param("categoryIds") String categoryIds,
|
||||
@Param("mpList") String mpList);
|
||||
|
||||
@@ -46,7 +44,6 @@ public interface MaterialMapperEx {
|
||||
List<MaterialVo4Unit> findByAll(
|
||||
@Param("name") String name,
|
||||
@Param("model") String model,
|
||||
@Param("categoryId") Long categoryId,
|
||||
@Param("categoryIds") String categoryIds);
|
||||
/**
|
||||
* 通过商品名称查询商品信息
|
||||
|
||||
@@ -34,11 +34,10 @@ public class MaterialComponent implements ICommonQuery {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String model = StringUtil.getInfo(search, "model");
|
||||
Long categoryId = Long.parseLong(StringUtil.getInfo(search, "categoryId"));
|
||||
String categoryIds = StringUtil.getInfo(search, "categoryIds");
|
||||
String mpList = StringUtil.getInfo(search, "mpList");
|
||||
String order = QueryUtils.order(map);
|
||||
return materialService.select(name, model,categoryId,categoryIds,mpList, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
return materialService.select(name, model,categoryIds,mpList, QueryUtils.offset(map), QueryUtils.rows(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,10 +45,9 @@ public class MaterialComponent implements ICommonQuery {
|
||||
String search = map.get(Constants.SEARCH);
|
||||
String name = StringUtil.getInfo(search, "name");
|
||||
String model = StringUtil.getInfo(search, "model");
|
||||
Long categoryId = Long.parseLong(StringUtil.getInfo(search, "categoryId"));
|
||||
String categoryIds = StringUtil.getInfo(search, "categoryIds");
|
||||
String mpList = StringUtil.getInfo(search, "mpList");
|
||||
return materialService.countMaterial(name, model,categoryId,categoryIds,mpList);
|
||||
return materialService.countMaterial(name, model,categoryIds,mpList);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -70,13 +70,13 @@ public class MaterialService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> select(String name, String model,Long categoryId, String categoryIds,String mpList, int offset, int rows)
|
||||
public List<MaterialVo4Unit> select(String name, String model, String categoryIds,String mpList, int offset, int rows)
|
||||
throws Exception{
|
||||
String[] mpArr = mpList.split(",");
|
||||
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
|
||||
List<MaterialVo4Unit> list =null;
|
||||
try{
|
||||
list= materialMapperEx.selectByConditionMaterial(name, model,categoryId,categoryIds,mpList, offset, rows);
|
||||
list= materialMapperEx.selectByConditionMaterial(name, model,categoryIds,mpList, offset, rows);
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||
@@ -117,10 +117,10 @@ public class MaterialService {
|
||||
return resList;
|
||||
}
|
||||
|
||||
public Long countMaterial(String name, String model,Long categoryId, String categoryIds,String mpList)throws Exception {
|
||||
public Long countMaterial(String name, String model, String categoryIds,String mpList)throws Exception {
|
||||
Long result =null;
|
||||
try{
|
||||
result= materialMapperEx.countsByMaterial(name, model,categoryId,categoryIds,mpList);
|
||||
result= materialMapperEx.countsByMaterial(name, model,categoryIds,mpList);
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||
@@ -320,11 +320,11 @@ public class MaterialService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<MaterialVo4Unit> findByAll(String name, String model, Long categoryId, String categoryIds)throws Exception {
|
||||
public List<MaterialVo4Unit> findByAll(String name, String model, String categoryIds)throws Exception {
|
||||
List<MaterialVo4Unit> resList = new ArrayList<MaterialVo4Unit>();
|
||||
List<MaterialVo4Unit> list =null;
|
||||
try{
|
||||
list= materialMapperEx.findByAll(name, model, categoryId, categoryIds);
|
||||
list= materialMapperEx.findByAll(name, model, categoryIds);
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||
|
||||
@@ -22,6 +22,7 @@ import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -68,12 +69,9 @@ public class MaterialCategoryService {
|
||||
}
|
||||
|
||||
public List<MaterialCategory> getAllList(Long parentId)throws Exception {
|
||||
MaterialCategoryExample example = new MaterialCategoryExample();
|
||||
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
|
||||
example.setOrderByClause("id");
|
||||
List<MaterialCategory> list=null;
|
||||
try{
|
||||
list=materialCategoryMapper.selectByExample(example);
|
||||
list = getMCList(parentId);
|
||||
}catch(Exception e){
|
||||
logger.error("异常码[{}],异常提示[{}],异常[{}]",
|
||||
ExceptionConstants.DATA_READ_FAIL_CODE,ExceptionConstants.DATA_READ_FAIL_MSG,e);
|
||||
@@ -83,6 +81,25 @@ public class MaterialCategoryService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<MaterialCategory> getMCList(Long parentId)throws Exception {
|
||||
List<MaterialCategory> res= new ArrayList<MaterialCategory>();
|
||||
List<MaterialCategory> list=null;
|
||||
MaterialCategoryExample example = new MaterialCategoryExample();
|
||||
example.createCriteria().andParentidEqualTo(parentId).andIdNotEqualTo(1l);
|
||||
example.setOrderByClause("id");
|
||||
list=materialCategoryMapper.selectByExample(example);
|
||||
if(list!=null && list.size()>0) {
|
||||
res.addAll(list);
|
||||
for(MaterialCategory mc : list) {
|
||||
List<MaterialCategory> mcList = getMCList(mc.getId());
|
||||
if(mcList!=null && mcList.size()>0) {
|
||||
res.addAll(mcList);
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
public List<MaterialCategory> select(String name, Integer parentId, int offset, int rows) throws Exception{
|
||||
List<MaterialCategory> list=null;
|
||||
try{
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<if test="model != null">
|
||||
and m.model like '%${model}%'
|
||||
</if>
|
||||
<if test="categoryId != 1">
|
||||
<if test="categoryIds != null">
|
||||
and m.CategoryId in (${categoryIds})
|
||||
</if>
|
||||
and ifnull(m.delete_Flag,'0') !='1'
|
||||
@@ -45,7 +45,7 @@
|
||||
<if test="model != null">
|
||||
and m.model like '%${model}%'
|
||||
</if>
|
||||
<if test="categoryId != 1">
|
||||
<if test="categoryIds != null">
|
||||
and m.CategoryId in (${categoryIds})
|
||||
</if>
|
||||
and ifnull(m.delete_Flag,'0') !='1'
|
||||
@@ -102,7 +102,7 @@
|
||||
<if test="model != null">
|
||||
and m.model like '%${model}%'
|
||||
</if>
|
||||
<if test="categoryId != 1">
|
||||
<if test="categoryIds != null">
|
||||
and m.CategoryId in (${categoryIds})
|
||||
</if>
|
||||
and ifnull(m.delete_Flag,'0') !='1'
|
||||
|
||||
Reference in New Issue
Block a user