Parcourir la source

台区停电月报修改

tudc il y a 4 ans
Parent
commit
2f62be0fe7

+ 55 - 10
src/main/java/com/minpay/common/service/impl/ReportServiceImpl.java

@@ -1322,7 +1322,6 @@ public class ReportServiceImpl implements IReportService {
 		param.put("beginDay", beginTime);
 		param.put("endDay", endTime);
 		param.put("countNum", "1");
-		List<Map<String, String>> taiquCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
 		/** 本月数据---- end ----*/
 		/** 去年同月数据---- start ----*/
 		if (CommonUtil.isEmpty(timeRange)) {
@@ -1356,10 +1355,6 @@ public class ReportServiceImpl implements IReportService {
 		/** 上月月数据---- end ----*/
 
 		/** 停电台区数 ----start----*/
-		String totalCount = "0";
-		for (int i = 0; i < taiquCountList.size(); i++) {
-			totalCount = CommonUtil.add(taiquCountList.get(i).get("num"), totalCount);
-		}
 		/** 停电台区数 ---- end ----*/
 
 		/**停电次数数据处理----start----*/
@@ -1503,6 +1498,9 @@ public class ReportServiceImpl implements IReportService {
 				}
 			}
 		}
+		if (!CommonUtil.isEmpty(tbAreaPingjunDesc)) {
+			tbAreaPingjunDesc = "从同比情况看," + tbAreaPingjunDesc;
+		}
 		// 重新计算开始时间和结束时间
 		if (CommonUtil.isEmpty(timeRange)) {
 			beginTime = rangeArray[0] + "000000";
@@ -1520,7 +1518,7 @@ public class ReportServiceImpl implements IReportService {
 			shiduanMap.put("beginTime", beginTime);
 			shiduanMap.put("endTime", endTime);
 			String num = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00FenDuan(shiduanMap);
-			String zhanbi = CommonUtil.multiply(CommonUtil.divide(num, totalCount, 4), "100", 2);
+			String zhanbi = CommonUtil.multiply(CommonUtil.divide(num, shejiNum, 4), "100", 2);
 			if (i == fenduanList.size() - 1) {
 				fenduanDesc += shiduanMap.get("desc")+ "的" + num+ "台,占比"+zhanbi+"%。";
 			} else {
@@ -1582,12 +1580,59 @@ public class ReportServiceImpl implements IReportService {
 			}
 		}
 		String countMapTwiceDesc = "";
+		String max1 = "0";
+		String max1Value = "0";
+		
+		param.put("beginTime", beginDay + beginTime.substring(8,14));
+		param.put("endTime", rangeArray[1] + endTime.substring(8,14));
 		for (Map.Entry<String, Integer> entry : countMapTwice.entrySet()) {
-			countMapTwiceDesc += "停电" + entry.getKey() + "次的" + entry.getValue() + "台,占比" + CommonUtil.multiply(CommonUtil.divide(entry.getValue().toString(), totalCountTwice, 4), "100", 2)+"%;";
+			if (CommonUtil.compare(max1, entry.getKey()) == -1) {
+				max1 = entry.getKey();
+				max1Value = entry.getValue().toString();
+			}
+			countMapTwiceDesc += "停电" + entry.getKey() + "次的" + entry.getValue() + "台,占比" + CommonUtil.multiply(CommonUtil.divide(entry.getValue().toString(), totalCountTwice, 4), "100", 2)+"%,";
+			countMapTwiceDesc += "其中,";
+			// 各区域数量及占比
+			param.put("countNum", entry.getKey());
+			List<Map<String, String>> areaListDesc = db.getMybatisMapper(ReportServiceMapper.class).selectDetail00ByAddress(param);
+			for (Map<String, String> areaMap : areaListDesc) {
+				countMapTwiceDesc += areaMap.get("area") + "区" + areaMap.get("num") + "台,占比" + CommonUtil.multiply(CommonUtil.divide(areaMap.get("num"), entry.getValue().toString(), 4), "100", 2)+"%、";
+			}
+			countMapTwiceDesc = countMapTwiceDesc.substring(0, countMapTwiceDesc.length() - 1) + ";";
 		}
+		
 		if(!"".equals(countMapTwiceDesc)){
 			countMapTwiceDesc = countMapTwiceDesc.substring(0,countMapTwiceDesc.length() - 1) + "。";
 		}
+		// 最高停电台次描述
+		String max1Desc = "";
+		if (!"0".equals(max1)) {
+			max1Desc = "最高停电次数台区为"+ max1 + "次,";
+			param.put("countNum", max1);
+			List<Map<String, String>> maxList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount01(param);
+			String numTemp = "0";
+			String areaTemp = null;
+			for (Map<String, String> maxMap : maxList) {
+				if (areaTemp == null) {
+					areaTemp = maxMap.get("area");
+					numTemp = "1";
+					max1Desc += areaTemp + "区#num#台,为" + maxMap.get("addressName") + "、";
+				} else if (areaTemp.equals(maxMap.get("area"))) {
+					numTemp = CommonUtil.add(numTemp, "1");
+					max1Desc += maxMap.get("addressName") + "、";
+				} else {
+					max1Desc = max1Desc.substring(0, max1Desc.length()-1) + "台区,占比" + CommonUtil.multiply(CommonUtil.divide(numTemp, max1Value, 4), "100", 2) + "%;";
+					max1Desc = max1Desc.replace("#num#", numTemp);
+					
+					numTemp = "1";
+					areaTemp = maxMap.get("area");
+					max1Desc += areaTemp + "区#num#台,为" + maxMap.get("addressName") + "、";
+				}
+			}
+			max1Desc = max1Desc.substring(0, max1Desc.length()-1) + "台区,占比" + CommonUtil.multiply(CommonUtil.divide(numTemp, max1Value, 4), "100", 2) + "%。";
+			max1Desc = max1Desc.replace("#num#", numTemp);
+		}
+		
 		// 两个月内停电3次以上的数据
 		param.put("countNum", "3");
 		List<Map<String, String>> thipleMountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
@@ -1596,9 +1641,9 @@ public class ReportServiceImpl implements IReportService {
 		/**停电次数数据处理----end----*/
 
 		String descStr = "<p>(1)台区停电总体情况${month}月份,台区累计停电${benyueCount}台次,同比${tongbi},环比${huanbi},涉及${shejiNum}个台区,${shejiDesc}</p>"
-				+ "<p>(2)台区停电时长情况${shejiNum}个台区累计停电时间${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>";
+				+ "<p>(3)台区重复停电情况两个月内停电2次及以上的台变${totalCountTwice}个,其中${totalCountTwiceDesc}${totalCountTwice}个重复停电台变中,${countMapTwiceDesc}${max1Desc}两个月内停电3次及以上的台变${totalCountthiple}个。</p>";
 
 		Map<String, Object> dataMap = new HashMap<String, Object>();
 		dataMap.put("month", month);
@@ -1607,7 +1652,6 @@ public class ReportServiceImpl implements IReportService {
 		dataMap.put("huanbi", huanbi);
 		dataMap.put("shejiNum", shejiNum);
 		dataMap.put("shejiDesc", shejiDesc);
-		dataMap.put("totalCount", totalCount);
 		dataMap.put("benyueTime", benyueTime);
 		dataMap.put("pingjunHour", pingjunHour);
 		dataMap.put("tongbiPingjunHour", tongbiPingjunHour);
@@ -1622,6 +1666,7 @@ public class ReportServiceImpl implements IReportService {
 		dataMap.put("totalCountTwice", totalCountTwice);
 		dataMap.put("totalCountTwiceDesc", totalCountTwiceDesc);
 		dataMap.put("countMapTwiceDesc", countMapTwiceDesc);
+		dataMap.put("max1Desc", max1Desc);
 		dataMap.put("totalCountthiple", totalCountthiple);
 
 		Map<String, Object> resMap = new HashMap<String, Object>();

+ 7 - 8
src/main/java/com/minpay/reportManage/action/TQTDReportAction.java

@@ -489,9 +489,6 @@ public class TQTDReportAction implements IMINAction {
 			DwFileDetail00 dwFileDetail00 = fileDetail00List.get(j);
 			// 与上一条数据是否相同
 			if (!dwFileDetail00.getAddressNum().equals(addressNumFlag) && addressNumFlag != null) {
-				/*Map<String, String> excelMap = new HashMap<String, String>();
-				excelMap.put("shichang", String.valueOf(i));
-				excelList.add(excelMap);*/
 				for (int k = 0; k < i; k ++) {
 					Map<String, String> map = excelList.get(j - 1 - k);
 					map.put("cishu", String.valueOf(i));
@@ -517,16 +514,18 @@ public class TQTDReportAction implements IMINAction {
 			excelList.add(excelMap);
 			addressNumFlag = dwFileDetail00.getAddressNum();
 			i ++;
+			if (j == fileDetail00List.size() - 1) {
+				for (int k = 0; k < i; k ++) {
+					Map<String, String> map = excelList.get(j - k);
+					map.put("cishu", String.valueOf(i));
+				}
+			}
 		}
 
-		Map<String, String> excelMap = new HashMap<String, String>();
-		excelMap.put("shichang", String.valueOf(i));
-		excelList.add(excelMap);
-
 		// 格式化时间
 		excelList = Service.lookup(IFormatService.class).formatDateTime(excelList, "startTime", "endTime");
 
-		OutputStream out=null;
+		OutputStream out = null;
 		try {
 			String[] excelHeader = {"台区名称#addressName","数据日期#date","台区编号#addressNum","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电时间#startTime","来电时间#endTime","时长#shichang","停电次数#cishu"};
 			out = response.getOutputStream();

+ 7 - 2
src/main/resources/com/minpay/db/table/own/mapper/ReportServiceMapper.xml

@@ -104,7 +104,7 @@
 		   	</if>
 		group by a.DFD0_ADDRESS_NUM,a.DFD0_AREA
 		having num = #{countNum,jdbcType=VARCHAR}
-		ORDER BY COUNT(1) DESC
+		ORDER BY COUNT(1) DESC, a.DFD0_AREA
 	</select>
 	<select id="queryYesterdayDetail" resultType="hashmap" parameterType="java.util.Map">
 		select
@@ -163,8 +163,13 @@
 		    	and DFD0_END_TIME &lt;= #{endTime,jdbcType=VARCHAR}
 		   	</if>
 		  GROUP BY a.DFD0_ADDRESS_NUM,
-		    a.DFD0_AREA) a 
+		    a.DFD0_AREA
+		    <if test="countNum != null  and countNum != ''">
+		    	having num = #{countNum,jdbcType=VARCHAR}
+		    </if>
+		    ) a 
 		GROUP BY AREA
+		order by COUNT(1) desc
 	</select>
 	<select id="selectReportType00FenDuan" resultType="java.lang.String" parameterType="java.util.Map">
 		SELECT