| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987 |
- 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.service.IReportService;
- 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.DwFileDetail98Mapper;
- import com.minpay.db.table.mapper.DwFileDetail99Mapper;
- import com.minpay.db.table.mapper.DwReportInfMapper;
- import com.minpay.db.table.mapper.PubAppparMapper;
- import com.minpay.db.table.model.DwFileDetail00;
- import com.minpay.db.table.model.DwFileDetail00Example;
- import com.minpay.db.table.model.DwFileDetail98;
- import com.minpay.db.table.model.DwFileDetail98Example;
- import com.minpay.db.table.model.DwFileDetail99;
- import com.minpay.db.table.model.DwFileDetail99Example;
- import com.minpay.db.table.model.DwReportInf;
- import com.minpay.db.table.model.PubApppar;
- import com.minpay.db.table.model.PubAppparExample;
- import com.minpay.db.table.own.mapper.ReportServiceMapper;
- import com.startup.minpay.frame.business.IMINAction;
- import com.startup.minpay.frame.business.res.MINActionResult;
- import com.startup.minpay.frame.constant.IMINBusinessConstant;
- import com.startup.minpay.frame.exception.MINBusinessException;
- import com.startup.minpay.frame.jdbc.MINRowBounds;
- import com.startup.minpay.frame.service.base.IMINDataBaseService;
- import com.startup.minpay.frame.service.base.Service;
- 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;
- @MINComponent
- public class TQTDReportAction implements IMINAction {
- private IMINDataBaseService db;
- /** 台区停电日报穿透数据 */
- public final static String REPORT_INF_CHUANTOU = "reportInfChuantou";
- /** 台区停电月报附件 */
- public final static String REPORT_INF_FUJIAN = "reportInfFujian";
- /** 台区数量管理 */
- public final static String AREA_NUM_MANAGE = "areaNumManage";
- /** 台区数量编辑 */
- public final static String AREA_NUM_UPDATE = "areaNumUpdate";
- /**穿透导出详情*/
- public final static String REPORT_INF_FUJIAN_CHUANTOU = "reportInfFujianChuantou";
- /**红黄蓝督办预警下载*/
- public final static String DOWN_RB_HHL = "downRbHhl";
- /** 台区停电周报报穿透数据 */
- public final static String REPORT_INF_ZB_CHUANTOU = "reportInfZbChuantou";
- /** 台区停电周报报穿透数据下载 */
- public final static String REPORT_INF_ZB_CHUANTOU_DOWN = "reportInfZbChuantouDown";
- /**
- * 台区停电穿透数据
- * @param reportId 报表id
- * @param chuantouType 穿透类型
- * @param session
- * @return
- * @throws MINBusinessException
- * @throws ParseException
- * @throws InvocationTargetException
- * @throws IllegalArgumentException
- * @throws IllegalAccessException
- * @throws SecurityException
- * @throws NoSuchMethodException
- */
- @MINAction(value = REPORT_INF_CHUANTOU)
- public MINActionResult reportInfChuantou(
- @MINParam(key = "reportId") String reportId,
- @MINParam(key = "chuantouType") String chuantouType,
- MINSession session
- ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- MINActionResult res = new MINActionResult();
- db = Service.lookup(IMINDataBaseService.class);
- //分页
- MINRowBounds rows = new MINRowBounds();
- rows.setSeparateSql(true);
- // 查询报表具体信息
- DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
- // 报表时间范围
- Map<String, Object> param = new HashMap<String, Object>();
- String dayInterval = reportInf.getDayInterval();
- String timeInterval = reportInf.getTimeInterval();
- String[] dayIntervalArray = dayInterval.split("-");
- String[] timeIntervalArray = timeInterval.split("-");
- String beginTime = dayIntervalArray[0] + timeIntervalArray[0];
- String endTime = dayIntervalArray[1] + timeIntervalArray[1];
- param.put("beginTime", beginTime);
- param.put("endTime", endTime);
- // 台区次数穿透数据
- if ("TQTD01".equals(chuantouType)) {
- List<Map<String, String>> fileList00 = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00(param);
- fileList00 = Service.lookup(IFormatService.class).formatDate(fileList00, "date");
- fileList00 = Service.lookup(IFormatService.class).formatDateTime(fileList00, "startTime", "endTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, fileList00);
- // month个月停电count次及以上台区穿透
- } else if ("TQTD02".equals(chuantouType)) {
- String monthNum = reportInf.getTqtdMonth();
- String countNum = reportInf.getTqtdCount();
- // monthNum个月内停电 countNum次以上的台区
- String beginDay = DateUtil.dateAddMonth(dayIntervalArray[1], Integer.parseInt("-" + monthNum));
- param.put("beginDay", beginDay);
- param.put("endDay", dayIntervalArray[1]);
- param.put("countNum", countNum);
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- if (addressNumList.size() == 0) {
- return res;
- }
- DwFileDetail00Example example = new DwFileDetail00Example();
- example.createCriteria().andAddressNumIn(addressNumList).andStartTimeGreaterThanOrEqualTo(beginDay).andEndTimeLessThanOrEqualTo(dayIntervalArray[1]);
- example.setOrderByClause("DFD0_ADDRESS_NUM");
- List<DwFileDetail00> selectByExample = db.selectByExample(DwFileDetail00Mapper.class, example);
- selectByExample = Service.lookup(IFormatService.class).formatDate(selectByExample, "date");
- selectByExample = Service.lookup(IFormatService.class).formatDateTime(selectByExample, "startTime", "endTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, selectByExample);
- // month个月停电count次及以上台区且当日停电穿透
- } else if ("TQTD03".equals(chuantouType)) {
- String monthNum = reportInf.getTqtdMonth();
- String countNum = reportInf.getTqtdCount();
- // monthNum个月内停电 countNum次以上的台区
- String beginDay = DateUtil.dateAddMonth(dayIntervalArray[1], Integer.parseInt("-" + monthNum));
- param.put("beginDay", beginDay + timeIntervalArray[0]);
- param.put("endDay", dayIntervalArray[1] + timeIntervalArray[1]);
- param.put("countNum", countNum);
- // 查询当日停电的数据
- param.put("yesterday", dayIntervalArray[1]);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- param.put("yesterdayDetail", yesterdayList);
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- if (mountCountList.size() == 0) {
- return res;
- }
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- param.put("addressNumList", addressNumList);
- List<Map<String, String>> selectByExample = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- selectByExample = Service.lookup(IFormatService.class).formatDate(selectByExample, "date");
- selectByExample = Service.lookup(IFormatService.class).formatDateTime(selectByExample, "startTime", "endTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, selectByExample);
- // 2个月停电2次台区且当日停电穿透
- } else if ("TQTD04".equals(chuantouType)) {
- String monthNum = "2";
- String countNum = "2";
- // monthNum个月内停电 countNum次以上的台区
- String beginDay = DateUtil.dateAddMonth(dayIntervalArray[1], Integer.parseInt("-" + monthNum));
- param.put("beginDay", beginDay + timeIntervalArray[0]);
- param.put("endDay", dayIntervalArray[1] + timeIntervalArray[1]);
- param.put("countNum", countNum);
- // 查询当日停电的数据
- param.put("yesterday", dayIntervalArray[1]);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- param.put("yesterdayDetail", yesterdayList);
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount01(param);
- if (mountCountList.size() == 0) {
- return res;
- }
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- param.put("addressNumList", addressNumList);
- List<Map<String, String>> selectByExample = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- selectByExample = Service.lookup(IFormatService.class).formatDate(selectByExample, "date");
- selectByExample = Service.lookup(IFormatService.class).formatDateTime(selectByExample, "startTime", "endTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, selectByExample);
- // 台区停电时户数
- } else if ("TQTD05".equals(chuantouType)) {
- List<Map<String, String>> fileList00 = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00(param);
- fileList00 = Service.lookup(IFormatService.class).formatDate(fileList00, "date");
- fileList00 = Service.lookup(IFormatService.class).formatDateTime(fileList00, "startTime", "endTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, fileList00);
- // 2个月停电1次台区且当日停电穿透
- }else if ("TQTD06".equals(chuantouType)) {
- String monthNum = "2";
- String countNum = "1";
- // monthNum个月内停电 countNum次以上的台区
- String beginDay = DateUtil.dateAddMonth(dayIntervalArray[1], Integer.parseInt("-" + monthNum));
- param.put("beginDay", beginDay + timeIntervalArray[0]);
- param.put("endDay", dayIntervalArray[1] + timeIntervalArray[1]);
- param.put("countNum", countNum);
- // 查询当日停电的数据
- param.put("yesterday", dayIntervalArray[1]);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- if (yesterdayList.size() == 0) {
- return res;
- }
- param.put("yesterdayDetail", yesterdayList);
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount01(param);
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- param.put("addressNumList", addressNumList);
- List<Map<String, String>> selectByExample = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- selectByExample = Service.lookup(IFormatService.class).formatDate(selectByExample, "date");
- selectByExample = Service.lookup(IFormatService.class).formatDateTime(selectByExample, "startTime", "endTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, selectByExample);
- }
- return res;
- }
- @MINAction(value = REPORT_INF_FUJIAN_CHUANTOU)
- public HttpServletResponse reportInfFujianChuantou(
- @MINParam(key = "reportId") String reportId,
- @MINParam(key = "chuantouType") String chuantouType,
- HttpServletResponse response,
- MINSession session
- )throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- //分页
- MINRowBounds rows = new MINRowBounds();
- rows.setSeparateSql(true);
- // 查询报表具体信息
- DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
- // 报表时间范围
- Map<String, Object> param = new HashMap<String, Object>();
- String dayInterval = reportInf.getDayInterval();
- String timeInterval = reportInf.getTimeInterval();
- String[] dayIntervalArray = dayInterval.split("-");
- String[] timeIntervalArray = timeInterval.split("-");
- String beginTime = dayIntervalArray[0] + timeIntervalArray[0];
- String endTime = dayIntervalArray[1] + timeIntervalArray[1];
- param.put("beginTime", beginTime);
- param.put("endTime", endTime);
- List<Map<String, String>> excelList = null;
- // 台区次数穿透数据
- if ("TQTD01".equals(chuantouType)) {
- excelList = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00(param);
- excelList = Service.lookup(IFormatService.class).formatDate(excelList, "date");
- excelList = Service.lookup(IFormatService.class).formatDateTime(excelList, "startTime", "endTime");
- // month个月停电count次及以上台区穿透
- } else if ("TQTD02".equals(chuantouType)) {
- String monthNum = reportInf.getTqtdMonth();
- String countNum = reportInf.getTqtdCount();
- // monthNum个月内停电 countNum次以上的台区
- String beginDay = DateUtil.dateAddMonth(dayIntervalArray[1], Integer.parseInt("-" + monthNum));
- param.put("beginDay", beginDay);
- param.put("endDay", dayIntervalArray[1]);
- param.put("countNum", countNum);
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- if (addressNumList.size() == 0) {
- excelList = new ArrayList<>();
- } else {
- excelList = new ArrayList<>();
- DwFileDetail00Example example = new DwFileDetail00Example();
- example.createCriteria().andAddressNumIn(addressNumList).andStartTimeGreaterThanOrEqualTo(beginDay).andEndTimeLessThanOrEqualTo(dayIntervalArray[1]);
- example.setOrderByClause("DFD0_ADDRESS_NUM");
- List<DwFileDetail00> selectByExample = db.selectByExample(DwFileDetail00Mapper.class, example);
- selectByExample = Service.lookup(IFormatService.class).formatDate(selectByExample, "date");
- selectByExample = Service.lookup(IFormatService.class).formatDateTime(selectByExample, "startTime", "endTime");
- for (DwFileDetail00 dwFileDetail00:selectByExample) {
- 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());
- excelList.add(excelMap);
- }
- }
- // month个月停电count次及以上台区且当日停电穿透
- } else if ("TQTD03".equals(chuantouType)) {
- String monthNum = reportInf.getTqtdMonth();
- String countNum = reportInf.getTqtdCount();
- // monthNum个月内停电 countNum次以上的台区
- String beginDay = DateUtil.dateAddMonth(dayIntervalArray[1], Integer.parseInt("-" + monthNum));
- param.put("beginDay", beginDay + timeIntervalArray[0]);
- param.put("endDay", dayIntervalArray[1] + timeIntervalArray[1]);
- param.put("countNum", countNum);
- // 查询当日停电的数据
- param.put("yesterday", dayIntervalArray[1]);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- param.put("yesterdayDetail", yesterdayList);
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- if (mountCountList.size() == 0) {
- excelList = new ArrayList<>();
- } else {
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- param.put("addressNumList", addressNumList);
- excelList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- excelList = Service.lookup(IFormatService.class).formatDate(excelList, "date");
- excelList = Service.lookup(IFormatService.class).formatDateTime(excelList, "startTime", "endTime");
- }
- // 2个月停电2次台区且当日停电穿透
- } else if ("TQTD04".equals(chuantouType)) {
- String monthNum = "2";
- String countNum = "2";
- // monthNum个月内停电 countNum次以上的台区
- String beginDay = DateUtil.dateAddMonth(dayIntervalArray[1], Integer.parseInt("-" + monthNum));
- param.put("beginDay", beginDay + timeIntervalArray[0]);
- param.put("endDay", dayIntervalArray[1] + timeIntervalArray[1]);
- param.put("countNum", countNum);
- // 查询当日停电的数据
- param.put("yesterday", dayIntervalArray[1]);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- param.put("yesterdayDetail", yesterdayList);
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount01(param);
- if (mountCountList.size() == 0) {
- excelList = new ArrayList<>();
- } else {
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- param.put("addressNumList", addressNumList);
- excelList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- excelList = Service.lookup(IFormatService.class).formatDate(excelList, "date");
- excelList = Service.lookup(IFormatService.class).formatDateTime(excelList, "startTime", "endTime");
- }
- // 台区停电时户数
- } else if ("TQTD05".equals(chuantouType)) {
- excelList = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00(param);
- excelList = Service.lookup(IFormatService.class).formatDate(excelList, "date");
- excelList = Service.lookup(IFormatService.class).formatDateTime(excelList, "startTime", "endTime");
- for (Map<String, String> m : excelList) {
- m.put("hour", CommonUtil.divide(m.get("time"), "60", 2));
- }
- // 2个月停电1次台区且当日停电穿透
- }else if ("TQTD06".equals(chuantouType)) {
- String monthNum = "2";
- String countNum = "1";
- // monthNum个月内停电 countNum次以上的台区
- String beginDay = DateUtil.dateAddMonth(dayIntervalArray[1], Integer.parseInt("-" + monthNum));
- param.put("beginDay", beginDay + timeIntervalArray[0]);
- param.put("endDay", dayIntervalArray[1] + timeIntervalArray[1]);
- param.put("countNum", countNum);
- // 查询当日停电的数据
- param.put("yesterday", dayIntervalArray[1]);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- if (yesterdayList.size() == 0) {
- excelList = new ArrayList<>();
- } else {
- param.put("yesterdayDetail", yesterdayList);
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount01(param);
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- param.put("addressNumList", addressNumList);
- excelList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- excelList = Service.lookup(IFormatService.class).formatDate(excelList, "date");
- excelList = Service.lookup(IFormatService.class).formatDateTime(excelList, "startTime", "endTime");
- }
- }
- OutputStream out=null;
- try {
- out = response.getOutputStream();
- HSSFWorkbook wb = null;
- if ("TQTD01".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","数据日期#date","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电时间#startTime","来电时间#endTime"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- } else if ("TQTD02".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","数据日期#date","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电时间#startTime","来电时间#endTime"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- } else if ("TQTD03".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电次数#num","停电时间#startTime","来电时间#endTime"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- } else if ("TQTD04".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电时间#startTime","来电时间#endTime"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- } else if ("TQTD05".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","数据日期#date","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电时间#startTime","来电时间#endTime","时长#hour"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- } else if ("TQTD06".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电时间#startTime","来电时间#endTime"};
- 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;
- }
- /**
- * 台区停电附件导出
- * @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");
- if(addressNumList == null || addressNumList.isEmpty()){
- addressNumList.add("XXXXXXXX");
- }
- 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 (int j = 0; j < fileDetail00List.size(); j ++) {
- DwFileDetail00 dwFileDetail00 = fileDetail00List.get(j);
- // 与上一条数据是否相同
- if (!dwFileDetail00.getAddressNum().equals(addressNumFlag) && addressNumFlag != null) {
- for (int k = 0; k < i; k ++) {
- Map<String, String> map = excelList.get(j - 1 - k);
- map.put("cishu", String.valueOf(i));
- }
- 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 ++;
- 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));
- }
- }
- }
- // 格式化时间
- 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","停电次数#cishu"};
- 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;
- }
- /**
- * 台区数量管理
- * @param session
- * @return
- * @throws MINBusinessException
- */
- @MINAction(value = AREA_NUM_MANAGE)
- public MINActionResult areaNumManage(
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- db = Service.lookup(IMINDataBaseService.class);
- PubAppparExample appparExample = new PubAppparExample();
- String systemCode = Service.lookup(IReportService.class).getSystemCode();
- appparExample.createCriteria().andCodeEqualTo("tqtd_num_" + systemCode);
- List<PubApppar> appparList = db.selectByExample(PubAppparMapper.class, appparExample);
- List<Map<String, String>> resList = new ArrayList<Map<String, String>>();
- Map<String, String> resMap = new HashMap<String, String>();
- resList.add(resMap);
- String hejiNum = "0";
- List<Map<String, Object>> col = new ArrayList<Map<String, Object>>();
- for (PubApppar pub : appparList) {
- resMap.put(pub.getValue(), pub.getShowmsg());
- hejiNum = CommonUtil.add(hejiNum, pub.getShowmsg());
- Map<String, Object> colMap = new HashMap<String, Object>();
- colMap.put("field", pub.getValue());
- colMap.put("title", pub.getValue());
- colMap.put("edit", "text");
- col.add(colMap);
- }
- Map<String, Object> colHejiMap = new HashMap<String, Object>();
- colHejiMap.put("field", "合计");
- colHejiMap.put("title", "合计");
- col.add(colHejiMap);
- resMap.put("合计", hejiNum);
- res.set(IMINBusinessConstant.F_PAGING_LAY, resList);
- res.set("col", col);
- return res;
- }
- @MINAction(value = AREA_NUM_UPDATE)
- public MINActionResult areaNumUpdate(
- @MINParam(key = "field") String field,
- @MINParam(key = "value") String value,
- MINSession session
- ) throws MINBusinessException {
- MINActionResult res = new MINActionResult();
- String systemCode = Service.lookup(IReportService.class).getSystemCode();
- // 修改数据库数据
- db = Service.lookup(IMINDataBaseService.class);
- PubApppar apppar = new PubApppar();
- apppar.setCode("tqtd_num_"+systemCode);
- apppar.setValue(field);
- apppar.setShowmsg(value);
- db.updateByPrimaryKeySelective(PubAppparMapper.class, apppar);
- // 更新值
- Service.lookup(IReportService.class).reflush();
- return res;
- }
- @MINAction(value = DOWN_RB_HHL)
- public MINActionResult downRbHhl(
- @MINParam(key = "reportId") String reportId,
- HttpServletResponse response,
- MINSession session
- ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- db = Service.lookup(IMINDataBaseService.class);
- MINActionResult res = new MINActionResult();
- // 查询报表具体信息
- DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
- // 报表时间范围
- Map<String, Object> param = new HashMap<String, Object>();
- String dayInterval = reportInf.getDayInterval();
- String timeInterval = reportInf.getTimeInterval();
- String[] dayIntervalArray = dayInterval.split("-");
- String[] timeIntervalArray = timeInterval.split("-");
- String beginTime = dayIntervalArray[0] + timeIntervalArray[0];
- String endTime = dayIntervalArray[1] + timeIntervalArray[1];
- param.put("beginTime", beginTime);
- param.put("endTime", endTime);
- List<Map<String, String>> excelList = null;
- String monthNum = reportInf.getTqtdMonth();
- String countNum = "1";
- // monthNum个月内停电 countNum次以上的台区
- String beginDay = DateUtil.dateAddMonth(dayIntervalArray[1], Integer.parseInt("-" + monthNum));
- param.put("beginDay", beginDay + timeIntervalArray[0]);
- param.put("endDay", dayIntervalArray[1] + timeIntervalArray[1]);
- param.put("countNum", countNum);
- // 查询当日停电的数据
- param.put("yesterday", dayIntervalArray[1]);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- param.put("yesterdayDetail", yesterdayList);
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- if (mountCountList.size() == 0) {
- excelList = new ArrayList<>();
- } else {
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- param.put("addressNumList", addressNumList);
- excelList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- excelList = Service.lookup(IFormatService.class).formatDate(excelList, "date");
- excelList = Service.lookup(IFormatService.class).formatDateTime(excelList, "startTime", "endTime");
- }
- List<String> addressNameList = CommonUtil.getIdFromList(excelList, "addressName");
- // 线路台账(供服)
- DwFileDetail98Example dwFileDetail98Example = new DwFileDetail98Example();
- dwFileDetail98Example.createCriteria().andGbmcIn(addressNameList);
- List<DwFileDetail98> gfList = db.getMybatisMapper(DwFileDetail98Mapper.class).selectByExample(dwFileDetail98Example);
- // 匹配供服台账的线路数据
- for (Map<String, String> e : excelList) {
- for (DwFileDetail98 d : gfList) {
- if (d.getGbmc().equals(e.get("addressName"))) {
- e.put("ssxl", d.getSskx());
- break;
- }
- }
- }
- DwFileDetail99Example dwFileDetail99Example = new DwFileDetail99Example();
- dwFileDetail99Example.createCriteria().andTqIn(addressNameList);
- List<DwFileDetail99> yxList = db.getMybatisMapper(DwFileDetail99Mapper.class).selectByExample(dwFileDetail99Example);
- // 匹配营销台账的线路数据
- for (Map<String, String> e : excelList) {
- for (DwFileDetail99 d : yxList) {
- if (CommonUtil.isEmpty(e.get("ssxl")) && d.getTq().equals(e.get("addressName"))) {
- e.put("ssxl", d.getTq());
- break;
- }
- }
- }
- OutputStream out=null;
- try {
- out = response.getOutputStream();
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电次数#num","所属线路#ssxl"};
- 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 res;
- }
- @MINAction(value = REPORT_INF_ZB_CHUANTOU)
- public MINActionResult reportInfZbChuantou(
- @MINParam(key = "reportId") String reportId,
- @MINParam(key = "chuantouType") String chuantouType,
- MINSession session
- ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
- MINActionResult res = new MINActionResult();
- db = Service.lookup(IMINDataBaseService.class);
- //分页
- MINRowBounds rows = new MINRowBounds();
- rows.setSeparateSql(true);
- // 查询报表具体信息
- DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
- // 报表时间范围
- Map<String, Object> param = new HashMap<String, Object>();
- String dayInterval = reportInf.getDayInterval();
- String timeInterval = reportInf.getTimeInterval();
- String[] dayIntervalArray = dayInterval.split("-");
- String[] timeIntervalArray = timeInterval.split("-");
- String beginTime = dayIntervalArray[0] + timeIntervalArray[0];
- String endTime = dayIntervalArray[1] + timeIntervalArray[1];
- param.put("beginTime", beginTime);
- param.put("endTime", endTime);
- // 停电台区数
- if ("TQTD00".equals(chuantouType)) {
- param.put("beginDay", beginTime);
- param.put("endDay", endTime);
- List<Map<String, String>> tqCountList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- res.set(IMINBusinessConstant.F_PAGING_LAY, tqCountList);
- // 本周累计停电台次
- }else if ("TQTD01".equals(chuantouType)) {
- DwFileDetail00Example example = new DwFileDetail00Example();
- example.createCriteria().andStartTimeGreaterThanOrEqualTo(beginTime).andEndTimeLessThanOrEqualTo(endTime);
- List<DwFileDetail00> selectByExample = db.selectByExample(DwFileDetail00Mapper.class, example);
- selectByExample = Service.lookup(IFormatService.class).formatDate(selectByExample, "date");
- selectByExample = Service.lookup(IFormatService.class).formatDateTime(selectByExample, "startTime", "endTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, selectByExample);
- // 本周重复停电台区数
- } else if ("TQTD02".equals(chuantouType)) {
- param.put("beginDay", beginTime);
- param.put("endDay", endTime);
- param.put("countNum", "2");
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- if (addressNumList.size() == 0) {
- return res;
- }
- param.put("addressNumList", addressNumList);
- List<Map<String, String>> tqCountList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- res.set(IMINBusinessConstant.F_PAGING_LAY, tqCountList);
- // 本周督办频繁停电台次
- } else if ("TQTD03".equals(chuantouType)) {
- List<Map<String, String>> resList = new ArrayList<>();
- String begin = dayIntervalArray[0];
- String end = dayIntervalArray[1];
- while (CommonUtil.compare(begin, end) != 1) {
- param.put("yesterday", begin);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- if (yesterdayList.size() == 0) {
- begin = DateUtil.dateAddDay(begin, 1);
- continue;
- }
- param.put("yesterdayDetail", yesterdayList);
- param.put("beginDay", DateUtil.dateAddDay(DateUtil.dateAddMonth(begin, -2), 1) + beginTime.substring(8, 14));
- param.put("endDay", begin + endTime.substring(8, 14));
- param.put("countNum", 3);
- List<Map<String, String>> sanciData = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- List<String> addressNumList = CommonUtil.getIdFromList(sanciData, "addressNum");
- if (addressNumList.size() != 0) {
- param.put("beginTime", DateUtil.dateAddDay(DateUtil.dateAddMonth(begin, -2), 1) + beginTime.substring(8, 14));
- param.put("endTime", begin + endTime.substring(8, 14));
- param.put("addressNumList", addressNumList);
- List<Map<String, String>> selectReportType00 = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00(param);
- for (Map<String, String> map : selectReportType00) {
- map.put("queryDate", begin);
- }
- resList.addAll(selectReportType00);
- }
- // 天数 + 1
- begin = DateUtil.dateAddDay(begin, 1);
- }
- resList = Service.lookup(IFormatService.class).formatDate(resList, "date", "queryDate");
- resList = Service.lookup(IFormatService.class).formatDateTime(resList, "startTime", "endTime");
- res.set(IMINBusinessConstant.F_PAGING_LAY, resList);
- // 本周督办频繁停电台区数
- } else if ("TQTD04".equals(chuantouType)) {
- List<Map<String, String>> resList = new ArrayList<>();
- String begin = dayIntervalArray[0];
- String end = dayIntervalArray[1];
- while (CommonUtil.compare(begin, end) != 1) {
- param.put("yesterday", begin);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- if (yesterdayList.size() == 0) {
- begin = DateUtil.dateAddDay(begin, 1);
- continue;
- }
- param.put("yesterdayDetail", yesterdayList);
- param.put("beginDay", DateUtil.dateAddDay(DateUtil.dateAddMonth(begin, -2), 1) + beginTime.substring(8, 14));
- param.put("endDay", begin + endTime.substring(8, 14));
- param.put("countNum", 3);
- List<Map<String, String>> sanciData = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- List<String> addressNumList = CommonUtil.getIdFromList(sanciData, "addressNum");
- if (addressNumList.size() != 0) {
- param.put("addressNumList", addressNumList);
- List<Map<String, String>> tqCountList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- for (Map<String, String> t : tqCountList) {
- t.put("date", begin);
- }
- resList.addAll(tqCountList);
- }
- // 天数 + 1
- begin = DateUtil.dateAddDay(begin, 1);
- }
- resList = Service.lookup(IFormatService.class).formatDate(resList, "date");
- res.set(IMINBusinessConstant.F_PAGING_LAY, resList);
- }
- return res;
- }
- @MINAction(value = REPORT_INF_ZB_CHUANTOU_DOWN)
- public MINActionResult reportInfZbChuantouDown(
- @MINParam(key = "reportId") String reportId,
- @MINParam(key = "chuantouType") String chuantouType,
- HttpServletResponse response,
- MINSession session
- )throws MINBusinessException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, ParseException{
- MINActionResult res = new MINActionResult();
- db = Service.lookup(IMINDataBaseService.class);
- //分页
- MINRowBounds rows = new MINRowBounds();
- rows.setSeparateSql(true);
- // 查询报表具体信息
- DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
- // 报表时间范围
- Map<String, Object> param = new HashMap<String, Object>();
- String dayInterval = reportInf.getDayInterval();
- String timeInterval = reportInf.getTimeInterval();
- String[] dayIntervalArray = dayInterval.split("-");
- String[] timeIntervalArray = timeInterval.split("-");
- String beginTime = dayIntervalArray[0] + timeIntervalArray[0];
- String endTime = dayIntervalArray[1] + timeIntervalArray[1];
- param.put("beginTime", beginTime);
- param.put("endTime", endTime);
- List<Map<String, String>> excelList = new ArrayList<>();
- // 停电台区数
- if ("TQTD00".equals(chuantouType)) {
- param.put("beginDay", beginTime);
- param.put("endDay", endTime);
- excelList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- // 本周累计停电台次
- }else if ("TQTD01".equals(chuantouType)) {
- DwFileDetail00Example example = new DwFileDetail00Example();
- example.createCriteria().andStartTimeGreaterThanOrEqualTo(beginTime).andEndTimeLessThanOrEqualTo(endTime);
- List<DwFileDetail00> selectByExample = db.selectByExample(DwFileDetail00Mapper.class, example);
- selectByExample = Service.lookup(IFormatService.class).formatDate(selectByExample, "date");
- selectByExample = Service.lookup(IFormatService.class).formatDateTime(selectByExample, "startTime", "endTime");
- for (DwFileDetail00 dwFileDetail00:selectByExample) {
- 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());
- excelList.add(excelMap);
- }
- // 本周重复停电台区数
- } else if ("TQTD02".equals(chuantouType)) {
- param.put("beginDay", beginTime);
- param.put("endDay", endTime);
- param.put("countNum", "2");
- List<Map<String, String>> mountCountList = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- List<String> addressNumList = CommonUtil.getIdFromList(mountCountList, "addressNum");
- if (addressNumList.size() == 0) {
- return res;
- }
- param.put("addressNumList", addressNumList);
- excelList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- // 本周督办频繁停电台次
- } else if ("TQTD03".equals(chuantouType)) {
- String begin = dayIntervalArray[0];
- String end = dayIntervalArray[1];
- while (CommonUtil.compare(begin, end) != 1) {
- param.put("yesterday", begin);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- if (yesterdayList.size() == 0) {
- begin = DateUtil.dateAddDay(begin, 1);
- continue;
- }
- param.put("yesterdayDetail", yesterdayList);
- param.put("beginDay", DateUtil.dateAddDay(DateUtil.dateAddMonth(begin, -2), 1) + beginTime.substring(8, 14));
- param.put("endDay", begin + endTime.substring(8, 14));
- param.put("countNum", 3);
- List<Map<String, String>> sanciData = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- List<String> addressNumList = CommonUtil.getIdFromList(sanciData, "addressNum");
- if (addressNumList.size() != 0) {
- param.put("beginTime", DateUtil.dateAddDay(DateUtil.dateAddMonth(begin, -2), 1) + beginTime.substring(8, 14));
- param.put("endTime", begin + endTime.substring(8, 14));
- param.put("addressNumList", addressNumList);
- List<Map<String, String>> selectReportType00 = db.getMybatisMapper(ReportServiceMapper.class).selectReportType00(param);
- for (Map<String, String> map : selectReportType00) {
- map.put("queryDate", begin);
- }
- excelList.addAll(selectReportType00);
- }
- // 天数 + 1
- begin = DateUtil.dateAddDay(begin, 1);
- }
- excelList = Service.lookup(IFormatService.class).formatDate(excelList, "date", "queryDate");
- excelList = Service.lookup(IFormatService.class).formatDateTime(excelList, "startTime", "endTime");
- // 本周督办频繁停电台区数
- } else if ("TQTD04".equals(chuantouType)) {
- String begin = dayIntervalArray[0];
- String end = dayIntervalArray[1];
- while (CommonUtil.compare(begin, end) != 1) {
- param.put("yesterday", begin);
- List<Map<String, String>> yesterdayList = db.getMybatisMapper(ReportServiceMapper.class).queryYesterdayDetail(param);
- if (yesterdayList.size() == 0) {
- begin = DateUtil.dateAddDay(begin, 1);
- continue;
- }
- param.put("yesterdayDetail", yesterdayList);
- param.put("beginDay", DateUtil.dateAddDay(DateUtil.dateAddMonth(begin, -2), 1) + beginTime.substring(8, 14));
- param.put("endDay", begin + endTime.substring(8, 14));
- param.put("countNum", 3);
- List<Map<String, String>> sanciData = db.getMybatisMapper(ReportServiceMapper.class).selectMountCount00(param);
- List<String> addressNumList = CommonUtil.getIdFromList(sanciData, "addressNum");
- if (addressNumList.size() != 0) {
- param.put("addressNumList", addressNumList);
- List<Map<String, String>> tqCountList = db.getMybatisMapper(ReportServiceMapper.class).selectTqtdRbDetail(param);
- for (Map<String, String> t : tqCountList) {
- t.put("date", begin);
- }
- excelList.addAll(tqCountList);
- }
- // 天数 + 1
- begin = DateUtil.dateAddDay(begin, 1);
- }
- excelList = Service.lookup(IFormatService.class).formatDate(excelList, "date");
- }
- OutputStream out=null;
- try {
- out = response.getOutputStream();
- HSSFWorkbook wb = null;
- if ("TQTD00".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电次数#num"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- } else if ("TQTD01".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","数据日期#date","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电时间#startTime","来电时间#endTime"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- } else if ("TQTD02".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","单位#area","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电次数#num"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- } else if ("TQTD03".equals(chuantouType)) {
- String[] excelHeader = {"日报日期#queryDate","台区编号#addressNum","台区名称#addressName","数据日期#date","单位#area","单位名称#comonpanyName","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电时间#startTime","来电时间#endTime"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- } else if ("TQTD04".equals(chuantouType)) {
- String[] excelHeader = {"台区编号#addressNum","台区名称#addressName","单位#area","终端名称#terminalName","终端编号#terminalNum","终端地址码#terminalAddress","停电次数#num","日报日期#date"};
- wb = ExportExcelUtil.export(response, reportInf.getFileName(), excelHeader, excelList);
- }
- if(wb != null){
- wb.write(out);
- }
- out.flush();
- out.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- return res;
- }
- }
|