|
@@ -0,0 +1,677 @@
|
|
|
+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.bean.User;
|
|
|
+import com.minpay.common.constant.Constant;
|
|
|
+import com.minpay.common.format.IFormatService;
|
|
|
+import com.minpay.common.service.IDianwangService;
|
|
|
+import com.minpay.common.service.IReportService;
|
|
|
+import com.minpay.common.util.CommonUtil;
|
|
|
+import com.minpay.common.util.DateUtil;
|
|
|
+import com.minpay.db.table.mapper.DwBranchReportTypeMapper;
|
|
|
+import com.minpay.db.table.mapper.DwDdyFxbDetailMapper;
|
|
|
+import com.minpay.db.table.mapper.DwDdyFxbMapper;
|
|
|
+import com.minpay.db.table.mapper.DwReportDataMapper;
|
|
|
+import com.minpay.db.table.mapper.DwReportInfMapper;
|
|
|
+import com.minpay.db.table.model.DwBranchReportType;
|
|
|
+import com.minpay.db.table.model.DwDdyFxb;
|
|
|
+import com.minpay.db.table.model.DwDdyFxbDetail;
|
|
|
+import com.minpay.db.table.model.DwDdyFxbDetailExample;
|
|
|
+import com.minpay.db.table.model.DwDdyFxbExample;
|
|
|
+import com.minpay.db.table.model.DwReportData;
|
|
|
+import com.minpay.db.table.model.DwReportInf;
|
|
|
+import com.minpay.db.table.own.mapper.ReportManageMapper;
|
|
|
+import com.minpay.db.table.own.mapper.SequenceMapper;
|
|
|
+import com.minpay.dianwang.util.ReportExcelUtil;
|
|
|
+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 net.sf.json.JSONArray;
|
|
|
+
|
|
|
+@MINComponent
|
|
|
+public class JtfjtReportAction 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 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";
|
|
|
+
|
|
|
+
|
|
|
+ /** 低电压分析表提交 */
|
|
|
+ public final static String DDY_REPORT_INF_SUBMIT = "ddyReportInfSubmit";
|
|
|
+
|
|
|
+ /** 低电压分析表详情 */
|
|
|
+ public final static String DDY_REPORT_INF_DETAIL = "ddyReportInfDetail";
|
|
|
+
|
|
|
+ /** 低电压分析表编辑 */
|
|
|
+ public final static String DDY_REPORT_INF_UPDATE = "ddyReportInfUpdate";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报表查询
|
|
|
+ * @param page
|
|
|
+ * @param limit
|
|
|
+ * @param date
|
|
|
+ * @param fileName
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ * @throws InvocationTargetException
|
|
|
+ * @throws IllegalArgumentException
|
|
|
+ * @throws IllegalAccessException
|
|
|
+ * @throws SecurityException
|
|
|
+ * @throws NoSuchMethodException
|
|
|
+ * @throws InstantiationException
|
|
|
+ */
|
|
|
+ @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<String, Object> param = new HashMap<String, Object>();
|
|
|
+
|
|
|
+ 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<Map<String, String>> 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报告明细信息组装
|
|
|
+ * @param chooseFileListStr
|
|
|
+ * @param session
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ */
|
|
|
+ @MINAction(value = FILE_INF_REPORT_QUERY)
|
|
|
+ public MINActionResult fileInfReportQuery(
|
|
|
+ @MINParam(key = "chooseFileListStr") String chooseFileListStr,
|
|
|
+ @MINParam(key = "page", defaultValue = "1") int page,
|
|
|
+ @MINParam(key = "limit", defaultValue = "200") int limit,
|
|
|
+ MINSession session
|
|
|
+ ) throws MINBusinessException {
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+ MINRowBounds rows = new MINRowBounds(page, limit);
|
|
|
+ rows.setSeparateSql(true);
|
|
|
+
|
|
|
+ JSONArray chooseFileList = JSONArray.fromObject(chooseFileListStr);
|
|
|
+
|
|
|
+ List<Map<String, Object>> fileTypeList = new ArrayList<Map<String, Object>>();
|
|
|
+ // 处理选中数据 将同一文件类型的数据放在一起,方便分表查询数据
|
|
|
+ for (Object object : chooseFileList) {
|
|
|
+ Map<String, String> chooseFile = (Map<String, String>)object;
|
|
|
+
|
|
|
+ boolean flag = false;
|
|
|
+ for (Map<String, Object> fileType : fileTypeList) {
|
|
|
+ if (chooseFile.get("type").equals(fileType.get("type"))) {
|
|
|
+ List<String> fileIdList = (List<String>)fileType.get("fileIdList");
|
|
|
+ fileIdList.add(chooseFile.get("id"));
|
|
|
+ }
|
|
|
+ flag = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!flag) {
|
|
|
+ Map<String, Object> fileType = new HashMap<String, Object>();
|
|
|
+ List<String> fileIdList = new ArrayList<String>();
|
|
|
+ fileIdList.add(chooseFile.get("id"));
|
|
|
+ fileType.put("type", chooseFile.get("type"));
|
|
|
+ fileType.put("fileIdList", fileIdList);
|
|
|
+ fileTypeList.add(fileType);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查询对应明细信息
|
|
|
+ for (Map<String, Object> fileType : fileTypeList) {
|
|
|
+ String type = fileType.get("type").toString();
|
|
|
+ List<String> fileIdList = (List<String>)fileType.get("fileIdList");
|
|
|
+
|
|
|
+ Map<String, String> param = new HashMap<String, String>();
|
|
|
+ param.put("fileType", type);
|
|
|
+ param.put("fileIdListStr", JSONArray.fromObject(fileIdList).toString());
|
|
|
+ List fileInfDetailList = Service.lookup(IDianwangService.class).queryFileInfDetail(param, rows);
|
|
|
+ fileType.put("fileInfDetailList", fileInfDetailList);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置返回值
|
|
|
+ res.set(IMINBusinessConstant.F_PAGING_LAY, fileTypeList);
|
|
|
+ res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报表信息组装
|
|
|
+ * @param monthChoose 月范围
|
|
|
+ * @param range 日期范围
|
|
|
+ * @param timeRange 时分秒范围
|
|
|
+ * @param reportInf 报表信息
|
|
|
+ * @param monthNum 台区停电 monthNum个月内停电countNum次
|
|
|
+ * @param countNum 台区停电 monthNum个月内停电countNum次
|
|
|
+ * @param firstFileId 终端投托运报表选择的第一个原始数据文件
|
|
|
+ * @param secondFileId 终端投托运报表选择的对比原始数据文件
|
|
|
+ * @param FADateRange FA动作日期区间
|
|
|
+ * @param yearChoose FA动作年份
|
|
|
+ * @param DdyDateRange 低电压动日期区间
|
|
|
+ * @param ddyFxbId 低电压分析表id
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ * @throws ParseException
|
|
|
+ * @throws InvocationTargetException
|
|
|
+ * @throws IllegalArgumentException
|
|
|
+ * @throws IllegalAccessException
|
|
|
+ * @throws SecurityException
|
|
|
+ * @throws NoSuchMethodException
|
|
|
+ */
|
|
|
+ @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 {
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+
|
|
|
+ // 报表类型id
|
|
|
+ String reportTypeId = reportInf.split("_")[0];
|
|
|
+
|
|
|
+ Map<String, String> param = new HashMap<String, String>();
|
|
|
+ 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<String, String> resMap = Service.lookup(IReportService.class).reportNeedDetail(param);
|
|
|
+ res.set(IMINBusinessConstant.F_PAGING_LAY, resMap);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param reportData
|
|
|
+ * @param reportInf
|
|
|
+ * @param fileName
|
|
|
+ * @param monthNum 台区停电参数 台区停电【month个月内停电count次及以上台区】的month
|
|
|
+ * @param countNum 台区停电参数 台区停电【month个月内停电count次及以上台区】的count
|
|
|
+ * @param range 台区停电参数
|
|
|
+ * @param timeRange 台区停电参数
|
|
|
+ * @param firstFileId 终端投退运参数
|
|
|
+ * @param secondFileId 终端投退运参数
|
|
|
+ * @param session
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ */
|
|
|
+ @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);
|
|
|
+ report.setUploadDate(DateUtil.getCurrentDateString());
|
|
|
+ report.setFileName(fileName);
|
|
|
+ report.setCreatUser(user.getId());
|
|
|
+ report.setBranch(user.getBranchid());
|
|
|
+ report.setType(reportTypeId);
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报告详情
|
|
|
+ * @param reportId
|
|
|
+ * @param session
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ */
|
|
|
+ @MINAction(value = REPORT_INF_DETAIL)
|
|
|
+ public MINActionResult reportInfDetail(
|
|
|
+ @MINParam(key = "reportId") String reportId,
|
|
|
+ MINSession session
|
|
|
+ ) throws MINBusinessException {
|
|
|
+ db = Service.lookup(IMINDataBaseService.class);
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+
|
|
|
+ DwReportData reportDataInf = db.selectByPrimaryKey(DwReportDataMapper.class, reportId);
|
|
|
+ res.set(IMINBusinessConstant.F_PAGING_LAY, reportDataInf);
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报表下载
|
|
|
+ * @param reportId
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ */
|
|
|
+ @MINAction(value = REPORT_DOWN_LOAD)
|
|
|
+ public HttpServletResponse reportDownLoad(
|
|
|
+ @MINParam(key = "reportId") String reportId,
|
|
|
+ HttpServletResponse response
|
|
|
+ ) throws MINBusinessException {
|
|
|
+ db = Service.lookup(IMINDataBaseService.class);
|
|
|
+
|
|
|
+ DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
|
|
|
+
|
|
|
+ DwBranchReportType branchReportType = db.selectByPrimaryKey(DwBranchReportTypeMapper.class, reportInf.getType());
|
|
|
+
|
|
|
+ DwReportData reportDataInf = db.selectByPrimaryKey(DwReportDataMapper.class, reportId);
|
|
|
+
|
|
|
+ // excel类型
|
|
|
+ if ("00".equals(branchReportType.getType())) {
|
|
|
+ //导出Excel
|
|
|
+ OutputStream out=null;
|
|
|
+ try {
|
|
|
+ out = response.getOutputStream();
|
|
|
+ HSSFWorkbook wb = ReportExcelUtil.export(response, reportInf.getFileName(), reportDataInf.getData());
|
|
|
+ if(wb != null){
|
|
|
+ wb.write(out);
|
|
|
+ }
|
|
|
+ out.flush();
|
|
|
+ out.close();
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 报告删除
|
|
|
+ * @param reportId
|
|
|
+ * @param session
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ */
|
|
|
+ @MINAction(value = REPORT_INF_DELETE)
|
|
|
+ public MINActionResult reportInfDelete(
|
|
|
+ @MINParam(key = "reportId") String reportId,
|
|
|
+ MINSession session
|
|
|
+ ) throws MINBusinessException {
|
|
|
+ db = Service.lookup(IMINDataBaseService.class);
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+
|
|
|
+ DwReportInf reportInf = new DwReportInf();
|
|
|
+ reportInf.setId(reportId);
|
|
|
+ reportInf.setState(Constant.REPORT_STATE_1);
|
|
|
+ db.updateByPrimaryKeySelective(DwReportInfMapper.class, reportInf);
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改
|
|
|
+ * @param reportId
|
|
|
+ * @param excelList
|
|
|
+ * @param reportName
|
|
|
+ * @param session
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ */
|
|
|
+ @MINAction(value = REPORT_INF_UPDATE)
|
|
|
+ public MINActionResult reportInfUpdate(
|
|
|
+ @MINParam(key = "reportId") String reportId,
|
|
|
+ @MINParam(key = "excelList") String excelList,
|
|
|
+ @MINParam(key = "reportName") String reportName,
|
|
|
+ MINSession session
|
|
|
+ ) throws MINBusinessException {
|
|
|
+ db = Service.lookup(IMINDataBaseService.class);
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+
|
|
|
+ DwReportInf reportInf = new DwReportInf();
|
|
|
+ reportInf.setId(reportId);
|
|
|
+ reportInf.setFileName(reportName);
|
|
|
+ db.updateByPrimaryKeySelective(DwReportInfMapper.class, reportInf);
|
|
|
+
|
|
|
+ DwReportData reportData = new DwReportData();
|
|
|
+ reportData.setId(reportId);
|
|
|
+ reportData.setData(excelList);
|
|
|
+ db.updateByPrimaryKeySelective(DwReportDataMapper.class, reportData);
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 低电压分析表提交
|
|
|
+ * @param reportId
|
|
|
+ * @param excelList
|
|
|
+ * @param reportName
|
|
|
+ * @param session
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ * @throws ParseException
|
|
|
+ * @throws InvocationTargetException
|
|
|
+ * @throws IllegalArgumentException
|
|
|
+ * @throws IllegalAccessException
|
|
|
+ * @throws SecurityException
|
|
|
+ * @throws NoSuchMethodException
|
|
|
+ */
|
|
|
+ @MINAction(value = DDY_REPORT_INF_SUBMIT, transaction = IMINTransactionEnum.CMT)
|
|
|
+ public MINActionResult ddyReportInfSubmit(
|
|
|
+ @MINParam(key = "range") String range,
|
|
|
+ @MINParam(key = "fileName") String fileName,
|
|
|
+ @MINParam(key = "reportInf") String reportInf,
|
|
|
+ MINSession session
|
|
|
+ ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
|
+ db = Service.lookup(IMINDataBaseService.class);
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+
|
|
|
+ String reportType = reportInf.split("_")[0];
|
|
|
+
|
|
|
+ User user = session.getUser();
|
|
|
+
|
|
|
+ String reportId = db.getMybatisMapper(SequenceMapper.class).getSequence("REPORT_INF_NO");
|
|
|
+ // 生成报告表
|
|
|
+ DwReportInf report = new DwReportInf();
|
|
|
+ report.setId(reportId);
|
|
|
+ report.setUploadDate(DateUtil.getCurrentDateString());
|
|
|
+ report.setFileName(fileName);
|
|
|
+ report.setCreatUser(user.getId());
|
|
|
+ report.setBranch(user.getBranchid());
|
|
|
+ report.setType(reportType);
|
|
|
+ report.setDayInterval(range.replaceAll(" ", "")); // 日期时间段
|
|
|
+ db.insertSelective(DwReportInfMapper.class, report);
|
|
|
+
|
|
|
+ int page = 1;
|
|
|
+ int limit = 1000;
|
|
|
+ // 循环生成分析表数据
|
|
|
+ while (true) {
|
|
|
+ Map<String, Object> resMap = Service.lookup(IReportService.class).reportTypeDDYZLFXB(report.getDayInterval(), reportType, page, limit);
|
|
|
+ // 需处理总条数
|
|
|
+ Integer count = (Integer)resMap.get("count");
|
|
|
+
|
|
|
+ List<List<String>> resList = (List<List<String>>)resMap.get("resList");
|
|
|
+ for (int i = 2; i < resList.size(); i ++) {
|
|
|
+ List<String> childList = (List<String>)resList.get(i);
|
|
|
+ String id = db.getMybatisMapper(SequenceMapper.class).getSequence("DW_DDY_FXB_NO");
|
|
|
+ DwDdyFxb ddyFxb = new DwDdyFxb();
|
|
|
+ ddyFxb.setId(id);
|
|
|
+ ddyFxb.setXh(childList.get(0));
|
|
|
+ ddyFxb.setXgsmc(childList.get(1));
|
|
|
+ ddyFxb.setYhgldwmc(childList.get(2));
|
|
|
+ ddyFxb.setXlmc(childList.get(3));
|
|
|
+ ddyFxb.setTqid(childList.get(4));
|
|
|
+ ddyFxb.setByqmc(childList.get(5));
|
|
|
+ ddyFxb.setYhbh(childList.get(6));
|
|
|
+ ddyFxb.setDdysj(Integer.parseInt(childList.get(7)));
|
|
|
+ ddyFxb.setLjts(Integer.parseInt(childList.get(8)));
|
|
|
+ ddyFxb.setDdyzymc(childList.get(9));
|
|
|
+ ddyFxb.setJtyy(childList.get(10));
|
|
|
+ ddyFxb.setZlcs(childList.get(11));
|
|
|
+ ddyFxb.setSfzl(childList.get(12));
|
|
|
+ ddyFxb.setZlwcsj(childList.get(13));
|
|
|
+ ddyFxb.setSfxc(childList.get(14));
|
|
|
+ ddyFxb.setZrxz(childList.get(15));
|
|
|
+ ddyFxb.setQnljts(Integer.parseInt(childList.get(16)));
|
|
|
+ ddyFxb.setReportId(reportId);
|
|
|
+ db.insertSelective(DwDdyFxbMapper.class, ddyFxb);
|
|
|
+
|
|
|
+ String beginDate = report.getDayInterval().split("-")[0];
|
|
|
+ String endDate = report.getDayInterval().split("-")[1];
|
|
|
+ int index = 17;
|
|
|
+ while (CommonUtil.compare(endDate, beginDate) != -1) {
|
|
|
+ if (CommonUtil.isEmpty(childList.get(index))) {
|
|
|
+ // 天数减1
|
|
|
+ endDate = DateUtil.dateAddDay(endDate, -1);
|
|
|
+ index++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ DwDdyFxbDetail ddyFxbDetail = new DwDdyFxbDetail();
|
|
|
+ String detailId = db.getMybatisMapper(SequenceMapper.class).getSequence("DW_DDY_FXB_DETAIL_NO");
|
|
|
+ ddyFxbDetail.setId(detailId);
|
|
|
+ ddyFxbDetail.setDate(endDate);
|
|
|
+ ddyFxbDetail.setFxbId(id);
|
|
|
+ ddyFxbDetail.setSc(childList.get(index));
|
|
|
+ index++;
|
|
|
+ db.insertSelective(DwDdyFxbDetailMapper.class, ddyFxbDetail);
|
|
|
+ // 天数减1
|
|
|
+ endDate = DateUtil.dateAddDay(endDate, -1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count <= page * limit) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ page ++;
|
|
|
+ }
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 低电压报告详情
|
|
|
+ * @param reportId
|
|
|
+ * @param session
|
|
|
+ * @return
|
|
|
+ * @throws MINBusinessException
|
|
|
+ * @throws ParseException
|
|
|
+ * @throws InvocationTargetException
|
|
|
+ * @throws IllegalArgumentException
|
|
|
+ * @throws IllegalAccessException
|
|
|
+ * @throws SecurityException
|
|
|
+ * @throws NoSuchMethodException
|
|
|
+ */
|
|
|
+ @MINAction(value = DDY_REPORT_INF_DETAIL)
|
|
|
+ public MINActionResult ddyReportInfDetail(
|
|
|
+ @MINParam(key = "reportId") String reportId,
|
|
|
+ @MINParam(key = "page") int page,
|
|
|
+ @MINParam(key = "limit") int limit,
|
|
|
+ MINSession session
|
|
|
+ ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
|
|
|
+ db = Service.lookup(IMINDataBaseService.class);
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+
|
|
|
+ List<Map<String, String>> resList = new ArrayList<Map<String, String>>();
|
|
|
+
|
|
|
+ MINRowBounds rows = new MINRowBounds(page, limit);
|
|
|
+ rows.setSeparateSql(true);
|
|
|
+
|
|
|
+ DwDdyFxbExample ddyFxbExample = new DwDdyFxbExample();
|
|
|
+ ddyFxbExample.createCriteria().andReportIdEqualTo(reportId);
|
|
|
+ ddyFxbExample.setOrderByClause("DDF_ID");
|
|
|
+ List<DwDdyFxb> ddyFxbList = db.selectByExample(DwDdyFxbMapper.class, ddyFxbExample, rows);
|
|
|
+
|
|
|
+ List<String> fxbIdList = CommonUtil.getIdFromList(ddyFxbList, "id");
|
|
|
+
|
|
|
+ DwDdyFxbDetailExample ddyFxbDetailExample = new DwDdyFxbDetailExample();
|
|
|
+ ddyFxbDetailExample.createCriteria().andFxbIdIn(fxbIdList);
|
|
|
+ ddyFxbDetailExample.setOrderByClause("DDFD_FXB_ID");
|
|
|
+ List<DwDdyFxbDetail> detailList = db.selectByExample(DwDdyFxbDetailMapper.class, ddyFxbDetailExample);
|
|
|
+
|
|
|
+ for (DwDdyFxb ddyFxb : ddyFxbList) {
|
|
|
+ Map<String, String> child = new HashMap<String, String>();
|
|
|
+ child.put("id", ddyFxb.getId());
|
|
|
+ child.put("xh", ddyFxb.getXh());
|
|
|
+ child.put("xgsmc", ddyFxb.getXgsmc());
|
|
|
+ child.put("yhgldwmc", ddyFxb.getYhgldwmc());
|
|
|
+ child.put("xlmc", ddyFxb.getXlmc());
|
|
|
+ child.put("tqid", ddyFxb.getTqid());
|
|
|
+ child.put("byqmc", ddyFxb.getByqmc());
|
|
|
+ child.put("yhbh", ddyFxb.getYhbh());
|
|
|
+ child.put("ddysj", String.valueOf(ddyFxb.getDdysj()));
|
|
|
+ child.put("ljts", String.valueOf(ddyFxb.getLjts()));
|
|
|
+ child.put("ddyzymc", ddyFxb.getDdyzymc());
|
|
|
+ child.put("jtyy", ddyFxb.getJtyy());
|
|
|
+ child.put("zlcs", ddyFxb.getZlcs());
|
|
|
+ child.put("sfzl", ddyFxb.getSfzl());
|
|
|
+ child.put("zlwcsj", ddyFxb.getZlwcsj());
|
|
|
+ child.put("sfxc", ddyFxb.getSfxc());
|
|
|
+
|
|
|
+ for (int i = 0; i < detailList.size(); i++) {
|
|
|
+ // 分析表id一致
|
|
|
+ if (ddyFxb.getId().equals(detailList.get(i).getFxbId())) {
|
|
|
+ String sjrq = detailList.get(i).getDate();
|
|
|
+ child.put(sjrq, detailList.get(i).getSc());
|
|
|
+ detailList.remove(i);
|
|
|
+ i --;
|
|
|
+ } else {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resList.add(child);
|
|
|
+ }
|
|
|
+ res.set(IMINBusinessConstant.F_PAGING_LAY, resList);
|
|
|
+ res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ @MINAction(value = DDY_REPORT_INF_UPDATE, transaction = IMINTransactionEnum.CMT)
|
|
|
+ public MINActionResult ddyReportInfUpdate(
|
|
|
+ @MINParam(key = "id") String id,
|
|
|
+ @MINParam(key = "ddyzymc") String ddyzymc,
|
|
|
+ @MINParam(key = "jtyy") String jtyy,
|
|
|
+ @MINParam(key = "zlcs") String zlcs,
|
|
|
+ @MINParam(key = "sfzl") String sfzl,
|
|
|
+ @MINParam(key = "zlwcsj") String zlwcsj,
|
|
|
+ @MINParam(key = "sfxc") String sfxc,
|
|
|
+ MINSession session
|
|
|
+ ) throws MINBusinessException, ParseException {
|
|
|
+ db = Service.lookup(IMINDataBaseService.class);
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
+ DwDdyFxb ddyFxb = new DwDdyFxb();
|
|
|
+ ddyFxb.setId(id);
|
|
|
+ if (!CommonUtil.isEmpty(ddyzymc)) {
|
|
|
+ ddyFxb.setDdyzymc(ddyzymc);
|
|
|
+ }
|
|
|
+ if (!CommonUtil.isEmpty(jtyy)) {
|
|
|
+ ddyFxb.setJtyy(jtyy);
|
|
|
+ }
|
|
|
+ if (!CommonUtil.isEmpty(zlcs)) {
|
|
|
+ ddyFxb.setZlcs(zlcs);
|
|
|
+ }
|
|
|
+ if (!CommonUtil.isEmpty(sfzl)) {
|
|
|
+ ddyFxb.setSfzl(sfzl);
|
|
|
+ }
|
|
|
+ if (!CommonUtil.isEmpty(zlwcsj)) {
|
|
|
+ ddyFxb.setZlwcsj(zlwcsj);
|
|
|
+ }
|
|
|
+ if (!CommonUtil.isEmpty(sfxc)) {
|
|
|
+ ddyFxb.setSfxc(sfxc);
|
|
|
+ }
|
|
|
+ db.updateByPrimaryKeySelective(DwDdyFxbMapper.class, ddyFxb);
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+}
|