tudc 5 years ago
parent
commit
e607bd0ae6

+ 132 - 101
src/main/java/com/minpay/common/service/impl/ReportServiceImpl.java

@@ -94,30 +94,30 @@ public class ReportServiceImpl implements IReportService {
 		// 0-1小时
 		Map<String, String> map0To60 = new HashMap<String, String>();
 		map0To60.put("start", "0");
-		map0To60.put("end", "60");
+		map0To60.put("end", "3600");
 		map0To60.put("desc", "0-1小时");
 		fenduanList.add(map0To60);
 		// 1-6小时
 		Map<String, String> map60To360 = new HashMap<String, String>();
-		map60To360.put("start", "60");
-		map60To360.put("end", "360");
+		map60To360.put("start", "3600");
+		map60To360.put("end", "21600");
 		map60To360.put("desc", "1-6小时");
 		fenduanList.add(map60To360);
 		// 6-12小时
 		Map<String, String> map360To720 = new HashMap<String, String>();
-		map360To720.put("start", "360");
-		map360To720.put("end", "720");
+		map360To720.put("start", "21600");
+		map360To720.put("end", "43200");
 		map360To720.put("desc", "6-12小时");
 		fenduanList.add(map360To720);
 		// 12-24小时
 		Map<String, String> map720To1440 = new HashMap<String, String>();
-		map720To1440.put("start", "720");
-		map720To1440.put("end", "1440");
+		map720To1440.put("start", "43200");
+		map720To1440.put("end", "86400");
 		map720To1440.put("desc", "12-24小时");
 		fenduanList.add(map720To1440);
 		// 24小时以上
 		Map<String, String> mapGT1440 = new HashMap<String, String>();
-		mapGT1440.put("start", "1440");
+		mapGT1440.put("start", "86400");
 		mapGT1440.put("desc", "24小时以上");
 		fenduanList.add(mapGT1440);
 	}
@@ -279,26 +279,26 @@ public class ReportServiceImpl implements IReportService {
 		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("taishan", "0");
 		countMap.put("daiyue", "0");
+		countMap.put("gaoxin", "0");
+		countMap.put("taishanjingqu", "0");
+		countMap.put("xintai", "0");
+		countMap.put("feicheng", "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");
 		
 		
 		Map<String, String> shihuMap = new HashMap<String, String>();
-		shihuMap.put("xintai", "0");
+		shihuMap.put("taishan", "0");
 		shihuMap.put("daiyue", "0");
+		shihuMap.put("gaoxin", "0");
+		shihuMap.put("taishanjingqu", "0");
+		shihuMap.put("xintai", "0");
+		shihuMap.put("feicheng", "0");
 		shihuMap.put("ningyang", "0");
-		shihuMap.put("taishan", "0");
 		shihuMap.put("dongping", "0");
-		shihuMap.put("feicheng", "0");
-		shihuMap.put("taishanjingqu", "0");
-		shihuMap.put("gaoxin", "0");
 		shihuMap.put("heji", "0");
 		
 		for (Map<String, String> map : fileList00) {
@@ -336,66 +336,66 @@ public class ReportServiceImpl implements IReportService {
 		
 		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("泰山");
 		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("taishan"));
 		childList1.add(totalMap.get("daiyue"));
+		childList1.add(totalMap.get("gaoxin"));
+		childList1.add(totalMap.get("taishanjingqu"));
+		childList1.add(totalMap.get("xintai"));
+		childList1.add(totalMap.get("feicheng"));
 		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("taishan"));
 		childList2.add(countMap.get("daiyue"));
+		childList2.add(countMap.get("gaoxin"));
+		childList2.add(countMap.get("taishanjingqu"));
+		childList2.add(countMap.get("xintai"));
+		childList2.add(countMap.get("feicheng"));
 		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> childList9 = new ArrayList<String>();
 		childList9.add("台区停电时户数");
-		childList9.add(CommonUtil.divide(shihuMap.get("xintai"), "60", 2));
+		childList9.add(CommonUtil.divide(shihuMap.get("taishan"), "60", 2));
 		childList9.add(CommonUtil.divide(shihuMap.get("daiyue"), "60", 2));
+		childList9.add(CommonUtil.divide(shihuMap.get("gaoxin"), "60", 2));
+		childList9.add(CommonUtil.divide(shihuMap.get("taishanjingqu"), "60", 2));
+		childList9.add(CommonUtil.divide(shihuMap.get("xintai"), "60", 2));
+		childList9.add(CommonUtil.divide(shihuMap.get("feicheng"), "60", 2));
 		childList9.add(CommonUtil.divide(shihuMap.get("ningyang"), "60", 2));
-		childList9.add(CommonUtil.divide(shihuMap.get("taishan"), "60", 2));
 		childList9.add(CommonUtil.divide(shihuMap.get("dongping"), "60", 2));
-		childList9.add(CommonUtil.divide(shihuMap.get("feicheng"), "60", 2));
-		childList9.add(CommonUtil.divide(shihuMap.get("taishanjingqu"), "60", 2));
-		childList9.add(CommonUtil.divide(shihuMap.get("gaoxin"), "60", 2));
 		childList9.add(CommonUtil.divide(shihuMap.get("heji"), "60", 2));
 		resList.add(childList9);
 		
 		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("taishan"), 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("gaoxin"), totalMap.get("ningyang"), 4), "100", 2) + "%");
