Ver Fonte

线路重过载

ZHGYL_GKPT há 4 anos atrás
pai
commit
9c302e58a2

+ 0 - 2
src/main/java/com/minpay/common/service/impl/ReportServiceImpl.java

@@ -416,8 +416,6 @@ public class ReportServiceImpl implements IReportService {
 			//获取配变重载数据最大值
 			rstMap.put("descStr",this.getXlgzzDesc(ja,ja2,param));
 			rstMap.put("descStr2",this.getXlPbgzzDesc(ja3,ja4,param));
-
-
 		}
 		return rstMap;
 	}

+ 88 - 0
src/main/java/com/minpay/common/util/ExportUtils.java

@@ -0,0 +1,88 @@
+package com.minpay.common.util;
+
+import org.apache.poi.xssf.usermodel.XSSFCellStyle;
+import org.apache.poi.xssf.usermodel.XSSFColor;
+import org.apache.poi.xssf.usermodel.XSSFFont;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+/**
+ *
+ */
+public class ExportUtils {
+    /**
+     * 描述列样式
+     * @param wb
+     * @return
+     */
+    public static XSSFCellStyle getDescCellStyle(XSSFWorkbook wb){
+        // 生成一个样式
+        XSSFCellStyle style = wb.createCellStyle();
+        // 设置这些样式
+        style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
+        style.setBorderBottom(XSSFCellStyle.BORDER_THIN);
+        style.setBorderLeft(XSSFCellStyle.BORDER_THIN);
+        style.setBorderRight(XSSFCellStyle.BORDER_THIN);
+        style.setBorderTop(XSSFCellStyle.BORDER_THIN);
+        style.setAlignment(XSSFCellStyle.ALIGN_LEFT);
+        // 生成一个字体
+        XSSFFont font = wb.createFont();
+        font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
+        font.setFontName("宋体");
+        font.setColor(new XSSFColor(java.awt.Color.RED));
+        font.setFontHeightInPoints((short) 12);
+        // 把字体应用到当前的样式
+        style.setFont(font);
+        return style;
+    }
+
+        /**
+         * 标题样式
+         * @param wb
+         * @return
+         */
+    public static XSSFCellStyle getTitleCellStyle(XSSFWorkbook wb){
+        // 生成一个样式
+        XSSFCellStyle style = wb.createCellStyle();
+        // 设置这些样式
+        style.setFillForegroundColor(new XSSFColor(java.awt.Color.gray));
+        style.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
+        style.setBorderBottom(XSSFCellStyle.BORDER_THIN);
+        style.setBorderLeft(XSSFCellStyle.BORDER_THIN);
+        style.setBorderRight(XSSFCellStyle.BORDER_THIN);
+        style.setBorderTop(XSSFCellStyle.BORDER_THIN);
+        style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
+        // 生成一个字体
+        XSSFFont font = wb.createFont();
+        font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
+        font.setFontName("宋体");
+        font.setColor(new XSSFColor(java.awt.Color.BLACK));
+        font.setFontHeightInPoints((short) 11);
+        // 把字体应用到当前的样式
+        style.setFont(font);
+        return style;
+    }
+
+    /**
+     * 正文样式
+     * @param wb
+     * @return
+     */
+    public static XSSFCellStyle getTextCellStyle(XSSFWorkbook wb) {
+        // 生成并设置另一个样式
+        XSSFCellStyle style2 = wb.createCellStyle();
+        style2.setFillForegroundColor(new XSSFColor(java.awt.Color.WHITE));
+        style2.setFillPattern(XSSFCellStyle.SOLID_FOREGROUND);
+        style2.setBorderBottom(XSSFCellStyle.BORDER_THIN);
+        style2.setBorderLeft(XSSFCellStyle.BORDER_THIN);
+        style2.setBorderRight(XSSFCellStyle.BORDER_THIN);
+        style2.setBorderTop(XSSFCellStyle.BORDER_THIN);
+        style2.setAlignment(XSSFCellStyle.ALIGN_CENTER);
+        style2.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
+        // 生成另一个字体
+        XSSFFont font2 = wb.createFont();
+        font2.setBoldweight(XSSFFont.BOLDWEIGHT_NORMAL);
+        // 把字体应用到当前的样式
+        style2.setFont(font2);
+        return style2;
+    }
+}

