能力广场和能力集市资源排序按指定方式排序
This commit is contained in:
parent
8574f26607
commit
9e362f3ae9
|
@ -43,6 +43,7 @@ import io.renren.modules.resourceMountApply.service.TResourceMountApplyService;
|
||||||
import io.renren.modules.resourceScore.dao.ResourceScoreDao;
|
import io.renren.modules.resourceScore.dao.ResourceScoreDao;
|
||||||
import io.renren.modules.security.user.SecurityUser;
|
import io.renren.modules.security.user.SecurityUser;
|
||||||
import io.renren.modules.sys.dao.SysDeptDao;
|
import io.renren.modules.sys.dao.SysDeptDao;
|
||||||
|
import io.renren.modules.sys.dao.SysRegionDao;
|
||||||
import io.renren.modules.sys.dto.SysUserDTO;
|
import io.renren.modules.sys.dto.SysUserDTO;
|
||||||
import io.renren.modules.sys.service.SysDeptService;
|
import io.renren.modules.sys.service.SysDeptService;
|
||||||
import io.renren.modules.sys.service.SysUserService;
|
import io.renren.modules.sys.service.SysUserService;
|
||||||
|
@ -180,6 +181,9 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
@Autowired
|
@Autowired
|
||||||
private TbDataResourceRelDao tbDataResourceRelDao;
|
private TbDataResourceRelDao tbDataResourceRelDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SysRegionDao sysRegionDao;
|
||||||
|
|
||||||
@Value("${census.type}")
|
@Value("${census.type}")
|
||||||
private String[] censusTypes; // 需要进行统计的资源类型
|
private String[] censusTypes; // 需要进行统计的资源类型
|
||||||
|
|
||||||
|
@ -386,13 +390,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
//默认按上架时间降序排列
|
//默认按上架时间降序排列
|
||||||
String orderField;
|
String orderField;
|
||||||
if (StringUtils.isBlank(jsonObject.getString("orderField"))) {
|
if (StringUtils.isBlank(jsonObject.getString("orderField"))) {
|
||||||
if ("应用资源".equals(jsonObject.getString("type"))) {
|
orderField = "visits";
|
||||||
orderField = "deptSort";
|
|
||||||
} else if ("组件服务".equals(jsonObject.getString("type"))) {
|
|
||||||
orderField = "pin_top";
|
|
||||||
} else {
|
|
||||||
orderField = "total";
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
orderField = jsonObject.getString("orderField");
|
orderField = jsonObject.getString("orderField");
|
||||||
}
|
}
|
||||||
|
@ -786,13 +784,17 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
}
|
}
|
||||||
Map<String, List<Map<String, Object>>> listMap = typeMapList.stream().collect(Collectors.groupingBy(m -> m.get("type").toString()));
|
Map<String, List<Map<String, Object>>> listMap = typeMapList.stream().collect(Collectors.groupingBy(m -> m.get("type").toString()));
|
||||||
//区级要根据行政区划多加一层结构
|
//区级要根据行政区划多加一层结构
|
||||||
List<CompletableFuture> tasks = listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> {
|
List<CompletableFuture> tasks =
|
||||||
|
listMap.entrySet().stream().filter(index -> !"区级".equals(index.getKey())).map(item -> {
|
||||||
CompletableFuture task = CompletableFuture.runAsync(() -> {
|
CompletableFuture task = CompletableFuture.runAsync(() -> {
|
||||||
HashMap<String, Object> map = new HashMap<>();
|
HashMap<String, Object> map = new HashMap<>();
|
||||||
map.put("type", item.getKey());
|
map.put("type", item.getKey());
|
||||||
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
|
Integer integer = resourceDao.selectTypeCountByDept(item.getKey(), jsonObject.getString("type"));
|
||||||
map.put("total", integer);
|
map.put("total", integer);
|
||||||
item.getValue().forEach(item1 -> item1.remove("type"));
|
item.getValue().forEach(item1 -> {
|
||||||
|
item1.remove("type");
|
||||||
|
item1.remove("regionSort");
|
||||||
|
});
|
||||||
map.put("dataList", item.getValue());
|
map.put("dataList", item.getValue());
|
||||||
if (integer != 0) {
|
if (integer != 0) {
|
||||||
resultList.add(map);
|
resultList.add(map);
|
||||||
|
@ -820,12 +822,14 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
map.put("total", resourceDao.selectTypeCountByDist(key, jsonObject.getString("type")));
|
map.put("total", resourceDao.selectTypeCountByDist(key, jsonObject.getString("type")));
|
||||||
value.forEach(item1 -> item1.remove("type"));
|
value.forEach(item1 -> item1.remove("type"));
|
||||||
map.put("dataList", value);
|
map.put("dataList", value);
|
||||||
|
map.put("regionSort", value.get(0).get("regionSort"));
|
||||||
areaListTemp.add(map);
|
areaListTemp.add(map);
|
||||||
}, executor);
|
}, executor);
|
||||||
tasksArea.add(task);
|
tasksArea.add(task);
|
||||||
});
|
});
|
||||||
CompletableFuture.allOf(tasksArea.toArray(new CompletableFuture[tasksArea.size()])).join();
|
CompletableFuture.allOf(tasksArea.toArray(new CompletableFuture[tasksArea.size()])).join();
|
||||||
areaMap.put("dataList", areaListTemp);
|
List<Map> collect = areaListTemp.stream().sorted(Comparator.comparingInt(m -> Integer.parseInt(m.get("regionSort").toString()))).collect(Collectors.toList());
|
||||||
|
areaMap.put("dataList", collect);
|
||||||
if (integer != 0) {
|
if (integer != 0) {
|
||||||
resultList.add(areaMap);
|
resultList.add(areaMap);
|
||||||
}
|
}
|
||||||
|
@ -1057,7 +1061,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Cacheable(value = SELECT_DTO_PAGE_SPECIAL_TOTAL_KEY, key = "#p0")
|
//@Cacheable(value = SELECT_DTO_PAGE_SPECIAL_TOTAL_KEY, key = "#p0")
|
||||||
public List<Map> selectDTOPageSpecilTotal(ResourceDTO resourceDTO) {
|
public List<Map> selectDTOPageSpecilTotal(ResourceDTO resourceDTO) {
|
||||||
return resourceDao.selectDTOPageSpecilTotal(resourceDTO);
|
return resourceDao.selectDTOPageSpecilTotal(resourceDTO);
|
||||||
}
|
}
|
||||||
|
@ -1065,7 +1069,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
@Override
|
@Override
|
||||||
public Object getApplyCameraList(Long instanceId) {
|
public Object getApplyCameraList(Long instanceId) {
|
||||||
QueryWrapper<TAbilityApplicationEntity> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<TAbilityApplicationEntity> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("instance_id", instanceId).eq("approve_status", "通过");
|
queryWrapper.eq("instance_id", instanceId)
|
||||||
|
.eq("approve_status", "通过");
|
||||||
List<TAbilityApplicationEntity> applicationEntities = tAbilityApplicationDao.selectList(queryWrapper);
|
List<TAbilityApplicationEntity> applicationEntities = tAbilityApplicationDao.selectList(queryWrapper);
|
||||||
ArrayList cameraList = new ArrayList();
|
ArrayList cameraList = new ArrayList();
|
||||||
applicationEntities.forEach(index -> {
|
applicationEntities.forEach(index -> {
|
||||||
|
@ -1849,7 +1854,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
||||||
resourceIds.add(Long.parseLong(abilityApplicationDTO1.getResourceId()));
|
resourceIds.add(Long.parseLong(abilityApplicationDTO1.getResourceId()));
|
||||||
} else {
|
} else {
|
||||||
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(his.getBusinessKey()));
|
TResourceMountApplyDTO resourceMountApplyDTO = tResourceMountApplyService.get(Long.valueOf(his.getBusinessKey()));
|
||||||
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null && resourceMountApplyDTO.getResourceDTO().getId() != null) {
|
if (resourceMountApplyDTO != null && resourceMountApplyDTO.getResourceDTO() != null
|
||||||
|
&& resourceMountApplyDTO.getResourceDTO().getId() != null) {
|
||||||
resourceIds.add(resourceMountApplyDTO.getResourceDTO().getId());
|
resourceIds.add(resourceMountApplyDTO.getResourceDTO().getId());
|
||||||
if (resourceMountApplyDTO.getResourceId() != null) {
|
if (resourceMountApplyDTO.getResourceId() != null) {
|
||||||
ResourceDTO resourceDTO = get(resourceMountApplyDTO.getResourceId());
|
ResourceDTO resourceDTO = get(resourceMountApplyDTO.getResourceId());
|
||||||
|
|
|
@ -103,6 +103,12 @@
|
||||||
DISTINCT tdr.id,
|
DISTINCT tdr.id,
|
||||||
tdr.create_date,
|
tdr.create_date,
|
||||||
tdr.visits,
|
tdr.visits,
|
||||||
|
tdr.visitor,
|
||||||
|
tdr.pin_top,
|
||||||
|
tdr.pin_top_time,
|
||||||
|
sd.type AS "deptType",
|
||||||
|
sd.sort AS "deptSort",
|
||||||
|
sr.sort AS "regionSort",
|
||||||
IFNULL(taa2.approve_status, '未申请') AS "applyState",
|
IFNULL(taa2.approve_status, '未申请') AS "applyState",
|
||||||
IFNULL(trs.score, 0 ) AS "score",
|
IFNULL(trs.score, 0 ) AS "score",
|
||||||
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||||
|
@ -132,10 +138,10 @@
|
||||||
AND user_id = #{dto.creator}
|
AND user_id = #{dto.creator}
|
||||||
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
|
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
|
||||||
LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1
|
LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1
|
||||||
AND del_flag = 0 AND user_id = #{dto.creator} AND approve_status = '通过' GROUP BY resource_id ) taa3 ON tdr.id
|
AND del_flag = 0 AND user_id = #{dto.creator} AND approve_status = '通过' GROUP BY resource_id ) taa3 ON tdr.id =
|
||||||
=
|
|
||||||
taa3.resource_id
|
taa3.resource_id
|
||||||
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
||||||
|
LEFT JOIN sys_region sr ON sd.district = sr.id
|
||||||
WHERE 1 = 1
|
WHERE 1 = 1
|
||||||
AND tdr.del_flag = 0
|
AND tdr.del_flag = 0
|
||||||
<if test="dto.type != null and dto.type != '赋能案例'">
|
<if test="dto.type != null and dto.type != '赋能案例'">
|
||||||
|
@ -192,7 +198,7 @@
|
||||||
ORDER BY ${orderField} ${orderType}, pin_top_time DESC
|
ORDER BY ${orderField} ${orderType}, pin_top_time DESC
|
||||||
</if>
|
</if>
|
||||||
<if test="orderField == 'deptSort'">
|
<if test="orderField == 'deptSort'">
|
||||||
ORDER BY sd.type, sd.sort
|
ORDER BY sd.type, sr.sort, sd.sort, tdr.dept_id, tdr.visitor DESC, tdr.id DESC
|
||||||
</if>
|
</if>
|
||||||
<if test="orderField != 'pin_top' and orderField != 'deptSort'">
|
<if test="orderField != 'pin_top' and orderField != 'deptSort'">
|
||||||
ORDER BY ${orderField} ${orderType}
|
ORDER BY ${orderField} ${orderType}
|
||||||
|
@ -308,8 +314,6 @@
|
||||||
tdr.undercarriage_reason,
|
tdr.undercarriage_reason,
|
||||||
tdr.undercarriage_user_name,
|
tdr.undercarriage_user_name,
|
||||||
tdr.info_list,
|
tdr.info_list,
|
||||||
tdr.pin_top,
|
|
||||||
tdr.pin_top_time,
|
|
||||||
IFNULL( trs.score, 0 ) AS "score",
|
IFNULL( trs.score, 0 ) AS "score",
|
||||||
IFNULL( taa.applyCount, 0 ) AS "applyCount",
|
IFNULL( taa.applyCount, 0 ) AS "applyCount",
|
||||||
IFNULL( trc.collectCount, 0 ) AS "collectCount",
|
IFNULL( trc.collectCount, 0 ) AS "collectCount",
|
||||||
|
@ -389,10 +393,14 @@
|
||||||
tdr.total AS total,
|
tdr.total AS total,
|
||||||
tdr.pin_top,
|
tdr.pin_top,
|
||||||
tdr.pin_top_time,
|
tdr.pin_top_time,
|
||||||
|
tdr.visitor,
|
||||||
IFNULL(trs.score, 0 ) AS "score",
|
IFNULL(trs.score, 0 ) AS "score",
|
||||||
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
IFNULL(taa.applyCount, 0 ) AS "applyCount",
|
||||||
IFNULL(trc.collectCount, 0) AS "collectCount",
|
IFNULL(trc.collectCount, 0) AS "collectCount",
|
||||||
sd.name AS "deptName",
|
sd.name AS "deptName",
|
||||||
|
sd.type AS "deptType",
|
||||||
|
sd.sort AS "deptSort",
|
||||||
|
sr.sort AS "regionSort",
|
||||||
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
IFNULL(trc2.isCollect, 'false') AS "isCollect",
|
||||||
IFNULL(taa2.approve_status, '未申请') AS "applyState",
|
IFNULL(taa2.approve_status, '未申请') AS "applyState",
|
||||||
IF ( IFNULL( trcar.car, 0 ) > 0, TRUE, FALSE ) AS "isInShoppingCart",
|
IF ( IFNULL( trcar.car, 0 ) > 0, TRUE, FALSE ) AS "isInShoppingCart",
|
||||||
|
@ -415,10 +423,10 @@
|
||||||
AND user_id = #{dto.creator}
|
AND user_id = #{dto.creator}
|
||||||
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
|
GROUP BY id) taa2 ON tdr.id = taa2.resource_id
|
||||||
LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1
|
LEFT JOIN ( SELECT resource_id, COUNT( approve_status ) approve_status FROM t_ability_application WHERE 1 = 1
|
||||||
AND del_flag = 0 AND user_id = #{dto.creator} AND approve_status = '通过' GROUP BY resource_id ) taa3 ON tdr.id
|
AND del_flag = 0 AND user_id = #{dto.creator} AND approve_status = '通过' GROUP BY resource_id ) taa3 ON tdr.id =
|
||||||
=
|
|
||||||
taa3.resource_id
|
taa3.resource_id
|
||||||
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
||||||
|
LEFT JOIN sys_region sr ON sd.district = sr.id
|
||||||
WHERE 1 = 1
|
WHERE 1 = 1
|
||||||
AND tdr.del_flag = 0
|
AND tdr.del_flag = 0
|
||||||
|
|
||||||
|
@ -465,7 +473,7 @@
|
||||||
ORDER BY ${orderField} ${orderType}, pin_top_time DESC
|
ORDER BY ${orderField} ${orderType}, pin_top_time DESC
|
||||||
</if>
|
</if>
|
||||||
<if test="orderField == 'deptSort'">
|
<if test="orderField == 'deptSort'">
|
||||||
ORDER BY sd.type, sd.sort
|
ORDER BY sd.type, sr.sort, sd.sort, tdr.dept_id, tdr.visitor DESC, tdr.id DESC
|
||||||
</if>
|
</if>
|
||||||
<if test="orderField != 'pin_top' and orderField != 'deptSort'">
|
<if test="orderField != 'pin_top' and orderField != 'deptSort'">
|
||||||
ORDER BY ${orderField} ${orderType}
|
ORDER BY ${orderField} ${orderType}
|
||||||
|
@ -599,13 +607,13 @@
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS
|
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
|
||||||
"type",
|
|
||||||
sd.NAME AS "deptName",
|
sd.NAME AS "deptName",
|
||||||
IFNULL( tdr.deptCount, 0 ) AS "deptCount",
|
IFNULL( tdr.deptCount, 0 ) AS "deptCount",
|
||||||
sd.id AS "deptId",
|
sd.id AS "deptId",
|
||||||
sr.name AS "districtName",
|
sr.name AS "districtName",
|
||||||
sr.id AS "districtId"
|
sr.id AS "districtId",
|
||||||
|
sr.sort AS "regionSort"
|
||||||
FROM
|
FROM
|
||||||
sys_dept sd
|
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 = 0
|
||||||
|
@ -614,7 +622,7 @@
|
||||||
</if>
|
</if>
|
||||||
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
|
GROUP BY dept_id ) tdr ON sd.id = tdr.dept_id
|
||||||
LEFT JOIN sys_region sr ON sd.district = sr.id
|
LEFT JOIN sys_region sr ON sd.district = sr.id
|
||||||
ORDER BY sd.type, sr.sort, sd.sort
|
ORDER BY sd.type, sd.sort
|
||||||
) temp1
|
) temp1
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
|
@ -633,8 +641,7 @@
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS
|
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
|
||||||
"type",
|
|
||||||
IFNULL( tdr.deptCount, 0 ) AS "deptCount"
|
IFNULL( tdr.deptCount, 0 ) AS "deptCount"
|
||||||
FROM
|
FROM
|
||||||
sys_dept sd
|
sys_dept sd
|
||||||
|
@ -672,8 +679,7 @@
|
||||||
FROM
|
FROM
|
||||||
(
|
(
|
||||||
SELECT
|
SELECT
|
||||||
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS
|
( CASE sd.type WHEN 1 THEN '省级' WHEN 2 THEN '市级' WHEN 3 THEN '区级' WHEN 4 THEN '企业' ELSE '其他' END ) AS "type",
|
||||||
"type",
|
|
||||||
IFNULL( tdr.deptCount, 0) AS "deptCount",
|
IFNULL( tdr.deptCount, 0) AS "deptCount",
|
||||||
IFNULL(sr.name, '暂无该地区') AS "districtName"
|
IFNULL(sr.name, '暂无该地区') AS "districtName"
|
||||||
FROM
|
FROM
|
||||||
|
@ -1515,10 +1521,15 @@
|
||||||
SELECT
|
SELECT
|
||||||
tdr.id,
|
tdr.id,
|
||||||
tdr.`name`,
|
tdr.`name`,
|
||||||
sd.name AS "deptName"
|
sd.name AS "deptName",
|
||||||
|
sd.sort AS "deptSort",
|
||||||
|
sd.type AS "deptType",
|
||||||
|
sr.sort AS "regionSort",
|
||||||
|
tdr.visitor
|
||||||
FROM
|
FROM
|
||||||
tb_data_resource tdr
|
tb_data_resource tdr
|
||||||
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
LEFT JOIN sys_dept sd ON tdr.dept_id = sd.id
|
||||||
|
LEFT JOIN sys_region sr ON sd.district = sr.id
|
||||||
WHERE
|
WHERE
|
||||||
1 = 1
|
1 = 1
|
||||||
AND tdr.type = '应用资源'
|
AND tdr.type = '应用资源'
|
||||||
|
@ -1527,7 +1538,7 @@
|
||||||
AND sd.type = #{type}
|
AND sd.type = #{type}
|
||||||
</if>
|
</if>
|
||||||
ORDER BY
|
ORDER BY
|
||||||
tdr.visitor
|
sd.type, sr.sort, sd.sort, tdr.dept_id, tdr.visitor DESC, tdr.id DESC
|
||||||
LIMIT ${pageNum}, 9
|
LIMIT ${pageNum}, 9
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
Loading…
Reference in New Issue