package com.minpay.reportManage.action; import com.minpay.common.bean.User; 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.db.table.mapper.DwReportDataMapper; import com.minpay.db.table.mapper.DwReportInfMapper; import com.minpay.db.table.model.DwReportData; 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.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.constant.IMINTransactionEnum; 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; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.text.ParseException; import java.util.HashMap; import java.util.List; import java.util.Map; @MINComponent public class XlgzzReportAction implements IMINAction { private IMINDataBaseService db; /** 报表查询 */ 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 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) public MINActionResult reportInfQuery( @MINParam(key = "page", defaultValue = "1") int page, @MINParam(key = "limit", defaultValue = "10") int limit, @MINParam(key = "date") String date, @MINParam(key = "fileName") String fileName, @MINParam(key = "timeType") String timeType, @MINParam(key = "reportType") String reportType, MINSession session ) throws MINBusinessException { MINActionResult res = new MINActionResult(); db = Service.lookup(IMINDataBaseService.class); //分页 MINRowBounds rows = new MINRowBounds(page, limit); rows.setSeparateSql(true); Map param = new HashMap(); param.put("date", date); param.put("fileName", fileName); param.put("timeType", timeType); param.put("reportType", reportType); User user = session.getUser(); String roleId = user.getRoleId(); // 非系统管理员 if (!Constant.ROLE_ID.equals(roleId)) { param.put("branchId", user.getBranchid()); } List> list = db.getMybatisMapper(ReportManageMapper.class).selectReportInf(param, rows); list = Service.lookup(IFormatService.class).formatDate(list, "uploadDate"); // 设置返回值 res.set(IMINBusinessConstant.F_PAGING_LAY, list); res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount()); return res; } @MINAction(value = FILE_INF_REPORT_SUBMIT, transaction = IMINTransactionEnum.CMT) public MINActionResult fileInfReportSubmit( @MINParam(key = "reportData") String reportData, @MINParam(key = "reportInf") String reportInf, @MINParam(key = "fileName") String fileName, @MINParam(key = "monthNum") String monthNum, @MINParam(key = "countNum") String countNum, @MINParam(key = "range") String range, @MINParam(key = "timeRange") String timeRange, @MINParam(key = "firstFileId") String firstFileId, @MINParam(key = "secondFileId") String secondFileId, @MINParam(key = "ddyFxbId") String ddyFxbId, @MINParam(key = "yearChoose") String yearChoose, @MINParam(key = "monthChoose") String monthChoose, MINSession session ) throws MINBusinessException { db = Service.lookup(IMINDataBaseService.class); MINActionResult res = new MINActionResult(); String reportId = db.getMybatisMapper(SequenceMapper.class).getSequence("REPORT_INF_NO"); String reportType = reportInf.split("_")[1]; String reportTypeId = reportInf.split("_")[0]; // 不生成报表数据表,实时计算 // DwReportData reportDataInf = new DwReportData(); // reportDataInf.setId(reportId);// // reportDataInf.setData(reportData); // reportDataInf.setType(reportType); // db.insertSelective(DwReportDataMapper.class, reportDataInf); User user = session.getUser(); // 生成报告表 DwReportInf report = new DwReportInf(); report.setId(reportId);//报表ID report.setUploadDate(DateUtil.getCurrentDateString());//更新时间 report.setFileName(fileName);//文件名 report.setCreatUser(user.getId());//当前登录用户ID report.setBranch(user.getBranchid());//所属结构(班组) report.setType(reportTypeId);//dw_branch_report_type.DBRT_ID report.setZdttyCompareId(firstFileId + "-" + secondFileId); report.setTqtdMonth(monthNum); // 台区停电【month个月内停电count次及以上台区】的month report.setTqtdCount(countNum); // 台区停电【month个月内停电count次及以上台区】的count report.setDdyFxbId(ddyFxbId); report.setDayInterval(range.replaceAll(" ", "")); // 日期时间段 report.setTimeInterval(timeRange.replaceAll(" ", "")); // 时分秒时间段 report.setYearInterval(yearChoose.replaceAll(" ", "")); report.setMonthInterval(monthChoose.replaceAll(" ", "")); db.insertSelective(DwReportInfMapper.class, report); return res; } @MINAction(value = REPORT_NEED_DATA_DETAIL) public MINActionResult reportNeedDataDetail( @MINParam(key = "monthChoose") String monthChoose, @MINParam(key = "range") String range, @MINParam(key = "timeRange") String timeRange, @MINParam(key = "reportInf") String reportInf, @MINParam(key = "monthNum") String monthNum, @MINParam(key = "countNum") String countNum, @MINParam(key = "firstFileId") String firstFileId, @MINParam(key = "secondFileId") String secondFileId, @MINParam(key = "FADateRange") String FADateRange, @MINParam(key = "yearChoose") String yearChoose, @MINParam(key = "DdyDateRange") String DdyDateRange, @MINParam(key = "ddyFxbId") String ddyFxbId ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InvalidFormatException, IOException { MINActionResult res = new MINActionResult(); // 报表类型id String reportTypeId = reportInf.split("_")[0]; Map param = new HashMap(); param.put("monthChoose", monthChoose); param.put("range", range); param.put("timeRange", timeRange); param.put("reportTypeId", reportTypeId); param.put("monthNum", monthNum); param.put("countNum", countNum); param.put("firstFileId", firstFileId); param.put("secondFileId", secondFileId); param.put("FADateRange", FADateRange); param.put("yearChoose", yearChoose); param.put("DdyDateRange", DdyDateRange); param.put("ddyFxbId", ddyFxbId); Map resMap = Service.lookup(IReportService.class).reportNeedDetail(param); res.set(IMINBusinessConstant.F_PAGING_LAY, resMap); return res; } @MINAction(value = REPORT_NEED_DATA_DETAIL2) public MINActionResult reportNeedDataDetail2( @MINParam(key = "reportId") String reportId ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InvalidFormatException, IOException { MINActionResult res = new MINActionResult(); db = Service.lookup(IMINDataBaseService.class); // 报表类型id Map param = new HashMap(); param.put("reportId", reportId); param.put("reportTypeId","XLGZZRB"); List> 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")); } Map resMap = Service.lookup(IReportService.class).reportNeedDetail(param); res.set(IMINBusinessConstant.F_PAGING_LAY, resMap); return res; } }