Compare commits
2 Commits
edda52f387
...
64398d8926
Author | SHA1 | Date |
---|---|---|
wangliwen | 64398d8926 | |
dinggang | 44d99b4e21 |
|
@ -61,15 +61,7 @@ public class CensusController {
|
|||
List<Map<String, Object>> dbAmount = resourceService.getAmountGroupByType();
|
||||
List<String> temp = dbAmount.stream().map(index -> index.get("type").toString()).collect(Collectors.toList());
|
||||
Arrays.stream(censusTypes).filter(index -> !temp.contains(index)).forEach(index -> { // 数据库内不存在的资源类型
|
||||
if (index.equals("知识库")) {
|
||||
Map<String, Object> nullMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("amount", 14);
|
||||
put("type", "知识库");
|
||||
}
|
||||
};
|
||||
dbAmount.add(nullMap);
|
||||
} else if (index.equals("数据资源")) {
|
||||
if (index.equals("数据资源")) {
|
||||
Map<String, Object> nullMap = new HashMap<String, Object>() {
|
||||
{
|
||||
put("amount", 10413);
|
||||
|
|
|
@ -33,7 +33,7 @@ import java.util.stream.Collectors;
|
|||
@RestController
|
||||
@RequestMapping("/census/center/v2")
|
||||
public class CensusControllerV2 {
|
||||
private static Logger logger = LoggerFactory.getLogger(CensusControllerV2.class);
|
||||
private static final Logger logger = LoggerFactory.getLogger(CensusControllerV2.class);
|
||||
|
||||
@Autowired
|
||||
private ResourceService resourceService;
|
||||
|
@ -289,4 +289,11 @@ public class CensusControllerV2 {
|
|||
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);
|
||||
return new Result().ok(map);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return new Result().ok(new HashMap<String, Object>() {{
|
||||
put("sxmlcount", 0);
|
||||
put("yfbfwcount", 0);
|
||||
|
|
|
@ -25,7 +25,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
|||
@Param("orderField") String orderField,
|
||||
@Param("orderType") String orderType);
|
||||
|
||||
List<Map> selectTypeCount();
|
||||
List<Map> selectTypeCount(String type);
|
||||
|
||||
List<ResourceDTO> selectMostPopular(Map<String, Object> selectMap);
|
||||
|
||||
|
@ -106,4 +106,7 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
|
|||
|
||||
List<Map> selectAppAreaCountList();
|
||||
|
||||
List<Map> selectTopFiveComponentServiceApplications();
|
||||
|
||||
List<Map> selectTopFiveComponentServiceScore();
|
||||
}
|
|
@ -79,4 +79,6 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
|
|||
* 同步知识库
|
||||
*/
|
||||
void KnowledgeBase();
|
||||
|
||||
Object componentServiceRank(String type);
|
||||
}
|
|
@ -55,7 +55,9 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
@Service
|
||||
public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEntity, ResourceDTO> implements ResourceService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ResourceServiceImpl.class);
|
||||
|
||||
@Value("${zsk.appid}")
|
||||
private String appId;
|
||||
|
||||
|
@ -250,7 +252,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
@Override
|
||||
public Object selectTotal() {
|
||||
HashMap<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("total", resourceDao.selectTypeCount());
|
||||
resultMap.put("total", resourceDao.selectTypeCount(null));
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
|
@ -291,7 +293,6 @@ 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());
|
||||
|
@ -372,17 +373,21 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
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")));
|
||||
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
|
||||
map.put("total", integer);
|
||||
item.getValue().forEach(item1 -> item1.remove("type"));
|
||||
map.put("dataList", item.getValue());
|
||||
resultList.add(map);
|
||||
if (integer != 0) {
|
||||
resultList.add(map);
|
||||
}
|
||||
});
|
||||
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()
|
||||
.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")));
|
||||
Integer integer = resourceDao.selectTypeCountByDept("区级", jsonObject.getString("type"));
|
||||
areaMap.put("total", integer);
|
||||
ArrayList<Map> areaListTemp = new ArrayList<>();
|
||||
areaTypeList.orElse(new HashMap<>()).forEach((key, value) -> {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
@ -393,7 +398,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
areaListTemp.add(map);
|
||||
});
|
||||
areaMap.put("dataList", areaListTemp);
|
||||
resultList.add(areaMap);
|
||||
if (integer != 0) {
|
||||
resultList.add(areaMap);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
|
@ -712,4 +719,15 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
}).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">
|
||||
|
||||
<mapper namespace="io.renren.modules.resource.dao.ResourceDao">
|
||||
|
@ -179,6 +179,9 @@
|
|||
FROM tb_data_resource
|
||||
WHERE 1 = 1
|
||||
AND del_flag = 0
|
||||
<if test="type != null and type != ''">
|
||||
AND type = #{type}
|
||||
</if>
|
||||
GROUP BY type
|
||||
ORDER BY type
|
||||
</select>
|
||||
|
@ -249,7 +252,7 @@
|
|||
sd.NAME AS "deptName",
|
||||
IFNULL( trc2.isCollect, 'false' ) AS "isCollect",
|
||||
IF
|
||||
( taa2.approve_status < 1, '未申请', "已申请" ) AS "applyState"
|
||||
( taa2.approve_status < 1, '未申请', '已申请' ) AS "applyState"
|
||||
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
|
||||
|
@ -890,4 +893,46 @@
|
|||
type
|
||||
</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>
|
Loading…
Reference in New Issue