+		childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("taishanjingqu"), totalMap.get("taishan"), 4), "100", 2) + "%");
+		childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("xintai"), 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("ningyang"), totalMap.get("taishanjingqu"), 4), "100", 2) + "%");
+		childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("dongping"), totalMap.get("gaoxin"), 4), "100", 2) + "%");
 		childList3.add(CommonUtil.multiply(CommonUtil.divide(countMap.get("heji"), totalMap.get("heji"), 4), "100", 2) + "%");
 		resList.add(childList3);
 		
@@ -434,14 +434,14 @@ public class ReportServiceImpl implements IReportService {
 		}
 		List<String> childList4 = new ArrayList<String>();
 		childList4.add("台区停电个数");
-		childList4.add(tqtdGsMap.get("xintai"));
+		childList4.add(tqtdGsMap.get("taishan"));
 		childList4.add(tqtdGsMap.get("daiyue"));
+		childList4.add(tqtdGsMap.get("gaoxin"));
+		childList4.add(tqtdGsMap.get("taishanjingqu"));
+		childList4.add(tqtdGsMap.get("xintai"));
+		childList4.add(tqtdGsMap.get("feicheng"));
 		childList4.add(tqtdGsMap.get("ningyang"));
-		childList4.add(tqtdGsMap.get("taishan"));
 		childList4.add(tqtdGsMap.get("dongping"));
-		childList4.add(tqtdGsMap.get("feicheng"));
-		childList4.add(tqtdGsMap.get("taishanjingqu"));
-		childList4.add(tqtdGsMap.get("gaoxin"));
 		childList4.add(tqtdGsMap.get("heji"));
 		resList.add(childList4);
 		
@@ -483,14 +483,14 @@ public class ReportServiceImpl implements IReportService {
 		}
 		List<String> childList6 = new ArrayList<String>();
 		childList6.add(monthNum+"个月停电" + countNum + "次及以上台区");
-		childList6.add(taiQuMap.get("xintai").toString());
+		childList6.add(taiQuMap.get("taishan").toString());
 		childList6.add(taiQuMap.get("daiyue").toString());
+		childList6.add(taiQuMap.get("gaoxin").toString());
+		childList6.add(taiQuMap.get("taishanjingqu").toString());
+		childList6.add(taiQuMap.get("xintai").toString());
+		childList6.add(taiQuMap.get("feicheng").toString());
 		childList6.add(taiQuMap.get("ningyang").toString());
-		childList6.add(taiQuMap.get("taishan").toString());
 		childList6.add(taiQuMap.get("dongping").toString());
-		childList6.add(taiQuMap.get("feicheng").toString());
-		childList6.add(taiQuMap.get("taishanjingqu").toString());
-		childList6.add(taiQuMap.get("gaoxin").toString());
 		childList6.add(taiQuMap.get("heji").toString());
 		resList.add(childList6);
 		
@@ -507,14 +507,14 @@ public class ReportServiceImpl implements IReportService {
 		}
 				
 		Map<String, Integer> yesterdayTaiQuMap = new HashMap<String, Integer>();
-		yesterdayTaiQuMap.put("xintai", 0);
+		yesterdayTaiQuMap.put("taishan", 0);
 		yesterdayTaiQuMap.put("daiyue", 0);