+ 153 - 21
src/main/java/com/minpay/reportManage/action/XlgzzReportAction.java

@@ -5,6 +5,8 @@ import com.minpay.common.constant.Constant;
 import com.minpay.common.format.IFormatService;
 import com.minpay.common.service.IReportService;
 import com.minpay.common.util.DateUtil;
+import com.minpay.common.util.ExportUtils;
+import com.minpay.common.util.StringUtil;
 import com.minpay.db.table.mapper.DwReportDataMapper;
 import com.minpay.db.table.mapper.DwReportInfMapper;
 import com.minpay.db.table.model.DwReportData;
@@ -12,6 +14,7 @@ import com.minpay.db.table.model.DwReportInf;
 import com.minpay.db.table.own.mapper.IReportBatchMapper;
 import com.minpay.db.table.own.mapper.ReportManageMapper;
 import com.minpay.db.table.own.mapper.SequenceMapper;
+import com.mongodb.util.StringBuilderPool;
 import com.startup.minpay.frame.business.IMINAction;
 import com.startup.minpay.frame.business.res.MINActionResult;
 import com.startup.minpay.frame.constant.IMINBusinessConstant;
@@ -24,14 +27,21 @@ import com.startup.minpay.frame.session.MINSession;
 import com.startup.minpay.frame.target.MINAction;
 import com.startup.minpay.frame.target.MINComponent;
 import com.startup.minpay.frame.target.MINParam;
+import org.apache.poi.hssf.usermodel.*;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.util.CellRangeAddress;
+import org.apache.poi.xssf.usermodel.*;
 
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.io.OutputStream;
 import java.lang.reflect.InvocationTargetException;
