XlgzzReportAction.java 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. package com.minpay.reportManage.action;
  2. import com.minpay.common.bean.User;
  3. import com.minpay.common.constant.Constant;
  4. import com.minpay.common.format.IFormatService;
  5. import com.minpay.common.service.IReportService;
  6. import com.minpay.common.util.DateUtil;
  7. import com.minpay.db.table.mapper.DwReportDataMapper;
  8. import com.minpay.db.table.mapper.DwReportInfMapper;
  9. import com.minpay.db.table.model.DwReportData;
  10. import com.minpay.db.table.model.DwReportInf;
  11. import com.minpay.db.table.own.mapper.IReportBatchMapper;
  12. import com.minpay.db.table.own.mapper.ReportManageMapper;
  13. import com.minpay.db.table.own.mapper.SequenceMapper;
  14. import com.startup.minpay.frame.business.IMINAction;
  15. import com.startup.minpay.frame.business.res.MINActionResult;
  16. import com.startup.minpay.frame.constant.IMINBusinessConstant;
  17. import com.startup.minpay.frame.constant.IMINTransactionEnum;
  18. import com.startup.minpay.frame.exception.MINBusinessException;
  19. import com.startup.minpay.frame.jdbc.MINRowBounds;
  20. import com.startup.minpay.frame.service.base.IMINDataBaseService;
  21. import com.startup.minpay.frame.service.base.Service;
  22. import com.startup.minpay.frame.session.MINSession;
  23. import com.startup.minpay.frame.target.MINAction;
  24. import com.startup.minpay.frame.target.MINComponent;
  25. import com.startup.minpay.frame.target.MINParam;
  26. import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  27. import java.io.IOException;
  28. import java.lang.reflect.InvocationTargetException;
  29. import java.text.ParseException;
  30. import java.util.HashMap;
  31. import java.util.List;
  32. import java.util.Map;
  33. @MINComponent
  34. public class XlgzzReportAction implements IMINAction {
  35. private IMINDataBaseService db;
  36. /** 报表查询 */
  37. public final static String REPORT_INF_QUERY = "reportInfQuery";
  38. /** 生成报表的数据查询 */
  39. public final static String FILE_INF_REPORT_QUERY = "fileInfReportQuery";
  40. /** 根据不同的报表类型查询对应时间范围类的所需数据 */
  41. public final static String REPORT_NEED_DATA_DETAIL = "reportNeedDataDetail";
  42. public final static String REPORT_NEED_DATA_DETAIL2 = "reportNeedDataDetail2";
  43. /** 生成报表 */
  44. public final static String FILE_INF_REPORT_SUBMIT = "fileInfReportSubmit";
  45. /** 报告数据详情 */
  46. public final static String REPORT_INF_DETAIL = "reportInfDetail";
  47. /** 报告下载 */
  48. public final static String REPORT_DOWN_LOAD = "reportDownLoad";
  49. /** 报告删除 */
  50. public final static String REPORT_INF_DELETE = "reportInfDelete";
  51. /** 报告修改 */
  52. public final static String REPORT_INF_UPDATE = "reportInfUpdate";
  53. @MINAction(value = REPORT_INF_QUERY)
  54. public MINActionResult reportInfQuery(
  55. @MINParam(key = "page", defaultValue = "1") int page,
  56. @MINParam(key = "limit", defaultValue = "10") int limit,
  57. @MINParam(key = "date") String date,
  58. @MINParam(key = "fileName") String fileName,
  59. @MINParam(key = "timeType") String timeType,
  60. @MINParam(key = "reportType") String reportType,
  61. MINSession session
  62. ) throws MINBusinessException {
  63. MINActionResult res = new MINActionResult();
  64. db = Service.lookup(IMINDataBaseService.class);
  65. //分页
  66. MINRowBounds rows = new MINRowBounds(page, limit);
  67. rows.setSeparateSql(true);
  68. Map<String, Object> param = new HashMap<String, Object>();
  69. param.put("date", date);
  70. param.put("fileName", fileName);
  71. param.put("timeType", timeType);
  72. param.put("reportType", reportType);
  73. User user = session.getUser();
  74. String roleId = user.getRoleId();
  75. // 非系统管理员
  76. if (!Constant.ROLE_ID.equals(roleId)) {
  77. param.put("branchId", user.getBranchid());
  78. }
  79. List<Map<String, String>> list = db.getMybatisMapper(ReportManageMapper.class).selectReportInf(param, rows);
  80. list = Service.lookup(IFormatService.class).formatDate(list, "uploadDate");
  81. // 设置返回值
  82. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  83. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  84. return res;
  85. }
  86. @MINAction(value = FILE_INF_REPORT_SUBMIT, transaction = IMINTransactionEnum.CMT)
  87. public MINActionResult fileInfReportSubmit(
  88. @MINParam(key = "reportData") String reportData,
  89. @MINParam(key = "reportInf") String reportInf,
  90. @MINParam(key = "fileName") String fileName,
  91. @MINParam(key = "monthNum") String monthNum,
  92. @MINParam(key = "countNum") String countNum,
  93. @MINParam(key = "range") String range,
  94. @MINParam(key = "timeRange") String timeRange,
  95. @MINParam(key = "firstFileId") String firstFileId,
  96. @MINParam(key = "secondFileId") String secondFileId,
  97. @MINParam(key = "ddyFxbId") String ddyFxbId,
  98. @MINParam(key = "yearChoose") String yearChoose,
  99. @MINParam(key = "monthChoose") String monthChoose,
  100. MINSession session
  101. ) throws MINBusinessException {
  102. db = Service.lookup(IMINDataBaseService.class);
  103. MINActionResult res = new MINActionResult();
  104. String reportId = db.getMybatisMapper(SequenceMapper.class).getSequence("REPORT_INF_NO");
  105. String reportType = reportInf.split("_")[1];
  106. String reportTypeId = reportInf.split("_")[0];
  107. // 不生成报表数据表,实时计算
  108. // DwReportData reportDataInf = new DwReportData();
  109. // reportDataInf.setId(reportId);//
  110. // reportDataInf.setData(reportData);
  111. // reportDataInf.setType(reportType);
  112. // db.insertSelective(DwReportDataMapper.class, reportDataInf);
  113. User user = session.getUser();
  114. // 生成报告表
  115. DwReportInf report = new DwReportInf();
  116. report.setId(reportId);//报表ID
  117. report.setUploadDate(DateUtil.getCurrentDateString());//更新时间
  118. report.setFileName(fileName);//文件名
  119. report.setCreatUser(user.getId());//当前登录用户ID
  120. report.setBranch(user.getBranchid());//所属结构(班组)
  121. report.setType(reportTypeId);//dw_branch_report_type.DBRT_ID
  122. report.setZdttyCompareId(firstFileId + "-" + secondFileId);
  123. report.setTqtdMonth(monthNum); // 台区停电【month个月内停电count次及以上台区】的month
  124. report.setTqtdCount(countNum); // 台区停电【month个月内停电count次及以上台区】的count
  125. report.setDdyFxbId(ddyFxbId);
  126. report.setDayInterval(range.replaceAll(" ", "")); // 日期时间段
  127. report.setTimeInterval(timeRange.replaceAll(" ", "")); // 时分秒时间段
  128. report.setYearInterval(yearChoose.replaceAll(" ", ""));
  129. report.setMonthInterval(monthChoose.replaceAll(" ", ""));
  130. db.insertSelective(DwReportInfMapper.class, report);
  131. return res;
  132. }
  133. @MINAction(value = REPORT_NEED_DATA_DETAIL)
  134. public MINActionResult reportNeedDataDetail(
  135. @MINParam(key = "monthChoose") String monthChoose,
  136. @MINParam(key = "range") String range,
  137. @MINParam(key = "timeRange") String timeRange,
  138. @MINParam(key = "reportInf") String reportInf,
  139. @MINParam(key = "monthNum") String monthNum,
  140. @MINParam(key = "countNum") String countNum,
  141. @MINParam(key = "firstFileId") String firstFileId,
  142. @MINParam(key = "secondFileId") String secondFileId,
  143. @MINParam(key = "FADateRange") String FADateRange,
  144. @MINParam(key = "yearChoose") String yearChoose,
  145. @MINParam(key = "DdyDateRange") String DdyDateRange,
  146. @MINParam(key = "ddyFxbId") String ddyFxbId
  147. ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InvalidFormatException, IOException {
  148. MINActionResult res = new MINActionResult();
  149. // 报表类型id
  150. String reportTypeId = reportInf.split("_")[0];
  151. Map<String, Object> param = new HashMap<String, Object>();
  152. param.put("monthChoose", monthChoose);
  153. param.put("range", range);
  154. param.put("timeRange", timeRange);
  155. param.put("reportTypeId", reportTypeId);
  156. param.put("monthNum", monthNum);
  157. param.put("countNum", countNum);
  158. param.put("firstFileId", firstFileId);
  159. param.put("secondFileId", secondFileId);
  160. param.put("FADateRange", FADateRange);
  161. param.put("yearChoose", yearChoose);
  162. param.put("DdyDateRange", DdyDateRange);
  163. param.put("ddyFxbId", ddyFxbId);
  164. Map<String, Object> resMap = Service.lookup(IReportService.class).reportNeedDetail(param);
  165. res.set(IMINBusinessConstant.F_PAGING_LAY, resMap);
  166. return res;
  167. }
  168. @MINAction(value = REPORT_NEED_DATA_DETAIL2)
  169. public MINActionResult reportNeedDataDetail2(
  170. @MINParam(key = "reportId") String reportId
  171. ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InvalidFormatException, IOException {
  172. MINActionResult res = new MINActionResult();
  173. db = Service.lookup(IMINDataBaseService.class);
  174. // 报表类型id
  175. Map<String, Object> param = new HashMap<String, Object>();
  176. param.put("reportId", reportId);
  177. param.put("reportTypeId","XLGZZRB");
  178. List<Map<String,String>> list = db.getMybatisMapper(IReportBatchMapper.class).selectReportInfo(param);
  179. String range = "";
  180. String timeRange = "";
  181. if(list != null && !list.isEmpty()){
  182. param.put("range",list.get(0).get("DAYINTERVAL")) ;
  183. param.put("timeRange",list.get(0).get("TIMEINTERVAL"));
  184. }
  185. Map<String, Object> resMap = Service.lookup(IReportService.class).reportNeedDetail(param);
  186. res.set(IMINBusinessConstant.F_PAGING_LAY, resMap);
  187. return res;
  188. }
  189. }