+		yesterdayTaiQuMap.put("gaoxin", 0);
+		yesterdayTaiQuMap.put("taishanjingqu", 0);
+		yesterdayTaiQuMap.put("xintai", 0);
+		yesterdayTaiQuMap.put("feicheng", 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"))) {
@@ -538,14 +538,14 @@ public class ReportServiceImpl implements IReportService {
 		}
 		List<String> childList7 = new ArrayList<String>();
 		childList7.add(monthNum+"个月停电" + countNum + "次及以上台区且当日停电");
-		childList7.add(yesterdayTaiQuMap.get("xintai").toString());
+		childList7.add(yesterdayTaiQuMap.get("taishan").toString());
 		childList7.add(yesterdayTaiQuMap.get("daiyue").toString());
+		childList7.add(yesterdayTaiQuMap.get("gaoxin").toString());
+		childList7.add(yesterdayTaiQuMap.get("taishanjingqu").toString());
+		childList7.add(yesterdayTaiQuMap.get("xintai").toString());
+		childList7.add(yesterdayTaiQuMap.get("feicheng").toString());
 		childList7.add(yesterdayTaiQuMap.get("ningyang").toString());
-		childList7.add(yesterdayTaiQuMap.get("taishan").toString());
 		childList7.add(yesterdayTaiQuMap.get("dongping").toString());
-		childList7.add(yesterdayTaiQuMap.get("feicheng").toString());
-		childList7.add(yesterdayTaiQuMap.get("taishanjingqu").toString());
-		childList7.add(yesterdayTaiQuMap.get("gaoxin").toString());
 		childList7.add(yesterdayTaiQuMap.get("heji").toString());
 		resList.add(childList7);
 		
@@ -587,14 +587,14 @@ public class ReportServiceImpl implements IReportService {
 		}
 		List<String> childList8 = new ArrayList<String>();
 		childList8.add("2个月停电1次及以上台区且当日停电");
-		childList8.add(yiciMap.get("xintai").toString());
+		childList8.add(yiciMap.get("taishan").toString());
 		childList8.add(yiciMap.get("daiyue").toString());
+		childList8.add(yiciMap.get("gaoxin").toString());
+		childList8.add(yiciMap.get("taishanjingqu").toString());
+		childList8.add(yiciMap.get("xintai").toString());
+		childList8.add(yiciMap.get("feicheng").toString());
 		childList8.add(yiciMap.get("ningyang").toString());
-		childList8.add(yiciMap.get("taishan").toString());
 		childList8.add(yiciMap.get("dongping").toString());
-		childList8.add(yiciMap.get("feicheng").toString());
-		childList8.add(yiciMap.get("taishanjingqu").toString());
-		childList8.add(yiciMap.get("gaoxin").toString());
 		childList8.add(yiciMap.get("heji").toString());
 		resList.add(childList8);
 		
@@ -790,6 +790,8 @@ public class ReportServiceImpl implements IReportService {
 		}
 		
 		// 平均停电时长
+		String shihuArea = "";	// 时户最大区域
+		String shihuNum = "0";	// 时户最大数
 		String totalHour = "0";	//总时长
 		String totalCountSC = "0";
 		List<Map<String, String>> areaTimeList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByArea(param);
@@ -798,8 +800,8 @@ public class ReportServiceImpl implements IReportService {
 			String timeMinute = map.get("timeMinute");
 			String count = map.get("count");
 			// 平均停电小时
-			String hour = CommonUtil.divide(timeMinute, "60", 2);
-			String hourPJ = CommonUtil.divide(hour, count, 2);
+			String hour = CommonUtil.divide(timeMinute, "60", 2);	// 时户
+			String hourPJ = CommonUtil.divide(hour, count, 2);		// 平均时长
 			if ("新泰".equals(area)) {
 				xintai.add(hour);
 				xintai.add(hourPJ);
@@ -827,6 +829,10 @@ public class ReportServiceImpl implements IReportService {
 			} else {
 				continue;
 			}
+			if (CommonUtil.compare(shihuNum, hour) == -1) {
+				shihuNum = hour;
+				shihuArea = area;
+			}
 			totalHour = CommonUtil.add(totalHour, hour);
 			totalCountSC = CommonUtil.add(totalCountSC, count);
 		}
@@ -1111,6 +1117,9 @@ public class ReportServiceImpl implements IReportService {
 		// 描述数据
 		Map<String, Object> dataMap = new HashMap<String, Object>();
 		dataMap.put("totalCount", totalCount);
+		dataMap.put("totalHour", totalHour);
+		dataMap.put("shihuArea", shihuArea);
+		dataMap.put("shihuNum", shihuNum);
 		dataMap.put("pingjun", CommonUtil.divide(totalHour, totalCount, 2));
 		dataMap.put("twiceCount", totalChongfu);
 		dataMap.put("mostAddressNumDesc", mostAddressNumDesc);
@@ -1170,7 +1179,7 @@ public class ReportServiceImpl implements IReportService {
 		
 		resMap.put("dataMap", dataMap);
 		
-		String descStr = "<p>上周,台区累计停电${totalCount}台次,平均停电时长${pingjun}小时/台。停电两次及以上台区${twiceCount}个,${twiceCountDesc}${mostAddressNumDesc}重复停电次数最多为${mostAddressNum}次。${zuichangTaiqu}停电时长最长为${zuichangSj}小时。</p>"
+		String descStr = "<p>上周,台区累计停电${totalCount}台次(${totalHour}时户),平均停电时长${pingjun}小时/台,${shihuArea}停电时户数最多为${shihuNum}时户。停电两次及以上台区${twiceCount}个,${twiceCountDesc}${mostAddressNumDesc}重复停电次数最多为${mostAddressNum}次。${zuichangTaiqu}停电时长最长为${zuichangSj}小时。</p>"
 				+"上周,督办频繁停电(两个月内三次及以上)共计${dubanCount}台次,${huanbi},${tongbi}${dubantaiciDesc}${liangyueMostAddressNumDesc}两个月内频繁停电次数最多为${liangyueMostAddressNum}次。";
 		resMap.put("descStr", descStr);
 		
@@ -1211,6 +1220,8 @@ public class ReportServiceImpl implements IReportService {
 		List<Map<String, String>> areaCountList = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00TqtdGS(param);
 		//停电时长
 		List<Map<String, String>> areaTimeList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByArea(param);
+		// 台次数
+		List<Map<String, String>> tcList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByAddress(param);
 		//停电台区数
 		param.put("beginDay", beginTime);
 		param.put("endDay", endTime);
@@ -1230,6 +1241,7 @@ public class ReportServiceImpl implements IReportService {
 		param.put("endTime", endTime);
 		List<Map<String, String>> tbAreaCountList = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00TqtdGS(param);
 		List<Map<String, String>> tbAreaTimeList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByArea(param);
+		List<Map<String, String>> tbTcList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByAddress(param);		// 台次
 		/** 去年同月数据---- end ----*/
 		/** 上月月数据---- start ----*/
 		if (CommonUtil.isEmpty(timeRange)) {
@@ -1244,6 +1256,7 @@ public class ReportServiceImpl implements IReportService {
 		param.put("endTime", endTime);
 		List<Map<String, String>> hbAreaCountList = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00TqtdGS(param);
 		List<Map<String, String>> hbAreaTimeList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByArea(param);
+		List<Map<String, String>> hbTcList = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByAddress(param);		// 台次
 		/** 上月月数据---- end ----*/
 		
 		/** 停电台区数 ----start----*/
@@ -1289,7 +1302,23 @@ public class ReportServiceImpl implements IReportService {
 				huanbi = "减少" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(hbCount, benyueCount), hbCount,4), "100", 2) + "%";
 			}
 		}
-		int shejiNum = areaCountList.size();
+		
+		// 台次数
+		String shejiNum = "0";
+		for (Map<String, String> map : tcList) {
+			shejiNum = CommonUtil.add(shejiNum, map.get("num"));
+		}
+		// 去年数据台次数
+		String tbShejiNum = "0";
+		for (Map<String, String> map : tbTcList) {
+			tbShejiNum = CommonUtil.add(tbShejiNum, map.get("num"));
+		}
+		// 上月数据台次数
+		String hbShejiNum = "0";
+		for (Map<String, String> map : hbTcList) {
+			hbShejiNum = CommonUtil.add(hbShejiNum, map.get("num"));
+		}
+		
 		String shejiDesc = "";
 		for (int i = 0; i < areaCountList.size(); i++) {
 			if (i == areaCountList.size() - 1) {
@@ -1320,56 +1349,58 @@ public class ReportServiceImpl implements IReportService {
 		// 平均时长
 		
 		String pingjunHour = "0";
-		if (CommonUtil.compare(totalCount, "0") != 0) {
-			pingjunHour = CommonUtil.divide(benyueTime, totalCount, 2);
+		if (CommonUtil.compare(shejiNum, "0") != 0) {
+			pingjunHour = CommonUtil.divide(benyueTime, shejiNum, 2);
 		}
 		// 同比数据
 		String tongbiPingjunHour = "";
 		if (CommonUtil.compare(tbTime, "0") != 0) {
-			if (CommonUtil.compare(benyueTime, tbTime) == 1) {
-				tongbiPingjunHour = "增加" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(benyueTime, tbTime), tbTime, 4), "100", 2)+"%";
+			tongbiPingjunHour = CommonUtil.divide(tbTime, tbShejiNum, 2);
+			if (CommonUtil.compare(pingjunHour, tongbiPingjunHour) == 1) {
+				tongbiPingjunHour = "增加" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(pingjunHour, tongbiPingjunHour), tongbiPingjunHour, 4), "100", 2)+"%";
 			} else {
-				tongbiPingjunHour = "下降" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(tbTime, benyueTime), tbTime, 4), "100", 2)+"%";
+				tongbiPingjunHour = "下降" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(tongbiPingjunHour, pingjunHour), tongbiPingjunHour, 4), "100", 2)+"%";
 			}
 		}
 		
 		// 环比数据
 		String huanbiPingjunHour = "";
 		if (CommonUtil.compare(hbTime, "0") != 0) {
-			if (CommonUtil.compare(benyueTime, hbTime) == 1) {
-				huanbiPingjunHour = "增加" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(benyueTime, hbTime), hbTime, 4), "100", 2)+"%";
+			huanbiPingjunHour = CommonUtil.divide(hbTime, hbShejiNum, 2);
+			if (CommonUtil.compare(pingjunHour, huanbiPingjunHour) == 1) {
+				huanbiPingjunHour = "增加" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(pingjunHour, huanbiPingjunHour), huanbiPingjunHour, 4), "100", 2)+"%";
 			} else {
-				huanbiPingjunHour = "下降" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(hbTime, benyueTime), hbTime, 4), "100", 2)+"%";
+				huanbiPingjunHour = "下降" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(huanbiPingjunHour, pingjunHour), huanbiPingjunHour, 4), "100", 2)+"%";
 			}
 		}
 		// 台区平均停电时长描述
 		String areaPingjunDesc = "";
