|
|
|
@ -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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|