@@ -42,7 +42,7 @@ public class StatisticsController extends BaseController { | |||
List<TauvCategory> categoryList = categoryService.getChildrenList(0); | |||
if (StringUtils.isNotEmpty(categoryList)) { | |||
for (TauvCategory category : categoryList) { | |||
Integer questionNum = inspectImageMapper.getQuestionNum(category.getId()); | |||
Integer questionNum = inspectImageMapper.getQuestionNum(category.getId(), query); | |||
category.setQuestionNum(questionNum); | |||
totalNum += questionNum; | |||
@@ -2,6 +2,7 @@ package com.taauav.admin.controller; | |||
import com.taauav.admin.entity.TauvCategory; | |||
import com.taauav.admin.query.StatisticsQuery; | |||
import com.taauav.admin.service.ITauvCategoryService; | |||
import com.taauav.common.bean.Response; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
@@ -29,9 +30,9 @@ public class TauvCategoryController extends BaseController { | |||
* | |||
* @return | |||
*/ | |||
@GetMapping("/index") | |||
public Response index() { | |||
return categoryService.getList(); | |||
@PostMapping("/index") | |||
public Response index(@RequestBody StatisticsQuery query) { | |||
return categoryService.getList(query); | |||
} | |||
/** |
@@ -5,11 +5,7 @@ import com.taauav.admin.query.TauvInspectImageQuery; | |||
import com.taauav.admin.service.ITauvInspectImageService; | |||
import com.taauav.common.bean.Response; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.PostMapping; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import org.springframework.web.bind.annotation.*; | |||
/** | |||
* <p> | |||
@@ -37,4 +33,14 @@ public class TauvInspectImageController extends BaseController { | |||
return inspectImageService.getList(inspectImageQuery); | |||
} | |||
/** | |||
* 获取巡检公路名称 | |||
* | |||
* @return | |||
*/ | |||
@GetMapping("/getNameList") | |||
public Response getNameList() { | |||
return inspectImageService.getNameList(); | |||
} | |||
} |
@@ -3,9 +3,14 @@ package com.taauav.admin.mapper; | |||
import com.baomidou.mybatisplus.core.metadata.IPage; | |||
import com.taauav.admin.entity.TauvInspectImage; | |||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; | |||
import com.taauav.admin.query.StatisticsQuery; | |||
import com.taauav.admin.query.TauvInspectImageQuery; | |||
import com.taauav.admin.vo.InspectNameListVo; | |||
import org.springframework.web.bind.annotation.RequestParam; | |||
import java.util.List; | |||
/** | |||
* <p> | |||
* 巡检图片表 Mapper 接口 | |||
@@ -27,9 +32,17 @@ public interface TauvInspectImageMapper extends BaseMapper<TauvInspectImage> { | |||
/** | |||
* 根据分类获取 | |||
* | |||
* @param categoryId | |||
* @return | |||
*/ | |||
Integer getQuestionNum(Integer categoryId); | |||
Integer getQuestionNum(Integer categoryId, @RequestParam("param") StatisticsQuery param); | |||
/** | |||
* 获取巡检公路名称列表 | |||
* | |||
* @return | |||
*/ | |||
List<InspectNameListVo> getNameList(); | |||
} |
@@ -21,7 +21,15 @@ | |||
<!-- 根据分类统计图片数量 --> | |||
<select id="getQuestionNum" resultType="Integer"> | |||
SELECT count(*) as questionNum FROM tauv_inspect_image WHERE find_in_set(#{categoryId}, category_id) AND mark=1; | |||
SELECT count(*) as questionNum FROM tauv_inspect_image WHERE find_in_set(#{categoryId}, category_id) AND mark=1 | |||
<if test="param.name != null and param.name != ''"> | |||
and name like CONCAT('%',#{param.name},'%') | |||
</if> | |||
</select> | |||
<!-- 根据分类统计图片数量 --> | |||
<select id="getNameList" resultType="com.taauav.admin.vo.InspectNameListVo"> | |||
SELECT DISTINCT(`name`) FROM tauv_inspect_image WHERE mark=1; | |||
</select> | |||
</mapper> |
@@ -1,6 +1,7 @@ | |||
package com.taauav.admin.service; | |||
import com.taauav.admin.entity.TauvCategory; | |||
import com.taauav.admin.query.StatisticsQuery; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.common.service.IBaseService; | |||
@@ -21,7 +22,7 @@ public interface ITauvCategoryService extends IBaseService<TauvCategory> { | |||
* | |||
* @return | |||
*/ | |||
Response getList(); | |||
Response getList(StatisticsQuery query); | |||
/** | |||
* 添加或编辑分类 |
@@ -23,4 +23,11 @@ public interface ITauvInspectImageService extends IService<TauvInspectImage> { | |||
*/ | |||
Response getList(TauvInspectImageQuery inspectImageQuery); | |||
/** | |||
* 获取巡检名称列表 | |||
* | |||
* @return | |||
*/ | |||
Response getNameList(); | |||
} |
@@ -6,12 +6,14 @@ import com.taauav.admin.entity.SysLevel; | |||
import com.taauav.admin.entity.TauvCategory; | |||
import com.taauav.admin.mapper.TauvCategoryMapper; | |||
import com.taauav.admin.mapper.TauvInspectImageMapper; | |||
import com.taauav.admin.query.StatisticsQuery; | |||
import com.taauav.admin.service.ITauvCategoryService; | |||
import com.taauav.common.bean.Response; | |||
import com.taauav.common.service.impl.BaseServiceImpl; | |||
import com.taauav.common.util.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
import org.springframework.web.bind.annotation.RequestBody; | |||
import javax.annotation.Resource; | |||
import javax.validation.ConstraintViolation; | |||
@@ -45,7 +47,7 @@ public class TauvCategoryServiceImpl extends BaseServiceImpl<TauvCategoryMapper, | |||
* @return | |||
*/ | |||
@Override | |||
public Response getList() { | |||
public Response getList(StatisticsQuery query) { | |||
// 查询条件 | |||
QueryWrapper<TauvCategory> queryWrapper = new QueryWrapper<>(); | |||
queryWrapper.eq("mark", 1); | |||
@@ -53,7 +55,7 @@ public class TauvCategoryServiceImpl extends BaseServiceImpl<TauvCategoryMapper, | |||
List<TauvCategory> categoryList = list(queryWrapper); | |||
categoryList.forEach(item -> { | |||
// 获取分类问题数量 | |||
Integer questionNum = inspectImageMapper.getQuestionNum(item.getId()); | |||
Integer questionNum = inspectImageMapper.getQuestionNum(item.getId(), query); | |||
item.setQuestionNum(questionNum); | |||
}); | |||
return response.success("操作成功", categoryList); |
@@ -77,4 +77,14 @@ public class TauvInspectImageServiceImpl extends ServiceImpl<TauvInspectImageMap | |||
}); | |||
return response.success(pageData); | |||
} | |||
/** | |||
* 获取巡检公路名称 | |||
* | |||
* @return | |||
*/ | |||
@Override | |||
public Response getNameList() { | |||
return response.success(inspectImageMapper.getNameList()); | |||
} | |||
} |
@@ -0,0 +1,16 @@ | |||
package com.taauav.admin.vo; | |||
import lombok.Data; | |||
/** | |||
* 巡检公路名称 | |||
*/ | |||
@Data | |||
public class InspectNameListVo { | |||
/** | |||
* 巡检公路名称 | |||
*/ | |||
private String name; | |||
} |