From 6edd7a00d2f8046cc3ff2d2bea03369c576d2272 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Mon, 14 Sep 2020 17:14:56 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dto/AuthorizationInfoDTO.java | 5 + .../com/epmet/dto/PersonalTemplateDTO.java | 126 +++++ .../java/com/epmet/dto/PublicTemplateDTO.java | 91 ++++ .../epmet/dto/form/AddTemplateFormDTO.java | 51 ++ .../epmet/dto/form/DelTemplateFormDTO.java | 17 + .../java/com/epmet/dto/form/InitFormDTO.java | 39 ++ .../epmet/dto/form/PubTemplateFormDTO.java | 26 + .../com/epmet/dto/form/SubscribeFormDTO.java | 19 + .../dto/result/CustomerTempResultDTO.java | 18 + .../dto/result/GetTemplateResultDTO.java | 47 ++ .../epmet/dto/result/KeyWordsResultDTO.java | 34 ++ .../dto/result/PubTemplateResultDTO.java | 39 ++ .../result/SubscribeCategoryResultDTO.java | 17 + .../com/epmet/dto/result/TemplateDTO.java | 27 ++ .../epmet/controller/SubscribeController.java | 149 ++++++ .../com/epmet/dao/AuthorizationInfoDao.java | 9 + .../java/com/epmet/dao/PaCustomerDao.java | 9 + .../com/epmet/dao/PersonalTemplateDao.java | 79 ++++ .../java/com/epmet/dao/PublicTemplateDao.java | 56 +++ .../epmet/entity/PersonalTemplateEntity.java | 96 ++++ .../epmet/entity/PublicTemplateEntity.java | 61 +++ .../com/epmet/service/PaCustomerService.java | 9 + .../service/PersonalTemplateService.java | 126 +++++ .../epmet/service/PublicTemplateService.java | 115 +++++ .../com/epmet/service/SubscribeService.java | 105 +++++ .../service/impl/PaCustomerServiceImpl.java | 5 + .../impl/PersonalTemplateServiceImpl.java | 119 +++++ .../impl/PublicTemplateServiceImpl.java | 112 +++++ .../service/impl/SubscribeServiceImpl.java | 445 ++++++++++++++++++ .../wxapi/constant/WxSubscribeConstant.java | 38 ++ .../epmet/wxapi/enums/WxMaErrorMsgEnum.java | 20 + .../epmet/wxapi/param/WxAddTemplateReq.java | 31 ++ .../epmet/wxapi/param/WxDelTemplateReq.java | 22 + .../epmet/wxapi/param/WxSubTemplateReq.java | 30 ++ .../wxapi/result/WxGetCategoryResult.java | 41 ++ .../wxapi/result/WxGetTemplateResult.java | 56 +++ .../epmet/wxapi/result/WxKeyWordsResult.java | 52 ++ .../wxapi/result/WxSubTemplateResult.java | 56 +++ .../wxapi/service/WxMaSubscribeService.java | 78 +++ .../impl/WxMaSubscribeServiceImpl.java | 146 ++++++ .../db/migration/V0.0.10__thirdUpdate.sql | 36 ++ .../resources/mapper/AuthorizationInfoDao.xml | 11 + .../main/resources/mapper/PaCustomerDao.xml | 12 + .../resources/mapper/PersonalTemplateDao.xml | 78 +++ .../resources/mapper/PublicTemplateDao.xml | 41 ++ 45 files changed, 2799 insertions(+) create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PersonalTemplateDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PublicTemplateDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelTemplateFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PubTemplateFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubscribeFormDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTempResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/GetTemplateResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/KeyWordsResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PubTemplateResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SubscribeCategoryResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PublicTemplateDao.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PersonalTemplateEntity.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PublicTemplateEntity.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PublicTemplateService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PublicTemplateServiceImpl.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxSubscribeConstant.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxAddTemplateReq.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxDelTemplateReq.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxSubTemplateReq.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetCategoryResult.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetTemplateResult.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxKeyWordsResult.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxSubTemplateResult.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaSubscribeService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaSubscribeServiceImpl.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.10__thirdUpdate.sql create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PublicTemplateDao.xml diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AuthorizationInfoDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AuthorizationInfoDTO.java index 394b8680bc..e540f690d7 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AuthorizationInfoDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/AuthorizationInfoDTO.java @@ -63,6 +63,11 @@ public class AuthorizationInfoDTO implements Serializable { */ private String authorizerRefreshToken; + /** + * 客户端类型 resi:居民端,work:工作端 + */ + private String clientType; + /** * */ diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PersonalTemplateDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PersonalTemplateDTO.java new file mode 100644 index 0000000000..574f772896 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PersonalTemplateDTO.java @@ -0,0 +1,126 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-09 + */ +@Data +public class PersonalTemplateDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 小程序类型 居民端resi,工作端work + */ + private String clientType; + + /** + * APPID + */ + private String appId; + + /** + * 主模板ID + */ + private String pid; + + /** + * 添加至帐号下的模板id + */ + private String priTmplId; + + /** + * 模板类型,2 代表一次性订阅,3 代表长期订阅 + */ + private String type; + + /** + * 模板ID + */ + private String tid; + + /** + * 模板标题 + */ + private String title; + + /** + * 关键词ID + */ + private String keyIds; + + /** + * 关键词 + */ + private String keyWords; + + /** + * 服务场景描述,15个字以内 + */ + private String sceneDesc; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 是否删除 + */ + private String delFlag; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PublicTemplateDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PublicTemplateDTO.java new file mode 100644 index 0000000000..b4c8b1d7f7 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/PublicTemplateDTO.java @@ -0,0 +1,91 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-11 + */ +@Data +public class PublicTemplateDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String id; + + /** + * + */ + private String tid; + + /** + * + */ + private String title; + + /** + * + */ + private String type; + + /** + * + */ + private String categoryId; + + /** + * + */ + private Integer revision; + + /** + * + */ + private String delFlag; + + /** + * + */ + private String createdBy; + + /** + * + */ + private Date createdTime; + + /** + * + */ + private String updatedBy; + + /** + * + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java new file mode 100644 index 0000000000..edb391eb73 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/AddTemplateFormDTO.java @@ -0,0 +1,51 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 14:20 + */ +@NoArgsConstructor +@Data +public class AddTemplateFormDTO implements Serializable { + + private static final long serialVersionUID = 8721859887464107897L; + /** + * appId + */ + private String appId; + /** + * 公共模板标题 id + */ + private String tid; + /** + * 公共模板标题 + */ + private String title; + /** + * 服务场景描述,15个字以内 + */ + private String sceneDesc; + /** + * 工作端(gov),居民端(resi) + */ + private String clientType; + /** + * 模板类型,2 代表一次性订阅,3 代表长期订阅 + */ + private String type; + /** + * 关键词id,最多支持5个,最少2个关键词组合 + */ + private List kidList; + /** + * 关键字名称 + */ + private List nameList; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelTemplateFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelTemplateFormDTO.java new file mode 100644 index 0000000000..e3cc9b4e48 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/DelTemplateFormDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 14:23 + */ +@Data +public class DelTemplateFormDTO implements Serializable { + private static final long serialVersionUID = -3468604475671634840L; + private String appId; + private String priTmplId; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java new file mode 100644 index 0000000000..ab154a196a --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/InitFormDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/10 16:22 + */ +@NoArgsConstructor +@Data +public class InitFormDTO implements Serializable { + + private static final long serialVersionUID = -7120483520014483199L; + /** + * 客户ID + */ + private String customerId; + /** + * 居民端测试号AppID + */ + private String resiAppId; + /** + * 工作端测试号AppID + */ + private String workAppId; + /** + * 居民端需要同步的模板id数组 + */ + private List resiTempIdList; + /** + * 工作端需要同步的模板id数组 + */ + private List workTempIdList; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PubTemplateFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PubTemplateFormDTO.java new file mode 100644 index 0000000000..c0431067b4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/PubTemplateFormDTO.java @@ -0,0 +1,26 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 14:58 + */ +@NoArgsConstructor +@Data +public class PubTemplateFormDTO implements Serializable { + + private static final long serialVersionUID = 9023183147998651076L; + private String appId; + /** + * 类目 id,多个用逗号隔开 + */ + private String ids; + private String title; + private Integer pageNo; + private Integer pageSize; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubscribeFormDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubscribeFormDTO.java new file mode 100644 index 0000000000..574f64689f --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/form/SubscribeFormDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.form; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 14:19 + */ +@NoArgsConstructor +@Data +public class SubscribeFormDTO implements Serializable { + private static final long serialVersionUID = -4637357527979131441L; + private String appId; + private String titleId; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTempResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTempResultDTO.java new file mode 100644 index 0000000000..d75387bfb6 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/CustomerTempResultDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/11 14:02 + */ +@NoArgsConstructor +@Data +public class CustomerTempResultDTO { + private List workList; + private List resiList; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/GetTemplateResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/GetTemplateResultDTO.java new file mode 100644 index 0000000000..fca432b8b7 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/GetTemplateResultDTO.java @@ -0,0 +1,47 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 14:36 + */ +@NoArgsConstructor +@Data +public class GetTemplateResultDTO implements Serializable { + + private static final long serialVersionUID = -3558254681242362668L; + /** + * 添加至帐号下的模板 id,发送小程序订阅消息时所需 + */ + private String priTmplId; + /** + * 模板标题 + */ + private String title; + /** + * 模板内容 + */ + private String content; + /** + * 模板内容示例 + */ + private String example; + /** + * 模板类型,2 代表一次性订阅,3 代表长期订阅 + */ + private String type; + /** + * 关键词名称,逗号隔开 + */ + private String kidNames; + + /** + * 场景说明 + */ + private String sceneDesc; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/KeyWordsResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/KeyWordsResultDTO.java new file mode 100644 index 0000000000..7291a415c0 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/KeyWordsResultDTO.java @@ -0,0 +1,34 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 14:34 + */ +@NoArgsConstructor +@Data +public class KeyWordsResultDTO implements Serializable { + + private static final long serialVersionUID = 3082505411447366845L; + /** + * 关键词 id + */ + private Integer kid; + /** + * 关键词内容 + */ + private String name; + /** + * 关键词内容对应的示例 + */ + private String example; + /** + * 参数类型 + */ + private String rule; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PubTemplateResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PubTemplateResultDTO.java new file mode 100644 index 0000000000..ae28b3bfb0 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/PubTemplateResultDTO.java @@ -0,0 +1,39 @@ +package com.epmet.dto.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 14:27 + */ +@NoArgsConstructor +@Data +public class PubTemplateResultDTO implements Serializable { + + private static final long serialVersionUID = -1563615907119995448L; + /** + * 模板标题 id + */ + private Integer tid; + /** + * 模板标题 + */ + private String title; + /** + * 模板类型,2 为一次性订阅,3 为长期订阅 + */ + private Integer type; + /** + * 模板所属类目 id + */ + private String categoryId; + /** + * 关键词 + */ + private List keywords; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SubscribeCategoryResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SubscribeCategoryResultDTO.java new file mode 100644 index 0000000000..057394c552 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/SubscribeCategoryResultDTO.java @@ -0,0 +1,17 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 14:25 + */ +@Data +public class SubscribeCategoryResultDTO implements Serializable { + private static final long serialVersionUID = -2539495405169212998L; + private Integer id; + private String name; +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java new file mode 100644 index 0000000000..b9c43fb0d3 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java @@ -0,0 +1,27 @@ +package com.epmet.dto.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/11 14:38 + */ +@Data +public class TemplateDTO implements Serializable { + private static final long serialVersionUID = 1709155656984339643L; + /** + * 模板ID + */ + private String priTmplId; + /** + * 标题 + */ + private String title; + /** + * 同步状态 0未同步 1同步 + */ + private String state; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java new file mode 100644 index 0000000000..47d3b6d653 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/SubscribeController.java @@ -0,0 +1,149 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.*; +import com.epmet.dto.result.CustomerTempResultDTO; +import com.epmet.dto.result.GetTemplateResultDTO; +import com.epmet.dto.result.KeyWordsResultDTO; +import com.epmet.dto.result.SubscribeCategoryResultDTO; +import com.epmet.service.SubscribeService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/10 13:44 + */ +@RestController +@RequestMapping("subscribe") +public class SubscribeController { + + @Autowired + private SubscribeService subscribeService; + + /** + * 获取当前帐号所设置的类目信息 + * + * @param formDTO + * @return com.epmet.dto.result.SubscribeCategoryResultDTO + * @author zhaoqifeng + * @date 2020/9/9 14:57 + */ + @PostMapping("getcategory") + public Result> getCategory(@RequestBody SubscribeFormDTO formDTO) { + List result = subscribeService.getCategory(formDTO); + return new Result>().ok(result); + } + + + /** + * 获取模板标题列表 + * + * @param formDTO + * @return com.epmet.dto.result.PubTemplateResultDTO + * @author zhaoqifeng + * @date 2020/9/9 15:00 + */ + @PostMapping("getpubtemplatetitles") + public Result getPubTemplateTitles(@RequestBody PubTemplateFormDTO formDTO) { + PageData result = subscribeService.getPubTemplateTitles(formDTO); + return new Result().ok(result); + } + + /** + * 同步微信公共模板 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/9/11 16:11 + */ + @PostMapping("syncpubtemplatetitles") + public Result syncPubTemplateTitles(@RequestBody PubTemplateFormDTO formDTO) { + subscribeService.syncPubTemplateTitles(formDTO); + return new Result(); + } + + /** + * 获取模板标题下的关键词库 + * + * @param formDTO + * @return com.epmet.dto.result.KeyWordsResultDTO + * @author zhaoqifeng + * @date 2020/9/9 15:10 + */ + @PostMapping("getkeywords") + public Result> getKeyWords(@RequestBody SubscribeFormDTO formDTO) { + List result = subscribeService.getKeyWords(formDTO); + return new Result>().ok(result); + } + + /** + * 获取帐号下的模板列表 + * + * @param formDTO + * @return com.epmet.dto.result.GetTemplateResultDTO + * @author zhaoqifeng + * @date 2020/9/9 15:12 + */ + @PostMapping("gettemplate") + public Result> getTemplate(@RequestBody SubscribeFormDTO formDTO) { + List result = subscribeService.getTemplate(formDTO); + return new Result>().ok(result); + } + + /** + * 添加个人模板 + * + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/9/9 15:13 + */ + @PostMapping("addtemplate") + public Result addTemplate(@RequestBody AddTemplateFormDTO formDTO) { + subscribeService.addTemplate(formDTO); + return new Result(); + } + + /** + * 删除账号下模板 + * + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/9/9 15:13 + */ + @PostMapping("deltemplate") + public Result delTemplate(@RequestBody DelTemplateFormDTO formDTO) { + subscribeService.delTemplate(formDTO); + return new Result(); + } + + /** + * 客户初始化 + * + * @param formDTO + * @return com.epmet.commons.tools.utils.Result + * @author zhaoqifeng + * @date 2020/9/11 9:25 + */ + @PostMapping("init") + public Result init(@RequestBody InitFormDTO formDTO) { + subscribeService.init(formDTO); + return new Result(); + } + + @PostMapping("getcustomerlist") + public Result getCustomerTemplate(@RequestBody InitFormDTO formDTO) { + CustomerTempResultDTO result = subscribeService.getCustomerTemplate(formDTO); + return new Result().ok(result); + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java index 882a091b1b..ccd9802432 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/AuthorizationInfoDao.java @@ -118,4 +118,13 @@ public interface AuthorizationInfoDao extends BaseDao { * @date 2020.08.25 15:24 **/ List selectClientToken(@Param("customerId") String customerId); + + /** + * 根据APPID获取auth信息 + * @author zhaoqifeng + * @date 2020/9/9 15:23 + * @param appId + * @return com.epmet.dto.AuthorizationInfoDTO + */ + AuthorizationInfoDTO selectInfoByAppId(@Param("appId") String appId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java index 573ad48cf3..ac24fb4ac2 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PaCustomerDao.java @@ -120,4 +120,13 @@ public interface PaCustomerDao extends BaseDao { * @date 2020.08.26 10:59 **/ String selectSourceById(@Param("customerId") String customerId,@Param("source") String source); + + /** + * 根据测试号查询同源的客户列表 + * @author zhaoqifeng + * @date 2020/9/9 17:23 + * @param customerId + * @return java.util.List + */ + List selectCustomerListByTestId(@Param("customerId") String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java new file mode 100644 index 0000000000..bd77f6ffea --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PersonalTemplateDao.java @@ -0,0 +1,79 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.PersonalTemplateDTO; +import com.epmet.dto.result.CustomerTempResultDTO; +import com.epmet.dto.result.TemplateDTO; +import com.epmet.entity.PersonalTemplateEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-09 + */ +@Mapper +public interface PersonalTemplateDao extends BaseDao { + /** + * 获取个人模板列表 + * + * @param pid + * @return java.util.List + * @author zhaoqifeng + * @date 2020/9/9 17:56 + */ + List selectListByPid(@Param("pid") String pid); + + /** + * 根据AppID获取模板列表 + * + * @param appId + * @return java.util.List + * @author zhaoqifeng + * @date 2020/9/10 10:49 + */ + List selectListByAppId(@Param("appId") String appId); + + /** + * 获取已配置的模板 + * + * @param customerId + * @param pid + * @return com.epmet.dto.PersonalTemplateDTO + * @author zhaoqifeng + * @date 2020/9/11 9:42 + */ + PersonalTemplateDTO selectSetTemp(@Param("customerId") String customerId, @Param("pid") String pid); + + /** + * 根据客户Id获取模板列表 + * + * @param appId + * @param customerId + * @param clientType + * @return java.util.List + * @author zhaoqifeng + * @date 2020/9/11 14:35 + */ + List selectListByCustomerId(@Param("appId") String appId, @Param("customerId") String customerId, + @Param("clientType") String clientType); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PublicTemplateDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PublicTemplateDao.java new file mode 100644 index 0000000000..b51596e20e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/PublicTemplateDao.java @@ -0,0 +1,56 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.form.PubTemplateFormDTO; +import com.epmet.dto.result.PubTemplateResultDTO; +import com.epmet.entity.PublicTemplateEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-11 + */ +@Mapper +public interface PublicTemplateDao extends BaseDao { + + /** + * 根据类目Id删除模板 + * @author zhaoqifeng + * @date 2020/9/11 16:22 + * @param list + * @return void + */ + void deleteTempByCategoryId(List list); + + /** + * 获取公共模板列表 + * @author zhaoqifeng + * @date 2020/9/11 16:57 + * @param dto + * @return java.util.List + */ + List getPubTempList(PubTemplateFormDTO dto); + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PersonalTemplateEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PersonalTemplateEntity.java new file mode 100644 index 0000000000..022c2982a5 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PersonalTemplateEntity.java @@ -0,0 +1,96 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-09 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("personal_template") +public class PersonalTemplateEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 小程序类型 居民端resi,工作端work + */ + private String clientType; + + /** + * APPID + */ + private String appId; + + /** + * 主模板ID + */ + private String pid; + + /** + * 添加至帐号下的模板id + */ + private String priTmplId; + + /** + * 模板类型,2 代表一次性订阅,3 代表长期订阅 + */ + private String type; + + /** + * 模板ID + */ + private String tid; + + /** + * 模板标题 + */ + private String title; + + /** + * 关键词ID + */ + private String keyIds; + + /** + * 关键词 + */ + private String keyWords; + + /** + * 服务场景描述,15个字以内 + */ + private String sceneDesc; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PublicTemplateEntity.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PublicTemplateEntity.java new file mode 100644 index 0000000000..62cac50b92 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/entity/PublicTemplateEntity.java @@ -0,0 +1,61 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-11 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("public_template") +public class PublicTemplateEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * + */ + private String tid; + + /** + * + */ + private String title; + + /** + * + */ + private String type; + + /** + * + */ + private String categoryId; + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java index a1b30bd255..ecdf6cfe25 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PaCustomerService.java @@ -233,4 +233,13 @@ public interface PaCustomerService extends BaseService { * @date 2020.08.25 15:46 **/ void clearPublicCustomer(CommonCustomerIdAndSrcFormDTO param); + + /** + * 根据测试号查询同源的客户列表 + * @author zhaoqifeng + * @date 2020/9/9 17:32 + * @param customerId + * @return java.util.List + */ + List getCustomerListByTestId(String customerId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java new file mode 100644 index 0000000000..447e6dd388 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PersonalTemplateService.java @@ -0,0 +1,126 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.PersonalTemplateDTO; +import com.epmet.dto.result.TemplateDTO; +import com.epmet.entity.PersonalTemplateEntity; + +import java.util.List; +import java.util.Map; + +/** + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-09 + */ +public interface PersonalTemplateService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-09-09 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-09-09 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return PersonalTemplateDTO + * @author generator + * @date 2020-09-09 + */ + PersonalTemplateDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-09-09 + */ + void save(PersonalTemplateDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-09-09 + */ + void update(PersonalTemplateDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-09-09 + */ + void delete(String[] ids); + + /** + * 获取个人模板列表 + * + * @param pid + * @return java.util.List + * @author zhaoqifeng + * @date 2020/9/9 17:59 + */ + List getListByPid(String pid); + + /** + * 根据AppID获取模板列表 + * + * @param appId + * @return java.util.List + * @author zhaoqifeng + * @date 2020/9/10 10:48 + */ + List getListByAppId(String appId); + + /** + * 根据客户Id获取模板列表 + * + * @param appId + * @param customerId + * @param clientType + * @return java.util.List + * @author zhaoqifeng + * @date 2020/9/11 14:43 + */ + List getListByCustomer(String appId, String customerId, String clientType); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PublicTemplateService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PublicTemplateService.java new file mode 100644 index 0000000000..25ed0174ec --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PublicTemplateService.java @@ -0,0 +1,115 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service; + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.PublicTemplateDTO; +import com.epmet.dto.form.PubTemplateFormDTO; +import com.epmet.dto.result.PubTemplateResultDTO; +import com.epmet.entity.PublicTemplateEntity; + +import java.util.List; +import java.util.Map; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-11 + */ +public interface PublicTemplateService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-09-11 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-09-11 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return PublicTemplateDTO + * @author generator + * @date 2020-09-11 + */ + PublicTemplateDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-09-11 + */ + void save(PublicTemplateDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-09-11 + */ + void update(PublicTemplateDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-09-11 + */ + void delete(String[] ids); + + /** + * 根据类目Id删除模板 + * @author zhaoqifeng + * @date 2020/9/11 16:29 + * @param categoryIds + * @return void + */ + void deleteTempByCategoryId(List categoryIds); + + /** + * 获取公共模板列表 + * @author zhaoqifeng + * @date 2020/9/11 17:01 + * @param dto + * @return java.util.List + */ + List getPubTempList(PubTemplateFormDTO dto); +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java new file mode 100644 index 0000000000..c56d17487a --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/SubscribeService.java @@ -0,0 +1,105 @@ +package com.epmet.service; + +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; + +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 11:02 + */ +public interface SubscribeService { + + /** + * 获取当前帐号所设置的类目信息 + * + * @param formDTO + * @return com.epmet.dto.result.SubscribeCategoryResultDTO + * @author zhaoqifeng + * @date 2020/9/9 14:57 + */ + List getCategory(SubscribeFormDTO formDTO); + + /** + * 获取模板标题列表 + * + * @param formDTO + * @return com.epmet.dto.result.PubTemplateResultDTO + * @author zhaoqifeng + * @date 2020/9/9 15:00 + */ + PageData getPubTemplateTitles(PubTemplateFormDTO formDTO); + + /** + * 同步微信公共模板 + * @author zhaoqifeng + * @date 2020/9/11 15:26 + * @param formDTO + * @return void + */ + void syncPubTemplateTitles(PubTemplateFormDTO formDTO); + + /** + * 获取模板标题下的关键词库 + * + * @param formDTO + * @return com.epmet.dto.result.KeyWordsResultDTO + * @author zhaoqifeng + * @date 2020/9/9 15:10 + */ + List getKeyWords(SubscribeFormDTO formDTO); + + /** + * 获取帐号下的模板列表 + * + * @param formDTO + * @return com.epmet.dto.result.GetTemplateResultDTO + * @author zhaoqifeng + * @date 2020/9/9 15:12 + */ + List getTemplate(SubscribeFormDTO formDTO); + + /** + * 添加个人模板 + * + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/9/9 15:13 + */ + void addTemplate(AddTemplateFormDTO formDTO); + + /** + * 删除账号下模板 + * + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/9/9 15:13 + */ + void delTemplate(DelTemplateFormDTO formDTO); + + /** + * 客户初始化 + * + * @param formDTO + * @return void + * @author zhaoqifeng + * @date 2020/9/10 16:25 + */ + void init(InitFormDTO formDTO); + + /** + * 获取客户模板列表 + * + * @param formDTO + * @return com.epmet.dto.result.CustomerTempResultDTO + * @author zhaoqifeng + * @date 2020/9/11 14:04 + */ + CustomerTempResultDTO getCustomerTemplate(InitFormDTO formDTO); + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java index 5b683027b5..11dd6bad81 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PaCustomerServiceImpl.java @@ -697,4 +697,9 @@ public class PaCustomerServiceImpl extends BaseServiceImpl getCustomerListByTestId(String customerId) { + return baseDao.selectCustomerListByTestId(customerId); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java new file mode 100644 index 0000000000..f7b5589f43 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PersonalTemplateServiceImpl.java @@ -0,0 +1,119 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.PersonalTemplateDao; +import com.epmet.dto.PersonalTemplateDTO; +import com.epmet.dto.result.TemplateDTO; +import com.epmet.entity.PersonalTemplateEntity; +import com.epmet.service.PersonalTemplateService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-09 + */ +@Service +public class PersonalTemplateServiceImpl extends BaseServiceImpl implements PersonalTemplateService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, PersonalTemplateDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, PersonalTemplateDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public PersonalTemplateDTO get(String id) { + PersonalTemplateEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, PersonalTemplateDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(PersonalTemplateDTO dto) { + PersonalTemplateEntity entity = ConvertUtils.sourceToTarget(dto, PersonalTemplateEntity.class); + insert(entity); + //copy主键值到dto + BeanUtils.copyProperties(entity, dto); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(PersonalTemplateDTO dto) { + PersonalTemplateEntity entity = ConvertUtils.sourceToTarget(dto, PersonalTemplateEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public List getListByPid(String pid) { + return baseDao.selectListByPid(pid); + } + + @Override + public List getListByAppId(String appId) { + return baseDao.selectListByAppId(appId); + } + + @Override + public List getListByCustomer(String appId, String customerId, String clientType) { + return baseDao.selectListByCustomerId(appId, customerId, clientType); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PublicTemplateServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PublicTemplateServiceImpl.java new file mode 100644 index 0000000000..d59297f700 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PublicTemplateServiceImpl.java @@ -0,0 +1,112 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.PublicTemplateDao; +import com.epmet.dto.PublicTemplateDTO; +import com.epmet.dto.form.PubTemplateFormDTO; +import com.epmet.dto.result.PubTemplateResultDTO; +import com.epmet.entity.PublicTemplateEntity; +import com.epmet.service.PublicTemplateService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-09-11 + */ +@Service +public class PublicTemplateServiceImpl extends BaseServiceImpl implements PublicTemplateService { + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, PublicTemplateDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, PublicTemplateDTO.class); + } + + private QueryWrapper getWrapper(Map params){ + String id = (String)params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public PublicTemplateDTO get(String id) { + PublicTemplateEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, PublicTemplateDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(PublicTemplateDTO dto) { + PublicTemplateEntity entity = ConvertUtils.sourceToTarget(dto, PublicTemplateEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(PublicTemplateDTO dto) { + PublicTemplateEntity entity = ConvertUtils.sourceToTarget(dto, PublicTemplateEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + public void deleteTempByCategoryId(List categoryIds) { + baseDao.deleteTempByCategoryId(categoryIds); + } + + @Override + public List getPubTempList(PubTemplateFormDTO formDTO) { + return baseDao.getPubTempList(formDTO); + } + +} \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java new file mode 100644 index 0000000000..7443a16d90 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java @@ -0,0 +1,445 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.AuthorizationInfoDao; +import com.epmet.dto.AuthorizationInfoDTO; +import com.epmet.dto.PaCustomerDTO; +import com.epmet.dto.PersonalTemplateDTO; +import com.epmet.dto.PublicTemplateDTO; +import com.epmet.dto.form.*; +import com.epmet.dto.result.*; +import com.epmet.entity.PublicTemplateEntity; +import com.epmet.service.PaCustomerService; +import com.epmet.service.PersonalTemplateService; +import com.epmet.service.PublicTemplateService; +import com.epmet.service.SubscribeService; +import com.epmet.wxapi.param.WxAddTemplateReq; +import com.epmet.wxapi.param.WxDelTemplateReq; +import com.epmet.wxapi.param.WxSubTemplateReq; +import com.epmet.wxapi.result.*; +import com.epmet.wxapi.service.WxMaSubscribeService; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 11:02 + */ +@Slf4j +@Service +public class SubscribeServiceImpl implements SubscribeService { + @Autowired + private AuthorizationInfoDao authorizationInfoDao; + @Autowired + private WxMaSubscribeService wxMaSubscribeService; + @Autowired + private PersonalTemplateService personalTemplateService; + @Autowired + private PaCustomerService paCustomerService; + @Autowired + private PublicTemplateService publicTemplateService; + + + @Override + public List getCategory(SubscribeFormDTO formDTO) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); + WxGetCategoryResult wxResult = getCategoryResult(authInfo.getAuthorizerAccessToken()); + + List list = wxResult.getData().stream().map(category -> { + SubscribeCategoryResultDTO resultDTO = new SubscribeCategoryResultDTO(); + resultDTO.setId(category.getId()); + resultDTO.setName(category.getName()); + return resultDTO; + }).collect(Collectors.toList()); + + return list; + } + + @Override + public PageData getPubTemplateTitles(PubTemplateFormDTO formDTO) { + PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()); + List list = publicTemplateService.getPubTempList(formDTO); + PageInfo pageInfo = new PageInfo<>(list); + return new PageData<>(list, pageInfo.getTotal()); + } + + @Override + public void syncPubTemplateTitles(PubTemplateFormDTO formDTO) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); + //获取类目ID + WxGetCategoryResult wxGetCategoryResult = getCategoryResult(authInfo.getAuthorizerAccessToken()); + List idList = wxGetCategoryResult.getData().stream().map(a -> a.getId().toString()).collect(Collectors.toList()); + publicTemplateService.deleteTempByCategoryId(idList); + String ids = String.join(",", idList); + WxSubTemplateReq request = new WxSubTemplateReq(); + request.setIds(ids); + request.setLimit(NumConstant.THIRTY); + request.setStart(NumConstant.ZERO); + WxResult wxResult = wxMaSubscribeService.getPubTemplateTitles(authInfo.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + Integer total = wxResult.getData().getCount(); + List list = wxResult.getData().getData().stream().map(template -> { + PublicTemplateDTO dto = new PublicTemplateDTO(); + dto.setTid(template.getTid().toString()); + dto.setTitle(template.getTitle()); + dto.setCategoryId(template.getCategoryId()); + dto.setType(template.getType().toString()); + return dto; + }).collect(Collectors.toList()); + if (total > NumConstant.THIRTY) { + for (int i = NumConstant.THIRTY; i < total; i= i + NumConstant.THIRTY) { + request.setStart(i); + wxResult = wxMaSubscribeService.getPubTemplateTitles(authInfo.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + List pubList = wxResult.getData().getData().stream().map(template -> { + PublicTemplateDTO dto = new PublicTemplateDTO(); + dto.setTid(template.getTid().toString()); + dto.setTitle(template.getTitle()); + dto.setCategoryId(template.getCategoryId()); + dto.setType(template.getType().toString()); + return dto; + }).collect(Collectors.toList()); + list.addAll(pubList); + } + } + publicTemplateService.insertBatch(ConvertUtils.sourceToTarget(list, PublicTemplateEntity.class)); + } + + @Override + public List getKeyWords(SubscribeFormDTO formDTO) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); + WxKeyWordsResult keyWordsResult = getTitleKeyWords(authInfo.getAuthorizerAccessToken(), formDTO.getTitleId()); + List list = keyWordsResult.getData().stream().map(keyWord -> { + KeyWordsResultDTO dto = new KeyWordsResultDTO(); + dto.setExample(keyWord.getExample()); + dto.setKid(keyWord.getKid()); + dto.setName(keyWord.getName()); + dto.setRule(keyWord.getRule()); + return dto; + }).collect(Collectors.toList()); + return list; + } + + @Override + public List getTemplate(SubscribeFormDTO formDTO) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); + List list = personalTemplateService.getListByAppId(formDTO.getAppId()); + WxResult wxResult = wxMaSubscribeService.getTemplate(authInfo.getAuthorizerAccessToken()); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + + List resultList = new ArrayList<>(); + if (null != list && list.size() > 0) { + resultList = + list.stream().flatMap(dto -> wxResult.getData().getData().stream().filter(bean -> + dto.getPriTmplId().equals(bean.getPriTmplId())).map(template -> { + GetTemplateResultDTO tempDTO = new GetTemplateResultDTO(); + tempDTO.setPriTmplId(dto.getPriTmplId()); + tempDTO.setTitle(dto.getTitle()); + tempDTO.setType(dto.getType()); + tempDTO.setKidNames(dto.getKeyWords()); + tempDTO.setSceneDesc(dto.getSceneDesc()); + tempDTO.setContent(template.getContent()); + tempDTO.setExample(template.getExample()); + return tempDTO; + })).collect(Collectors.toList()); + } + return resultList; + } + + @Override + public void addTemplate(AddTemplateFormDTO formDTO) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.selectInfoByAppId(formDTO.getAppId()); + WxAddTemplateReq request = new WxAddTemplateReq(); + request.setTid(formDTO.getTid()); + request.setKidList(formDTO.getKidList()); + request.setSceneDesc(formDTO.getSceneDesc()); + WxResult wxResult = wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + String priTmplId = wxResult.getData(); + String keywords = String.join(",", formDTO.getNameList()); + List keyIdList = formDTO.getKidList().stream().map(Object::toString).collect(Collectors.toList()); + String keyIds = String.join(",", keyIdList); + //将公共模板存入数据库 + PersonalTemplateDTO personalTemplateDTO = new PersonalTemplateDTO(); + personalTemplateDTO.setCustomerId(authInfo.getCustomerId()); + personalTemplateDTO.setClientType(authInfo.getClientType()); + personalTemplateDTO.setAppId(formDTO.getAppId()); + personalTemplateDTO.setPid(priTmplId); + personalTemplateDTO.setPriTmplId(priTmplId); + personalTemplateDTO.setTid(formDTO.getTid()); + personalTemplateDTO.setKeyIds(keyIds); + personalTemplateDTO.setTitle(formDTO.getTitle()); + personalTemplateDTO.setSceneDesc(formDTO.getSceneDesc()); + personalTemplateDTO.setKeyWords(keywords); + personalTemplateDTO.setType(formDTO.getType()); + personalTemplateService.save(personalTemplateDTO); + //获取客户列表 + List customerList = paCustomerService.getCustomerListByTestId(authInfo.getCustomerId()); + List customerNames = new ArrayList<>(); + if (null != customerList && customerList.size() > NumConstant.ZERO) { + for (PaCustomerDTO paCustomerDTO : customerList) { + //获取小程序调用令牌 + AuthorizationInfoDTO authDTO = authorizationInfoDao.getAuthInfoByCustomer(paCustomerDTO.getId(), authInfo.getClientType()); + if (null == authDTO) { + log.error("客户[" + paCustomerDTO.getCustomerName() + "]未授权"); + customerNames.add(paCustomerDTO.getCustomerName()); + continue; + } + WxResult wxResult1 = wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request); + if (!wxResult1.success()) { + log.error("客户[" + paCustomerDTO.getCustomerName() + "]添加模板失败,原因:" + wxResult1.getErrorCode() + wxResult1.getErrorMsg()); + customerNames.add(paCustomerDTO.getCustomerName()); + continue; + } + String tmplId = wxResult1.getData(); + PersonalTemplateDTO templateDTO = new PersonalTemplateDTO(); + templateDTO.setCustomerId(authInfo.getCustomerId()); + templateDTO.setClientType(authInfo.getClientType()); + templateDTO.setAppId(authDTO.getAuthorizerAppid()); + templateDTO.setPid(priTmplId); + templateDTO.setPriTmplId(tmplId); + templateDTO.setTid(formDTO.getTid()); + templateDTO.setKeyIds(keyIds); + templateDTO.setTitle(formDTO.getTitle()); + templateDTO.setSceneDesc(formDTO.getSceneDesc()); + templateDTO.setKeyWords(keywords); + templateDTO.setType(formDTO.getType()); + personalTemplateService.save(templateDTO); + } + } + + if (customerNames.size() > NumConstant.ZERO) { + String names = String.join(",", customerNames); + throw new RenException("客户[" + names + "]添加模板失败"); + } + + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delTemplate(DelTemplateFormDTO formDTO) { + List list = personalTemplateService.getListByPid(formDTO.getPriTmplId()); + for (PersonalTemplateDTO dto : list) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(dto.getCustomerId(), dto.getClientType()); + if (null == authInfo) { + log.error("客户[" + dto.getCustomerId() + "]未授权"); + continue; + } + WxDelTemplateReq request = new WxDelTemplateReq(); + request.setPriTmplId(dto.getPriTmplId()); + WxResult wxResult = wxMaSubscribeService.delTemplate(authInfo.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + personalTemplateService.deleteById(dto.getId()); + } + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void init(InitFormDTO formDTO) { + if (null != formDTO.getResiTempIdList() && !formDTO.getResiTempIdList().isEmpty()) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "resi"); + if (null == authInfo) { + throw new RenException("居民端未授权或token已过期"); + } + formDTO.getResiTempIdList().forEach(tempId -> { + PersonalTemplateDTO templateDTO = personalTemplateService.get(tempId); + List keyIds = Arrays.asList(templateDTO.getKeyIds().split(",")); + List keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList()); + WxAddTemplateReq request = new WxAddTemplateReq(); + request.setTid(templateDTO.getTid()); + request.setKidList(keyIdList); + request.setSceneDesc(templateDTO.getSceneDesc()); + WxResult wxResult = wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + log.error("居民端添加模板失败,原因:" + wxResult.getErrorCode() + wxResult.getErrorMsg()); + return; + } + String tmplId = wxResult.getData(); + PersonalTemplateDTO personalTemplate = ConvertUtils.sourceToTarget(templateDTO, PersonalTemplateDTO.class); + personalTemplate.setPriTmplId(tmplId); + personalTemplate.setCustomerId(formDTO.getCustomerId()); + personalTemplate.setClientType("resi"); + personalTemplate.setAppId(authInfo.getAuthorizerAppid()); + personalTemplateService.save(personalTemplate); + }); + } + + if (null != formDTO.getWorkTempIdList() && !formDTO.getWorkTempIdList().isEmpty()) { + AuthorizationInfoDTO authInfo = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "work"); + if (null == authInfo) { + throw new RenException("工作端未授权或token已过期"); + } + formDTO.getWorkTempIdList().forEach(tempId -> { + PersonalTemplateDTO templateDTO = personalTemplateService.get(tempId); + List keyIds = Arrays.asList(templateDTO.getKeyIds().split(",")); + List keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList()); + WxAddTemplateReq request = new WxAddTemplateReq(); + request.setTid(templateDTO.getTid()); + request.setKidList(keyIdList); + request.setSceneDesc(templateDTO.getSceneDesc()); + WxResult wxResult = wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + log.error("工作端添加模板失败,原因:" + wxResult.getErrorCode() + wxResult.getErrorMsg()); + return; + } + String tmplId = wxResult.getData(); + PersonalTemplateDTO personalTemplate = ConvertUtils.sourceToTarget(templateDTO, PersonalTemplateDTO.class); + personalTemplate.setPriTmplId(tmplId); + personalTemplate.setCustomerId(formDTO.getCustomerId()); + personalTemplate.setClientType("resi"); + personalTemplate.setAppId(authInfo.getAuthorizerAppid()); + personalTemplateService.save(personalTemplate); + }); + } + + } + + @Override + public CustomerTempResultDTO getCustomerTemplate(InitFormDTO formDTO) { + CustomerTempResultDTO resultDTO = new CustomerTempResultDTO(); + AuthorizationInfoDTO resiAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "resi"); + if (null == resiAuthDTO) { + throw new RenException("居民端未授权"); + } + WxResult wxResiResult = wxMaSubscribeService.getTemplate(resiAuthDTO.getAuthorizerAccessToken()); + if (!wxResiResult.success()) { + throw new RenException(wxResiResult.getErrorCode(), wxResiResult.getErrorMsg()); + } + List resiPubTmplIds = + wxResiResult.getData().getData().stream().map(WxGetTemplateResult.DataBean::getPriTmplId).collect(Collectors.toList()); + List resiList = personalTemplateService.getListByCustomer(formDTO.getResiAppId(), formDTO.getCustomerId(), "resi"); + List resiTmplIds = resiList.stream().map(TemplateDTO::getPriTmplId).collect(Collectors.toList()); + List resiReduce = resiPubTmplIds.stream().filter(item -> !resiTmplIds.contains(item)).collect(Collectors.toList()); + resiReduce.forEach(tmplId -> { + WxDelTemplateReq request = new WxDelTemplateReq(); + request.setPriTmplId(tmplId); + WxResult wxResult = wxMaSubscribeService.delTemplate(resiAuthDTO.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + log.error("居民端同步失败:" + wxResult.getErrorCode() + wxResult.getErrorMsg()); + } + }); + resultDTO.setResiList(resiList); + + AuthorizationInfoDTO workAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "work"); + if (null == workAuthDTO) { + throw new RenException("工作端未授权"); + } + WxResult wxWorkResult = wxMaSubscribeService.getTemplate(workAuthDTO.getAuthorizerAccessToken()); + if (!wxWorkResult.success()) { + throw new RenException(wxWorkResult.getErrorCode(), wxWorkResult.getErrorMsg()); + } + List workPubTmplIds = + wxWorkResult.getData().getData().stream().map(WxGetTemplateResult.DataBean::getPriTmplId).collect(Collectors.toList()); + List workList = personalTemplateService.getListByCustomer(formDTO.getWorkAppId(), formDTO.getCustomerId(), "work"); + List workTmplIds = workList.stream().map(TemplateDTO::getPriTmplId).collect(Collectors.toList()); + List workReduce = workPubTmplIds.stream().filter(item -> !workTmplIds.contains(item)).collect(Collectors.toList()); + workReduce.forEach(tmplId -> { + WxDelTemplateReq request = new WxDelTemplateReq(); + request.setPriTmplId(tmplId); + WxResult wxResult = wxMaSubscribeService.delTemplate(resiAuthDTO.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + log.error("工作端同步失败:" + wxResult.getErrorCode() + wxResult.getErrorMsg()); + } + }); + resultDTO.setWorkList(workList); + return resultDTO; + } + + private WxGetCategoryResult getCategoryResult(String accessToken) { + WxResult wxResult = wxMaSubscribeService.getCategory(accessToken); + + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + return wxResult.getData(); + } + + private WxKeyWordsResult getTitleKeyWords(String accessToken, String tId) { + WxResult wxResult = wxMaSubscribeService.getPubTemplateKeywords(accessToken, tId); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + return wxResult.getData(); + } + + public void sync(InitFormDTO formDTO) { + AuthorizationInfoDTO resiAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "resi"); + if (null == resiAuthDTO) { + throw new RenException("居民端未授权"); + } + AuthorizationInfoDTO workAuthDTO = authorizationInfoDao.getAuthInfoByCustomer(formDTO.getCustomerId(), "work"); + if (null == workAuthDTO) { + throw new RenException("工作端未授权"); + } + //居民端初始化 + List resiList = personalTemplateService.getListByAppId(formDTO.getResiAppId()); + if (null != resiList && resiList.size() > 0) { + resiList.forEach(templateDTO -> { + List keyIds = Arrays.asList(templateDTO.getKeyIds().split(",")); + List keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList()); + WxAddTemplateReq request = new WxAddTemplateReq(); + request.setTid(templateDTO.getTid()); + request.setKidList(keyIdList); + request.setSceneDesc(templateDTO.getSceneDesc()); + WxResult wxResult = wxMaSubscribeService.addTemplate(resiAuthDTO.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + String tmplId = wxResult.getData(); + PersonalTemplateDTO personalTemplate = ConvertUtils.sourceToTarget(templateDTO, PersonalTemplateDTO.class); + personalTemplate.setPriTmplId(tmplId); + personalTemplate.setCustomerId(formDTO.getCustomerId()); + personalTemplate.setClientType("resi"); + personalTemplate.setAppId(resiAuthDTO.getAuthorizerAppid()); + personalTemplateService.save(personalTemplate); + }); + } + //工作端初始化 + List workList = personalTemplateService.getListByAppId(formDTO.getWorkAppId()); + if (null != workList && workList.size() > 0) { + workList.forEach(templateDTO -> { + List keyIds = Arrays.asList(templateDTO.getKeyIds().split(",")); + List keyIdList = keyIds.stream().map(Integer::parseInt).collect(Collectors.toList()); + WxAddTemplateReq request = new WxAddTemplateReq(); + request.setTid(templateDTO.getTid()); + request.setKidList(keyIdList); + request.setSceneDesc(templateDTO.getSceneDesc()); + WxResult wxResult = wxMaSubscribeService.addTemplate(workAuthDTO.getAuthorizerAccessToken(), request); + if (!wxResult.success()) { + throw new RenException(wxResult.getErrorCode(), wxResult.getErrorMsg()); + } + String tmplId = wxResult.getData(); + PersonalTemplateDTO personalTemplate = ConvertUtils.sourceToTarget(templateDTO, PersonalTemplateDTO.class); + personalTemplate.setPriTmplId(tmplId); + personalTemplate.setCustomerId(formDTO.getCustomerId()); + personalTemplate.setClientType("work"); + personalTemplate.setAppId(workAuthDTO.getAuthorizerAppid()); + personalTemplateService.save(personalTemplate); + }); + } + } + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxSubscribeConstant.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxSubscribeConstant.java new file mode 100644 index 0000000000..e0c27129b5 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/constant/WxSubscribeConstant.java @@ -0,0 +1,38 @@ +package com.epmet.wxapi.constant; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 10:34 + */ +public interface WxSubscribeConstant { + /** + * 获取当前帐号所设置的类目信息 + */ + String GET_CATEGORY_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/getcategory"; + + /** + * 获取模板标题列表 + */ + String GET_PUB_TEMPLATE_TITLES_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatetitles"; + + /** + * 获取模板标题下的关键词库 + */ + String GET_KEY_WORDS_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/getpubtemplatekeywords"; + + /** + * 组合模板并添加到个人模板库 + */ + String ADD_TEMPLATE_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/addtemplate"; + + /** + * 获取帐号下的模板列表 + */ + String GET_TEMPLATE_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate"; + + /** + * 删除帐号下的某个模板 + */ + String DEL_TEMPLATE_URL = "https://api.weixin.qq.com/wxaapi/newtmpl/deltemplate"; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java index 23e1077e7c..29e341df7a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/enums/WxMaErrorMsgEnum.java @@ -519,6 +519,26 @@ public enum WxMaErrorMsgEnum { CODE_43101(43101, "用户拒绝接受消息,如果用户之前曾经订阅过,则表示用户取消了订阅关系"), CODE_47003(47003, "模板参数不准确,可能为空或者不满足规则,errmsg会提示具体是哪个字段出错"), + + CODE_200011(200011, "此账号已被封禁,无法操作"), + + CODE_200012(200012, "个人模板数已达上限,上限25个"), + + CODE_200013(200013, "此模板已被封禁,无法选用"), + + CODE_200014(200014, "模板 tid 参数错误"), + + CODE_200016(200016, "start 参数错误"), + + CODE_200017(200017, "limit 参数错误"), + + CODE_200018(200018, "类目 ids 缺失"), + + CODE_200019(200019, "类目 ids 不合法"), + + CODE_200020(200020, "关键词列表 kidList 参数错误"), + + CODE_200021(200021, "场景描述 sceneDesc 参数错误"), ; private int code; diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxAddTemplateReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxAddTemplateReq.java new file mode 100644 index 0000000000..ae083f7702 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxAddTemplateReq.java @@ -0,0 +1,31 @@ +package com.epmet.wxapi.param; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 9:33 + */ +@NoArgsConstructor +@Data +public class WxAddTemplateReq implements Serializable { + + private static final long serialVersionUID = -9163397048982502051L; + /** + * 模板标题 id + */ + private String tid; + /** + * 关键词id + */ + private String sceneDesc; + /** + * 服务场景描述,15个字以内 + */ + private List kidList; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxDelTemplateReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxDelTemplateReq.java new file mode 100644 index 0000000000..4bb8be5958 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxDelTemplateReq.java @@ -0,0 +1,22 @@ +package com.epmet.wxapi.param; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 9:43 + */ +@NoArgsConstructor +@Data +public class WxDelTemplateReq implements Serializable { + + private static final long serialVersionUID = 195634574947498628L; + /** + * 要删除的模板id + */ + private String priTmplId; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxSubTemplateReq.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxSubTemplateReq.java new file mode 100644 index 0000000000..48ac4c482e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxSubTemplateReq.java @@ -0,0 +1,30 @@ +package com.epmet.wxapi.param; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/8 16:30 + */ +@NoArgsConstructor +@Data +public class WxSubTemplateReq implements Serializable { + private static final long serialVersionUID = 4133480686759651875L; + + /** + * 类目 id,多个用逗号隔开 + */ + private String ids; + /** + * 用于分页,表示从 start 开始。从 0 开始计数 + */ + private Integer start; + /** + * 用于分页,表示拉取 limit 条记录。最大为 30 + */ + private Integer limit; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetCategoryResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetCategoryResult.java new file mode 100644 index 0000000000..085b9e3a1d --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetCategoryResult.java @@ -0,0 +1,41 @@ +package com.epmet.wxapi.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/8 16:03 + */ +@NoArgsConstructor +@Data +public class WxGetCategoryResult implements Serializable { + + private static final long serialVersionUID = 6785111976796640604L; + /** + * 错误码 + */ + private Integer errcode; + /** + * 错误信息 + */ + private String errmsg; + /** + * 类目列表 + */ + private List data; + + @NoArgsConstructor + @Data + public static class DataBean { + /** + * id : 616 + */ + private Integer id; + private String name; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetTemplateResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetTemplateResult.java new file mode 100644 index 0000000000..c6a4101ea7 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxGetTemplateResult.java @@ -0,0 +1,56 @@ +package com.epmet.wxapi.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/9 9:36 + */ +@NoArgsConstructor +@Data +public class WxGetTemplateResult implements Serializable { + + private static final long serialVersionUID = 1796638032203448934L; + /** + * 错误码 + */ + private Integer errcode; + /** + * 错误信息 + */ + private String errmsg; + /** + * 个人模板列表 + */ + private List data; + + @NoArgsConstructor + @Data + public static class DataBean { + /** + * 添加至帐号下的模板 id + */ + private String priTmplId; + /** + * 模板标题 + */ + private String title; + /** + * 模板内容 + */ + private String content; + /** + * 模板内容示例 + */ + private String example; + /** + * 模板类型,2 代表一次性订阅,3 代表长期订阅 + */ + private Integer type; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxKeyWordsResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxKeyWordsResult.java new file mode 100644 index 0000000000..fca92e0b42 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxKeyWordsResult.java @@ -0,0 +1,52 @@ +package com.epmet.wxapi.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/8 16:42 + */ +@NoArgsConstructor +@Data +public class WxKeyWordsResult implements Serializable { + + private static final long serialVersionUID = -7867379425609113193L; + /** + * 错误码 + */ + private Integer errcode; + /** + * 错误信息 + */ + private String errmsg; + /** + * 关键词列表 + */ + private List data; + + @NoArgsConstructor + @Data + public static class DataBean { + /** + * 关键词 id + */ + private Integer kid; + /** + * 关键词内容 + */ + private String name; + /** + * 关键词内容对应的示例 + */ + private String example; + /** + * 参数类型 + */ + private String rule; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxSubTemplateResult.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxSubTemplateResult.java new file mode 100644 index 0000000000..db5989187e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/result/WxSubTemplateResult.java @@ -0,0 +1,56 @@ +package com.epmet.wxapi.result; + +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/8 16:12 + */ +@NoArgsConstructor +@Data +public class WxSubTemplateResult implements Serializable { + + private static final long serialVersionUID = 5581168509440371239L; + /** + * 错误码 + */ + private Integer errcode; + /** + * 错误信息 + */ + private String errmsg; + /** + * 列表总数 + */ + private Integer count; + /** + * 标题列表 + */ + private List data; + + @NoArgsConstructor + @Data + public static class DataBean { + /** + * 模板标题 id + */ + private Integer tid; + /** + * 模板标题 + */ + private String title; + /** + * 模板类型,2 为一次性订阅,3 为长期订阅 + */ + private Integer type; + /** + * 模板所属类目 id + */ + private String categoryId; + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaSubscribeService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaSubscribeService.java new file mode 100644 index 0000000000..6f426b0c0e --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/WxMaSubscribeService.java @@ -0,0 +1,78 @@ +package com.epmet.wxapi.service; + +import com.epmet.wxapi.param.WxAddTemplateReq; +import com.epmet.wxapi.param.WxDelTemplateReq; +import com.epmet.wxapi.param.WxSubTemplateReq; +import com.epmet.wxapi.result.*; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/8 15:55 + */ +public interface WxMaSubscribeService { + + /** + * 获取当前帐号所设置的类目信息 + * + * @param accessToken + * @return com.epmet.wxapi.result.WxResult + * @author zhaoqifeng + * @date 2020/9/8 16:06 + */ + WxResult getCategory(String accessToken); + + /** + * 获取模板标题列表 + * + * @param accessToken + * @param request + * @return com.epmet.wxapi.result.WxSubTemplateResult + * @author zhaoqifeng + * @date 2020/9/8 16:34 + */ + WxResult getPubTemplateTitles(String accessToken, WxSubTemplateReq request); + + /** + * 获取模板标题下的关键词库 + * + * @param accessToken + * @param tId + * @return com.epmet.wxapi.result.WxResult + * @author zhaoqifeng + * @date 2020/9/8 16:45 + */ + WxResult getPubTemplateKeywords(String accessToken, String tId); + + /** + * 组合模板并添加到个人模板库 + * + * @param accessToken + * @param request + * @return com.epmet.wxapi.result.WxResult + * @author zhaoqifeng + * @date 2020/9/9 9:35 + */ + WxResult addTemplate(String accessToken, WxAddTemplateReq request); + + /** + * 获取帐号下的模板列表 + * + * @param accessToken + * @return com.epmet.wxapi.result.WxResult + * @author zhaoqifeng + * @date 2020/9/9 9:42 + */ + WxResult getTemplate(String accessToken); + + /** + * 删除帐号下的某个模板 + * + * @param accessToken + * @param request + * @return com.epmet.wxapi.result.WxResult + * @author zhaoqifeng + * @date 2020/9/9 9:44 + */ + WxResult delTemplate(String accessToken, WxDelTemplateReq request); +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaSubscribeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaSubscribeServiceImpl.java new file mode 100644 index 0000000000..6826f70fd2 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/service/impl/WxMaSubscribeServiceImpl.java @@ -0,0 +1,146 @@ +package com.epmet.wxapi.service.impl; + +import com.alibaba.fastjson.JSONObject; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.wxapi.constant.WxSubscribeConstant; +import com.epmet.wxapi.enums.WxMaErrorMsgEnum; +import com.epmet.wxapi.param.WxAddTemplateReq; +import com.epmet.wxapi.param.WxDelTemplateReq; +import com.epmet.wxapi.param.WxSubTemplateReq; +import com.epmet.wxapi.result.*; +import com.epmet.wxapi.service.WxMaSubscribeService; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import org.springframework.stereotype.Service; + +/** + * @author zhaoqifeng + * @dscription + * @date 2020/9/8 15:56 + */ +@Service +public class WxMaSubscribeServiceImpl implements WxMaSubscribeService { + + private static final String ERR_CODE = "errcode"; + private static final String ERR_MSG = "errmsg"; + + @Override + public WxResult getCategory(String accessToken) { + WxResult result = new WxResult<>(); + String url = WxSubscribeConstant.GET_CATEGORY_URL + "?" + "access_token=" + accessToken; + + Result httpResult = HttpClientManager.getInstance().sendGet(url, null); + if (!httpResult.success()) { + result.setErrorCode(httpResult.getCode()); + result.setErrorMsg(httpResult.getMsg()); + return result; + } + Gson gson = new Gson(); + WxGetCategoryResult getCategoryResult = gson.fromJson(httpResult.getData(), WxGetCategoryResult.class); + result.setErrorCode(getCategoryResult.getErrcode()); + result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(getCategoryResult.getErrcode())); + result.setData(getCategoryResult); + return result; + } + + @Override + public WxResult getPubTemplateTitles(String accessToken, WxSubTemplateReq request) { + WxResult result = new WxResult<>(); + String url = WxSubscribeConstant.GET_PUB_TEMPLATE_TITLES_URL + "?" + "access_token=" + accessToken + "&ids=" + request.getIds() + + "&start=" + request.getStart() + "&limit=" + request.getLimit(); + + Result httpResult = HttpClientManager.getInstance().sendGet(url, null); + if (!httpResult.success()) { + result.setErrorCode(httpResult.getCode()); + result.setErrorMsg(httpResult.getMsg()); + return result; + } + Gson gson = new Gson(); + WxSubTemplateResult subTemplateResult = gson.fromJson(httpResult.getData(), WxSubTemplateResult.class); + result.setErrorCode(subTemplateResult.getErrcode()); + result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(subTemplateResult.getErrcode())); + result.setData(subTemplateResult); + return result; + } + + @Override + public WxResult getPubTemplateKeywords(String accessToken, String tId) { + WxResult result = new WxResult<>(); + String url = WxSubscribeConstant.GET_KEY_WORDS_URL + "?" + "access_token=" + accessToken + "&tid=" + tId; + + Result httpResult = HttpClientManager.getInstance().sendGet(url, null); + if (!httpResult.success()) { + result.setErrorCode(httpResult.getCode()); + result.setErrorMsg(httpResult.getMsg()); + return result; + } + Gson gson = new Gson(); + WxKeyWordsResult keyWordsResult = gson.fromJson(httpResult.getData(), WxKeyWordsResult.class); + result.setErrorCode(keyWordsResult.getErrcode()); + result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(keyWordsResult.getErrcode())); + result.setData(keyWordsResult); + return result; + } + + @Override + public WxResult addTemplate(String accessToken, WxAddTemplateReq request) { + WxResult result = new WxResult<>(); + String url = WxSubscribeConstant.ADD_TEMPLATE_URL + "?" + "access_token=" + accessToken; + + Result httpResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); + if (!httpResult.success()) { + result.setErrorCode(httpResult.getCode()); + result.setErrorMsg(httpResult.getMsg()); + return result; + } + JSONObject jsonObject = JSONObject.parseObject(httpResult.getData()); + result.setErrorCode(jsonObject.getInteger(ERR_CODE)); + result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); + result.setData(jsonObject.getString("priTmplId")); + return result; + } + + @Override + public WxResult getTemplate(String accessToken) { + WxResult result = new WxResult<>(); + String url = WxSubscribeConstant.GET_TEMPLATE_URL + "?" + "access_token=" + accessToken; + + Result httpResult = HttpClientManager.getInstance().sendGet(url, null); + if (!httpResult.success()) { + result.setErrorCode(httpResult.getCode()); + result.setErrorMsg(httpResult.getMsg()); + return result; + } + Gson gson = new Gson(); + WxGetTemplateResult templateResult = gson.fromJson(httpResult.getData(), WxGetTemplateResult.class); + result.setErrorCode(templateResult.getErrcode()); + result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(templateResult.getErrcode())); + result.setData(templateResult); + return result; + } + + @Override + public WxResult delTemplate(String accessToken, WxDelTemplateReq request) { + WxResult result = new WxResult<>(); + String url = WxSubscribeConstant.DEL_TEMPLATE_URL + "?" + "access_token=" + accessToken; + + Result httpResult = HttpClientManager.getInstance().sendPostByJSON(url, toJson(request)); + if (!httpResult.success()) { + result.setErrorCode(httpResult.getCode()); + result.setErrorMsg(httpResult.getMsg()); + return result; + } + JSONObject jsonObject = JSONObject.parseObject(httpResult.getData()); + result.setErrorCode(jsonObject.getInteger(ERR_CODE)); + result.setErrorMsg(WxMaErrorMsgEnum.findMsgByCode(jsonObject.getInteger(ERR_CODE))); + return result; + } + + private String toJson(Object object) { + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.setPrettyPrinting(); + Gson gson = gsonBuilder.create(); + return gson.toJson(object); + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.10__thirdUpdate.sql b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.10__thirdUpdate.sql new file mode 100644 index 0000000000..ebf69013cf --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/db/migration/V0.0.10__thirdUpdate.sql @@ -0,0 +1,36 @@ +CREATE TABLE `personal_template` ( + `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `CUSTOMER_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `CLIENT_TYPE` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `APP_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `PID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `PRI_TMPL_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `TYPE` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `TID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `TITLE` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `KEY_IDS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `KEY_WORDS` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `SCENE_DESC` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `REVISION` int(11) NULL DEFAULT NULL, + `DEL_FLAG` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `CREATED_TIME` datetime(0) NULL DEFAULT NULL, + `UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `UPDATED_TIME` datetime(0) NULL DEFAULT NULL, + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; + +CREATE TABLE `public_template` ( + `ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `TID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `TITLE` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `TYPE` varchar(2) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `CATEGORY_ID` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `REVISION` int(11) NULL DEFAULT NULL, + `DEL_FLAG` varchar(11) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `CREATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `CREATED_TIME` datetime(0) NULL DEFAULT NULL, + `UPDATED_BY` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL, + `UPDATED_TIME` datetime(0) NULL DEFAULT NULL, + PRIMARY KEY (`ID`) USING BTREE +) ENGINE = InnoDB CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci ROW_FORMAT = Dynamic; \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml index 77e38472e8..f2cbc173f7 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/AuthorizationInfoDao.xml @@ -132,5 +132,16 @@ DEL_FLAG = '0' AND CUSTOMER_ID = #{customerId} + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml index 11d1b50262..9926104565 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PaCustomerDao.xml @@ -196,4 +196,16 @@ AND SOURCE = #{source} + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml new file mode 100644 index 0000000000..4218ef19f4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PublicTemplateDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PublicTemplateDao.xml new file mode 100644 index 0000000000..a1baf39ef4 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PublicTemplateDao.xml @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + DELETE FROM public_template WHERE 1=1 + + CATEGORY_ID = #{item} + + + + + + \ No newline at end of file From c5640fa902964391ed0290915d26d16698d32386 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Mon, 14 Sep 2020 17:39:19 +0800 Subject: [PATCH 02/13] =?UTF-8?q?Ext=5FJson=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/service/impl/CodeServiceImpl.java | 16 +++++++++++----- .../java/com/epmet/wxapi/param/WxExtJson.java | 16 ++++++++++++++-- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java index 9a5640f22d..781a8a40d4 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/CodeServiceImpl.java @@ -15,6 +15,7 @@ import com.epmet.dao.MiniInfoDao; import com.epmet.dto.*; import com.epmet.dto.form.*; import com.epmet.dto.result.*; +import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.feign.OssFeignClient; import com.epmet.service.*; import com.epmet.wxapi.param.*; @@ -68,6 +69,8 @@ public class CodeServiceImpl implements CodeService { private PaCustomerService paCustomerService; @Autowired private MiniInfoDao miniInfoDao; + @Autowired + private OperCrmOpenFeignClient operCrmOpenFeignClient; @Override public List templateList() { @@ -97,11 +100,7 @@ public class CodeServiceImpl implements CodeService { @Override public String getExtJson(CodeUploadFormDTO formDTO) { - CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); - if (null == codeExtDTO) { - return codeExtService.getExtTemplate(formDTO.getClientType()); - } - return codeExtDTO.getExtJson(); + return codeExtService.getExtTemplate(formDTO.getClientType()); } @@ -118,6 +117,12 @@ public class CodeServiceImpl implements CodeService { if (null == authInfo) { throw new RenException("未授权"); } + CustomerDTO customerFormDTO = new CustomerDTO(); + customerFormDTO.setId(formDTO.getCustomerId()); + Result result = operCrmOpenFeignClient.getCustomerInfo(customerFormDTO); + if (!result.success()) { + throw new RenException(result.getCode(), result.getMsg()); + } //获取小程序居民端与工作端名称 String resiName = miniInfoDao.getNickName(formDTO.getCustomerId(), "resi"); String workName = miniInfoDao.getNickName(formDTO.getCustomerId(), "work"); @@ -127,6 +132,7 @@ public class CodeServiceImpl implements CodeService { wxExtJson.getExt().setExtAppid(authInfo.getAuthorizerAppid()); wxExtJson.getExt().setResiName(resiName); wxExtJson.getExt().setWorkName(workName); + wxExtJson.getExt().setCustomerName(null == result.getData().getCustomerName()?"":result.getData().getCustomerName()); extJson = JSON.toJSONString(wxExtJson); CodeExtDTO codeExtDTO = codeExtService.getExtByCustomer(formDTO.getCustomerId(), formDTO.getClientType()); if (null == codeExtDTO) { diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java index 4ba45e37cf..6a22908d9b 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/wxapi/param/WxExtJson.java @@ -24,6 +24,8 @@ public class WxExtJson implements Serializable { private boolean directCommit; @JSONField(ordinal = 4) private ExtBean ext; + @JSONField(ordinal = 5) + private WindowBean window; @NoArgsConstructor @Data @@ -31,10 +33,12 @@ public class WxExtJson implements Serializable { @JSONField(ordinal = 1) private String extAppid; @JSONField(ordinal = 2) - private String resiName; + private String customerName; @JSONField(ordinal = 3) - private String workName; + private String resiName; @JSONField(ordinal = 4) + private String workName; + @JSONField(ordinal = 5) private FootbarBean footbar; @NoArgsConstructor @Data @@ -119,4 +123,12 @@ public class WxExtJson implements Serializable { } } } + + @NoArgsConstructor + @Data + public static class WindowBean { + @JSONField(ordinal = 1) + private String navigationBarTitleText; + } + } From 232d5e4e4034cd60ead1b81c722d61176e791bb9 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 15 Sep 2020 09:48:58 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/service/impl/SubscribeServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java index 7443a16d90..b8ddb28343 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java @@ -206,7 +206,7 @@ public class SubscribeServiceImpl implements SubscribeService { customerNames.add(paCustomerDTO.getCustomerName()); continue; } - WxResult wxResult1 = wxMaSubscribeService.addTemplate(authInfo.getAuthorizerAccessToken(), request); + WxResult wxResult1 = wxMaSubscribeService.addTemplate(authDTO.getAuthorizerAccessToken(), request); if (!wxResult1.success()) { log.error("客户[" + paCustomerDTO.getCustomerName() + "]添加模板失败,原因:" + wxResult1.getErrorCode() + wxResult1.getErrorMsg()); customerNames.add(paCustomerDTO.getCustomerName()); @@ -214,7 +214,7 @@ public class SubscribeServiceImpl implements SubscribeService { } String tmplId = wxResult1.getData(); PersonalTemplateDTO templateDTO = new PersonalTemplateDTO(); - templateDTO.setCustomerId(authInfo.getCustomerId()); + templateDTO.setCustomerId(paCustomerDTO.getId()); templateDTO.setClientType(authInfo.getClientType()); templateDTO.setAppId(authDTO.getAuthorizerAppid()); templateDTO.setPid(priTmplId); From d4881878905609454a9d19feb4523e3bb37b40b3 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Tue, 15 Sep 2020 10:29:08 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E8=AE=A2=E9=98=85=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/dto/result/TemplateDTO.java | 6 +++++- .../java/com/epmet/service/impl/SubscribeServiceImpl.java | 4 ++-- .../src/main/resources/mapper/PersonalTemplateDao.xml | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java index b9c43fb0d3..0229316e01 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/TemplateDTO.java @@ -15,7 +15,11 @@ public class TemplateDTO implements Serializable { /** * 模板ID */ - private String priTmplId; + private String id; + /** + * 模板ID + */ + private String tmplId; /** * 标题 */ diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java index b8ddb28343..1521aa508a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/SubscribeServiceImpl.java @@ -331,7 +331,7 @@ public class SubscribeServiceImpl implements SubscribeService { List resiPubTmplIds = wxResiResult.getData().getData().stream().map(WxGetTemplateResult.DataBean::getPriTmplId).collect(Collectors.toList()); List resiList = personalTemplateService.getListByCustomer(formDTO.getResiAppId(), formDTO.getCustomerId(), "resi"); - List resiTmplIds = resiList.stream().map(TemplateDTO::getPriTmplId).collect(Collectors.toList()); + List resiTmplIds = resiList.stream().map(TemplateDTO::getTmplId).collect(Collectors.toList()); List resiReduce = resiPubTmplIds.stream().filter(item -> !resiTmplIds.contains(item)).collect(Collectors.toList()); resiReduce.forEach(tmplId -> { WxDelTemplateReq request = new WxDelTemplateReq(); @@ -354,7 +354,7 @@ public class SubscribeServiceImpl implements SubscribeService { List workPubTmplIds = wxWorkResult.getData().getData().stream().map(WxGetTemplateResult.DataBean::getPriTmplId).collect(Collectors.toList()); List workList = personalTemplateService.getListByCustomer(formDTO.getWorkAppId(), formDTO.getCustomerId(), "work"); - List workTmplIds = workList.stream().map(TemplateDTO::getPriTmplId).collect(Collectors.toList()); + List workTmplIds = workList.stream().map(TemplateDTO::getTmplId).collect(Collectors.toList()); List workReduce = workPubTmplIds.stream().filter(item -> !workTmplIds.contains(item)).collect(Collectors.toList()); workReduce.forEach(tmplId -> { WxDelTemplateReq request = new WxDelTemplateReq(); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml index 4218ef19f4..f3b46b3c42 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/PersonalTemplateDao.xml @@ -46,7 +46,8 @@ + + diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java index de4de9ed21..490b2445e8 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppJwtTokenUtils.java @@ -75,13 +75,23 @@ public class ExtAppJwtTokenUtils { public static void genToken() { HashMap claim = new HashMap<>(); - claim.put("appId", "acc4ad66c82a7b46e741364b4c62dce2"); - claim.put("customerId", "b09527201c4409e19d1dbc5e3c3429a1"); + //市北 + //String secret = "612d304095c50369c3ef06e490f05779eeb8f19ff16566c73aeafafc5fa01970"; + //String appId = "acc4ad66c82a7b46e741364b4c62dce2"; + // String customrId = "b09527201c4409e19d1dbc5e3c3429a1"; + //孔村 + String secret = "657cd46d385a4c2ba6d9355aee24654ac3951deab7e6436e91201561b94969b5"; + String appId = "5efcfb775125d656f39583b8110a3d7d"; + String customrId = "2fe0065f70ca0e23ce4c26fca5f1d933"; + + claim.put("customerId", customrId); + claim.put("appId", appId); + claim.put("customerId", customrId); long ts = System.currentTimeMillis() - 1000 * 60 * 4; System.out.println("时间戳:" + ts); claim.put("ts", ts); - String abc = new ExtAppJwtTokenUtils().createToken(claim, "612d304095c50369c3ef06e490f05779eeb8f19ff16566c73aeafafc5fa01970"); + String abc = new ExtAppJwtTokenUtils().createToken(claim, secret); System.out.println(abc); } From 846bd0469de2391d023ea854b1167fdf085cb6cb Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 18 Sep 2020 13:34:47 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extappauth/aspect/ExternalAppRequestAuthAspect.java | 4 +++- .../com/epmet/utils/externalapp/ExtAppMD5AuthProcessor.java | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java b/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java index ec98b35d7b..5585cfaa79 100644 --- a/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java +++ b/epmet-commons/epmet-commons-extapp-auth/src/main/java/com/epmet/commons/extappauth/aspect/ExternalAppRequestAuthAspect.java @@ -1,6 +1,7 @@ package com.epmet.commons.extappauth.aspect; +import com.alibaba.fastjson.JSON; import com.epmet.commons.extappauth.bean.ExternalAppRequestParam; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; @@ -96,7 +97,8 @@ public class ExternalAppRequestAuthAspect { if (parameters[i].getType() == ExternalAppRequestParam.class) { ExternalAppRequestParam requestParam = (ExternalAppRequestParam) point.getArgs()[i]; requestParam.setAppId(appId); - requestParam.setCustomerId(authResult.getCustomerId() == null ? customerId : authResult.getCustomerId()); + requestParam.setCustomerId(StringUtils.isBlank(authResult.getCustomerId()) ? customerId : authResult.getCustomerId()); + logger.info("auth ExternalAppRequestParam:{}", JSON.toJSONString(requestParam)); } } } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppMD5AuthProcessor.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppMD5AuthProcessor.java index b19e963f53..0ec71dc38f 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppMD5AuthProcessor.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/utils/externalapp/ExtAppMD5AuthProcessor.java @@ -15,6 +15,7 @@ public class ExtAppMD5AuthProcessor extends ExtAppAuthProcessor { private static Logger logger = LoggerFactory.getLogger(ExtAppMD5AuthProcessor.class); + @Override public ExternalAppAuthResultDTO auth(String appId, String token, Long ts) { if (ts == null) { return fillAuthResult(false, "需要传入时间戳参数", null); From 12e721b9fed4154a919ce98d27e9dd6007d1f6a0 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 18 Sep 2020 14:31:14 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/datareport/controller/screen/IndexController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java index 388ce0a1c1..f2a7ebd151 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java @@ -104,8 +104,8 @@ public class IndexController { @ExternalAppRequestAuth @PostMapping("gridindexrank") public Result> gridIndexRank(ExternalAppRequestParam extParam, @RequestBody GridIndexRankFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO); formDTO.setCustomerId(extParam.getCustomerId()); + ValidatorUtils.validateEntity(formDTO); formDTO.setOrgType(OrgTypeEnum.GRID.getCode()); return new Result>().ok(indexService.selectIndexRankByOrgType(formDTO)); } From a1c121afe363f3f027cf2cd8f396494c0319e412 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Mon, 21 Sep 2020 09:58:31 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E5=AD=94=E6=9D=91=E5=A4=A7=E5=B1=8F?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=BF=94=E5=8F=82=E8=B0=83=E6=95=B4=20?= =?UTF-8?q?=E6=B3=A8=E9=87=8A=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../GroupTopicShiftIssueRatioRankResultDTO.java | 4 ++-- .../controller/screen/KcScreenController.java | 2 +- .../screenkc/ScreenKcGroupDetailGridDailyDao.java | 2 +- .../evaluationindex/screen/KcScreenService.java | 2 +- .../screen/impl/KcScreenServiceImpl.java | 6 +++--- .../screenkc/ScreenKcGroupDetailGridDailyDao.xml | 14 +++++++------- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GroupTopicShiftIssueRatioRankResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GroupTopicShiftIssueRatioRankResultDTO.java index d1068120bf..e4677c0e5d 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GroupTopicShiftIssueRatioRankResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/GroupTopicShiftIssueRatioRankResultDTO.java @@ -22,9 +22,9 @@ public class GroupTopicShiftIssueRatioRankResultDTO implements Serializable { */ private String groupName = ""; /** - * 话题数量 + * 转为议题的话题数 */ - private Integer topicCount = 0; + private Integer shifitIssueCount = 0; /** * 群主名称 */ diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/KcScreenController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/KcScreenController.java index db794ca26b..210c950e78 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/KcScreenController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/KcScreenController.java @@ -210,7 +210,7 @@ public class KcScreenController { /** * @param externalAppRequestParam - * @Description 邻里党群-话题数量排名 + * @Description 邻里党群-话题转化率排名 * @author sun */ @ExternalAppRequestAuth diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screenkc/ScreenKcGroupDetailGridDailyDao.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screenkc/ScreenKcGroupDetailGridDailyDao.java index 23e6e5afbd..834a64c0ee 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screenkc/ScreenKcGroupDetailGridDailyDao.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screenkc/ScreenKcGroupDetailGridDailyDao.java @@ -43,7 +43,7 @@ public interface ScreenKcGroupDetailGridDailyDao { /** * @param formDTO - * @Description 按客户查询最近一天所有网格数据 再按话题总数降序排列 + * @Description 按客户查询最近一天所有网格数据 再按转议题数量降序排列 * @author sun */ List selectGroupTopicShiftIssueRatioRankList(GroupTopicShiftIssueRatioRankFormDTO formDTO); diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/KcScreenService.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/KcScreenService.java index f40e8517ae..d17df56ba1 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/KcScreenService.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/KcScreenService.java @@ -96,7 +96,7 @@ public interface KcScreenService { /** * @param formDTO - * @Description 邻里党群-话题数量排名 + * @Description 邻里党群-话题转化率排名 * @author sun */ List groupTopicShiftIssueRatioRank(GroupTopicShiftIssueRatioRankFormDTO formDTO); diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/KcScreenServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/KcScreenServiceImpl.java index 661a43306a..b82d6b654f 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/KcScreenServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/KcScreenServiceImpl.java @@ -300,21 +300,21 @@ public class KcScreenServiceImpl implements KcScreenService { public List groupUserCountRank(GroupUserCountRankFormDTO formDTO) { int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); formDTO.setPageNo(pageIndex); - //按客户查询最近一天所有网格数据 再按社群总数降序排列 + //按客户查询最近一天所有网格数据 再按照群内成员数降序 List list = screenKcGroupDetailGridDailyDao.selectGroupUserCountRankList(formDTO); return list; } /** * @param formDTO - * @Description 邻里党群-话题数量排名 + * @Description 邻里党群-话题转化率排名 * @author sun */ @Override public List groupTopicShiftIssueRatioRank(GroupTopicShiftIssueRatioRankFormDTO formDTO) { int pageIndex = (formDTO.getPageNo() - NumConstant.ONE) * formDTO.getPageSize(); formDTO.setPageNo(pageIndex); - //按客户查询最近一天所有网格数据 再按话题总数降序排列 + //按客户查询最近一天所有网格数据 再按转议题数量降序排列 List list = screenKcGroupDetailGridDailyDao.selectGroupTopicShiftIssueRatioRankList(formDTO); return list; } diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screenkc/ScreenKcGroupDetailGridDailyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screenkc/ScreenKcGroupDetailGridDailyDao.xml index c0d3133d95..76db75d09f 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screenkc/ScreenKcGroupDetailGridDailyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screenkc/ScreenKcGroupDetailGridDailyDao.xml @@ -5,8 +5,8 @@ From b997ca7d9d786029c57dc2f6b4590b476846f027 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Mon, 21 Sep 2020 10:12:18 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E7=9B=B8=E5=85=B3=20?= =?UTF-8?q?=E5=85=9A=E5=BB=BA=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extract/result/PartyActiveResultDTO.java | 25 ++++++++++ .../extract/FactOriginIssueLogDailyDao.java | 11 +++++ .../extract/FactOriginTopicLogDailyDao.java | 11 +++++ .../FactOriginTopicLogDailyService.java | 11 +++++ .../extract/IssueExtractService.java | 11 +++++ .../extract/impl/CalGridIndexServiceImpl.java | 47 ++++++++++++++++++- .../FactOriginTopicLogDailyServiceImpl.java | 14 ++++++ .../extract/impl/IssueExtractServiceImpl.java | 13 +++++ .../extract/FactOriginIssueLogDailyDao.xml | 13 +++++ .../extract/FactOriginTopicLogDailyDao.xml | 13 +++++ 10 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/PartyActiveResultDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/PartyActiveResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/PartyActiveResultDTO.java new file mode 100644 index 0000000000..53bc3f2658 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/PartyActiveResultDTO.java @@ -0,0 +1,25 @@ +package com.epmet.dto.extract.result; + +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2020/9/21 9:35 上午 + */ +@Data +public class PartyActiveResultDTO implements Serializable { + + private static final long serialVersionUID = 4694666116463447613L; + + /** + * 网格ID + */ + private String gridId; + + /** + * 动作操作用户ID + */ + private String userId; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java index b7d86e4353..1e4ab97477 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginIssueLogDailyDao.java @@ -19,6 +19,7 @@ package com.epmet.dao.evaluationindex.extract; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.extract.form.IssueLogDailyFormDTO; +import com.epmet.dto.extract.result.PartyActiveResultDTO; import com.epmet.entity.evaluationindex.extract.FactOriginIssueLogDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -61,4 +62,14 @@ public interface FactOriginIssueLogDailyDao extends BaseDao selectPartyActiveIssueVote(@Param("customerId")String customerId,@Param("monthId") String monthId,@Param("isParty") Integer isParty); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java index ab43a21b2e..198625b577 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/extract/FactOriginTopicLogDailyDao.java @@ -18,6 +18,7 @@ package com.epmet.dao.evaluationindex.extract; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.extract.result.PartyActiveResultDTO; import com.epmet.entity.evaluationindex.extract.FactOriginTopicLogDailyEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -93,4 +94,14 @@ public interface FactOriginTopicLogDailyDao extends BaseDao selectTopicIds(@Param("list") List groupIdList); + + /** + * @Description 查询 话题评论【党员/群众】 + * @param customerId + * @param monthId + * @param isParty + * @author zxc + * @date 2020/9/21 9:37 上午 + */ + List selectPartyActiveTopic(@Param("customerId")String customerId,@Param("monthId") String monthId,@Param("isParty") Integer isParty); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginTopicLogDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginTopicLogDailyService.java index f5eb32bd09..3946572305 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginTopicLogDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginTopicLogDailyService.java @@ -19,6 +19,7 @@ package com.epmet.service.evaluationindex.extract; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.extract.result.PartyActiveResultDTO; import com.epmet.entity.evaluationindex.extract.FactOriginTopicLogDailyEntity; import java.util.List; @@ -71,4 +72,14 @@ public interface FactOriginTopicLogDailyService extends BaseService selectTopicIds(List groupIdList); + + /** + * @Description 查询 话题评论【党员/群众】 + * @param customerId + * @param monthId + * @param isParty + * @author zxc + * @date 2020/9/21 9:37 上午 + */ + List selectPartyActiveTopic(String customerId, String monthId,Integer isParty); } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/IssueExtractService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/IssueExtractService.java index 0b7ec04c48..45f9c1ff0a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/IssueExtractService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/IssueExtractService.java @@ -3,6 +3,7 @@ package com.epmet.service.evaluationindex.extract; import com.epmet.dto.extract.form.ExtractFormDTO; import com.epmet.dto.extract.form.GridIssueCountResultDTO; import com.epmet.dto.extract.result.GridProjectCountResultDTO; +import com.epmet.dto.extract.result.PartyActiveResultDTO; import com.epmet.dto.extract.result.ShiftProjectCountResultDTO; import java.util.List; @@ -90,4 +91,14 @@ public interface IssueExtractService { * @Date 2020/9/20 22:50 **/ Integer selectIssueTotalTwoMonth(List topicIdList); + + /** + * @Description 查询 议题表决【党员/群众】 + * @param customerId + * @param monthId + * @param isParty + * @author zxc + * @date 2020/9/21 9:37 上午 + */ + List selectPartyActiveIssueVote(String customerId, String monthId, Integer isParty); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java index 9fea4c2476..aa240d30aa 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/CalGridIndexServiceImpl.java @@ -33,7 +33,6 @@ import java.util.stream.Collectors; */ @Service @Slf4j -//@DataSource(DataSourceConstant.EVALUATION_INDEX) public class CalGridIndexServiceImpl implements CalGridIndexService { @Autowired @@ -56,6 +55,8 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { private FactArticlePublishedGridDailyService articlePublishedGridDailyService; @Autowired private GroupExtractService groupExtractService; + @Autowired + private FactOriginTopicLogDailyService topicLogService; /** * @Description 计算网格指标党建能力 @@ -88,6 +89,32 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { List gridIssueShiftProjectRatio = getGridIssueShiftProjectRatio(gridIssueTotalList, gridProjectTotalList); // 建群党员数 List partyCreateGroupCountList = groupExtractService.selectPartyCreateGroupCount(customerId, monthId); + //结合目前产品,数据来源:话题评论、议题表决 + //网格活跃群众用户数 + Map gridMassActiveMap = new HashMap<>(16); + List massActiveList = topicLogService.selectPartyActiveTopic(customerId, monthId, NumConstant.ZERO); + List massActiveIssueVote = issueExtractService.selectPartyActiveIssueVote(customerId, monthId, NumConstant.ZERO); + massActiveList.addAll(massActiveIssueVote); + if (!CollectionUtils.isEmpty(massActiveList)) { + Map> collectMap = massActiveList.stream().collect(Collectors.groupingBy(PartyActiveResultDTO::getGridId)); + collectMap.forEach((gridId, massActive) -> { + List userIds = massActive.stream().map(mass -> mass.getUserId()).distinct().collect(Collectors.toList()); + gridMassActiveMap.put(gridId, userIds.size()); + }); + } + //网格活跃党员用户数 + Map gridPartyActiveMap = new HashMap<>(16); + List partyActiveList = topicLogService.selectPartyActiveTopic(customerId, monthId, NumConstant.ONE); + List partyActiveIssueVote = issueExtractService.selectPartyActiveIssueVote(customerId, monthId, NumConstant.ONE); + partyActiveList.addAll(partyActiveIssueVote); + if (!CollectionUtils.isEmpty(partyActiveList)){ + Map> collectMap = massActiveList.stream().collect(Collectors.groupingBy(PartyActiveResultDTO::getGridId)); + collectMap.forEach((gridId, partyActive) -> { + List userIds = partyActive.stream().map(party -> party.getUserId()).distinct().collect(Collectors.toList()); + gridPartyActiveMap.put(gridId, userIds.size()); + }); + } + String quarterId = DateUtils.getQuarterId(monthId); String yearId = DateUtils.getYearId(monthId); result.forEach(r -> { @@ -158,6 +185,22 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { } }); } + // 9. 网格活跃群众用户数 + if (null != gridMassActiveMap){ + gridMassActiveMap.forEach((k,v) -> { + if (r.getGridId().equals(k)){ + r.setActiveUserCount(v); + } + }); + } + // 10. 网格活跃党员用户数 + if (null != gridPartyActiveMap){ + gridPartyActiveMap.forEach((k,v) -> { + if (r.getGridId().equals(k)){ + r.setActivePartyCount(v); + } + }); + } }); delAndInsertPartyAbility(result,customerId,monthId); return true; @@ -323,7 +366,7 @@ public class CalGridIndexServiceImpl implements CalGridIndexService { } /** - * @Description 小数四舍五入 + * @Description 小数四舍五入【保留六位小数】 * @param d * @author zxc * @date 2020/9/18 2:01 下午 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicLogDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicLogDailyServiceImpl.java index d1f1ed681a..e2f4b39e16 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicLogDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginTopicLogDailyServiceImpl.java @@ -21,6 +21,7 @@ import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.constant.DataSourceConstant; import com.epmet.dao.evaluationindex.extract.FactOriginTopicLogDailyDao; +import com.epmet.dto.extract.result.PartyActiveResultDTO; import com.epmet.entity.evaluationindex.extract.FactOriginTopicLogDailyEntity; import com.epmet.service.evaluationindex.extract.FactOriginTopicLogDailyService; import org.springframework.stereotype.Service; @@ -96,4 +97,17 @@ public class FactOriginTopicLogDailyServiceImpl extends BaseServiceImpl selectPartyActiveTopic(String customerId, String monthId, Integer isParty) { + return baseDao.selectPartyActiveTopic(customerId, monthId, isParty); + } } \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/IssueExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/IssueExtractServiceImpl.java index 78bb8a187c..2c6414b910 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/IssueExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/IssueExtractServiceImpl.java @@ -324,4 +324,17 @@ public class IssueExtractServiceImpl implements IssueExtractService { public Integer selectIssueTotalTwoMonth(List topicIdList) { return issueMainDailyDao.selectIssueTotalTwoMonth(topicIdList); } + + /** + * @Description 查询 议题表决【党员/群众】 + * @param customerId + * @param monthId + * @param isParty + * @author zxc + * @date 2020/9/21 9:37 上午 + */ + @Override + public List selectPartyActiveIssueVote(String customerId, String monthId, Integer isParty) { + return issueLogDailyDao.selectPartyActiveIssueVote(customerId, monthId, isParty); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml index 862f0488c5..1f62f10256 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginIssueLogDailyDao.xml @@ -78,4 +78,17 @@ T1.ACTION_CODE = 'vote_support' OR T1.ACTION_CODE = 'vote_opposition') + + + \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml index 848a0d733a..bbb25ff3ae 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/extract/FactOriginTopicLogDailyDao.xml @@ -128,4 +128,17 @@ T1.GROUP_ID =#{groupId} + + + \ No newline at end of file From 83d0b78762c5a3605f85a48634a2bed2f41471bf Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 21 Sep 2020 10:12:34 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E6=8C=87=E6=A0=87=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=8A=BD=E5=8F=96formDTO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/extract/form/ExtractIndexFormDTO.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/ExtractIndexFormDTO.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/ExtractIndexFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/ExtractIndexFormDTO.java new file mode 100644 index 0000000000..c188b64a57 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/form/ExtractIndexFormDTO.java @@ -0,0 +1,20 @@ +package com.epmet.dto.extract.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * desc:抽取指标数据 参数dto + */ +@Data +public class ExtractIndexFormDTO implements Serializable { + + + private static final long serialVersionUID = 1248641210655148366L; + + private String customerId; + + private String monthId; + +} From 10089700cdd9be0143a9510f90e8c0d5fb35dfb6 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 21 Sep 2020 10:33:54 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E6=8A=BD=E5=8F=96=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E7=BB=9F=E4=B8=80=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../feign/DataStatisticalOpenFeignClient.java | 22 +++ .../feign/FactExtractOpenFeignClient.java | 30 ---- ...ataStatisticalOpenFeignClientFallBack.java | 28 +++- .../FactExtractOpenFeignClientFallBack.java | 26 ++++ .../controller/FactOriginController.java | 135 ------------------ .../IndexOriginExtractController.java | 37 +++++ .../FactOriginProjectMainDailyService.java | 3 +- .../IndexOriginExtractService.java | 18 +++ .../impl/IndexOriginExtractServiceImpl.java | 105 ++++++++++++++ .../impl/FactOriginExtractServiceImpl.java | 1 + .../IndexOriginExtractTaskService.java | 24 ++++ .../FactOriginExtractTaskServiceImpl.java | 6 +- .../IndexOriginExtractTaskServiceImpl.java | 30 ++++ .../epmet/task/IndexOriginExtractTask.java | 38 +++++ 14 files changed, 332 insertions(+), 171 deletions(-) delete mode 100644 epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/FactExtractOpenFeignClient.java delete mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginController.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexOriginExtractController.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/IndexOriginExtractService.java create mode 100644 epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java create mode 100644 epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IndexOriginExtractTaskService.java create mode 100644 epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IndexOriginExtractTaskServiceImpl.java create mode 100644 epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/IndexOriginExtractTask.java diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java index 5d2892bfe0..ee35accdae 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/DataStatisticalOpenFeignClient.java @@ -3,6 +3,8 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StatsFormDTO; +import com.epmet.dto.extract.form.ExtractFormDTO; +import com.epmet.dto.extract.form.ExtractIndexFormDTO; import com.epmet.dto.group.form.GroupStatsFormDTO; import com.epmet.dto.issue.form.IssueJobFromDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; @@ -182,11 +184,31 @@ public interface DataStatisticalOpenFeignClient { */ @PostMapping("/data/stats/dim/statsparty") Result getPartyInfo(@RequestBody CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO); + /** * 处理暂停的计算 + * * @return */ @PostMapping("/data/stats/indexcalculate/process-pendding-cals") Result processPenddingCalculate(); + /** + * desc: 【日】抽取业务数据到统计库 小组 话题 议题 项目 + * + * @date: 2020/6/22 9:09 + * @author: jianjun liu + */ + @PostMapping(value = "data/stats/factorigin/extractall") + Result factOriginExtractAll(@RequestBody(required = false) ExtractFormDTO formDTO); + + /** + * desc: 【月】抽取统计数据到指标库 + * + * @date: 2020/6/22 9:09 + * @author: jianjun liu + */ + @PostMapping(value = "data/stats/indexorigin/extractall") + Result indexOriginExtractAll(@RequestBody(required = false) ExtractIndexFormDTO formDTO); + } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/FactExtractOpenFeignClient.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/FactExtractOpenFeignClient.java deleted file mode 100644 index 97bd66843c..0000000000 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/FactExtractOpenFeignClient.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.epmet.feign; - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.extract.form.ExtractFormDTO; -import com.epmet.feign.impl.FactExtractOpenFeignClientFallBack; -import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; - -/** - * desc: 数据抽取 对外feign client - * - * @return: - * @date: 2020/6/22 17:39 - * @author: jianjun liu - */ -@FeignClient(name = ServiceConstant.DATA_STATISTICAL_SERVER, fallback = FactExtractOpenFeignClientFallBack.class) -public interface FactExtractOpenFeignClient { - - /** - * desc: 【日】抽取业务数据到统计库 小组 话题 议题 项目 - * - * @date: 2020/6/22 9:09 - * @author: jianjun liu - */ - @PostMapping(value = "data/stats/factorigin/extractall") - Result extractall(@RequestBody(required = false) ExtractFormDTO formDTO); - -} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java index f14f0807cb..cec2bb3195 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/DataStatisticalOpenFeignClientFallBack.java @@ -4,6 +4,8 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StatsFormDTO; +import com.epmet.dto.extract.form.ExtractFormDTO; +import com.epmet.dto.extract.form.ExtractIndexFormDTO; import com.epmet.dto.group.form.GroupStatsFormDTO; import com.epmet.dto.issue.form.IssueJobFromDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; @@ -174,11 +176,35 @@ public class DataStatisticalOpenFeignClientFallBack implements DataStatisticalOp @Override public Result getPartyInfo(CustomerIdAndDateIdFormDTO customerIdAndDateIdFormDTO) { - return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "getPartyInfo",customerIdAndDateIdFormDTO); + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "getPartyInfo", customerIdAndDateIdFormDTO); } @Override public Result processPenddingCalculate() { return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "processPenddingCalculate"); } + + /** + * desc: 【日】抽取业务数据到统计库 小组 话题 议题 项目 + * + * @param formDTO + * @date: 2020/6/22 9:09 + * @author: jianjun liu + */ + @Override + public Result factOriginExtractAll(ExtractFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "factOriginExtractAll", formDTO); + } + + /** + * desc: 【月】抽取统计数据到指标库 + * + * @param formDTO + * @date: 2020/6/22 9:09 + * @author: jianjun liu + */ + @Override + public Result indexOriginExtractAll(ExtractIndexFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "indexOriginExtractAll", formDTO); + } } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/FactExtractOpenFeignClientFallBack.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/FactExtractOpenFeignClientFallBack.java index b5a24ce131..b06cc18485 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/FactExtractOpenFeignClientFallBack.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/feign/impl/FactExtractOpenFeignClientFallBack.java @@ -4,6 +4,8 @@ import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.ModuleUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.StatsFormDTO; +import com.epmet.dto.extract.form.ExtractFormDTO; +import com.epmet.dto.extract.form.ExtractIndexFormDTO; import com.epmet.dto.group.form.GroupStatsFormDTO; import com.epmet.dto.issue.form.IssueJobFromDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; @@ -181,4 +183,28 @@ public class FactExtractOpenFeignClientFallBack implements DataStatisticalOpenFe public Result processPenddingCalculate() { return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "processPenddingCalculate"); } + + /** + * desc: 【日】抽取业务数据到统计库 小组 话题 议题 项目 + * + * @param formDTO + * @date: 2020/6/22 9:09 + * @author: jianjun liu + */ + @Override + public Result factOriginExtractAll(ExtractFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "factOriginExtractAll", formDTO); + } + + /** + * desc: 【月】抽取统计数据到指标库 + * + * @param formDTO + * @date: 2020/6/22 9:09 + * @author: jianjun liu + */ + @Override + public Result indexOriginExtractAll(ExtractIndexFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.DATA_STATISTICAL_SERVER, "indexOriginExtractAll", formDTO); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginController.java deleted file mode 100644 index 0810df755a..0000000000 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactOriginController.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.epmet.controller; - -import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.commons.tools.utils.Result; -import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.extract.form.ExtractFormDTO; -import com.epmet.service.evaluationindex.extract.*; -import com.epmet.util.DimIdGenerator; -import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.Date; - - -/** - * 原始数据清洗 - * - * @author yinzuomei@elink-cn.com - * @date 2020/9/15 11:06 - */ -@RestController -@RequestMapping("factorigin") -public class FactOriginController { - @Autowired - private FactOriginExtractService factOriginExtractService; - @Autowired - private IssueExtractService issueExtractService; - @Autowired - private FactOriginTopicMainDailyService factOriginTopicMainDailyService; - @Autowired - private ProjectExtractService projectExtractService; - @Autowired - private GroupExtractService groupExtractService; - - /** - * desc:抽取业务数据到统计库 - * - * @param extractFormDTO 默认统计前一天 - * @return - */ - @PostMapping("extractall") - public Result extractAll(@RequestBody ExtractFormDTO extractFormDTO) { - if (StringUtils.isNotBlank(extractFormDTO.getStartDate()) && StringUtils.isNotBlank(extractFormDTO.getEndDate())) { - Date startDate = DateUtils.stringToDate(extractFormDTO.getStartDate(), "yyyyMMdd"); - Date endDate = DateUtils.stringToDate(extractFormDTO.getEndDate(), "yyyyMMdd"); - do { - String dateDimId = DimIdGenerator.getDateDimId(startDate); - extractFormDTO.setDateId(dateDimId); - factOriginExtractService.extractAll(extractFormDTO); - startDate = DateUtils.addDateDays(DateUtils.stringToDate(extractFormDTO.getStartDate(), "yyyyMMdd"), 1); - } while (endDate.compareTo(startDate) >= 0); - } else { - factOriginExtractService.extractAll(extractFormDTO); - } - return new Result(); - } - - - /** - * @param extractFormDTO - * @Description 议题抽取(main) - * @author zxc - * @date 2020/9/15 2:02 下午 - */ - @PostMapping("issueextractmain") - public Result issueExtractMain(@RequestBody ExtractFormDTO extractFormDTO) { - ValidatorUtils.validateEntity(extractFormDTO, ExtractFormDTO.ExtractForm.class); - issueExtractService.issueExtractMain(extractFormDTO); - return new Result(); - } - - /** - * @Description 议题抽取(log) - * @param extractFormDTO - * @author zxc - * @date 2020/9/16 9:41 上午 - */ - @PostMapping("issueextractlog") - public Result issueExtractLog(@RequestBody ExtractFormDTO extractFormDTO){ - ValidatorUtils.validateEntity(extractFormDTO, ExtractFormDTO.ExtractForm.class); - issueExtractService.issueExtractLog(extractFormDTO); - return new Result(); - } - - /** - * @param extractFormDTO - * @return com.epmet.commons.tools.utils.Result - * @author yinzuomei - * @description 话题 (fact_origin_topic_main_daily 话题主表_日统计 fact_origin_topic_log_daily 话题明细_日统计) - * @Date 2020/9/15 13:39 - **/ - @PostMapping("topic") - public Result topicDataCleaning(@RequestBody ExtractFormDTO extractFormDTO) { - if (StringUtils.isNotBlank(extractFormDTO.getCustomerId()) && StringUtils.isNotBlank(extractFormDTO.getDateId())) { - factOriginTopicMainDailyService.topicCleaning(extractFormDTO); - } - return new Result(); - } - - @PostMapping("project") - public Result projectData(@RequestBody ExtractFormDTO extractFormDTO) { - projectExtractService.saveOriginProjectDaily(extractFormDTO); - return new Result(); - } - - /** - * @Description 项目节点历时数据清洗 - * @param param - * @return - * @author wangc - * @date 2020.09.20 16:11 - **/ - @PostMapping("projectorgperiodcleanning") - public Result projectOrgPeriodCleaning(@RequestBody ExtractFormDTO param){ - projectExtractService.extractProjectPeriodData(param); - return new Result(); - } - - /** - * @Description 小组数据清洗 - * @param - * @return - * @author wangc - * @date 2020.09.20 16:11 - **/ - @PostMapping("groupdatacleaning") - public Result groupDataCleaning(@RequestBody ExtractFormDTO param){ - groupExtractService.extractGroupData(param); - return new Result(); - } -} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexOriginExtractController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexOriginExtractController.java new file mode 100644 index 0000000000..1f2b86020a --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexOriginExtractController.java @@ -0,0 +1,37 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.extract.form.ExtractIndexFormDTO; +import com.epmet.service.evaluationindex.extract.dataToIndex.IndexOriginExtractService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + + +/** + * 原始数据清洗 + * + * @author yinzuomei@elink-cn.com + * @date 2020/9/15 11:06 + */ +@RestController +@RequestMapping("indexorigin") +public class IndexOriginExtractController { + @Autowired + private IndexOriginExtractService indexOriginExtractService; + + + /** + * desc:抽取统计数据到指标库 + * + * @param extractFormDTO 默认统计上一个月 + * @return + */ + @PostMapping("extractall") + public Result extractAll(@RequestBody ExtractIndexFormDTO extractFormDTO) { + indexOriginExtractService.indexOriginExtractAll(extractFormDTO); + return new Result(); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginProjectMainDailyService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginProjectMainDailyService.java index e18d8251f5..cf6307d212 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginProjectMainDailyService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/FactOriginProjectMainDailyService.java @@ -20,8 +20,8 @@ package com.epmet.service.evaluationindex.extract; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.extract.FactOriginProjectMainDailyDTO; -import com.epmet.dto.extract.result.OrgStatisticsResultDTO; import com.epmet.dto.extract.result.GridProjectClosedTotalResultDTO; +import com.epmet.dto.extract.result.OrgStatisticsResultDTO; import com.epmet.entity.evaluationindex.extract.FactOriginProjectMainDailyEntity; import java.util.List; @@ -142,7 +142,6 @@ public interface FactOriginProjectMainDailyService extends BaseService> diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/IndexOriginExtractService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/IndexOriginExtractService.java new file mode 100644 index 0000000000..773e902e00 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/IndexOriginExtractService.java @@ -0,0 +1,18 @@ +package com.epmet.service.evaluationindex.extract.dataToIndex; + +import com.epmet.dto.extract.form.ExtractIndexFormDTO; + +/** + * desc:将统计库对象数据抽取到指标库 服务接口 + * + * @author yinzuomei@elink-cn.com + * @date 2020/9/17 14:05 + */ +public interface IndexOriginExtractService { + /** + * desc:从统计库对象抽取指标数据 + * + * @param formDTO + */ + void indexOriginExtractAll(ExtractIndexFormDTO formDTO); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java new file mode 100644 index 0000000000..febf3fc41e --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java @@ -0,0 +1,105 @@ +package com.epmet.service.evaluationindex.extract.dataToIndex.impl; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.dto.extract.form.ExtractIndexFormDTO; +import com.epmet.service.evaluationindex.extract.CalCpcIndexService; +import com.epmet.service.evaluationindex.extract.CalGridIndexService; +import com.epmet.service.evaluationindex.extract.dataToIndex.IndexOriginExtractService; +import com.epmet.service.stats.DimCustomerService; +import com.epmet.util.DimIdGenerator; +import com.google.common.util.concurrent.ThreadFactoryBuilder; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.concurrent.*; + +/** + * desc:指标原始数据抽取服务实现类 + */ +@Slf4j +@Service +public class IndexOriginExtractServiceImpl implements IndexOriginExtractService { + ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() + .setNameFormat("indexOriginExtract-pool-%d").build(); + ExecutorService threadPool = new ThreadPoolExecutor(2, 8, + 10L, TimeUnit.MINUTES, + new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); + + @Autowired + private CalCpcIndexService calCpcIndexService; + @Autowired + private CalGridIndexService calGridIndexService; + @Autowired + private DimCustomerService dimCustomerService; + + /** + * desc:从统计库对象抽取指标数据 + * + * @param formDTO + */ + @Override + public void indexOriginExtractAll(ExtractIndexFormDTO formDTO) { + String monthId = formDTO.getMonthId(); + String customerId = formDTO.getCustomerId(); + if (StringUtils.isBlank(monthId)) { + monthId = DimIdGenerator.getDateDimId(DateUtils.addDateMonths(new Date(), -1)); + } + List customerIds = new ArrayList<>(); + if (StringUtils.isNotBlank(customerId)) { + customerIds.add(customerId); + } + int pageNo = NumConstant.ONE; + int pageSize = NumConstant.ONE_HUNDRED; + customerIds = dimCustomerService.selectCustomerIdPage(pageNo, pageSize); + if (CollectionUtils.isEmpty(customerIds)) { + log.error("indexOriginExtractAll 获取客户Id为空"); + return; + } + + String finalMonthId = monthId; + customerIds.forEach(cId -> { + ExtractIndexFormDTO param = new ExtractIndexFormDTO(); + param.setCustomerId(cId); + param.setMonthId(finalMonthId); + submitJob(param); + }); + } + + + private void submitJob(ExtractIndexFormDTO param) { + final String customerId = param.getCustomerId(); + final String monthId = param.getMonthId(); + threadPool.submit(() -> { + try { + calCpcIndexService.calCpcPartyAbility(customerId, monthId); + } catch (Exception e) { + log.error("抽取【党员相关数据】发生异常,参数:" + JSON.toJSONString(param), e); + } + }); + threadPool.submit(() -> { + try { + calGridIndexService.calGridIndexGovernAbility(customerId, monthId); + } catch (Exception e) { + log.error("抽取【网格治理能力数据】发生异常,参数:" + JSON.toJSONString(param), e); + } + try { + calGridIndexService.calGridIndexPartyAbility(customerId, monthId); + } catch (Exception e) { + log.error("抽取【网格党建能力数据】发生异常,参数:" + JSON.toJSONString(param), e); + } + try { + calGridIndexService.calGridIndexServiceAbility(customerId, monthId); + } catch (Exception e) { + log.error("抽取【网格服务能力数据】发生异常,参数:" + JSON.toJSONString(param), e); + } + }); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginExtractServiceImpl.java index 6b1aa32805..0a10a193db 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/impl/FactOriginExtractServiceImpl.java @@ -98,6 +98,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { threadPool.submit(() -> { try { projectExtractService.saveOriginProjectDaily(param); + projectExtractService.extractProjectPeriodData(param); } catch (Exception e) { log.error("抽取【项目数据】发生异常,参数:" + JSON.toJSONString(param), e); } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IndexOriginExtractTaskService.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IndexOriginExtractTaskService.java new file mode 100644 index 0000000000..5416375c13 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/IndexOriginExtractTaskService.java @@ -0,0 +1,24 @@ +package com.epmet.service; + + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.extract.form.ExtractIndexFormDTO; + +/** + * desc: 统计库数据抽取到指标库服务类 + * + * @return: + * @date: 2020/6/22 10:24 + * @author: jianjun liu + */ +public interface IndexOriginExtractTaskService { + + /** + * desc: 【月】抽取 数据到指标库 + * + * @param formDTO + * @date: 2020/6/22 9:09 + * @author: jianjun liu + */ + Result indexOriginExtractJob(ExtractIndexFormDTO formDTO); +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/FactOriginExtractTaskServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/FactOriginExtractTaskServiceImpl.java index b9b818d305..9dfed79a57 100644 --- a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/FactOriginExtractTaskServiceImpl.java +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/FactOriginExtractTaskServiceImpl.java @@ -2,7 +2,7 @@ package com.epmet.service.impl; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.extract.form.ExtractFormDTO; -import com.epmet.feign.FactExtractOpenFeignClient; +import com.epmet.feign.DataStatisticalOpenFeignClient; import com.epmet.service.FactOriginExtractTaskService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -13,7 +13,7 @@ import org.springframework.stereotype.Service; @Service public class FactOriginExtractTaskServiceImpl implements FactOriginExtractTaskService { @Autowired - private FactExtractOpenFeignClient factExtractOpenFeignClient; + private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; /** @@ -25,6 +25,6 @@ public class FactOriginExtractTaskServiceImpl implements FactOriginExtractTaskSe */ @Override public Result factOriginExtractJob(ExtractFormDTO formDTO) { - return factExtractOpenFeignClient.extractall(formDTO); + return dataStatisticalOpenFeignClient.factOriginExtractAll(formDTO); } } diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IndexOriginExtractTaskServiceImpl.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IndexOriginExtractTaskServiceImpl.java new file mode 100644 index 0000000000..e734004bd7 --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/service/impl/IndexOriginExtractTaskServiceImpl.java @@ -0,0 +1,30 @@ +package com.epmet.service.impl; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.extract.form.ExtractIndexFormDTO; +import com.epmet.feign.DataStatisticalOpenFeignClient; +import com.epmet.service.IndexOriginExtractTaskService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * desc:指标原始数据统计 任务服务类 + */ +@Service +public class IndexOriginExtractTaskServiceImpl implements IndexOriginExtractTaskService { + @Autowired + private DataStatisticalOpenFeignClient dataStatisticalOpenFeignClient; + + + /** + * desc: 【月】抽取 统计库对象数据到统计库 + * + * @param formDTO + * @date: 2020/6/22 9:09 + * @author: jianjun liu + */ + @Override + public Result indexOriginExtractJob(ExtractIndexFormDTO formDTO) { + return dataStatisticalOpenFeignClient.indexOriginExtractAll(formDTO); + } +} diff --git a/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/IndexOriginExtractTask.java b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/IndexOriginExtractTask.java new file mode 100644 index 0000000000..f8f405587a --- /dev/null +++ b/epmet-module/epmet-job/epmet-job-server/src/main/java/com/epmet/task/IndexOriginExtractTask.java @@ -0,0 +1,38 @@ +package com.epmet.task; + +import com.alibaba.fastjson.JSON; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.extract.form.ExtractFormDTO; +import com.epmet.service.FactOriginExtractTaskService; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +/** + * desc:数据抽取定时任务 定时任务 + */ +@Component("indexOriginExtractTask") +public class IndexOriginExtractTask implements ITask { + private Logger logger = LoggerFactory.getLogger(getClass()); + + @Autowired + private FactOriginExtractTaskService factOriginExtractTaskService; + + + @Override + public void run(String params) { + logger.info("indexOriginExtractTask定时任务正在执行,参数为:{}", params); + ExtractFormDTO formDTO = new ExtractFormDTO(); + if (StringUtils.isNotBlank(params)) { + formDTO = JSON.parseObject(params, ExtractFormDTO.class); + } + Result result = factOriginExtractTaskService.factOriginExtractJob(formDTO); + if (result.success()) { + logger.info("indexOriginExtractTask定时任务执行成功"); + } else { + logger.error("indexOriginExtractTask定时任务执行失败:" + result.getMsg()); + } + } +}