From 9cd3023ef6a51d986ce7d123159a0de2600e3cea Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 4 Mar 2022 09:41:17 +0800 Subject: [PATCH 1/4] temp --- .../tools/constant/DingDingRobotConstant.java | 11 ++ .../tools/utils/HttpClientManager.java | 1 + .../data-aggregator-server/pom.xml | 6 + .../controller/GovOrgController.java | 12 +- .../dataaggre/excel/GridLivelyExcel.java | 19 +++- .../service/govorg/GovOrgService.java | 6 + .../govorg/impl/GovOrgServiceImpl.java | 106 ++++++++++++++++++ 7 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java new file mode 100644 index 0000000000..e4c3bd0467 --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/DingDingRobotConstant.java @@ -0,0 +1,11 @@ +package com.epmet.commons.tools.constant; + +public interface DingDingRobotConstant { + String YZM_TEST_URL="https://oapi.dingtalk.com/robot/send?access_token=249c5f49006cf14b37f9c3bc502ede34c16926a5ac5a0deeb9c9b4be735c0daf"; + String YZM_TEST_SECRET="SECa03f447d67c62d924b5ae52dd9a7ddd9147d32c1d43f8cb43449f505444bdc6b"; + /** + * EPMET V3 产品研发 + */ + String V3_ROBOT_URL="https://oapi.dingtalk.com/robot/send?access_token=75e9ab857536f3018baa09009646876edbd263d07521a1a22eedfc3852623614"; + String V3_ROBOT_SECRET="SECdc8d3fb6780faa919f38fd43783f76d111255036c3b5bdcbc086dff023ee84d5"; +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java index 048745cfb6..ce4b79cb1e 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/HttpClientManager.java @@ -305,6 +305,7 @@ public class HttpClientManager { */ public Result sendAlarmMsg(String content) { Long timestamp = System.currentTimeMillis(); + //生产环境报警群:重要消息通知 String url = "https://oapi.dingtalk.com/robot/send?access_token=c40055ed85e45fdaafea00f3218928794262ff15163e09ad5c89764433b69806"; String secret = "SEC220eafdcb39ab5dd6cffa9f11b0e5de7178ddac9812d40fdceb6b1dda2963186"; diff --git a/epmet-module/data-aggregator/data-aggregator-server/pom.xml b/epmet-module/data-aggregator/data-aggregator-server/pom.xml index f05b85d745..51d95b3aa9 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/pom.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/pom.xml @@ -110,6 +110,12 @@ --> + + com.epmet + epmet-oss-client + 2.0.0 + compile + diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java index a0f7bafdbb..c1b2b0e98a 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/GovOrgController.java @@ -27,7 +27,6 @@ import com.epmet.dataaggre.entity.govorg.CustomerAgencyEntity; import com.epmet.dataaggre.enums.GridMemberDataAnalysisEnums; import com.epmet.dataaggre.service.AggreGridService; import com.epmet.dataaggre.service.govorg.GovOrgService; -import com.epmet.dto.form.patrol.PcworkRecordListFormDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -402,4 +401,15 @@ public class GovOrgController { govOrgService.grdiLivelyExport(response, formDTO); } + /** + * 定时任务调用本方法,查询网格活跃度统计结果,生成excel,上传oss.发送钉钉excel. + * @param formDTO + * @return + */ + @PostMapping("export-send-msg") + public Result pcworkRecordListExportSendMsg(@RequestBody GridLivelyFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, GridLivelyFormDTO.Grid.class); + govOrgService.pcworkRecordListExportSendMsg(formDTO); + return new Result(); + } } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java index 655675326f..331511dbe6 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/GridLivelyExcel.java @@ -29,40 +29,57 @@ import lombok.Data; */ @Data public class GridLivelyExcel { - @ExcelProperty("组织ID") @ExcelIgnore private String agencyId; //组织名称 + @Excel(name = "组织名称",width = 15) @ExcelProperty("组织名称") @ColumnWidth(15) private String agencyName; + //组织下所有网格总数 + @Excel(name = "网格总数",width = 15) @ExcelProperty("网格总数") @ColumnWidth(15) private Integer gridSumNum; + //活跃网格数 + @Excel(name = "活跃网格数",width = 15) @ExcelProperty("活跃网格数") @ColumnWidth(15) private Integer gridLivelyNum; + + //活跃网格数占比 + @Excel(name = "活跃网格数占比",width = 15) @ExcelProperty("活跃网格数占比") @ColumnWidth(15) private String gridLivelyRatio; + //正常运行网格数 + @Excel(name = "正常运行网格数",width = 15) @ExcelProperty("正常运行网格数") @ColumnWidth(15) private Integer gridOrdinaryNum; + + //正常运行网格数占比 + @Excel(name = "正常运行网格数占比",width = 15) @ExcelProperty("正常运行网格数占比") @ColumnWidth(15) private String gridOrdinaryRatio; + //僵尸网格数 + @Excel(name = "僵尸网格数",width = 15) @ExcelProperty("僵尸网格数") @ColumnWidth(15) private Integer gridLazyNum; + + //僵尸网格数占比 + @Excel(name = "僵尸网格数占比",width = 15) @ExcelProperty("僵尸网格数占比") @ColumnWidth(15) private String gridLazyRatio; diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java index d81af9c6f7..51d938bb2e 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/GovOrgService.java @@ -182,4 +182,10 @@ public interface GovOrgService { * @Description 查询组织的直属下级组织下网格活跃度统计--文件导出 **/ void grdiLivelyExport(HttpServletResponse response, GridLivelyFormDTO formDTO); + + /** + * @Author sun + * @Description 查询组织的直属下级组织下网格活跃度统计--文件导出 + **/ + void pcworkRecordListExportSendMsg(GridLivelyFormDTO formDTO); } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 4fc3cb4f81..bb8756f80c 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -1,18 +1,26 @@ package com.epmet.dataaggre.service.govorg.impl; +import cn.afterturn.easypoi.excel.ExcelExportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.fastjson.JSON; +import com.dingtalk.api.request.OapiRobotSendRequest; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.DingDingRobotConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; import com.epmet.dataaggre.constant.DataSourceConstant; import com.epmet.dataaggre.dao.govorg.*; import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO; @@ -28,13 +36,23 @@ import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.service.epmetuser.EpmetUserService; import com.epmet.dataaggre.service.govorg.GovOrgService; import com.epmet.dataaggre.service.opercrm.CustomerRelation; +import com.epmet.dto.result.UploadImgResultDTO; +import com.epmet.feign.OssFeignClient; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.fileupload.FileItem; +import org.apache.commons.fileupload.FileItemFactory; +import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.lang3.StringUtils; +import org.apache.http.entity.ContentType; +import org.apache.poi.ss.usermodel.Workbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.web.multipart.commons.CommonsMultipartFile; import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.OutputStream; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.*; @@ -67,6 +85,8 @@ public class GovOrgServiceImpl implements GovOrgService { private EpmetUserService epmetUserService; @Autowired private DataStatsService dataStatsService; + @Autowired + private OssFeignClient ossFeignClient; /** * @param staffId @@ -690,4 +710,90 @@ public class GovOrgServiceImpl implements GovOrgService { return name.toString(); } + /** + * @Author sun + * @Description 查询组织的直属下级组织下网格活跃度统计--文件导出 + **/ + @Override + public void pcworkRecordListExportSendMsg(GridLivelyFormDTO formDTO) { + List data = ConvertUtils.sourceToTarget(grdiLively(formDTO), GridLivelyExcel.class); + if(CollectionUtils.isEmpty(data)){ + log.warn(String.format("网格员活跃度统计数据查询为空,入参【%s】", JSON.toJSONString(formDTO))); + return; + } + ExportParams exportParams = new ExportParams(); + String sheetName = excelSheetName(formDTO); + exportParams.setSheetName(sheetName); + Workbook workbook = ExcelExportUtil.exportExcel(exportParams, + GridLivelyExcel.class, data); + + // 文件名 + String resultDescFileName = sheetName.concat(".xls"); + + FileItemFactory factory = new DiskFileItemFactory(16, null); + FileItem fileItem = factory.createItem("file", ContentType.APPLICATION_OCTET_STREAM.toString(), true, resultDescFileName); + OutputStream os = null; + Result uploadResult = null; + try { + os = fileItem.getOutputStream(); + workbook.write(os); + uploadResult = ossFeignClient.uploadImportTaskDescFile(new CommonsMultipartFile(fileItem)); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.warn("【网格活跃度统计】上传错误描述文件异常:{}", errormsg); + } finally { + try { + os.close(); + } catch (IOException e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.warn("【网格活跃度统计】上传错误描述文件关闭输出流:{}", errormsg); + } + try { + fileItem.delete(); + } catch (Exception e) { + String errormsg = ExceptionUtils.getErrorStackTrace(e); + log.warn("【网格活跃度统计】上传错误描述文件删除临时文件:{}", errormsg); + } + } + log.warn(String.format("网格员活跃度统计数据查询为空,返参【%s】", JSON.toJSONString(uploadResult))); + if (uploadResult == null || !uploadResult.success()) { + log.warn("【网格活跃度统计】调用OSS上传结果描述文件失败"); + } else { + //EPMETV3群机器人 + // String secret = DingDingRobotConstant.V3_ROBOT_SECRET; + // String url = DingDingRobotConstant.V3_ROBOT_URL; + String secret = DingDingRobotConstant.YZM_TEST_SECRET; + String url = DingDingRobotConstant.YZM_TEST_URL; + + OapiRobotSendRequest request = new OapiRobotSendRequest(); + //MarkDown方式发送 + request.setMsgtype("markdown"); + OapiRobotSendRequest.Markdown markdown = new OapiRobotSendRequest.Markdown(); + markdown.setTitle("网格活跃度统计"); + markdown.setText("网格活跃度统计: \n" + + "> 起止时间: " + formDTO.getStartTime().concat(StrConstant.UNDER_LINE).concat(formDTO.getEndTime()) + "\n\n" + + "> 文件下载地址: " + uploadResult.getData().getUrl() + "\n\n"); + request.setMarkdown(markdown); + + //小雷哥手机号:18660295251 + OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); + at.setAtMobiles(Arrays.asList("15764229697")); + at.setIsAtAll(true); + request.setAt(at); + + /*//文本方式发送 + request.setMsgtype("text"); + OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text(); + text.setContent("网格活跃度统计: \n" + + "起止时间: " + formDTO.getStartTime().concat(StrConstant.UNDER_LINE).concat(formDTO.getEndTime()) + "\n" + + "文件下载地址: " + uploadResult.getData().getUrl() + "\n\n"); + request.setText(text);*/ + + + log.info("发送钉钉消息入参:"+JSON.toJSONString(request,true)); + HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(request), url, secret); + } + } + + } From cbd729d9dd12bbe4b7df14645cb160b09a58b3b9 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 4 Mar 2022 12:54:39 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=B4=BB=E8=B7=83=E5=BA=A6=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E4=B8=8A=E4=BC=A0oss=E5=8F=91=E9=92=89=E9=92=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../govorg/impl/GovOrgServiceImpl.java | 10 ++--- .../epmet-job/epmet-job-server/pom.xml | 6 +++ .../com/epmet/controller/DemoController.java | 26 +++++++++++-- .../feign/DataAggregatorFeignClient.java | 24 ++++++++++++ ...gatorFeignClientClientFallBackFactory.java | 23 +++++++++++ .../com/epmet/task/ExportGridLiveResTask.java | 39 +++++++++++++++++++ 6 files changed, 120 insertions(+), 8 deletions(-) create mode 100644 epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/DataAggregatorFeignClient.java create mode 100644 epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/DataAggregatorFeignClientClientFallBackFactory.java create mode 100644 epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index c460665cf5..861df6da98 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -761,15 +761,15 @@ public class GovOrgServiceImpl implements GovOrgService { log.warn("【网格活跃度统计】调用OSS上传结果描述文件失败"); } else { //EPMETV3群机器人 - // String secret = DingDingRobotConstant.V3_ROBOT_SECRET; - // String url = DingDingRobotConstant.V3_ROBOT_URL; - String secret = DingDingRobotConstant.YZM_TEST_SECRET; - String url = DingDingRobotConstant.YZM_TEST_URL; + String secret = DingDingRobotConstant.V3_ROBOT_SECRET; + String url = DingDingRobotConstant.V3_ROBOT_URL; + // String secret = DingDingRobotConstant.YZM_TEST_SECRET; + // String url = DingDingRobotConstant.YZM_TEST_URL; DingTextBriefNessFormDTO dingTalkTextMsg=new DingTextBriefNessFormDTO(); dingTalkTextMsg.setMsgtype("text"); - //小雷哥手机号:18660295251 + //小雷哥手机号:18660295251, OapiRobotSendRequest.At at = new OapiRobotSendRequest.At(); at.setAtMobiles(Arrays.asList("18660295251","15764229697")); at.setIsAtAll(false); diff --git a/epmet-module/epmet-job/epmet-job-server/pom.xml b/epmet-module/epmet-job/epmet-job-server/pom.xml index f772b6134b..80377c1fba 100644 --- a/epmet-module/epmet-job/epmet-job-server/pom.xml +++ b/epmet-module/epmet-job/epmet-job-server/pom.xml @@ -102,6 +102,12 @@ 2.0.0 compile + + com.epmet + data-aggregator-client + 2.0.0 + compile + diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java index 6bb9718720..ace6b473bc 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/controller/DemoController.java @@ -8,12 +8,16 @@ package com.epmet.controller; +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; +import com.epmet.feign.DataAggregatorFeignClient; import com.epmet.feign.DataStatisticalOpenFeignClient; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; /** * 定时任务 @@ -27,6 +31,8 @@ public class DemoController { @Autowired private DataStatisticalOpenFeignClient client; + @Autowired + private DataAggregatorFeignClient dataAggregatorFeignClient; @GetMapping("testAlarm") public void testAlarm() { @@ -35,4 +41,18 @@ public class DemoController { //} client.agencyGridIssueStats(null); } + + + @PostMapping("exportGridLiveRes") + public Result exportGridLiveRes(@RequestParam("params") String params) { + if(StringUtils.isBlank(params)){ + return new Result(); + } + GridLivelyFormDTO formDTO = new GridLivelyFormDTO(); + if (StringUtils.isNotBlank(params)) { + formDTO = JSON.parseObject(params, GridLivelyFormDTO.class); + } + ValidatorUtils.validateEntity(formDTO,GridLivelyFormDTO.Grid.class); + return dataAggregatorFeignClient.exportGridLiveRes(formDTO); + } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/DataAggregatorFeignClient.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/DataAggregatorFeignClient.java new file mode 100644 index 0000000000..46976ad07d --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/DataAggregatorFeignClient.java @@ -0,0 +1,24 @@ +package com.epmet.feign; + + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; +import com.epmet.feign.impl.DataAggregatorFeignClientClientFallBackFactory; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +@FeignClient(name = ServiceConstant.DATA_AGGREGATOR_SERVER, fallback = DataAggregatorFeignClientClientFallBackFactory.class) +// @FeignClient(name = ServiceConstant.DATA_AGGREGATOR_SERVER, fallback= DataAggregatorFeignClientClientFallBackFactory.class,url = "localhost:8114") +public interface DataAggregatorFeignClient { + + /** + * 定时任务导出网格活跃统计表 + * @param form + * @return + */ + @PostMapping(value = "data/aggregator/org/export-send-msg") + Result exportGridLiveRes(@RequestBody GridLivelyFormDTO form); + +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/DataAggregatorFeignClientClientFallBackFactory.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/DataAggregatorFeignClientClientFallBackFactory.java new file mode 100644 index 0000000000..7e6504bcfa --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/feign/impl/DataAggregatorFeignClientClientFallBackFactory.java @@ -0,0 +1,23 @@ +package com.epmet.feign.impl; + + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; +import com.epmet.feign.DataAggregatorFeignClient; +import org.springframework.stereotype.Component; + +@Component +public class DataAggregatorFeignClientClientFallBackFactory implements DataAggregatorFeignClient { + + /** + * 定时任务导出网格活跃统计表 + * @param form + * @return + */ + @Override + public Result exportGridLiveRes(GridLivelyFormDTO form) { + return ModuleUtils.feignConError(ServiceConstant.DATA_AGGREGATOR_SERVER, "pcworkRecordListExportSendMsg",form); + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java new file mode 100644 index 0000000000..e5d8bca884 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java @@ -0,0 +1,39 @@ +package com.epmet.task; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.dataaggre.dto.govorg.form.GridLivelyFormDTO; +import com.epmet.feign.DataAggregatorFeignClient; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + + +/** + * 每个星期一的凌晨5点执行,查询网格活跃度统计导出excel,上传oss, 发送钉钉@小雷哥 + */ +@Slf4j +@Component("exportGridLiveResTask") +public class ExportGridLiveResTask implements ITask { + + @Autowired + private DataAggregatorFeignClient dataAggregatorFeignClient; + + @Override + public void run(String params) { + if(StringUtils.isBlank(params)){ + return; + } + GridLivelyFormDTO formDTO = new GridLivelyFormDTO(); + if (StringUtils.isNotBlank(params)) { + formDTO = JSON.parseObject(params, GridLivelyFormDTO.class); + } + ValidatorUtils.validateEntity(formDTO,GridLivelyFormDTO.Grid.class); + Result result = dataAggregatorFeignClient.exportGridLiveRes(formDTO); + if(!result.success()){ + log.error(String.format("exportGridLiveResTask网格活跃度统计导出失败,入参:%s",params)); + } + } +} \ No newline at end of file From 4c1473c1048e8d02d781cb73850a8c4999ec306f Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 4 Mar 2022 13:22:51 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=AF=8F=E5=91=A8=E4=B8=80=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=EF=BC=8C=E5=8F=96=E4=B8=8A=E4=B8=AA=E8=87=AA=E7=84=B6?= =?UTF-8?q?=E5=91=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/task/ExportGridLiveResTask.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java index e5d8bca884..6aaad889f4 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/ExportGridLiveResTask.java @@ -10,6 +10,10 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; + /** * 每个星期一的凌晨5点执行,查询网格活跃度统计导出excel,上传oss, 发送钉钉@小雷哥 @@ -30,10 +34,33 @@ public class ExportGridLiveResTask implements ITask { if (StringUtils.isNotBlank(params)) { formDTO = JSON.parseObject(params, GridLivelyFormDTO.class); } + //默认获取当前日期的上一个自然周 + if (StringUtils.isBlank(formDTO.getStartTime()) || StringUtils.isBlank(formDTO.getEndTime())) { + Calendar calendar = Calendar.getInstance(); + calendar.add(Calendar.DATE, -1); + //上周日的日期 + Date yesterday = calendar.getTime(); + DateFormat format = new SimpleDateFormat("yyyyMMdd"); + Calendar c = new GregorianCalendar(); + //这里设置一周开始时间是星期一 + c.setFirstDayOfWeek(Calendar.MONDAY); + c.setTime(yesterday); + c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); + //获取当前自然周的起始时间 + String beginTime = format.format(c.getTime()); + c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek() + 6); + //当前自然周的截止时间 + String endTime = format.format(c.getTime()); + formDTO.setStartTime(beginTime); + formDTO.setEndTime(endTime); + } ValidatorUtils.validateEntity(formDTO,GridLivelyFormDTO.Grid.class); Result result = dataAggregatorFeignClient.exportGridLiveRes(formDTO); if(!result.success()){ log.error(String.format("exportGridLiveResTask网格活跃度统计导出失败,入参:%s",params)); } } + + + } \ No newline at end of file From 680336195d185293295e57e41c6543f4262f5d42 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 4 Mar 2022 14:06:44 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/ImportBuildingInfoListener.java | 21 ++++++++++---- .../epmet/model/ImportHouseInfoListener.java | 29 ++++++++++++++----- .../model/ImportNeighborHoodInfoListener.java | 13 +++++++-- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java index 27ab369129..6c1963888a 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/model/ImportBuildingInfoListener.java @@ -223,7 +223,9 @@ public class ImportBuildingInfoListener extends AnalysisEventListener