ReportManageAction.java 38 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  1. package com.minpay.reportManage.action;
  2. import java.io.IOException;
  3. import java.io.OutputStream;
  4. import java.lang.reflect.InvocationTargetException;
  5. import java.net.URLEncoder;
  6. import java.text.ParseException;
  7. import java.util.ArrayList;
  8. import java.util.Collection;
  9. import java.util.HashMap;
  10. import java.util.Iterator;
  11. import java.util.List;
  12. import java.util.Map;
  13. import javax.servlet.http.HttpServletResponse;
  14. import com.alibaba.fastjson.JSON;
  15. import com.minpay.common.util.StringUtil;
  16. import com.minpay.db.table.mapper.*;
  17. import com.minpay.db.table.model.*;
  18. import org.apache.commons.fileupload.FileItem;
  19. import org.apache.poi.hssf.usermodel.HSSFCell;
  20. import org.apache.poi.hssf.usermodel.HSSFCellStyle;
  21. import org.apache.poi.hssf.usermodel.HSSFPalette;
  22. import org.apache.poi.hssf.usermodel.HSSFRow;
  23. import org.apache.poi.hssf.usermodel.HSSFSheet;
  24. import org.apache.poi.hssf.usermodel.HSSFWorkbook;
  25. import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
  26. import org.apache.poi.ss.usermodel.CellStyle;
  27. import org.apache.poi.ss.usermodel.Font;
  28. import com.minpay.common.bean.User;
  29. import com.minpay.common.constant.Constant;
  30. import com.minpay.common.format.IFormatService;
  31. import com.minpay.common.service.IDianwangService;
  32. import com.minpay.common.service.IReportService;
  33. import com.minpay.common.util.CommonUtil;
  34. import com.minpay.common.util.DateUtil;
  35. import com.minpay.common.util.FilesUtil;
  36. import com.minpay.db.table.own.mapper.ReportManageMapper;
  37. import com.minpay.db.table.own.mapper.SequenceMapper;
  38. import com.minpay.dianwang.util.ReportExcelUtil;
  39. import com.startup.minpay.frame.business.IMINAction;
  40. import com.startup.minpay.frame.business.MINHttpServletRequestContext;
  41. import com.startup.minpay.frame.business.res.MINActionResult;
  42. import com.startup.minpay.frame.constant.IMINBusinessConstant;
  43. import com.startup.minpay.frame.constant.IMINTransactionEnum;
  44. import com.startup.minpay.frame.exception.MINBusinessException;
  45. import com.startup.minpay.frame.jdbc.MINRowBounds;
  46. import com.startup.minpay.frame.service.base.IMINDataBaseService;
  47. import com.startup.minpay.frame.service.base.Service;
  48. import com.startup.minpay.frame.session.MINSession;
  49. import com.startup.minpay.frame.target.MINAction;
  50. import com.startup.minpay.frame.target.MINComponent;
  51. import com.startup.minpay.frame.target.MINParam;
  52. import net.sf.json.JSONArray;
  53. import net.sf.json.JSONObject;
  54. @MINComponent
  55. public class ReportManageAction implements IMINAction {
  56. private IMINDataBaseService db;
  57. /** 报表查询 */
  58. public final static String REPORT_INF_QUERY = "reportInfQuery";
  59. /** 生成报表的数据查询 */
  60. public final static String FILE_INF_REPORT_QUERY = "fileInfReportQuery";
  61. /** 根据不同的报表类型查询对应时间范围类的所需数据 */
  62. public final static String REPORT_NEED_DATA_DETAIL = "reportNeedDataDetail";
  63. /** 生成报表 */
  64. public final static String FILE_INF_REPORT_SUBMIT = "fileInfReportSubmit";
  65. /** 报告数据详情 */
  66. public final static String REPORT_INF_DETAIL = "reportInfDetail";
  67. /** 报告下载 */
  68. public final static String REPORT_DOWN_LOAD = "reportDownLoad";
  69. /** 报告删除 */
  70. public final static String REPORT_INF_DELETE = "reportInfDelete";
  71. /** 报告修改 */
  72. public final static String REPORT_INF_UPDATE = "reportInfUpdate";
  73. /** 低电压分析表提交 */
  74. public final static String DDY_REPORT_INF_SUBMIT = "ddyReportInfSubmit";
  75. /** 低电压分析表详情 */
  76. public final static String DDY_REPORT_INF_DETAIL = "ddyReportInfDetail";
  77. /** 低电压分析表编辑 */
  78. public final static String DDY_REPORT_INF_UPDATE = "ddyReportInfUpdate";
  79. /** 低电压分析表下载*/
  80. public final static String DDY_REPORT_INF_DOWNLOAD = "ddyReportInfDownload";
  81. /** 低电压分析表上传*/
  82. public final static String DDY_REPORT_INF_UPLOAD = "ddyReportInfUpload";
  83. /** test*/
  84. public final static String test = "test";
  85. /**
  86. * 报表查询
  87. * @param page
  88. * @param limit
  89. * @param date
  90. * @param fileName
  91. * @return
  92. * @throws MINBusinessException
  93. * @throws InvocationTargetException
  94. * @throws IllegalArgumentException
  95. * @throws IllegalAccessException
  96. * @throws SecurityException
  97. * @throws NoSuchMethodException
  98. * @throws InstantiationException
  99. */
  100. @MINAction(value = REPORT_INF_QUERY)
  101. public MINActionResult reportInfQuery(
  102. @MINParam(key = "page", defaultValue = "1") int page,
  103. @MINParam(key = "limit", defaultValue = "10") int limit,
  104. @MINParam(key = "date") String date,
  105. @MINParam(key = "fileName") String fileName,
  106. @MINParam(key = "timeType") String timeType,
  107. @MINParam(key = "reportType") String reportType,
  108. MINSession session
  109. ) throws MINBusinessException {
  110. MINActionResult res = new MINActionResult();
  111. db = Service.lookup(IMINDataBaseService.class);
  112. //分页
  113. MINRowBounds rows = new MINRowBounds(page, limit);
  114. rows.setSeparateSql(true);
  115. Map<String, Object> param = new HashMap<String, Object>();
  116. //去空格
  117. param.put("date", StringUtil.ObjectToString(date).replaceAll("-",""));
  118. param.put("fileName", fileName);
  119. param.put("timeType", timeType);
  120. param.put("reportType", reportType);
  121. User user = session.getUser();
  122. String roleId = user.getRoleId();
  123. // 非系统管理员
  124. if (!Constant.ROLE_ID.equals(roleId)) {
  125. param.put("branchId", user.getBranchid());
  126. }
  127. List<Map<String, String>> list = db.getMybatisMapper(ReportManageMapper.class).selectReportInf(param, rows);
  128. list = Service.lookup(IFormatService.class).formatDate(list, "uploadDate");
  129. // 设置返回值
  130. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  131. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  132. return res;
  133. }
  134. /**
  135. * 报告明细信息组装
  136. * @param chooseFileListStr
  137. * @param session
  138. * @return
  139. * @throws MINBusinessException
  140. */
  141. @MINAction(value = FILE_INF_REPORT_QUERY)
  142. public MINActionResult fileInfReportQuery(
  143. @MINParam(key = "chooseFileListStr") String chooseFileListStr,
  144. @MINParam(key = "page", defaultValue = "1") int page,
  145. @MINParam(key = "limit", defaultValue = "200") int limit,
  146. MINSession session
  147. ) throws MINBusinessException {
  148. MINActionResult res = new MINActionResult();
  149. MINRowBounds rows = new MINRowBounds(page, limit);
  150. rows.setSeparateSql(true);
  151. JSONArray chooseFileList = JSONArray.fromObject(chooseFileListStr);
  152. List<Map<String, Object>> fileTypeList = new ArrayList<Map<String, Object>>();
  153. // 处理选中数据 将同一文件类型的数据放在一起,方便分表查询数据
  154. for (Object object : chooseFileList) {
  155. Map<String, String> chooseFile = (Map<String, String>)object;
  156. boolean flag = false;
  157. for (Map<String, Object> fileType : fileTypeList) {
  158. if (chooseFile.get("type").equals(fileType.get("type"))) {
  159. List<String> fileIdList = (List<String>)fileType.get("fileIdList");
  160. fileIdList.add(chooseFile.get("id"));
  161. }
  162. flag = true;
  163. }
  164. if (!flag) {
  165. Map<String, Object> fileType = new HashMap<String, Object>();
  166. List<String> fileIdList = new ArrayList<String>();
  167. fileIdList.add(chooseFile.get("id"));
  168. fileType.put("type", chooseFile.get("type"));
  169. fileType.put("fileIdList", fileIdList);
  170. fileTypeList.add(fileType);
  171. }
  172. }
  173. // 查询对应明细信息
  174. for (Map<String, Object> fileType : fileTypeList) {
  175. String type = fileType.get("type").toString();
  176. List<String> fileIdList = (List<String>)fileType.get("fileIdList");
  177. Map<String, String> param = new HashMap<String, String>();
  178. param.put("fileType", type);
  179. param.put("fileIdListStr", JSONArray.fromObject(fileIdList).toString());
  180. List fileInfDetailList = Service.lookup(IDianwangService.class).queryFileInfDetail(param, rows);
  181. fileType.put("fileInfDetailList", fileInfDetailList);
  182. }
  183. // 设置返回值
  184. res.set(IMINBusinessConstant.F_PAGING_LAY, fileTypeList);
  185. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  186. return res;
  187. }
  188. /**
  189. * 报表信息组装
  190. * @param monthChoose 月范围
  191. * @param range 日期范围
  192. * @param timeRange 时分秒范围
  193. * @param reportInf 报表信息
  194. * @param monthNum 台区停电 monthNum个月内停电countNum次
  195. * @param countNum 台区停电 monthNum个月内停电countNum次
  196. * @param firstFileId 终端投托运报表选择的第一个原始数据文件
  197. * @param secondFileId 终端投托运报表选择的对比原始数据文件
  198. * @param FADateRange FA动作日期区间
  199. * @param yearChoose FA动作年份
  200. * @param DdyDateRange 低电压动日期区间
  201. * @param ddyFxbId 低电压分析表id
  202. * @return
  203. * @throws MINBusinessException
  204. * @throws ParseException
  205. * @throws InvocationTargetException
  206. * @throws IllegalArgumentException
  207. * @throws IllegalAccessException
  208. * @throws SecurityException
  209. * @throws NoSuchMethodException
  210. * @throws IOException
  211. * @throws InvalidFormatException
  212. */
  213. @MINAction(value = REPORT_NEED_DATA_DETAIL)
  214. public MINActionResult reportNeedDataDetail(
  215. MINHttpServletRequestContext request,
  216. @MINParam(key = "monthChoose") String monthChoose,
  217. @MINParam(key = "range") String range,
  218. @MINParam(key = "timeRange") String timeRange,
  219. @MINParam(key = "reportInf") String reportInf,
  220. @MINParam(key = "monthNum") String monthNum,
  221. @MINParam(key = "countNum") String countNum,
  222. @MINParam(key = "firstFileId") String firstFileId,
  223. @MINParam(key = "secondFileId") String secondFileId,
  224. @MINParam(key = "FADateRange") String FADateRange,
  225. @MINParam(key = "yearChoose") String yearChoose,
  226. @MINParam(key = "DdyDateRange") String DdyDateRange,
  227. @MINParam(key = "ddyFxbId") String ddyFxbId
  228. ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, InvalidFormatException, IOException {
  229. MINActionResult res = new MINActionResult();
  230. // 报表类型id
  231. String reportTypeId = reportInf.split("_")[0];
  232. Map<String, Object> param = new HashMap<String, Object>();
  233. param.put("monthChoose", monthChoose);
  234. param.put("range", range);
  235. param.put("timeRange", timeRange);
  236. param.put("reportTypeId", reportTypeId);
  237. param.put("monthNum", monthNum);
  238. param.put("countNum", countNum);
  239. param.put("firstFileId", firstFileId);
  240. param.put("secondFileId", secondFileId);
  241. param.put("FADateRange", FADateRange);
  242. param.put("yearChoose", yearChoose);
  243. param.put("DdyDateRange", DdyDateRange);
  244. param.put("ddyFxbId", ddyFxbId);
  245. param.put("request", request);
  246. Map<String, Object> resMap = Service.lookup(IReportService.class).reportNeedDetail(param);
  247. res.set(IMINBusinessConstant.F_PAGING_LAY, resMap);
  248. return res;
  249. }
  250. /**
  251. *
  252. * @param reportData
  253. * @param reportInf
  254. * @param fileName
  255. * @param monthNum 台区停电参数 台区停电【month个月内停电count次及以上台区】的month
  256. * @param countNum 台区停电参数 台区停电【month个月内停电count次及以上台区】的count
  257. * @param range 台区停电参数
  258. * @param timeRange 台区停电参数
  259. * @param firstFileId 终端投退运参数
  260. * @param secondFileId 终端投退运参数
  261. * @param session
  262. * @return
  263. * @throws MINBusinessException
  264. */
  265. @MINAction(value = FILE_INF_REPORT_SUBMIT, transaction = IMINTransactionEnum.CMT)
  266. public MINActionResult fileInfReportSubmit(
  267. @MINParam(key = "reportData") String reportData,
  268. @MINParam(key = "reportInf") String reportInf,
  269. @MINParam(key = "fileName") String fileName,
  270. @MINParam(key = "monthNum") String monthNum,
  271. @MINParam(key = "countNum") String countNum,
  272. @MINParam(key = "range") String range,
  273. @MINParam(key = "timeRange") String timeRange,
  274. @MINParam(key = "firstFileId") String firstFileId,
  275. @MINParam(key = "secondFileId") String secondFileId,
  276. @MINParam(key = "ddyFxbId") String ddyFxbId,
  277. @MINParam(key = "yearChoose") String yearChoose,
  278. @MINParam(key = "monthChoose") String monthChoose,
  279. MINSession session
  280. ) throws MINBusinessException {
  281. db = Service.lookup(IMINDataBaseService.class);
  282. MINActionResult res = new MINActionResult();
  283. String reportId = db.getMybatisMapper(SequenceMapper.class).getSequence("REPORT_INF_NO");
  284. String reportType = reportInf.split("_")[1];
  285. String reportTypeId = reportInf.split("_")[0];
  286. // 生成报表数据表
  287. DwReportData reportDataInf = new DwReportData();
  288. reportDataInf.setId(reportId);
  289. reportDataInf.setData(reportData);
  290. reportDataInf.setType(reportType);
  291. db.insertSelective(DwReportDataMapper.class, reportDataInf);
  292. User user = session.getUser();
  293. // 生成报告表
  294. DwReportInf report = new DwReportInf();
  295. report.setId(reportId);
  296. report.setUploadDate(DateUtil.getCurrentDateString());
  297. report.setFileName(fileName);
  298. report.setCreatUser(user.getId());
  299. report.setBranch(user.getBranchid());
  300. report.setType(reportTypeId);
  301. report.setZdttyCompareId(firstFileId + "-" + secondFileId);
  302. report.setTqtdMonth(monthNum); // 台区停电【month个月内停电count次及以上台区】的month
  303. report.setTqtdCount(countNum); // 台区停电【month个月内停电count次及以上台区】的count
  304. report.setDdyFxbId(ddyFxbId);
  305. report.setDayInterval(range.replaceAll(" ", "")); // 日期时间段
  306. report.setTimeInterval(timeRange.replaceAll(" ", "")); // 时分秒时间段
  307. report.setYearInterval(yearChoose.replaceAll(" ", ""));
  308. report.setMonthInterval(monthChoose.replaceAll(" ", ""));
  309. db.insertSelective(DwReportInfMapper.class, report);
  310. return res;
  311. }
  312. /**
  313. * 报告详情
  314. * @param reportId
  315. * @param session
  316. * @return
  317. * @throws MINBusinessException
  318. */
  319. @MINAction(value = REPORT_INF_DETAIL)
  320. public MINActionResult reportInfDetail(
  321. @MINParam(key = "reportId") String reportId,
  322. MINSession session
  323. ) throws MINBusinessException {
  324. db = Service.lookup(IMINDataBaseService.class);
  325. MINActionResult res = new MINActionResult();
  326. DwReportData reportDataInf = db.selectByPrimaryKey(DwReportDataMapper.class, reportId);
  327. res.set(IMINBusinessConstant.F_PAGING_LAY, reportDataInf);
  328. return res;
  329. }
  330. /**
  331. * 报表下载
  332. * @param reportId
  333. * @param response
  334. * @return
  335. * @throws Exception
  336. */
  337. @MINAction(value = REPORT_DOWN_LOAD)
  338. public HttpServletResponse reportDownLoad(
  339. @MINParam(key = "reportId") String reportId,
  340. HttpServletResponse response
  341. ) throws Exception {
  342. db = Service.lookup(IMINDataBaseService.class);
  343. DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
  344. DwBranchReportType branchReportType = db.selectByPrimaryKey(DwBranchReportTypeMapper.class, reportInf.getType());
  345. DwReportData reportDataInf = db.selectByPrimaryKey(DwReportDataMapper.class, reportId);
  346. Map<String, Object> dataJSONMap = new HashMap<String,Object>();
  347. List<List<String>> dataList = new ArrayList<List<String>>();
  348. String descStr = "";
  349. try {
  350. dataJSONMap = JSONObject.fromObject(reportDataInf.getData());//数据格式不对应
  351. dataList = (List<List<String>>)dataJSONMap.get("excelList");
  352. descStr = (String)dataJSONMap.get("descStr");
  353. descStr = descStr.replaceAll("<p>", "");
  354. descStr = descStr.replaceAll("</p>", System.getProperty("line.separator"));
  355. if (dataJSONMap.get("dataMap") != null) {
  356. Map<String, Object> dataMap = (Map<String, Object>)dataJSONMap.get("dataMap");
  357. for(Map.Entry<String, Object> entry : dataMap.entrySet()){
  358. String mapKey = entry.getKey();
  359. Object mapValue = entry.getValue();
  360. descStr = descStr.replaceAll("\\$\\{" + mapKey + "\\}", String.valueOf(mapValue));
  361. }
  362. }
  363. } catch (Exception e){
  364. try {
  365. String[][] temp = JSON.parseObject(reportDataInf.getData(),String[][].class);
  366. String[] temp2 = null;
  367. List<String> tempList = null;
  368. if (temp != null) {
  369. for (int i = 0; i < temp.length; i++) {
  370. tempList = new ArrayList<String>();
  371. temp2 = temp[i];
  372. for (int j = 0; j < temp2.length; j++) {
  373. tempList.add(temp2[j]);
  374. }
  375. dataList.add(tempList);
  376. }
  377. }
  378. } catch (Exception ee){
  379. dataList = new ArrayList<List<String>>();
  380. }
  381. }
  382. if( dataList == null){
  383. dataList = new ArrayList<List<String>>();
  384. }
  385. // excel类型
  386. if ("00".equals(branchReportType.getType())) {
  387. //导出Excel
  388. OutputStream out=null;
  389. try {
  390. out = response.getOutputStream();
  391. HSSFWorkbook wb = ReportExcelUtil.export(response, reportInf.getFileName(), dataList, descStr);
  392. if(wb != null){
  393. wb.write(out);
  394. }
  395. out.flush();
  396. out.close();
  397. } catch (Exception e) {
  398. e.printStackTrace();
  399. }
  400. } else {
  401. ReportExcelUtil.write2Docx(response, reportInf.getFileName(), descStr, "\\home\\temp", reportInf.getFileName() + ".docx");
  402. }
  403. return response;
  404. }
  405. /**
  406. * 报告删除
  407. * @param reportId
  408. * @param session
  409. * @return
  410. * @throws MINBusinessException
  411. */
  412. @MINAction(value = REPORT_INF_DELETE)
  413. public MINActionResult reportInfDelete(@MINParam(key = "reportId") String reportId,MINSession session) throws MINBusinessException {
  414. db = Service.lookup(IMINDataBaseService.class);
  415. MINActionResult res = new MINActionResult();
  416. DwReportInf reportInf = new DwReportInf();
  417. reportInf.setId(reportId);
  418. reportInf.setState(Constant.REPORT_STATE_1);
  419. db.updateByPrimaryKeySelective(DwReportInfMapper.class, reportInf);
  420. return res;
  421. }
  422. /**
  423. * 修改
  424. * @param reportId
  425. * @param excelList
  426. * @param reportName
  427. * @param session
  428. * @return
  429. * @throws MINBusinessException
  430. */
  431. @MINAction(value = REPORT_INF_UPDATE)
  432. public MINActionResult reportInfUpdate(
  433. @MINParam(key = "reportId") String reportId,
  434. @MINParam(key = "excelList") String excelList,
  435. @MINParam(key = "reportName") String reportName,
  436. MINSession session
  437. ) throws MINBusinessException {
  438. db = Service.lookup(IMINDataBaseService.class);
  439. MINActionResult res = new MINActionResult();
  440. DwReportInf reportInf = new DwReportInf();
  441. reportInf.setId(reportId);
  442. reportInf.setFileName(reportName);
  443. db.updateByPrimaryKeySelective(DwReportInfMapper.class, reportInf);
  444. DwReportData reportData = new DwReportData();
  445. reportData.setId(reportId);
  446. reportData.setData(excelList);
  447. db.updateByPrimaryKeySelective(DwReportDataMapper.class, reportData);
  448. return res;
  449. }
  450. /**
  451. * 低电压分析表提交
  452. * @param range
  453. * @param fileName
  454. * @param reportInf
  455. * @param session
  456. * @return
  457. * @throws MINBusinessException
  458. * @throws ParseException
  459. * @throws InvocationTargetException
  460. * @throws IllegalArgumentException
  461. * @throws IllegalAccessException
  462. * @throws SecurityException
  463. * @throws NoSuchMethodException
  464. */
  465. @MINAction(value = DDY_REPORT_INF_SUBMIT, transaction = IMINTransactionEnum.CMT)
  466. public MINActionResult ddyReportInfSubmit(
  467. @MINParam(key = "range") String range,
  468. @MINParam(key = "fileName") String fileName,
  469. @MINParam(key = "reportInf") String reportInf,
  470. MINSession session
  471. ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
  472. db = Service.lookup(IMINDataBaseService.class);
  473. MINActionResult res = new MINActionResult();
  474. //获取报表类型
  475. String reportType = reportInf.split("_")[0];//DDYZLFXB_00_03
  476. User user = session.getUser();
  477. String reportId = db.getMybatisMapper(SequenceMapper.class).getSequence("REPORT_INF_NO");
  478. // 生成报表数据表
  479. String[] date = range.replaceAll(" ", "").split("-");
  480. //日期格式化
  481. String bbStartDate = CommonUtil.dateFormat(date[0],"yyyy年MM月dd日");
  482. String bbEndDate = CommonUtil.dateFormat(date[1],"yyyy年MM月dd日");
  483. DwReportData reportDataInf = new DwReportData();
  484. reportDataInf.setId(reportId);
  485. reportDataInf.setData("{\"descStr\":\"<p>1.数据来源:智能化供电服务指挥系统;因系统数据滞后,统计时间为:"+bbStartDate+"—"+bbEndDate+",每日发生低电压客户已标红,受考核用户已标黄,累计时长≥15小时的预警用户标褐红色需重点治理。每日新增预警及考核用户编号已标红。</p><p>2.反馈要求:请各单位照实填写,按时反馈,具体原因请填写详细,治理完成的填写治理完成时间。未填写或填写不详细的一律列入考核,请知悉。</p><p>3.低电压是否消除:以供电服务指挥系统数据为依据,连续7天未发生低电压视为低电压消除。</P>\"}");
  486. reportDataInf.setType(reportInf.split("_")[1]);
  487. db.insertSelective(DwReportDataMapper.class, reportDataInf);
  488. // 生成报告表
  489. DwReportInf report = new DwReportInf();
  490. report.setId(reportId);
  491. report.setUploadDate(DateUtil.getCurrentDateString());
  492. report.setFileName(fileName);
  493. report.setCreatUser(user.getId());
  494. report.setBranch(user.getBranchid());
  495. report.setType(reportType);
  496. report.setDayInterval(range.replaceAll(" ", "")); // 日期时间段
  497. db.insertSelective(DwReportInfMapper.class, report);
  498. int page = 1;
  499. int limit = 1000;
  500. // 循环生成分析表数据
  501. while (true) {
  502. Map<String, Object> resMap = Service.lookup(IReportService.class).reportTypeDDYZLFXB(report.getDayInterval(), reportType, page, limit);
  503. // 需处理总条数
  504. Integer count = (Integer)resMap.get("count");
  505. List<List<String>> resList = (List<List<String>>)resMap.get("resList");
  506. for (int i = 2; i < resList.size(); i ++) {
  507. List<String> childList = (List<String>)resList.get(i);
  508. String id = db.getMybatisMapper(SequenceMapper.class).getSequence("DW_DDY_FXB_NO");
  509. DwDdyFxb ddyFxb = new DwDdyFxb();
  510. ddyFxb.setId(id);
  511. ddyFxb.setXh(childList.get(0));
  512. ddyFxb.setXgsmc(childList.get(1));
  513. ddyFxb.setYhgldwmc(childList.get(2));
  514. ddyFxb.setXlmc(childList.get(3));
  515. ddyFxb.setTqid(childList.get(4));
  516. ddyFxb.setByqmc(childList.get(5));
  517. ddyFxb.setYhbh(childList.get(6));
  518. ddyFxb.setDdysj(Integer.parseInt(childList.get(7)));//低电压时长
  519. ddyFxb.setLjts(Integer.parseInt(childList.get(8)));//累计天数
  520. ddyFxb.setDdyzymc(childList.get(9));
  521. ddyFxb.setJtyy(childList.get(10));
  522. ddyFxb.setZlcs(childList.get(11));
  523. ddyFxb.setSfzl(childList.get(12));
  524. ddyFxb.setZlwcsj(childList.get(13));
  525. ddyFxb.setSfxc(childList.get(14));
  526. ddyFxb.setZrxz(childList.get(15));
  527. ddyFxb.setQnljts(Integer.parseInt(childList.get(16)));
  528. ddyFxb.setReportId(reportId);
  529. db.insertSelective(DwDdyFxbMapper.class, ddyFxb);
  530. String beginDate = report.getDayInterval().split("-")[0];
  531. String endDate = report.getDayInterval().split("-")[1];
  532. int index = 17;
  533. while (CommonUtil.compare(endDate, beginDate) != -1) {
  534. if (CommonUtil.isEmpty(childList.get(index))) {
  535. // 天数减1
  536. endDate = DateUtil.dateAddDay(endDate, -1);
  537. index++;
  538. continue;
  539. }
  540. DwDdyFxbDetail ddyFxbDetail = new DwDdyFxbDetail();
  541. String detailId = db.getMybatisMapper(SequenceMapper.class).getSequence("DW_DDY_FXB_DETAIL_NO");
  542. ddyFxbDetail.setId(detailId);
  543. ddyFxbDetail.setDate(endDate);
  544. ddyFxbDetail.setFxbId(id);
  545. ddyFxbDetail.setSc(childList.get(index));
  546. index++;
  547. db.insertSelective(DwDdyFxbDetailMapper.class, ddyFxbDetail);
  548. // 天数减1
  549. endDate = DateUtil.dateAddDay(endDate, -1);
  550. }
  551. }
  552. if (count <= page * limit) {
  553. break;
  554. }
  555. page ++;
  556. }
  557. return res;
  558. }
  559. /**
  560. * 低电压报告详情
  561. * @param reportId
  562. * @param session
  563. * @return
  564. * @throws MINBusinessException
  565. * @throws ParseException
  566. * @throws InvocationTargetException
  567. * @throws IllegalArgumentException
  568. * @throws IllegalAccessException
  569. * @throws SecurityException
  570. * @throws NoSuchMethodException
  571. */
  572. @MINAction(value = DDY_REPORT_INF_DETAIL)
  573. public MINActionResult ddyReportInfDetail(
  574. @MINParam(key = "reportId") String reportId,
  575. @MINParam(key = "page") int page,
  576. @MINParam(key = "limit") int limit,
  577. MINSession session
  578. ) throws MINBusinessException, ParseException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
  579. db = Service.lookup(IMINDataBaseService.class);
  580. MINActionResult res = new MINActionResult();
  581. List<Map<String, String>> resList = new ArrayList<Map<String, String>>();
  582. MINRowBounds rows = new MINRowBounds(page, limit);
  583. rows.setSeparateSql(true);
  584. DwDdyFxbExample ddyFxbExample = new DwDdyFxbExample();
  585. ddyFxbExample.createCriteria().andReportIdEqualTo(reportId);
  586. ddyFxbExample.setOrderByClause("DDF_ID");
  587. //查询电网低电压分析表数据-DDF_ID
  588. List<DwDdyFxb> ddyFxbList = db.selectByExample(DwDdyFxbMapper.class, ddyFxbExample, rows);
  589. List<String> fxbIdList = CommonUtil.getIdFromList(ddyFxbList, "id");
  590. if(fxbIdList == null || fxbIdList.isEmpty()){
  591. fxbIdList = new ArrayList<String>();
  592. fxbIdList.add("XXXXXXXX");
  593. }
  594. DwDdyFxbDetailExample ddyFxbDetailExample = new DwDdyFxbDetailExample();
  595. ddyFxbDetailExample.createCriteria().andFxbIdIn(fxbIdList);
  596. ddyFxbDetailExample.setOrderByClause("DDFD_FXB_ID");
  597. List<DwDdyFxbDetail> detailList = db.selectByExample(DwDdyFxbDetailMapper.class, ddyFxbDetailExample);
  598. System.out.println("当前页数据遍历:共"+ddyFxbList.size()+"条数据");
  599. for (DwDdyFxb ddyFxb : ddyFxbList) {
  600. Map<String, String> child = new HashMap<String, String>();
  601. child.put("id", ddyFxb.getId());
  602. child.put("xh", ddyFxb.getXh());
  603. child.put("xgsmc", ddyFxb.getXgsmc());
  604. child.put("yhgldwmc", ddyFxb.getYhgldwmc());
  605. child.put("xlmc", ddyFxb.getXlmc());
  606. child.put("tqid", ddyFxb.getTqid());
  607. child.put("byqmc", ddyFxb.getByqmc());
  608. child.put("yhbh", ddyFxb.getYhbh());
  609. child.put("ddysj", String.valueOf(ddyFxb.getDdysj()));
  610. child.put("ljts", String.valueOf(ddyFxb.getLjts()));
  611. child.put("ddyzymc", ddyFxb.getDdyzymc());
  612. child.put("jtyy", ddyFxb.getJtyy());
  613. child.put("zlcs", ddyFxb.getZlcs());
  614. child.put("sfzl", ddyFxb.getSfzl());
  615. child.put("zlwcsj", ddyFxb.getZlwcsj());
  616. child.put("sfxc", ddyFxb.getSfxc());
  617. for (int i = 0; i < detailList.size(); i++) {
  618. // 分析表id一致
  619. if (ddyFxb.getId().equals(detailList.get(i).getFxbId())) {
  620. String sjrq = detailList.get(i).getDate();
  621. child.put(sjrq, detailList.get(i).getSc());
  622. detailList.remove(i);
  623. i --;
  624. } else {
  625. break;
  626. }
  627. }
  628. resList.add(child);
  629. }
  630. res.set(IMINBusinessConstant.F_PAGING_LAY, resList);
  631. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  632. return res;
  633. }
  634. /**
  635. * 低电压编辑
  636. * @param id
  637. * @param ddyzymc
  638. * @param jtyy
  639. * @param zlcs
  640. * @param sfzl
  641. * @param zlwcsj
  642. * @param sfxc
  643. * @param session
  644. * @return
  645. * @throws MINBusinessException
  646. * @throws ParseException
  647. */
  648. @MINAction(value = DDY_REPORT_INF_UPDATE, transaction = IMINTransactionEnum.CMT)
  649. public MINActionResult ddyReportInfUpdate(
  650. @MINParam(key = "id") String id,
  651. @MINParam(key = "ddyzymc") String ddyzymc,
  652. @MINParam(key = "jtyy") String jtyy,
  653. @MINParam(key = "zlcs") String zlcs,
  654. @MINParam(key = "sfzl") String sfzl,
  655. @MINParam(key = "zlwcsj") String zlwcsj,
  656. @MINParam(key = "sfxc") String sfxc,
  657. MINSession session
  658. ) throws MINBusinessException, ParseException {
  659. db = Service.lookup(IMINDataBaseService.class);
  660. MINActionResult res = new MINActionResult();
  661. DwDdyFxb ddyFxb = new DwDdyFxb();
  662. ddyFxb.setId(id);
  663. if (!CommonUtil.isEmpty(ddyzymc)) {
  664. ddyFxb.setDdyzymc(ddyzymc);
  665. }
  666. if (!CommonUtil.isEmpty(jtyy)) {
  667. ddyFxb.setJtyy(jtyy);
  668. }
  669. if (!CommonUtil.isEmpty(zlcs)) {
  670. ddyFxb.setZlcs(zlcs);
  671. }
  672. if (!CommonUtil.isEmpty(sfzl)) {
  673. ddyFxb.setSfzl(sfzl);
  674. }
  675. if (!CommonUtil.isEmpty(zlwcsj)) {
  676. ddyFxb.setZlwcsj(zlwcsj);
  677. }
  678. if (!CommonUtil.isEmpty(sfxc)) {
  679. ddyFxb.setSfxc(sfxc);
  680. }
  681. db.updateByPrimaryKeySelective(DwDdyFxbMapper.class, ddyFxb);
  682. return res;
  683. }
  684. @MINAction(value = DDY_REPORT_INF_DOWNLOAD)
  685. public HttpServletResponse ddyReportInfDownload(
  686. @MINParam(key = "reportId") String reportId,
  687. HttpServletResponse response
  688. ) throws Exception {
  689. db = Service.lookup(IMINDataBaseService.class);
  690. DwReportInf reportInf = db.selectByPrimaryKey(DwReportInfMapper.class, reportId);
  691. int page = 1;
  692. int limit = 1000;
  693. int count = 0;
  694. List<Map<String, String>> resList = new ArrayList<Map<String, String>>();
  695. while (true) {
  696. MINRowBounds rows = new MINRowBounds(page, limit);
  697. rows.setSeparateSql(true);
  698. DwDdyFxbExample ddyFxbExample = new DwDdyFxbExample();
  699. ddyFxbExample.createCriteria().andReportIdEqualTo(reportId);
  700. ddyFxbExample.setOrderByClause("DDF_ID");
  701. List<DwDdyFxb> ddyFxbList = db.selectByExample(DwDdyFxbMapper.class, ddyFxbExample, rows);
  702. count = rows.getCount();
  703. List<String> fxbIdList = CommonUtil.getIdFromList(ddyFxbList, "id");
  704. DwDdyFxbDetailExample ddyFxbDetailExample = new DwDdyFxbDetailExample();
  705. ddyFxbDetailExample.createCriteria().andFxbIdIn(fxbIdList);
  706. ddyFxbDetailExample.setOrderByClause("DDFD_FXB_ID");
  707. List<DwDdyFxbDetail> detailList = db.selectByExample(DwDdyFxbDetailMapper.class, ddyFxbDetailExample);
  708. for (DwDdyFxb ddyFxb : ddyFxbList) {
  709. Map<String, String> child = new HashMap<String, String>();
  710. child.put("id", ddyFxb.getId());
  711. child.put("xh", ddyFxb.getXh());
  712. child.put("xgsmc", ddyFxb.getXgsmc());
  713. child.put("yhgldwmc", ddyFxb.getYhgldwmc());
  714. child.put("xlmc", ddyFxb.getXlmc());
  715. child.put("tqid", ddyFxb.getTqid());
  716. child.put("byqmc", ddyFxb.getByqmc());
  717. child.put("yhbh", ddyFxb.getYhbh());
  718. child.put("ddysj", String.valueOf(ddyFxb.getDdysj()));
  719. child.put("ljts", String.valueOf(ddyFxb.getLjts()));
  720. child.put("ddyzymc", ddyFxb.getDdyzymc());
  721. child.put("jtyy", ddyFxb.getJtyy());
  722. child.put("zlcs", ddyFxb.getZlcs());
  723. child.put("sfzl", ddyFxb.getSfzl());
  724. child.put("zlwcsj", ddyFxb.getZlwcsj());
  725. child.put("sfxc", ddyFxb.getSfxc());
  726. for (int i = 0; i < detailList.size(); i++) {
  727. // 分析表id一致
  728. if (ddyFxb.getId().equals(detailList.get(i).getFxbId())) {
  729. String sjrq = detailList.get(i).getDate();
  730. child.put(sjrq, detailList.get(i).getSc());
  731. detailList.remove(i);
  732. i --;
  733. } else {
  734. break;
  735. }
  736. }
  737. resList.add(child);
  738. }
  739. if (limit*page >= count) {
  740. break;
  741. }
  742. page ++;
  743. }
  744. //导出Excel
  745. OutputStream out=null;
  746. try {
  747. String beginTime = reportInf.getDayInterval().split("-")[0];
  748. String endTime = reportInf.getDayInterval().split("-")[1];
  749. int dayNum = DateUtil.diffDate(beginTime, endTime);
  750. String[] excelHeader = new String[dayNum + 16];
  751. excelHeader[0] = "系统编号#id";
  752. excelHeader[1] = "县公司名称#xgsmc";
  753. excelHeader[2] = "用户管理单位名称#yhgldwmc";
  754. excelHeader[3] = "线路名称#xlmc";
  755. excelHeader[4] = "台区ID#tqid";
  756. excelHeader[5] = "变压器名称#byqmc";
  757. excelHeader[6] = "用户编号#yhbh";
  758. excelHeader[7] = "低电压时长#ddysj";
  759. excelHeader[8] = "累计天数#ljts";
  760. excelHeader[9] = "低电压主要原因#ddyzymc";
  761. excelHeader[10] = "具体原因#jtyy";
  762. excelHeader[11] = "治理措施#zlcs";
  763. excelHeader[12] = "是否治理#sfzl";
  764. excelHeader[13] = "治理完成时间#zlwcsj";
  765. excelHeader[14] = "是否消除#sfxc";
  766. int index = 15;
  767. while (CommonUtil.compare(endTime, beginTime) != -1) {
  768. excelHeader[index] = endTime + "#" + endTime;
  769. index ++;
  770. endTime = DateUtil.dateAddDay(endTime, -1);
  771. }
  772. out = response.getOutputStream();
  773. HSSFWorkbook wb = export(response, reportInf.getFileName(), excelHeader, resList);
  774. if(wb != null){
  775. wb.write(out);
  776. }
  777. out.flush();
  778. out.close();
  779. } catch (Exception e) {
  780. e.printStackTrace();
  781. }
  782. return response;
  783. }
  784. @MINAction(value = DDY_REPORT_INF_UPLOAD)
  785. public MINActionResult ddyReportInfUpload(
  786. MINHttpServletRequestContext request,
  787. @MINParam(key = "id") String id,
  788. MINSession session
  789. ) throws MINBusinessException, InvalidFormatException, IOException {
  790. MINActionResult res = new MINActionResult();
  791. db = Service.lookup(IMINDataBaseService.class);
  792. // 获取文件
  793. FileItem fileItem = request.getFile("file");
  794. String fileName = fileItem.getName();
  795. if (!fileName.endsWith(".xlsx") && !fileName.endsWith(".xls")) {
  796. throw new MINBusinessException("文件格式错误!");
  797. }
  798. // 获取表格信息
  799. String[] titleKey = new String[]{"NO","ID","XGSMC","YHGLDWMC", "XLMC","TQID","BYQMC","YHBH","DDYSJ","LJTS","DDYZYMC","JTYY","ZLCS","SFZL","ZLWCSJ","SFXC"};
  800. List<Map<String,String>> list = FilesUtil.readExecleasy(fileItem, titleKey, 1);
  801. for (int i = 0; i < list.size(); i ++) {
  802. Map<String, String> map = list.get(i);
  803. DwDdyFxb ddyFxb = new DwDdyFxb();
  804. ddyFxb.setId(map.get("ID"));
  805. ddyFxb.setDdyzymc(map.get("DDYZYMC"));
  806. ddyFxb.setJtyy(map.get("JTYY"));
  807. ddyFxb.setZlcs(map.get("ZLCS"));
  808. ddyFxb.setSfzl(map.get("SFZL"));
  809. ddyFxb.setZlwcsj(map.get("ZLWCSJ"));
  810. ddyFxb.setSfxc(map.get("SFXC"));
  811. db.updateByPrimaryKeySelective(DwDdyFxbMapper.class, ddyFxb);
  812. }
  813. return res;
  814. }
  815. public static <T> HSSFWorkbook export(HttpServletResponse response, String fileName, String[] excelHeader,
  816. Collection<T> dataList) throws Exception {
  817. // 设置请求
  818. response.setContentType("application/application/vnd.ms-excel");
  819. response.setHeader("Content-disposition",
  820. "attachment;filename=" + URLEncoder.encode(fileName + ".xlsx", "UTF-8"));
  821. // 创建一个Workbook,对应一个Excel文件
  822. HSSFWorkbook wb = new HSSFWorkbook();
  823. // 设置标题样式
  824. HSSFCellStyle titleStyle = wb.createCellStyle();
  825. // 设置字体样式
  826. Font titleFont = wb.createFont();
  827. titleFont.setFontHeightInPoints((short) 12); // 字体高度
  828. titleFont.setFontName("黑体"); // 字体样式
  829. titleStyle.setFont(titleFont);
  830. titleStyle.setAlignment(CellStyle.ALIGN_CENTER);
  831. // 在Workbook中添加一个sheet,对应Excel文件中的sheet
  832. HSSFSheet sheet = wb.createSheet(fileName);
  833. // 标题数组
  834. String[] titleArray = new String[excelHeader.length];
  835. // 字段名数组
  836. String[] fieldArray = new String[excelHeader.length];
  837. for (int i = 0; i < excelHeader.length; i++) {
  838. String[] tempArray = excelHeader[i].split("#");// 临时数组 分割#
  839. titleArray[i] = tempArray[0];
  840. fieldArray[i] = tempArray[1];
  841. }
  842. // 在sheet中添加标题行
  843. HSSFRow row = sheet.createRow((int) 0);// 行数从0开始
  844. HSSFCell sequenceCell = row.createCell(0);// cell列 从0开始 第一列添加序号
  845. sequenceCell.setCellValue("序号");
  846. sequenceCell.setCellStyle(titleStyle);
  847. sheet.autoSizeColumn(0);// 自动设置宽度
  848. // 为标题行赋值
  849. for (int i = 0; i < titleArray.length; i++) {
  850. HSSFCell titleCell = row.createCell(i + 1);// 0号位被序号占用,所以需+1
  851. titleCell.setCellValue(titleArray[i]);
  852. titleCell.setCellStyle(titleStyle);
  853. sheet.autoSizeColumn(i + 1);// 0号位被序号占用,所以需+1
  854. sheet.setColumnWidth(i+1,titleArray[i].getBytes().length*256+500);
  855. }
  856. // 数据样式 因为标题和数据样式不同 需要分开设置 不然会覆盖
  857. HSSFCellStyle dataStyle = wb.createCellStyle();
  858. // 设置数据字体
  859. Font dataFont = wb.createFont();
  860. dataFont.setFontHeightInPoints((short) 10); // 字体高度
  861. dataFont.setFontName("宋体"); // 字体
  862. dataStyle.setFont(dataFont);
  863. dataStyle.setAlignment(CellStyle.ALIGN_CENTER);
  864. // 自定义颜色
  865. HSSFPalette palette = wb.getCustomPalette();
  866. palette.setColorAtIndex((short)9, (byte) (0xff & 240), (byte) (0xff & 165), (byte) (0xff & 172));
  867. palette.setColorAtIndex((short)10, (byte) (0xff & 255), (byte) (0xff & 192), (byte) (0xff & 0));
  868. HSSFCellStyle dataStyle2 = wb.createCellStyle();
  869. dataStyle2.setFont(dataFont);
  870. dataStyle2.setFillPattern(CellStyle.SOLID_FOREGROUND);
  871. dataStyle2.setFillForegroundColor((short)9);
  872. dataStyle2.setAlignment(CellStyle.ALIGN_CENTER);
  873. HSSFCellStyle dataStyle3 = wb.createCellStyle();
  874. dataStyle3.setFont(dataFont);
  875. dataStyle3.setFillPattern(CellStyle.SOLID_FOREGROUND);
  876. dataStyle3.setFillForegroundColor((short)10);
  877. dataStyle3.setAlignment(CellStyle.ALIGN_CENTER);
  878. // 遍历集合数据,产生数据行
  879. Iterator<T> it = dataList.iterator();
  880. int index = 0;
  881. while (it.hasNext()) {
  882. index++;
  883. row = sheet.createRow(index);
  884. // 为序号赋值
  885. HSSFCell sequenceCellValue = row.createCell(0);// 序号值永远是第0列
  886. sequenceCellValue.setCellValue(index);
  887. sequenceCellValue.setCellStyle(dataStyle);
  888. // sheet.autoSizeColumn(0);
  889. T t = (T) it.next();
  890. Map<String, Object> map = (Map<String, Object> )t;
  891. HSSFCell dataCell = null;
  892. for (int i = 0; i < fieldArray.length; i++) {
  893. dataCell = row.createCell(i + 1);
  894. String fieldName = fieldArray[i];
  895. String value = CommonUtil.objToString(map.get(fieldName));
  896. // 每日时长列
  897. if (i >= 15) {
  898. if (CommonUtil.isEmpty(value)) {
  899. dataCell.setCellValue("");
  900. dataCell.setCellStyle(dataStyle);
  901. } else {
  902. dataCell.setCellValue(value);// 为当前列赋值
  903. dataCell.setCellStyle(dataStyle2);
  904. }
  905. //用户编号列
  906. } else if (i == 6) {
  907. // 低电压时长
  908. String sj = String.valueOf(map.get(fieldArray[i + 1]));
  909. if (CommonUtil.compare(sj, "48") != -1) {
  910. dataCell.setCellValue(value);// 为当前列赋值
  911. dataCell.setCellStyle(dataStyle3);
  912. } else {
  913. dataCell.setCellValue(value);// 为当前列赋值
  914. dataCell.setCellStyle(dataStyle);
  915. }
  916. } else {
  917. dataCell.setCellStyle(dataStyle);
  918. if (CommonUtil.isEmpty(value)) {
  919. dataCell.setCellValue(""); // 为当前列赋值
  920. } else {
  921. dataCell.setCellValue(CommonUtil.objToString(value));// 为当前列赋值
  922. }
  923. }
  924. }
  925. }
  926. sheet.setColumnWidth(fieldArray.length, 20 * 256);
  927. return wb;
  928. }
  929. /**
  930. * 报表查询--测试
  931. * @param page
  932. * @param limit
  933. */
  934. @MINAction(value = test)
  935. public MINActionResult test(
  936. @MINParam(key = "page", defaultValue = "1") int page,
  937. @MINParam(key = "limit", defaultValue = "10") int limit,
  938. MINSession session
  939. ) throws MINBusinessException {
  940. MINActionResult res = new MINActionResult();
  941. db = Service.lookup(IMINDataBaseService.class);
  942. //分页
  943. MINRowBounds rows = new MINRowBounds(page, limit);
  944. rows.setSeparateSql(true);
  945. //参数
  946. Map<String, Object> param = new HashMap<String, Object>();
  947. //用户信息
  948. User user = session.getUser();
  949. String roleId = user.getRoleId();
  950. // 非系统管理员
  951. if (!Constant.ROLE_ID.equals(roleId)) {
  952. param.put("branchId", user.getBranchid());
  953. }
  954. //查询
  955. DwFileDetail08Example ddyFxbExample = new DwFileDetail08Example();
  956. List<DwFileDetail08> list = db.selectByExample(DwFileDetail08Mapper.class,ddyFxbExample,rows);
  957. // 设置返回值
  958. res.set(IMINBusinessConstant.F_PAGING_LAY, list);
  959. res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
  960. return res;
  961. }
  962. }