-		for (int i = 0; i < areaTimeList.size(); i++) {
-			String pingjunTime =  CommonUtil.divide(CommonUtil.divide(areaTimeList.get(i).get("timeMinute"), areaTimeList.get(i).get("count"), 2),"60", 2);
-			if (areaTimeList.size() - 1 == i) {
-				areaPingjunDesc += areaTimeList.get(i).get("area")+pingjunTime+"小时;";
+		for (int i = 0; i < tcList.size(); i++) {
+			String pingjunTime =  CommonUtil.divide(CommonUtil.divide(tcList.get(i).get("time"), tcList.get(i).get("num"), 2),"60", 2);
+			if (tcList.size() - 1 == i) {
+				areaPingjunDesc += tcList.get(i).get("area")+pingjunTime+"小时;";
 			} else {
-				areaPingjunDesc += areaTimeList.get(i).get("area")+pingjunTime+"小时、";
+				areaPingjunDesc += tcList.get(i).get("area")+pingjunTime+"小时、";
 			}
 		}
 		// 区域平均时长同比
 		String tbAreaPingjunDesc = "";
-		for (int i = 0; i < areaTimeList.size(); i++) {
-			String pingjunTime =  CommonUtil.divide(CommonUtil.divide(areaTimeList.get(i).get("timeMinute"), areaTimeList.get(i).get("count"), 2),"60", 2);
-			for (int j = 0; j < tbAreaTimeList.size(); j++) {
-				if (areaTimeList.get(i).get("area").equals(tbAreaTimeList.get(j).get("area"))) {
-					String tbPingjunTime =  CommonUtil.divide(CommonUtil.divide(tbAreaTimeList.get(j).get("timeMinute"), tbAreaTimeList.get(j).get("count"), 2),"60", 2);
+		for (int i = 0; i < tcList.size(); i++) {
+			String pingjunTime =  CommonUtil.divide(CommonUtil.divide(tcList.get(i).get("time"), tcList.get(i).get("num"), 2),"60", 2);
+			for (int j = 0; j < tbTcList.size(); j++) {
+				if (tcList.get(i).get("area").equals(tbTcList.get(j).get("area"))) {
+					String tbPingjunTime =  CommonUtil.divide(CommonUtil.divide(tbTcList.get(j).get("time"), tbTcList.get(j).get("num"), 2),"60", 2);
 					if (CommonUtil.compare(pingjunTime, tbPingjunTime) == 1) {
-						if (i == areaTimeList.size() - 1) {
-							tbAreaPingjunDesc += areaTimeList.get(i).get("area") + "同比上升" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(pingjunTime, tbPingjunTime), tbPingjunTime, 4), "100", 2)+"%。";
+						if (i == tcList.size() - 1) {
+							tbAreaPingjunDesc += tcList.get(i).get("area") + "同比上升" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(pingjunTime, tbPingjunTime), tbPingjunTime, 4), "100", 2)+"%。";
 						}  else {
-							tbAreaPingjunDesc += areaTimeList.get(i).get("area") + "同比上升" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(pingjunTime, tbPingjunTime), tbPingjunTime, 4), "100", 2)+"%、";
+							tbAreaPingjunDesc += tcList.get(i).get("area") + "同比上升" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(pingjunTime, tbPingjunTime), tbPingjunTime, 4), "100", 2)+"%、";
 						}
 					} else {
-						if (i == areaTimeList.size() - 1) {
-							tbAreaPingjunDesc += areaTimeList.get(i).get("area") + "同比下降" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(tbPingjunTime, pingjunTime), tbPingjunTime, 4), "100", 2)+"%。";
+						if (i == tcList.size() - 1) {
+							tbAreaPingjunDesc += tcList.get(i).get("area") + "同比下降" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(tbPingjunTime, pingjunTime), tbPingjunTime, 4), "100", 2)+"%。";
 						}  else {
-							tbAreaPingjunDesc += areaTimeList.get(i).get("area") + "同比下降" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(tbPingjunTime, pingjunTime), tbPingjunTime, 4), "100", 2)+"%、";
+							tbAreaPingjunDesc += tcList.get(i).get("area") + "同比下降" + CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(tbPingjunTime, pingjunTime), tbPingjunTime, 4), "100", 2)+"%、";
 						}
 					}
 					break;
