提交 043409dc authored 作者: kxjia's avatar kxjia

修改风险监控

上级 a8d17877
...@@ -377,7 +377,7 @@ public class MetricStatReportController extends JeecgController<MetricStatReport ...@@ -377,7 +377,7 @@ public class MetricStatReportController extends JeecgController<MetricStatReport
private String getActionByRiskLevel(int riskLevel, Map<String, Object> data) { private String getActionByRiskLevel(int riskLevel, Map<String, Object> data) {
switch (riskLevel) { switch (riskLevel) {
case 0: return "按时填写数据"; case 0: return "按时填写数据";
case 1: return "继续监测"; case 1: return "持续监测,确保风险指标处于绿色区间";
case 2: return data.get("geWarnAct") != null ? data.get("geWarnAct").toString() : ""; case 2: return data.get("geWarnAct") != null ? data.get("geWarnAct").toString() : "";
case 3: return data.get("geTolAct") != null ? data.get("geTolAct").toString() : ""; case 3: return data.get("geTolAct") != null ? data.get("geTolAct").toString() : "";
default: return ""; default: return "";
......
...@@ -114,32 +114,81 @@ public class MetricReportServiceImpl extends ServiceImpl<MetricReportMapper, Met ...@@ -114,32 +114,81 @@ public class MetricReportServiceImpl extends ServiceImpl<MetricReportMapper, Met
private Date getGroupedDateByFrequency(int frequency, Date date) { private Date getGroupedDateByFrequency(int frequency, Date date) {
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.setTime(date); calendar.setTime(date);
switch (frequency) { switch (frequency) {
case 2: case 2: // 周
calendar.setFirstDayOfWeek(Calendar.MONDAY); calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek()); calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek());
// 设置为当周的周日(一周的最后一天)
calendar.add(Calendar.DAY_OF_WEEK, 6);
break; break;
case 3:
case 3: // 月
calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1);
// 先设置为当月第一天,再加一个月,然后减一天得到当月最后一天
calendar.add(Calendar.MONTH, 1);
calendar.add(Calendar.DAY_OF_MONTH, -1);
break; break;
case 4:
case 4: // 季度
int month = calendar.get(Calendar.MONTH); int month = calendar.get(Calendar.MONTH);
int quarter = (month / 3) + 1; int quarter = (month / 3) + 1;
calendar.set(Calendar.MONTH, (quarter - 1) * 3); calendar.set(Calendar.MONTH, (quarter - 1) * 3);
calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1);
// 先设置为季度第一天,加3个月,然后减一天得到季度最后一天
calendar.add(Calendar.MONTH, 3);
calendar.add(Calendar.DAY_OF_MONTH, -1);
break; break;
case 5:
case 5: // 半年
calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) < 6 ? 0 : 6); calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) < 6 ? 0 : 6);
calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1);
// 先设置为半年第一天,加6个月,然后减一天得到半年最后一天
calendar.add(Calendar.MONTH, 6);
calendar.add(Calendar.DAY_OF_MONTH, -1);
break; break;
case 6:
case 6: // 年
calendar.set(Calendar.MONTH, 0); calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.DAY_OF_MONTH, 1); calendar.set(Calendar.DAY_OF_MONTH, 1);
// 先设置为当年第一天,加12个月(1年),然后减一天得到当年最后一天
calendar.add(Calendar.MONTH, 12);
calendar.add(Calendar.DAY_OF_MONTH, -1);
break; break;
} }
return calendar.getTime(); return calendar.getTime();
} }
// private Date getGroupedDateByFrequency(int frequency, Date date) {
// Calendar calendar = Calendar.getInstance();
// calendar.setTime(date);
// switch (frequency) {
// case 2:
// calendar.setFirstDayOfWeek(Calendar.MONDAY);
// calendar.set(Calendar.DAY_OF_WEEK, calendar.getFirstDayOfWeek());
// break;
// case 3:
// calendar.set(Calendar.DAY_OF_MONTH, 1);
// break;
// case 4:
// int month = calendar.get(Calendar.MONTH);
// int quarter = (month / 3) + 1;
// calendar.set(Calendar.MONTH, (quarter - 1) * 3);
// calendar.set(Calendar.DAY_OF_MONTH, 1);
// break;
// case 5:
// calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) < 6 ? 0 : 6);
// calendar.set(Calendar.DAY_OF_MONTH, 1);
// break;
// case 6:
// calendar.set(Calendar.MONTH, 0);
// calendar.set(Calendar.DAY_OF_MONTH, 1);
// break;
// }
// return calendar.getTime();
// }
private MetricReport createMetricReport(Date fillTime, List<MetricReport> reports, String formulas, MetricMonitorSet monitorSet, LoginUser user) { private MetricReport createMetricReport(Date fillTime, List<MetricReport> reports, String formulas, MetricMonitorSet monitorSet, LoginUser user) {
String newFormulas = formulas; String newFormulas = formulas;
for (MetricReport report : reports) { for (MetricReport report : reports) {
......
...@@ -6,6 +6,7 @@ import org.jeecg.modules.stm.metric.mapper.MetricStatReportMapper; ...@@ -6,6 +6,7 @@ import org.jeecg.modules.stm.metric.mapper.MetricStatReportMapper;
import org.jeecg.modules.stm.metric.service.IMetricStatReportService; import org.jeecg.modules.stm.metric.service.IMetricStatReportService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.RoundingMode;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.*; import java.util.*;
...@@ -97,7 +98,7 @@ public class MetricStatReportServiceImpl extends ServiceImpl<MetricStatReportMap ...@@ -97,7 +98,7 @@ public class MetricStatReportServiceImpl extends ServiceImpl<MetricStatReportMap
} }
} }
riskMap.put("其他", level0); //riskMap.put("其他", level0);
riskMap.put("正常", level1); riskMap.put("正常", level1);
riskMap.put("预警", level2); riskMap.put("预警", level2);
riskMap.put("干预", level3); riskMap.put("干预", level3);
...@@ -159,14 +160,14 @@ public class MetricStatReportServiceImpl extends ServiceImpl<MetricStatReportMap ...@@ -159,14 +160,14 @@ public class MetricStatReportServiceImpl extends ServiceImpl<MetricStatReportMap
numMap.put("low",low); numMap.put("low",low);
numMap.put("middle",middle); numMap.put("middle",middle);
numMap.put("hight",hight); numMap.put("hight",hight);
numMap.put("other",other); //numMap.put("other",other);
numMap.put("total",total); numMap.put("total",total);
retMap.put("num",numMap); retMap.put("num",numMap);
percentMap.put("low",calculate(total,low)); percentMap.put("low",calculate(total,low));
percentMap.put("middle",calculate(total,middle)); percentMap.put("middle",calculate(total,middle));
percentMap.put("hight",calculate(total,hight)); percentMap.put("hight",calculate(total,hight));
percentMap.put("other",calculate(total,other));; //percentMap.put("other",calculate(total,other));;
retMap.put("percent",percentMap); retMap.put("percent",percentMap);
return retMap; return retMap;
...@@ -338,12 +339,17 @@ public class MetricStatReportServiceImpl extends ServiceImpl<MetricStatReportMap ...@@ -338,12 +339,17 @@ public class MetricStatReportServiceImpl extends ServiceImpl<MetricStatReportMap
return retList; return retList;
} }
private Float calculate(Integer total,Integer val) { private Float calculate(Integer total, Integer val) {
if(total.intValue() ==0) return null; if (total == null || total == 0) return null;
if (val == null) return null;
DecimalFormat df = new DecimalFormat("#.##"); DecimalFormat df = new DecimalFormat("#.##");
double d = 100.00*val/total; df.setRoundingMode(RoundingMode.HALF_UP); // 设置四舍五入
double d = 100.00 * val / total;
String result = df.format(d); String result = df.format(d);
return Float.parseFloat(result); return Float.parseFloat(result);
} }
} }
...@@ -13,14 +13,7 @@ ...@@ -13,14 +13,7 @@
AND D.level = 2 AND D.level = 2
WHERE B.mtrc_tp = 1 WHERE B.mtrc_tp = 1
AND C.risk_level IS NOT NULL AND C.risk_level IS NOT NULL
AND ( AND DATE_FORMAT(C.fill_time, '%Y-%m') = DATE_FORMAT(#{query.endDate}, '%Y-%m')
B.coll_freq = #{query.tp}
OR
(
DATE_FORMAT(C.fill_time, '%Y-%m') = DATE_FORMAT(#{query.endDate}, '%Y-%m')
AND B.coll_freq &lt;&gt; #{query.tp}
)
)
GROUP BY D.domain_code, D.domain_name, C.risk_level GROUP BY D.domain_code, D.domain_name, C.risk_level
</select> </select>
<select id="queryMetricStatByMtricClass" resultType="java.util.Map"> <select id="queryMetricStatByMtricClass" resultType="java.util.Map">
...@@ -36,17 +29,7 @@ ...@@ -36,17 +29,7 @@
WHERE B.mtrc_tp = 1 WHERE B.mtrc_tp = 1
AND (B.mtrc_class IS NULL OR E.dict_code = 'mtrc_class') AND (B.mtrc_class IS NULL OR E.dict_code = 'mtrc_class')
AND C.risk_level IS NOT NULL AND C.risk_level IS NOT NULL
AND ( AND C.fill_time BETWEEN #{query.stDate} AND #{query.endDate}
(
C.fill_time BETWEEN #{query.stDate} AND #{query.endDate}
AND B.coll_freq = #{query.tp}
)
OR
(
DATE_FORMAT(C.fill_time, '%Y-%m') = DATE_FORMAT(#{query.endDate}, '%Y-%m')
AND B.coll_freq &lt;&gt; #{query.tp}
)
)
GROUP BY B.mtrc_class, C.risk_level, D.item_text GROUP BY B.mtrc_class, C.risk_level, D.item_text
</select> </select>
<select id="queryMetricStatDetail" resultType="java.util.Map"> <select id="queryMetricStatDetail" resultType="java.util.Map">
...@@ -62,17 +45,12 @@ ...@@ -62,17 +45,12 @@
C.fill_vals AS fillVals, C.fill_vals AS fillVals,
B.unit B.unit
FROM metric_monitor_set B FROM metric_monitor_set B
INNER JOIN metric_report C ON B.mtrc_no = C.mtrc_no INNER JOIN metric_report C ON B.mtrc_no = C.mtrc_no
INNER JOIN st_domain D ON B.domain_no LIKE CONCAT(D.domain_code, '%') INNER JOIN st_domain D ON B.domain_no LIKE CONCAT(D.domain_code, '%')
AND D.level = 2 AND D.level = 2
WHERE B.mtrc_tp = 1 WHERE B.mtrc_tp = 1
AND C.risk_level IS NOT NULL AND C.risk_level IS NOT NULL
AND AND DATE_FORMAT(C.fill_time, '%Y-%m') = DATE_FORMAT(#{query.endDate}, '%Y-%m')
(B.coll_freq = #{query.tp} OR (
DATE_FORMAT(C.fill_time, '%Y-%m') = DATE_FORMAT(#{query.endDate}, '%Y-%m')
AND B.coll_freq &lt;&gt; #{query.tp}
)
)
ORDER BY B.mtrc_no ASC ORDER BY B.mtrc_no ASC
</select> </select>
<select id="queryReportSubTitle" resultType="java.util.Map"> <select id="queryReportSubTitle" resultType="java.util.Map">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论