|
@@ -0,0 +1,207 @@
|
|
|
|
+package com.ruoyi.powerdistribution.controller;
|
|
|
|
+
|
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
|
+import com.ruoyi.common.utils.uuid.UUID;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.PdmReportAppointmentDay;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.PdmReportIllegalDay;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.PdmReportPlanDay;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.PdmReportPlanNextDay;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.vo.SupRiskTeam;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.vo.TaskRiskPlan;
|
|
|
|
+import com.ruoyi.powerdistribution.service.IPdmReportAppointmentDayService;
|
|
|
|
+import com.ruoyi.powerdistribution.service.IPdmReportIllegalDayService;
|
|
|
|
+import com.ruoyi.powerdistribution.service.IPdmReportPlanDayService;
|
|
|
|
+import com.ruoyi.powerdistribution.service.IPdmReportPlanNextDayService;
|
|
|
|
+import com.ruoyi.powerdistribution.util.GenerateWordUtil;
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import javax.activation.MimetypesFileTypeMap;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import java.io.*;
|
|
|
|
+import java.text.ParseException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * 日报导出
|
|
|
|
+ */
|
|
|
|
+@RestController
|
|
|
|
+@RequestMapping("/power/dailyReport")
|
|
|
|
+public class DailyReportController extends BaseController {
|
|
|
|
+
|
|
|
|
+ @Value("${printReplenishmentPath}")
|
|
|
|
+ private String printReplenishmentPath;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmReportIllegalDayService pdmReportIllegalDayService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmReportPlanDayService pdmReportPlanDayService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmReportAppointmentDayService pdmReportAppointmentDayService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmReportPlanNextDayService pdmReportPlanNextDayService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping("/export")
|
|
|
|
+ @ApiOperation(value = "日报导出")
|
|
|
|
+ public void dayExport(HttpServletResponse response, String beingDate,String endDate) throws IOException, ParseException {
|
|
|
|
+ PdmReportIllegalDay pdmReportIllegalDay = new PdmReportIllegalDay();
|
|
|
|
+ pdmReportIllegalDay.setReportDate(beingDate);
|
|
|
|
+ Map<String,Object> dataMap = new HashMap();
|
|
|
|
+ dataMap.put("rptDate", DateUtils.dateTimeNow("yyyy年MM月dd日"));//日报生成日期
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ Date cvrtFirstDate = sdf.parse(beingDate);
|
|
|
|
+ Date cvrtEndDate = sdf.parse(endDate);
|
|
|
|
+ //日期公共使用
|
|
|
|
+ dataMap.put("month",new SimpleDateFormat("MM").format(cvrtFirstDate));//月
|
|
|
|
+ dataMap.put("beginDay",new SimpleDateFormat("dd").format(cvrtFirstDate));//开始日
|
|
|
|
+ dataMap.put("endDay",new SimpleDateFormat("dd").format(cvrtEndDate));//结束日
|
|
|
|
+ //1.违章查处情况
|
|
|
|
+ dataMap.put("provinceInvestPunishRecNum",0);//被省公司查处违章
|
|
|
|
+ dataMap.put("provinceInvestSeriousRecNum",0);//严重违章
|
|
|
|
+ dataMap.put("cityInvestPunishRecNum",0);//被市公司查处违章
|
|
|
|
+ dataMap.put("cityInvestSeriousRecNum",0);//严重违章
|
|
|
|
+ dataMap.put("countySelfInvestPunishRecNum",0);//县区公司自查处违章
|
|
|
|
+ dataMap.put("countySelfInvestSeriousRecNum",0);//严重违章
|
|
|
|
+ dataMap.put("guaraSelfIssuesRecNum",0);//保障体系自查问题
|
|
|
|
+ dataMap.put("guaraCityIssuesRecNum",0);//其中市公司查处问题
|
|
|
|
+ List<PdmReportIllegalDay> illegalList = pdmReportIllegalDayService.selectPdmReportIllegalDayList(pdmReportIllegalDay); File descFile=null;
|
|
|
|
+ long no=1;
|
|
|
|
+ for(PdmReportIllegalDay pdmReportIllegalDay2 : illegalList){
|
|
|
|
+ pdmReportIllegalDay2.setNo(no);
|
|
|
|
+ no++;
|
|
|
|
+ }
|
|
|
|
+ dataMap.put("illegalList",illegalList);//列表明细
|
|
|
|
+ //(二)作业计划执行情况
|
|
|
|
+ dataMap.put("jobRecNum",0);//发布作业信息条数
|
|
|
|
+ dataMap.put("exceRecNum",0);//已执行
|
|
|
|
+ dataMap.put("cancelRecNum",0);//已取消
|
|
|
|
+ dataMap.put("implementationRate",0);//执行率
|
|
|
|
+ dataMap.put("tmpPlanRecNum",0);//临时计划
|
|
|
|
+ dataMap.put("cancelTmpPlanRecNum",0);//取消计划数
|
|
|
|
+ dataMap.put("tmpPlanRate",0);//临时计划率
|
|
|
|
+ dataMap.put("repairRecNum",0);//已执行临时计划包含抢修
|
|
|
|
+ dataMap.put("operateRecNum",0);//操作条数
|
|
|
|
+ PdmReportPlanDay pdmReportPlanDay = new PdmReportPlanDay();
|
|
|
|
+ pdmReportPlanDay.setReportDate(beingDate);
|
|
|
|
+ List<PdmReportPlanDay> planlist = pdmReportPlanDayService.selectPdmReportPlanDayList(pdmReportPlanDay);
|
|
|
|
+ no=1;
|
|
|
|
+ for(PdmReportPlanDay pdmReportPlanDay2 : planlist){//表2.作业计划执行情况
|
|
|
|
+ pdmReportPlanDay2.setNo(no);
|
|
|
|
+ no++;
|
|
|
|
+ }
|
|
|
|
+ dataMap.put("planlist",planlist);//操作条数
|
|
|
|
+ //(三)人员到岗到位履职情况
|
|
|
|
+ dataMap.put("supervTimes",0);//督察共计次数
|
|
|
|
+ dataMap.put("leaderSupervTimes",0);//领导督察共计次数
|
|
|
|
+ dataMap.put("manageSupervTimes",0);//管理人员督察次数
|
|
|
|
+ dataMap.put("nonfulfilmentNum",0);//未履职(应查未查)现场
|
|
|
|
+ dataMap.put("derelictionDutyNum",0);//履职不到位
|
|
|
|
+ PdmReportAppointmentDay pdmReportAppointmentDay = new PdmReportAppointmentDay();
|
|
|
|
+ pdmReportAppointmentDay.setReportDate(beingDate);
|
|
|
|
+ List<PdmReportAppointmentDay> appointmentlist = pdmReportAppointmentDayService.selectPdmReportAppointmentDayList(pdmReportAppointmentDay);
|
|
|
|
+ no=1;
|
|
|
|
+ for(PdmReportAppointmentDay pdmReportAppointmentDay2 : appointmentlist){//表2.作业计划执行情况
|
|
|
|
+ pdmReportAppointmentDay2.setNo(no);
|
|
|
|
+ no++;
|
|
|
|
+ }
|
|
|
|
+ dataMap.put("appointmentlist",appointmentlist);//操作条数
|
|
|
|
+
|
|
|
|
+ //二、明日配网安全工作安排
|
|
|
|
+ dataMap.put("distNetworkProfesRecNum",0);//作业信息总共条数
|
|
|
|
+ dataMap.put("switchOperatNum",0);//倒闸操作操作项
|
|
|
|
+ dataMap.put("distNetworkProjectNum",0);//配网工程项
|
|
|
|
+ dataMap.put("expanRelocationNum",0);//业扩杆迁
|
|
|
|
+ dataMap.put("maintenanceNum",0);//运维检修
|
|
|
|
+ dataMap.put("other",0);//其他
|
|
|
|
+ dataMap.put("tempPlanNum",0);//临时计划共计
|
|
|
|
+ dataMap.put("operateNum",0);//操作项
|
|
|
|
+ dataMap.put("kv10Num",0);//10千伏作业
|
|
|
|
+ dataMap.put("zeroPointFourKvNum",0);//0.4千伏作业
|
|
|
|
+ dataMap.put("liveWorkingNum",0);//带电作业
|
|
|
|
+ dataMap.put("liveDisconnectLeadNum",0);//带电断接引
|
|
|
|
+ dataMap.put("assemDeviceNum",0);//带电消缺、装拆设备
|
|
|
|
+ dataMap.put("threeRiskNum",0);//三级风险作业
|
|
|
|
+ dataMap.put("fourRiskNum",0);//四级风险作业
|
|
|
|
+ dataMap.put("fiveRiskNum",0);//五级风险作业
|
|
|
|
+ dataMap.put("liftingOperationNum",0);//起重作业
|
|
|
|
+ dataMap.put("verticalPoleNum",0);//立杆
|
|
|
|
+ dataMap.put("chgeDeviceNum",0);//更换配变、综配箱等设备
|
|
|
|
+ dataMap.put("keyAssignments",0);//重点作业面
|
|
|
|
+
|
|
|
|
+ PdmReportPlanNextDay nextDay = new PdmReportPlanNextDay();
|
|
|
|
+ nextDay.setReportDate(DateUtils.getNextDateStr(beingDate,DateUtils.YYYYMMDD,1));
|
|
|
|
+ List<PdmReportPlanNextDay> nextDayList = pdmReportPlanNextDayService.selectPdmReportPlanNextDayList(nextDay);
|
|
|
|
+ no=1;
|
|
|
|
+ for(PdmReportPlanNextDay pdmReportPlanNextDay2 : nextDayList){//表5.明日作业计划安排情况
|
|
|
|
+ pdmReportPlanNextDay2.setNo(no);
|
|
|
|
+ no++;
|
|
|
|
+ }
|
|
|
|
+ dataMap.put("nextDayList",nextDayList);//
|
|
|
|
+ //(二)“七分准备”及承载力审查情况
|
|
|
|
+ List<String> morrowExistSupRiskCompList=new ArrayList<>(); //存放次日存在超管理承载力风险的单位数据
|
|
|
|
+ dataMap.put("morrowExistSupRiskComp",morrowExistSupRiskCompList==null||morrowExistSupRiskCompList.size()==0?"无":String.join(",",morrowExistSupRiskCompList));//次日存在超管理承载力风险的单位
|
|
|
|
+
|
|
|
|
+ List<SupRiskTeam> supRiskTeamList=new ArrayList<>(); //存放次日存在超作业承载力风险的班组
|
|
|
|
+ StringBuilder builder=new StringBuilder();
|
|
|
|
+ for(int i=0;i<supRiskTeamList.size();i++){
|
|
|
|
+ SupRiskTeam supRiskTeam=supRiskTeamList.get(i);
|
|
|
|
+ builder.append((i+1)).append(".").append(supRiskTeam.getTeamName()).append(":").append(String.join(",",supRiskTeam.getHandlingMatters())).append("\r\n");
|
|
|
|
+ }
|
|
|
|
+ dataMap.put("supRiskTeam",supRiskTeamList==null||supRiskTeamList.size()==0?"无":builder.toString());//次日存在超作业承载力风险的班组
|
|
|
|
+ //(三)人员到岗到位履职安排
|
|
|
|
+ SimpleDateFormat formatter = new SimpleDateFormat("MM月dd日");
|
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ dataMap.put("tomorrow",formatter.format(format.parse(DateUtils.getNextDateStr(endDate,"yyyyMMdd",1))));//获取明天的日期
|
|
|
|
+ List<TaskRiskPlan> taskRiskPlanList=new ArrayList<>(); //获取风险作业计划数据
|
|
|
|
+ dataMap.put("cityThreeRiskPlanNum",taskRiskPlanList==null?0:taskRiskPlanList.size());//全市三级作业风险计划
|
|
|
|
+ StringBuilder riskPlanBuilder=new StringBuilder();
|
|
|
|
+ for(int i=0;i<taskRiskPlanList.size();i++){
|
|
|
|
+ TaskRiskPlan taskRiskPlan=taskRiskPlanList.get(i);
|
|
|
|
+ riskPlanBuilder.append((i+1)).append(".").append(taskRiskPlan.getCompName()).append(":").append(String.join(",",taskRiskPlan.getHandlingMatters())).append(taskRiskPlan.getLeader()).append(".")
|
|
|
|
+ .append("把关领导:").append("\r\n")
|
|
|
|
+ ;
|
|
|
|
+ }
|
|
|
|
+ dataMap.put("cityThreeRiskPlan",taskRiskPlanList==null||taskRiskPlanList.size()==0?"无":riskPlanBuilder.toString());//全市三级作业风险计划
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ String fileN = UUID.randomUUID().toString();
|
|
|
|
+ File fileFold = new File(printReplenishmentPath+"/temp_print/");
|
|
|
|
+ if(!fileFold.exists()){
|
|
|
|
+ fileFold.mkdirs();
|
|
|
|
+ }
|
|
|
|
+ String fileDocPath = fileFold+"/"+fileN+".doc";
|
|
|
|
+ GenerateWordUtil.generateWord(dataMap, "衡阳公司配电专业安全管控专班日报.ftl", new OutputStreamWriter(new FileOutputStream(new File(fileDocPath)), "utf-8"));
|
|
|
|
+ descFile = new File(fileDocPath);
|
|
|
|
+ String type = new MimetypesFileTypeMap().getContentType(descFile);
|
|
|
|
+ response.setHeader("Content-type",type);
|
|
|
|
+ String filename = new String(descFile.getName().getBytes("utf-8"), "iso-8859-1");
|
|
|
|
+ response.setHeader("Content-Disposition", "attachment;filename=" + filename);
|
|
|
|
+ //输出pdf流
|
|
|
|
+ OutputStream outputStream1 = response.getOutputStream();
|
|
|
|
+ byte[] buff = new byte[1024];
|
|
|
|
+ BufferedInputStream bis = null;
|
|
|
|
+ bis = new BufferedInputStream(new FileInputStream(descFile));
|
|
|
|
+ int i = bis.read(buff);
|
|
|
|
+ while (i != -1) {
|
|
|
|
+ outputStream1.write(buff, 0, buff.length);
|
|
|
|
+ outputStream1.flush();
|
|
|
|
+ i = bis.read(buff);
|
|
|
|
+ }
|
|
|
|
+ outputStream1.close();
|
|
|
|
+ bis.close();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }finally {
|
|
|
|
+ if(descFile!=null)
|
|
|
|
+ descFile.deleteOnExit();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|