| | |
| | | package cn.gistack.sm.sjztmd.word.controller; |
| | | |
| | | |
| | | |
| | | import cn.gistack.alerts.sms.feign.ISmsRecordClient; |
| | | import cn.gistack.alerts.sms.vo.SmsResultVO; |
| | | import cn.gistack.sm.intelligentCall.service.CallService; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskResultVO; |
| | | import cn.gistack.sm.sjztmd.entity.YwFloodReportInfo; |
| | | import cn.gistack.sm.sjztmd.service.IYwFloodReportInfoService; |
| | | import cn.gistack.sm.sjztmd.util.MyDateUtils; |
| | | import cn.gistack.sm.sjztmd.word.service.ISjztmdService; |
| | | import cn.gistack.sm.sjztmd.word.util.BriefReportUtil; |
| | | import cn.gistack.sm.sjztmd.word.util.ExcelUtil; |
| | | import cn.gistack.sm.sjztmd.word.util.WordUtil; |
| | | import cn.gistack.sm.sjztmd.word.vo.*; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import io.swagger.annotations.Api; |
| | | import lombok.AllArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.utils.DateUtil; |
| | | import org.springframework.core.io.InputStreamResource; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.http.ResponseEntity; |
| | |
| | | import java.io.*; |
| | | import java.net.URLEncoder; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | |
| | | |
| | | private final ISjztmdService sjztmdService; |
| | | |
| | | private final ISmsRecordClient smsRecordClient; |
| | | |
| | | private final CallService callService; |
| | | |
| | | private final IYwFloodReportInfoService ywFloodReportInfoService; |
| | | |
| | | @GetMapping(value = "/getBriefReport") |
| | | public R getBriefReport() { |
| | | //获取总览、大中库、明细数据 |
| | |
| | | |
| | | @GetMapping("/download/{resGuid}") |
| | | public ResponseEntity genera(HttpServletResponse response, @PathVariable String resGuid) throws Exception { |
| | | HashMap<String,Object> obj = sjztmdService.getTbWordVO(resGuid); |
| | | HashMap<String, Object> obj = sjztmdService.getTbWordVO(resGuid); |
| | | |
| | | TbWordVO tbWordVO = (TbWordVO) obj.get("tbWordVO"); |
| | | Map<String,Object> tableMap= (Map<String, Object>) obj.get("tableMap"); |
| | | Map<String, Object> tableMap = (Map<String, Object>) obj.get("tableMap"); |
| | | |
| | | String fileName = resGuid + ".docx"; |
| | | byte[] data = WordUtil.compileTemplateAndRenderData(tbWordVO,tableMap); |
| | | byte[] data = WordUtil.compileTemplateAndRenderData(tbWordVO, tableMap); |
| | | |
| | | // 创建响应实体并设置响应头,将输出流作为响应体返回给客户端 |
| | | InputStreamResource resource = new InputStreamResource(new ByteArrayInputStream(data)); |
| | |
| | | } |
| | | |
| | | @GetMapping("/download/overFloodInfo") |
| | | public ResponseEntity overFloodInfo(String isShow) throws Exception{ |
| | | public ResponseEntity overFloodInfo(String isShow) throws Exception { |
| | | String time = new SimpleDateFormat("yyyy日MM月dd日HH时").format(new Date()); |
| | | String fileName = time+ "报汛文件.docx"; |
| | | String fileName = time + "报汛文件.docx"; |
| | | String fileNameURL = URLEncoder.encode(fileName, "UTF-8"); |
| | | //获取总览、大中库、明细数据 |
| | | List<TotalInfo> totalList = sjztmdService.getTotalInfo(isShow); |
| | |
| | | List<OverDetail> overDetailList = sjztmdService.getOverDetailInfo(isShow); |
| | | List<SzInfo> szInfoList = sjztmdService.getSzInfo(isShow); |
| | | |
| | | HashMap<String,String> over10Params = new HashMap<>(); |
| | | //短信预警数量 |
| | | SmsResultVO vo = new SmsResultVO(); |
| | | // 获取当前日期 |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | // 获取前一天日期 |
| | | LocalDateTime oneDayBefore = now.minusDays(1); |
| | | // 格式化日期并打印 |
| | | // 定义日期时间格式,包含年-月-日 时:分:秒 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | vo.setStartTime(oneDayBefore.format(formatter)); |
| | | vo.setEndTime(now.format(formatter)); |
| | | vo.setSmsType("2"); |
| | | vo.setResCode("0"); |
| | | vo.setIsExport(1); |
| | | List<SmsResultVO> dxyjList = smsRecordClient.smsSuccessList(vo); |
| | | |
| | | //外呼统计 |
| | | DateTimeFormatter formatter2 = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | CallTaskResultVO callTaskResult = new CallTaskResultVO(); |
| | | callTaskResult.setStartTime(oneDayBefore.format(formatter2)); |
| | | callTaskResult.setEndTime(now.format(formatter2)); |
| | | List<CallTaskResultVO> whtjList = (List<CallTaskResultVO>) callService.getCallResultListTemp(null, callTaskResult); |
| | | |
| | | HashMap<String, String> over10Params = new HashMap<>(); |
| | | //small_start_stag=0&small_end_stag=2&mid_start_stag=0&mid_end_stag=2&big_start_stag=0&big_end_stag=2 |
| | | over10Params.put("small_start_stag", "0.1"); |
| | | over10Params.put("mid_start_stag", "0.1"); |
| | | over10Params.put("big_start_stag", "0.1"); |
| | | |
| | | HashMap<String,String> normalParams = new HashMap<>(); |
| | | HashMap<String, String> normalParams = new HashMap<>(); |
| | | //small_start_stag=0&small_end_stag=2&mid_start_stag=0&mid_end_stag=2&big_start_stag=0&big_end_stag=2 |
| | | normalParams.put("small_start_stag", "0"); |
| | | normalParams.put("mid_start_stag", "0"); |
| | | normalParams.put("big_start_stag", "0"); |
| | | |
| | | |
| | | List<TotalInfo> totalOverList = sjztmdService.getTotalOverInfo(isShow,normalParams); |
| | | List<TotalInfo> totalOver10List = sjztmdService.getTotalOverInfo(isShow,over10Params); |
| | | byte[] data = null; |
| | | if (MyDateUtils.isTodayInFloodSeason()){ |
| | | data = WordUtil.GetOverInfo(totalList,dzkList,overDetailList,szInfoList); |
| | | }else { |
| | | data= WordUtil.GetNotInSeasonOverInfo(totalList,dzkList,overDetailList,szInfoList,totalOverList,totalOver10List); |
| | | List<TotalInfo> totalOverList = sjztmdService.getTotalOverInfo(isShow, normalParams); |
| | | List<TotalInfo> totalOver10List = sjztmdService.getTotalOverInfo(isShow, over10Params); |
| | | |
| | | //昨日报汛内容 |
| | | YwFloodReportInfo ywFloodReportInfo = ywFloodReportInfoService.getLatestReport(oneDayBefore.format(formatter2)); |
| | | |
| | | byte[] data = null; |
| | | if (MyDateUtils.isTodayInFloodSeason()) { |
| | | data = WordUtil.GetOverInfo(totalList, dzkList, overDetailList, szInfoList, dxyjList, whtjList, ywFloodReportInfo); |
| | | } else { |
| | | data = WordUtil.GetNotInSeasonOverInfo(totalList, dzkList, overDetailList, szInfoList, totalOverList, totalOver10List); |
| | | |
| | | } |
| | | // 创建响应实体并设置响应头,将输出流作为响应体返回给客户端 |
| | |
| | | } |
| | | |
| | | @GetMapping("/download/getOverFloodInfoExcel") |
| | | public void getOverFloodInfoExcel(HttpServletResponse response,String isShow) throws Exception { |
| | | public void getOverFloodInfoExcel(HttpServletResponse response, String isShow) throws Exception { |
| | | |
| | | //获取总览、大中库、明细数据 |
| | | List<TotalInfo> totalList = sjztmdService.getTotalInfo(isShow); |
| | | List<DzkInfo> dzkList = sjztmdService.getDzkInfo(isShow); |
| | | List<OverDetail> overDetailList = sjztmdService.getOverDetailInfo(isShow); |
| | | |
| | | ExcelUtil.generateExcel(response,totalList,dzkList,overDetailList); |
| | | ExcelUtil.generateExcel(response, totalList, dzkList, overDetailList); |
| | | } |
| | | |
| | | } |