|
@@ -1,5 +1,10 @@
|
|
|
package com.minpay.reportManage.action;
|
|
|
|
|
|
+import com.minpay.common.constant.Constant;
|
|
|
+import com.minpay.common.util.ExportExcelUtil;
|
|
|
+import com.minpay.common.util.StringUtil;
|
|
|
+import com.minpay.db.table.mapper.*;
|
|
|
+import com.minpay.db.table.model.*;
|
|
|
import com.minpay.db.table.own.mapper.IEFileManageMapper;
|
|
|
import com.minpay.db.table.own.mapper.IQxgdUnitManageMapper;
|
|
|
import com.startup.minpay.frame.business.IMINAction;
|
|
@@ -14,9 +19,12 @@ import com.startup.minpay.frame.target.MINAction;
|
|
|
import com.startup.minpay.frame.target.MINComponent;
|
|
|
import com.startup.minpay.frame.target.MINParam;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import javax.servlet.ServletOutputStream;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.*;
|
|
|
+import java.net.URLEncoder;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@MINComponent
|
|
|
public class EFileReportAction implements IMINAction {
|
|
@@ -25,6 +33,7 @@ public class EFileReportAction implements IMINAction {
|
|
|
/** 电采暖台账查询 */
|
|
|
public final static String REPORT_INF_QUERY = "reportInfQuery";
|
|
|
public final static String REPORT_EDIT = "reportEdit";
|
|
|
+ public final static String FILE_INF_DOWNLOAD = "fileInfDownload";
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -55,5 +64,70 @@ public class EFileReportAction implements IMINAction {
|
|
|
res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 原始数据文件下载
|
|
|
+ * @param fileId
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ * @throws IOException
|
|
|
+ */
|
|
|
+ @MINAction(value = FILE_INF_DOWNLOAD)
|
|
|
+ public HttpServletResponse fileInfDownload(
|
|
|
+ @MINParam(key = "fileId") String fileId,
|
|
|
+ HttpServletResponse response
|
|
|
+ ) throws MINBusinessException, IOException {
|
|
|
+ db = Service.lookup(IMINDataBaseService.class);
|
|
|
+ try {
|
|
|
+ //获取昨天的时间
|
|
|
+ Calendar cal=Calendar.getInstance();
|
|
|
+ cal.add(Calendar.DATE,-1);
|
|
|
+ Date d=cal.getTime();
|
|
|
+ SimpleDateFormat sp=new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String yesterday=sp.format(d);
|
|
|
+// //获取数据
|
|
|
+// String sql="select * from JDBHAPP.FAULT_RECORD where FAULTTIME='"+yesterday+"'";
|
|
|
+// DataTable resultRecord = dbDao.select(sql);
|
|
|
+ ///写入数据
|
|
|
+ // 相对路径,如果没有则要建立一个新的output.txt文件
|
|
|
+ File writeName = new File("../temp/mumengxiang.txt");
|
|
|
+ // 创建新文件,有同名的文件的话直接覆盖
|
|
|
+ writeName.createNewFile();
|
|
|
+ try (FileWriter writer = new FileWriter(writeName);
|
|
|
+ BufferedWriter out = new BufferedWriter(writer)
|
|
|
+ ) {
|
|
|
+ // \r\n即为换行
|
|
|
+ //文件头
|
|
|
+ String headTime= StringUtil.replace(yesterday,"-","");
|
|
|
+ out.write("<! system=继电保护系统 version=1.0 type=notype code=GBK data=1.0 datetime='"+headTime+"_00:00:00' !>\n" +
|
|
|
+ "<继电保护系统::"+headTime+"录播记录信息>\r\n");
|
|
|
+ // 字段名称
|
|
|
+ out.write("@");
|
|
|
+// for(int i=0;i<resultRecord.getColumns().size();i++){
|
|
|
+// out.write(resultRecord.getColumnName(i)+" ");
|
|
|
+// }
|
|
|
+ //结束
|
|
|
+ out.write("\r\n ");
|
|
|
+ //字段简介
|
|
|
+ out.write("//主键值 时间戳 录播记录编号 故障时间毫秒值 主站名 变电站名 录播器名 一次设备名 故障识别 故障测距 录波器类型 对策故障记录ID 录波器测距结果 最低故障电压 最大故障电压 A相最大故障电流一次值 B相最大故障电流一次值 C相最大故障电流一次值 零序最大故障电流一次值 故障信息 数据文件是否存在 电压等级 故障记录对应文件名 上传时间\r\n ");
|
|
|
+// //数据记录
|
|
|
+// DataRowCollection rows = resultRecord.getRows();
|
|
|
+// for (DataRow row: rows){
|
|
|
+// out.write("#");
|
|
|
+// for (int i = 0;i< 25 ; i++) {
|
|
|
+// out.write(row.getValue(i)+" ");
|
|
|
+// }
|
|
|
+// out.write("\r\n ");
|
|
|
+// }
|
|
|
+ //结束
|
|
|
+ out.write("</继电保护系统::"+headTime+"录播记录信息>");
|
|
|
+ // 把缓存区内容压入文件
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
}
|