|
@@ -0,0 +1,209 @@
|
|
|
|
+package com.ruoyi.powerdistribution.controller;
|
|
|
|
+
|
|
|
|
+import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
+import com.ruoyi.common.utils.DateUtils;
|
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
|
|
+import com.ruoyi.common.utils.uuid.UUID;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.*;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.dto.PdmWorkPlanDTO;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.vo.SupRiskTeam;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.vo.TaskRiskPlan;
|
|
|
|
+import com.ruoyi.powerdistribution.domain.vo.ThreeLevelRiskJob;
|
|
|
|
+import com.ruoyi.powerdistribution.service.*;
|
|
|
|
+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/weklyReport")
|
|
|
|
+public class WeeklyReportController extends BaseController {
|
|
|
|
+
|
|
|
|
+ @Value("${printReplenishmentPath}")
|
|
|
|
+ private String printReplenishmentPath;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmReportIllegalWeekService pdmReportIllegalWeekService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmReportPlanNextWeekService pdmReportPlanNextWeekService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmWorkPlanService pdmWorkPlanService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmReportPlanNextDayService pdmReportPlanNextDayService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmReportPlanWeekService pdmReportPlanWeekService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IPdmReportAppointmentWeekService pdmReportAppointmentWeekService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @PostMapping("/export")
|
|
|
|
+ @ApiOperation(value = "周报导出")
|
|
|
|
+ public void export(HttpServletResponse response, String beingDate,String endDate) throws IOException, ParseException {
|
|
|
|
+ PdmReportIllegalDay pdmReportIllegalDay = new PdmReportIllegalDay();
|
|
|
|
+ pdmReportIllegalDay.setReportDate(beingDate);
|
|
|
|
+ Map<String,Object> dataMap = new HashMap();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ Date cvrtFirstDate = sdf.parse(beingDate);
|
|
|
|
+ Date cvrtEndDate = sdf.parse(endDate);
|
|
|
|
+
|
|
|
|
+ String month=new SimpleDateFormat("MM").format(cvrtFirstDate);
|
|
|
|
+ dataMap.put("beginDay",month+"月"+new SimpleDateFormat("dd").format(cvrtFirstDate)+"日");
|
|
|
|
+ dataMap.put("endDay",month+"月"+new SimpleDateFormat("dd").format(cvrtEndDate)+"日");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ dataMap.put("jobRecNum",0);
|
|
|
|
+ dataMap.put("weekPlanJobReNum",0);
|
|
|
|
+ dataMap.put("cancelRecNum",0);
|
|
|
|
+ dataMap.put("implRate",0);
|
|
|
|
+ dataMap.put("lowImplUnit","");
|
|
|
|
+ dataMap.put("lowImplRate","");
|
|
|
|
+ dataMap.put("tmpPlanRecNum",0);
|
|
|
|
+ dataMap.put("repairRecNum",0);
|
|
|
|
+ dataMap.put("operateRecNum",0);
|
|
|
|
+ dataMap.put("maintenanceNum",0);
|
|
|
|
+ dataMap.put("expanRelocationNum",0);
|
|
|
|
+ dataMap.put("networkReformNum",0);
|
|
|
|
+ dataMap.put("tmpPlanRate",0);
|
|
|
|
+ dataMap.put("cancelTmpPlanRecNum",0);
|
|
|
|
+ dataMap.put("tmpPlanImplRate",0);
|
|
|
|
+ PdmReportPlanWeek pdmReportPlan = new PdmReportPlanWeek();
|
|
|
|
+ pdmReportPlan.setReportDate(beingDate);
|
|
|
|
+ pdmReportPlan.setReportEndDate(endDate);
|
|
|
|
+ List<PdmReportPlanWeek> planlist = pdmReportPlanWeekService.selectPdmReportPlanWeekList(pdmReportPlan);
|
|
|
|
+ dataMap.put("planlist",planlist);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String nextMonday=DateUtils.getNextMonday(beingDate,"yyyyMMdd");
|
|
|
|
+ String nextSunday=DateUtils.getNextSunday(beingDate,"yyyyMMdd");
|
|
|
|
+ Date cvrtNextMonday = sdf.parse(nextMonday);
|
|
|
|
+ Date cvrtNextSunday = sdf.parse(nextSunday);
|
|
|
|
+ month=new SimpleDateFormat("MM").format(cvrtNextMonday);
|
|
|
|
+ dataMap.put("nextWeekBeginDay",month+"月"+new SimpleDateFormat("dd").format(cvrtNextMonday)+"日");
|
|
|
|
+ dataMap.put("nextWeekEndDay",month+"月"+new SimpleDateFormat("dd").format(cvrtNextSunday)+"日");
|
|
|
|
+ dataMap.put("nextWeekJobRecNum",0);
|
|
|
|
+ dataMap.put("nextWeekSwitchingNum",0);
|
|
|
|
+ dataMap.put("distribuNetworkEngineNum",0);
|
|
|
|
+ dataMap.put("nextWeekExpanRelocationNum",0);
|
|
|
|
+ dataMap.put("nextWeekMaintenanceNum",0);
|
|
|
|
+ dataMap.put("threeLevelRiskNum",0);
|
|
|
|
+ dataMap.put("fourLevelRiskNum",0);
|
|
|
|
+ dataMap.put("fiveLevelRiskNum",0);
|
|
|
|
+ dataMap.put("liveWorkingNum",0);
|
|
|
|
+ dataMap.put("liveDisconnectLeadNum",0);
|
|
|
|
+ dataMap.put("assemDeviceNum",0);
|
|
|
|
+
|
|
|
|
+ List<ThreeLevelRiskJob> threeLevelRiskJobs=new ArrayList<ThreeLevelRiskJob>() ;
|
|
|
|
+ StringBuilder builder=new StringBuilder();
|
|
|
|
+ for(int i=0;i<threeLevelRiskJobs.size();i++){
|
|
|
|
+ ThreeLevelRiskJob threeLevelRiskJob=threeLevelRiskJobs.get(i);
|
|
|
|
+ builder.append(threeLevelRiskJob.getCompName()).append(": ").append(threeLevelRiskJob.getJobDate()).append(",").append(threeLevelRiskJob.getJobContent()).append("。").append("\r\n");
|
|
|
|
+ }
|
|
|
|
+ dataMap.put(" threeLevelRiskJobs",StringUtils.isEmpty(builder.toString())?"无":builder.toString());
|
|
|
|
+
|
|
|
|
+ PdmWorkPlanDTO workPlan = new PdmWorkPlanDTO();
|
|
|
|
+ workPlan.setStartDate(nextMonday);
|
|
|
|
+ workPlan.setEndDate(nextSunday);
|
|
|
|
+ workPlan.setLevel3Flag("1");
|
|
|
|
+ List<PdmWorkPlan> workList = pdmWorkPlanService.selectPdmWorkPlanList(workPlan);
|
|
|
|
+ dataMap.put("threeLevelRiskWorkList",workList);
|
|
|
|
+ dataMap.put("fousMaintenanceNum",0);
|
|
|
|
+ String fousMaintenanceInfo="";
|
|
|
|
+ dataMap.put("fousMaintenanceInfo", StringUtils.isEmpty(fousMaintenanceInfo)?"无":fousMaintenanceInfo);
|
|
|
|
+
|
|
|
|
+ PdmReportPlanNextWeek next = new PdmReportPlanNextWeek();
|
|
|
|
+ next.setReportDate(nextMonday);
|
|
|
|
+ next.setReportEndDate(nextSunday);
|
|
|
|
+ List<PdmReportPlanNextWeek> nextList = pdmReportPlanNextWeekService.selectPdmReportPlanNextWeekList(next);
|
|
|
|
+ dataMap.put("nextWeekWorkList",nextList);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ dataMap.put("investPunishRecAllNum",0);
|
|
|
|
+ dataMap.put("provinceInvestPunishRecNum",0);
|
|
|
|
+ dataMap.put("cityInvestPunishRecNum",0);
|
|
|
|
+ dataMap.put("cityInvestSeriousRecNum",0);
|
|
|
|
+ dataMap.put("cityInvestGeneralRecNum",0);
|
|
|
|
+ dataMap.put("countyInvestPunishRecNum",0);
|
|
|
|
+ dataMap.put("countyInvestSeriousRecNum",0);
|
|
|
|
+ dataMap.put("countyInvestGeneralRecNum",0);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ PdmReportIllegalWeek pdmReportIllegal = new PdmReportIllegalWeek();
|
|
|
|
+ pdmReportIllegal.setReportDate(beingDate);
|
|
|
|
+ pdmReportIllegal.setReportEndDate(endDate);
|
|
|
|
+ List<PdmReportIllegalWeek> illegalList = pdmReportIllegalWeekService.selectPdmReportIllegalWeekList(pdmReportIllegal);
|
|
|
|
+ dataMap.put("illegalList",illegalList);
|
|
|
|
+ String typicalIllegal="";
|
|
|
|
+ dataMap.put("typicalIllegal",StringUtils.isEmpty(typicalIllegal)?"无":typicalIllegal);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ dataMap.put("supervTimes",0);
|
|
|
|
+ dataMap.put("leaderSupervTimes",0);
|
|
|
|
+ dataMap.put("manageSupervTimes",0);
|
|
|
|
+ dataMap.put("problemNum",0);
|
|
|
|
+ dataMap.put("cityFindProblemNum",0);
|
|
|
|
+ dataMap.put("derelictionDutyNum",0);
|
|
|
|
+
|
|
|
|
+ PdmReportAppointmentWeek pdmReportAppointment = new PdmReportAppointmentWeek();
|
|
|
|
+ pdmReportAppointment.setReportDate(beingDate);
|
|
|
|
+ pdmReportAppointment.setReportEndDate(endDate);
|
|
|
|
+ List<PdmReportAppointmentWeek> appointmentlist = pdmReportAppointmentWeekService.selectPdmReportAppointmentWeekList(pdmReportAppointment);
|
|
|
|
+ dataMap.put("appointmentlist",appointmentlist);
|
|
|
|
+
|
|
|
|
+ File descFile=null;
|
|
|
|
+ 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);
|
|
|
|
+ response.setContentType("application/octet-stream");
|
|
|
|
+ response.reset();
|
|
|
|
+ OutputStream outputStream1 = response.getOutputStream();
|
|
|
|
+ BufferedInputStream bis = null;
|
|
|
|
+ bis = new BufferedInputStream(new FileInputStream(descFile));
|
|
|
|
+ byte[] buff = new byte[bis.available()];
|
|
|
|
+ bis.read(buff);
|
|
|
|
+ outputStream1.write(buff);
|
|
|
|
+ outputStream1.close();
|
|
|
|
+ bis.close();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }finally {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ try {
|
|
|
|
+ if(descFile.exists()){
|
|
|
|
+ descFile.delete();
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|