WeeklyReportController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. package com.ruoyi.powerdistribution.controller;
  2. import com.ruoyi.common.core.controller.BaseController;
  3. import com.ruoyi.common.utils.DateUtils;
  4. import com.ruoyi.common.utils.StringUtils;
  5. import com.ruoyi.common.utils.uuid.UUID;
  6. import com.ruoyi.powerdistribution.domain.*;
  7. import com.ruoyi.powerdistribution.domain.dto.PdmWorkPlanDTO;
  8. import com.ruoyi.powerdistribution.domain.vo.SupRiskTeam;
  9. import com.ruoyi.powerdistribution.domain.vo.TaskRiskPlan;
  10. import com.ruoyi.powerdistribution.domain.vo.ThreeLevelRiskJob;
  11. import com.ruoyi.powerdistribution.service.*;
  12. import com.ruoyi.powerdistribution.util.GenerateWordUtil;
  13. import io.swagger.annotations.ApiOperation;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.beans.factory.annotation.Value;
  16. import org.springframework.web.bind.annotation.PostMapping;
  17. import org.springframework.web.bind.annotation.RequestMapping;
  18. import org.springframework.web.bind.annotation.RestController;
  19. import javax.activation.MimetypesFileTypeMap;
  20. import javax.servlet.http.HttpServletResponse;
  21. import java.io.*;
  22. import java.text.ParseException;
  23. import java.text.SimpleDateFormat;
  24. import java.util.*;
  25. /**
  26. * 周报导出
  27. */
  28. @RestController
  29. @RequestMapping("/power/weklyReport")
  30. public class WeeklyReportController extends BaseController {
  31. @Value("${printReplenishmentPath}")
  32. private String printReplenishmentPath;
  33. @Autowired
  34. private IPdmReportIllegalWeekService pdmReportIllegalWeekService;
  35. @Autowired
  36. private IPdmReportPlanNextWeekService pdmReportPlanNextWeekService;
  37. @Autowired
  38. private IPdmWorkPlanService pdmWorkPlanService;
  39. @Autowired
  40. private IPdmReportPlanNextDayService pdmReportPlanNextDayService;
  41. @Autowired
  42. private IPdmReportPlanWeekService pdmReportPlanWeekService;
  43. @Autowired
  44. private IPdmReportAppointmentWeekService pdmReportAppointmentWeekService;
  45. @PostMapping("/export")
  46. @ApiOperation(value = "周报导出")
  47. public void export(HttpServletResponse response, String beingDate,String endDate) throws IOException, ParseException {
  48. PdmReportIllegalDay pdmReportIllegalDay = new PdmReportIllegalDay();
  49. pdmReportIllegalDay.setReportDate(beingDate);
  50. Map<String,Object> dataMap = new HashMap();
  51. SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
  52. Date cvrtFirstDate = sdf.parse(beingDate);
  53. Date cvrtEndDate = sdf.parse(endDate);
  54. //日期公共使用
  55. String month=new SimpleDateFormat("MM").format(cvrtFirstDate);
  56. dataMap.put("beginDay",month+"月"+new SimpleDateFormat("dd").format(cvrtFirstDate)+"日");//开始日
  57. dataMap.put("endDay",month+"月"+new SimpleDateFormat("dd").format(cvrtEndDate)+"日");//结束日
  58. //一.风险计划管控
  59. //1.本周计划执行情况
  60. dataMap.put("jobRecNum",0);//发布作业信息条数
  61. dataMap.put("weekPlanJobReNum",0);//来源于周计划的作业条数
  62. dataMap.put("cancelRecNum",0);//已取消
  63. dataMap.put("implRate",0);//执行率
  64. dataMap.put("lowImplUnit","");//较低的单位 ()
  65. dataMap.put("lowImplRate","");//较低的单位执行率
  66. dataMap.put("tmpPlanRecNum",0);//临时计划
  67. dataMap.put("repairRecNum",0);//其中抢修
  68. dataMap.put("operateRecNum",0);//操作条数
  69. dataMap.put("maintenanceNum",0);//运维检修
  70. dataMap.put("expanRelocationNum",0);//业扩
  71. dataMap.put("networkReformNum",0);//网改
  72. dataMap.put("tmpPlanRate",0);//临时计划率
  73. dataMap.put("cancelTmpPlanRecNum",0);//临时取消计划数
  74. dataMap.put("tmpPlanImplRate",0);//临时计划执行率
  75. PdmReportPlanWeek pdmReportPlan = new PdmReportPlanWeek();
  76. pdmReportPlan.setReportDate(beingDate);
  77. pdmReportPlan.setReportEndDate(endDate);
  78. List<PdmReportPlanWeek> planlist = pdmReportPlanWeekService.selectPdmReportPlanWeekList(pdmReportPlan);
  79. dataMap.put("planlist",planlist);//本周计划执行情况
  80. //2.下周计划安排情况
  81. String nextMonday=DateUtils.getNextMonday(beingDate,"yyyyMMdd");
  82. String nextSunday=DateUtils.getNextSunday(beingDate,"yyyyMMdd");
  83. Date cvrtNextMonday = sdf.parse(nextMonday);
  84. Date cvrtNextSunday = sdf.parse(nextSunday);
  85. month=new SimpleDateFormat("MM").format(cvrtNextMonday);
  86. dataMap.put("nextWeekBeginDay",month+"月"+new SimpleDateFormat("dd").format(cvrtNextMonday)+"日");//下周开始日
  87. dataMap.put("nextWeekEndDay",month+"月"+new SimpleDateFormat("dd").format(cvrtNextSunday)+"日");//下周结束日
  88. dataMap.put("nextWeekJobRecNum",0);//配网专业计划总数
  89. dataMap.put("nextWeekSwitchingNum",0);//倒闸操作
  90. dataMap.put("distribuNetworkEngineNum",0);//配网工程
  91. dataMap.put("nextWeekExpanRelocationNum",0);//业扩杆迁
  92. dataMap.put("nextWeekMaintenanceNum",0);//运维检修
  93. dataMap.put("threeLevelRiskNum",0);//三级风险作业
  94. dataMap.put("fourLevelRiskNum",0);//四级风险作业
  95. dataMap.put("fiveLevelRiskNum",0);//五级风险作业
  96. dataMap.put("liveWorkingNum",0);//带电作业
  97. dataMap.put("liveDisconnectLeadNum",0);//带电断接引
  98. dataMap.put("assemDeviceNum",0);//带电消缺、装拆设备
  99. //三级风险作业内容:
  100. List<ThreeLevelRiskJob> threeLevelRiskJobs=new ArrayList<ThreeLevelRiskJob>() ;
  101. StringBuilder builder=new StringBuilder();
  102. for(int i=0;i<threeLevelRiskJobs.size();i++){
  103. ThreeLevelRiskJob threeLevelRiskJob=threeLevelRiskJobs.get(i);
  104. builder.append(threeLevelRiskJob.getCompName()).append(": ").append(threeLevelRiskJob.getJobDate()).append(",").append(threeLevelRiskJob.getJobContent()).append("。").append("\r\n");
  105. }
  106. dataMap.put(" threeLevelRiskJobs",StringUtils.isEmpty(builder.toString())?"无":builder.toString());//三级风险作业内容:
  107. //三级及以上作业风险计划
  108. PdmWorkPlanDTO workPlan = new PdmWorkPlanDTO();
  109. workPlan.setStartDate(nextMonday);
  110. workPlan.setEndDate(nextSunday);
  111. workPlan.setLevel3Flag("1");//三级及以上作业
  112. List<PdmWorkPlan> workList = pdmWorkPlanService.selectPdmWorkPlanList(workPlan);
  113. dataMap.put("threeLevelRiskWorkList",workList);//三级及以上作业列表明细
  114. dataMap.put("fousMaintenanceNum",0);//重点关注检修面个数
  115. String fousMaintenanceInfo="";//重点关注检修面内容
  116. dataMap.put("fousMaintenanceInfo", StringUtils.isEmpty(fousMaintenanceInfo)?"无":fousMaintenanceInfo);//重点关注检修面内容
  117. //下周计划安排情况
  118. PdmReportPlanNextWeek next = new PdmReportPlanNextWeek();
  119. next.setReportDate(nextMonday);
  120. next.setReportEndDate(nextSunday);
  121. List<PdmReportPlanNextWeek> nextList = pdmReportPlanNextWeekService.selectPdmReportPlanNextWeekList(next);
  122. dataMap.put("nextWeekWorkList",nextList);//下周计划安排情况列表
  123. //二、专业反违章履职情况
  124. //1.本周违章查处情况
  125. dataMap.put("investPunishRecAllNum",0);//配网专业共计查处违章
  126. dataMap.put("provinceInvestPunishRecNum",0);//被省公司查处违章
  127. dataMap.put("cityInvestPunishRecNum",0);//被市公司查处违章
  128. dataMap.put("cityInvestSeriousRecNum",0);//严重违章
  129. dataMap.put("cityInvestGeneralRecNum",0);//一般违章
  130. dataMap.put("countyInvestPunishRecNum",0);//县区公司自查处违章
  131. dataMap.put("countyInvestSeriousRecNum",0);//严重违章
  132. dataMap.put("countyInvestGeneralRecNum",0);//一般违章
  133. //本周违章查处情况列表
  134. PdmReportIllegalWeek pdmReportIllegal = new PdmReportIllegalWeek();
  135. pdmReportIllegal.setReportDate(beingDate);
  136. pdmReportIllegal.setReportEndDate(endDate);
  137. List<PdmReportIllegalWeek> illegalList = pdmReportIllegalWeekService.selectPdmReportIllegalWeekList(pdmReportIllegal);
  138. dataMap.put("illegalList",illegalList);//违章列表明细
  139. String typicalIllegal="";//其中典型违章通报如下
  140. dataMap.put("typicalIllegal",StringUtils.isEmpty(typicalIllegal)?"无":typicalIllegal);//其中典型违章通报如下
  141. //2.本周人员到岗到位履职情况
  142. dataMap.put("supervTimes",0);//督察共计次数
  143. dataMap.put("leaderSupervTimes",0);//领导督察共计次数
  144. dataMap.put("manageSupervTimes",0);//管理人员督察次数
  145. dataMap.put("problemNum",0);//督察发现问题
  146. dataMap.put("cityFindProblemNum",0);//市公司发现问题处数
  147. dataMap.put("derelictionDutyNum",0);//履职不到位(应查未查)
  148. //本周到岗到位履职情况
  149. PdmReportAppointmentWeek pdmReportAppointment = new PdmReportAppointmentWeek();
  150. pdmReportAppointment.setReportDate(beingDate);
  151. pdmReportAppointment.setReportEndDate(endDate);
  152. List<PdmReportAppointmentWeek> appointmentlist = pdmReportAppointmentWeekService.selectPdmReportAppointmentWeekList(pdmReportAppointment);
  153. dataMap.put("appointmentlist",appointmentlist);//本周到岗到位履职情况
  154. File descFile=null;
  155. try {
  156. String fileN = UUID.randomUUID().toString();
  157. File fileFold = new File(printReplenishmentPath+"/temp_print/");
  158. if(!fileFold.exists()){
  159. fileFold.mkdirs();
  160. }
  161. String fileDocPath = fileFold+"/"+fileN+".doc";
  162. GenerateWordUtil.generateWord(dataMap, "生产周例会配电汇报内容.ftl", new OutputStreamWriter(new FileOutputStream(new File(fileDocPath)), "utf-8"));
  163. descFile = new File(fileDocPath);
  164. String type = new MimetypesFileTypeMap().getContentType(descFile);
  165. response.setHeader("Content-type",type);
  166. String filename = new String(descFile.getName().getBytes("utf-8"), "iso-8859-1");
  167. response.setHeader("Content-Disposition", "attachment;filename=" + filename);
  168. response.setContentType("application/octet-stream");
  169. response.reset();
  170. OutputStream outputStream1 = response.getOutputStream();
  171. BufferedInputStream bis = null;
  172. bis = new BufferedInputStream(new FileInputStream(descFile));
  173. byte[] buff = new byte[bis.available()];
  174. bis.read(buff);
  175. outputStream1.write(buff);
  176. outputStream1.close();
  177. bis.close();
  178. } catch (Exception e) {
  179. e.printStackTrace();
  180. }finally {
  181. // if(descFile!=null)
  182. // descFile.deleteOnExit();
  183. }
  184. //下载之后删除
  185. try {
  186. if(descFile.exists()){
  187. descFile.delete();
  188. }
  189. } catch (Exception e) {
  190. e.printStackTrace();
  191. }
  192. }
  193. }