From 0e408f78c21a29b8c6240c65110d6b93409654fd Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 27 Aug 2021 14:41:37 +0800 Subject: [PATCH 01/41] =?UTF-8?q?=E6=8F=92=E5=85=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=A4=AA=E5=A4=9A=E5=86=85=E5=AD=98=E6=BA=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extract/todata/impl/ProjectExtractServiceImpl.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java index f05f6e5f70..f4f616a722 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/ProjectExtractServiceImpl.java @@ -35,6 +35,7 @@ import com.epmet.service.project.ProjectService; import com.epmet.service.stats.DimCustomerService; import com.epmet.service.topic.TopicService; import com.epmet.util.DimIdGenerator; +import com.google.common.collect.Lists; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -478,9 +479,11 @@ public class ProjectExtractServiceImpl implements ProjectExtractService { formattingData.add(dest); }); - if(!CollectionUtils.isEmpty(formattingData)) { - factOriginProjectOrgPeriodDailyDao.deleteByProjectIds(null,param.getCustomerId()); - factOriginProjectOrgPeriodDailyDao.insertBatch(formattingData); + if (!CollectionUtils.isEmpty(formattingData)) { + factOriginProjectOrgPeriodDailyDao.deleteByProjectIds(null, param.getCustomerId()); + Lists.partition(formattingData, NumConstant.ONE_HUNDRED) + .forEach(part -> factOriginProjectOrgPeriodDailyDao.insertBatch(part)); + } } From 24c4edd1c9004d66b4a60060f6ec69879931094b Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 27 Aug 2021 16:20:53 +0800 Subject: [PATCH 02/41] =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=A6=E4=B8=80=E7=A7=8D=E6=83=85=E5=86=B5?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E5=88=A0=E9=99=A4=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eenProjectCategoryOrgDailyServiceImpl.java | 68 ++++++++++++------- 1 file changed, 44 insertions(+), 24 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java index 4a1ae47b8b..b73ceb3d9c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java @@ -242,6 +242,9 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl agencyIdList){ List result = new ArrayList<>(); + Map> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); + List orgIds = groupByLevel.get(level).stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); + del(customerId,dateId,orgIds); if (isGrid){ // 是社区级别 List categoryInfos = gridDailyDao.selectCategoryInfo(customerId, dateId,null,null); @@ -274,11 +277,8 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl orgIds = new ArrayList<>(); - Map> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); List levelAgencyInfo = groupByLevel.get(level); if (!CollectionUtils.isEmpty(levelAgencyInfo)){ - orgIds = levelAgencyInfo.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); List screenProjectCategory = factOriginProjectCategoryDailyService.selectListProjectCategoryByOrg(orgIds,customerId); if (!CollectionUtils.isEmpty(result)){ if (!CollectionUtils.isEmpty(screenProjectCategory)){ @@ -306,7 +306,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl {r.setOrgType(level);r.setDateId(dateId);}); } } - deleteAndInsert(customerId,dateId,result,orgIds); + insert(result); } /** @@ -357,7 +357,15 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl relationInfo,List agencyIdList){ List result = new ArrayList<>(); - List orgIds = new ArrayList<>(); + Map> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); + List orgIds = groupByLevel.get(level).stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); + if (ScreenConstant.DISTRICT.equals(level)){ + // 添加此 锦水、孔村、榆山 orgId,删除时使用 + orgIds.add(PingYinConstant.JIN_SHUI_AGENCY_ID); + orgIds.add(PingYinConstant.KONG_CUN_AGENCY_ID); + orgIds.add(PingYinConstant.YU_SHAN_AGENCY_ID); + } + del(customerId,dateId,orgIds); if (isGrid){ // community级别走这 List categoryInfos = gridDailyDao.selectCategoryInfo(customerId, dateId,null,null); @@ -401,11 +409,9 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl customerIds = relationInfo.stream().map(m -> m.getCustomerId()).collect(Collectors.toList()); // 父客户存在的分类 List categoryProjectExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, true); - // 内部客户进行分组 - Map> groupByCategoryCode = categoryProjectResultDTOS.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getCategoryCode)); // 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】 result.clear(); - List finalResult = result; +/* List finalResult = result; groupByCategoryCode.forEach((code, list) -> { ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity(); e.setCustomerId(customerId); @@ -418,35 +424,45 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl { + categoryProjectResultDTOS.forEach(f -> { categoryProjectExists.forEach(c -> { if (f.getCategoryCode().equals(c.getCategoryCode())){ f.setProjectTotal(f.getProjectTotal() + c.getProjectTotal()); + c.setStatus(true); } }); }); } + List finalResult = result; + categoryProjectResultDTOS.forEach(c -> { + ScreenProjectCategoryOrgDailyEntity e = ConvertUtils.sourceToTarget(c, ScreenProjectCategoryOrgDailyEntity.class); + e.setCustomerId(customerId); + e.setCategoryOriginCustomerId(customerId); + e.setOrgId(entity.getAgencyId()); + e.setPid(entity.getPid()); + e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids()); + finalResult.add(e); + }); + // 父客户存在分类,但是父客户没有使用过此分类 + Map> groupByStatus = categoryProjectExists.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus)); + if (!CollectionUtils.isEmpty(groupByStatus.get(false))){ + List entities = ConvertUtils.sourceToTarget(groupByStatus.get(false), ScreenProjectCategoryOrgDailyEntity.class); + result.addAll(entities); + } // 父客户不存在的分类 List categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false); if (!CollectionUtils.isEmpty(categoryProjectNotExists)){ List entities = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class); result.addAll(entities); } - // 添加此 锦水、孔村、榆山 orgId,删除时使用 - orgIds.add(PingYinConstant.JIN_SHUI_AGENCY_ID); - orgIds.add(PingYinConstant.KONG_CUN_AGENCY_ID); - orgIds.add(PingYinConstant.YU_SHAN_AGENCY_ID); } } // 目前不考虑计算子客户组织直接创建的项目,只算内部客户 - Map> groupByLevel = agencyIdList.stream().collect(Collectors.groupingBy(CustomerAgencyInfoResultDTO::getLevel)); List levelAgencyInfo = groupByLevel.get(level); if (!CollectionUtils.isEmpty(levelAgencyInfo)) { - List orgIdss = levelAgencyInfo.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); - orgIds.addAll(orgIdss); // 查询客户下,组织直接立项的,各项目分类下的项目数量【筛选组织创建的项目,fact_origin_project_main_daily表gridId为空】 List screenProjectCategory = factOriginProjectCategoryDailyService.selectListProjectCategoryByOrg(orgIds, customerId); if (!CollectionUtils.isEmpty(result)) { @@ -485,21 +501,29 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl needInsert,List orgIds){ + public void insert(List needInsert){ if (CollectionUtils.isEmpty(needInsert)){ return; } + List> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + insertBatch(p); + }); + } + + @Transactional(rollbackFor = Exception.class) + public void del(String customerId, String dateId,List orgIds){ if (CollectionUtils.isEmpty(orgIds)){ return; } @@ -507,10 +531,6 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl NumConstant.ZERO && row == NumConstant.ONE_THOUSAND); - List> partition = ListUtils.partition(needInsert, NumConstant.ONE_HUNDRED); - partition.forEach(p -> { - insertBatch(p); - }); } } \ No newline at end of file From 7564ef74fc34e12f1bded6576438ed7e4028b9ab Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Fri, 27 Aug 2021 16:36:19 +0800 Subject: [PATCH 03/41] =?UTF-8?q?=E6=88=91=E6=94=B6=E5=88=B0=E7=9A=84sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/epmetmessage/InfoProfileDao.xml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml index 8c31bdcbb8..f93f3198d7 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetmessage/InfoProfileDao.xml @@ -75,9 +75,9 @@ SELECT ir.INFO_ID, ip.content, - ii.CREATED_TIME, + ip.CREATED_TIME, ir.READ_FLAG, - ii.publish_staff_id, + ip.publish_staff_id, ip.first_att_id, ia.ATTACHMENT_NAME AS name, ia.ATTACHMENT_FORMAT AS format, @@ -91,18 +91,20 @@ end) as duration FROM info_receivers ir - INNER JOIN info ii ON ( ir.INFO_ID = ii.ID ) - INNER JOIN info_profile ip ON ( ii.ID = ip.INFO_ID AND ip.DEL_FLAG = '0' ) + + INNER JOIN info ii ON ( ir.INFO_ID = ii.ID ) + + INNER JOIN info_profile ip ON ( ir.INFO_ID = ip.INFO_ID AND ip.DEL_FLAG = '0' ) LEFT JOIN info_att ia on ( ip.first_att_id = ia.id AND ia.DEL_FLAG = '0' ) WHERE ir.DEL_FLAG = '0' - AND ii.DEL_FLAG = '0' AND ir.STAFF_ID = #{userId} + AND ii.DEL_FLAG = '0' and ii.content like concat('%',trim(#{content}),'%') ORDER BY - ii.CREATED_TIME DESC + ip.CREATED_TIME DESC - SELECT - agency.USER_ID - FROM - CUSTOMER_STAFF_AGENCY agency - WHERE - agency.DEL_FLAG = '0' - AND agency.AGENCY_ID = ( SELECT - PID + agency.user_id FROM - CUSTOMER_GRID + customer_staff_agency agency + INNER JOIN staff_org_relation sor ON agency.user_id = sor.staff_id AND sor.org_type = 'agency' WHERE - DEL_FLAG = '0' - AND ID = #{gridId}) - - AND agency.USER_ID NOT IN ( - SELECT - USER_ID - FROM - CUSTOMER_STAFF_GRID - WHERE - DEL_FLAG = '0' - AND - GRID_ID = #{gridId} ) + agency.del_flag = '0' + AND agency.agency_id = ( + SELECT + pid + FROM + customer_grid + WHERE + del_flag = '0' + AND id = #{gridId} + ) + AND agency.user_id NOT IN ( + SELECT + user_id + FROM + customer_staff_grid + WHERE + del_flag = '0' + AND + grid_id = #{gridId} + ) From b1e3614c5a0135be195135302ef77c018a8364f7 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 31 Aug 2021 14:00:28 +0800 Subject: [PATCH 16/41] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eenProjectCategoryOrgDailyServiceImpl.java | 63 +++++++++++-------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java index eaabf75cc0..cd771a5a9f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.evaluationindex.screen.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.dynamic.datasource.annotation.DataSource; @@ -365,7 +366,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl categoryProjectResultDTOS = baseDao.selectOrgCategoryInfo(customerId, dateId, level); - log.info("分类标签:"+categoryProjectResultDTOS); + log.info("分类标签:{}"+JSON.toJSONString(categoryProjectResultDTOS)); List belongGridInfos = gridService.selectBelongGridInfo(customerId, level); if (!CollectionUtils.isEmpty(belongGridInfos)){ // 存在直属网格 @@ -405,29 +406,38 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl customerIds = relationInfo.stream().map(m -> m.getCustomerId()).collect(Collectors.toList()); + // 子客户单独存一份【三个街道的】 + List sonCustomerList = new ArrayList<>(); // 父客户存在的分类 List categoryProjectExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, true); - log.info("父客户存在的分类"+categoryProjectExists); - // 这时的result集合要清空,因为被上边使用 【result = ConvertUtils.sourceToTarget(categoryProjectResultDTOS,ScreenProjectCategoryOrgDailyEntity.class);】 - result.clear(); -/* List finalResult = result; - groupByCategoryCode.forEach((code, list) -> { - ScreenProjectCategoryOrgDailyEntity e = new ScreenProjectCategoryOrgDailyEntity(); - e.setCustomerId(customerId); - e.setCategoryOriginCustomerId(customerId); - e.setCategoryCode(code); - e.setOrgId(entity.getAgencyId()); - e.setProjectTotal(CollectionUtils.isEmpty(list) ? NumConstant.ZERO : list.stream().collect(Collectors.summingInt(CategoryProjectResultDTO::getProjectTotal))); - e.setPid(entity.getPid()); - e.setPids(StringUtils.isEmpty(entity.getPids()) ? NumConstant.ZERO_STR : entity.getPids()); - // 因为根据categoryCode分组,所以level都一样,取第一条的 - e.setLevel(list.get(NumConstant.ZERO).getLevel()); - finalResult.add(e); - });*/ + log.info("父客户存在的分类{}"+ JSON.toJSONString(categoryProjectExists)); + // 父客户不存在的分类 + List categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false); + log.info("父客户不存在的分类{}"+ JSON.toJSONString(categoryProjectNotExists)); + if (!CollectionUtils.isEmpty(categoryProjectExists)){ + sonCustomerList.addAll(categoryProjectExists); + } + if (!CollectionUtils.isEmpty(categoryProjectNotExists)){ + sonCustomerList.addAll(categoryProjectNotExists); + } + if (!CollectionUtils.isEmpty(sonCustomerList)){ + List finalSonResult = result; + sonCustomerList.forEach(s -> { + ScreenProjectCategoryOrgDailyEntity e = ConvertUtils.sourceToTarget(s, ScreenProjectCategoryOrgDailyEntity.class); + e.setOrgType(ScreenConstant.STREET); + e.setDateId(dateId); + e.setPid(entity.getPid()); + e.setCustomerId(customerId); + finalSonResult.add(e); + }); + result.addAll(finalSonResult); + } // 内部客户与外部客户 相同的分类累加 if (!CollectionUtils.isEmpty(categoryProjectExists)){ categoryProjectResultDTOS.forEach(f -> { @@ -449,22 +459,23 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl> groupByStatus = categoryProjectExists.stream().collect(Collectors.groupingBy(CategoryProjectResultDTO::getStatus)); if (!CollectionUtils.isEmpty(groupByStatus.get(false))){ List entities = ConvertUtils.sourceToTarget(groupByStatus.get(false), ScreenProjectCategoryOrgDailyEntity.class); + entities.forEach(e -> { + e.setOrgId(entity.getAgencyId()); + }); result.addAll(entities); } - log.info("父客户存在的分类,但是未使用的分类:"+groupByStatus.get(false)); - log.info("父客户存在的分类,但是未使用的分类,组合后:"+result); - // 父客户不存在的分类 - List categoryProjectNotExists = baseDao.selectOrgCategoryMoreCustomerInfo(customerIds, dateId, level, customerId, false); if (!CollectionUtils.isEmpty(categoryProjectNotExists)){ List entities = ConvertUtils.sourceToTarget(categoryProjectNotExists, ScreenProjectCategoryOrgDailyEntity.class); + entities.forEach(e -> { + e.setOrgId(entity.getAgencyId()); + }); result.addAll(entities); } - log.info("父客户不存在的分类:"+categoryProjectNotExists); } } // 目前不考虑计算子客户组织直接创建的项目,只算内部客户 @@ -509,7 +520,7 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl Date: Tue, 31 Aug 2021 14:03:11 +0800 Subject: [PATCH 17/41] =?UTF-8?q?=E5=95=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/ScreenProjectCategoryOrgDailyDao.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml index 40b9b158af..e6293d01f2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectCategoryOrgDailyDao.xml @@ -47,7 +47,7 @@ From 70a8406ac3ef305ad6d50f20866a1b104533d084 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 31 Aug 2021 15:03:27 +0800 Subject: [PATCH 19/41] =?UTF-8?q?=E5=86=8D=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java index 23f44b8184..902981793a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectCategoryOrgDailyServiceImpl.java @@ -436,7 +436,6 @@ public class ScreenProjectCategoryOrgDailyServiceImpl extends BaseServiceImpl Date: Tue, 31 Aug 2021 17:38:23 +0800 Subject: [PATCH 20/41] =?UTF-8?q?=E7=BB=84=E7=BB=87/=E9=83=A8=E9=97=A8/?= =?UTF-8?q?=E7=BD=91=E6=A0=BC=E5=90=8D=E7=A7=B0=E4=B8=8D=E8=83=BD=E8=B6=85?= =?UTF-8?q?=E8=BF=8720=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dto/form/AddAgencyFormDTO.java | 2 +- .../com/epmet/dto/form/AddDepartmentFormDTO.java | 12 +++++++----- .../java/com/epmet/dto/form/AddGridFormDTO.java | 15 +++++++++++---- .../com/epmet/dto/form/EditAgencyFormDTO.java | 2 +- .../com/epmet/dto/form/EditDepartmentFormDTO.java | 12 +++++++----- .../java/com/epmet/dto/form/EditGridFormDTO.java | 15 +++++++++++---- .../epmet/controller/DepartmentController.java | 4 ++-- .../java/com/epmet/controller/GridController.java | 2 ++ 8 files changed, 42 insertions(+), 22 deletions(-) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java index a177306a68..7a5e6b5537 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java @@ -45,7 +45,7 @@ public class AddAgencyFormDTO implements Serializable { * 机构组织名称 */ @NotBlank(message = "组织名称不能为空") - @Length(max=50,message = "机构名称不能超过50个字") + @Length(max=20,message = "机构名称不能超过20个字") private String agencyName; /** diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java index 30f74015ca..5a582535c6 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddDepartmentFormDTO.java @@ -16,6 +16,7 @@ package com.epmet.dto.form; * along with this program. If not, see . */ +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -31,20 +32,21 @@ import java.io.Serializable; public class AddDepartmentFormDTO implements Serializable { private static final long serialVersionUID = 1L; - /** * 所属组织机构ID(customer_agency.id) */ - @NotBlank(message = "组织机构Id不能为空") + @NotBlank(message = "组织机构Id不能为空",groups = AddDepartmentFormDTO.AddDept.class) private String agencyId; - /** * 部门名称 */ - @NotBlank(message = "部门名称不能为空") - @Length(max=120,message = "部门名称不能超过120个字") + @NotBlank(message = "部门名称不能为空",groups = AddDepartmentFormDTO.AddDept.class) + @Length(max=20,message = "部门名称不能超过20个字",groups = AddDepartmentFormDTO.AddDept.class) private String departmentName; + public interface AddDept extends CustomerClientShowGroup { + } + /** * 部门职责 */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java index 95df5fca15..a9473e218e 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddGridFormDTO.java @@ -1,7 +1,10 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotBlank; import java.io.Serializable; /** @@ -12,16 +15,20 @@ import java.io.Serializable; public class AddGridFormDTO implements Serializable { private static final long serialVersionUID = 1L; + /** + * 新建网格名称 + */ + @NotBlank(message = "网格名称不能为空") + @Length(max=20,message = "网格名称不能超过20个字",groups = AddGridFormDTO.AddGrid.class) + private String gridName; /** * 机构id */ private String agencyId; - /** - * 新建网格名称 - */ - private String gridName; + public interface AddGrid extends CustomerClientShowGroup { + } /** * 管辖区域 diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java index 66984fc62e..f279164095 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditAgencyFormDTO.java @@ -50,7 +50,7 @@ public class EditAgencyFormDTO implements Serializable { * 机关组织名称 */ @NotBlank(message = "机关组织名称不能为空") - @Length(max=50,message = "机构名称不能超过50个字",groups = DefaultUserShowGroup.class) + @Length(max=20,message = "机构名称不能超过20个字",groups = DefaultUserShowGroup.class) private String agencyName; /** diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java index d87c0081a0..5d59b289f0 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditDepartmentFormDTO.java @@ -17,6 +17,7 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; import org.hibernate.validator.constraints.Length; @@ -33,20 +34,21 @@ import java.io.Serializable; public class EditDepartmentFormDTO implements Serializable { private static final long serialVersionUID = 1L; - /** * 部门Id */ - @NotBlank(message = "部门ID不能为空") + @NotBlank(message = "部门ID不能为空",groups = EditDepartmentFormDTO.EditDept.class) private String departmentId; - /** * 部门名称 */ - @NotBlank(message = "部门名称不能为空") - @Length(max=120,message = "部门名称不能超过120个字") + @NotBlank(message = "部门名称不能为空",groups = EditDepartmentFormDTO.EditDept.class) + @Length(max=20,message = "部门名称不能超过20个字",groups = EditDepartmentFormDTO.EditDept.class) private String departmentName; + public interface EditDept extends CustomerClientShowGroup { + } + /** * 部门职责 */ diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java index b22e5048f9..0ad04c404d 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/EditGridFormDTO.java @@ -1,7 +1,10 @@ package com.epmet.dto.form; +import com.epmet.commons.tools.validator.group.CustomerClientShowGroup; import lombok.Data; +import org.hibernate.validator.constraints.Length; +import javax.validation.constraints.NotBlank; import java.io.Serializable; /** @@ -12,6 +15,12 @@ import java.io.Serializable; public class EditGridFormDTO implements Serializable { private static final long serialVersionUID = 1L; + /** + * 网格名称 + */ + @NotBlank(message = "网格名称不能为空") + @Length(max=20,message = "网格名称不能超过20个字",groups = EditGridFormDTO.EditGrid.class) + private String gridName; /** * gridId 网格id @@ -23,10 +32,8 @@ public class EditGridFormDTO implements Serializable { */ private String agencyId; - /** - * 网格名称 - */ - private String gridName; + public interface EditGrid extends CustomerClientShowGroup { + } /** * 管理区域 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java index e0d76fc5b4..186cae52b6 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/DepartmentController.java @@ -52,7 +52,7 @@ public class DepartmentController { @PostMapping("adddepartment") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_DEPARTMENT_CREATE) public Result addDepartment(@LoginUser TokenDto tokenDTO, @RequestBody AddDepartmentFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO); + ValidatorUtils.validateEntity(formDTO, AddDepartmentFormDTO.AddDept.class); return departmentService.addDepartment(formDTO); } @@ -65,7 +65,7 @@ public class DepartmentController { @PostMapping("editdepartment") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_DEPARTMENT_UPDATE) public Result editDepartment(@LoginUser TokenDto tokenDTO, @RequestBody EditDepartmentFormDTO formDTO) { - ValidatorUtils.validateEntity(formDTO); + ValidatorUtils.validateEntity(formDTO, EditDepartmentFormDTO.EditDept.class); return departmentService.editDepartment(formDTO); } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java index 4940768e7d..daf3c835cc 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/GridController.java @@ -46,6 +46,7 @@ public class GridController { @PostMapping("addgrid") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_CREATE) public Result addGrid(@LoginUser TokenDto tokenDto, @RequestBody AddGridFormDTO addGridFormDTO){ + ValidatorUtils.validateEntity(addGridFormDTO, AddGridFormDTO.AddGrid.class); return customerGridService.addGrid(tokenDto,addGridFormDTO); } @@ -56,6 +57,7 @@ public class GridController { @PostMapping("editgrid") @RequirePermission(requirePermission = RequirePermissionEnum.ORG_GRID_UPDATE) public Result editGrid(@LoginUser TokenDto tokenDto, @RequestBody EditGridFormDTO editGridFormDTO){ + ValidatorUtils.validateEntity(editGridFormDTO, EditGridFormDTO.EditGrid.class); return customerGridService.editGrid(tokenDto,editGridFormDTO); } From b5d66cebfd9e596c416375de261be6142c69ec2f Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 31 Aug 2021 21:34:53 +0800 Subject: [PATCH 21/41] =?UTF-8?q?1.=E6=8F=90=E5=8F=96openapi-sdk=202.?= =?UTF-8?q?=E8=B0=83=E6=95=B4third=20apiService=E7=9B=B8=E5=85=B3=E9=80=BB?= =?UTF-8?q?=E8=BE=91=203.=E5=AE=8C=E6=88=90=E6=8E=A8=E9=80=81component=20a?= =?UTF-8?q?ccess=20token=E5=88=B0=E7=A7=81=E6=9C=89=E5=8C=96=E5=B9=B3?= =?UTF-8?q?=E5=8F=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/redis/RedisKeys.java | 22 ++ .../src/main/resources/bootstrap.yml | 1 + .../epmet/constant/ThirdPlatformActions.java | 6 + .../result/ThirdPlatformActionsResultDTO.java | 19 ++ .../privateepmet/GetAccessTokenResultDTO.java | 18 ++ .../com/epmet/feign/ThirdOpenFeignClient.java | 22 ++ .../ThirdOpenFeignClientFallback.java | 12 + .../java/com/epmet/apiservice/ApiService.java | 246 +++++++++++++++--- .../epmet/apiservice/impl/DemoApiService.java | 18 +- .../impl/LuzhouGridPlatformApiService.java | 49 ++-- .../impl/PingyinPrivateEpmetApiService.java | 169 ++++++++++++ .../controller/PrivateEpmetController.java | 50 ++++ .../com/epmet/controller/TestConttroller.java | 30 +++ .../com/epmet/dao/ThirdplatformActionDao.java | 10 + .../dao/ThirdplatformCustomerRegisterDao.java | 10 + .../com/epmet/redis/ThirdPlatformCache.java | 19 ++ .../service/ComponentVerifyTicketService.java | 3 + .../epmet/service/PrivateEpmetService.java | 19 ++ .../epmet/service/ThirdPlatformService.java | 10 + .../ComponentVerifyTicketServiceImpl.java | 203 +++++++++------ .../service/impl/PrivateEpmetServiceImpl.java | 71 +++++ .../impl/ThirdPlatformServiceImpl.java | 6 + .../mapper/ThirdplatformActionDao.xml | 17 ++ .../ThirdplatformCustomerRegisterDao.xml | 14 + epmet-openapi/epmet-openapi-sdk/pom.xml | 15 ++ .../epmet/openapi/sdk/encrypt/Md5Util.java | 133 ++++++++++ .../openapi/sdk/sign/OpenApiSignUtils.java | 109 ++++++++ epmet-openapi/pom.xml | 1 + 28 files changed, 1160 insertions(+), 142 deletions(-) create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdPlatformActionsResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/privateepmet/GetAccessTokenResultDTO.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PrivateEpmetController.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/TestConttroller.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/ThirdPlatformCache.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PrivateEpmetService.java create mode 100644 epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PrivateEpmetServiceImpl.java create mode 100644 epmet-openapi/epmet-openapi-sdk/pom.xml create mode 100644 epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/encrypt/Md5Util.java create mode 100644 epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/sign/OpenApiSignUtils.java diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 046802e321..0b965cf2da 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -440,6 +440,28 @@ public class RedisKeys { return rootPrefix.concat("thirdplatform:accesstoken:").concat(platformId); } + /** + * @Description 第三方平台信息key + * @param platformId + * @return java.lang.String + * @author wxz + * @date 2021.08.31 14:44:35 + */ + public static String getThirdPlatformInfoKey(String platformId) { + return rootPrefix.concat("thirdplatform:info:").concat(platformId); + } + + /** + * @Description 第三方平台操作urlkey + * @param platformId + * @return java.lang.String + * @author wxz + * @date 2021.08.31 15:15:15 + */ + public static String getThirdPlatformActionUrlKey(String platformId) { + return rootPrefix.concat("thirdplatform:actions:").concat(platformId); + } + /** * @return 设置组员已读、未读标识 * @param source :act notice diff --git a/epmet-gateway/src/main/resources/bootstrap.yml b/epmet-gateway/src/main/resources/bootstrap.yml index 91552a59b1..4f65034c7d 100644 --- a/epmet-gateway/src/main/resources/bootstrap.yml +++ b/epmet-gateway/src/main/resources/bootstrap.yml @@ -495,6 +495,7 @@ epmet: - /data/stats/project/** - /data/stats/basereport/** - /data/stats/governance/** + - /third/private-epmet/push-component-access-token # 对外开放接口认证白名单 diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java index dc17deca39..bd0875b2e2 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/constant/ThirdPlatformActions.java @@ -19,4 +19,10 @@ public interface ThirdPlatformActions { */ String UPLOAD_FILE = "UPLOAD_FILE"; + /** 推送 微信component access token */ + String PUSH_COMPONENT_ACCESS_TOKEN = "PUSH_COMPONENT_ACCESS_TOKEN"; + + /** 推送 微信 authorizer access token */ + String PUSH_AUTHORIZER_ACCESS_TOKEN = "PUSH_AUTHORIZER_ACCESS_TOKEN"; + } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdPlatformActionsResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdPlatformActionsResultDTO.java new file mode 100644 index 0000000000..a1a81ee406 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/ThirdPlatformActionsResultDTO.java @@ -0,0 +1,19 @@ +package com.epmet.dto.result; + +import lombok.Data; + +/** + * @Description 第三方平台及其支持的action result + * @author wxz + * @date 2021.08.30 17:06:42 +*/ +@Data +public class ThirdPlatformActionsResultDTO { + + private String platformId; + private String platformKey; + private String platformName; + private String actionKey; + private String apiUrl; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/privateepmet/GetAccessTokenResultDTO.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/privateepmet/GetAccessTokenResultDTO.java new file mode 100644 index 0000000000..e2cc8ab4c3 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/dto/result/privateepmet/GetAccessTokenResultDTO.java @@ -0,0 +1,18 @@ +package com.epmet.dto.result.privateepmet; + +import lombok.Data; + +/** + * @Description 获取accesstoken结果 + * @author wxz + * @date 2021.08.30 17:40:25 +*/ +@Data +public class GetAccessTokenResultDTO { + + // token + private String accessToken; + // 有效时长 + private Long expireTime; + +} diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java index 9cfd126d4c..d4efa88cc9 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/ThirdOpenFeignClient.java @@ -2,6 +2,8 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; import com.epmet.dto.form.SaveOrUpdateCustSelPlatformFormDTO; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.result.ThirdplatformResultDTO; @@ -35,4 +37,24 @@ public interface ThirdOpenFeignClient { */ @PostMapping("/third/thirdplatform/customer/list-available-platforms-by-action") Result> listAvailablePlatformsByCustomerAndAction(@RequestBody ThirdPlatformFormDTO input); + + /** + * @Description 私有化平台接收component-access推送 + * @param input + * @return com.epmet.commons.tools.utils.Result + * @author wxz + * @date 2021.08.30 16:40:17 + */ + @PostMapping("/third/private-epmet/push-component-access-token") + Result pushComponentAccessToken(@RequestBody ComponentAccessTokenFormDTO input); + + /** + * @Description 接收推送AuthorizerTokens + * @param input + * @return com.epmet.commons.tools.utils.Result + * @author wxz + * @date 2021.08.30 16:36:02 + */ + @PostMapping("/third/private-epmet/push-authorizer-tokens") + Result pushAuthorizerTokens(@RequestBody AuthorizerAccessTokenFormDTO input); } diff --git a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java index 76098de169..b6929b9883 100644 --- a/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java +++ b/epmet-module/epmet-third/epmet-third-client/src/main/java/com/epmet/feign/fallback/ThirdOpenFeignClientFallback.java @@ -3,6 +3,8 @@ package com.epmet.feign.fallback; 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.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; import com.epmet.dto.form.SaveOrUpdateCustSelPlatformFormDTO; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.result.ThirdplatformResultDTO; @@ -22,4 +24,14 @@ public class ThirdOpenFeignClientFallback implements ThirdOpenFeignClient { public Result> listAvailablePlatformsByCustomerAndAction(ThirdPlatformFormDTO input) { return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "listAvailablePlatformsByCustomerAndAction", input); } + + @Override + public Result pushComponentAccessToken(ComponentAccessTokenFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "pushComponentAccessToken", input); + } + + @Override + public Result pushAuthorizerTokens(AuthorizerAccessTokenFormDTO input) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_THIRD_SERVER, "pushAuthorizerTokens", input); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java index 36117287e1..a43689e321 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/ApiService.java @@ -1,7 +1,8 @@ package com.epmet.apiservice; +import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSON; -import com.epmet.apiservice.result.LZGridPlatformBaseResult; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.utils.HttpClientManager; @@ -10,19 +11,21 @@ import com.epmet.commons.tools.utils.SpringContextUtils; import com.epmet.dao.ThirdplatformActionDao; import com.epmet.dao.ThirdplatformCustomerRegisterDao; import com.epmet.dao.ThirdplatformDao; -import com.epmet.dto.form.ProjectApplyAssistFormDTO; -import com.epmet.dto.form.TPFDemoFormDTO; -import com.epmet.dto.form.UploadFileFormDTO; +import com.epmet.dto.form.*; import com.epmet.dto.result.ProjectAssistResult; import com.epmet.dto.result.UploadFileResultDTO; import com.epmet.entity.ThirdplatformActionEntity; import com.epmet.entity.ThirdplatformCustomerRegisterEntity; import com.epmet.entity.ThirdplatformEntity; +import com.epmet.redis.ThirdPlatformCache; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.data.redis.core.HashOperations; import org.springframework.data.redis.core.RedisTemplate; import java.io.File; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -32,7 +35,7 @@ import java.util.concurrent.TimeUnit; * 此抽象类中定义方法的具体返回类型,所有子类都要统一使用,在具体实现中做转换。若是不需要返回,返回null即可。 */ @Slf4j -public abstract class ApiService { +public abstract class ApiService { /** * 重试次数 */ @@ -61,13 +64,13 @@ public abstract class ApiService { * @param headers * @return */ - public String sendGetRequest(String platformId, String action, Map params, Map headers) { + public R sendGetRequest(String platformId, String action, Map params, Map headers) { // 1.获取token String accessToken = getAccessToken(platformId); //2.获取url - ThirdplatformEntity thirdplatform = SpringContextUtils.getBean(ThirdplatformDao.class).selectById(platformId); - ThirdplatformActionEntity actionEntity = SpringContextUtils.getBean(ThirdplatformActionDao.class) - .getByPlatformIdAndActionKey(platformId, action); + ThirdPlatformCache thirdPlatformInfo = getThirdPlatformInfo(platformId); + String actionUrl = getThirdPlatformActionUrl(platformId, action); + if (headers == null) { headers = new HashMap<>(); @@ -76,8 +79,8 @@ public abstract class ApiService { // 填充access token到头当中 headers.put("X-Access-Token", accessToken); log.info("apiService sendGetRequest param:{},headers:{}",params,headers); - Result result = HttpClientManager.getInstance().sendGet(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()), - thirdplatform.getBaseUrl().startsWith("https://"), + Result result = HttpClientManager.getInstance().sendGet(thirdPlatformInfo.getBaseUrl().concat(actionUrl), + thirdPlatformInfo.getBaseUrl().startsWith("https://"), params, headers); log.info("apiService sendGetRequest result:{}",JSON.toJSONString(result)); @@ -87,37 +90,51 @@ public abstract class ApiService { if (result.success()) { throw new RenException("请求第三方平台,获取AccessToken失败。"); } - LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class); - judgeResultSuccess(platformResult); - return result.getData(); + return parsePlatformResponseResult(result.getData(), String.class); } + /** + * @Description + accesstoken header名称。如果不需要AccessToken,与getAccessToken()方法共同返回null即可 + * @return java.lang.String + * @author wxz + * @date 2021.08.30 14:06:26 + */ + public abstract String getAccessTokenHeaderName(); + /** * 发送post请求 * @param platformId * @param action * @param jsonString * @param headers - * @return + * @return 平台对应返回值的Result类 */ - public String sendPostRequest(String platformId, String action, String jsonString, Map headers) { + public R sendPostRequest(String platformId, String action, String jsonString, Map headers, Map urlParams) { // 1.获取token String accessToken = getAccessToken(platformId); //2.获取url - ThirdplatformEntity thirdplatform = SpringContextUtils.getBean(ThirdplatformDao.class).selectById(platformId); - ThirdplatformActionEntity actionEntity = SpringContextUtils.getBean(ThirdplatformActionDao.class) - .getByPlatformIdAndActionKey(platformId, action); + ThirdPlatformCache platformFromCache = getThirdPlatformInfo(platformId); + String actionUrl = getThirdPlatformActionUrl(platformId, action); if (headers == null) { headers = new HashMap<>(); } // 填充access token到头当中 - headers.put("X-Access-Token", accessToken); + if (StringUtils.isNotBlank(accessToken)) { + //headers.put("X-Access-Token", accessToken); + String accessTokenHeaderName = getAccessTokenHeaderName(); + if (StringUtils.isBlank(accessTokenHeaderName)) { + throw new RenException("没有指定AccessToken的Header名字"); + } + headers.put(accessTokenHeaderName, accessToken); + } log.info("apiService sendPostRequest param:{},headers:{}",jsonString,headers); - Result result = HttpClientManager.getInstance().sendPost(thirdplatform.getBaseUrl().concat(actionEntity.getApiUrl()), - thirdplatform.getBaseUrl().startsWith("https://"), + String urlParmsStr = this.convertQueryParams2String(urlParams); + Result result = HttpClientManager.getInstance().sendPost(platformFromCache.getBaseUrl().concat(actionUrl).concat(urlParmsStr), + platformFromCache.getBaseUrl().startsWith("https://"), jsonString, headers); log.info("apiService sendPostRequest result:{}",JSON.toJSONString(result)); @@ -128,12 +145,10 @@ public abstract class ApiService { throw new RenException("请求第三方平台,发送Post请求失败。错误信息:" + result.getMsg()); } - LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class); - judgeResultSuccess(platformResult); - return result.getData(); + return parsePlatformResponseResult(result.getData(), String.class); } - public String sendPostRequestToUploadFile(String platformId, String action, File file, String fileName) { + public R sendPostRequestToUploadFile(String platformId, String action, File file, String fileName) { // 1.获取token String accessToken = getAccessToken(platformId); //2.获取url @@ -159,8 +174,6 @@ public abstract class ApiService { throw new RenException("请求第三方平台,发送Post请求失败。错误信息:" + result.getMsg()); } - LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class); - // token过期重试逻辑,先不加 //if ("402".equals(platformResult.getCode())) { // // 如果token过期 @@ -168,8 +181,37 @@ public abstract class ApiService { // getAccessToken(platformId); // return sendPostRequest(platformId, action, jsonString, headers); //} - judgeResultSuccess(platformResult); - return result.getData(); + return parsePlatformResponseResult(result.getData(), String.class); + } + + /** + * @Description 将url参数拼接为字符串 + * @param queryParams + * @return java.lang.String + * @author wxz + * @date 2021.08.31 14:08:17 + */ + protected String convertQueryParams2String(Map queryParams) { + try { + if (queryParams == null || queryParams.size() == 0) { + return ""; + } + StringBuilder sb = new StringBuilder(""); + queryParams.entrySet().forEach(entry -> { + String key = entry.getKey(); + String value = entry.getValue(); + sb.append("&").append(key).append("=").append(value); + }); + String result = sb.toString(); + if (result.startsWith("&")) { + result = result.substring(1); + return "?".concat(result); + } + return ""; + } catch (Exception e) { + log.warn("gateway中将url参数转化为String失败,程序继续执行,错误信息:".concat(ExceptionUtils.getErrorStackTrace(e))); + return ""; + } } /** @@ -202,6 +244,36 @@ public abstract class ApiService { stringRedisTemplate.opsForValue().set(RedisKeys.getThirdPlatformAccessTokenKey(platformId), accessToken, expire, timeUnit); } + /** + * @Description 将第三方平台信息存入缓存 + * @param cache + * @return void + * @author wxz + * @date 2021.08.31 14:55:48 + */ + protected void addPlatformToCache(ThirdPlatformCache cache) { + RedisTemplate stringRedisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class); + Map stringObjectMap = BeanUtil.beanToMap(cache); + stringRedisTemplate.opsForHash().putAll(RedisKeys.getThirdPlatformInfoKey(cache.getPlatformId()), stringObjectMap); + } + + /** + * @Description 从缓存中取第三方平台信息 + * @param thirdPlatformKey + * @return com.epmet.redis.ThirdPlatformCache + * @author wxz + * @date 2021.08.31 14:55:28 + */ + protected ThirdPlatformCache getPlatformFromCache(String thirdPlatformKey) { + HashOperations hashOperations = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class).opsForHash(); + Map entries = hashOperations.entries(RedisKeys.getThirdPlatformInfoKey(thirdPlatformKey)); + if (entries.size() == 0) { + return null; + } + ThirdPlatformCache thirdPlatformCache = BeanUtil.mapToBean(entries, ThirdPlatformCache.class, true); + return thirdPlatformCache; + } + /** * @Description 从缓存中取token * @return @@ -210,7 +282,87 @@ public abstract class ApiService { */ protected String getAccessTokenFromCache(String platformId) { RedisTemplate stringRedisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class); - return stringRedisTemplate.opsForValue().get(platformId); + return stringRedisTemplate.opsForValue().get(RedisKeys.getThirdPlatformAccessTokenKey(platformId)); + } + + /** + * @Description 从缓存查询第三方平台操作url + * @param platformId + * @param action + * @return java.lang.String + * @author wxz + * @date 2021.08.31 15:18:06 + */ + protected String getThirdPlatformActionUrlFromCache(String platformId, String action) { + HashOperations ops = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class).opsForHash(); + String url = ops.get(RedisKeys.getThirdPlatformActionUrlKey(platformId), action); + return url; + } + + /** + * @Description 将第三方平台操作url添加至缓存 + * @param platformId + * @param map + * @return java.lang.String + * @author wxz + * @date 2021.08.31 15:20:45 + */ + protected void addThirdPlatformActionUrlsToCache(String platformId, Map map) { + String redisKey = RedisKeys.getThirdPlatformActionUrlKey(platformId); + + RedisTemplate redisTemplate = SpringContextUtils.getBean("redisTemplate", RedisTemplate.class); + HashOperations ops = redisTemplate.opsForHash(); + ops.putAll(redisKey, map); + } + + /** + * @Description 从缓存里面读取平台信息,如果缓存中没有,从db读取,放入缓存 + * @param platformId 平台id + * @return com.epmet.redis.ThirdPlatformCache + * @author wxz + * @date 2021.08.31 15:02:19 + */ + protected ThirdPlatformCache getThirdPlatformInfo(String platformId) { + ThirdPlatformCache platform = getPlatformFromCache(platformId); + if (platform == null) { + platform = new ThirdPlatformCache(); + ThirdplatformEntity platformEntity = SpringContextUtils.getBean(ThirdplatformDao.class).selectById(platformId); + platform.setPlatformId(platformEntity.getId()); + platform.setApiService(platformEntity.getApiService()); + platform.setBaseUrl(platformEntity.getBaseUrl()); + platform.setPlatformKey(platformEntity.getPlatformKey()); + platform.setPlatformName(platformEntity.getPlatformName()); + platform.setPlatformSecret(platformEntity.getPlatformSecret()); + addPlatformToCache(platform); + } + return platform; + } + + /** + * @Description 获取第三放平台操作url。优先读取缓存,没有则读取db + * @param platformId + * @param actionKey + * @return java.util.Map + * @author wxz + * @date 2021.08.31 15:21:39 + */ + protected String getThirdPlatformActionUrl(String platformId, String actionKey) { + String url = getThirdPlatformActionUrlFromCache(platformId, actionKey); + if (StringUtils.isBlank(url)) { + List actions = SpringContextUtils.getBean(ThirdplatformActionDao.class) + .listPlatformActions(platformId); + + Map map = new HashMap<>(actions.size()); + // 将action:url映射至map + for (ThirdplatformActionEntity a : actions) { + map.put(a.getActionKey(), a.getApiUrl()); + if (actionKey.equals(a.getActionKey())) { + url = a.getApiUrl(); + } + } + addThirdPlatformActionUrlsToCache(platformId, map); + } + return url; } /** @@ -246,16 +398,38 @@ public abstract class ApiService { } /** - * @Description 判断第三方平台返回结果成功失败。如果失败,则抛出异常 - * @return + * @Description 解析第三方平台返回结果 + * @param resultString + * @param clazz R的泛型对象T的clazz + * @return R 泛型,不同平台的Result DTO类型 * @author wxz - * @date 2021.03.22 10:32 - */ - public abstract void judgeResultSuccess(LZGridPlatformBaseResult result); + * @date 2021.08.31 13:36:11 + */ + public abstract R parsePlatformResponseResult(String resultString, Class clazz); public UploadFileResultDTO uploadFile(UploadFileFormDTO formDTO) { return null; } + /** + * @Description 推送ComponentAccessToken + * @param form + * @return void 保持空实现,让子类去实现 + * @author wxz + * @date 2021.08.30 17:15:01 + */ + public void pushComponentAccessToken(ComponentAccessTokenFormDTO form, String platformId, String platformKey) {} + + /** + * @description 推送小程序token + * + * @param form + * @param platformId + * @param platformKey + * @return + * @author wxz + * @date 2021.08.31 20:26:51 + */ + public void pushAuthorizerAccessToken(AuthorizerAccessTokenFormDTO form, String platformId, String platformKey) {}; } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java index 63f718a0d5..ed06d5059a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/DemoApiService.java @@ -14,10 +14,15 @@ import org.springframework.stereotype.Component; * demo api service */ @Component(value = "demoApiService") -public class DemoApiService extends ApiService { +public class DemoApiService extends ApiService { Logger logger = LoggerFactory.getLogger(DemoApiService.class); + @Override + public String getAccessTokenHeaderName() { + return null; + } + @Override public String getAccessToken(String platformId) { return null; @@ -29,8 +34,15 @@ public class DemoApiService extends ApiService { return null; } + /** + * @Description 解析平台返回结果 + * @param resultString 平台返回结果string + * @return java.lang.String + * @author wxz + * @date 2021.08.30 22:43:24 + */ @Override - public void judgeResultSuccess(LZGridPlatformBaseResult result) { - + public String parsePlatformResponseResult(String resultString, Class clazz) { + return null; } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java index abbaad2255..dee2cd8137 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/LuzhouGridPlatformApiService.java @@ -31,7 +31,12 @@ import java.util.concurrent.TimeUnit; */ @Slf4j @Component("luzhouGridPlatformApiService") -public class LuzhouGridPlatformApiService extends ApiService { +public class LuzhouGridPlatformApiService extends ApiService { + + @Override + public String getAccessTokenHeaderName() { + return "X-Access-Token"; + } @Override public String getAccessToken(String platformId) { @@ -58,11 +63,8 @@ public class LuzhouGridPlatformApiService extends ApiService { throw new RenException("请求第三方平台,获取AccessToken失败。"); } - LZGridPlatformBaseResult platformResult = JSON.parseObject(result.getData(), LZGridPlatformBaseResult.class); - judgeResultSuccess(platformResult); - - token = platformResult.getResult(); - addAccessTokenToCache(platformId, token, (long)(3600*1.8*1000), TimeUnit.MILLISECONDS); + LZGridPlatformBaseResult lzGridPlatformBaseResult = parsePlatformResponseResult(result.getData(), String.class); + addAccessTokenToCache(platformId, lzGridPlatformBaseResult.getResult(), (long)(3600*1.8*1000), TimeUnit.MILLISECONDS); } return token; } @@ -83,30 +85,24 @@ public class LuzhouGridPlatformApiService extends ApiService { // 正式调用第三方平台 String argsStr = JSON.toJSONString(formDTO); - String result = sendPostRequest(platformId, ThirdPlatformActions.PROJECT_ASSIST, argsStr, null); + LZGridPlatformBaseResult result = sendPostRequest(platformId, ThirdPlatformActions.PROJECT_ASSIST, argsStr, null, null); // 开发阶段临时写死 //String result = "{\"eventId\":\"test-task-id\"}"; ProjectAssistResult projectAssistResult = new ProjectAssistResult(); - if (!StringUtils.isBlank(result)) { - // 此处要经过一系列业务处理,将第三方平台返回的数据进行解析,等处理最后转换成ProjectAssistResult类型,返回。ProjectAssistResult这个类型是 - // 所有apiService的projectAssist方法返回值的统一类型,是我们的epmet-cloud所需要的数据的实体, - // 所有apiService都要想办法转化成这个类型。 - LZGridPlatformBaseResult lzResult = JSON.parseObject(result, LZGridPlatformBaseResult.class); - - // 此处设置为第三方系统返回的唯一id - projectAssistResult.setTaskId(lzResult.getResult()); - } + // 此处设置为第三方系统返回的唯一id + projectAssistResult.setTaskId(result.getResult()); log.info("projectAssist 泸州网格化平台项目协助发送成功"); return projectAssistResult; } @Override - public void judgeResultSuccess(LZGridPlatformBaseResult result) { - //LZGridPlatformBaseResult; - if (!"200".equalsIgnoreCase(result.getCode())) { - throw new RenException("泸州网格化平台:返回失败结果,错误码:" + result.getCode()); + public LZGridPlatformBaseResult parsePlatformResponseResult(String resultString, Class clazz) { + LZGridPlatformBaseResult baseResult = JSON.parseObject(resultString, LZGridPlatformBaseResult.class); + if (!"200".equalsIgnoreCase(baseResult.getCode())) { + throw new RenException("泸州网格化平台:返回失败结果,错误码:" + baseResult.getCode()); } + return baseResult; } @Override @@ -118,16 +114,9 @@ public class LuzhouGridPlatformApiService extends ApiService { // 正式调用第三方平台 File file = new File(formDTO.getFile().getOriginalFilename()); FileUtils.copyInputStreamToFile(formDTO.getFile().getInputStream(), file); - String result = sendPostRequestToUploadFile(platformId, ThirdPlatformActions.UPLOAD_FILE, file, fileName); - if (!StringUtils.isBlank(result)) { - // 此处要经过一系列业务处理,将第三方平台返回的数据进行解析,等处理最后转换成ProjectAssistResult类型,返回。ProjectAssistResult这个类型是 - // 所有apiService的projectAssist方法返回值的统一类型,是我们的epmet-cloud所需要的数据的实体, - // 所有apiService都要想办法转化成这个类型。 - LZGridPlatformBaseResult lzResult = JSON.parseObject(result, LZGridPlatformBaseResult.class); - - // 此处设置为第三方系统返回的唯一id - resultDTO.setUrl((String) lzResult.getResult()); - } + LZGridPlatformBaseResult baseResult = sendPostRequestToUploadFile(platformId, ThirdPlatformActions.UPLOAD_FILE, file, fileName); + // 此处设置为第三方系统返回的唯一id + resultDTO.setUrl(baseResult.getResult()); System.out.println("泸州网格化平台项目文件上传成功"); } catch (Exception e) { throw new RenException("上传失败"); diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java new file mode 100644 index 0000000000..da62386442 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/apiservice/impl/PingyinPrivateEpmetApiService.java @@ -0,0 +1,169 @@ +package com.epmet.apiservice.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.epmet.apiservice.ApiService; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.ExceptionUtils; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.feign.ResultDataResolver; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.constant.ThirdPlatformActions; +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; +import com.epmet.dto.result.privateepmet.GetAccessTokenResultDTO; +import com.epmet.openapi.sdk.sign.OpenApiSignUtils; +import com.epmet.redis.ThirdPlatformCache; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +@Component("pingyinPrivateEpmetApiService") +@Slf4j +public class PingyinPrivateEpmetApiService extends ApiService implements ResultDataResolver { + + // 认证方式 + private String authType = "take_token"; + + @Override + public String getAccessTokenHeaderName() { + return "AccessToken"; + } + + @Override + public String getAccessToken(String platformId) { + String accessTokenFromCache = super.getAccessTokenFromCache(platformId); + if (StringUtils.isBlank(accessTokenFromCache)) { + ThirdPlatformCache thirdPlatformInfo = super.getThirdPlatformInfo(platformId); + String apiUrl = getThirdPlatformActionUrl(platformId, ThirdPlatformActions.GET_ACCESS_TOKEN); + String baseUrl = thirdPlatformInfo.getBaseUrl(); + String platformKey = thirdPlatformInfo.getPlatformKey(); + String platformSecret = thirdPlatformInfo.getPlatformSecret(); + String uuid = UUID.randomUUID().toString(); + long currentTimeMillis = System.currentTimeMillis(); + + try { + String sign = createSign(platformKey, platformSecret, uuid, currentTimeMillis, authType, null); + log.info("【调用平阴私有化平台获取AccessToken】参数列表:sign:{}, app_id:{}, auth_type:{}, nonce:{}, timestamp:{}", sign, platformKey, platformSecret, uuid, currentTimeMillis); + String urlParams = super.convertQueryParams2String(constructCommonUrlParamsMap(platformKey, authType, uuid, currentTimeMillis, sign)); + String requestUrl = baseUrl.concat(apiUrl).concat(urlParams); + Result stringResult = HttpClientManager.getInstance().sendPostByHttps(requestUrl, "{}"); + String remoteResultString = getResultDataOrThrowsException(stringResult, "【调用平阴私有化平台获取AccessToken】", EpmetErrorCode.SERVER_ERROR.getCode(), null); + Result remoteResult = parsePlatformResponseResult(remoteResultString, GetAccessTokenResultDTO.class); + log.info("【调用平阴私有化平台获取AccessToken】结果:{}", remoteResultString); + accessTokenFromCache = remoteResult.getData().getAccessToken(); + //(15 * 60 * 1000)为提前获取token。对方token有效期2小时,我们设置有效期为1小时45分钟,留15分钟容错时间,防止时间差 + long expire = remoteResult.getData().getExpireTime() - System.currentTimeMillis() - (15 * 60 * 1000); + super.addAccessTokenToCache(platformId, accessTokenFromCache, expire, TimeUnit.MILLISECONDS); + } catch (Exception e) { + throw new RenException(ExceptionUtils.getErrorStackTrace(e)); + } + } + return accessTokenFromCache; + } + + /** + * @Description 创建签名 + * @param platformKey + * @param platformSecret + * @param nonce + * @param timeMillis + * @param authType + * @return java.lang.String + * @author wxz + * @date 2021.08.31 15:37:58 + */ + private String createSign(String platformKey, String platformSecret, String nonce, Long timeMillis, String authType, Map requestBodyMap) { + HashMap contentMap = new HashMap<>(); + contentMap.put("app_id", platformKey); + contentMap.put("auth_type", authType); + contentMap.put("nonce", nonce); + contentMap.put("timestamp", String.valueOf(timeMillis)); + + if (requestBodyMap != null && requestBodyMap.size() > 0) { + contentMap.putAll(requestBodyMap); + } + + String sign; + try { + sign = OpenApiSignUtils.createSign(contentMap, platformSecret); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "【平阴私有化平台apService】创建签名失败"); + } + return sign; + } + + /** + * @Description 构造url参数map + * @param platformKey + * @param authType + * @param nonce + * @param timeMillis + * @param sign + * @return java.util.Map + * @author wxz + * @date 2021.08.31 14:19:41 + */ + private Map constructCommonUrlParamsMap(String platformKey, String authType, String nonce, Long timeMillis, String sign) { + HashMap map = new HashMap<>(); + map.put("app_id", platformKey); + map.put("auth_type", authType); + map.put("nonce", nonce); + map.put("timestamp", String.valueOf(timeMillis)); + map.put("sign", sign); + return map; + } + + @Override + public Result parsePlatformResponseResult(String resultString, Class clazz) { + Result result; + try { + result = JSON.parseObject(resultString, new TypeReference>(clazz){}); + } catch (Exception e) { + String errorStackTrace = ExceptionUtils.getErrorStackTrace(e); + log.error(errorStackTrace); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "【调用平阴私有化服务器,解析返回结果失败】"); + } + if (!result.success()) { + throw new RenException(String.format("【请求平阴私有化平台】失败,返回结果string:%s", resultString)); + } + return result; + } + + @Override + public void pushComponentAccessToken(ComponentAccessTokenFormDTO form, String platformId, String platformKey) { + ThirdPlatformCache thirdPlatformInfo = getThirdPlatformInfo(platformId); + String nonce = UUID.randomUUID().toString(); + long timeMillis = System.currentTimeMillis(); + + Map bodyMap = null; + try { + bodyMap = ConvertUtils.entityToMap(form); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "【推送ComponentAccessToken】requestBody转化为map失败"); + } + + String sign = createSign(platformKey, thirdPlatformInfo.getPlatformSecret(), nonce, timeMillis, authType, bodyMap); + Map urlParams = constructCommonUrlParamsMap(platformKey, authType, nonce, timeMillis, sign); + + String jsonString = JSON.toJSONString(form); + Result result = super.sendPostRequest(platformId, ThirdPlatformActions.PUSH_COMPONENT_ACCESS_TOKEN, jsonString, null, urlParams); + getResultDataOrThrowsException(result, "【平阴私有化平台】推送ComponentAccessToken", EpmetErrorCode.SERVER_ERROR.getCode(), null); + } + + @Override + public void pushAuthorizerAccessToken(AuthorizerAccessTokenFormDTO form, String platformId, String platformKey) { + + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PrivateEpmetController.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PrivateEpmetController.java new file mode 100644 index 0000000000..1135562069 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/PrivateEpmetController.java @@ -0,0 +1,50 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; +import com.epmet.service.PrivateEpmetService; +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; + +/** + * @Description 私有化平台相关controller + * @author wxz + * @date 2021.08.30 15:18:51 +*/ +@RestController +@RequestMapping("/private-epmet") +public class PrivateEpmetController { + + @Autowired + private PrivateEpmetService privateEpmetService; + + /** + * @Description 接收推送component access + * @param input + * @return com.epmet.commons.tools.utils.Result + * @author wxz + * @date 2021.08.30 15:18:57 + */ + @PostMapping("push-component-access-token") + public Result pushComponentAccessToken(@RequestBody ComponentAccessTokenFormDTO input) { + privateEpmetService.pushComponentAccessToken(input); + return new Result(); + } + + /** + * @Description 接收推送AuthorizerTokens + * @param input + * @return com.epmet.commons.tools.utils.Result + * @author wxz + * @date 2021.08.30 16:36:02 + */ + @PostMapping("push-authorizer-tokens") + public Result pushAuthorizerTokens(@RequestBody AuthorizerAccessTokenFormDTO input) { + privateEpmetService.pushAuthorizerTokens(input); + return new Result(); + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/TestConttroller.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/TestConttroller.java new file mode 100644 index 0000000000..f5d81f987d --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/controller/TestConttroller.java @@ -0,0 +1,30 @@ +package com.epmet.controller; + +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; +import com.epmet.service.ComponentVerifyTicketService; +import com.epmet.service.PrivateEpmetService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Date; + +@RestController +@RequestMapping("test") +public class TestConttroller { + + @Autowired + private ComponentVerifyTicketService componentVerifyTicketService; + + @PostMapping("push-component-access-token") + public Result testPushComponentAccessToken() { + ComponentAccessTokenFormDTO form = new ComponentAccessTokenFormDTO(); + form.setComponentAccessToken("token..."); + form.setExpiresInTime(new Date()); + componentVerifyTicketService.pushComponentAccessToken2PrivateEpmetPlatforms(form); + return new Result(); + } + +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java index 50de9d3629..405ae52529 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformActionDao.java @@ -22,6 +22,8 @@ import com.epmet.entity.ThirdplatformActionEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * * @@ -38,4 +40,12 @@ public interface ThirdplatformActionDao extends BaseDao listPlatformActions(@Param("platformId") String platformId); } \ No newline at end of file diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java index 3dc3001baf..5f1fe6f038 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/dao/ThirdplatformCustomerRegisterDao.java @@ -19,6 +19,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.PlatformUnregisterFormDTO; +import com.epmet.dto.result.ThirdPlatformActionsResultDTO; import com.epmet.entity.ThirdplatformCustomerRegisterEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -55,4 +56,13 @@ public interface ThirdplatformCustomerRegisterDao extends BaseDao + * @author wxz + * @date 2021.08.30 17:07:32 + */ + List listPlatformsByActionKey(@Param("actionKey") String actionKey); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/ThirdPlatformCache.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/ThirdPlatformCache.java new file mode 100644 index 0000000000..c8c3409bc2 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/redis/ThirdPlatformCache.java @@ -0,0 +1,19 @@ +package com.epmet.redis; + +import lombok.Data; + +/** + * @Description 第三方平台缓存对象 + * @author wxz + * @date 2021.08.31 14:41:49 +*/ +@Data +public class ThirdPlatformCache { + //String platformKey, String platformSecret, String platformName, String apiService, String baseUrl + private String platformId; + private String platformKey; + private String platformSecret; + private String platformName; + private String apiService; + private String baseUrl; +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java index 28cfae2fde..8d3ce45cbf 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ComponentVerifyTicketService.java @@ -2,6 +2,7 @@ package com.epmet.service; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.dto.form.AuthCodeAndTimeFromDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; import org.springframework.web.bind.annotation.RequestBody; import javax.servlet.http.HttpServletRequest; @@ -48,4 +49,6 @@ public interface ComponentVerifyTicketService { */ void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO fromDTO); + public void pushComponentAccessToken2PrivateEpmetPlatforms(ComponentAccessTokenFormDTO input); + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PrivateEpmetService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PrivateEpmetService.java new file mode 100644 index 0000000000..3ab6a0b870 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/PrivateEpmetService.java @@ -0,0 +1,19 @@ +package com.epmet.service; + +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; + +public interface PrivateEpmetService { + void pushAuthorizerTokens(AuthorizerAccessTokenFormDTO input); + + /** + * @Description 推送component access token + * @param input + * @return void + * @author wxz + * @date 2021.08.30 16:17:48 + */ + void pushComponentAccessToken(ComponentAccessTokenFormDTO input); + + void pushVerifyTicket(String ticket); +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java index 570ce04d49..33224b3497 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/ThirdPlatformService.java @@ -5,6 +5,7 @@ import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.form.PlatformRegisterFormDTO; import com.epmet.dto.form.PlatformUnregisterFormDTO; +import com.epmet.dto.result.ThirdPlatformActionsResultDTO; import com.epmet.dto.result.ThirdplatformResultDTO; import java.util.List; @@ -100,4 +101,13 @@ public interface ThirdPlatformService { * @Date 10:15 2021-04-09 **/ void registerThirdPlatformCustomer(PlatformRegisterFormDTO formDTO); + + /** + * @Description 已知操作的key,查询哪些app可以做此操作 + * @param actionKey + * @return java.util.List + * @author wxz + * @date 2021.08.30 16:59:13 + */ + List listPlatformsByActionKey(String actionKey); } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java index a23d9ac77f..2ac3e225b2 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ComponentVerifyTicketServiceImpl.java @@ -4,12 +4,15 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.client.config.utils.IOUtils; import com.dingtalk.api.request.OapiRobotSendRequest; +import com.epmet.apiservice.ApiService; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.constant.ModuleConstant; +import com.epmet.constant.ThirdPlatformActions; import com.epmet.constant.ThirdRedisKeyConstant; import com.epmet.constant.ThirdRunTimeInfoConstant; import com.epmet.dao.*; @@ -21,7 +24,9 @@ import com.epmet.feign.OperCrmOpenFeignClient; import com.epmet.mpaes.WXBizMsgCrypt; import com.epmet.mpaes.WXXmlToMapUtil; import com.epmet.redis.RedisThird; +import com.epmet.service.ApiServiceSelector; import com.epmet.service.ComponentVerifyTicketService; +import com.epmet.service.ThirdPlatformService; import com.epmet.wxapi.constant.WxMaCodeConstant; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -47,7 +52,7 @@ import static com.epmet.constant.ThirdRunTimeInfoConstant.*; */ @Slf4j @Service -public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketService { +public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketService, ApiServiceSelector { @Autowired private RedisThird redisThird; @@ -94,6 +99,9 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe @Autowired private PaCustomerDao paCustomerDao; + @Autowired + private ThirdPlatformService thirdPlatformService; + @Value("${third.platform.appId}") private String componentAppId; @Value("${third.platform.appSecret}") @@ -104,8 +112,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe private String token; /** - * @Description 获得授权事件的票据 * @param + * @Description 获得授权事件的票据 * @author zxc */ @Transactional(rollbackFor = Exception.class) @@ -123,23 +131,23 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String nonce = request.getParameter(ModuleConstant.NONCE); String encryptType = request.getParameter(ModuleConstant.ENCRYPT_TYPE); String signature = request.getParameter(ModuleConstant.SIGNATURE); - log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET,msgSignature,timeStamp,nonce,encryptType,signature)); + log.info(String.format(ThirdRunTimeInfoConstant.VERIFY_TICKET, msgSignature, timeStamp, nonce, encryptType, signature)); // 从请求中读取整个post数据 InputStream inputStream; String postData = null; inputStream = request.getInputStream(); - postData= IOUtils.toString(inputStream,ModuleConstant.UTF8); - WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token,aesKey,componentAppId); + postData = IOUtils.toString(inputStream, ModuleConstant.UTF8); + WXBizMsgCrypt wxBizMsgCrypt = new WXBizMsgCrypt(token, aesKey, componentAppId); String msg = wxBizMsgCrypt.decryptMsg(msgSignature, timeStamp, nonce, postData); - log.info(String.format(ThirdRunTimeInfoConstant.MSG,msg)); + log.info(String.format(ThirdRunTimeInfoConstant.MSG, msg)); // 将xml转为map Map result = WXXmlToMapUtil.xmlToMap(msg); String infotype = result.get(ModuleConstant.INFO_TYPE); - log.info(String.format(ThirdRunTimeInfoConstant.INFO_TYPE,infotype)); - switch (infotype){ + log.info(String.format(ThirdRunTimeInfoConstant.INFO_TYPE, infotype)); + switch (infotype) { case ModuleConstant.TICKET_UNDERLINE_KEY: //接收票据 【component_verify_ticket】 String ComponentVerifyTicket = result.get(ModuleConstant.TICKET_KEY); - log.info(String.format(COMPONENT_VERIFY_TICKET,ComponentVerifyTicket)); + log.info(String.format(COMPONENT_VERIFY_TICKET, ComponentVerifyTicket)); // 缓存 ticket redisThird.setComponentVerifyTicket(ComponentVerifyTicket); // 存数据库 @@ -149,7 +157,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe //先逻辑删 ticketDao.deleteOldComponentVerifyTicket(); ticketDao.insertComponentVerifyTicket(ticketFormDTO); - log.info(ModuleConstant.TICKET_UNDERLINE_KEY+":"+ComponentVerifyTicket); + log.info(ModuleConstant.TICKET_UNDERLINE_KEY + ":" + ComponentVerifyTicket); break; case ModuleConstant.AUTHORIZED: //授权成功 this.disposeAuthResult(result); @@ -173,7 +181,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } log.info(ThirdRunTimeInfoConstant.END_TICKET); Integer tokenCount = componentAccessTokenDao.selectAccessTokenCount(); - if (tokenCount == NumConstant.ZERO){ + if (tokenCount == NumConstant.ZERO) { String accessTokenCountFlag = ModuleConstant.ACCOUNT_TOKEN_FLAG_ONE; this.getComponentAccessToken(accessTokenCountFlag); } @@ -181,14 +189,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 授权结果插入 * @param result + * @Description 授权结果插入 * @author zxc */ @Transactional(rollbackFor = Exception.class) - public void disposeAuthResult(Map result){ + public void disposeAuthResult(Map result) { Map tempMap = result; - Map data = tempMap; + Map data = tempMap; AuthResultRecordFormDTO authResultRecord = ConvertUtils.mapToEntity(data, AuthResultRecordFormDTO.class); authResultRecord.setWechatCreateTime(this.sToDate(result.get(ModuleConstant.CREATE_TIME))); if (result.containsKey(ModuleConstant.AUTHORIZATION_CODE_EXPIRED_TIME)) { @@ -199,9 +207,9 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 定时获取 (令牌,component_access_token) 第三方与微信交互使用的component_access_token - * 每十分钟执行一次,判断是否有马上超时的(15分钟以内算马上超时) * @param accessTokenCountFlag 表里的 component_access_token的数量 + * @Description 定时获取 (令牌,component_access_token) 第三方与微信交互使用的component_access_token + * 每十分钟执行一次,判断是否有马上超时的(15分钟以内算马上超时) * @author zxc */ @Transactional(rollbackFor = Exception.class) @@ -218,7 +226,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); jsonObject.put(ModuleConstant.COMPONENT_APPSECRET, appSecret); jsonObject.put(ModuleConstant.TICKET_UNDERLINE_KEY, componentVerifyTicket); - log.info(String.format(ThirdRunTimeInfoConstant.COMPONENT_ACCESS_TOKEN,componentVerifyTicket)); + log.info(String.format(ThirdRunTimeInfoConstant.COMPONENT_ACCESS_TOKEN, componentVerifyTicket)); String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_COMPONENT_TOKEN_URL, JSON.toJSONString(jsonObject)).getData(); Map hashMap = JSON.parseObject(post, Map.class); if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) { @@ -236,6 +244,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe componentAccessTokenDao.insertComponentAccessToken(formDTO); //存缓存 redisThird.setComponentAccessToken(componentAccessToken); + //推送到私有化平台们 + try { + pushComponentAccessToken2PrivateEpmetPlatforms(formDTO); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + } } else { throw new RenException(ThirdRunTimeInfoConstant.FAILURE_ACCESS_TOKEN); } @@ -245,8 +260,29 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 获取预授权码 + * @param input + * @return void + * @Description 推送component access token到私有化平台 + * @author wxz + * @date 2021.08.30 17:12:15 + */ + public void pushComponentAccessToken2PrivateEpmetPlatforms(ComponentAccessTokenFormDTO input) { + List platforms = thirdPlatformService.listPlatformsByActionKey(ThirdPlatformActions.PUSH_COMPONENT_ACCESS_TOKEN); + platforms.stream().forEach(p -> { + log.info("推送component-access-token到私有化平台:platformId:{}, platformKey:{}, platformName:{}, apiUrl:{}", p.getPlatformId(), p.getPlatformKey(), p.getPlatformName(), p.getApiUrl()); + ApiService apiService = selectApiService(p.getPlatformId()); + try { + apiService.pushComponentAccessToken(input, p.getPlatformId(), p.getPlatformKey()); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + } + }); + } + + /** * @param + * @Description 获取预授权码 * @author zxc */ @Transactional(rollbackFor = Exception.class) @@ -258,7 +294,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe JSONObject jsonObject = new JSONObject(); jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); String post = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_CREATE_PREAUTHCODE_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); - log.info(String.format(POST_RESULT,post)); + log.info(String.format(POST_RESULT, post)); Map hashMap = JSON.parseObject(post, Map.class); if (!hashMap.containsKey(ModuleConstant.ERR_MSG)) { preAuthCode = hashMap.get(ModuleConstant.PRE_AUTH_CODE).toString(); @@ -283,11 +319,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 使用授权码获取授权信息 请求参数:【component_access_token、component_appid、authorization_code】 + * @Description 使用授权码获取授权信息 请求参数:【component_access_token、component_appid、authorization_code】 * @author zxc */ @Transactional(rollbackFor = Exception.class) - public AuthorizationInfoResultDTO authInfoByAuthCode(String authCode,String customerId,String clientType) { + public AuthorizationInfoResultDTO authInfoByAuthCode(String authCode, String customerId, String clientType) { log.info(START_GET_AUTH_INFO); AuthorizationInfoResultDTO authorizationInfoResultDTO = new AuthorizationInfoResultDTO(); // 获取令牌【component_access_token】 @@ -297,11 +333,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); jsonObject.put(ModuleConstant.AUTHORIZATION_CODE, authCode); String authInfo = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_QUERY_AUTH_URL + accessToken, JSON.toJSONString(jsonObject)).getData(); - HashMap hashMap = JSON.parseObject(authInfo, HashMap.class); + HashMap hashMap = JSON.parseObject(authInfo, HashMap.class); Map map = hashMap.get(ModuleConstant.AUTHORIZATION_INFO); authorizationInfoResultDTO = ConvertUtils.mapToEntity(map, AuthorizationInfoResultDTO.class); String authAppId = authorizationInfoResultDTO.getAuthorizer_appid(); - log.info("授权信息:"+map); + log.info("授权信息:" + map); String expiresIn = authorizationInfoResultDTO.getExpires_in().toString(); Date expiresInTime = this.countExpirationTime(expiresIn); //授权信息分为两张表,基础信息authorization_info,授权列表func_info @@ -314,14 +350,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe authInfoDTO.setCustomerId(customerId); authInfoDTO.setClientType(clientType); List func_info = authorizationInfoResultDTO.getFunc_info(); - log.info("权限列表信息:"+func_info); + log.info("权限列表信息:" + func_info); String funcInfo = JSON.toJSONString(func_info); authInfoDTO.setFuncInfo(funcInfo); //先逻辑删除,在插入 authorizationInfoDao.updateOldAuthorizationInfo(authAppId); authorizationInfoDao.insertAuthorizationInfo(authInfoDTO); // 授权信息放入缓存 - redisThird.setAuthInfo(authorizationInfoResultDTO,customerId,clientType); + redisThird.setAuthInfo(authorizationInfoResultDTO, customerId, clientType); //authorizer_refresh_token 放入缓存 redisThird.setAuthorizerRefreshToken(authInfoDTO); log.info(END_GET_AUTH_INFO); @@ -329,8 +365,8 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 获取/刷新接口调用令牌 * @param + * @Description 获取/刷新接口调用令牌 * @author zxc */ @Transactional(rollbackFor = Exception.class) @@ -338,7 +374,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe public void refreshToken() { //查询 即将过期的 authorizer_access_token List willOverDueResultDTOS = authorizationInfoDao.checkWillOverDue(); - if (willOverDueResultDTOS.size() != NumConstant.ZERO && null != willOverDueResultDTOS){ + if (willOverDueResultDTOS.size() != NumConstant.ZERO && null != willOverDueResultDTOS) { log.info("查询到即将过期的authorizer_access_token"); willOverDueResultDTOS.forEach(willOverDueDTO -> { String authAppId = willOverDueDTO.getAuthAppId(); @@ -346,10 +382,10 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe String clientType = willOverDueDTO.getClientType(); JSONObject jsonObject = new JSONObject(); //授权方AppId - jsonObject.put(ModuleConstant.AUTHORIZER_APPID,authAppId); + jsonObject.put(ModuleConstant.AUTHORIZER_APPID, authAppId); //第三方平台AppId - jsonObject.put(ModuleConstant.COMPONENT_APPID,componentAppId); - jsonObject.put(ModuleConstant.AUTHORIZER_REFRESH_TOKEN,willOverDueDTO.getAuthorizerRefreshToken()); + jsonObject.put(ModuleConstant.COMPONENT_APPID, componentAppId); + jsonObject.put(ModuleConstant.AUTHORIZER_REFRESH_TOKEN, willOverDueDTO.getAuthorizerRefreshToken()); String componentAccessToken = redisThird.getComponentAccessToken(); String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_AUTHORIZER_TOKEN_URL + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); Map map = JSON.parseObject(data, HashMap.class); @@ -368,7 +404,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe formDTO.setAuthAppid(authAppId); formDTO.setClientType(clientType); AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO(); - BeanUtils.copyProperties(formDTO,authorizationInfo); + BeanUtils.copyProperties(formDTO, authorizationInfo); authorizationInfo.setAuthorizerAppid(authAppId); //先逻辑删除,在插入 authorizationInfoDao.deleteOldAuthorizerAccessToken(customerId, clientType); @@ -380,7 +416,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe resultDTO.setAuthorizer_refresh_token(authorizerRefreshToken); resultDTO.setAuthorizer_appid(authAppId); resultDTO.setExpires_in(7200); - redisThird.setAuthInfo(resultDTO,customerId,clientType); + redisThird.setAuthInfo(resultDTO, customerId, clientType); } }); log.info("更新authorizer_access_token成功"); @@ -389,13 +425,13 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 授权回调URL,回调时并获取授权信息 * @param + * @Description 授权回调URL, 回调时并获取授权信息 * @author zxc */ @Transactional(rollbackFor = Exception.class) @Override - public void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO authCodeAndTime){ + public void redirectUri(TokenDto tokenDto, @RequestBody AuthCodeAndTimeFromDTO authCodeAndTime) { log.info("开始执行回调URL"); String authCode = authCodeAndTime.getAuthCode(); String clientType = authCodeAndTime.getClientType(); @@ -413,7 +449,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe formDTO.setClientType(clientType); formDTO.setCustomerId(customerId); log.info(ThirdRunTimeInfoConstant.BEGIN_DELETE_INSERT_AUTH_CODE); - authCodeDao.deleteCustomerAuthCode(customerId,clientType); + authCodeDao.deleteCustomerAuthCode(customerId, clientType); authCodeDao.insertRedirectAuthCode(formDTO); //authCode存缓存 redisThird.setAuthCode(formDTO); @@ -423,12 +459,12 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe List fixationAppIdResultDTOS = fixationAppIdDao.selectFixationInfos(); String finalCustomerId = customerId;// fixationAppIdResultDTOS.forEach(fixationAppId -> { - if (fixationAppId.getAppId().equals(authAppId)){ + if (fixationAppId.getAppId().equals(authAppId)) { // TODO 是城阳项目或者党群e事通 // crm表中的customerId【原customerId】 String masterCustomerId = fixationAppId.getMasterCustomerId(); formDTO.setCustomerId(masterCustomerId); - authCodeDao.deleteCustomerAuthCode(finalCustomerId,clientType); + authCodeDao.deleteCustomerAuthCode(finalCustomerId, clientType); authCodeDao.insertRedirectAuthCode(formDTO); //authCode存缓存 redisThird.setAuthCode(formDTO); @@ -447,37 +483,37 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe //替换 新customerId为旧customerId customerId = formDTO.getCustomerId(); // 2. 创建开放平台账号并绑定 或者 直接绑定开放平台 - this.createAndBindOpenAccount(customerId,authAppId,clientType); + this.createAndBindOpenAccount(customerId, authAppId, clientType); // 3. 更新 customer_mp 表授权状态和AuthAppId - this.updateCustomerMpAppId(customerId,authAppId,clientType); - authCodeDao.updateAppId(customerId,clientType,authAppId); + this.updateCustomerMpAppId(customerId, authAppId, clientType); + authCodeDao.updateAppId(customerId, clientType, authAppId); // 4. 保存授权方账户信息 - this.saveAuthAccountInfo(customerId,authAppId,clientType); + this.saveAuthAccountInfo(customerId, authAppId, clientType); // 5. 校验客户居民端、工作端小程序是否全部授权,全部授权完成的推送钉钉消息 sun this.checkAuthorization(customerId); log.info("回调结束"); } /** - * @Description 获取授权方的帐号基本信息并保存 * @param customerId * @param authAppId + * @Description 获取授权方的帐号基本信息并保存 * @author zxc */ @Transactional(rollbackFor = Exception.class) - public void saveAuthAccountInfo(String customerId, String authAppId,String clientType) { + public void saveAuthAccountInfo(String customerId, String authAppId, String clientType) { log.info("开始执行保存授权账户基本信息"); JSONObject jsonObject = new JSONObject(); - jsonObject.put(ModuleConstant.COMPONENT_APP_ID,componentAppId); - jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID,authAppId); + jsonObject.put(ModuleConstant.COMPONENT_APP_ID, componentAppId); + jsonObject.put(ModuleConstant.AUTHORIZER_APP_ID, authAppId); String componentAccessToken = redisThird.getComponentAccessToken(); - String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken , JSON.toJSONString(jsonObject)).getData(); - Map map = JSON.parseObject(data, Map.class); + String data = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_GET_AUTHORIZER_INFO + componentAccessToken, JSON.toJSONString(jsonObject)).getData(); + Map map = JSON.parseObject(data, Map.class); Map authorizerInfo = map.get(ModuleConstant.AUTHORIZER_INFO); - log.info("授权信息:"+authorizerInfo); + log.info("授权信息:" + authorizerInfo); // 存在 “miniprograminfo” 字段为小程序,不存在为公众号 boolean keyExist = authorizerInfo.containsKey(ModuleConstant.MINI_PROGRAM_INFO); - if (keyExist == true){ + if (keyExist == true) { log.info("授权方为小程序 并 开始插入信息"); MiniInfoFormDTO miniInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, MiniInfoFormDTO.class); miniInfoFormDTO.setCustomerId(customerId); @@ -498,22 +534,22 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe businessInfoForm.setPrimaryId(primaryId); businessInfoList.add(businessInfoForm); }); - businessInfoDao.deleteBusinessInfo(customerId,clientType); + businessInfoDao.deleteBusinessInfo(customerId, clientType); businessInfoDao.insertBusinessInfo(businessInfoList); //todo 小程序配置的合法域名信息插入 Map miniProgramInfo = (Map) authorizerInfo.get(ModuleConstant.MINI_PROGRAM_INFO); List networkInfoList = new ArrayList<>(); Map networkInfo = (Map) miniProgramInfo.get(ModuleConstant.NETWORK); - networkInfo.forEach((key,value) -> { + networkInfo.forEach((key, value) -> { MiniNetworkInfoFormDTO miniNetworkInfoForm = new MiniNetworkInfoFormDTO(); - miniNetworkInfoForm .setCustomerId(customerId); + miniNetworkInfoForm.setCustomerId(customerId); miniNetworkInfoForm.setClientType(clientType); miniNetworkInfoForm.setNetworkType(key.toString()); miniNetworkInfoForm.setUrl(value.toString()); miniNetworkInfoForm.setPrimaryId(primaryId); networkInfoList.add(miniNetworkInfoForm); }); - miniNetworkInfoDao.deleteNetworkInfo(customerId,clientType); + miniNetworkInfoDao.deleteNetworkInfo(customerId, clientType); miniNetworkInfoDao.insertNetworkInfo(networkInfoList); //todo 小程序配置的类目信息插入 List categoryInfoList = new ArrayList<>(); @@ -533,7 +569,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe miniCategoryInfoDao.deleteCategoryInfo(customerId, clientType); miniCategoryInfoDao.insertCategoryInfo(categoryInfoList); } - }else { + } else { log.info("授权方为公众号 并 开始插入信息"); PaInfoFormDTO paInfoFormDTO = ConvertUtils.mapToEntity(authorizerInfo, PaInfoFormDTO.class); //公众号基本信息插入 @@ -551,7 +587,7 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe businessInfoForm.setPrimaryId(primaryId); businessInfoList.add(businessInfoForm); }); - businessInfoDao.deleteBusinessInfo(customerId,clientType); + businessInfoDao.deleteBusinessInfo(customerId, clientType); businessInfoDao.insertBusinessInfo(businessInfoList); } log.info("保存授权方基本信息结束"); @@ -559,12 +595,12 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 回填 customer_mp appId , 更改授权状态 * @param + * @Description 回填 customer_mp appId , 更改授权状态 * @author zxc */ @Transactional(rollbackFor = Exception.class) - public void updateCustomerMpAppId(String customerId,String authAppId,String clientType){ + public void updateCustomerMpAppId(String customerId, String authAppId, String clientType) { log.info("==========回填customer_mp开始=========="); Integer checkBindCount = customerMpDao.checkBind(authAppId, clientType); if (checkBindCount == NumConstant.ZERO) { @@ -578,14 +614,14 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe log.info("==========回填customer_mp结束=========="); } - public void createAndBindOpenAccount(String customerId,String authAppId,String clientType){ + public void createAndBindOpenAccount(String customerId, String authAppId, String clientType) { log.info(ThirdRunTimeInfoConstant.BEGIN_CREATE_OPEN); Map authorizerRefreshToken = redisThird.getAuthorizerRefreshToken(customerId + ThirdRedisKeyConstant.COLON + clientType); String authorizerAccessToken = authorizerRefreshToken.get("authorizerAccessToken").toString(); JSONObject bindInfoForm = new JSONObject(); - bindInfoForm.put(ModuleConstant.LOW_APP_ID,authAppId); + bindInfoForm.put(ModuleConstant.LOW_APP_ID, authAppId); String bindResult = HttpClientManager.getInstance().sendPostByJSON(WxMaCodeConstant.API_OPEN_GET + authorizerAccessToken, JSON.toJSONString(bindInfoForm)).getData(); - Map bindInfo = JSON.parseObject(bindResult, Map.class); + Map bindInfo = JSON.parseObject(bindResult, Map.class); boolean bindStatus = bindInfo.containsKey(ModuleConstant.OPEN_APP_ID); if (bindStatus != true) { Integer authCount = customerMpDao.selectAuthCount(customerId); @@ -663,11 +699,11 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 转换过期时间 * @param expiresIn + * @Description 转换过期时间 * @author zxc */ - public Date countExpirationTime(String expiresIn){ + public Date countExpirationTime(String expiresIn) { expiresIn = expiresIn + "000"; Date date = new Date(); long l = date.getTime() + Long.valueOf(expiresIn); @@ -676,21 +712,21 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe } /** - * @Description 查询客户Id * @param tokenDto + * @Description 查询客户Id * @author zxc */ - public String getLoginUserCustomerId(TokenDto tokenDto){ + public String getLoginUserCustomerId(TokenDto tokenDto) { PaCustomerUserAgencyDTO result = paCustomerUserAgencyDao.selectCustomerIdByUserId(tokenDto.getUserId()); return result.getCustomerId(); } /** - * @Description 时间戳(秒级)转换 Date * @param t + * @Description 时间戳(秒级)转换 Date * @author zxc */ - public Date sToDate(String t){ + public Date sToDate(String t) { Long aLong = Long.valueOf(t + "000"); Date date = new Date(); date.setTime(aLong); @@ -699,24 +735,24 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe /** * @author sun - * @Description 校验客户两哥小程序是否完成授权 + * @Description 校验客户两哥小程序是否完成授权 */ - private void checkAuthorization(String customerId){ + private void checkAuthorization(String customerId) { List list = customerMpDao.selectByCustomerId(customerId); AtomicBoolean bl = new AtomicBoolean(false); - list.forEach(mp->{ - if(mp.getAuthorizationFlag()!=NumConstant.ONE){ + list.forEach(mp -> { + if (mp.getAuthorizationFlag() != NumConstant.ONE) { bl.set(true); } }); - if(!bl.get()){ + if (!bl.get()) { dDingNews(customerId); } } /** * @author sun - * @Description 发送钉钉消息,通知运营人员有新客户完成授权 + * @Description 发送钉钉消息,通知运营人员有新客户完成授权 */ private String dDingNews(String customerId) { //1.查询客户及管理员信息,用于发送消息使用 @@ -739,8 +775,29 @@ public class ComponentVerifyTicketServiceImpl implements ComponentVerifyTicketSe "> 管理员称谓: " + result.getAppellation() + "\n\n" + "> 联系方式: " + result.getPhone() + "\n"); request.setMarkdown(markdown); - HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(request),url,secret); + HttpClientManager.getInstance().sendDingMsg(JSON.toJSONString(request), url, secret); return null; } + /** + * @Description 推送AuthorizerAccessToken到私有化平台们 + * @param form + * @return void + * @author wxz + * @date 2021.08.31 17:22:04 + */ + public void pushAuthorizerAccessToken2PrivateEpmets(AuthorizerAccessTokenFormDTO form) { + List platforms = thirdPlatformService.listPlatformsByActionKey(ThirdPlatformActions.PUSH_AUTHORIZER_ACCESS_TOKEN); + platforms.stream().forEach(p -> { + log.info("推送authorizer-access-token到私有化平台:platformId:{}, platformKey:{}, platformName:{}, apiUrl:{}", p.getPlatformId(), p.getPlatformKey(), p.getPlatformName(), p.getApiUrl()); + ApiService apiService = selectApiService(p.getPlatformId()); + try { + apiService.pushAuthorizerAccessToken(form, p.getPlatformId(), p.getPlatformKey()); + } catch (Exception e) { + String detail = ExceptionUtils.getErrorStackTrace(e); + log.error(detail); + } + }); + } + } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PrivateEpmetServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PrivateEpmetServiceImpl.java new file mode 100644 index 0000000000..35cb59cad1 --- /dev/null +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/PrivateEpmetServiceImpl.java @@ -0,0 +1,71 @@ +package com.epmet.service.impl; + +import com.epmet.constant.ThirdRunTimeInfoConstant; +import com.epmet.dao.AuthorizationInfoDao; +import com.epmet.dao.ComponentAccessTokenDao; +import com.epmet.dao.ComponentVerifyTicketDao; +import com.epmet.dto.form.AuthorizationInfoFormDTO; +import com.epmet.dto.form.AuthorizerAccessTokenFormDTO; +import com.epmet.dto.form.ComponentAccessTokenFormDTO; +import com.epmet.dto.result.AuthorizationInfoResultDTO; +import com.epmet.redis.RedisThird; +import com.epmet.service.PrivateEpmetService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +@Service +@Slf4j +public class PrivateEpmetServiceImpl implements PrivateEpmetService { + + @Autowired + private ComponentVerifyTicketDao componentVerifyTicketDao; + + @Autowired + private AuthorizationInfoDao authorizationInfoDao; + + @Autowired + private ComponentAccessTokenDao componentAccessTokenDao; + + @Autowired + private RedisThird redisThird; + + @Transactional(rollbackFor = RuntimeException.class) + @Override + public void pushAuthorizerTokens(AuthorizerAccessTokenFormDTO input) { + System.out.println("收到AuthorizerAccessTokenFormDTO:" + input); + + //AuthorizationInfoFormDTO authorizationInfo = new AuthorizationInfoFormDTO(); + //BeanUtils.copyProperties(input,authorizationInfo); + //authorizationInfo.setAuthorizerAppid(input.getAuthAppid()); + ////先逻辑删除,在插入 + //authorizationInfoDao.deleteOldAuthorizerAccessToken(input.getCustomerId(), input.getClientType()); + //authorizationInfoDao.insertAuthorizerAccessToken(input); + ////缓存 refreshAuthorizerAccessToken + //redisThird.setAuthorizerRefreshToken(authorizationInfo); + //AuthorizationInfoResultDTO resultDTO = new AuthorizationInfoResultDTO(); + //resultDTO.setAuthorizer_access_token(input.getAuthorizerAccessToken()); + //resultDTO.setAuthorizer_refresh_token(input.getAuthorizerRefreshToken()); + //resultDTO.setAuthorizer_appid(input.getAuthAppid()); + //resultDTO.setExpires_in(7200); + //redisThird.setAuthInfo(resultDTO,input.getCustomerId(),input.getClientType()); + } + + @Override + @Transactional(rollbackFor = RuntimeException.class) + public void pushComponentAccessToken(ComponentAccessTokenFormDTO componentAccessToken) { + System.out.println("收到componentAccessToken:" + componentAccessToken); + //先逻辑删,在插入 + //componentAccessTokenDao.deleteOldComponentAccessToken(); + //componentAccessTokenDao.insertComponentAccessToken(componentAccessToken); + ////存缓存 + //redisThird.setComponentAccessToken(componentAccessToken.getComponentAccessToken()); + } + + @Override + public void pushVerifyTicket(String ticket) { + + } +} diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java index 3d6393e17e..a3e0930e7a 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java +++ b/epmet-module/epmet-third/epmet-third-server/src/main/java/com/epmet/service/impl/ThirdPlatformServiceImpl.java @@ -12,6 +12,7 @@ import com.epmet.dto.form.CustomerFormDTO; import com.epmet.dto.form.ThirdPlatformFormDTO; import com.epmet.dto.form.PlatformRegisterFormDTO; import com.epmet.dto.form.PlatformUnregisterFormDTO; +import com.epmet.dto.result.ThirdPlatformActionsResultDTO; import com.epmet.dto.result.ThirdplatformResultDTO; import com.epmet.entity.ThirdplatformCustomerActionEntity; import com.epmet.entity.ThirdplatformCustomerRegisterEntity; @@ -160,4 +161,9 @@ public class ThirdPlatformServiceImpl implements ThirdPlatformService { thirdplatformCustomerRegisterDao.batchInsertThirdplatformCustomerRegister(entityList); } } + + @Override + public List listPlatformsByActionKey(String actionKey) { + return thirdplatformCustomerRegisterDao.listPlatformsByActionKey(actionKey); + } } diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml index 39de22dca5..954b8a96e6 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformActionDao.xml @@ -30,6 +30,23 @@ from thirdplatform_action ta where ta.PLATFORM_ID = #{platformId} and ACTION_KEY = #{action} + and ta.DEL_FLAG=0 + + + diff --git a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml index 9ab368a8bc..66d039fc3c 100644 --- a/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml +++ b/epmet-module/epmet-third/epmet-third-server/src/main/resources/mapper/ThirdplatformCustomerRegisterDao.xml @@ -36,6 +36,20 @@ and DEL_FLAG = 0 + + + insert into thirdplatform_customer_register ( diff --git a/epmet-openapi/epmet-openapi-sdk/pom.xml b/epmet-openapi/epmet-openapi-sdk/pom.xml new file mode 100644 index 0000000000..c006c05b10 --- /dev/null +++ b/epmet-openapi/epmet-openapi-sdk/pom.xml @@ -0,0 +1,15 @@ + + + + epmet-openapi + com.epmet + 2.0.0 + + 4.0.0 + + epmet-openapi-sdk + + + \ No newline at end of file diff --git a/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/encrypt/Md5Util.java b/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/encrypt/Md5Util.java new file mode 100644 index 0000000000..0838048629 --- /dev/null +++ b/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/encrypt/Md5Util.java @@ -0,0 +1,133 @@ +package com.epmet.openapi.sdk.encrypt; + +import java.io.UnsupportedEncodingException; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +public class Md5Util { + /** + * 加密盐 值 + */ + public static final String SALT = "EPMET_UMD_SALT"; + + public static String md5(String string) throws Exception { + if (string == null || string.trim().length() == 0) { + return null; + } + return getMD5(string.getBytes("GBK")); + } + + private static final char hexDigits[] = { // 用来将字节转换成 16 进制表示的字符 + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'}; + + private static String getMD5(byte[] source) throws Exception { + String s = null; + MessageDigest md = MessageDigest.getInstance("MD5"); + md.update(source); + byte tmp[] = md.digest(); // MD5 的计算结果是一个 128 位的长整数, + // 用字节表示就是 16 个字节 + char str[] = new char[16 * 2]; // 每个字节用 16 进制表示的话,使用两个字符, + // 所以表示成 16 进制需要 32 个字符 + int k = 0; // 表示转换结果中对应的字符位置 + for (int i = 0; i < 16; i++) { // 从第一个字节开始,对 MD5 的每一个字节 + // 转换成 16 进制字符的转换 + byte byte0 = tmp[i]; // 取第 i 个字节 + str[k++] = hexDigits[byte0 >>> 4 & 0xf]; // 取字节中高 4 位的数字转换, + // >>> 为逻辑右移,将符号位一起右移 + str[k++] = hexDigits[byte0 & 0xf]; // 取字节中低 4 位的数字转换 + } + s = new String(str); // 换后的结果转换为字符串 + return s; + } + + private static String byteArrayToHexString(byte b[]) { + StringBuffer resultSb = new StringBuffer(); + for (int i = 0; i < b.length; i++) + resultSb.append(byteToHexString(b[i])); + + return resultSb.toString(); + } + + private static String byteToHexString(byte b) { + int n = b; + if (n < 0) + n += 256; + int d1 = n / 16; + int d2 = n % 16; + return hexDigits[d1] + "" + hexDigits[d2]; + } + + public static String MD5Encode(String origin, String charsetname) throws Exception { + String resultString = null; + resultString = new String(origin); + MessageDigest md = MessageDigest.getInstance("MD5"); + if (charsetname == null || "".equals(charsetname)) + resultString = byteArrayToHexString(md.digest(resultString + .getBytes())); + else + resultString = byteArrayToHexString(md.digest(resultString + .getBytes(charsetname))); + return resultString; + } + + + public static void main(String[] args) { + for (int i = 0; i < 5; i++) { + String uuid = "03a1dcd8cb1811eabac1c03fd56f7847"; + System.out.println(get12Char(uuid)); + } + } + + /** + * 获取短字符 + * + * @param str + * @return 大写 + */ + public static String get12Char(String str) { + String arr[] = ShortText(str); + String rst = (arr[0] + arr[1]).toUpperCase(); + return rst.substring(0, 4) + rst.substring(4, 8) + rst.substring(8, 12); + } + + private static String[] ShortText(String string) { + String[] chars = new String[]{ // 要使用生成URL的字符 + "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", + "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", + "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", + "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", + "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"}; + + String hex = ""; + + MessageDigest md = null; + try { + md = MessageDigest.getInstance("MD5"); + hex = byteArrayToHexString(md.digest(SALT.concat(string) + .getBytes("utf-8"))); + } catch (Exception e) { + e.printStackTrace(); + } + + int hexLen = hex.length(); + int subHexLen = hexLen / 8; + String[] ShortStr = new String[4]; + + for (int i = 0; i < subHexLen; i++) { + String outChars = ""; + int j = i + 1; + String subHex = hex.substring(i * 8, j * 8); + long idx = Long.valueOf("3FFFFFFF", 16) & Long.valueOf(subHex, 16); + + for (int k = 0; k < 6; k++) { + int index = (int) (Long.valueOf("0000003D", 16) & idx); + outChars += chars[index]; + idx = idx >> 5; + } + ShortStr[i] = outChars; + } + + return ShortStr; + } + +} diff --git a/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/sign/OpenApiSignUtils.java b/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/sign/OpenApiSignUtils.java new file mode 100644 index 0000000000..e44b17aa30 --- /dev/null +++ b/epmet-openapi/epmet-openapi-sdk/src/main/java/com/epmet/openapi/sdk/sign/OpenApiSignUtils.java @@ -0,0 +1,109 @@ +package com.epmet.openapi.sdk.sign; + +import com.epmet.openapi.sdk.encrypt.Md5Util; + +import java.util.*; + +/** + * OpenApi签名工具 + */ +public class OpenApiSignUtils { + + /** + * @Description 创建签名 + * @return + * @author wxz + * @date 2021.03.22 16:47 + */ + public static String createSign(Map contentMap, String signKey) throws Exception { + String str2beSigned = mapToSignStr(contentMap); + str2beSigned = str2beSigned.concat("&sign_key=").concat(signKey); + return Md5Util.md5(str2beSigned); + } + + /** + * @Description 验签 + * @return + * @author wxz + * @date 2021.03.22 16:51 + */ + public static boolean checkSign(Map contentMap, String signKey) throws Exception { + String newSign = createSign(contentMap, signKey); + return newSign.equals(contentMap.get("sign")); + } + + /** + * @Description map转化为签名明文 + * @return + * @author wxz + * @date 2021.03.22 16:47 + */ + public static String mapToSignStr(Map map) { + Set keySet = map.keySet(); + String[] keyArray = (String[])keySet.toArray(new String[keySet.size()]); + Arrays.sort(keyArray); + StringBuilder sb = new StringBuilder(); + + for(int i = 0; i < keyArray.length; ++i) { + String key = keyArray[i]; + String val = (String)map.get(key); + if (val != null && val.trim().length() > 0 && !"sign".equals(key)) { + if (!sb.toString().isEmpty()) { + sb.append("&"); + } + + sb.append(key).append("=").append((String)map.get(key)); + } + } + + return sb.toString(); + } + + public static void main(String[] args) throws Exception { + generateGetAccessTokenSign(); + System.out.println("=============="); + generateGetOrgDetailSign(); + } + + private static void generateGetAccessTokenSign() throws Exception { + long now = System.currentTimeMillis(); + System.out.println(now); + + String uuid = UUID.randomUUID().toString().replace("-", ""); + + HashMap content = new HashMap<>(); + content.put("app_id", "7d98b8af2d05752b4225709c4cfd4bd0"); + content.put("timestamp", String.valueOf(now)); + content.put("nonce", uuid); + content.put("auth_type", "take_token"); + + String secret = "3209ee9f41704482be1a1fb5873a25376f2899191ca846119d44168316bc3e44"; + + String sign = createSign(content, secret); + + System.out.println("时间戳:" + now); + System.out.println("随机数:" + uuid); + System.out.println("签名:" + sign); + } + + private static void generateGetOrgDetailSign() throws Exception { + long now = System.currentTimeMillis(); + String uuid = UUID.randomUUID().toString().replace("-", "");; + System.out.println("时间戳:" + now); + System.out.println("随机数:" + uuid); + + HashMap content = new HashMap<>(); + //content.put("orgId", "aaa"); + //content.put("test", null); + content.put("gridId", "12128e0f614f1c00a058ea9a107033b2"); + content.put("app_id", "7d98b8af2d05752b4225709c4cfd4bd0"); + content.put("timestamp", String.valueOf(now)); + content.put("nonce", uuid); + content.put("auth_type", "take_token"); + + String secret = "3209ee9f41704482be1a1fb5873a25376f2899191ca846119d44168316bc3e44"; + + String sign = createSign(content, secret); + System.out.println("签名:" + sign); + } +} diff --git a/epmet-openapi/pom.xml b/epmet-openapi/pom.xml index 9db62073f3..a3be582a53 100644 --- a/epmet-openapi/pom.xml +++ b/epmet-openapi/pom.xml @@ -13,6 +13,7 @@ epmet-openapi epmet-openapi-scan + epmet-openapi-sdk \ No newline at end of file From 2557b58325b51fbdbcc61a4c8e6bcfe53451d044 Mon Sep 17 00:00:00 2001 From: wxz Date: Tue, 31 Aug 2021 22:21:44 +0800 Subject: [PATCH 22/41] =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=EF=BC=9A=E6=BC=8F=E4=BA=86openapi-sdk=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-module/epmet-third/epmet-third-server/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/epmet-module/epmet-third/epmet-third-server/pom.xml b/epmet-module/epmet-third/epmet-third-server/pom.xml index bd811cf03e..a945beb046 100644 --- a/epmet-module/epmet-third/epmet-third-server/pom.xml +++ b/epmet-module/epmet-third/epmet-third-server/pom.xml @@ -21,6 +21,11 @@ + + com.epmet + epmet-openapi-sdk + 2.0.0 + com.epmet epmet-third-client From 8df605b3cdf2cfb0e11233506db7d1d8b6f2e529 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Wed, 1 Sep 2021 09:56:55 +0800 Subject: [PATCH 23/41] =?UTF-8?q?=E5=85=9A=E5=91=98=E8=AE=A4=E8=AF=81bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../partymember/service/impl/PartyMemberConfirmServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java index 80cc4cc91e..1610de67c6 100644 --- a/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java +++ b/epmet-module/resi-partymember/resi-partymember-server/src/main/java/com/epmet/modules/partymember/service/impl/PartyMemberConfirmServiceImpl.java @@ -193,7 +193,7 @@ public class PartyMemberConfirmServiceImpl implements PartyMemberConfirmService PartymemberInfoEntity.class); PartymemberInfoDTO info = partymemberInfoService.getPartyMemberInfoByUser(partyMemberInfoDTO.getCustomerId(), partyMemberInfoDTO.getUserId()); if (null != info) { - partyMemberInfoDTO.setId(info.getId()); + partyMemberInfoEntity.setId(info.getId()); } if (confirmAutoDTO == null || !confirmAutoDTO.getComparisonResults()) { log.info("submit confirmAutoDTO return null or false:{}",JSON.toJSONString(confirmAutoDTO)); From bdc0ab6e20a0e7915cdfade6d75dd716a3e6eeeb Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 3 Sep 2021 10:32:01 +0800 Subject: [PATCH 24/41] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E5=AE=9E=E5=86=B5=E6=97=A5=E6=9C=9Fbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datastats/impl/DataStatsServiceImpl.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index 6a8896618d..868a97eda4 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1,5 +1,6 @@ package com.epmet.dataaggre.service.datastats.impl; + import com.alibaba.fastjson.JSON; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; @@ -1487,26 +1488,25 @@ public class DataStatsServiceImpl implements DataStatsService { } String startDate = null; String actulStartDate = null; - String endDate = null; + String endDate = formDTO.getDateId(); Date dateIdDate = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD); boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId()); switch (formDTO.getType()){ case "yesterday": startDate = DateUtils.getBeforeNDay(formDTO.getDateId(),1); - endDate = formDTO.getDateId(); actulStartDate = formDTO.getDateId(); break; case "thisWeek": - actulStartDate = DateUtils.getWeekStart(formDTO.getDateId()); - startDate = DateUtils.getBeforeNDay(actulStartDate,1); - DateUtils.format(DateUtils.addDateDays(yesterday, -1),DateUtils.DATE_PATTERN_YYYYMMDD); + startDate = DateUtils.getWeekStart(formDTO.getDateId()); + //startDate = DateUtils.getBeforeNDay(actulStartDate,1); + //DateUtils.format(DateUtils.addDateDays(yesterday, -1),DateUtils.DATE_PATTERN_YYYYMMDD); if (!isYesterday){ endDate = DateUtils.getWeekEnd(formDTO.getDateId()); } break; case "thisMonth": - actulStartDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); - startDate = DateUtils.getBeforeNDay(actulStartDate,1); + startDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); + //startDate = DateUtils.getBeforeNDay(actulStartDate,1); if (!isYesterday) { endDate = DateUtils.format(DateUtils.getMonthEnd(dateIdDate), DateUtils.DATE_PATTERN_YYYYMMDD); } @@ -1516,6 +1516,7 @@ public class DataStatsServiceImpl implements DataStatsService { } formDTO.setStartDateId(startDate); formDTO.setEndDateId(endDate); + log.info("getSubWorkFact do select param:{}", JSON.toJSONString(formDTO)); List result = new ArrayList<>(); //如果是社区 则下级是网格 查询网格的数据 if (OrgLevelEnum.COMMUNITY.getCode().equals(formDTO.getAgencyLevel())){ From d657ee22cc0d894b02b78309e9ed799fa11127b3 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 1 Sep 2021 12:33:23 +0800 Subject: [PATCH 25/41] =?UTF-8?q?=E5=86=8D=E6=AC=A1=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastats/impl/DataStatsServiceImpl.java | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index 4667a7b99c..411be35b77 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1489,26 +1489,22 @@ public class DataStatsServiceImpl implements DataStatsService { formDTO.setDateId(format.format(yesterday)); } String startDate = null; - String actulStartDate = null; String endDate = formDTO.getDateId(); Date dateIdDate = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD); boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId()); switch (formDTO.getType()){ case "yesterday": startDate = DateUtils.getBeforeNDay(formDTO.getDateId(),1); - actulStartDate = formDTO.getDateId(); + endDate = formDTO.getDateId(); break; case "thisWeek": startDate = DateUtils.getWeekStart(formDTO.getDateId()); - //startDate = DateUtils.getBeforeNDay(actulStartDate,1); - //DateUtils.format(DateUtils.addDateDays(yesterday, -1),DateUtils.DATE_PATTERN_YYYYMMDD); if (!isYesterday){ endDate = DateUtils.getWeekEnd(formDTO.getDateId()); } break; case "thisMonth": startDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); - //startDate = DateUtils.getBeforeNDay(actulStartDate,1); if (!isYesterday) { endDate = DateUtils.format(DateUtils.getMonthEnd(dateIdDate), DateUtils.DATE_PATTERN_YYYYMMDD); } @@ -1544,7 +1540,7 @@ public class DataStatsServiceImpl implements DataStatsService { Map closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); Map closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); //巡查次数和时间 - List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,actulStartDate,formDTO.getEndDateId()); + List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(gridIdList,formDTO.getStartDateId(),formDTO.getEndDateId()); Map patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1)); subAgencyList.forEach(agency->{ @@ -1585,7 +1581,7 @@ public class DataStatsServiceImpl implements DataStatsService { Map closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); //巡查次数和时间 List agencyFullIds = subAgencyList.stream().map(o -> o.getPids().concat(StrConstant.COLON).concat(o.getAgencyId())).collect(Collectors.toList()); - List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,actulStartDate,formDTO.getEndDateId()); + List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,formDTO.getStartDateId(),formDTO.getEndDateId()); Map patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1)); subAgencyList.forEach(agency->{ From 65d8cbcd1911a5294c3185047baa5f75f401242f Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 1 Sep 2021 12:57:43 +0800 Subject: [PATCH 26/41] =?UTF-8?q?=E5=80=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastats/impl/DataStatsServiceImpl.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index 411be35b77..443b33c2fa 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1599,7 +1599,9 @@ public class DataStatsServiceImpl implements DataStatsService { }); } - List newResult = result.stream().sorted(Comparator.comparing(o -> o.getTopicToIssueTotal() + o.getIssueToProjectTotal() + o.getClosedProjectTotal() + o.getPatrolTotal())).collect(Collectors.toList()); + List newResult = result.stream().sorted(Comparator.comparing(o -> o.getTopicToIssueTotal() + o.getIssueToProjectTotal() + o.getClosedProjectTotal() + o.getPatrolTotal())) + .collect(Collectors.toList()); + Collections.reverse(newResult); return newResult; } From 59f134ef5455499dabe283e71fd438f0bb62255c Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 1 Sep 2021 13:22:04 +0800 Subject: [PATCH 27/41] =?UTF-8?q?=E3=80=82=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataaggre/service/datastats/impl/DataStatsServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index 443b33c2fa..748ba3cf82 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1494,7 +1494,7 @@ public class DataStatsServiceImpl implements DataStatsService { boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId()); switch (formDTO.getType()){ case "yesterday": - startDate = DateUtils.getBeforeNDay(formDTO.getDateId(),1); + startDate = formDTO.getDateId(); endDate = formDTO.getDateId(); break; case "thisWeek": From b1c45ef5582c8ab927daebf73314e97e5a98ea8e Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Wed, 1 Sep 2021 13:35:12 +0800 Subject: [PATCH 28/41] =?UTF-8?q?sql=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/epmetuser/CustomerStaffDao.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml index 9b5da74efb..cc2f8dab8b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml @@ -96,10 +96,10 @@ 'grid_manager' - , sr.created_time DESC + , sr.created_time DESC ) t GROUP BY t.staff_id - ORDER BY t.is_first ]]> 1 + ORDER BY t.is_first ]]> 1, t.staff_id desc LIMIT #{pageNo}, #{pageSize} From 7e1a228191be6d82720882bd5d035ff09e5f7dcc Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 1 Sep 2021 13:38:39 +0800 Subject: [PATCH 29/41] =?UTF-8?q?=E5=B7=AE=E5=80=BC=20=E5=B7=AE=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../datastats/impl/DataStatsServiceImpl.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index 748ba3cf82..eef006470e 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1490,21 +1490,25 @@ public class DataStatsServiceImpl implements DataStatsService { } String startDate = null; String endDate = formDTO.getDateId(); + String breforeStartDate = null; Date dateIdDate = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD); boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId()); switch (formDTO.getType()){ case "yesterday": startDate = formDTO.getDateId(); + breforeStartDate = startDate = DateUtils.getBeforeNDay(startDate,1); endDate = formDTO.getDateId(); break; case "thisWeek": startDate = DateUtils.getWeekStart(formDTO.getDateId()); + breforeStartDate = startDate = DateUtils.getBeforeNDay(startDate,1); if (!isYesterday){ endDate = DateUtils.getWeekEnd(formDTO.getDateId()); } break; case "thisMonth": startDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); + breforeStartDate = startDate = DateUtils.getBeforeNDay(startDate,1); if (!isYesterday) { endDate = DateUtils.format(DateUtils.getMonthEnd(dateIdDate), DateUtils.DATE_PATTERN_YYYYMMDD); } @@ -1525,17 +1529,17 @@ public class DataStatsServiceImpl implements DataStatsService { } List gridIdList = subAgencyList.stream().map(ScreenCustomerGridDTO::getGridId).collect(Collectors.toList()); //查询组织的话题转议题数据 - List toIssueStart = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, formDTO.getStartDateId()); + List toIssueStart = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, breforeStartDate); List toIssueEnd = dataStatsDao.getSubGridTopicShiftIssue(gridIdList, formDTO.getEndDateId()); Map toIssueStartMap = toIssueStart.stream().collect(Collectors.toMap(SubGridFormDTO.Topic::getGridId, SubGridFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); Map toIssueEndMap = toIssueEnd.stream().collect(Collectors.toMap(SubGridFormDTO.Topic::getGridId, SubGridFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); //查询组织的议题转项目数据 - List toProjectStart = dataStatsDao.getSubGridIssue(gridIdList, formDTO.getStartDateId()); + List toProjectStart = dataStatsDao.getSubGridIssue(gridIdList, breforeStartDate); List toProjectEnd = dataStatsDao.getSubGridIssue(gridIdList, formDTO.getEndDateId()); Map toProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubGridIssueResultDTO::getGridId, SubGridIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); Map toProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubGridIssueResultDTO::getGridId, SubGridIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); //查询组织已关闭的项目数据 - List closeProjectStart = dataStatsDao.getSubGridProject(gridIdList, formDTO.getStartDateId()); + List closeProjectStart = dataStatsDao.getSubGridProject(gridIdList, breforeStartDate); List closeProjectEnd = dataStatsDao.getSubGridProject(gridIdList, formDTO.getEndDateId()); Map closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); Map closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubGridProjectResultDTO::getGridId, SubGridProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); @@ -1565,23 +1569,23 @@ public class DataStatsServiceImpl implements DataStatsService { List agencyList = subAgencyList.stream().map(ScreenCustomerAgencyDTO::getAgencyId).collect(Collectors.toList()); //查询组织的话题转议题数据 - List toIssueStart = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getStartDateId()); + List toIssueStart = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, breforeStartDate); List toIssueEnd = dataStatsDao.getSubAgencyTopicShiftIssue(agencyList, formDTO.getEndDateId()); Map toIssueStartMap = toIssueStart.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); Map toIssueEndMap = toIssueEnd.stream().collect(Collectors.toMap(SubAgencyFormDTO.Topic::getAgencyId, SubAgencyFormDTO.Topic::getShiftedIssueTotal, (o1, o2) -> o1)); //查询组织的议题转项目数据 - List toProjectStart = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getStartDateId()); + List toProjectStart = dataStatsDao.getSubAgencyIssue(agencyList, breforeStartDate); List toProjectEnd = dataStatsDao.getSubAgencyIssue(agencyList, formDTO.getEndDateId()); Map toProjectStartMap = toProjectStart.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); Map toProjectEndMap = toProjectEnd.stream().collect(Collectors.toMap(SubAgencyIssueResultDTO::getAgencyId, SubAgencyIssueResultDTO::getShiftProjectTotal, (o1, o2) -> o1)); //查询组织已关闭的项目数据 - List closeProjectStart = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getStartDateId()); + List closeProjectStart = dataStatsDao.getSubAgencyProject(agencyList, breforeStartDate); List closeProjectEnd = dataStatsDao.getSubAgencyProject(agencyList, formDTO.getEndDateId()); Map closeProjectStartMap = closeProjectStart.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); Map closeProjectEndMap = closeProjectEnd.stream().collect(Collectors.toMap(SubAgencyProjectResultDTO::getAgencyId, SubAgencyProjectResultDTO::getClosedProjectTotal, (o1, o2) -> o1)); //巡查次数和时间 List agencyFullIds = subAgencyList.stream().map(o -> o.getPids().concat(StrConstant.COLON).concat(o.getAgencyId())).collect(Collectors.toList()); - List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,formDTO.getStartDateId(),formDTO.getEndDateId()); + List patrolList = statsStaffPatrolRecordDailyService.getPatrolSumList(agencyFullIds,breforeStartDate,formDTO.getEndDateId()); Map patrolListMap = patrolList.stream().collect(Collectors.toMap(PatrolDailySumResult::getFullAgencyId, o -> o, (o1, o2) -> o1)); subAgencyList.forEach(agency->{ From a574ef5683d1cf0c1cd1746ae7b94a71365d1f0c Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 1 Sep 2021 13:40:25 +0800 Subject: [PATCH 30/41] =?UTF-8?q?=E5=B7=AE=E5=80=BC=20=E5=B7=AE=E5=80=BC?= =?UTF-8?q?=20=E4=BB=A3=E7=A0=81=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/datastats/impl/DataStatsServiceImpl.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java index eef006470e..1002b8c34a 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/datastats/impl/DataStatsServiceImpl.java @@ -1490,25 +1490,21 @@ public class DataStatsServiceImpl implements DataStatsService { } String startDate = null; String endDate = formDTO.getDateId(); - String breforeStartDate = null; Date dateIdDate = DateUtils.parse(formDTO.getDateId(), DateUtils.DATE_PATTERN_YYYYMMDD); boolean isYesterday = DateUtils.getBeforeNDay(1,DateUtils.DATE_PATTERN_YYYYMMDD).equals(formDTO.getDateId()); switch (formDTO.getType()){ case "yesterday": startDate = formDTO.getDateId(); - breforeStartDate = startDate = DateUtils.getBeforeNDay(startDate,1); endDate = formDTO.getDateId(); break; case "thisWeek": startDate = DateUtils.getWeekStart(formDTO.getDateId()); - breforeStartDate = startDate = DateUtils.getBeforeNDay(startDate,1); if (!isYesterday){ endDate = DateUtils.getWeekEnd(formDTO.getDateId()); } break; case "thisMonth": startDate = DateUtils.format(DateUtils.getMonthStart(dateIdDate),DateUtils.DATE_PATTERN_YYYYMMDD); - breforeStartDate = startDate = DateUtils.getBeforeNDay(startDate,1); if (!isYesterday) { endDate = DateUtils.format(DateUtils.getMonthEnd(dateIdDate), DateUtils.DATE_PATTERN_YYYYMMDD); } @@ -1517,6 +1513,7 @@ public class DataStatsServiceImpl implements DataStatsService { log.warn("==========="); } formDTO.setStartDateId(startDate); + String breforeStartDate = DateUtils.getBeforeNDay(formDTO.getStartDateId(),1); formDTO.setEndDateId(endDate); log.info("getSubWorkFact do select param:{}", JSON.toJSONString(formDTO)); List result = new ArrayList<>(); From 23936ab7437da2e0535cd926c4ec5d4b28c374d0 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Wed, 1 Sep 2021 14:35:38 +0800 Subject: [PATCH 31/41] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=86=85=E6=9C=89?= =?UTF-8?q?=E5=8D=95=E4=BD=8D=E9=A2=86=E5=AF=BC=E6=A0=87=E7=AD=BE=E7=9A=84?= =?UTF-8?q?=E4=BA=BA=E6=8E=92=E5=9C=A8=E5=89=8D=E9=9D=A2=EF=BC=8C=E7=BD=91?= =?UTF-8?q?=E6=A0=BC=E5=86=85=E6=9C=89=E7=BD=91=E6=A0=BC=E9=95=BF=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E7=9A=84=E4=BA=BA=E6=8E=92=E5=9C=A8=E5=89=8D=E9=9D=A2?= =?UTF-8?q?=EF=BC=8C=E9=83=A8=E9=97=A8=E5=86=85=E6=9C=89=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E9=A2=86=E5=AF=BC=E6=A0=87=E7=AD=BE=E7=9A=84=E4=BA=BA=E6=8E=92?= =?UTF-8?q?=E5=9C=A8=E5=89=8D=E9=9D=A2=EF=BC=8C=E7=9B=B8=E5=90=8C=E8=81=8C?= =?UTF-8?q?=E4=BD=8D=E5=8F=8A=E5=85=B6=E4=BB=96=E8=81=8C=E4=BD=8D=E6=8C=89?= =?UTF-8?q?=E5=88=9B=E5=BB=BA=E9=A1=BA=E5=BA=8F=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/epmetuser/CustomerStaffDao.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml index cc2f8dab8b..07039eeed0 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/epmetuser/CustomerStaffDao.xml @@ -60,6 +60,7 @@ SELECT DISTINCT sr.staff_id, + cs.created_time, case when gsr.role_key = @@ -74,6 +75,7 @@ then 1 else 0 end is_first FROM staff_role sr + INNER JOIN customer_staff cs ON sr.staff_id = cs.user_id INNER JOIN gov_staff_role gsr ON sr.role_id = gsr.id AND gsr.customer_id = #{customerId} WHERE sr.del_flag = '0' @@ -96,10 +98,9 @@ 'grid_manager' - , sr.created_time DESC ) t GROUP BY t.staff_id - ORDER BY t.is_first ]]> 1, t.staff_id desc + ORDER BY t.is_first ]]> 1, t.created_time desc LIMIT #{pageNo}, #{pageSize} From 8d08abc80c2e6d5ff3f123ac4493a806e9d7ca64 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Wed, 1 Sep 2021 15:12:11 +0800 Subject: [PATCH 32/41] =?UTF-8?q?screenProjectOrgDaily=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ScreenProjectOrgDailyServiceImpl.java | 26 ++---- .../extract/FactOriginProjectMainDailyDao.xml | 91 +++++++++---------- .../screen/ScreenProjectOrgDailyDao.xml | 2 +- 3 files changed, 48 insertions(+), 71 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectOrgDailyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectOrgDailyServiceImpl.java index 3a37d17a40..9fbca67078 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectOrgDailyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenProjectOrgDailyServiceImpl.java @@ -184,44 +184,30 @@ public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl projectOrgDaily = baseDao.selectOrgProjectByAgency(agencyInfos, dateId); if (CollectionUtils.isEmpty(projectOrgDaily)){ log.info(String.format(PingYinConstants.SELECT_GRID_INFO_BY_ORG_IS_NULL,customerId)); return; } log.info(projectOrgDaily.toString()); - List createProjects = disposeCreateProject(agencyInfos, dateId); + agencyInfos = disposeCreateProject(agencyInfos, dateId); agencyInfos.forEach(a -> { a.setDateId(dateId); projectOrgDaily.forEach(p -> { if (a.getAreaCode().equals(p.getAreaCode())){ - a.setResolvedRatio(getRatio(p.getResolvedNum(),p.getProjectTotal())); - a.setBadRatio(getRatio(p.getBadTotal(),p.getEvaluateTotal())); - a.setGoodRatio(getRatio(p.getGoodTotal(),p.getEvaluateTotal())); - a.setBadTotal(p.getBadTotal()); - a.setEvaluateTotal(p.getEvaluateTotal()); - a.setGoodTotal(p.getGoodTotal()); - a.setProjectTotal(p.getProjectTotal()); - a.setResolvedNum(p.getResolvedNum()); - } - }); - }); - agencyInfos.forEach(a -> { - createProjects.forEach(p -> { - if (a.getOrgId().equals(p.getOrgId())){ a.setBadTotal(p.getBadTotal() + a.getBadTotal()); a.setEvaluateTotal(p.getEvaluateTotal() + a.getEvaluateTotal()); a.setGoodTotal(p.getGoodTotal() + a.getGoodTotal()); a.setProjectTotal(p.getProjectTotal() + a.getProjectTotal()); a.setResolvedNum(p.getResolvedNum() + a.getResolvedNum()); - a.setResolvedRatio(getRatio(a.getResolvedNum(),a.getProjectTotal())); - a.setBadRatio(getRatio(a.getBadTotal(),a.getEvaluateTotal())); - a.setGoodRatio(getRatio(a.getGoodTotal(),a.getEvaluateTotal())); + a.setResolvedRatio(getRatio(p.getResolvedNum(),p.getProjectTotal())); + a.setBadRatio(getRatio(p.getBadTotal(),p.getEvaluateTotal())); + a.setGoodRatio(getRatio(p.getGoodTotal(),p.getEvaluateTotal())); } }); }); log.info(agencyInfos.toString()); - del(customerId, dateId); insert(agencyInfos,customerId,dateId); } @@ -239,6 +225,7 @@ public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl projectOrgDaily = baseDao.selectOrgProject(agencyInfos, dateId); if (CollectionUtils.isEmpty(projectOrgDaily)){ log.info(String.format(PingYinConstants.SELECT_GRID_INFO_BY_ORG_IS_NULL,customerId)); @@ -278,7 +265,6 @@ public class ScreenProjectOrgDailyServiceImpl extends BaseServiceImpl diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml index 0700977462..841526476b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenProjectOrgDailyDao.xml @@ -138,7 +138,7 @@ FROM screen_project_grid_daily g LEFT JOIN screen_customer_grid cg ON cg.GRID_ID = g.GRID_ID WHERE g.DEL_FLAG = 0 - AND cg.PARENT_AGENCY_ID = #{a.orgId} + AND cg.ALL_PARENT_IDS LIKE CONCAT('%',#{a.orgId},'%') AND g.DATE_ID #{dateId} From 7d2ccc1906362aaff3e3b47b16397591d3100300 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 2 Sep 2021 09:51:42 +0800 Subject: [PATCH 33/41] =?UTF-8?q?selectMonthPieChart=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/screen/ScreenIndexDataMonthlyDao.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml index 43d30e9193..7b641de992 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml @@ -6,9 +6,9 @@ SELECT fact.index_code AS "indexCode", - ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal", + ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal", ROUND(fact.score,1) AS "indexTotalOriginScore", fact.WEIGHT AS "indexTotalSupWeight", ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml index 7c6be5ab92..8bb86a24b3 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml @@ -24,7 +24,7 @@ SELECT fact.index_code AS "indexCode", - ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal", + ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal", ROUND(fact.score,1) AS "indexTotalOriginScore", fact.WEIGHT AS "indexTotalSupWeight", ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", From 084be558edb1206ca8bc24ff5062529d90005aa0 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 2 Sep 2021 13:12:10 +0800 Subject: [PATCH 35/41] =?UTF-8?q?month/indexscore=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/mapper/screen/ScreenIndexDataMonthlyDao.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml index 7b641de992..8d6109753d 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml @@ -201,13 +201,13 @@ SELECT - ROUND(service_ablity,1) * SERVICE_ABLITY_WEIGHT AS serviceAbility, - ROUND(party_dev_ablity,1) * PARTY_DEV_WEIGHT AS partyDevAbility, - ROUND(govern_ablity,1) * GOVERN_ABLITY_WEIGHT AS governAbility, + ROUND((ROUND(service_ablity,1) * SERVICE_ABLITY_WEIGHT),1) AS serviceAbility, + ROUND((ROUND(party_dev_ablity,1) * PARTY_DEV_WEIGHT),1) AS partyDevAbility, + ROUND((ROUND(govern_ablity,1) * GOVERN_ABLITY_WEIGHT),1) AS governAbility, ROUND(service_ablity,1) serviceOriginScore, ROUND(party_dev_ablity,1) partyOriginScore, ROUND(govern_ablity,1) governOriginScore, @@ -38,9 +38,9 @@ SELECT sca.AGENCY_NAME AS NAME, - sy.govern_ablity * sy.GOVERN_ABLITY_WEIGHT AS governAbility, - sy.party_dev_ablity * sy.PARTY_DEV_WEIGHT AS partyDevAbility, - sy.service_ablity * sy.SERVICE_ABLITY_WEIGHT AS serviceAbility, + ROUND((ROUND(sy.govern_ablity,1) * sy.GOVERN_ABLITY_WEIGHT),1) AS governAbility, + ROUND((ROUND(sy.party_dev_ablity,1) * sy.PARTY_DEV_WEIGHT),1) AS partyDevAbility, + ROUND((ROUND(sy.service_ablity,1) * sy.SERVICE_ABLITY_WEIGHT),1) AS serviceAbility, sy.ORG_ID as orgId, sca.area_code as areaCode FROM screen_customer_agency sca @@ -382,9 +382,9 @@ SELECT - service_ablity AS serviceAbility, - party_dev_ablity AS partyDevAbility, - govern_ablity AS governAbility, + ROUND(service_ablity,1) AS serviceAbility, + ROUND(party_dev_ablity,1) AS partyDevAbility, + ROUND(govern_ablity,1) AS governAbility, year_id as yearId FROM screen_index_data_yearly From a2c2f99b2a91c006f26fc6510efb004db7e5b384 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Thu, 2 Sep 2021 16:50:29 +0800 Subject: [PATCH 37/41] =?UTF-8?q?=E8=AF=84=E4=BB=B7=E6=8C=87=E6=A0=87?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=20=E8=AE=BE=E7=BD=AE=E5=88=86=E5=80=BC?= =?UTF-8?q?=E7=9A=84=E6=8C=89=E7=85=A7=E3=80=90=E6=80=BB=E5=88=86=3D?= =?UTF-8?q?=E5=90=84=E4=B8=AA=E8=83=BD=E5=8A=9B=E5=80=BC=E5=9B=9B=E8=88=8D?= =?UTF-8?q?=E4=BA=94=E5=85=A5=E4=BF=9D=E7=95=99=E4=B8=80=E4=BD=8D=20*=20?= =?UTF-8?q?=E6=9D=83=E9=87=8D=20=E7=9B=B8=E5=8A=A0=EF=BC=8C=E7=BB=93?= =?UTF-8?q?=E6=9E=9C=E5=80=BC=E5=9B=9B=E8=88=8D=E4=BA=94=E5=85=A5=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E4=B8=80=E4=BD=8D=EF=BC=9B=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=20=20=20=E4=B8=89=E5=A4=A7=E8=83=BD=E5=8A=9B?= =?UTF-8?q?=E7=9A=84=E5=88=86=3D=E5=8E=9F=E5=A7=8B=E5=80=BC=E5=9B=9B?= =?UTF-8?q?=E8=88=8D=E4=BA=94=E5=85=A5=E4=BF=9D=E7=95=99=E4=B8=80=E4=BD=8D?= =?UTF-8?q?*=20=E6=9D=83=E9=87=8D=EF=BC=8C=E7=BB=93=E6=9E=9C=E5=80=BC?= =?UTF-8?q?=E5=9B=9B=E8=88=8D=E4=BA=94=E5=85=A5=E4=BF=9D=E7=95=99=E4=B8=80?= =?UTF-8?q?=E4=BD=8D=EF=BC=9B=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=E5=8D=95=E9=A1=B9=E5=8E=9F=E5=A7=8B=E5=80=BC=EF=BC=9A?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=9B=9B=E8=88=8D=E4=BA=94=E5=85=A5=E4=BF=9D?= =?UTF-8?q?=E7=95=99=E4=B8=80=E4=BD=8D=E5=B0=8F=E6=95=B0=EF=BC=9B=E3=80=91?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mapper/fact/FactIndexAgencyScoreDao.xml | 8 ++++---- .../mapper/fact/FactIndexAgencySubScoreDao.xml | 4 ++-- .../mapper/fact/FactIndexCommunityScoreDao.xml | 12 ++++++------ .../fact/FactIndexCommunitySubScoreDao.xml | 4 ++-- .../mapper/fact/FactIndexGridScoreDao.xml | 12 ++++++------ .../mapper/fact/FactIndexGridSubScoreDao.xml | 4 ++-- .../screen/ScreenIndexDataMonthlyDao.xml | 18 +++++++++--------- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml index 214385cc29..04fcae2efd 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencyScoreDao.xml @@ -6,7 +6,7 @@ SELECT fact.month_id AS "monthId", - ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal", + ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal", ROUND(fact.score,1) AS "indexTotalOriginScore", fact.WEIGHT AS "indexTotalSupWeight", - ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", - ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore", + ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore", + ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore", fact.index_code AS "indexCode", self.SELF_WEIGHT AS "selfWeight", self.SUB_WEIGHT AS "subWeight" diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml index aafd8dd25b..17354e06f7 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexAgencySubScoreDao.xml @@ -7,10 +7,10 @@ SELECT fact.index_code AS "key", IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value", - fact.score AS score, + round(fact.score,1) AS score, dict.index_name AS "name", round(fact.WEIGHT,2) AS weight, - (fact.SCORE * fact.WEIGHT) AS weightedScore + round(round(fact.SCORE,1) * fact.WEIGHT,1) AS weightedScore FROM fact_index_agency_sub_score fact LEFT JOIN index_dict dict ON fact.index_code = dict.index_code diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml index 8bb86a24b3..5f77c4950d 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunityScoreDao.xml @@ -6,7 +6,7 @@ SELECT fact.month_id AS "monthId", - ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal", + ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal", ROUND(fact.score,1) AS "indexTotalOriginScore", fact.WEIGHT AS "indexTotalSupWeight", - ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", - ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore", + ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore", + ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore", fact.index_code AS "indexCode", self.SELF_WEIGHT AS "selfWeight", self.SUB_WEIGHT AS "subWeight" diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml index 37290ed60a..11a9f85a9b 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexCommunitySubScoreDao.xml @@ -8,9 +8,9 @@ fact.index_code AS "key", IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value", dict.index_name AS "name", - fact.score AS score, + round(fact.score,1) AS score, round(fact.WEIGHT,2) AS weight, - (fact.SCORE * fact.WEIGHT) AS weightedScore + round(round(fact.SCORE,1) * fact.WEIGHT,1) AS weightedScore FROM fact_index_community_sub_score fact LEFT JOIN index_dict dict ON fact.index_code = dict.index_code diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml index 9be33bd524..c152cbd144 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridScoreDao.xml @@ -6,7 +6,7 @@ SELECT fact.month_id AS "monthId", - ROUND(fact.score*fact.WEIGHT, 1) AS "indexTotal", + ROUND(ROUND(fact.score,1)*fact.WEIGHT, 1) AS "indexTotal", ROUND(fact.score,1) AS "indexTotalOriginScore", fact.WEIGHT AS "indexTotalSupWeight", - ROUND(self.self_score*fact.WEIGHT, 1) AS "agencyScore", - ROUND(self.sub_score*fact.WEIGHT, 1) AS "subAgencyScore", + ROUND(ROUND(self.self_score,1)*fact.WEIGHT, 1) AS "agencyScore", + ROUND(ROUND(self.sub_score,1)*fact.WEIGHT, 1) AS "subAgencyScore", fact.index_code AS "indexCode", self.SELF_WEIGHT AS "selfWeight", self.SUB_WEIGHT AS "subWeight" diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml index 1fda25b3ac..f3127095e7 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/fact/FactIndexGridSubScoreDao.xml @@ -8,9 +8,9 @@ fact.index_code AS "key", IF(fact.origin_value='',0,IFNULL(fact.origin_value,0)) AS "value", dict.index_name AS "name", - fact.score AS score, + round(fact.score,1) AS score, round(fact.WEIGHT,2) AS weight, - (fact.SCORE * fact.WEIGHT) AS weightedScore + round(round(fact.SCORE,1) * fact.WEIGHT,1) AS weightedScore FROM fact_index_grid_sub_score fact LEFT JOIN index_dict dict ON fact.index_code = dict.index_code diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml index 03f4da3f4f..d6ad50cc2b 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml @@ -88,9 +88,9 @@ resultType="com.epmet.evaluationindex.screen.dto.result.AnNingSubAgencyIndexRankResultDTO"> SELECT score.org_name AS `NAME`, - score.service_ablity * score.SERVICE_ABLITY_WEIGHT AS serviceAbility, - score.party_dev_ablity * score.PARTY_DEV_WEIGHT AS partyDevAbility, - score.govern_ablity * score.GOVERN_ABLITY_WEIGHT AS governAbility, + ROUND(ROUND(score.service_ablity,1) * score.SERVICE_ABLITY_WEIGHT, 1) AS serviceAbility, + ROUND(ROUND(score.party_dev_ablity,1) * score.PARTY_DEV_WEIGHT, 1) AS partyDevAbility, + ROUND(ROUND(score.govern_ablity,1) * score.GOVERN_ABLITY_WEIGHT, 1) AS governAbility, score.PARTY_DEV_WEIGHT AS partyWeight, score.GOVERN_ABLITY_WEIGHT AS governWeight, score.SERVICE_ABLITY_WEIGHT AS serviceWeight, @@ -156,13 +156,13 @@ org_id AS "orgId", org_name AS "orgName", - round((party_dev_ablity * party_dev_weight),1) AS "score" + round(round(party_dev_ablity,1) * party_dev_weight,1) AS "score" - round((govern_ablity * govern_ablity_weight),1) AS "score" + round(round(govern_ablity,1) * govern_ablity_weight,1) AS "score" - round((service_ablity * service_ablity_weight),1) AS "score" + round(round(service_ablity,1) * service_ablity_weight,1) AS "score" FROM screen_index_data_monthly @@ -406,9 +406,9 @@ resultType="com.epmet.evaluationindex.screen.dto.result.AnNingSubAgencyIndexRankResultDTO"> SELECT score.org_name AS `NAME`, - score.service_ablity * score.SERVICE_ABLITY_WEIGHT AS serviceAbility, - score.party_dev_ablity * score.PARTY_DEV_WEIGHT AS partyDevAbility, - score.govern_ablity * score.GOVERN_ABLITY_WEIGHT AS governAbility, + ROUND(ROUND(score.service_ablity,1)*score.SERVICE_ABLITY_WEIGHT, 1)AS serviceAbility, + ROUND(ROUND(score.party_dev_ablity,1) * score.PARTY_DEV_WEIGHT, 1) AS partyDevAbility, + ROUND(ROUND(score.govern_ablity,1) * score.GOVERN_ABLITY_WEIGHT, 1) AS governAbility, score.PARTY_DEV_WEIGHT AS partyWeight, score.GOVERN_ABLITY_WEIGHT AS governWeight, score.SERVICE_ABLITY_WEIGHT AS serviceWeight, From a61fd17deb0679dee3d4b3af7333b8988bd6e3f0 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Thu, 2 Sep 2021 17:10:12 +0800 Subject: [PATCH 38/41] =?UTF-8?q?=E7=BB=84=E7=BB=87=E4=B8=8B=E4=B8=8D?= =?UTF-8?q?=E5=85=81=E8=AE=B8=E7=9C=8B=E5=88=B0=E9=9D=9E=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=9A=84=E4=BA=BA=E5=91=98=E3=80=81=E9=83=A8?= =?UTF-8?q?=E9=97=A8=E7=BD=91=E6=A0=BC=E4=B8=8B=E6=B7=BB=E5=8A=A0=E7=9A=84?= =?UTF-8?q?=E4=BA=BA=E4=B8=8D=E5=85=81=E8=AE=B8=E5=86=8D=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E7=BD=91=E6=A0=BC=E4=B8=8B=E7=A7=BB=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/epmetuser/result/ListStaffResultDTO.java | 2 ++ .../service/govorg/impl/GovOrgServiceImpl.java | 14 ++++++++------ .../mapper/govorg/CustomerStaffAgencyDao.xml | 12 +++++++----- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java index b465f8ec3e..ae926bd6ee 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmetuser/result/ListStaffResultDTO.java @@ -31,5 +31,7 @@ public class ListStaffResultDTO implements Serializable { private String orgName = ""; //职责名称列表 private List roles; + //工作人员添加入口类型(组织:agency;部门:dept;网格:gridId) + private String orgType = ""; } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java index 5a56be39c6..b7b23299ab 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/govorg/impl/GovOrgServiceImpl.java @@ -1,7 +1,6 @@ package com.epmet.dataaggre.service.govorg.impl; import com.alibaba.fastjson.JSON; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; @@ -12,11 +11,6 @@ import com.epmet.dataaggre.dao.govorg.*; import com.epmet.dataaggre.dto.epmetuser.result.ListStaffResultDTO; import com.epmet.dataaggre.dto.epmetuser.result.StaffRoleListResultDTO; import com.epmet.dataaggre.dto.govorg.*; -import com.epmet.dataaggre.dto.govorg.form.*; -import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO; -import com.epmet.dataaggre.dto.govorg.CustomerDepartmentDTO; -import com.epmet.dataaggre.dto.govorg.CustomerGridDTO; -import com.epmet.dataaggre.dto.govorg.CustomerStaffAgencyDTO; import com.epmet.dataaggre.dto.govorg.form.NextAreaCodeFormDTO; import com.epmet.dataaggre.dto.govorg.form.OrgStaffListFormDTO; import com.epmet.dataaggre.dto.govorg.form.StaffDetailV2FormDTO; @@ -38,6 +32,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.stream.Collectors; /** * @Author zxc @@ -401,6 +396,13 @@ public class GovOrgServiceImpl implements GovOrgService { //2.分页查询工作人员基础信息、角色信息【组织人员单位领导角色人员在前;部门人员部门领导角色人员在前;网格人员网格长角色人员在前】 List staffList = epmetUserService.getStaffInfoList(formDTO); + //3.查询工作人员注册组织关系信息 + List staffIdList = staffList.stream().map(ListStaffResultDTO::getStaffId).collect(Collectors.toList()); + if (!CollectionUtils.isEmpty(staffIdList)){ + List list = customerAgencyDao.selelctStaffOrg(staffIdList); + staffList.forEach(re -> list.stream().filter(l -> re.getStaffId().equals(l.getStaffId())).forEach(s -> re.setOrgType(s.getOrgType()))); + } + //3.封装数据并返回 resultDTO.setStaffCount(staffIds.size()); resultDTO.setStaffList((null == staffList ? new ArrayList<>() : staffList)); diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml index 65afdbabdd..55c4d7789c 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/resources/mapper/govorg/CustomerStaffAgencyDao.xml @@ -77,14 +77,16 @@ SELECT - user_id + csa.user_id FROM - customer_staff_agency + customer_staff_agency csa + INNER JOIN staff_org_relation sor ON csa.user_id = sor.staff_id WHERE - del_flag = '0' - AND agency_id = #{orgId} + csa.del_flag = '0' + AND sor.org_type = 'agency' + AND csa.agency_id = #{orgId} ORDER BY - created_time ASC + csa.created_time ASC From 906dd8120577aec9bd994ed27ccc2e29d5697d09 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 3 Sep 2021 09:48:25 +0800 Subject: [PATCH 39/41] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=96=B0=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../screen/dto/result/SubAgencyIndexRankResultDTO.java | 3 +++ .../main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubAgencyIndexRankResultDTO.java b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubAgencyIndexRankResultDTO.java index af9d6caf5e..ae70697765 100644 --- a/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubAgencyIndexRankResultDTO.java +++ b/epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/SubAgencyIndexRankResultDTO.java @@ -27,16 +27,19 @@ public class SubAgencyIndexRankResultDTO implements Serializable { * 党建能力 */ private Double governAbility = 0.0; + private Double originGovernAbility = 0.0; /** * 治理能力 */ private Double partyDevAbility = 0.0; + private Double originPartyDevAbility = 0.0; /** * 服务能力 */ private Double serviceAbility = 0.0; + private Double originServiceAbility = 0.0; private String orgId; private String orgType; diff --git a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml index d6ad50cc2b..8b4eed6642 100644 --- a/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml +++ b/epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml @@ -363,6 +363,9 @@ ROUND((ROUND(sy.govern_ablity,1) * sy.GOVERN_ABLITY_WEIGHT),1) AS governAbility, ROUND((ROUND(sy.party_dev_ablity,1) * sy.PARTY_DEV_WEIGHT),1) AS partyDevAbility, ROUND((ROUND(sy.service_ablity,1) * sy.SERVICE_ABLITY_WEIGHT),1) AS serviceAbility, + ROUND(sy.govern_ablity,1) AS originGovernAbility, + ROUND(sy.party_dev_ablity,1) AS originPartyDevAbility, + ROUND(sy.service_ablity,1) AS originServiceAbility, sy.ORG_ID as orgId, sca.area_code as areaCode FROM screen_customer_agency sca From 1298b0acd77f5e2348cef3f5733990c1292a8902 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 6 Sep 2021 10:34:44 +0800 Subject: [PATCH 40/41] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E7=9A=84error=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/PartyBranchManageServiceImpl.java | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java index 0cf320e03f..e4e806573a 100644 --- a/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java +++ b/epmet-module/gov-grid/gov-grid-server/src/main/java/com/epmet/service/impl/PartyBranchManageServiceImpl.java @@ -137,17 +137,14 @@ public class PartyBranchManageServiceImpl implements PartyBranchManageService { CustomerPartyBranchDTO customerPartyBranch = customerPartyBranchResult.getData(); PartyMemberBaseInfoAddFormDTO partyMemberBaseInfoAddFormDTO = this.getPartyMemberBaseInfoAddFormDTO(formDTO, customerPartyBranch); Result result = resiPartyMemberOpenFeignClient.addPartyMemberBaseInfo(partyMemberBaseInfoAddFormDTO); + if (!result.success() || StringUtils.isBlank(result.getData())) { + throw new RenException(result.getCode(), result.getMsg()); + } //3、党支部总人数+1 - if (result.success() && StringUtils.isNotBlank(result.getData())) { - //党支部总人数+1 - customerPartyBranch.setTotalPartyMember(customerPartyBranch.getTotalPartyMember() + 1); - Result updatePartyBranchResult = govOrgOpenFeignClient.updatePartyBranch(customerPartyBranch); - if (updatePartyBranchResult.success()) { - logger.info(String.format("党支部(%s)总人数+1", formDTO.getPartyBranchId())); - } - } else { - logger.error("添加党员异常"); - throw new RenException(result.getCode()); + customerPartyBranch.setTotalPartyMember(customerPartyBranch.getTotalPartyMember() + 1); + Result updatePartyBranchResult = govOrgOpenFeignClient.updatePartyBranch(customerPartyBranch); + if (updatePartyBranchResult.success()) { + logger.info(String.format("党支部(%s)总人数+1", formDTO.getPartyBranchId())); } return result.getData(); } From 4777b56d32502c544a2639bb9381f42103c571e6 Mon Sep 17 00:00:00 2001 From: jianjun Date: Wed, 8 Sep 2021 17:40:31 +0800 Subject: [PATCH 41/41] wxController --- .../com/epmet/controller/WxController.java | 125 ++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/WxController.java diff --git a/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/WxController.java b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/WxController.java new file mode 100644 index 0000000000..71fc73ef60 --- /dev/null +++ b/epmet-module/epmet-demo/epmet-demo-server/src/main/java/com/epmet/controller/WxController.java @@ -0,0 +1,125 @@ + +package com.epmet.controller; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.util.Arrays; + + +/** + * desc:微信配置测试 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-08 + */ +@RestController +@RequestMapping("wechat") +public class WxController { + private static Logger log = LoggerFactory.getLogger(WxController.class); + + + @RequestMapping("check") + public void doGet(HttpServletRequest request, HttpServletResponse response) { + log.debug("weixin get..."); + // 微信加密签名,signature结合了开发者填写的token参数和请求中的timestamp参数、nonce参数。 + String signature = request.getParameter("signature"); + // 时间戳 + String timestamp = request.getParameter("timestamp"); + // 随机数 + String nonce = request.getParameter("nonce"); + // 随机字符串 + String echostr = request.getParameter("echostr"); + + // 通过检验signature对请求进行校验,若校验成功则原样返回echostr,表示接入成功,否则接入失败 + PrintWriter out = null; + try { + out = response.getWriter(); + if (WxController.checkSignature(signature, timestamp, nonce)) { + log.debug("weixin get success...."); + out.print(echostr); + } + } catch (IOException e) { + e.printStackTrace(); + } finally { + if (out != null) + out.close(); + } + } + + /** + * 与接口配置信息中的Token要一致 + */ + private static String token = "o2opri3hschiwit"; + + /** + * 验证签名 + * + * @param signature + * @param timestamp + * @param nonce + * @return + */ + public static boolean checkSignature(String signature, String timestamp, String nonce) { + String[] arr = new String[]{token, timestamp, nonce}; + // 将token、timestamp、nonce三个参数进行字典序排序 + Arrays.sort(arr); + StringBuilder content = new StringBuilder(); + for (int i = 0; i < arr.length; i++) { + content.append(arr[i]); + } + MessageDigest md = null; + String tmpStr = null; + + try { + md = MessageDigest.getInstance("SHA-1"); + // 将三个参数字符串拼接成一个字符串进行sha1加密 + byte[] digest = md.digest(content.toString().getBytes()); + tmpStr = byteToStr(digest); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + + content = null; + // 将sha1加密后的字符串可与signature对比,标识该请求来源于微信 + return tmpStr != null ? tmpStr.equals(signature.toUpperCase()) : false; + } + + /** + * 将字节数组转换为十六进制字符串 + * + * @param byteArray + * @return + */ + private static String byteToStr(byte[] byteArray) { + String strDigest = ""; + for (int i = 0; i < byteArray.length; i++) { + strDigest += byteToHexStr(byteArray[i]); + } + return strDigest; + } + + /** + * 将字节转换为十六进制字符串 + * + * @param mByte + * @return + */ + private static String byteToHexStr(byte mByte) { + char[] Digit = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + char[] tempArr = new char[2]; + tempArr[0] = Digit[(mByte >>> 4) & 0X0F]; + tempArr[1] = Digit[mByte & 0X0F]; + + String s = new String(tempArr); + return s; + } +}