|
@@ -3,6 +3,7 @@ package com.minpay.common.service.impl;
|
|
|
|
|
|
import java.text.ParseException;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -42,19 +43,23 @@ public class ReportServiceImpl implements IReportService {
|
|
|
String reportTypeId = param.get("reportTypeId");
|
|
|
|
|
|
Map<String, Object> resMap = new HashMap<String, Object>();
|
|
|
- // 台区停电周报
|
|
|
+ // 台区停电日报
|
|
|
if (Constant.REPORT_TYPE_00.equals(reportTypeId)) {
|
|
|
String monthNum = param.get("monthNum");
|
|
|
String countNum = param.get("countNum");
|
|
|
|
|
|
- List<List<String>> resList = reportType00(range, timeRange, monthNum, countNum);
|
|
|
+ List<List<String>> resList = reportTypeTQTDRB(range, timeRange, monthNum, countNum);
|
|
|
+ resMap.put("resList", resList);
|
|
|
+ // 台区停电周报
|
|
|
+ } else if (Constant.REPORT_TYPE_01.equals(reportTypeId)) {
|
|
|
+ List<List<String>> resList = reportTypeTQTDZB(range, timeRange);
|
|
|
resMap.put("resList", resList);
|
|
|
}
|
|
|
return resMap;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 台区停电日报生成
|
|
|
+ * 台区停电日报
|
|
|
* @param range 日期范围
|
|
|
* @param timeRange 时间段范围
|
|
|
* @param monthNum 几个月内停电
|
|
@@ -63,17 +68,18 @@ public class ReportServiceImpl implements IReportService {
|
|
|
* @throws MINBusinessException
|
|
|
* @throws ParseException
|
|
|
*/
|
|
|
- public List<List<String>> reportType00(String range, String timeRange, String monthNum, String countNum) throws MINBusinessException, ParseException {
|
|
|
+ public List<List<String>> reportTypeTQTDRB(String range, String timeRange, String monthNum, String countNum) throws MINBusinessException, ParseException {
|
|
|
IMINDataBaseService db = Service.lookup(IMINDataBaseService.class);
|
|
|
List<List<String>> resList = new ArrayList<List<String>>();
|
|
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
|
String beginTime = null;
|
|
|
String endTime = null;
|
|
|
+ range = range.replaceAll(" ", "");
|
|
|
String[] rangeArray = range.split("-");
|
|
|
timeRange = timeRange.replaceAll(" ", "");
|
|
|
if (CommonUtil.isEmpty(timeRange)) {
|
|
|
beginTime = rangeArray[0] + "000000";
|
|
|
- endTime = rangeArray[1] + "000000";
|
|
|
+ endTime = rangeArray[1] + "235959";
|
|
|
} else {
|
|
|
String[] timeRangeArray = timeRange.split("-");
|
|
|
beginTime = rangeArray[0] + timeRangeArray[0];
|
|
@@ -269,32 +275,302 @@ public class ReportServiceImpl implements IReportService {
|
|
|
return resList;
|
|
|
}
|
|
|
|
|
|
- public void countTaiqu(Map<String, Object> taiQuMap, Object taiQuObj, String addressNum) {
|
|
|
- Map<String, Object> taiQu;
|
|
|
- // 第一次统计
|
|
|
- if (taiQuObj == null) {
|
|
|
- taiQu = new HashMap<String, Object>();
|
|
|
- taiQu.put(addressNum, 1);
|
|
|
- return;
|
|
|
+ /**
|
|
|
+ * 台区停电周报
|
|
|
+ * @param range
|
|
|
+ * @param timeRange
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ * @throws ParseException
|
|
|
+ */
|
|
|
+ public List<List<String>> reportTypeTQTDZB(String range, String timeRange) throws MINBusinessException, ParseException {
|
|
|
+ IMINDataBaseService db = Service.lookup(IMINDataBaseService.class);
|
|
|
+ Map<String, Object> param = new HashMap<String, Object>();
|
|
|
+ String beginTime = null;
|
|
|
+ String endTime = null;
|
|
|
+ range = range.replaceAll(" ", "");
|
|
|
+ String[] rangeArray = range.split("-");
|
|
|
+ timeRange = timeRange.replaceAll(" ", "");
|
|
|
+ if (CommonUtil.isEmpty(timeRange)) {
|
|
|
+ beginTime = rangeArray[0] + "000000";
|
|
|
+ endTime = rangeArray[1] + "235959";
|
|
|
+ } else {
|
|
|
+ String[] timeRangeArray = timeRange.split("-");
|
|
|
+ beginTime = rangeArray[0] + timeRangeArray[0];
|
|
|
+ endTime = rangeArray[1] + timeRangeArray[1];
|
|
|
+ }
|
|
|
+ param.put("beginTime", beginTime);
|
|
|
+ param.put("endTime", endTime);
|
|
|
+
|
|
|
+
|
|
|
+ List<List<String>> resList = new ArrayList<List<String>>();
|
|
|
+ List<String> title = new ArrayList<String>();
|
|
|
+ title.add("单位\\分类");
|
|
|
+ title.add("管理台区总数");
|
|
|
+ title.add("1个月内累计停电台次");
|
|
|
+ title.add("上月累计停电台次");
|
|
|
+ title.add("去年同期累计停电台次");
|
|
|
+ title.add("1个月内平均停电频次");
|
|
|
+ title.add("平均停电频次排名");
|
|
|
+ title.add("1个月内平均停电时长");
|
|
|
+ title.add("平均停电时长排名");
|
|
|
+ resList.add(title);
|
|
|
+ List<String> xintai = new ArrayList<String>();
|
|
|
+ xintai.add("新泰");
|
|
|
+ xintai.add(totalMap.get("xintai"));
|
|
|
+ List<String> daiyue = new ArrayList<String>();
|
|
|
+ daiyue.add("岱岳");
|
|
|
+ daiyue.add(totalMap.get("daiyue"));
|
|
|
+ List<String> ningyang = new ArrayList<String>();
|
|
|
+ ningyang.add("宁阳");
|
|
|
+ ningyang.add(totalMap.get("ningyang"));
|
|
|
+ List<String> taishan = new ArrayList<String>();
|
|
|
+ taishan.add("泰山");
|
|
|
+ taishan.add(totalMap.get("taishan"));
|
|
|
+ List<String> dongping = new ArrayList<String>();
|
|
|
+ dongping.add("东平");
|
|
|
+ dongping.add(totalMap.get("dongping"));
|
|
|
+ List<String> feicheng = new ArrayList<String>();
|
|
|
+ feicheng.add("肥城");
|
|
|
+ feicheng.add(totalMap.get("feicheng"));
|
|
|
+ List<String> taishanjingqu = new ArrayList<String>();
|
|
|
+ taishanjingqu.add("泰山景区");
|
|
|
+ taishanjingqu.add(totalMap.get("taishanjingqu"));
|
|
|
+ List<String> gaoxin = new ArrayList<String>();
|
|
|
+ gaoxin.add("高新");
|
|
|
+ gaoxin.add(totalMap.get("gaoxin"));
|
|
|
+ List<String> heji = new ArrayList<String>();
|
|
|
+ heji.add("合计");
|
|
|
+ heji.add(totalMap.get("heji"));
|
|
|
+
|
|
|
+
|
|
|
+ resList.add(xintai);
|
|
|
+ resList.add(daiyue);
|
|
|
+ resList.add(ningyang);
|
|
|
+ resList.add(taishan);
|
|
|
+ resList.add(dongping);
|
|
|
+ resList.add(feicheng);
|
|
|
+ resList.add(taishanjingqu);
|
|
|
+ resList.add(gaoxin);
|
|
|
+ resList.add(heji);
|
|
|
+
|
|
|
+ //本月停电次数
|
|
|
+ List<Map<String, String>> areaCountList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByArea(param);
|
|
|
+ String totalCount = "0";
|
|
|
+ for (Map<String, String> map : areaCountList) {
|
|
|
+ String area = map.get("area");
|
|
|
+ String count = map.get("count");
|
|
|
+ if ("新泰".equals(area)) {
|
|
|
+ xintai.add(count);
|
|
|
+ } else if ("岱岳".equals(area)) {
|
|
|
+ daiyue.add(count);
|
|
|
+ } else if ("宁阳".equals(area)) {
|
|
|
+ ningyang.add(count);
|
|
|
+ } else if ("泰山".equals(area)) {
|
|
|
+ taishan.add(count);
|
|
|
+ } else if ("东平".equals(area)) {
|
|
|
+ dongping.add(count);
|
|
|
+ } else if ("肥城".equals(area)) {
|
|
|
+ feicheng.add(count);
|
|
|
+ } else if ("泰山景区".equals(area)) {
|
|
|
+ taishanjingqu.add(count);
|
|
|
+ } else if ("高新".equals(area)) {
|
|
|
+ gaoxin.add(count);
|
|
|
+ }
|
|
|
+ totalCount = CommonUtil.add(totalCount, count);
|
|
|
}
|
|
|
- // 重复统计次数+1
|
|
|
- taiQu = (Map<String, Object>)taiQuObj;
|
|
|
- for(Map.Entry<String, Object> entry : taiQu.entrySet()){
|
|
|
- int itemVal = (Integer)entry.getValue();
|
|
|
- String key = entry.getKey();
|
|
|
- if (addressNum == key) {
|
|
|
- taiQu.put(key, (itemVal + 1));
|
|
|
- if ((itemVal + 1) >= 3) {
|
|
|
- Object countObj = taiQu.get(key);
|
|
|
- if (countObj == null) {
|
|
|
- taiQu.put("count", 1);
|
|
|
- } else {
|
|
|
- taiQu.put("count", (Integer)countObj + 1);
|
|
|
+ heji.add(totalCount);
|
|
|
+ // 没有数据的区域数值为0
|
|
|
+ for (List<String> list : resList) {
|
|
|
+ if (list.size() == 2) {
|
|
|
+ list.add("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //上个与月停电次数
|
|
|
+ beginTime = DateUtil.dateAddMonth(rangeArray[0], -1);
|
|
|
+ endTime = DateUtil.dateAddMonth(rangeArray[1], -1);
|
|
|
+ if (CommonUtil.isEmpty(timeRange)) {
|
|
|
+ beginTime = beginTime + "000000";
|
|
|
+ endTime = endTime + "235959";
|
|
|
+ } else {
|
|
|
+ String[] timeRangeArray = timeRange.split("-");
|
|
|
+ beginTime = beginTime + timeRangeArray[0];
|
|
|
+ endTime = endTime + timeRangeArray[1];
|
|
|
+ }
|
|
|
+ param.put("beginTime", beginTime);
|
|
|
+ param.put("endTime", endTime);
|
|
|
+ List<Map<String, String>> lastMonthAreaCountList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByArea(param);
|
|
|
+ String lastMonthtotalCount = "0";
|
|
|
+ for (Map<String, String> map : lastMonthAreaCountList) {
|
|
|
+ String area = map.get("area");
|
|
|
+ String count = map.get("count");
|
|
|
+ if ("新泰".equals(area)) {
|
|
|
+ xintai.add(count);
|
|
|
+ } else if ("岱岳".equals(area)) {
|
|
|
+ daiyue.add(count);
|
|
|
+ } else if ("宁阳".equals(area)) {
|
|
|
+ ningyang.add(count);
|
|
|
+ } else if ("泰山".equals(area)) {
|
|
|
+ taishan.add(count);
|
|
|
+ } else if ("东平".equals(area)) {
|
|
|
+ dongping.add(count);
|
|
|
+ } else if ("肥城".equals(area)) {
|
|
|
+ feicheng.add(count);
|
|
|
+ } else if ("泰山景区".equals(area)) {
|
|
|
+ taishanjingqu.add(count);
|
|
|
+ } else if ("高新".equals(area)) {
|
|
|
+ gaoxin.add(count);
|
|
|
+ }
|
|
|
+ lastMonthtotalCount = CommonUtil.add(lastMonthtotalCount, count);
|
|
|
+ }
|
|
|
+ heji.add(lastMonthtotalCount);
|
|
|
+ // 没有数据的区域数值为0
|
|
|
+ for (List<String> list : resList) {
|
|
|
+ if (list.size() == 3) {
|
|
|
+ list.add("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //去年同期停电次数
|
|
|
+ beginTime = DateUtil.dateAddYear(rangeArray[0], -1);
|
|
|
+ endTime = DateUtil.dateAddYear(rangeArray[1], -1);
|
|
|
+ if (CommonUtil.isEmpty(timeRange)) {
|
|
|
+ beginTime = beginTime + "000000";
|
|
|
+ endTime = endTime + "235959";
|
|
|
+ } else {
|
|
|
+ String[] timeRangeArray = timeRange.split("-");
|
|
|
+ beginTime = beginTime + timeRangeArray[0];
|
|
|
+ endTime = endTime + timeRangeArray[1];
|
|
|
+ }
|
|
|
+ param.put("beginTime", beginTime);
|
|
|
+ param.put("endTime", endTime);
|
|
|
+ List<Map<String, String>> lastYearAreaCountList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByArea(param);
|
|
|
+ String lastYeartotalCount = "0";
|
|
|
+ for (Map<String, String> map : lastYearAreaCountList) {
|
|
|
+ String area = map.get("area");
|
|
|
+ String count = map.get("count");
|
|
|
+ if ("新泰".equals(area)) {
|
|
|
+ xintai.add(count);
|
|
|
+ } else if ("岱岳".equals(area)) {
|
|
|
+ daiyue.add(count);
|
|
|
+ } else if ("宁阳".equals(area)) {
|
|
|
+ ningyang.add(count);
|
|
|
+ } else if ("泰山".equals(area)) {
|
|
|
+ taishan.add(count);
|
|
|
+ } else if ("东平".equals(area)) {
|
|
|
+ dongping.add(count);
|
|
|
+ } else if ("肥城".equals(area)) {
|
|
|
+ feicheng.add(count);
|
|
|
+ } else if ("泰山景区".equals(area)) {
|
|
|
+ taishanjingqu.add(count);
|
|
|
+ } else if ("高新".equals(area)) {
|
|
|
+ gaoxin.add(count);
|
|
|
+ }
|
|
|
+ lastYeartotalCount = CommonUtil.add(lastYeartotalCount, count);
|
|
|
+ }
|
|
|
+ heji.add(lastYeartotalCount);
|
|
|
+ // 没有数据的区域数值为0
|
|
|
+ for (List<String> list : resList) {
|
|
|
+ if (list.size() == 4) {
|
|
|
+ list.add("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1个月内平均停电频次
|
|
|
+ for (int i = 1; i < resList.size(); i ++) {
|
|
|
+ List<String> list = resList.get(i);
|
|
|
+ String totalNum = list.get(1);
|
|
|
+ String tingdianNum = list.get(2);
|
|
|
+ String pinci = "0";
|
|
|
+ if (!(CommonUtil.compare(totalNum, "0") == 0)) {
|
|
|
+ pinci = CommonUtil.divide(tingdianNum, totalNum, 2);
|
|
|
+ }
|
|
|
+ list.add(pinci);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> pinciPaiming = new ArrayList<Integer>();
|
|
|
+ // 平均停电频次排名,合计不参与排名
|
|
|
+ for (int i = 1; i < resList.size() - 1; i ++) {
|
|
|
+ String pinci = resList.get(i).get(5);
|
|
|
+ // 排名
|
|
|
+ int num = 1;
|
|
|
+ for (int j = 1; j < resList.size() - 1; j ++) {
|
|
|
+ // 不和本次作对比
|
|
|
+ if (i != j) {
|
|
|
+ String comparePinci = resList.get(j).get(5);
|
|
|
+ // 不比对比频次大
|
|
|
+ if (CommonUtil.compare(comparePinci, pinci) == -1) {
|
|
|
+ num ++;
|
|
|
}
|
|
|
- // 合计次数累计
|
|
|
- taiQuMap.put("heji", (Integer)taiQuMap.get("heji") + 1);
|
|
|
}
|
|
|
}
|
|
|
+ // 相同次数的往后排
|
|
|
+ while (pinciPaiming.contains(num)) {
|
|
|
+ num ++;
|
|
|
+ }
|
|
|
+ pinciPaiming.add(num);
|
|
|
+ resList.get(i).add(String.valueOf(num));
|
|
|
+ }
|
|
|
+ heji.add("");
|
|
|
+
|
|
|
+ String totalTimeMinute = "0";
|
|
|
+ for (Map<String, String> map : areaCountList) {
|
|
|
+ String area = map.get("area");
|
|
|
+ String timeMinute = map.get("timeMinute");
|
|
|
+ String count = map.get("count");
|
|
|
+ if ("新泰".equals(area)) {
|
|
|
+ xintai.add(CommonUtil.divide(CommonUtil.divide(timeMinute, "60", 4), count, 2));
|
|
|
+ } else if ("岱岳".equals(area)) {
|
|
|
+ daiyue.add(CommonUtil.divide(CommonUtil.divide(timeMinute, "60", 4), count, 2));
|
|
|
+ } else if ("宁阳".equals(area)) {
|
|
|
+ ningyang.add(CommonUtil.divide(CommonUtil.divide(timeMinute, "60", 4), count, 2));
|
|
|
+ } else if ("泰山".equals(area)) {
|
|
|
+ taishan.add(CommonUtil.divide(CommonUtil.divide(timeMinute, "60", 4), count, 2));
|
|
|
+ } else if ("东平".equals(area)) {
|
|
|
+ dongping.add(CommonUtil.divide(CommonUtil.divide(timeMinute, "60", 4), count, 2));
|
|
|
+ } else if ("肥城".equals(area)) {
|
|
|
+ feicheng.add(CommonUtil.divide(CommonUtil.divide(timeMinute, "60", 4), count, 2));
|
|
|
+ } else if ("泰山景区".equals(area)) {
|
|
|
+ taishanjingqu.add(CommonUtil.divide(CommonUtil.divide(timeMinute, "60", 4), count, 2));
|
|
|
+ } else if ("高新".equals(area)) {
|
|
|
+ gaoxin.add(CommonUtil.divide(CommonUtil.divide(timeMinute, "60", 4), count, 2));
|
|
|
+ }
|
|
|
+ totalTimeMinute = CommonUtil.add(totalTimeMinute, timeMinute);
|
|
|
}
|
|
|
+ heji.add(CommonUtil.divide(CommonUtil.divide(totalTimeMinute, "60", 4), heji.get(2), 2));
|
|
|
+
|
|
|
+ // 没有数据的区域数值为0
|
|
|
+ for (List<String> list : resList) {
|
|
|
+ if (list.size() == 7) {
|
|
|
+ list.add("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> shichangPaiming = new ArrayList<Integer>();
|
|
|
+ // 平均停电频次排名,合计不参与排名
|
|
|
+ for (int i = 1; i < resList.size() - 1; i ++) {
|
|
|
+ String shichang = resList.get(i).get(7);
|
|
|
+ // 排名
|
|
|
+ int num = 1;
|
|
|
+ for (int j = 1; j < resList.size() - 1; j ++) {
|
|
|
+ // 不和本次作对比
|
|
|
+ if (i != j) {
|
|
|
+ String compareshichang = resList.get(j).get(7);
|
|
|
+ // 不比对比频次大
|
|
|
+ if (CommonUtil.compare(compareshichang, shichang) == -1) {
|
|
|
+ num ++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 相同次数的往后排
|
|
|
+ while (shichangPaiming.contains(num)) {
|
|
|
+ num ++;
|
|
|
+ }
|
|
|
+ shichangPaiming.add(num);
|
|
|
+ resList.get(i).add(String.valueOf(num));
|
|
|
+ }
|
|
|
+ heji.add("");
|
|
|
+
|
|
|
+
|
|
|
+ return resList;
|
|
|
}
|
|
|
}
|