+import java.net.URLEncoder;
 import java.text.ParseException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 @MINComponent
 public class XlgzzReportAction implements IMINAction {
@@ -40,31 +50,17 @@ public class XlgzzReportAction implements IMINAction {
     public final static String REPORT_INF_QUERY = "reportInfQuery";
 
 
-    /** 生成报表的数据查询 */
-    public final static String FILE_INF_REPORT_QUERY = "fileInfReportQuery";
-
-
     /** 根据不同的报表类型查询对应时间范围类的所需数据 */
     public final static String REPORT_NEED_DATA_DETAIL = "reportNeedDataDetail";
-    public final static String REPORT_NEED_DATA_DETAIL2 = "reportNeedDataDetail2";
 
+    public final static String REPORT_NEED_DATA_DETAIL2 = "reportNeedDataDetail2";
 
     /** 生成报表 */
     public final static String FILE_INF_REPORT_SUBMIT = "fileInfReportSubmit";
 
-
-    /** 报告数据详情 */
-    public final static String REPORT_INF_DETAIL = "reportInfDetail";
-
-
     /** 报告下载 */
     public final static String REPORT_DOWN_LOAD = "reportDownLoad";
 
-
-    /** 报告删除 */
-    public final static String REPORT_INF_DELETE = "reportInfDelete";
-
-
     /** 报告修改 */
     public final static String REPORT_INF_UPDATE = "reportInfUpdate";
     @MINAction(value = REPORT_INF_QUERY)
@@ -206,16 +202,152 @@ public class XlgzzReportAction implements IMINAction {
         Map<String, Object> param = new HashMap<String, Object>();
         param.put("reportId", reportId);
         param.put("reportTypeId","XLGZZRB");
-
+        String fileName = "";
         List<Map<String,String>> list = db.getMybatisMapper(IReportBatchMapper.class).selectReportInfo(param);
-        String range = "";
-        String timeRange = "";
         if(list != null && !list.isEmpty()){
             param.put("range",list.get(0).get("DAYINTERVAL")) ;
             param.put("timeRange",list.get(0).get("TIMEINTERVAL"));
+            fileName = list.get(0).get("FILENAME");
+        }else{
+            param.put("range","19000101-19000101") ;
+            param.put("timeRange","000000-235959");
         }
         Map<String, Object> resMap = Service.lookup(IReportService.class).reportNeedDetail(param);
+        resMap.put("fileName",fileName);
         res.set(IMINBusinessConstant.F_PAGING_LAY, resMap);
         return res;
     }
+
+    @MINAction(value = REPORT_DOWN_LOAD)
+    public MINActionResult reportDownLoad(
+            @MINParam(key = "reportId") String reportId,
+            HttpServletResponse response
+    ) throws Exception {
+        MINActionResult res = new MINActionResult();
+        db = Service.lookup(IMINDataBaseService.class);
+        // 报表类型id
+        Map<String, Object> param = new HashMap<String, Object>();
+        param.put("reportId", reportId);
+        param.put("reportTypeId","XLGZZRB");
+        List<Map<String,String>> list = db.getMybatisMapper(IReportBatchMapper.class).selectReportInfo(param);
+        String fileName = "";
+        if(list != null && !list.isEmpty()){
+            param.put("range",list.get(0).get("DAYINTERVAL")) ;
+            param.put("timeRange",list.get(0).get("TIMEINTERVAL"));
+            fileName = list.get(0).get("FILENAME");
+        }else{
+            param.put("range","19000101-19000101") ;
+            param.put("timeRange","000000-235959");
+        }
+        if("".equals(fileName)){
+            fileName = "线路重过载日报";
+        }
+        Map<String, Object> resMap = Service.lookup(IReportService.class).reportNeedDetail(param);
+        //导出Excel
+        OutputStream out = null;
+        out = response.getOutputStream();
+        XSSFWorkbook wb = export(response, fileName, resMap);
+        if(wb != null){
+            wb.write(out);
+        }
+        out.flush();
+        out.close();
+        return res;
+    }
+    public <T> XSSFWorkbook export(HttpServletResponse response, String fileName, Map<String, Object> map) throws Exception {
+        // 设置请求
+        response.setContentType("application/application/vnd.ms-excel");
+        response.setHeader("Content-disposition",
+                "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "UTF-8"));
+        // 创建一个Workbook,对应一个Excel文件
+        XSSFWorkbook wb = new XSSFWorkbook();
+        //******************************************线路重载明细******************************************//
+        // 标题数组
+        String[] titleArray = new String[]{"单位","供电所","线路名称","重载时长(h)","平均负载率(%)"};
+        // 字段名数组
+        String[] fieldArray = new String[]{"DFD10_XGSMC","DFD10_BZMC","DFD10_XLMC","sum","avg"};
+        Map<String,Object> temp = (Map<String, Object>) map.get("resList");
+        List<String> tempList = (List<String>) temp.get("descStr");
+        StringBuffer descxl = new StringBuffer();
+        descxl.append(tempList.get(0))
+                .append("/r/n")
+                .append(tempList.get(1));
+        List<Map<String,String>> dataList = (List<Map<String, String>>) temp.get("result");
+        int index = 0;
+        index = this.XlzgzCreateSheet(wb,index,"线路重载明细",titleArray,fieldArray,descxl.toString(),dataList,new HashMap<String,String>());
+
+        //******************************************线路过载明细******************************************//
+        titleArray[3] = "过载时长(h)";
+        List<Map<String,String>> dataList2 = (List<Map<String, String>>) temp.get("result2");
+        index = this.XlzgzCreateSheet(wb,index,"线路过载明细",titleArray,fieldArray,"",dataList2,new HashMap<String,String>());
+
+        //******************************************公变重载明细******************************************//
+        String[] titleArray2 = new String[]{"单位","供电所","公变名称","重载时长(h)","平均负载率(%)","原因","解决措施"};
+        String[] fieldArray2 = new String[]{"DFD9_UNIT","DFD9_BZMC","DFD9_GBMC","DFD9_ZZSC","avg","DFD9_JTYY","DFD9_JTJJCS"};
+        List<String> tempList2 = (List<String>) temp.get("descStr2");
+        StringBuffer descxl2 = new StringBuffer();
+        descxl2.append(tempList2.get(0))
+                .append("/r/n")
+                .append(tempList2.get(1));
+        List<Map<String,String>> dataList3 = (List<Map<String, String>>) temp.get("result3");
+        index = this.XlzgzCreateSheet(wb,index,"公变重载明细",titleArray2,fieldArray2,descxl2.toString(),dataList3,new HashMap<String,String>());
+
+        //******************************************公变过载明细******************************************//
+        titleArray2[3] = "过载时长(h)";
+        List<Map<String,String>> dataList4 = (List<Map<String, String>>) temp.get("result4");
+        index = this.XlzgzCreateSheet(wb,index,"公变过载明细",titleArray2,fieldArray2,"",dataList4,new HashMap<String,String>());
+
+        //******************************************抢修类工单明细******************************************//
+        String[] titleArray3 = new String[]{"客户总量(户)","平均到达现场时间(分)","工单处理平均时长(分)","到达现场超时数",
+                "工单时长超70分钟数","客户内部故障","低压故障","非电力故障","电能质量等故障"};
+        String[] fieldArray3 = new String[]{"1","2","3","4","5","6","7","8","9","10","11","12","13"};
+        index = this.XlzgzCreateSheet(wb,index,"抢修类工单报表明细",titleArray3,fieldArray3,"",new ArrayList<>(),new HashMap<String,String>());
+        return wb;
+    }
+    private static int XlzgzCreateSheet(XSSFWorkbook wb,int sheetIndex, String sheetName,String[] titleArray,String[] fieldArray,String descStr,List<Map<String,String>> list,Map<String,String> map){
+        XSSFSheet sheet = wb.createSheet(sheetName);
+        int rowIndex = 0;
+        String title = StringUtil.ObjectToString(map.get("title"));
+        if(!"".equals(title)){
+            XSSFRow row0 = sheet.createRow((int) rowIndex);// 行数从0开始
+            row0.setHeightInPoints(30);//设置行的高度
+            XSSFCell celldesc = row0.createCell(0);
+            sheet.addMergedRegion(new CellRangeAddress(0,0,0,titleArray.length));//合并单元格
+            celldesc.setCellValue(StringUtil.ObjectToString(title));
+            celldesc.setCellStyle(ExportUtils.getDescCellStyle(wb));
+            rowIndex ++;
+        }
+        if(!"".equals(descStr)){
+            //添加描述行
+            XSSFRow row0 = sheet.createRow((int) rowIndex);// 行数从0开始
+            row0.setHeightInPoints(30);//设置行的高度
+            XSSFCell celldesc = row0.createCell(0);
+            sheet.addMergedRegion(new CellRangeAddress(0,0,0,titleArray.length));//合并单元格
+            celldesc.setCellValue(StringUtil.ObjectToString(descStr));
+            celldesc.setCellStyle(ExportUtils.getDescCellStyle(wb));
+            rowIndex++;
+        }
+        if(titleArray.length > 0){
+            // 添加标题行
+            XSSFRow row1 = sheet.createRow((int) rowIndex);
+            for (int i = 0; i < titleArray.length; i++) {
+                XSSFCell titleCell = row1.createCell(i );// 0号位被序号占用,所以需+1
+                titleCell.setCellValue(titleArray[i]);
+                titleCell.setCellStyle(ExportUtils.getTitleCellStyle(wb));
+                sheet.setColumnWidth(i, 30 * 256);
+            }
+            rowIndex ++;
+        }
+        //数据列
+        for (int i = 0; i < list.size(); i++) {
+            //创建行
+            XSSFRow rowr = sheet.createRow((int) rowIndex + i);
+            for (int j = 0; j < fieldArray.length; j++) {
+                XSSFCell cell = rowr.createCell(j);
+                cell.setCellValue(StringUtil.ObjectToString(list.get(i).get(fieldArray[j])));
+                cell.setCellStyle(ExportUtils.getTextCellStyle(wb));
+            }
+        }
+        return 0;
+    }
 }

+ 0 - 17
src/main/java/com/minpay/test.java

@@ -1,17 +0,0 @@
-package com.minpay;
-
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
-public class test {
-
-    public static void main(String[] args) {
-        String datetime = "20140212111012";
-        DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
-        LocalDateTime ldt = LocalDateTime.parse(datetime,dtf);
-        System.out.println(ldt);
-        DateTimeFormatter fa = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
-        String datetime2 = ldt.format(fa);
-        System.out.println(datetime2);
-    }
-}

+ 6 - 0
src/main/webapp/admin/xlgzz/reportManageDetailXlgzz.html

@@ -5,6 +5,12 @@
     <meta charset="utf-8">
     <title>报告详情</title>
     <script src="../../js/min-loader-next.js"></script>
+    <style>
+        .desc_label{
+            font-size: 2rem;
+            line-height: 3rem;
+        }
+    </style>
 </head>
 <body class="content">
     <div style = "width: 100%; margin-left : 0px;" class = "layui-upload-drag" >

+ 4 - 4
src/main/webapp/admin/xlgzz/reportManageXlgzz.html

@@ -40,9 +40,9 @@
 	</div>
 	<script type="text/html" id="barDemo">
 		<a class="layui-btn layui-btn-xs" lay-event="detail">详情查看</a>
-		{{#  if(timeType == '00'){ }}
-			<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
-		{{#  } }}
+<!--		{{#  if(timeType == '00'){ }}-->
+<!--			<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
+<!--		{{#  } }}-->
      	<a class="layui-btn layui-btn-xs" lay-event="downLoad">下载</a>
 		<a class="layui-btn layui-btn-xs" lay-event="delete">删除</a>
    	</script>
@@ -105,7 +105,7 @@
 				if (layEvent === 'detail'){ //查看算法
 					showDetail(data);
 				} else if(layEvent === 'downLoad'){
-					window.open("../../ReportManageAction/reportDownLoad?reportId=" + data.id);
+					window.open("../../XlgzzReportAction/reportDownLoad?reportId=" + data.id);
 				} else if(layEvent === 'delete'){
 					layer.confirm('确认删除?', function(index){
 						layer.close(index);

+ 0 - 20
src/main/webapp/admin/xlgzz/reportProduceXlgzz.html

@@ -169,11 +169,6 @@
 		var $element;
 		layui.use('element', function(){
 			$element= layui.element;
-			//一些事件触发
-			$element.on('tab(demo)', function(data){
-				console.log(data);
-			});
-
 		});
 		layui.use('laydate', function(){
 			var laydate = layui.laydate;
@@ -269,7 +264,6 @@
 											$("#algorithmName").attr("reportTypeId", reportTypeId);
 										}
 									}
-									
 								},
 								error : function(data2) {
 									$.ErrorAlert(data2.MINErrorMessage);
@@ -458,21 +452,7 @@
 							goStep(3);
 						// 月报 或 周报
 						} else if (timeType == '02' || timeType == '01') {
-							$table.render({
-								elem: '#demo2'
-								,limit:100
-								,cols: [[ //表头
-									{field: 'id', title: '单位', width:150}
-									,{field: 'username', title: '供电所', width:150}
-									,{field: 'sex', title: '公变名称', width:150}
-									,{field: 'city', title: '过载时长', width:150}
-									,{field: 'city', title: '平均负载率(%)', width:150}
-									,{field: 'city', title: '原因', width:150}
-									,{field: 'city', title: '解决措施', width:150}
 
-								]],
-								data:data
-							});
 						}
 						$table.render({
 							elem: '#demo3'