@@ -1419,9 +1450,9 @@ public class ReportServiceImpl implements IReportService {
 		}
 
 		// 两个月内停电2次以上的数据
-		String beginDay = DateUtil.dateAddMonth(rangeArray[1], Integer.parseInt("-2"));
-		param.put("beginDay", beginDay);
-		param.put("endDay", rangeArray[1]);
+		String beginDay = DateUtil.dateAddDay(DateUtil.dateAddMonth(rangeArray[1], Integer.parseInt("-2")), 1);
+		param.put("beginDay", beginDay + beginTime.substring(8,14));
+		param.put("endDay", rangeArray[1] + endTime.substring(8,14));
 		param.put("countNum", "2");
 		List<Map<String, String>> twiceMountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
 		Map<String, Integer> taiQuMapTwice = new HashMap<String, Integer>();//区域统计
@@ -1467,7 +1498,7 @@ public class ReportServiceImpl implements IReportService {
 		/**停电次数数据处理----end----*/
 		
 		String descStr = "<p>(1)台区停电总体情况${month}月份,台区累计停电${benyueCount}台次,同比${tongbi},环比${huanbi},涉及${shejiNum}个台区,${shejiDesc}</p>"
-				+ "<p>(2)台区停电时长情况${totalCount}个台区累计停电时间${benyueTime}小时,平均停电时长${pingjunHour}小时,同比${tongbiPingjunHour},环比${huanbiPingjunHour}。台区平均停电时间为${areaPingjunDesc}从同比情况看,${tbAreaPingjunDesc}</p>"
+				+ "<p>(2)台区停电时长情况${shejiNum}个台区累计停电时间${benyueTime}小时,平均停电时长${pingjunHour}小时,同比${tongbiPingjunHour},环比${huanbiPingjunHour}。台区平均停电时间为${areaPingjunDesc}从同比情况看,${tbAreaPingjunDesc}</p>"
 				+ "<p>台区停电时长在${fenduanDesc}停电时长最长的为${zuichangTaiQu},停电${zuichangTaiQuTime}小时,其次是${qiciTaiQu},停电时长${qiciTaiQuTime}小时。</p>"
 				+ "<p>(3)台区重复停电情况两个月内停电2次及以上的台变${totalCountTwice}个,其中${totalCountTwiceDesc}${totalCountTwice}个重复停电台变中,${countMapTwiceDesc}两个月内停电3次及以上的台变${totalCountthiple}个。</p>";
 		

+ 3 - 0
src/main/java/com/minpay/common/util/CommonUtil.java

@@ -222,6 +222,9 @@ public class CommonUtil {
 		if (str2 == null || "".equals(str2) || "null".equals(str2)) {
 			str2 = "0";
 		}
+		if (CommonUtil.compare(str2, "0") == 0) {
+			return "0";
+		}
 		BigDecimal big1 = new BigDecimal(str1);
 		BigDecimal big2 = new BigDecimal(str2);
 		BigDecimal iRet = big1.divide(big2, pointWs, BigDecimal.ROUND_HALF_UP);

+ 2 - 0
src/main/java/com/minpay/db/table/own/mapper/ReportServiceMapper.java

@@ -58,4 +58,6 @@ public interface ReportServiceMapper extends IMINMybatisEntityMapper {
 
 	List<Map<String, String>> selectDdyFxbZlhzccx(Map<String, Object> param);
 
+	List<Map<String, String>> selectDetail00ByAddress(Map<String, Object> param);
+
 }

+ 2 - 2
src/main/java/com/minpay/reportManage/action/DataWareManageAction.java

@@ -18,6 +18,7 @@ import javax.servlet.http.HttpServletResponse;
 import com.minpay.db.table.mapper.*;
 import com.minpay.db.table.model.*;
 import org.apache.commons.fileupload.FileItem;
+import org.apache.ibatis.transaction.Transaction;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 
 import com.min.util.DateUtil;
@@ -220,8 +221,7 @@ public class DataWareManageAction implements IMINAction {
 														.andEndTimeEqualTo(endTime);
 					List<DwFileDetail00> selectByExample = db.selectByExample(DwFileDetail00Mapper.class, fileDetail00Example);
 					if (selectByExample.size() != 0) {
-						res.set("chongfu", selectByExample);
-						return res;
+						throw new MINBusinessException("chongfu|" + selectByExample.get(0).getAddressNum() + "|" + selectByExample.get(0).getAddressName() + "|" + selectByExample.get(0).getDate());
 					}
 				}
 				

+ 0 - 3
src/main/java/com/minpay/reportManage/action/ReportManageAction.java

@@ -21,12 +21,9 @@ import org.apache.poi.hssf.usermodel.HSSFPalette;
 import org.apache.poi.hssf.usermodel.HSSFRow;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.hssf.util.HSSFColor;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.FillPatternType;
 import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.IndexedColors;
 
 import com.minpay.common.bean.User;
 import com.minpay.common.constant.Constant;

+ 41 - 12
src/main/resources/com/minpay/db/table/own/mapper/ReportServiceMapper.xml

@@ -21,7 +21,7 @@
 		where
 			1 = 1
 			<if test="beginTime != null  and beginTime != ''">
-		    	and DFD0_START_TIME &gt;= #{beginTime,jdbcType=VARCHAR}
+		    	and DFD0_END_TIME &gt;= #{beginTime,jdbcType=VARCHAR}
 		   	</if>
 			<if test="endTime != null  and endTime != ''">
 		    	and DFD0_END_TIME &lt;= #{endTime,jdbcType=VARCHAR}
@@ -37,7 +37,7 @@
 		where
 			1 = 1
 			<if test="beginTime != null  and beginTime != ''">
-		    	and DFD0_START_TIME &gt;= #{beginTime,jdbcType=VARCHAR}
+		    	and DFD0_END_TIME &gt;= #{beginTime,jdbcType=VARCHAR}
 		   	</if>
 			<if test="endTime != null  and endTime != ''">
 		    	and DFD0_END_TIME &lt;= #{endTime,jdbcType=VARCHAR}
@@ -55,7 +55,7 @@
 		where
 			1 = 1
 			<if test="beginDay != null  and beginDay != ''">
-		    	and DFD0_START_TIME &gt;= #{beginDay,jdbcType=VARCHAR}
+		    	and DFD0_END_TIME &gt;= #{beginDay,jdbcType=VARCHAR}
 		   	</if>
 			<if test="endDay != null  and endDay != ''">
 		    	and DFD0_END_TIME &lt;= #{endDay,jdbcType=VARCHAR}
@@ -67,7 +67,7 @@
 					#{item.addressNum}
 				</foreach>
 		   	</if>
-		group by a.DFD0_ADDRESS_NUM,a.DFD0_AREA,DFD0_ADDRESS_NAME
+		group by a.DFD0_ADDRESS_NUM,a.DFD0_AREA
 		having num &gt;= #{countNum,jdbcType=VARCHAR}
 		ORDER BY COUNT(1) DESC
 	</select>
@@ -93,13 +93,44 @@
 		where
 			1 = 1
 			<if test="beginTime != null  and beginTime != ''">
-		    	and DFD0_START_TIME &gt;= #{beginTime,jdbcType=VARCHAR}
+		    	and DFD0_END_TIME &gt;= #{beginTime,jdbcType=VARCHAR}
 		   	</if>
 			<if test="endTime != null  and endTime != ''">
 		    	and DFD0_END_TIME &lt;= #{endTime,jdbcType=VARCHAR}
 		   	</if>
 		group by a.DFD0_AREA
 	</select>
+	<select id="selectDetail00ByAddress" resultType="hashmap" parameterType="java.util.Map">
+		SELECT 
+		  area,
+		  cast(COUNT(1) as char) num,
+		  cast(SUM(timeMinute) as char) time
+		FROM
+		  (SELECT 
+		    a.DFD0_ADDRESS_NUM addressNum,
+		    a.DFD0_AREA AREA,
+		    CAST(COUNT(1) AS CHAR) num,
+		    SUM(
+		      TIMESTAMPDIFF(
+		        MINUTE,
+		        DFD0_START_TIME,
+		        DFD0_END_TIME
+		      )
+		    ) timeMinute 
+		  FROM
+		    dw_file_detail_00 a 
+		  WHERE
+			1 = 1
+			<if test="beginTime != null  and beginTime != ''">
+		    	and DFD0_END_TIME &gt;= #{beginTime,jdbcType=VARCHAR}
+		   	</if>
+			<if test="endTime != null  and endTime != ''">
+		    	and DFD0_END_TIME &lt;= #{endTime,jdbcType=VARCHAR}
+		   	</if>
+		  GROUP BY a.DFD0_ADDRESS_NUM,
+		    a.DFD0_AREA) a 
+		GROUP BY AREA
+	</select>
 	<select id="selectReportType00FenDuan" resultType="java.lang.String" parameterType="java.util.Map">
 		SELECT 
 		  COUNT(1) 
@@ -107,7 +138,7 @@
 		  (SELECT 
 		    SUM(
 		      TIMESTAMPDIFF(
-		        MINUTE,
+		        SECOND,
 		        DFD0_START_TIME,
 		        DFD0_END_TIME
 		      )
@@ -115,13 +146,12 @@
 		  FROM
 		    dw_file_detail_00 a 
 		  WHERE 
-		  	DFD0_START_TIME &gt;= #{beginTime,jdbcType=VARCHAR}
+		  	DFD0_END_TIME &gt; #{beginTime,jdbcType=VARCHAR}
 		    and DFD0_END_TIME &lt;= #{endTime,jdbcType=VARCHAR}
-		  GROUP BY a.DFD0_ADDRESS_NUM,
-		    a.DFD0_ADDRESS_NAME) b 
+		  GROUP BY a.DFD0_ADDRESS_NUM) b 
 		WHERE 1=1
 			<if test="start != null  and start != ''">
-				and timeMinute &gt;= #{start,jdbcType=VARCHAR} 
+				and timeMinute &gt; #{start,jdbcType=VARCHAR} 
 			</if>
 			<if test="end != null  and end != ''">
 				AND timeMinute &lt;= #{end,jdbcType=VARCHAR} 
@@ -143,8 +173,7 @@
 		  dw_file_detail_00 a 
 		WHERE DFD0_DATE &gt;= #{beginTime,jdbcType=VARCHAR}
 		  AND DFD0_DATE &lt;= #{endTime,jdbcType=VARCHAR}
-		GROUP BY a.DFD0_ADDRESS_NUM,
-		  a.DFD0_ADDRESS_NAME 
+		GROUP BY a.DFD0_ADDRESS_NUM
 		ORDER BY SUM(
 		    TIMESTAMPDIFF(
 		      MINUTE,

+ 13 - 15
src/main/webapp/admin/reprotManage/dataWareUpload.html

@@ -450,22 +450,20 @@
 			    ,done: function(res){
 			    	layer.closeAll('loading'); //关闭loading
 			    	if (res.code == 0) {
-			    		if (isEmpty(res.chongfu)) {
-			    			goStep(3);
-			    		// 有重复数据
-			    		} else {
-			    			var fileType = $("#fileTypeDiv").find("select option:selected").val();
-			    			// 台区停电
-			    			if (fileType == "1000001") {
-			    				layer.confirm("台区编号:【"+res.chongfu[0].addressNum+"】 台区名称:【"+res.chongfu[0].addressName+"】 数据日期:【"+res.chongfu[0].date+"】数据重复,是否继续上传?", {icon: 3, title:'提示'}, function(index){
-			    					chongfuFlag = true;
-									layer.close(index);
-									$('#uploadBtn').click();
-			    				});
-			    			}
-			    		}
+			    		goStep(3);
 			    	} else {
-			    		$.ErrorAlert(res.MINErrorMessage);
+			    		var fileType = $("#fileTypeDiv").find("select option:selected").val();
+			    		console.log(res.MINErrorMessage);
+			    		var errorMessage = res.MINErrorMessage;
+			    		console.log(typeof(errorMessage));
+			    		if (fileType == "1000001" && errorMessage.substr(0, 7) == "chongfu") {
+			    			var message = res.MINErrorMessage.split("|");
+		    				layer.confirm("台区编号:【"+message[1]+"】 台区名称:【"+message[2]+"】 数据日期:【"+message[3]+"】数据重复,是否继续上传?", {icon: 3, title:'提示'}, function(index){
+		    					chongfuFlag = true;
+								layer.close(index);
+								$('#uploadBtn').click();
+		    				});
+		    			}
 			    	}
 			    }
 			    ,error: function(index, upload){

+ 46 - 68
src/main/webapp/admin/tqtd/reportManageDetailTqtd.html

@@ -26,78 +26,56 @@
 	
 	var cols = null;
 	
-	// excel
-	/* if ("00" == type) {
-		$("#reportDiv").hide();
-		$("#reportFujian").hide();
-		$("#reportTitle").html(fileName);
-		$.request({
-			action : 'ReportManageAction/reportInfDetail',
-			data : {
-				reportId : reportId
-			},
-			success : function(data) {
-				var reportDataJsonStr = data.data.data;
-				var excelList = eval('(' + reportDataJsonStr + ')');
-				reportTable(excelList, typeId);
-			},
-			error : function(data2) {
-				$.ErrorAlert(data2.MINErrorMessage);
-			}
-	  	});
-	// word
-	} else { */
-		$("#reportTable").hide();
-		$("#reportTitle").html(fileName);
-		$.request({
-			action : 'ReportManageAction/reportInfDetail',
-			data : {
-				reportId : reportId
-			},
-			success : function(data) {
-				var resJSON = eval('(' + data.data.data + ')');
-				var reportDataJson = resJSON.dataMap;
-				var reportDesc = resJSON.descStr;
-				
-				for(var key in reportDataJson){
-					var replaceStr = "${" + key + "}";
-					if (key == "totalCountTwice") {
-						reportDesc = reportDesc.replace(/\${totalCountTwice}/g, reportDataJson[key]);
-					} else {
-						reportDesc = reportDesc.replace(replaceStr, reportDataJson[key]);
-					}
+	$("#reportTable").hide();
+	$("#reportTitle").html(fileName);
+	$.request({
+		action : 'ReportManageAction/reportInfDetail',
+		data : {
+			reportId : reportId
+		},
+		success : function(data) {
+			var resJSON = eval('(' + data.data.data + ')');
+			var reportDataJson = resJSON.dataMap;
+			var reportDesc = resJSON.descStr;
+			
+			for(var key in reportDataJson){
+				var replaceStr = "${" + key + "}";
+				if (key == "totalCountTwice") {
+					reportDesc = reportDesc.replace(/\${totalCountTwice}/g, reportDataJson[key]);
+				} else {
+					reportDesc = reportDesc.replace(replaceStr, reportDataJson[key]);
 				}
-				$("#reportDiv").html(reportDesc);
-				
-				var excelList = resJSON.excelList;
-				// 周报
-				if (reportType == "TQTDZB") {
-					var tableHtml = '<table class="layui-table">';
-					for (var i = 0; i < excelList.length; i ++) {
-						tableHtml += '<tr>';
-						var childList = excelList[i];
-						for (var j = 0; j < childList.length; j ++) {
-							tableHtml += '<td>' + childList[j] + '</td>';
-						}
-						tableHtml += '</tr>';
+			}
+			$("#reportDiv").html(reportDesc);
+			
+			var excelList = resJSON.excelList;
+			// 周报
+			if (reportType == "TQTDZB") {
+				var tableHtml = '<table class="layui-table">';
+				for (var i = 0; i < excelList.length; i ++) {
+					tableHtml += '<tr>';
+					var childList = excelList[i];
+					for (var j = 0; j < childList.length; j ++) {
+						tableHtml += '<td>' + childList[j] + '</td>';
 					}
-					tableHtml += '</table>';
-					$("#reportDiv").append(tableHtml);
+					tableHtml += '</tr>';
 				}
-				// 日报
-				if (reportType == "TQTDRB") {
-					reportTable(excelList, typeId);
-				}
-				// 不是月报
-				if (reportType != "TQTDYB") {
-					$("#reportFujian").hide();
-				}
-			},
-			error : function(data2) {
-				$.ErrorAlert(data2.MINErrorMessage);
+				tableHtml += '</table>';
+				$("#reportDiv").append(tableHtml);
+			}
+			// 日报
+			if (reportType == "TQTDRB") {
+				reportTable(excelList, typeId);
+			}
+			// 不是月报
+			if (reportType != "TQTDYB") {
+				$("#reportFujian").hide();
 			}
-	  	});
-// 	}
+		},
+		error : function(data2) {
+			$.ErrorAlert(data2.MINErrorMessage);
+		}
+  	});
 	
 	function reportTable(excelList, typeId, isEdit) {
 		var html = '<table class="layui-table">';