统计2.0-组件服务排名
This commit is contained in:
parent
edda52f387
commit
44d99b4e21
|
@ -61,15 +61,7 @@ public class CensusController {
|
||||||
List<Map<String, Object>> dbAmount = resourceService.getAmountGroupByType();
|
List<Map<String, Object>> dbAmount = resourceService.getAmountGroupByType();
|
||||||
List<String> temp = dbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList());
|
List<String> temp = dbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList());
|
||||||
Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型
|
Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型
|
||||||
if (index.equals("知识库")) {
|
if (index.equals("数据资源")) {
|
||||||
Map<String, Object> nullMap = new HashMap<String, Object>() {
|
|
||||||
{
|
|
||||||
put("amount", 14);
|
|
||||||
put("type", "知识库");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
dbAmount.add(nullMap);
|
|
||||||
} else if (index.equals("数据资源")) {
|
|
||||||
Map<String, Object> nullMap = new HashMap<String, Object>() {
|
Map<String, Object> nullMap = new HashMap<String, Object>() {
|
||||||
{
|
{
|
||||||
put("amount", 10413);
|
put("amount", 10413);
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.util.stream.Collectors;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/census/center/v2")
|
@RequestMapping("/census/center/v2")
|
||||||
public class CensusControllerV2 {
|
public class CensusControllerV2 {
|
||||||
private static Logger logger = LoggerFactory.getLogger(CensusControllerV2.class);
|
private static final Logger logger = LoggerFactory.getLogger(CensusControllerV2.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ResourceService resourceService;
|
private ResourceService resourceService;
|
||||||
|
@ -289,4 +289,11 @@ public class CensusControllerV2 {
|
||||||
return new Result().ok(result);
|
return new Result().ok(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/componentServiceRank")
|
||||||
|
@ApiOperation("组件服务排名")
|
||||||
|
@LogOperation("组件服务排名")
|
||||||
|
public Result componentServiceRank(String type) {
|
||||||
|
return new Result().ok(resourceService.componentServiceRank(type));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -289,7 +289,6 @@ public class ResourceController {
|
||||||
HashMap map = JSONObject.parseObject(json, HashMap.class);
|
HashMap map = JSONObject.parseObject(json, HashMap.class);
|
||||||
return new Result().ok(map);
|
return new Result().ok(map);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
|
||||||
return new Result().ok(new HashMap<String, Object>() {{
|
return new Result().ok(new HashMap<String, Object>() {{
|
||||||
put("sxmlcount", 0);
|
put("sxmlcount", 0);
|
||||||
put("yfbfwcount", 0);
|
put("yfbfwcount", 0);
|
||||||
|
|
|
@ -106,4 +106,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
||||||
|
|
||||||
List<Map> selectAppAreaCountList();
|
List<Map> selectAppAreaCountList();
|
||||||
|
|
||||||
|
List<Map> selectTopFiveComponentServiceApplications();
|
||||||
|
|
||||||
|
List<Map> selectTopFiveComponentServiceScore();
|
||||||
}
|
}
|
|
@ -79,4 +79,6 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
|
||||||
* 同步知识库
|
* 同步知识库
|
||||||
*/
|
*/
|
||||||
void KnowledgeBase();
|
void KnowledgeBase();
|
||||||
|
|
||||||
|
Object componentServiceRank(String type);
|
||||||
}
|
}
|
|
@ -55,7 +55,9 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
|
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class);
|
private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class);
|
||||||
|
|
||||||
@Value("${zsk.appid}")
|
@Value("${zsk.appid}")
|
||||||
private String appId;
|
private String appId;
|
||||||
|
|
||||||
|
@ -250,7 +252,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
@Override
|
@Override
|
||||||
public Object selectTotal() {
|
public Object selectTotal() {
|
||||||
HashMap<String, Object> resultMap = new HashMap<>();
|
HashMap<String, Object> resultMap = new HashMap<>();
|
||||||
resultMap.put("total", resourceDao.selectTypeCount());
|
resultMap.put("total", resourceDao.selectTypeCount(null));
|
||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +293,6 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
.eq(ResourceEntity::getId, resourceEntity.getId())
|
.eq(ResourceEntity::getId, resourceEntity.getId())
|
||||||
.eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
|
.eq(ResourceEntity::getDelFlag, ResourceEntityDelFlag.NORMAL.getFlag());
|
||||||
resourceDao.update(entity, updateWrapper);
|
resourceDao.update(entity, updateWrapper);
|
||||||
|
|
||||||
ResourceBrowseEntity browseEntity = new ResourceBrowseEntity();
|
ResourceBrowseEntity browseEntity = new ResourceBrowseEntity();
|
||||||
browseEntity.setResourceId(id);
|
browseEntity.setResourceId(id);
|
||||||
browseEntity.setUserId(SecurityUser.getUserId());
|
browseEntity.setUserId(SecurityUser.getUserId());
|
||||||
|
@ -372,17 +373,21 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).forEach(item -> {
|
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).forEach(item -> {
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put("type", item.getKey());
|
map.put("type", item.getKey());
|
||||||
map.put("total", resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type")));
|
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
|
||||||
|
map.put("total", integer);
|
||||||
item.getValue().forEach(item1 -> item1.remove("type"));
|
item.getValue().forEach(item1 -> item1.remove("type"));
|
||||||
map.put("dataList", item.getValue());
|
map.put("dataList", item.getValue());
|
||||||
|
if (integer != 0) {
|
||||||
resultList.add(map);
|
resultList.add(map);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
Optional<List<Map<String, Object>>> areaList = Optional.ofNullable(listMap.get("区级"));
|
Optional<List<Map<String, Object>>> areaList = Optional.ofNullable(listMap.get("区级"));
|
||||||
Optional<Map<String, List<Map<String, Object>>>> areaTypeList = Optional.ofNullable(areaList.orElse(new ArrayList<>()).stream()
|
Optional<Map<String, List<Map<String, Object>>>> areaTypeList = Optional.ofNullable(areaList.orElse(new ArrayList<>()).stream()
|
||||||
.collect(Collectors.groupingBy(m -> m.get("districtName").toString())));
|
.collect(Collectors.groupingBy(m -> m.get("districtName").toString())));
|
||||||
HashMap<Object, Object> areaMap = new HashMap<>();
|
HashMap<Object, Object> areaMap = new HashMap<>();
|
||||||
areaMap.put("type", "区级");
|
areaMap.put("type", "区级");
|
||||||
areaMap.put("total", resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type")));
|
Integer integer = resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type"));
|
||||||
|
areaMap.put("total", integer);
|
||||||
ArrayList<Map> areaListTemp = new ArrayList<>();
|
ArrayList<Map> areaListTemp = new ArrayList<>();
|
||||||
areaTypeList.orElse(new HashMap<>()).forEach((key, value) -> {
|
areaTypeList.orElse(new HashMap<>()).forEach((key, value) -> {
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
|
@ -393,7 +398,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
areaListTemp.add(map);
|
areaListTemp.add(map);
|
||||||
});
|
});
|
||||||
areaMap.put("dataList", areaListTemp);
|
areaMap.put("dataList", areaListTemp);
|
||||||
|
if (integer != 0) {
|
||||||
resultList.add(areaMap);
|
resultList.add(areaMap);
|
||||||
|
}
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,4 +719,15 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object componentServiceRank(String type) {
|
||||||
|
switch (type) {
|
||||||
|
case "total":
|
||||||
|
return resourceDao.selectTopFiveComponentServiceApplications();
|
||||||
|
case "score":
|
||||||
|
return resourceDao.selectTopFiveComponentServiceScore();
|
||||||
|
default:
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
<mapper namespace="io.renren.modules.resource.dao.ResourceDao">
|
<mapper namespace="io.renren.modules.resource.dao.ResourceDao">
|
||||||
|
@ -179,6 +179,9 @@
|
||||||
FROM tb_data_resource
|
FROM tb_data_resource
|
||||||
WHERE 1 = 1
|
WHERE 1 = 1
|
||||||
AND del_flag = 0
|
AND del_flag = 0
|
||||||
|
<if test="type != null and type != ''">
|
||||||
|
AND type = #{type}
|
||||||
|
</if>
|
||||||
GROUP BY type
|
GROUP BY type
|
||||||
ORDER BY type
|
ORDER BY type
|
||||||
</select>
|
</select>
|
||||||
|
@ -249,7 +252,7 @@
|
||||||
sd.NAME AS "deptName",
|
sd.NAME AS "deptName",
|
||||||
IFNULL( trc2.isCollect, 'false' ) AS "isCollect",
|
IFNULL( trc2.isCollect, 'false' ) AS "isCollect",
|
||||||
IF
|
IF
|
||||||
( taa2.approve_status < 1, '未申请', "已申请" ) AS "applyState"
|
( taa2.approve_status < 1, '未申请', '已申请' ) AS "applyState"
|
||||||
FROM
|
FROM
|
||||||
tb_data_resource tdr
|
tb_data_resource tdr
|
||||||
LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0
|
LEFT JOIN ( SELECT resource_id, AVG( score ) AS "score" FROM tb_resource_score WHERE 1 = 1 AND del_flag = 0
|
||||||
|
@ -890,4 +893,46 @@
|
||||||
type
|
type
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="selectTopFiveComponentServiceApplications" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
tdr.id AS "resourceId",
|
||||||
|
tdr.NAME AS "name",
|
||||||
|
COUNT( taa.id ) AS "applyCount"
|
||||||
|
FROM
|
||||||
|
tb_data_resource tdr,
|
||||||
|
t_ability_application taa
|
||||||
|
WHERE
|
||||||
|
1 = 1
|
||||||
|
AND tdr.del_flag = 0
|
||||||
|
AND taa.del_flag = 0
|
||||||
|
AND tdr.id = taa.resource_id
|
||||||
|
AND tdr.type = '组件服务'
|
||||||
|
GROUP BY
|
||||||
|
tdr.id
|
||||||
|
ORDER BY
|
||||||
|
applyCount DESC
|
||||||
|
LIMIT 5
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectTopFiveComponentServiceScore" resultType="java.util.Map">
|
||||||
|
SELECT
|
||||||
|
tdr.id AS "resourceId",
|
||||||
|
tdr.NAME AS "name",
|
||||||
|
SUM(trs.score) AS "score"
|
||||||
|
FROM
|
||||||
|
tb_data_resource tdr,
|
||||||
|
tb_resource_score trs
|
||||||
|
WHERE
|
||||||
|
1 = 1
|
||||||
|
AND tdr.del_flag = 0
|
||||||
|
AND trs.del_flag = 0
|
||||||
|
AND tdr.id = trs.resource_id
|
||||||
|
AND tdr.type = '组件服务'
|
||||||
|
GROUP BY
|
||||||
|
tdr.id
|
||||||
|
ORDER BY
|
||||||
|
score DESC
|
||||||
|
LIMIT 5
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
Loading…
Reference in New Issue