| | |
| | | package cn.gistack.sm.sjztmd.feign; |
| | | |
| | | import cn.gistack.alerts.sms.feign.ISmsRecordClient; |
| | | import cn.gistack.alerts.sms.vo.SmsResultVO; |
| | | import cn.gistack.resource.feign.IOssClient; |
| | | import cn.gistack.resource.vo.MyMultipartFile; |
| | | import cn.gistack.sm.intelligentCall.service.CallService; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskResultVO; |
| | | import cn.gistack.sm.sjztmd.entity.AttResBase; |
| | | import cn.gistack.sm.sjztmd.entity.YwFloodReportInfo; |
| | | import cn.gistack.sm.sjztmd.feign.IAttResBaseClient; |
| | | import cn.gistack.sm.sjztmd.feign.ISjztMdClient; |
| | | import cn.gistack.sm.sjztmd.service.IAttResBaseService; |
| | | import cn.gistack.sm.sjztmd.service.ITbProjectService; |
| | | 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.WordUtil; |
| | | import cn.gistack.sm.sjztmd.word.vo.DzkInfo; |
| | | import cn.gistack.sm.sjztmd.word.vo.OverDetail; |
| | | import cn.gistack.sm.sjztmd.word.vo.SzInfo; |
| | | import cn.gistack.sm.sjztmd.word.vo.TotalInfo; |
| | | import cn.gistack.sm.sjztmd.word.vo.*; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springblade.core.redis.cache.BladeRedis; |
| | | import org.springblade.core.tenant.annotation.NonDS; |
| | | import org.springframework.core.io.InputStreamResource; |
| | | import org.springframework.http.MediaType; |
| | |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.text.ParseException; |
| | | 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 IOssClient ossClient; |
| | | |
| | | private final ISmsRecordClient smsRecordClient; |
| | | |
| | | private final CallService callService; |
| | | |
| | | private final ITbProjectService tbProjectService; |
| | | |
| | | private final IYwFloodReportInfoService ywFloodReportInfoService; |
| | | |
| | | @Override |
| | | public String saveYesterdayFloodReportContent(String isShow) throws Exception { |
| | | //获取总览、大中库、明细数据 |
| | | List<TotalInfo> totalList = sjztmdService.getTotalInfo(isShow); |
| | | OverWord overWord = WordUtil.GetOverInfo(totalList); |
| | | // bladeRedis.set("yesterDayFloodReport-totalinfo",overWord.getTotalInfo()); |
| | | // bladeRedis.set("yesterDayFloodReport-oversmallinfo",overWord.getOverSmallInfo()); |
| | | YwFloodReportInfo info = new YwFloodReportInfo(); |
| | | info.setCreateTime(new Date()); |
| | | info.setTotalInfo(overWord.getTotalInfo()); |
| | | info.setOversmallInfo(overWord.getOverSmallInfo()); |
| | | ywFloodReportInfoService.save(info); |
| | | return "保存昨日报汛内容"; |
| | | } |
| | | |
| | | @Override |
| | | @GetMapping(GENERATE_DAY_REPORT_FLOOD) |
| | | public String generateDayReportFlood(String isShow) throws Exception{ |
| | | |
| | | public String generateDayReportFlood(String isShow) throws Exception { |
| | | |
| | | |
| | | //获取总览、大中库、明细数据 |
| | |
| | | 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"); |
| | | 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); |
| | | |
| | | } |
| | | // 创建响应实体并设置响应头,将输出流作为响应体返回给客户端 |
| | | // InputStreamResource resource = new InputStreamResource(new ByteArrayInputStream(data)); |
| | | String time = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); |
| | | String fileName = time + "全省水库防汛情况.docx"; |
| | | MultipartFile file = new MyMultipartFile("file",fileName, "text/plain", data); |
| | | MultipartFile file = new MyMultipartFile("file", fileName, "text/plain", data); |
| | | String path = ossClient.uploadFile(fileName, file); |
| | | return path; |
| | | } |
| | | |
| | | private void createFile(String filePath,byte[] bytes){ |
| | | @Override |
| | | @GetMapping(ISjztMdClient.GET_RESERVOIR_RAINFALL_FORECAST) |
| | | public void getReservoirRainfallForecast(List<String> dayIndexList) { |
| | | sjztmdService.getReservoirRainfallForecast(dayIndexList); |
| | | } |
| | | |
| | | @Override |
| | | @GetMapping(ISjztMdClient.GET_PROJECT_CHECK_STATUS) |
| | | public void setGetProjectCheckStatus() throws Exception { |
| | | tbProjectService.updateallcheck(); |
| | | } |
| | | |
| | | private void createFile(String filePath, byte[] bytes) { |
| | | // 将byte[]写入文件 |
| | | try (FileOutputStream fos = new FileOutputStream(filePath)) { |
| | | fos.write(bytes); |