|
@@ -1,13 +1,25 @@
|
|
|
package com.minpay.reportManage.action;
|
|
|
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.lang.reflect.InvocationTargetException;
|
|
|
import java.text.ParseException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+
|
|
|
import com.minpay.common.format.IFormatService;
|
|
|
+import com.minpay.common.util.CommonUtil;
|
|
|
import com.minpay.common.util.DateUtil;
|
|
|
+import com.minpay.common.util.ExportExcelUtil;
|
|
|
+import com.minpay.db.table.mapper.DwFileDetail00Mapper;
|
|
|
import com.minpay.db.table.mapper.DwReportInfMapper;
|
|
|
+import com.minpay.db.table.model.DwFileDetail00;
|
|
|
+import com.minpay.db.table.model.DwFileDetail00Example;
|
|
|
import com.minpay.db.table.model.DwReportInf;
|
|
|
import com.minpay.db.table.own.mapper.ReportServiceMapper;
|
|
|
import com.startup.minpay.frame.business.IMINAction;
|
|
@@ -26,9 +38,12 @@ import com.startup.minpay.frame.target.MINParam;
|
|
|
public class TQTDReportAction implements IMINAction {
|
|
|
|
|
|
private IMINDataBaseService db;
|
|
|
- /** 台区停电穿透数据 */
|
|
|
+ /** 台区停电日报穿透数据 */
|
|
|
public final static String REPORT_INF_CHUANTOU = "reportInfChuantou";
|
|
|
|
|
|
+ /** 台区停电月报附件 */
|
|
|
+ public final static String REPORT_INF_FUJIAN = "reportInfFujian";
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 台区停电穿透数据
|
|
@@ -120,4 +135,118 @@ public class TQTDReportAction implements IMINAction {
|
|
|
|
|
|
return res;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 台区停电附件导出
|
|
|
+ * @param reportId
|
|
|
+ * @param response
|
|
|
+ * @param session
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ * @throws ParseException
|
|
|
+ * @throws NoSuchMethodException
|
|
|
+ * @throws SecurityException
|
|
|
+ * @throws IllegalAccessException
|
|
|
+ * @throws IllegalArgumentException
|
|
|
+ * @throws InvocationTargetException
|
|
|
+ */
|
|
|
+ @MINAction(value = REPORT_INF_FUJIAN)
|
|
|
+ public HttpServletResponse reportInfFujian(
|
|
|
+ @MINParam(key = "reportId") String reportId,
|
|
|
+ HttpServletResponse response,
|
|
|
+ MINSession session
|
|
|
+ ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
|
+ db = Service.lookup(IMINDataBaseService.class);
|
|
|
+ //分页
|
|
|
+ MINRowBounds rows = new MINRowBounds();
|
|
|
+ rows.setSeparateSql(true);
|
|
|
+ DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
|
|
|
+ // 日期区间
|
|
|
+ String dayInterval = reportInf.getDayInterval();
|
|
|
+ // 时分秒区间
|
|
|
+ String timeInterval = reportInf.getTimeInterval();
|
|
|
+ // 获取时分秒
|
|
|
+ String beginTime = null;
|
|
|
+ String endTime = null;
|
|
|
+ String[] rangeArray = dayInterval.split("-");
|
|
|
+ if (CommonUtil.isEmpty(timeInterval)) {
|
|
|
+ beginTime = rangeArray[0] + "000000";
|
|
|
+ endTime = rangeArray[1] + "235959";
|
|
|
+ } else {
|
|
|
+ String[] timeRangeArray = timeInterval.split("-");
|
|
|
+ beginTime = rangeArray[0] + timeRangeArray[0];
|
|
|
+ endTime = rangeArray[1] + timeRangeArray[1];
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> param = new HashMap<String, Object>();
|
|
|
+ param.put("beginTime", beginTime);
|
|
|
+ param.put("endTime", endTime);
|
|
|
+
|
|
|
+ String beginDay = DateUtil.dateAddMonth(rangeArray[1], Integer.parseInt("-2"));
|
|
|
+ param.put("beginDay", beginDay);
|
|
|
+ param.put("endDay", rangeArray[1]);
|
|
|
+ param.put("countNum", "3");
|
|
|
+ List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
|
|
|
+
|
|
|
+ List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
|
|
|
+ DwFileDetail00Example fileDetail00Example = new DwFileDetail00Example();
|
|
|
+ fileDetail00Example.createCriteria().andAddressNumIn(addressNumList)
|
|
|
+ .andStartTimeGreaterThanOrEqualTo(beginDay).andStartTimeLessThanOrEqualTo(rangeArray[1]);
|
|
|
+ fileDetail00Example.setOrderByClause("DFD0_ADDRESS_NUM desc");
|
|
|
+ List<DwFileDetail00> fileDetail00List = db.selectByExample(DwFileDetail00Mapper.class, fileDetail00Example);
|
|
|
+ int i = 0;
|
|
|
+ String addressNumFlag = null;
|
|
|
+ List<Map<String, String>> excelList = new ArrayList<Map<String,String>>();
|
|
|
+ for (DwFileDetail00 dwFileDetail00 : fileDetail00List) {
|
|
|
+ // 与上一条数据是否相同
|
|
|
+ if (!dwFileDetail00.getAddressNum().equals(addressNumFlag) && addressNumFlag != null) {
|
|
|
+ Map<String, String> excelMap = new HashMap<String, String>();
|
|
|
+ excelMap.put("shichang", String.valueOf(i));
|
|
|
+ excelList.add(excelMap);
|
|
|
+ i = 0;
|
|
|
+ }
|
|
|
+ Map<String, String> excelMap = new HashMap<String, String>();
|
|
|
+ excelMap.put("addressNum", dwFileDetail00.getAddressNum());
|
|
|
+ excelMap.put("addressName", dwFileDetail00.getAddressName());
|
|
|
+ excelMap.put("date", dwFileDetail00.getDate());
|
|
|
+ excelMap.put("area", dwFileDetail00.getArea());
|
|
|
+ excelMap.put("comonpanyName", dwFileDetail00.getComonpanyName());
|
|
|
+ excelMap.put("terminalName", dwFileDetail00.getTerminalName());
|
|
|
+ excelMap.put("terminalNum", dwFileDetail00.getTerminalNum());
|
|
|
+ excelMap.put("terminalAddress", dwFileDetail00.getTerminalAddress());
|
|
|
+ excelMap.put("startTime", dwFileDetail00.getStartTime());
|
|
|
+ excelMap.put("endTime", dwFileDetail00.getEndTime());
|
|
|
+ // 时差分钟
|
|
|
+ Long dateDiff = DateUtil.dateDiff(dwFileDetail00.getStartTime(), dwFileDetail00.getEndTime());
|
|
|
+ // 转换成小时
|
|
|
+ String shichang = CommonUtil.divide(String.valueOf(dateDiff), "60", 2);
|
|
|
+ excelMap.put("shichang", shichang);
|
|
|
+ excelList.add(excelMap);
|
|
|
+ addressNumFlag = dwFileDetail00.getAddressNum();
|
|
|
+ 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;
|
|
|
+ try {
|
|
|
+ String[] excelHeader = {"台区名称#addressName","数据日期#date","台区编号#addressNum","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电时间#startTime","来电时间#endTime","时长#shichang"};
|
|
|
+ out = response.getOutputStream();
|
|
|
+ HSSFWorkbook wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
|
|
|
+ if(wb != null){
|
|
|
+ wb.write(out);
|
|
|
+ }
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return response;
|
|
|
+ }
|
|
|
}
|