二级搜索左侧根据部门搜索,统计浏览统计接口
This commit is contained in:
parent
767968d01f
commit
19bbf0f606
|
@ -15,7 +15,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
|
@ -58,4 +58,6 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
|||
Integer selectTypeCountByDept(@Param("deptType") String deptType, @Param("resourceType") String resourceType);
|
||||
|
||||
List<ResourceDTO> selectAlgorithmPage(Map<String, Object> params);
|
||||
|
||||
Integer selectTypeCountByDist(@Param(("districtName")) String districtName, @Param("resourceType") String resourceType);
|
||||
}
|
|
@ -40,6 +40,7 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
|
|||
Object selectRecommend();
|
||||
|
||||
Object selectDeptList(JSONObject jsonObject);
|
||||
|
||||
List<Map<String, Object>> getAmountGroupByType();
|
||||
|
||||
Long countAllDept();
|
||||
|
|
|
@ -17,6 +17,8 @@ import io.renren.modules.resource.entity.AttrEntity;
|
|||
import io.renren.modules.resource.entity.ResourceEntity;
|
||||
import io.renren.modules.resource.entity.ResourceEntityDelFlag;
|
||||
import io.renren.modules.resource.service.ResourceService;
|
||||
import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao;
|
||||
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
|
||||
import io.renren.modules.resourceCar.dao.ResourceCarDao;
|
||||
import io.renren.modules.resourceCollection.dao.ResourceCollectionDao;
|
||||
import io.renren.modules.resourceScore.dao.ResourceScoreDao;
|
||||
|
@ -57,6 +59,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
@Autowired
|
||||
private AttrDao attrDao;
|
||||
|
||||
@Autowired
|
||||
private ResourceBrowseDao resourceBrowseDao;
|
||||
|
||||
@Override
|
||||
public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params) {
|
||||
QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>();
|
||||
|
@ -248,6 +253,12 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
.eq(ResourceEntity::getId, resourceEntity.getId())
|
||||
.eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
|
||||
resourceDao.update(entity, updateWrapper);
|
||||
|
||||
ResourceBrowseEntity browseEntity = new ResourceBrowseEntity();
|
||||
browseEntity.setResourceId(id);
|
||||
browseEntity.setUserId(SecurityUser.getUserId());
|
||||
browseEntity.setState(0);
|
||||
resourceBrowseDao.insert(browseEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -311,23 +322,43 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
HashMap<String, Object> resourceMap = new HashMap<>();
|
||||
resourceMap.put("type", "全部能力目录");
|
||||
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("del_flag", 0).eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"));
|
||||
queryWrapper.in(true,"del_flag", 0,5)
|
||||
.eq(StringUtils.isNotBlank(jsonObject.getString("type")), "type", jsonObject.getString("type"));
|
||||
resourceMap.put("total", resourceDao.selectCount(queryWrapper));
|
||||
//resourceMap.put("dataList", resourceDao.selectList(queryWrapper));
|
||||
resultList.add(resourceMap);
|
||||
List<Map<String, Object>> typeMapList = resourceDao.selectGroupByDeptId(jsonObject.getString("type"));
|
||||
Map<String, List<Map<String, Object>>> listMap = typeMapList.stream()
|
||||
.collect(Collectors.groupingBy(m -> m.get("type").toString()));
|
||||
listMap.entrySet().stream().forEach(item -> {
|
||||
HashMap<Object, Object> map = new HashMap<>();
|
||||
//区级要根据行政区划多加一层结构
|
||||
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).forEach(item -> {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("type", item.getKey());
|
||||
map.put("total", resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")));
|
||||
item.getValue().stream().forEach(item1 -> {
|
||||
item.getValue().forEach(item1 -> {
|
||||
item1.remove("type");
|
||||
});
|
||||
map.put("dataList", item.getValue());
|
||||
resultList.add(map);
|
||||
});
|
||||
List<Map<String, Object>> areaList = listMap.get("区级");
|
||||
Map<String, List<Map<String, Object>>> areaTypeList = areaList.stream()
|
||||
.collect(Collectors.groupingBy(m -> m.get("districtName").toString()));
|
||||
HashMap<Object, Object> areaMap = new HashMap<>();
|
||||
areaMap.put("type", "区级");
|
||||
areaMap.put("total", resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type")));
|
||||
ArrayList<Map> areaListTemp = new ArrayList<>();
|
||||
areaTypeList.entrySet().stream().forEach(item -> {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("type", item.getKey());
|
||||
map.put("total", resourceDao.selectTypeCountByDist(item.getKey(), jsonObject.getString("type")));
|
||||
item.getValue().forEach(item1 -> {
|
||||
item1.remove("type");
|
||||
});
|
||||
map.put("dataList", item.getValue());
|
||||
areaListTemp.add(map);
|
||||
});
|
||||
areaMap.put("dataList", areaListTemp);
|
||||
resultList.add(areaMap);
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@
|
|||
sd.name AS "deptName",
|
||||
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
||||
IFNULL(taa2.approve_status, '未申请') AS "applyState",
|
||||
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)+ IFNULL(collectCount,0)) AS total
|
||||
(IFNULL(visits / 100, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0) + IFNULL(collectCount,0)) AS total
|
||||
FROM
|
||||
tb_data_resource tdr
|
||||
LEFT JOIN ( SELECT resource_id, AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0 GROUP
|
||||
|
@ -355,14 +355,16 @@
|
|||
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
|
||||
sd.NAME AS "deptName",
|
||||
IFNULL( tdr.deptCount, 0 ) AS "deptCount",
|
||||
sd.id AS "deptId"
|
||||
sd.id AS "deptId",
|
||||
sr.name AS "districtName"
|
||||
FROM
|
||||
sys_dept sd
|
||||
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0
|
||||
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag IN (0 ,5)
|
||||
<if test="type != null and type != ''">
|
||||
AND type = #{type}
|
||||
</if>
|
||||
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
|
||||
LEFT JOIN sys_region sr ON sd.district = sr.id
|
||||
) temp1
|
||||
WHERE
|
||||
1 = 1
|
||||
|
@ -384,7 +386,7 @@
|
|||
IFNULL( tdr.deptCount, 0 ) AS "deptCount"
|
||||
FROM
|
||||
sys_dept sd
|
||||
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag = 0
|
||||
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource WHERE 1 = 1 AND del_flag IN (0, 5)
|
||||
<if test="resourceType != null and resourceType != ''">
|
||||
AND type = #{resourceType}
|
||||
</if>
|
||||
|
@ -408,4 +410,38 @@
|
|||
LIMIT ${pageNum}, ${pageSize}
|
||||
</select>
|
||||
|
||||
<select id="selectTypeCountByDist" resultType="java.lang.Integer">
|
||||
SELECT
|
||||
SUM( deptCount )
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
|
||||
sd.NAME AS "deptName",
|
||||
IFNULL( tdr.deptCount, 0) AS "deptCount",
|
||||
IFNULL(sr.name, '暂无该地区') AS "districtName"
|
||||
FROM
|
||||
sys_dept sd
|
||||
LEFT JOIN ( SELECT dept_id, COUNT( id ) AS "deptCount" FROM tb_data_resource
|
||||
WHERE 1 = 1 AND del_flag IN (0, 5)
|
||||
<if test="resourceType != null and resourceType != ''">
|
||||
AND type = #{resourceType}
|
||||
</if>
|
||||
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
|
||||
LEFT JOIN sys_region sr ON sd.district = sr.id
|
||||
) temp1
|
||||
WHERE
|
||||
1 = 1
|
||||
AND temp1.deptCount != 0
|
||||
) temp2
|
||||
WHERE 1 = 1
|
||||
AND temp2.districtName = #{districtName}
|
||||
GROUP BY
|
||||
temp2.type
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue