5c551cb5 sonin

运营月报 优化

1 个父辈 799381f9
......@@ -83,7 +83,7 @@ public class OperationReportController {
List<Map<String, Object>> resMapList = new ArrayList<>();
for (String tmpDepartId : departIdArray) {
String childDepartId = departService.getChildDepartId(tmpDepartId);
SysDepart tmpSysDepart = departService.getById(departId);
SysDepart tmpSysDepart = departService.getById(tmpDepartId);
// 获取机构子集
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("startTime", startTime);
......@@ -92,7 +92,7 @@ public class OperationReportController {
Map<String, Object> resMap = operationReportService.dataAnalysisOfMonth(paramMap);
resMap.put("departId", tmpDepartId);
resMap.put("departName", sysDepartDictMap.get(tmpDepartId));
resMap.put("departType", tmpSysDepart.getDepartType());
resMap.put("departType", tmpSysDepart != null ? tmpSysDepart.getDepartType() : "");
resMapList.add(resMap);
}
return Result.ok(resMapList);
......
......@@ -165,4 +165,6 @@ public class ReportTargetConfig {
private Integer delFlag;
private String targetPowerCost;
private String targetWaterCostIn;
}
......
......@@ -228,11 +228,12 @@ public class OperationReportServiceImpl implements IOperationReportService {
List<String> timeList = DateUtils.intervalByDay(startTime, endTime, BusinessConstant.dateFormat.substring(0, 10));
// 同比时间
String[] timeArray = DateUtils.tbTime(startTime, endTime);
List<String> timeListTb = DateUtils.intervalByDay(timeArray[0], timeArray[1], BusinessConstant.dateFormat.substring(0, 10));
List<String> tbTimeList = DateUtils.intervalByDay(timeArray[0], timeArray[1], BusinessConstant.dateFormat.substring(0, 10));
String departId = ConvertUtils.getString(paramMap.get("departId"));
List<String> departIdList = Arrays.asList(departId.split(","));
// 翻译
Map<String, String> sysDepartDictMap = businessService.dictMap("sys_depart", departIdList);
// 数据信息
// reitId => 展示字段名称 + dataTime时间长度 + dataValue数据转换
Map<String, String[]> dictMap0 = new LinkedHashMap<String, String[]>(){{
// 污水水量(吨 => 万吨)
......@@ -243,8 +244,10 @@ public class OperationReportServiceImpl implements IOperationReportService {
put("1818218432697643010", new String[]{"scgsl", "10", "/10000"});
// 污泥处置量(吨 => 万吨)
put("1910571063704104961", new String[]{"wnczl", "7", "/10000"});
// 水费收入
put("1912415992428384257", new String[]{"sfsr", "7", ""});
// 实际水费
put("1912415992428384257", new String[]{"sjsf", "7", ""});
put("1902657099079598082", new String[]{"sjsf", "7", ""});
// 实际水量
put("1818936221372633089", new String[]{"sjsl", "7", ""});
// 实际药费(元=>万元)
......@@ -266,13 +269,28 @@ public class OperationReportServiceImpl implements IOperationReportService {
queryWrapper0.in("reit_id", dictMap0.keySet())
.in("depart_id", departIdList);
Map<String, Object> queryMap0 = baseService.queryForMap("select " + caseWhen0.print() + " from f_report_itemv", queryWrapper0);
// 实际电费信息(元=>万元)
Map<String, String> dictMap0_1 = new LinkedHashMap<String, String>(){{
// 实际电费
put("cost/10000", "sjdf");
}};
QueryWrapper<?> queryWrapper0_1 = new QueryWrapper<>();
queryWrapper0_1.in("depart_id", departIdList);
CaseWhen caseWhen0_1 = new CaseWhen();
for (Map.Entry<String, String> entry: dictMap0_1.entrySet()) {
caseWhen0_1.selectCaseWhen("month >= '" + startTime.substring(0, 7) + "' and month <= '" + endTime.substring(0, 7) + "'", entry.getKey(), "0", entry.getValue());
caseWhen0_1.selectCaseWhen("month >= '" + timeArray[0].substring(0, 7) + "' and month <= '" + timeArray[1].substring(0, 7) + "'", entry.getKey(), "0", "tb_" + entry.getValue());
}
Map<String, Object> queryMap0_1 = baseService.queryForMap("select " + caseWhen0_1.print() + " from report_electric_cost", queryWrapper0_1);
// 年度目标
// 数据库字段 => 展示字段名称 + 对比数据展示字段名称
Map<String, String[]> dictMap1 = new LinkedHashMap<String, String[]>(){{
// 目标水量
// 目标实际水量
put("target_water", new String[]{"mbsl", "sjsl"});
// 目标水费
// 目标实际水费
put("target_cost", new String[]{"mbsf", "sjsf"});
// 目标水费收入
put("target_water_cost_in", new String[]{"mbsfsr", "sfsr"});
// 目标电费
put("target_power_cost", new String[]{"mbdf", "sjdf"});
// 目标药费(万元)
......@@ -287,34 +305,34 @@ public class OperationReportServiceImpl implements IOperationReportService {
CaseWhen caseWhen1 = new CaseWhen();
for (Map.Entry<String, String[]> entry: dictMap1.entrySet()) {
caseWhen1.selectCaseWhen("target_year = '" + endTime.substring(0, 4) + "'", entry.getKey(), "0", entry.getValue()[0]);
caseWhen1.selectCaseWhen("target_year = '" + timeArray[1].substring(0, 4) + "'", entry.getKey(), "0", "tb_" + entry.getValue()[0]);
}
Map<String, Object> queryMap1 = baseService.queryForMap("select " + caseWhen1.print() + " from report_target_config", queryWrapper1);
// 实际电费信息(元=>万元)
Map<String, String> dictMap2 = new LinkedHashMap<String, String>(){{
// 实际电费
put("cost/10000", "sjdf");
// 年度目标 序时情况
Map<String, String[]> dictMap1_1 = new LinkedHashMap<String, String[]>(){{
put("sl", new String[]{"xssl", "sjsl"});
put("fy", new String[]{"xssf", "sjsf"});
put("sf", new String[]{"xssfsr", "sfsr"});
}};
QueryWrapper<?> queryWrapper2 = new QueryWrapper<>();
queryWrapper2.in("depart_id", departIdList);
CaseWhen caseWhen2 = new CaseWhen();
for (Map.Entry<String, String> entry: dictMap2.entrySet()) {
caseWhen2.selectCaseWhen("month >= '" + startTime.substring(0, 7) + "' and month <= '" + endTime.substring(0, 7) + "'", entry.getKey(), "0", entry.getValue());
caseWhen2.selectCaseWhen("month >= '" + timeArray[0].substring(0, 7) + "' and month <= '" + timeArray[1].substring(0, 7) + "'", entry.getKey(), "0", "tb_" + entry.getValue());
QueryWrapper<?> queryWrapper1_1 = new QueryWrapper<>();
queryWrapper1_1.in("depart_id", departIdList);
CaseWhen caseWhen1_1 = new CaseWhen();
for (Map.Entry<String, String[]> entry: dictMap1_1.entrySet()) {
caseWhen1_1.selectCaseWhen("target_time >= '" + startTime.substring(0, 7) + "' and target_time <= '" + endTime.substring(0, 7) + "' and target_type = '" + entry.getKey() + "'", "target_value", "0", entry.getValue()[0]);
}
Map<String, Object> queryMap2 = baseService.queryForMap("select " + caseWhen2.print() + " from report_electric_cost", queryWrapper2);
Map<String, Object> queryMap1_1 = baseService.queryForMap("select " + caseWhen1_1.print() + " from report_target_config_sub", queryWrapper1_1);
// 详情信息
QueryWrapper<?> queryWrapper3 = new QueryWrapper<>();
queryWrapper3.in("aaa.depart_id", departIdList);
String reitIdStr = dictMap0.keySet().stream().map(key -> "'" + key + "'").collect(Collectors.joining(","));
String departIdStr = departIdList.stream().map(key -> "'" + key + "'").collect(Collectors.joining(","));
String sql0 = "(select depart_id, " + caseWhen0.print() + " from f_report_itemv where reit_id in (" + reitIdStr + ") and depart_id in (" + departIdStr + ") group by depart_id) as aaa";
String sq1 = "(select depart_id, " + caseWhen1.print() + " from report_target_config where depart_id in (" + departIdStr + ") group by depart_id) as bbb";
String sql2 = "(select depart_id, " + caseWhen2.print() + " from report_electric_cost where depart_id in (" + departIdStr + ") group by depart_id) as ccc";
List<Map<String, Object>> queryMapList3 = baseService.queryForList("select aaa.*, bbb.*, ccc.* from " + sql0 + " left join " + sq1 + " on aaa.depart_id = bbb.depart_id left join " + sql2 + " on bbb.depart_id = ccc.depart_id", queryWrapper3);
String sql0_1 = "(select depart_id, " + caseWhen0_1.print() + " from report_electric_cost where depart_id in (" + departIdStr + ") group by depart_id) as bbb";
String sql1 = "(select depart_id, " + caseWhen1.print() + " from report_target_config where depart_id in (" + departIdStr + ") group by depart_id) as ccc";
String sql1_1 = "(select depart_id, " + caseWhen1_1.print() + " from report_target_config_sub where depart_id in (" + departIdStr + ") group by depart_id) as ddd";
List<Map<String, Object>> queryMapList3 = baseService.queryForList("select aaa.*, bbb.*, ccc.*, ddd.* from " + sql0 + " left join " + sql0_1 + " on aaa.depart_id = bbb.depart_id left join " + sql1 + " on bbb.depart_id = ccc.depart_id left join " + sql1_1 + " on ccc.depart_id = ddd.depart_id", queryWrapper3);
// 详情-水费
List<Map<String, Object>> sfwwcList = new ArrayList<>();
List<Map<String, Object>> sfywcList = new ArrayList<>();
List<Map<String, Object>> sfsrwwcList = new ArrayList<>();
List<Map<String, Object>> sjsfywcList = new ArrayList<>();
List<Map<String, Object>> sjslxjList = new ArrayList<>();
List<Map<String, Object>> dfcbList = new ArrayList<>();
List<Map<String, Object>> yfcbList = new ArrayList<>();
......@@ -324,55 +342,63 @@ public class OperationReportServiceImpl implements IOperationReportService {
String tmpDepartId = ConvertUtils.getString(item.get("depart_id"));
String tmpDepartName = sysDepartDictMap.get(tmpDepartId);
// 水费收入 未完成
if (ConvertUtils.getDouble(item.get("sjsf"), 0D) / ConvertUtils.getDouble(item.get("mbsf"), 0D) < 0.25) {
sfwwcList.add(new LinkedHashMap<String, Object>(){{
if (ConvertUtils.getDouble(item.get("sfsr"), 0D) < ConvertUtils.getDouble(item.get("xssfsr"), 0D)) {
Double value = ConvertUtils.getDouble(item.get("sfsr"), 0D) / ConvertUtils.getDouble(item.get("xssfsr"), 0D) * 100;
sfsrwwcList.add(new LinkedHashMap<String, Object>(){{
put("departId", tmpDepartId);
put("departName", tmpDepartName);
put("sjsf", item.get("sjsf"));
put("mbsf", item.get("mbsf"));
put("sfsr", item.get("sfsr"));
put("xssfsr", item.get("xssfsr"));
put("sfsr_xsPercentage", (Double.isInfinite(value) || Double.isNaN(value)) ? null : value);
put("reason", "");
}});
}
// 水费已完成
if (ConvertUtils.getDouble(item.get("sjsf"), 0D) >= ConvertUtils.getDouble(item.get("mbsf"), 0D)) {
sfywcList.add(new LinkedHashMap<String, Object>(){{
// 实际水费 已完成
if (ConvertUtils.getDouble(item.get("sjsf"), 0D) >= ConvertUtils.getDouble(item.get("xssf"), 0D)) {
sjsfywcList.add(new LinkedHashMap<String, Object>(){{
put("departId", tmpDepartId);
put("departName", tmpDepartName);
put("sjsf", item.get("sjsf"));
put("mbsf", item.get("mbsf"));
put("xssf", item.get("mbsf"));
}});
}
// 实际水量同比下降
// 实际水量 同比下降
if (ConvertUtils.getDouble(item.get("sjsl"), 0D) < ConvertUtils.getDouble(item.get("tb_sjsl"), 0D)) {
Double value = (ConvertUtils.getDouble(item.get("sjsl"), 0D) - ConvertUtils.getDouble(item.get("tb_sjsl"), 0D)) / ConvertUtils.getDouble(item.get("tb_sjsl"), 0D) * 100;
sjslxjList.add(new LinkedHashMap<String, Object>(){{
put("departId", tmpDepartId);
put("departName", tmpDepartName);
put("sjsl", item.get("sjsl"));
put("tb_sjsl", item.get("tb_sjsl"));
put("sjsl_tbPercentage", (Double.isInfinite(value) || Double.isNaN(value)) ? null : value);
put("reason", "");
}});
}
// 电费超标
if (ConvertUtils.getDouble(item.get("sjdf"), 0D) > ConvertUtils.getDouble(item.get("mbdf"), 0D)) {
// 电费 超标
if (ConvertUtils.getDouble(item.get("sjdf"), 0D) > ConvertUtils.getDouble(item.get("mbdf"), 0D) * timeList.size() / 12) {
Double value = ConvertUtils.getDouble(item.get("sjdf"), 0D) / ConvertUtils.getDouble(item.get("mbdf"), 0D) * 100;
dfcbList.add(new LinkedHashMap<String, Object>(){{
put("departId", tmpDepartId);
put("departName", tmpDepartName);
put("sjdf", item.get("sjdf"));
put("mbdf", item.get("mbdf"));
put("sjdf_xsPercentage", (Double.isInfinite(value) || Double.isNaN(value)) ? null : value);
put("reason", "");
}});
}
// 药费超标
if (ConvertUtils.getDouble(item.get("sjyf"), 0D) > ConvertUtils.getDouble(item.get("mbyf"), 0D)) {
// 药费 超标
if (ConvertUtils.getDouble(item.get("sjyf"), 0D) > ConvertUtils.getDouble(item.get("mbyf"), 0D) * timeList.size() / 12) {
Double value = ConvertUtils.getDouble(item.get("sjyf"), 0D) / (ConvertUtils.getDouble(item.get("mbyf"), 0D) * timeList.size() * 12) * 100;
yfcbList.add(new LinkedHashMap<String, Object>(){{
put("departId", tmpDepartId);
put("departName", tmpDepartName);
put("sjyf", item.get("sjyf"));
put("mbyf", item.get("mbyf"));
put("sjyf_xsPercentage", (Double.isInfinite(value) || Double.isNaN(value)) ? null : value);
put("reason", "");
}});
}
// 电耗超标
// 电耗 超标
if (ConvertUtils.getDouble(item.get("sjdh"), 0D) > ConvertUtils.getDouble(item.get("mbdh"), 0D)) {
dhcbList.add(new LinkedHashMap<String, Object>(){{
put("departId", tmpDepartId);
......@@ -382,7 +408,7 @@ public class OperationReportServiceImpl implements IOperationReportService {
put("reason", "");
}});
}
// 药耗超标
// 药耗 超标
if (ConvertUtils.getDouble(item.get("sjyh"), 0D) > ConvertUtils.getDouble(item.get("mbyh"), 0D)) {
yhcbList.add(new LinkedHashMap<String, Object>(){{
put("departId", tmpDepartId);
......@@ -418,26 +444,31 @@ public class OperationReportServiceImpl implements IOperationReportService {
// 合并 电费信息
Map<String, Object> queryMap0_2 = new LinkedHashMap<String, Object>() {{
putAll(queryMap0);
putAll(queryMap2);
putAll(queryMap0_1);
}};
for (String key: queryMap0_2.keySet()) {
resMap.put(key, queryMap0_2.get(key));
if (key.startsWith("tb_")) {
// 补充平均值信息
resMap.put(key + "_avg", ConvertUtils.getDouble(queryMap0_2.get(key), 0) / timeListTb.size());
resMap.put(key + "_avg", ConvertUtils.getDouble(queryMap0_2.get(key), 0) / tbTimeList.size());
// 计算同比百分比
String srcKey = key.replaceAll("tb_", "");
double tbPercentage = (ConvertUtils.getDouble(queryMap0_2.get(srcKey), 0D) - ConvertUtils.getDouble(queryMap0_2.get(key), 0D)) / ConvertUtils.getDouble(queryMap0_2.get(key), 0D) * 100;
resMap.put(srcKey + "_tbPercentage", tbPercentage);
Double tbPercentage = (ConvertUtils.getDouble(queryMap0_2.get(srcKey), 0D) - ConvertUtils.getDouble(queryMap0_2.get(key), 0D)) / ConvertUtils.getDouble(queryMap0_2.get(key), 0D) * 100;
resMap.put(srcKey + "_tbPercentage", (Double.isInfinite(tbPercentage) || Double.isNaN(tbPercentage)) ? null : tbPercentage);
} else {
resMap.put(key + "_avg", ConvertUtils.getDouble(queryMap0_2.get(key), 0) / timeList.size());
}
}
resMap.putAll(queryMap1);
resMap.putAll(queryMap1_1);
// 计算完成年度目标情况
for (String[] valueArray: dictMap1.values()) {
double percentage = ConvertUtils.getDouble(resMap.get(valueArray[1]), 0D) / ConvertUtils.getDouble(resMap.get(valueArray[0]), 0D) * 100;
resMap.put(valueArray[1] + "_targetPercentage", percentage);
Double targetPercentage = ConvertUtils.getDouble(resMap.get(valueArray[1]), 0D) / ConvertUtils.getDouble(resMap.get(valueArray[0]), 0D) * 100;
resMap.put(valueArray[1] + "_targetPercentage", (Double.isInfinite(targetPercentage) || Double.isNaN(targetPercentage)) ? null : targetPercentage);
}
for (String[] valueArray: dictMap1_1.values()) {
Double xsPercentage = ConvertUtils.getDouble(resMap.get(valueArray[1]), 0D) / ConvertUtils.getDouble(resMap.get(valueArray[0]), 0D) * 100;
resMap.put(valueArray[1] + "_xsPercentage", (Double.isInfinite(xsPercentage) || Double.isNaN(xsPercentage)) ? null : xsPercentage);
}
// 统一保留2位小数
for (String key: resMap.keySet()) {
......@@ -445,8 +476,8 @@ public class OperationReportServiceImpl implements IOperationReportService {
resMap.put(key, DigitalUtils.nPoint(resMap.get(key), 2));
}
}
resMap.put("sfwwcList", sfwwcList);
resMap.put("sfywcList", sfywcList);
resMap.put("sfsrwwcList", sfsrwwcList);
resMap.put("sjsfywcList", sjsfywcList);
resMap.put("sjslxjList", sjslxjList);
resMap.put("dfcbList", dfcbList);
resMap.put("yfcbList", yfcbList);
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!