|
|
@@ -0,0 +1,300 @@
|
|
|
+package com.minpay.common.service.impl;
|
|
|
+
|
|
|
+
|
|
|
+import java.text.ParseException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import com.minpay.common.constant.Constant;
|
|
|
+import com.minpay.common.service.IReportService;
|
|
|
+import com.minpay.common.util.CommonUtil;
|
|
|
+import com.minpay.common.util.DateUtil;
|
|
|
+import com.minpay.db.table.own.mapper.ReportServiceMapper;
|
|
|
+import com.startup.minpay.frame.exception.MINBusinessException;
|
|
|
+import com.startup.minpay.frame.service.base.IMINDataBaseService;
|
|
|
+import com.startup.minpay.frame.service.base.Service;
|
|
|
+import com.startup.minpay.frame.target.MINComponent;
|
|
|
+
|
|
|
+
|
|
|
+@MINComponent
|
|
|
+public class ReportServiceImpl implements IReportService {
|
|
|
+ static Map<String, String> totalMap = new HashMap<String, String>();
|
|
|
+ static {
|
|
|
+ totalMap.put("xintai", "8382");
|
|
|
+ totalMap.put("daiyue", "4188");
|
|
|
+ totalMap.put("ningyang", "6292");
|
|
|
+ totalMap.put("taishan", "3784");
|
|
|
+ totalMap.put("dongping", "6212");
|
|
|
+ totalMap.put("feicheng", "6547");
|
|
|
+ totalMap.put("taishanjingqu", "1474");
|
|
|
+ totalMap.put("gaoxin", "1945");
|
|
|
+ totalMap.put("heji", "38824");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> reportNeedDetail(Map<String, String> param)
|
|
|
+ throws MINBusinessException, ParseException {
|
|
|
+ String range = param.get("range");
|
|
|
+ String timeRange = param.get("timeRange");
|
|
|
+ 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);
|
|
|
+ resMap.put("resList", resList);
|
|
|
+ }
|
|
|
+ return resMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 台区停电日报生成
|
|
|
+ * @param range 日期范围
|
|
|
+ * @param timeRange 时间段范围
|
|
|
+ * @param monthNum 几个月内停电
|
|
|
+ * @param countNum 停电次数
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ * @throws ParseException
|
|
|
+ */
|
|
|
+ public List<List<String>> reportType00(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;
|
|
|
+ String[] rangeArray = range.split("-");
|
|
|
+ timeRange = timeRange.replaceAll(" ", "");
|
|
|
+ if (CommonUtil.isEmpty(timeRange)) {
|
|
|
+ beginTime = rangeArray[0] + "000000";
|
|
|
+ endTime = rangeArray[1] + "000000";
|
|
|
+ } else {
|
|
|
+ String[] timeRangeArray = timeRange.split("-");
|
|
|
+ beginTime = rangeArray[0] + timeRangeArray[0];
|
|
|
+ endTime = rangeArray[1] + timeRangeArray[1];
|
|
|
+ }
|
|
|
+ param.put("beginTime", beginTime);
|
|
|
+ param.put("endTime", endTime);
|
|
|
+ List<Map<String, String>> fileList00 = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00(param);
|
|
|
+
|
|
|
+ Map<String, String> countMap = new HashMap<String, String>();
|
|
|
+ countMap.put("xintai", "0");
|
|
|
+ countMap.put("daiyue", "0");
|
|
|
+ countMap.put("ningyang", "0");
|
|
|
+ countMap.put("taishan", "0");
|
|
|
+ countMap.put("dongping", "0");
|
|
|
+ countMap.put("feicheng", "0");
|
|
|
+ countMap.put("taishanjingqu", "0");
|
|
|
+ countMap.put("gaoxin", "0");
|
|
|
+ countMap.put("heji", "0");
|
|
|
+
|
|
|
+ for (Map<String, String> map : fileList00) {
|
|
|
+ if ("新泰".equals(map.get("area"))) {
|
|
|
+ countMap.put("xintai",CommonUtil.add(countMap.get("xintai"), "1"));
|
|
|
+ } else if ("岱岳".equals(map.get("area"))) {
|
|
|
+ countMap.put("daiyue",CommonUtil.add(countMap.get("daiyue"), "1"));
|
|
|
+ } else if ("宁阳".equals(map.get("area"))) {
|
|
|
+ countMap.put("ningyang",CommonUtil.add(countMap.get("ningyang"), "1"));
|
|
|
+ } else if ("泰山".equals(map.get("area"))) {
|
|
|
+ countMap.put("taishan",CommonUtil.add(countMap.get("taishan"), "1"));
|
|
|
+ } else if ("东平".equals(map.get("area"))) {
|
|
|
+ countMap.put("dongping",CommonUtil.add(countMap.get("dongping"), "1"));
|
|
|
+ } else if ("肥城".equals(map.get("area"))) {
|
|
|
+ countMap.put("feicheng",CommonUtil.add(countMap.get("feicheng"), "1"));
|
|
|
+ } else if ("泰山景区".equals(map.get("area"))) {
|
|
|
+ countMap.put("taishanjingqu",CommonUtil.add(countMap.get("taishanjingqu"), "1"));
|
|
|
+ } else if ("高新".equals(map.get("area"))) {
|
|
|
+ countMap.put("gaoxin",CommonUtil.add(countMap.get("gaoxin"), "1"));
|
|
|
+ }
|
|
|
+ countMap.put("heji",CommonUtil.add(countMap.get("heji"), "1"));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> childList0 = new ArrayList<String>();
|
|
|
+ childList0.add("分类\\单位");
|
|
|
+ childList0.add("新泰");
|
|
|
+ childList0.add("岱岳");
|
|
|
+ childList0.add("宁阳");
|
|
|
+ childList0.add("泰山");
|
|
|
+ childList0.add("东平");
|
|
|
+ childList0.add("肥城");
|
|
|
+ childList0.add("泰山景区");
|
|
|
+ childList0.add("高新");
|
|
|
+ childList0.add("合计");
|
|
|
+ resList.add(childList0);
|
|
|
+
|
|
|
+ List<String> childList1 = new ArrayList<String>();
|
|
|
+ childList1.add("管辖台区数量");
|
|
|
+ childList1.add(totalMap.get("xintai"));
|
|
|
+ childList1.add(totalMap.get("daiyue"));
|
|
|
+ childList1.add(totalMap.get("ningyang"));
|
|
|
+ childList1.add(totalMap.get("taishan"));
|
|
|
+ childList1.add(totalMap.get("dongping"));
|
|
|
+ childList1.add(totalMap.get("feicheng"));
|
|
|
+ childList1.add(totalMap.get("taishanjingqu"));
|
|
|
+ childList1.add(totalMap.get("gaoxin"));
|
|
|
+ childList1.add(totalMap.get("heji"));
|
|
|
+ resList.add(childList1);
|
|
|
+
|
|
|
+ List<String> childList2 = new ArrayList<String>();
|
|
|
+ childList2.add("台区停电次数");
|
|
|
+ childList2.add(countMap.get("xintai"));
|
|
|
+ childList2.add(countMap.get("daiyue"));
|
|
|
+ childList2.add(countMap.get("ningyang"));
|
|
|
+ childList2.add(countMap.get("taishan"));
|
|
|
+ childList2.add(countMap.get("dongping"));
|
|
|
+ childList2.add(countMap.get("feicheng"));
|
|
|
+ childList2.add(countMap.get("taishanjingqu"));
|
|
|
+ childList2.add(countMap.get("gaoxin"));
|
|
|
+ childList2.add(countMap.get("heji"));
|
|
|
+ resList.add(childList2);
|
|
|
+
|
|
|
+ List<String> childList3 = new ArrayList<String>();
|
|
|
+ childList3.add("台区停电次数");
|
|
|
+ childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("xintai"), totalMap.get("xintai"), 4), "100", 2) + "%");
|
|
|
+ childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("daiyue"), totalMap.get("daiyue"), 4), "100", 2) + "%");
|
|
|
+ childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("ningyang"), totalMap.get("ningyang"), 4), "100", 2) + "%");
|
|
|
+ childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("taishan"), totalMap.get("taishan"), 4), "100", 2) + "%");
|
|
|
+ childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("dongping"), totalMap.get("dongping"), 4), "100", 2) + "%");
|
|
|
+ childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("feicheng"), totalMap.get("feicheng"), 4), "100", 2) + "%");
|
|
|
+ childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("taishanjingqu"), totalMap.get("taishanjingqu"), 4), "100", 2) + "%");
|
|
|
+ childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("gaoxin"), totalMap.get("gaoxin"), 4), "100", 2) + "%");
|
|
|
+ childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("heji"), totalMap.get("heji"), 4), "100", 2) + "%");
|
|
|
+ resList.add(childList3);
|
|
|
+
|
|
|
+ // monthNum个月内停电 countNum次以上的台区
|
|
|
+ String beginDay = DateUtil.dateAddMonth(rangeArray[1], Integer.parseInt("-" + monthNum));
|
|
|
+ param.put("beginDay", beginDay);
|
|
|
+ param.put("endDay", rangeArray[1]);
|
|
|
+ param.put("countNum", countNum);
|
|
|
+ List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
|
|
|
+ Map<String, Integer> taiQuMap = new HashMap<String, Integer>();
|
|
|
+ taiQuMap.put("xintai", 0);
|
|
|
+ taiQuMap.put("daiyue", 0);
|
|
|
+ taiQuMap.put("ningyang", 0);
|
|
|
+ taiQuMap.put("taishan", 0);
|
|
|
+ taiQuMap.put("dongping", 0);
|
|
|
+ taiQuMap.put("feicheng", 0);
|
|
|
+ taiQuMap.put("taishanjingqu", 0);
|
|
|
+ taiQuMap.put("gaoxin", 0);
|
|
|
+ taiQuMap.put("heji", 0);
|
|
|
+ for (Map<String, String> map : mountCountList) {
|
|
|
+ if ("新泰".equals(map.get("area"))) {
|
|
|
+ taiQuMap.put("xintai",taiQuMap.get("xintai") + 1);
|
|
|
+ } else if ("岱岳".equals(map.get("area"))) {
|
|
|
+ taiQuMap.put("daiyue",taiQuMap.get("daiyue") + 1);
|
|
|
+ } else if ("宁阳".equals(map.get("area"))) {
|
|
|
+ taiQuMap.put("ningyang",taiQuMap.get("ningyang") + 1);
|
|
|
+ } else if ("泰山".equals(map.get("area"))) {
|
|
|
+ taiQuMap.put("taishan",taiQuMap.get("taishan") + 1);
|
|
|
+ } else if ("东平".equals(map.get("area"))) {
|
|
|
+ taiQuMap.put("dongping",taiQuMap.get("dongping") + 1);
|
|
|
+ } else if ("肥城".equals(map.get("area"))) {
|
|
|
+ taiQuMap.put("feicheng",taiQuMap.get("feicheng") + 1);
|
|
|
+ } else if ("泰山景区".equals(map.get("area"))) {
|
|
|
+ taiQuMap.put("taishanjingqu",taiQuMap.get("taishanjingqu") + 1);
|
|
|
+ } else if ("高新".equals(map.get("area"))) {
|
|
|
+ taiQuMap.put("gaoxin",taiQuMap.get("gaoxin") + 1);
|
|
|
+ }
|
|
|
+ taiQuMap.put("heji",taiQuMap.get("heji") + 1);
|
|
|
+ }
|
|
|
+ List<String> childList4 = new ArrayList<String>();
|
|
|
+ childList4.add(monthNum+"个月停电" + countNum + "次及以上台区");
|
|
|
+ childList4.add(taiQuMap.get("xintai").toString());
|
|
|
+ childList4.add(taiQuMap.get("daiyue").toString());
|
|
|
+ childList4.add(taiQuMap.get("ningyang").toString());
|
|
|
+ childList4.add(taiQuMap.get("taishan").toString());
|
|
|
+ childList4.add(taiQuMap.get("dongping").toString());
|
|
|
+ childList4.add(taiQuMap.get("feicheng").toString());
|
|
|
+ childList4.add(taiQuMap.get("taishanjingqu").toString());
|
|
|
+ childList4.add(taiQuMap.get("gaoxin").toString());
|
|
|
+ childList4.add(taiQuMap.get("heji").toString());
|
|
|
+ resList.add(childList4);
|
|
|
+
|
|
|
+ // 查询昨日停电的数据
|
|
|
+ param.put("yesterday", DateUtil.dateAddDay(rangeArray[1], -1));
|
|
|
+ List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
|
|
|
+
|
|
|
+ param.put("yesterdayDetail", yesterdayList);
|
|
|
+ List<Map<String, String>> yesterdayAndTDData = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
|
|
|
+
|
|
|
+ Map<String, Integer> yesterdayTaiQuMap = new HashMap<String, Integer>();
|
|
|
+ yesterdayTaiQuMap.put("xintai", 0);
|
|
|
+ yesterdayTaiQuMap.put("daiyue", 0);
|
|
|
+ yesterdayTaiQuMap.put("ningyang", 0);
|
|
|
+ yesterdayTaiQuMap.put("taishan", 0);
|
|
|
+ yesterdayTaiQuMap.put("dongping", 0);
|
|
|
+ yesterdayTaiQuMap.put("feicheng", 0);
|
|
|
+ yesterdayTaiQuMap.put("taishanjingqu", 0);
|
|
|
+ yesterdayTaiQuMap.put("gaoxin", 0);
|
|
|
+ yesterdayTaiQuMap.put("heji", 0);
|
|
|
+ for (Map<String, String> map : yesterdayAndTDData) {
|
|
|
+ if ("新泰".equals(map.get("area"))) {
|
|
|
+ yesterdayTaiQuMap.put("xintai",yesterdayTaiQuMap.get("xintai") + 1);
|
|
|
+ } else if ("岱岳".equals(map.get("area"))) {
|
|
|
+ yesterdayTaiQuMap.put("daiyue",yesterdayTaiQuMap.get("daiyue") + 1);
|
|
|
+ } else if ("宁阳".equals(map.get("area"))) {
|
|
|
+ yesterdayTaiQuMap.put("ningyang",yesterdayTaiQuMap.get("ningyang") + 1);
|
|
|
+ } else if ("泰山".equals(map.get("area"))) {
|
|
|
+ yesterdayTaiQuMap.put("taishan",yesterdayTaiQuMap.get("taishan") + 1);
|
|
|
+ } else if ("东平".equals(map.get("area"))) {
|
|
|
+ yesterdayTaiQuMap.put("dongping",yesterdayTaiQuMap.get("dongping") + 1);
|
|
|
+ } else if ("肥城".equals(map.get("area"))) {
|
|
|
+ yesterdayTaiQuMap.put("feicheng",yesterdayTaiQuMap.get("feicheng") + 1);
|
|
|
+ } else if ("泰山景区".equals(map.get("area"))) {
|
|
|
+ yesterdayTaiQuMap.put("taishanjingqu",yesterdayTaiQuMap.get("taishanjingqu") + 1);
|
|
|
+ } else if ("高新".equals(map.get("area"))) {
|
|
|
+ yesterdayTaiQuMap.put("gaoxin",yesterdayTaiQuMap.get("gaoxin") + 1);
|
|
|
+ }
|
|
|
+ yesterdayTaiQuMap.put("heji",yesterdayTaiQuMap.get("heji") + 1);
|
|
|
+ }
|
|
|
+ List<String> childList5 = new ArrayList<String>();
|
|
|
+ childList5.add(monthNum+"个月停电" + countNum + "次及以上台区且昨日停电");
|
|
|
+ childList5.add(yesterdayTaiQuMap.get("xintai").toString());
|
|
|
+ childList5.add(yesterdayTaiQuMap.get("daiyue").toString());
|
|
|
+ childList5.add(yesterdayTaiQuMap.get("ningyang").toString());
|
|
|
+ childList5.add(yesterdayTaiQuMap.get("taishan").toString());
|
|
|
+ childList5.add(yesterdayTaiQuMap.get("dongping").toString());
|
|
|
+ childList5.add(yesterdayTaiQuMap.get("feicheng").toString());
|
|
|
+ childList5.add(yesterdayTaiQuMap.get("taishanjingqu").toString());
|
|
|
+ childList5.add(yesterdayTaiQuMap.get("gaoxin").toString());
|
|
|
+ childList5.add(yesterdayTaiQuMap.get("heji").toString());
|
|
|
+ resList.add(childList5);
|
|
|
+
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ // 重复统计次数+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);
|
|
|
+ }
|
|
|
+ // 合计次数累计
|
|
|
+ taiQuMap.put("heji", (Integer)taiQuMap.get("heji") + 1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|