区、市 部门上架、申请 环比
This commit is contained in:
parent
40ea0ef7dd
commit
8f03a0b54d
|
@ -8,6 +8,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import io.renren.common.annotation.LogOperation;
|
||||
import io.renren.common.constant.Constant;
|
||||
import io.renren.common.utils.Result;
|
||||
import io.renren.modules.date_snapshot.dto.SysDateSnapshotDTO;
|
||||
import io.renren.modules.date_snapshot.entity.SnapshotType;
|
||||
import io.renren.modules.date_snapshot.service.SysDateSnapshotService;
|
||||
import io.renren.modules.processForm.service.TAbilityApplicationService;
|
||||
import io.renren.modules.resource.dao.ResourceDao;
|
||||
|
@ -647,7 +649,66 @@ public class CensusController {
|
|||
@LogOperation("资源数量环比")
|
||||
@ApiImplicitParams({})
|
||||
public Result similitude() {
|
||||
return new Result();
|
||||
long countApply = tAbilityApplicationService.countApplyAll(); // 资源申请量
|
||||
HashMap<String, Object> resultMap = (HashMap<String, Object>) resourceService.selectTotal();
|
||||
List<Map<String, Object>> snapshot_now = new ArrayList<Map<String, Object>>() {{
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("count", countApply);
|
||||
put("type", "资源申请量");
|
||||
}});
|
||||
try {
|
||||
if (resultMap.containsKey("total")) {
|
||||
addAll((Collection<? extends Map<String, Object>>) resultMap.get("total"));
|
||||
}
|
||||
} catch (Exception exception) {
|
||||
logger.error("获取资源数量失败", exception);
|
||||
}
|
||||
}}; // 当前数据信息
|
||||
final List<String> needType = new ArrayList<String>() {{
|
||||
add("组件服务");
|
||||
add("应用资源");
|
||||
add("数据资源");
|
||||
add("基础设施");
|
||||
}};
|
||||
SysDateSnapshotDTO data_weekly = sysDateSnapshotService.selectForFlag(SnapshotType.DATA_WEEKLY.getFlag()); // 最近的周快照
|
||||
SysDateSnapshotDTO data_month = sysDateSnapshotService.selectForFlag(SnapshotType.DATA_MONTH.getFlag()); // 最近的周快照
|
||||
List<Map<String, Object>> result = snapshot_now.stream().filter(index -> needType.contains(index.get("type").toString())).map(index -> {
|
||||
String typeTemp = index.get("type").toString();
|
||||
Map<String, Object> temp = new LinkedHashMap<>();
|
||||
temp.put("type", typeTemp);
|
||||
temp.put("count", Integer.valueOf(index.get("count").toString()));
|
||||
if (data_weekly != null) {
|
||||
Optional<Map<String, Object>> t_weekly = data_weekly.getSnapshot().stream().filter(t -> typeTemp.equals(t.get("type"))).findFirst();// 周环比
|
||||
if (t_weekly.isPresent()) {
|
||||
temp.put("weekly_change", Integer.valueOf(index.get("count").toString()) - Integer.valueOf(t_weekly.get().get("count").toString()));
|
||||
} else {
|
||||
temp.put("weekly_change", Integer.valueOf(index.get("count").toString()));
|
||||
}
|
||||
} else {
|
||||
temp.put("weekly_change", Integer.valueOf(index.get("count").toString()));
|
||||
}
|
||||
if (data_month != null) {
|
||||
Optional<Map<String, Object>> t_month = data_month.getSnapshot().stream().filter(t -> typeTemp.equals(t.get("type"))).findFirst(); // 月环比
|
||||
if (t_month.isPresent()) {
|
||||
temp.put("month_change", Integer.valueOf(index.get("count").toString()) - Integer.valueOf(t_month.get().get("count").toString()));
|
||||
} else {
|
||||
temp.put("month_change", Integer.valueOf(index.get("count").toString()));
|
||||
}
|
||||
} else {
|
||||
temp.put("month_change", Integer.valueOf(index.get("count").toString()));
|
||||
}
|
||||
return temp;
|
||||
}).collect(Collectors.toList());
|
||||
Integer sum = result.stream().mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum();
|
||||
Integer weekly_change = result.stream().mapToInt(index -> Integer.valueOf(index.get("weekly_change").toString())).sum();
|
||||
Integer month_change = result.stream().mapToInt(index -> Integer.valueOf(index.get("month_change").toString())).sum();
|
||||
result.add(new LinkedHashMap<String, Object>() {{
|
||||
put("type", "四大类资源");
|
||||
put("count", sum);
|
||||
put("weekly_change", weekly_change);
|
||||
put("month_change", month_change);
|
||||
}});
|
||||
return new Result().ok(result);
|
||||
}
|
||||
|
||||
@GetMapping("/similitude_dept")
|
||||
|
@ -655,7 +716,120 @@ public class CensusController {
|
|||
@LogOperation("部门资源数量环比")
|
||||
@ApiImplicitParams({})
|
||||
public Result similitudeDept() {
|
||||
return new Result();
|
||||
List<HashMap<String, Object>> resultList1 = (List<HashMap<String, Object>>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap() {{
|
||||
put("snapshot", true);
|
||||
}}); // 能力申请统计原始数据
|
||||
|
||||
List<HashMap<String, Object>> resultList2 = (List<HashMap<String, Object>>) resourceService.selectDeptDetailTypeCountList(new HashMap() {{
|
||||
put("snapshot", true);
|
||||
}}); // 能力上架统计原始数据
|
||||
|
||||
Integer county_apply_sum = resultList1.stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区申请总量
|
||||
Integer county_resource_sum = resultList2.stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区上架总量
|
||||
|
||||
Integer municipal_apply_sum = resultList1.stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市申请总量
|
||||
Integer municipal_resource_sum = resultList2.stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市上架总量
|
||||
|
||||
Integer county_resource_weekly_change = 0;
|
||||
Integer county_resource_month_change = 0;
|
||||
|
||||
Integer municipal_resource_weekly_change = 0;
|
||||
Integer municipal_resource_month_change = 0;
|
||||
|
||||
SysDateSnapshotDTO resource_weekly = sysDateSnapshotService.selectForFlag(SnapshotType.RESOURCE_WEEKLY.getFlag()); // 最近的上架周快照
|
||||
SysDateSnapshotDTO resource_month = sysDateSnapshotService.selectForFlag(SnapshotType.RESOURCE_MONTH.getFlag()); // 最近的上架月快照
|
||||
if (resource_weekly != null) {
|
||||
int temp = resource_weekly.getSnapshot().stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区上架总量
|
||||
county_resource_weekly_change = county_resource_sum - temp;
|
||||
temp = resource_weekly.getSnapshot().stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市上架总量
|
||||
municipal_resource_weekly_change = municipal_resource_sum - temp;
|
||||
} else {
|
||||
county_resource_weekly_change = county_resource_sum;
|
||||
municipal_resource_weekly_change = municipal_resource_sum;
|
||||
}
|
||||
if (resource_month != null) {
|
||||
int temp = resource_month.getSnapshot().stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区上架总量
|
||||
county_resource_month_change = county_resource_sum - temp;
|
||||
|
||||
temp = resource_month.getSnapshot().stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市上架总量
|
||||
municipal_resource_month_change = municipal_resource_sum - temp;
|
||||
} else {
|
||||
county_resource_month_change = county_resource_sum;
|
||||
municipal_resource_month_change = municipal_resource_sum;
|
||||
}
|
||||
|
||||
SysDateSnapshotDTO apply_weekly = sysDateSnapshotService.selectForFlag(SnapshotType.APPLY_WEEKLY.getFlag()); // 最近的申请周快照
|
||||
SysDateSnapshotDTO apply_month = sysDateSnapshotService.selectForFlag(SnapshotType.APPLY_MONTH.getFlag()); // 最近的申请月快照
|
||||
|
||||
Integer county_apply_weekly_change = 0;
|
||||
Integer county_apply_month_change = 0;
|
||||
|
||||
Integer municipal_apply_weekly_change = 0;
|
||||
Integer municipal_apply_month_change = 0;
|
||||
|
||||
if (apply_weekly != null) {
|
||||
int temp = apply_weekly.getSnapshot().stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区申请总量
|
||||
county_apply_weekly_change = county_apply_sum - temp;
|
||||
|
||||
temp = apply_weekly.getSnapshot().stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市申请总量
|
||||
municipal_apply_weekly_change = municipal_apply_sum - temp;
|
||||
} else {
|
||||
county_apply_weekly_change = county_apply_sum;
|
||||
municipal_apply_weekly_change = municipal_apply_sum;
|
||||
}
|
||||
|
||||
if (apply_month != null) {
|
||||
int temp = apply_month.getSnapshot().stream().filter(index -> index.containsKey("level") && "county".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 区申请总量
|
||||
county_apply_month_change = county_apply_sum - temp;
|
||||
|
||||
temp = apply_month.getSnapshot().stream().filter(index -> index.containsKey("level") && "municipal".equals(index.get("level").toString()))
|
||||
.mapToInt(index -> Integer.valueOf(index.get("count").toString())).sum(); // 市申请总量
|
||||
municipal_apply_month_change = municipal_apply_sum - temp;
|
||||
} else {
|
||||
county_apply_month_change = county_apply_sum;
|
||||
municipal_apply_month_change = municipal_apply_sum;
|
||||
}
|
||||
|
||||
Integer finalCounty_resource_weekly_change = county_resource_weekly_change;
|
||||
Integer finalCounty_resource_month_change = county_resource_month_change;
|
||||
Integer finalMunicipal_resource_weekly_change = municipal_resource_weekly_change;
|
||||
Integer finalMunicipal_resource_month_change = municipal_resource_month_change;
|
||||
Integer finalCounty_apply_weekly_change = county_apply_weekly_change;
|
||||
Integer finalMunicipal_apply_weekly_change = municipal_apply_weekly_change;
|
||||
Integer finalMunicipal_apply_month_change = municipal_apply_month_change;
|
||||
Integer finalCounty_apply_month_change = county_apply_month_change;
|
||||
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>() {{
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("level", "county");
|
||||
put("apply_sum", county_apply_sum);
|
||||
put("resource_sum", county_resource_sum);
|
||||
put("resource_weekly_change", finalCounty_resource_weekly_change);
|
||||
put("resource_month_change", finalCounty_resource_month_change);
|
||||
put("apply_weekly_change", finalCounty_apply_weekly_change);
|
||||
put("apply_month_change", finalCounty_apply_month_change);
|
||||
}});
|
||||
add(new LinkedHashMap<String, Object>() {{
|
||||
put("level", "municipal");
|
||||
put("apply_sum", municipal_apply_sum);
|
||||
put("resource_sum", municipal_resource_sum);
|
||||
put("resource_weekly_change", finalMunicipal_resource_weekly_change);
|
||||
put("resource_month_change", finalMunicipal_resource_month_change);
|
||||
put("apply_weekly_change", finalMunicipal_apply_weekly_change);
|
||||
put("apply_month_change", finalMunicipal_apply_month_change);
|
||||
}});
|
||||
}};
|
||||
return new Result().ok(result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public class SysDateSnapshotServiceImpl extends CrudServiceImpl<SysDateSnapshotD
|
|||
SysDateSnapshotDTO sysDateSnapshotDTO = new SysDateSnapshotDTO();
|
||||
List<HashMap<String, Object>> resultList = (List<HashMap<String, Object>>) resourceService.selectApplyDeptDetailTypeCountList(new HashMap() {{
|
||||
put("snapshot", true);
|
||||
}}); // 能力上架统计原始数据
|
||||
}}); // 能力申请统计原始数据
|
||||
List<Map<String, Object>> snapshot = new ArrayList<Map<String, Object>>() {{
|
||||
addAll(resultList);
|
||||
}};
|
||||
|
|
|
@ -2745,8 +2745,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
resultList.addAll(getDeptTemp4()); // 企业
|
||||
Map<String, Integer> countMap = new HashMap<>();
|
||||
resultList = resultList.stream().map(index -> {
|
||||
index.put("level", "municipal"); // 市级别
|
||||
if (typeCountListMap.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
|
||||
index.put("level", "municipal"); // 市级别
|
||||
index.put("count", typeCountListMap.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
|
||||
typeCountListMap.get(index.get("dept_id").toString()).stream().forEach(count -> {
|
||||
index.put(count.get("type").toString(), count.get("count"));
|
||||
|
@ -2763,8 +2763,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("3"))
|
||||
.collect(Collectors.groupingBy(m -> m.get("district").toString()));
|
||||
resultList = resultList.stream().map(index -> {
|
||||
index.put("level", "county"); // 区县级别
|
||||
if (typeCountListMap1.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
|
||||
index.put("level", "county"); // 区县级别
|
||||
index.put("count", typeCountListMap1.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
|
||||
typeCountListMap1.get(index.get("dept_id").toString()).stream().forEach(count -> {
|
||||
index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString()));
|
||||
|
@ -2781,8 +2781,8 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
typeCountListByDept.stream().filter(index -> index.get("deptType").toString().equals("4"))
|
||||
.collect(Collectors.groupingBy(m -> m.get("dept_id").toString()));
|
||||
resultList = resultList.stream().map(index -> {
|
||||
index.put("level", "other"); // 企业级别
|
||||
if (typeCountListMap2.keySet().contains(index.get("dept_id").toString())) { // 该部门存在上架信息
|
||||
index.put("level", "other"); // 企业级别
|
||||
index.put("count", typeCountListMap2.get(index.get("dept_id").toString()).stream().mapToInt(it -> Integer.parseInt(it.get("count").toString())).sum());
|
||||
typeCountListMap2.get(index.get("dept_id").toString()).stream().forEach(count -> {
|
||||
index.put(count.get("type").toString(), Integer.parseInt(count.get("count").toString()) + Integer.parseInt(index.getOrDefault(count.get("type").toString(), "0").toString()));
|
||||
|
|
|
@ -112,3 +112,12 @@ synchro:
|
|||
url: jdbc:mysql://15.2.21.238:3310/share_platform?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&useSSL=false
|
||||
username: root
|
||||
password: Hisense2019
|
||||
|
||||
# 是否统计云资源
|
||||
cloud:
|
||||
enable: false
|
||||
|
||||
# 全局RestTemplate配置
|
||||
rest_template:
|
||||
read_timeout: 150
|
||||
connect_timeout: 30
|
|
@ -21,7 +21,7 @@
|
|||
typeHandler="com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectForFlag" resultType="io.renren.modules.date_snapshot.dto.SysDateSnapshotDTO">
|
||||
<select id="selectForFlag" resultMap="sysDateSnapshotDtoMap">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
|
|
Loading…
Reference in New Issue