diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/CustomerApplicationRunner.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/CustomerApplicationRunner.java new file mode 100644 index 0000000000..b1bfe5d08e --- /dev/null +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/aspect/CustomerApplicationRunner.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.commons.tools.aspect; + +import com.epmet.commons.tools.dto.form.DingTalkTextMsg; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.commons.tools.utils.HttpClientManager; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.SpringContextUtils; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.cloud.commons.util.InetUtils; +import org.springframework.core.annotation.Order; +import org.springframework.stereotype.Component; + +/** + * 应用 启动健康检查 通知类 + * CustomerApplicationRunner + * + * @author Mark sunlightcs@gmail.com + * @since 1.0.0 + */ +@Component +@Order(value = 99) +public class CustomerApplicationRunner implements ApplicationRunner { + private static Logger logger = LogManager.getLogger(CustomerApplicationRunner.class); + @Value("${spring.application.name}") + private String appName; + + @Override + public void run(ApplicationArguments args) { + //发送启动成功消息 + EnvEnum currentEnv = EnvEnum.getCurrentEnv(); + if (!EnvEnum.DEV.getCode().equals(currentEnv.getCode())) { + InetUtils inetUtils = SpringContextUtils.getBean(InetUtils.class); + String serverIp = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); + + //开发小组 群机器人地址 + String url = "https://oapi.dingtalk.com/robot/send?access_token=ffd7c972b0525e249283df1a16b65a8b9d0012601f3a458dfc588c2eac497bb5"; + StringBuilder stringBuilder = new StringBuilder(); + stringBuilder.append(EnvEnum.getCurrentEnv().getName()) + .append("【") + .append(appName) + .append("】") + .append("ip地址: ") + .append(serverIp) + .append("部署完毕!"); + DingTalkTextMsg msg = new DingTalkTextMsg(); + msg.setWebHook(url); + msg.setAtAll(true); + msg.setContent(stringBuilder.toString()); + Result stringResult = HttpClientManager.getInstance().sendPostByJSON(url, msg.getMsgContent()); + logger.info(stringResult); + } + } + +} diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index 80100ea470..fffbc50cc8 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -108,6 +108,7 @@ public enum EpmetErrorCode { OPER_EXTERNAL_APP_EXISTS(8711, "应用已存在"), OPER_CUSTOMER_FOOTBAR_EXISTS(8712, "footbar已存在"), OPER_CUSTOMER_FOOTBAR_NOT_FOUND(8713, "footbar不存在"), + OPER_EXT_APP_SECRET_RESET_FAIL(8712, "秘钥更新失败"), // 党建声音 前端提示 88段 DRAFT_CONTENT_IS_NULL(8801, "至少需要添加一个段落"), diff --git a/epmet-gateway/pom.xml b/epmet-gateway/pom.xml index 847c53fbd2..42687e7517 100644 --- a/epmet-gateway/pom.xml +++ b/epmet-gateway/pom.xml @@ -182,7 +182,7 @@ lb://data-statistical-server - + lb://epmet-openapi-scan diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java index bc7295ccda..f02185071f 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java @@ -31,6 +31,8 @@ public interface IndexCalConstant { String STREET_LEVEL = "street"; + String DISTRICT_LEVEL = "district"; + String COMMUNITY_RELATE = "shequxiangguan"; @@ -55,7 +57,9 @@ public interface IndexCalConstant { String INDEX_DETAIL_LIST_NULL = "指标明细查询集合为空"; String COMMUNITY_PARTY_AVG_NULL = "查询下属所有【社区】的党建能力平均值集合为空"; String GRID_PARTY_AVG_NULL = "查询下属所有【网格】的党建能力平均值集合为空"; + String DISTRICT_PARTY_AVG_NULL = "查询【区县】的党建能力平均值集合为空"; String STREET_PUBLISH_ARTICLE_LIST_NULL = "查询【街道】名义发文数量集合为空"; + String DISTRICT_PUBLISH_ARTICLE_LIST_NULL = "查询【区/县】名义发文数量集合为空"; String COMMUNITY_PUBLISH_ARTICLE_LIST_NULL = "查询【社区】名义发文数量集合为空"; String INDEX_CODE_NULL = "指标Code未查询出对应字段 【 %s 】"; String STREET_GOVERN_ABILITY_NULL = "查询【街道】治理能力的六个五级指标集合为空"; diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubAgencyScoreAvgResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubAgencyScoreAvgResultDTO.java new file mode 100644 index 0000000000..f88e035b7b --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubAgencyScoreAvgResultDTO.java @@ -0,0 +1,51 @@ +package com.epmet.dto.indexcal; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * @Author zxc + * @DateTime 2020/9/4 9:32 上午 + */ +@Data +public class SubAgencyScoreAvgResultDTO implements Serializable { + + private static final long serialVersionUID = 6913351504675726385L; + + /** + * + */ + private String customerId; + + /** + * 机关ID + */ + private String agencyId; + + /** + * 上级组织ID + */ + private String parentId; + + /** + * 月度ID + */ + private String monthId; + + /** + * 季度ID + */ + private String quarterId; + + /** + * 年度ID + */ + private String yearId; + + /** + * 分数 + */ + private BigDecimal score; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataDetailFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataDetailFormDTO.java new file mode 100644 index 0000000000..364b19c34f --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataDetailFormDTO.java @@ -0,0 +1,96 @@ +package com.epmet.dto.indexcollect.form; + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 1、党建能力-党员相关指标上报(按照月份) 入参 + * + * @author yinzuomei@elink-cn.com + * @date 2020/9/4 16:04 + */ +@Data +public class GridPartyMemberDataDetailFormDTO implements Serializable { + private static final long serialVersionUID = 2923515319015973995L; + /** + * 机关id:网格所属的组织id + */ + private String agencyId; + + /** + * 网格id + */ + private String gridId; + + /** + * yyyyMM + */ + private String monthId; + + /** + * yyyyQ1, yyyyQ2, yyyyQ3, yyyyQ4 + */ + private String quarterId; + + /** + * yyyy + */ + private String yearId; + + /** + * 党员提出的话题数 + */ + private Integer createTopicCount; + + /** + * 党员参与话题数(支持,反对,评论,浏览) + */ + private Integer joinTopicCount; + + /** + * 话题转议题数 + */ + private Integer shiftIssueCount; + + /** + * 议题转项目数 + */ + private Integer shiftProjectCount; + + /** + * 参加三会一课次数 + */ + private Integer joinThreeMeetsCount; + + /** + * 自建群群众人数 + */ + private Integer groupUserCount; + + /** + * 自建群活跃度-话题数 + */ + private Integer groupTopicCount; + + /** + * 议题转项目率 + */ + private BigDecimal topicToIssueRatio; + + /** + * 上级组织Id + */ + private String parentId; + + /** + * 党员自建群活跃群众人数(08-24) + */ + private Integer groupActiveUserCount; + + /** + * 用户id + */ + private String userId; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataFormDTO.java index 3c7c7a5141..5a0a9fb3c8 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/GridPartyMemberDataFormDTO.java @@ -3,8 +3,11 @@ package com.epmet.dto.indexcollect.form; import lombok.Data; import org.apache.poi.hpsf.Decimal; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import java.io.Serializable; import java.math.BigDecimal; +import java.util.List; /** * 1、党建能力-党员相关指标上报(按照月份) 入参 @@ -17,82 +20,14 @@ public class GridPartyMemberDataFormDTO implements Serializable { private static final long serialVersionUID = 1L; /** - * 机关id:网格所属的组织id + * 当为true时后台将删除本月数据 */ - private String agencyId; - - /** - * 网格id - */ - private String gridId; + private Boolean isFirst; /** * yyyyMM */ private String monthId; - /** - * yyyyQ1, yyyyQ2, yyyyQ3, yyyyQ4 - */ - private String quarterId; - - /** - * yyyy - */ - private String yearId; - - /** - * 党员提出的话题数 - */ - private Integer createTopicCount; - - /** - * 党员参与话题数(支持,反对,评论,浏览) - */ - private Integer joinTopicCount; - - /** - * 话题转议题数 - */ - private Integer shiftIssueCount; - - /** - * 议题转项目数 - */ - private Integer shiftProjectCount; - - /** - * 参加三会一课次数 - */ - private Integer joinThreeMeetsCount; - - /** - * 自建群群众人数 - */ - private Integer groupUserCount; - - /** - * 自建群活跃度-话题数 - */ - private Integer groupTopicCount; - - /** - * 议题转项目率 - */ - private BigDecimal topicToIssueRatio; - - /** - * 上级组织Id - */ - private String parentId; - - /** - * 党员自建群活跃群众人数(08-24) - */ - private Integer groupActiveUserCount; - - /** - * 用户id - */ - private String userId; + private List partyMemberDataList; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexGridScoreDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexGridScoreDTO.java index 6590da34cb..4d26f40f48 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexGridScoreDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexGridScoreDTO.java @@ -60,24 +60,24 @@ public class FactIndexGridScoreDTO implements Serializable { private String monthId; /** - * 总指数分值 + * 年维度Id: yyyy */ - private BigDecimal totalScore; + private String yearId; /** - * 党建能力分值 + * 1:总分;0不是;默认0 */ - private BigDecimal partyAblityScore; + private String isTotal; /** - * 治理能力分值 + * 分值 */ - private BigDecimal govrnAblityScore; + private BigDecimal score; /** - * 服务能力分值 + * 党建能力:dangjiannengli;治理能力:zhilinengli;服务能力:fuwunengli;网格相关(前三者之和):wanggexiangguan */ - private BigDecimal serviceAblityScore; + private String indexCode; /** * 删除标识 0未删除;1已删除 @@ -109,4 +109,4 @@ public class FactIndexGridScoreDTO implements Serializable { */ private Date updatedTime; -} \ No newline at end of file +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataDetailFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataDetailFormDTO.java new file mode 100644 index 0000000000..ab77a2363c --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataDetailFormDTO.java @@ -0,0 +1,105 @@ +package com.epmet.dto.screencoll.form; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 描述一下 + * + * @author yinzuomei@elink-cn.com + * @date 2020/9/4 15:43 + */ +@Data +public class DifficultyDataDetailFormDTO implements Serializable { + private static final long serialVersionUID = 4893795146396420078L; + /** + * 组织类别 agency:组织;部门:department;网格:grid + */ + private String orgType; + + /** + * 组织Id 可以为网格,机关id + */ + private String orgId; + + /** + * 上级组织Id + */ + private String parentId; + + /** + * 组织名称 + */ + private String orgName; + + /** + * 事件原Id + */ + private String eventId; + + /** + * 事件图片 URL + */ + private String eventImgUrl; + + /** + * 事件来源 eg: XXX街道-xx社区-网格 + */ + private String eventSource; + + /** + * 事件内容 + */ + private String eventContent; + + /** + * 事件耗时单位:分钟 + */ + private Integer eventCostTime; + + /** + * 事件设计部门数 + */ + private Integer eventReOrg; + + /** + * 事件类别编码 + */ + private String eventCategoryCode; + + /** + * 事件状态编码 + */ + private String eventStatusCode; + + /** + * 事件类别名称 + */ + private String eventCategoryName; + + /** + * 事件状态描述 + */ + private String eventStatusDesc; + + /** + * 最近一次操作说明 eg: 转项目,结案,流转 + */ + private String latestOperateDesc; + + /** + * 事件被处理次数(08-21新增) + */ + private Integer eventHandledCount; + + /** + * 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增) + */ + private String dataEndTime; + + /** + * 所有上级ID,用英文逗号分开(8.26新增) + */ + private String allParentIds; +} diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataFormDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataFormDTO.java index e446e073a3..a0de181acb 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataFormDTO.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/DifficultyDataFormDTO.java @@ -3,6 +3,7 @@ package com.epmet.dto.screencoll.form; import lombok.Data; import java.io.Serializable; +import java.util.List; /** * 3、难点赌点 入参 @@ -11,96 +12,15 @@ import java.io.Serializable; */ @Data public class DifficultyDataFormDTO implements Serializable { - private static final long serialVersionUID = 1L; - /** - * 组织类别 agency:组织;部门:department;网格:grid + * 当为true时后台将删除本月数据 */ - private String orgType; + private Boolean isFirst; /** - * 组织Id 可以为网格,机关id + * 难点堵点数据 */ - private String orgId; + private List diffcultyDataList; - /** - * 上级组织Id - */ - private String parentId; - - /** - * 组织名称 - */ - private String orgName; - - /** - * 事件原Id - */ - private String eventId; - - /** - * 事件图片 URL - */ - private String eventImgUrl; - - /** - * 事件来源 eg: XXX街道-xx社区-网格 - */ - private String eventSource; - - /** - * 事件内容 - */ - private String eventContent; - - /** - * 事件耗时单位:分钟 - */ - private Integer eventCostTime; - - /** - * 事件设计部门数 - */ - private Integer eventReOrg; - - /** - * 事件类别编码 - */ - private String eventCategoryCode; - - /** - * 事件状态编码 - */ - private String eventStatusCode; - - /** - * 事件类别名称 - */ - private String eventCategoryName; - - /** - * 事件状态描述 - */ - private String eventStatusDesc; - - /** - * 最近一次操作说明 eg: 转项目,结案,流转 - */ - private String latestOperateDesc; - - /** - * 事件被处理次数(08-21新增) - */ - private Integer eventHandledCount; - - /** - * 数据更新至: yyyy|yyyyMM|yyyyMMdd(08-21新增) - */ - private String dataEndTime; - - /** - * 所有上级ID,用英文逗号分开(8.26新增) - */ - private String allParentIds; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/OrgTypeConstant.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/OrgTypeConstant.java new file mode 100644 index 0000000000..95919792d9 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/OrgTypeConstant.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.constant; + +/** + * 组织类别 常量 + * + * @author sun + * @since 1.0.0 + */ +public interface OrgTypeConstant { + + /** + * 部门 + */ + String DEPARTMENT = "department"; + + /** + * 网格 + */ + String GRID = "grid"; + + /** + * 组织 + */ + String AGENCY = "agency"; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index 380b2f3b86..397d99df7a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -17,10 +17,7 @@ import com.epmet.entity.evaluationindex.indexcoll.FactIndexServiceAblityGridMont import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; import com.epmet.entity.stats.DimAgencyEntity; import com.epmet.service.StatsDemoService; -import com.epmet.service.evaluationindex.indexcal.DeptScoreService; -import com.epmet.service.evaluationindex.indexcal.GridCorreLationService; -import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService; -import com.epmet.service.evaluationindex.indexcal.IndexCalculateStreetService; +import com.epmet.service.evaluationindex.indexcal.*; import com.epmet.service.stats.DimAgencyService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -56,6 +53,8 @@ public class DemoController { private IndexCalculateStreetService indexCalculateStreetService; @Autowired private DeptScoreService deptScoreService; + @Autowired + private IndexCalculateDistrictService indexCalculateDistrictService; @GetMapping("testAlarm") public void testAlarm() { @@ -456,4 +455,11 @@ public class DemoController { String monthId = "202008"; indexCalculateStreetService.calStreetAll(customerId,monthId); } + + @PostMapping("districtZxc") + public void getDistrict(){ + String customerId = "b09527201c4409e19d1dbc5e3c3429a1"; + String monthId = "202008"; + indexCalculateDistrictService.calDistrictAll(customerId,monthId); + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactIndexCollectController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactIndexCollectController.java index eaa7c921b1..138ab5cbb7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactIndexCollectController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/FactIndexCollectController.java @@ -4,12 +4,10 @@ import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth; import com.epmet.commons.extappauth.bean.ExternalAppRequestParam; import com.epmet.commons.tools.utils.Result; import com.epmet.dto.indexcollect.form.*; +import com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO; import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import java.util.List; @@ -37,8 +35,8 @@ public class FactIndexCollectController { **/ @ExternalAppRequestAuth @PostMapping("gridpartymemberdata") - public Result gridPartyMemberData(ExternalAppRequestParam externalAppRequestParam, @RequestBody List formDTO) { - factIndexCollectService.insertGridPartyMemberData(formDTO, externalAppRequestParam.getCustomerId()); + public Result gridPartyMemberData(ExternalAppRequestParam externalAppRequestParam, @RequestBody GridPartyMemberDataFormDTO formDTO) { + factIndexCollectService.insertGridPartyMemberData(formDTO,externalAppRequestParam.getCustomerId() ); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenCollController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenCollController.java index 99ba483433..d83f8df3c5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenCollController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenCollController.java @@ -133,7 +133,7 @@ public class ScreenCollController { **/ @ExternalAppRequestAuth @PostMapping("difficultydata") - public Result difficultyData(ExternalAppRequestParam externalAppRequestParam, @RequestBody List formDTO) { + public Result difficultyData(ExternalAppRequestParam externalAppRequestParam, @RequestBody DifficultyDataFormDTO formDTO) { screenCollService.insertDifficultyData(formDTO, externalAppRequestParam.getCustomerId()); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java index 5c6a90ad02..b30d2751d1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java @@ -19,7 +19,7 @@ package com.epmet.dao.evaluationindex.indexcal; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.indexcal.AgencyScoreDTO; -import com.epmet.dto.screen.FactIndexCommunityScoreDTO; +import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO; import com.epmet.entity.evaluationindex.indexcal.AgencyScoreEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -27,7 +27,7 @@ import org.apache.ibatis.annotations.Param; import java.util.List; /** - * 区/街道相关分数表 + * 区/街道相关分数表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-09-02 @@ -54,12 +54,31 @@ public interface AgencyScoreDao extends BaseDao { void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("dataType")String dataType); /** - * @Description 查询街道相关信息 + * @Description 查询【fact_index_agency_score】相关信息 * @param customerId * @param monthId * @author zxc * @date 2020/9/1 9:41 上午 */ - List selectStreetInfo(@Param("customerId") String customerId, @Param("monthId")String monthId,@Param("dataType")String dataType); + List selectAgencyScoreInfo(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("dataType")String dataType); -} \ No newline at end of file + /** + * @Description 区下级街道得分平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 1:51 下午 + */ + List selectAgencyScoreAvg(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode); + + + /** + * 根据入参查询 区/街道相关分数表 记录 + * @param customerId + * @param monthId + * @return java.util.List + * @Author zhangyong + * @Date 10:43 2020-09-03 + **/ + List selectListAgencyScore(@Param("customerId")String customerId, @Param("monthId")String monthId); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java index 4f670bbfe2..b77849a5d5 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java @@ -18,8 +18,13 @@ package com.epmet.dao.evaluationindex.indexcal; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.indexcal.DeptScoreDTO; +import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO; import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 区直部门分值表 @@ -29,5 +34,26 @@ import org.apache.ibatis.annotations.Mapper; */ @Mapper public interface DeptScoreDao extends BaseDao { - -} \ No newline at end of file + + /** + * 根据入参查询 区直部门分值表 记录 + * @param customerId + * @param monthId + * @return java.util.List + * @Author zhangyong + * @Date 10:43 2020-09-03 + **/ + List selectListDeptScore(@Param("customerId")String customerId, @Param("monthId")String monthId); + + + /** + * @Description 所有直属部门治理能力平均值 + * @param customerId + * @param monthId + * @param indexCode + * @author zxc + * @date 2020/9/4 10:53 上午 + */ + List selectGovernDeptScoreAvg(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode); + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.java index abdabd7465..5a9350a63e 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.java @@ -18,6 +18,7 @@ package com.epmet.dao.evaluationindex.indexcoll; /** import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.indexcal.CalculateCommonFormDTO; +import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO; import com.epmet.dto.indexcollect.form.DeptGovrnAbilityFormDTO; import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity; import org.apache.ibatis.annotations.Mapper; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java index c23bf91b4c..ffdc533581 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java @@ -18,6 +18,7 @@ package com.epmet.dao.evaluationindex.indexcoll; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.indexcollect.form.GridPartyMemberDataDetailFormDTO; import com.epmet.dto.indexcollect.form.GridPartyMemberDataFormDTO; import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; import org.apache.ibatis.annotations.Mapper; @@ -40,22 +41,12 @@ public interface FactIndexPartyAblityCpcMonthlyDao extends BaseDao list, + int batchInsertFactIndexPartyAblityCpcMonthly(@Param("list") List list, @Param("customerId") String customerId); List> getCountByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java index 1df4f962b5..a6060a2bf7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java @@ -29,7 +29,7 @@ import org.apache.ibatis.annotations.Param; import java.util.List; /** - * 社区相关分数表 + * 社区相关分数表 * * @author generator generator@elink-cn.com * @since v1.0.0 2020-08-31 @@ -64,6 +64,15 @@ public interface FactIndexCommunityScoreDao extends BaseDao selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId); + /** + * 根据入参查询 查询社区相关信息 + * @param customerId + * @param monthId + * @return java.util.List + * @Author zhangyong + * @Date 10:43 2020-09-03 + **/ + List selectListCommunityScore(@Param("customerId")String customerId, @Param("monthId")String monthId); /** * @Description 街道下级所有社区得分平均值 * @param customerId @@ -73,4 +82,4 @@ public interface FactIndexCommunityScoreDao extends BaseDao selectSubCommAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode); -} \ No newline at end of file +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java index b1271f13f1..8a8a1f8a38 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java @@ -18,6 +18,7 @@ package com.epmet.dao.evaluationindex.screen; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.screen.FactIndexGridScoreDTO; import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO; import com.epmet.dto.screen.result.SubGridAvgResultDTO; import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO; @@ -44,4 +45,32 @@ public interface FactIndexGridScoreDao extends BaseDao * @date 2020/8/28 3:20 下午 */ List selectSubGridAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode); -} \ No newline at end of file + + /** + * @Description 社区下属所有网格治理能力汇总平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 9:19 上午 + */ + List selectSubGridGovernAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); + + /** + * @Description 社区下级所有网格服务能力得分平均值 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/8/31 1:51 下午 + */ + List selectSubGridServiceAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId); + + /** + * 根据入参查询 网格相关分值记录 + * @param customerId + * @param monthId + * @return java.util.List + * @Author zhangyong + * @Date 10:43 2020-09-03 + **/ + List selectListGridScore(@Param("customerId")String customerId, @Param("monthId")String monthId); +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java index f0d189f7ea..20147e0f82 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java @@ -55,4 +55,15 @@ public interface ScreenCustomerAgencyDao extends BaseDao list, @Param("customerId")String customerId); + + /** + * 根据客户id、组织id,查询区/街道 组织名称 + * + * @param customerId 客户id + * @param agencyId 组织id + * @return java.util.String + * @Author zhangyong + * @Date 16:57 2020-09-03 + **/ + String selectParentAgencyInfo(@Param("customerId")String customerId, @Param("agencyId")String agencyId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java index aedd720c25..7cfb17110c 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java @@ -58,6 +58,16 @@ public interface ScreenCustomerDeptDao extends BaseDao **/ void batchInsertCustomerDept(@Param("list") List list, @Param("customerId")String customerId); + /** + * 根据客户id、部门id,查询部门父级 信息 + * @param customerId 客户id + * @param deptId 部门id + * @return com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity + * @Author zhangyong + * @Date 16:57 2020-09-03 + **/ + ScreenCustomerDeptEntity selectParentDeptInfo(@Param("customerId")String customerId, @Param("deptId")String deptId); + /** * @param customerId * @param deptId diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java index 4254712cbf..0d9a6420f9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerGridDao.java @@ -94,4 +94,14 @@ public interface ScreenCustomerGridDao extends BaseDao * @Date 2020/8/31 12:35 **/ ScreenCustomerGridDTO selectParentAgencyId(@Param("customerId") String customerId, @Param("gridId") String gridId); + + /** + * 根据客户id、网格id,查询网格(党支部)父级信息 + * @param customerId + * @param gridId + * @return com.epmet.dto.screen.FactIndexGridScoreDTO + * @Author zhangyong + * @Date 16:57 2020-09-03 + **/ + ScreenCustomerGridDTO selectParentGridInfo(@Param("customerId")String customerId, @Param("gridId")String gridId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenDifficultyDataDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenDifficultyDataDao.java index 21eaa80280..412ab70225 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenDifficultyDataDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenDifficultyDataDao.java @@ -18,6 +18,7 @@ package com.epmet.dao.evaluationindex.screen; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.screencoll.form.DifficultyDataDetailFormDTO; import com.epmet.dto.screencoll.form.DifficultyDataFormDTO; import com.epmet.entity.evaluationindex.screen.ScreenDifficultyDataEntity; import org.apache.ibatis.annotations.Mapper; @@ -38,14 +39,10 @@ public interface ScreenDifficultyDataDao extends BaseDao list, @Param("customerId")String customerId); + void batchInsertDifficultyData(@Param("list") List list, @Param("customerId")String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java index 5ebaab6f74..cc29f12a95 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java @@ -31,6 +31,10 @@ public enum IndexCodeEnum { JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ("jiedaoxiashusysqdjnlhzpjz","街道下属所有社区党建能力汇总(平均值)",5), JIE_DAO_XIA_SHU_SYSQZLNLHZ("jiedaoxiashusysqzlnlhz","街道下属所有社区治理能力汇总 (平均值) ",5), JIE_DAO_XIA_SHU_SQFWNLDFPYZ("jiedaoxiashusqfwnldfpjz","街道下属社区服务能力得分 (平均值) ",5), + QU_XIA_SHU_JIE_DFWNLHZPJZ("quxiashujiedfwnlhzpjz","区下属街道服务能力汇总(平均值)",5), + QU_XIA_JI_JIE_DDJNLHZPJZ("quxiajijieddjnlhzpjz","区下级街道党建能力汇总(平均值)",5), + SUO_YOU_JIE_DAO_ZLNLPJZ("suoyoujiedaozlnlpjz","所有街道治理能力(平均值)",5), + SUO_YOU_ZHI_SHU_BMZLNLPJZ("suoyouzhishubmzlnlpjz","所有直属部门治理能力(平均值)",5), ; private String code; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java index eef2856684..3fec1a9132 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java @@ -11,6 +11,7 @@ import com.epmet.entity.evaluationindex.screen.IndexGroupTemplateEntity; import com.epmet.service.evaluationindex.screen.IndexDictService; import com.epmet.service.evaluationindex.screen.IndexGroupDetailTemplateService; import com.epmet.service.evaluationindex.screen.IndexGroupTemplateService; +import com.epmet.support.normalizing.Correlation; import com.epmet.util.Pinyin4jUtil; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -29,7 +30,6 @@ import java.util.stream.Collectors; */ public class IndexExcelDataListener extends AnalysisEventListener { private static final Logger LOGGER = LoggerFactory.getLogger(IndexExcelDataListener.class); - private String POSITIVE = "positive"; /** * 每隔5条存储数据库,实际使用中可以3000条,然后清理list ,方便内存回收 */ @@ -86,8 +86,23 @@ public class IndexExcelDataListener extends AnalysisEventListener { data.setWeight(preWheight); } LOGGER.info("解析到一条数据:{}", JSON.toJSONString(data)); - //TODO 默认正相关 - data.setCorrelation(POSITIVE); + if (StringUtils.isNotBlank(data.getThreshold())) { + String threshold = data.getThreshold(); + if ("无".equals(data.getThreshold())) { + threshold = "-1"; + } else if (data.getThreshold().contains("%")) { + String thresholdStr = data.getThreshold().replace("%", ""); + threshold = new BigDecimal(thresholdStr).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP).toString(); + } + data.setThreshold(threshold); + } + if (StringUtils.isNotBlank(data.getCorrelation())) { + if (Correlation.NEGATIVE.getDesc().equals(data.getCorrelation())) { + data.setCorrelation(Correlation.NEGATIVE.getCode()); + } else { + data.setCorrelation(Correlation.POSITIVE.getCode()); + } + } IndexDictEntity entity = new IndexDictEntity(); IndexDictEntity entity2 = new IndexDictEntity(); @@ -240,11 +255,8 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); templateEntity.setWeight(new BigDecimal(index.getWeight()).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP)); } - - if (StringUtils.isNotBlank(index.getThreshold())) { - String thresholdStr = index.getThreshold().replace("%", ""); - templateEntity.setThreshold(new BigDecimal(thresholdStr).divide(new BigDecimal(100), 4, RoundingMode.HALF_UP)); - } + templateEntity.setThreshold(new BigDecimal(index.getThreshold())); + templateEntity.setCorrelation(index.getCorrelation()); } private void buildIndexDicEntity(IndexModel data, IndexDictEntity entity, IndexDictEntity entity2, IndexDictEntity entity3, IndexDictEntity entity4, IndexDictEntity entity5) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java index 5ff0b19267..77a0fd3138 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexModel.java @@ -21,6 +21,7 @@ public class IndexModel { private String weight; @ExcelProperty(value = "五级权重") private String level5Weight; + //没有阈值:无,有就是百分数 @ExcelProperty(value = "阈值") private String threshold; /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateDistrictService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateDistrictService.java new file mode 100644 index 0000000000..0e8ce09ccf --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateDistrictService.java @@ -0,0 +1,18 @@ +package com.epmet.service.evaluationindex.indexcal; + +/** + * @Author zxc + * @DateTime 2020/9/4 9:03 上午 + */ +public interface IndexCalculateDistrictService { + + /** + * @Description 计算全区相关总分 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/2 3:12 下午 + */ + Boolean calDistrictAll(String customerId, String monthId); + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java index 7876c2158e..52cb4e3fc6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java @@ -10,9 +10,9 @@ import com.epmet.constant.DataSourceConstant; import com.epmet.constant.IndexCalConstant; import com.epmet.dao.evaluationindex.indexcal.CpcScoreDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyDao; -import com.epmet.dao.evaluationindex.screen.IndexCodeFieldReDao; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity; +import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; import com.epmet.eum.IndexCodeEnum; import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService; @@ -43,8 +43,6 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { @Autowired private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao; @Autowired - private IndexCodeFieldReDao indexCodeFieldReDao; - @Autowired private IndexGroupDetailService getDetailListByParentCode; @Autowired private IndexCodeFieldReService indexCodeFieldReService; @@ -97,11 +95,43 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { totalEntity.setScore(totalEntity.getScore().add(total)); } }); - deleteAndInsertBatch(formDTO.getCustomerId(),formDTO.getMonthId(),IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(),cpcScoreTotalMap.values().stream().collect(Collectors.toList())); + deleteAndInsertBatch(formDTO, cpcScoreTotalMap.values().stream().collect(Collectors.toList()), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode()); + } + + /** + * @param formDTO + * @param indexCode + * @param stringObjectMap + * @return void + * @author yinzuomei + * @description 只有一条事实记录时,分值默认赋50 + * @Date 2020/9/2 14:35 + **/ + private CpcScoreEntity handleOneGridScene(CalculateCommonFormDTO formDTO, String indexCode, Map stringObjectMap) { + FactIndexPartyAblityCpcMonthlyEntity factCpc = JSON.parseObject(JSON.toJSONString(stringObjectMap), FactIndexPartyAblityCpcMonthlyEntity.class); + // 保存中间表 + CpcScoreEntity cpcScoreEntity = new CpcScoreEntity(); + cpcScoreEntity.setCustomerId(factCpc.getCustomerId()); + cpcScoreEntity.setAgencyId(factCpc.getAgencyId()); + cpcScoreEntity.setGridId(factCpc.getGridId()); + cpcScoreEntity.setYearId(factCpc.getYearId()); + cpcScoreEntity.setMonthId(factCpc.getMonthId()); + cpcScoreEntity.setUserId(factCpc.getUserId()); + cpcScoreEntity.setScore(new BigDecimal(NumConstant.FIFTY_STR)); + cpcScoreEntity.setIndexCode(indexCode); + cpcScoreEntity.setIsTotal(NumConstant.ZERO_STR); + return cpcScoreEntity; } - private void deleteAndInsertBatch(String customerId, String monthId, String indexCode, Collection values) { - cpcScoreDao.deleteByMonthId(customerId, monthId, indexCode); + /** + * desc:根据客户id和月份Id 指标code 非必填 删除数据 + * + * @param formDTO + * @param indexCode 指标code 非必填 + * @param values + */ + private void deleteAndInsertBatch(CalculateCommonFormDTO formDTO, Collection values, String indexCode) { + cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode); cpcScoreDao.insertBatch(values); } @@ -119,20 +149,33 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { return; } - int pageNo = 1; - int pageSize = 10; + int pageNo = NumConstant.ONE; + int pageSize = NumConstant.ONE_THOUSAND; //分页查询 要计算的原始数据 List> list = null; do { list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize); if (!CollectionUtils.isEmpty(list)) { - //遍历指标分组 计算分数 - List> finalList = list; - groupIndexDetailsMap.forEach((parentIndexCode, details) -> { - calculateScore(formDTO, details, finalList, minAndMaxMap, parentIndexCode); - }); + //如果是第一页且仅有一条数据 则直接给50分 + if (pageNo == NumConstant.ONE && list.size() == NumConstant.ONE) { + List insertList = new ArrayList<>(); + for (String parentIndexCode : groupIndexDetailsMap.keySet()) { + insertList.add(handleOneGridScene(formDTO, parentIndexCode, list.get(0))); + } + if (CollectionUtils.isEmpty(insertList)) { + deleteAndInsertBatch(formDTO, insertList, null); + } + } else { + //遍历指标分组 计算分数 + for (Map.Entry> entry : groupIndexDetailsMap.entrySet()) { + String parentIndexCode = entry.getKey(); + List details = entry.getValue(); + calculateScore(formDTO, details, list, minAndMaxMap, parentIndexCode); + } + } } - } while (!CollectionUtils.isEmpty(list) && pageNo++ > 0); + pageNo++; + } while (!CollectionUtils.isEmpty(list) && list.size() == pageSize); } /** @@ -185,7 +228,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { log.info("计算的结果:{}", result); //处理结果 - if (CollectionUtils.isEmpty(result)){ + if (CollectionUtils.isEmpty(result)) { log.error("calculateScore calculateScore return empty"); return; } @@ -209,7 +252,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { cpcScoreEntity.setScore(score); list.add(cpcScoreEntity); }); - this.deleteAndInsertBatch(formDTO.getCustomerId(),formDTO.getMonthId(),parentIndexCode,list); + this.deleteAndInsertBatch(formDTO, list, parentIndexCode); } @@ -242,7 +285,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService { minValue = new BigDecimal(String.valueOf(minAndMaxMap.get(minValueKey))); //如果最大值超过阈值 则最大值为阈值 if (new BigDecimal(NumConstant.ONE_NEG).compareTo(index.getThreshold()) != NumConstant.ZERO - && maxValue.compareTo(new BigDecimal(NumConstant.ONE_NEG)) == NumConstant.ONE){ + && maxValue.compareTo(new BigDecimal(NumConstant.ONE_NEG)) == NumConstant.ONE) { maxValue = index.getThreshold(); } //分值计算器 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java index 59b6127b77..52ea21e80a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java @@ -18,11 +18,13 @@ package com.epmet.service.evaluationindex.indexcal.impl; import com.alibaba.fastjson.JSON; +import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.DataSourceConstant; import com.epmet.constant.IndexCalConstant; import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyDao; @@ -63,6 +65,7 @@ import java.util.Map; * @author generator generator@elink-cn.com * @since v1.0.0 2020-09-02 */ +@DataSource(DataSourceConstant.EVALUATION_INDEX) @Slf4j @Service public class DeptScoreServiceImpl extends BaseServiceImpl implements DeptScoreService { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java index 1d7b37a78d..349167c112 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java @@ -1,6 +1,7 @@ package com.epmet.service.evaluationindex.indexcal.impl; import com.alibaba.druid.util.StringUtils; +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.exception.RenException; @@ -139,7 +140,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni } }); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + log.info("communityPartyCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId)); List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result); return true; @@ -216,7 +219,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni } }); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + log.info("communityGovernAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId)); List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result); return true; @@ -293,7 +298,9 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni } }); BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + log.info("communityServiceAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId)); List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result); return true; diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java new file mode 100644 index 0000000000..4fd50137bd --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java @@ -0,0 +1,406 @@ +package com.epmet.service.evaluationindex.indexcal.impl; + +import com.alibaba.druid.util.StringUtils; +import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.constant.DataSourceConstant; +import com.epmet.constant.IndexCalConstant; +import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao; +import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao; +import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyDao; +import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao; +import com.epmet.dto.indexcal.AgencyScoreDTO; +import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO; +import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO; +import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity; +import com.epmet.eum.IndexCodeEnum; +import com.epmet.service.evaluationindex.indexcal.IndexCalculateDistrictService; +import com.epmet.service.evaluationindex.indexcal.IndexCodeFieldReService; +import com.epmet.service.evaluationindex.screen.IndexGroupDetailService; +import com.epmet.support.normalizing.BigDecimalScoreCalculator; +import com.epmet.support.normalizing.Correlation; +import com.epmet.support.normalizing.ScoreCalculator; +import com.epmet.support.normalizing.ScoreConstants; +import com.epmet.support.normalizing.batch.BatchScoreCalculator; +import com.epmet.support.normalizing.batch.IndexInputVO; +import com.epmet.support.normalizing.batch.SampleValue; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; + +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @Author zxc + * @DateTime 2020/9/4 9:03 上午 + */ +@Service +@Slf4j +@DataSource(DataSourceConstant.EVALUATION_INDEX) +public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrictService { + + @Autowired + private FactIndexPartyAblityOrgMonthlyDao factIndexPartyAblityOrgMonthlyDao; + @Autowired + private IndexCodeFieldReService indexCodeFieldReService; + @Autowired + private IndexGroupDetailService indexGroupDetailService; + @Autowired + private AgencyScoreDao agencyScoreDao; + @Autowired + private DeptScoreDao deptScoreDao; + + /** + * @Description 计算全区相关总分 + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/2 3:12 下午 + */ + @Override + public Boolean calDistrictAll(String customerId, String monthId) { + Boolean aBoolean = districtPartyCalculate(customerId, monthId);//党建能力 + if (!aBoolean.equals(true)) { + throw new RenException("calculate district-party-ability failure ......"); + } + Boolean bBoolean = districtGovernAbilityCalculate(customerId, monthId);// 治理能力 + if (!bBoolean.equals(true)) { + throw new RenException("calculate district-govern-ability failure ......"); + } + Boolean cBoolean = districtServiceAbilityCalculate(customerId, monthId);// 服务能力 + if (!cBoolean.equals(true)) { + throw new RenException("calculate district-service-ability failure ......"); + } + Boolean dBoolean = districtRelate(customerId, monthId); + if (!dBoolean.equals(true)) { + throw new RenException("calculate district-all insert failure ......"); + } + return true; + } + + /** + * @param customerId + * @Description 全区名义发文数量计算【党建能力】 + * @author zxc + * @date 2020/8/26 10:46 上午 + */ + public Boolean districtPartyCalculate(String customerId, String monthId) { + // 党建能力 + // 根据all_parent_index_code 获取指标明细 + List indexDetailList = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(indexDetailList)) { + log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL); + return false; + } + List indexInputVOS = new ArrayList<>(); + Map pid = new HashMap<>(); + //党建能力平均值 + indexDetailList.forEach(detail -> { + if (IndexCodeEnum.QU_XIA_JI_JIE_DDJNLHZPJZ.getCode().equals(detail.getIndexCode())) { + List subGridPartyAvgScore = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(subGridPartyAvgScore)) { + log.error(IndexCalConstant.DISTRICT_PARTY_AVG_NULL); + return; + }else if (subGridPartyAvgScore.size() == NumConstant.ONE){ + pid.put(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),subGridPartyAvgScore.get(NumConstant.ZERO).getParentId()); + sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); + return; + }else if (subGridPartyAvgScore.size() > NumConstant.ONE) { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); + List> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, IndexCalConstant.PAGE_SIZE); + subPartyAvgList.forEach( party -> { + List index1SampleValues = new ArrayList<>(); + party.forEach(c -> { + pid.put(c.getAgencyId(),c.getParentId()); + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + }); + BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc); + indexInputVOS.add(index1VO); + }); + } + } else { + // 区名义发文数量 + List> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.DISTRICT_LEVEL); + if (CollectionUtils.isEmpty(publishArticleCountList)) { + log.error(IndexCalConstant.DISTRICT_PUBLISH_ARTICLE_LIST_NULL); + return; + } + String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode()); + if (StringUtils.isEmpty(fieldNameByIndexCode)) { + log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode())); + return; + }else if (publishArticleCountList.size() == NumConstant.ONE){ + pid.put(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString()); + sizeOne(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid); + return; + }else if (publishArticleCountList.size() > NumConstant.ONE) { + List decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList()); + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList); + List>> publishArticleList = ListUtils.partition(publishArticleCountList, IndexCalConstant.PAGE_SIZE); + publishArticleList.forEach( publish -> { + ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List index1SampleValues = new ArrayList<>(); + publish.forEach(c -> { + pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString()); + SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode)))); + index1SampleValues.add(s); + }); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + indexInputVOS.add(index1VO); + }); + } + } + }); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid); + deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result); + return true; + } + + /** + * @param customerId + * @param monthId + * @Description 全区治理能力 + * @author zxc + * @date 2020/8/26 1:40 下午 + */ + public Boolean districtGovernAbilityCalculate(String customerId, String monthId) { + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(detailListByParentCode)) { + log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL); + return false; + } + List indexInputVOS = new ArrayList<>(); + Map pid = new HashMap<>(); + detailListByParentCode.forEach(detail -> { + if (IndexCodeEnum.SUO_YOU_JIE_DAO_ZLNLPJZ.getCode().equals(detail.getIndexCode())) { + List districtGovernAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + if (districtGovernAvgList.size() == NumConstant.ONE) { + pid.put(districtGovernAvgList.get(NumConstant.ZERO).getAgencyId(),districtGovernAvgList.get(NumConstant.ZERO).getParentId()); + sizeOne(districtGovernAvgList.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); + return; + } else if (districtGovernAvgList.size() > NumConstant.ONE) { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(districtGovernAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList())); + List> governAvg = ListUtils.partition(districtGovernAvgList, IndexCalConstant.PAGE_SIZE); + governAvg.forEach(avg -> { + List index1SampleValues = new ArrayList<>(); + avg.forEach(c -> { + pid.put(c.getAgencyId(),c.getParentId()); + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + }); + BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc); + indexInputVOS.add(index1VO); + }); + } + } else if (IndexCodeEnum.SUO_YOU_ZHI_SHU_BMZLNLPJZ.getCode().equals(detail.getIndexCode())){ + List deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); + if (deptScoreAvgList.size() == NumConstant.ONE) { + pid.put(deptScoreAvgList.get(NumConstant.ZERO).getAgencyId(),deptScoreAvgList.get(NumConstant.ZERO).getParentId()); + sizeOne(deptScoreAvgList.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid); + return; + } else if (deptScoreAvgList.size() > NumConstant.ONE) { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(deptScoreAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList())); + List> governAvg = ListUtils.partition(deptScoreAvgList, IndexCalConstant.PAGE_SIZE); + governAvg.forEach(avg -> { + List index1SampleValues = new ArrayList<>(); + avg.forEach(c -> { + pid.put(c.getAgencyId(),c.getParentId()); + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + }); + BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation())); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc); + indexInputVOS.add(index1VO); + }); + } + }else{ + // TODO 治理能力暂无自身级别 + } + }); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid); + deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result); + return true; + } + + /** + * @param customerId + * @param monthId + * @Description 全区服务能力 + * @author zxc + * @date 2020/8/31 1:38 下午 + */ + public Boolean districtServiceAbilityCalculate(String customerId, String monthId) { + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode()); + if (CollectionUtils.isEmpty(detailListByParentCode)) { + log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL); + return false; + } + List indexInputVOS = new ArrayList<>(); + Map pid = new HashMap<>(); + detailListByParentCode.forEach(detail -> { + String indexCode = detail.getIndexCode(); + if (IndexCodeEnum.QU_XIA_SHU_JIE_DFWNLHZPJZ.getCode().equals(indexCode)) { + List subStreetAvgList = agencyScoreDao.selectAgencyScoreAvg(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode()); + if (subStreetAvgList.size() == NumConstant.ONE) { + pid.put(subStreetAvgList.get(NumConstant.ZERO).getAgencyId(),subStreetAvgList.get(NumConstant.ZERO).getParentId()); + sizeOne(subStreetAvgList.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); + return; + } else if (subStreetAvgList.size() > NumConstant.ONE) { + MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subStreetAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList())); + List> serviceAvgList = ListUtils.partition(subStreetAvgList, IndexCalConstant.PAGE_SIZE); + serviceAvgList.forEach(serviceAvg -> { + BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE); + List index1SampleValues = new ArrayList<>(); + serviceAvg.forEach(c -> { + pid.put(c.getAgencyId(),c.getParentId()); + SampleValue s = new SampleValue(c.getAgencyId(), c.getScore()); + index1SampleValues.add(s); + }); + IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1); + indexInputVOS.add(index1VO); + }); + } + } else { + // todo 暂时没有自身级别 + } + }); + BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator(); + HashMap scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid); + deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result); + return true; + } + + /** + * @param customerId + * @param monthId + * @Description 区相关计算 + * @author zxc + * @date 2020/9/1 9:21 上午 + */ + public Boolean districtRelate(String customerId, String monthId) { + List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); + List agencyScoreList = agencyScoreDao.selectAgencyScoreInfo(customerId, monthId, IndexCalConstant.DISTRICT_LEVEL); + detailListByParentCode.forEach(detail -> { + agencyScoreList.forEach(community -> { + if (detail.getIndexCode().equals(community.getIndexCode())) { + community.setScore(community.getScore().multiply(detail.getWeight())); + } + }); + }); + Map> collect = agencyScoreList.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId)); + List result = new ArrayList<>(); + collect.forEach((key, value) -> { + AgencyScoreDTO score = new AgencyScoreDTO(); + score.setIsTotal(NumConstant.ONE_STR); + score.setCustomerId(customerId); + score.setAgencyId(key); + score.setMonthId(monthId); + score.setYearId(DateUtils.getYearId(monthId)); + score.setQuarterId(DateUtils.getQuarterId(monthId)); + score.setIndexCode(IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode()); + value.forEach(community -> { + score.setScore(score.getScore().add(community.getScore())); + score.setParentAgencyId(community.getParentAgencyId()); + }); + result.add(score); + }); + deleteAndInsert(customerId, monthId, IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), result); + return true; + } + + /** + * @param list + * @Description BigDecimal类型获取最大数和最小数 + * @author zxc + * @date 2020/8/27 1:30 下午 + */ + public MaxAndMinBigDecimalResultDTO getMaxAndMinBigDecimal(List list) { + BigDecimal max = Collections.max(list); + BigDecimal min = Collections.min(list); + MaxAndMinBigDecimalResultDTO result = new MaxAndMinBigDecimalResultDTO(); + result.setMax(max); + result.setMin(min); + return result; + } + + /** + * @param customerId + * @param monthId + * @param indexCode + * @param subAllDistrict + * @Description 先删除记录,在插入 + * @author zxc + * @date 2020/9/1 4:24 下午 + */ + @Transactional(rollbackFor = Exception.class) + public void deleteAndInsert(String customerId, String monthId, String indexCode, List subAllDistrict) { + if (!CollectionUtils.isEmpty(subAllDistrict)) { + agencyScoreDao.deleteOldRecord(customerId, monthId, indexCode,IndexCalConstant.DISTRICT_LEVEL); + System.err.println(subAllDistrict.size()); + agencyScoreDao.insertStreetRecord(subAllDistrict); + } + } + + /** + * @Description + * @param scoreCountOfSampleId 指标计算结果 + * @param customerId 客户ID + * @param monthId 月份ID + * @param isTotal 是否 总分【党建+治理+服务】 + * @param indexCode 党建能力:dangjiannengli,治理能力:zhilinengli,服务能力:fuwunengli,xx相关:xx相关 + * @author zxc + * @date 2020/9/2 2:37 下午 + */ + public List getResult(HashMap scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,Map pid) { + List result = new ArrayList<>(); + scoreCountOfSampleId.forEach((k, v) -> { + AgencyScoreDTO score = new AgencyScoreDTO(); + score.setCustomerId(customerId); + score.setAgencyId(k); + score.setMonthId(monthId); + score.setQuarterId(DateUtils.getQuarterId(monthId)); + score.setYearId(DateUtils.getYearId(monthId)); + score.setIsTotal(isTotal); + score.setIndexCode(indexCode); + score.setScore(v); + score.setDataType(IndexCalConstant.DISTRICT_LEVEL); + pid.forEach((agency,parentAgency) -> { + if (k.equals(agency)){ + score.setParentAgencyId(parentAgency); + } + }); + result.add(score); + }); + return result; + } + + /** + * @Description 当查询结果为一条时,调用此方法 + * @param agencyId + * @param customerId + * @param monthId + * @author zxc + * @date 2020/9/2 2:40 下午 + */ + public void sizeOne(String agencyId,String customerId,String monthId,String indexCode,Map pid){ + HashMap scoreCountOfSampleId = new HashMap<>(); + scoreCountOfSampleId.put(agencyId,new BigDecimal(NumConstant.FIFTY)); + List result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode,pid); + deleteAndInsert(customerId, monthId, indexCode, result); + } +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java index e3890fa9b2..473b7c7ccb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java @@ -338,7 +338,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ */ public Boolean streetRelate(String customerId, String monthId) { List detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode()); - List agencyScoreList = agencyScoreDao.selectStreetInfo(customerId, monthId, IndexCalConstant.STREET_LEVEL); + List agencyScoreList = agencyScoreDao.selectAgencyScoreInfo(customerId, monthId, IndexCalConstant.STREET_LEVEL); detailListByParentCode.forEach(detail -> { agencyScoreList.forEach(community -> { if (detail.getIndexCode().equals(community.getIndexCode())) { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexCollectService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexCollectService.java index 3e29d51f57..e88e5d55a3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexCollectService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/FactIndexCollectService.java @@ -22,7 +22,7 @@ public interface FactIndexCollectService { * @Author zhangyong * @Date 10:52 2020-08-20 **/ - void insertGridPartyMemberData(List formDTO, String customerId); + void insertGridPartyMemberData(GridPartyMemberDataFormDTO formDTO, String customerId); /** * 2、党建能力-网格相关指标上报(按照月份) @@ -107,4 +107,14 @@ public interface FactIndexCollectService { * @Date 10:52 2020-08-20 **/ void insertDeptGovrnAbility(List formDTO, String customerId); + + /** + * 将网格、社区、区直部门、区/街道分支记录表中的数据,抽取到 指数-指数数据(每月数值) 指数-指数数据(按年统计) + * @param monthId 2020-8 + * @param customerId + * @return void + * @Author zhangyong + * @Date 10:29 2020-09-03 + **/ + void insertScreenIndexDataMonthlyAndYearly(String monthId, String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java index e8ec5f9342..715bc56b0f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java @@ -3,19 +3,38 @@ package com.epmet.service.evaluationindex.indexcoll.impl; import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.constant.DataSourceConstant; +import com.epmet.constant.OrgTypeConstant; +import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao; +import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao; import com.epmet.dao.evaluationindex.indexcoll.*; +import com.epmet.dao.evaluationindex.screen.*; +import com.epmet.dto.ScreenCustomerGridDTO; +import com.epmet.dto.indexcal.AgencyScoreDTO; +import com.epmet.dto.indexcal.DeptScoreDTO; import com.epmet.dto.indexcollect.form.*; +import com.epmet.dto.screen.FactIndexCommunityScoreDTO; +import com.epmet.dto.screen.FactIndexGridScoreDTO; +import com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO; +import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity; +import com.epmet.eum.IndexCodeEnum; import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * @Auther: zhangyong * @Date: 2020-08-20 10:05 */ +@Slf4j @Service @DataSource(DataSourceConstant.EVALUATION_INDEX) public class FactIndexCollectServiceImpl implements FactIndexCollectService { @@ -36,18 +55,38 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao; @Autowired private FactIndexGovrnAblityDeptMonthlyDao factIndexGovrnAblityDeptMonthlyDao; + @Autowired + private FactIndexGridScoreDao factIndexGridScoreDao; + @Autowired + private FactIndexCommunityScoreDao factIndexCommunityScoreDao; + @Autowired + private DeptScoreDao deptScoreDao; + @Autowired + private AgencyScoreDao agencyScoreDaol; + @Autowired + private ScreenIndexDataMonthlyDao screenIndexDataMonthlyDao; + @Autowired + private ScreenIndexDataYearlyDao screenIndexDataYearlyDao; + @Autowired + private ScreenCustomerGridDao screenCustomerGridDao; + @Autowired + private ScreenCustomerDeptDao screenCustomerDeptDao; + @Autowired + private ScreenCustomerAgencyDao screenCustomerAgencyDao; @DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) @Override @Transactional(rollbackFor = Exception.class) - public void insertGridPartyMemberData(List formDTO, String customerId) { - if (null != formDTO && formDTO.size() > NumConstant.ZERO){ - for (int i = NumConstant.ZERO; i < formDTO.size(); i++){ - factIndexPartyAblityCpcMonthlyDao.deleteFactIndexPartyAblityCpcMonthly(customerId, - formDTO.get(i).getAgencyId(), formDTO.get(i).getGridId(), formDTO.get(i).getUserId(), - formDTO.get(i).getYearId(), formDTO.get(i).getMonthId(), formDTO.get(i).getQuarterId()); - } - factIndexPartyAblityCpcMonthlyDao.batchInsertFactIndexPartyAblityCpcMonthly(formDTO, customerId); + public void insertGridPartyMemberData(GridPartyMemberDataFormDTO formDTO, String customerId) { + if (formDTO.getIsFirst()) { + //删除这个客户这个月的数据 + int deleteNum; + do { + deleteNum = factIndexPartyAblityCpcMonthlyDao.deleteFactIndexPartyAblityCpcMonthly(customerId, formDTO.getMonthId()); + } while (deleteNum != NumConstant.ZERO); + } + if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getPartyMemberDataList())) { + factIndexPartyAblityCpcMonthlyDao.batchInsertFactIndexPartyAblityCpcMonthly(formDTO.getPartyMemberDataList(), customerId); } } @@ -160,4 +199,301 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { factIndexGovrnAblityDeptMonthlyDao.batchInsertFactIndexGovrnAblityDeptMonthly(formDTO, customerId); } } + + @DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) + @Override + @Transactional(rollbackFor = Exception.class) + public void insertScreenIndexDataMonthlyAndYearly(String monthId, String customerId) { + if (NumConstant.SIX != monthId.length()){ + throw new RuntimeException("入参monthId格式不正确:monthId =" + monthId); + } + String year = monthId.substring(NumConstant.ZERO, NumConstant.FOUR); + String month = monthId.substring(NumConstant.FOUR, NumConstant.SIX); + + // fact_index_grid_score 网格相关分值记录表 grid + List gridScoreDTOS = factIndexGridScoreDao.selectListGridScore(customerId, monthId); + if (null != gridScoreDTOS && gridScoreDTOS.size() > NumConstant.ZERO){ + this.insertIndexDataMonthlyByGridScore(month, year, customerId, gridScoreDTOS); + } + + // fact_index_community_score 社区相关分数表 agency + List communityScoreDTOS = factIndexCommunityScoreDao.selectListCommunityScore(customerId, monthId); + if (null != communityScoreDTOS && communityScoreDTOS.size() > NumConstant.ZERO){ + this.insertIndexDataMonthlyByCommunityScore(month, year, customerId, communityScoreDTOS); + } + + // fact_index_dept_score 区直部门分值表 department + List deptScoreDTOS = deptScoreDao.selectListDeptScore(customerId, monthId); + if (null != deptScoreDTOS && deptScoreDTOS.size() > NumConstant.ZERO){ + this.insertIndexDataMonthlyByDeptScore(month, year, customerId, deptScoreDTOS); + } + + // fact_index_agency_score 区/街道相关分数表 agency + List agencyScoreDTOS = agencyScoreDaol.selectListAgencyScore(customerId, monthId); + if (null != agencyScoreDTOS && agencyScoreDTOS.size() > NumConstant.ZERO) { + this.insertIndexDataMonthlyByAgencyScore(month, year, customerId, agencyScoreDTOS); + } + + // 插入年表 screen_index_data_yearly + } + + /** + * 将网格相关分值记录表 数据 插入月表 screenIndexDataMonthlyDao + * + * @param month 08 + * @param year 2020 + * @param customerId 客户id + * @param gridScoreDTOS 网格相关分值记录表 当前客户所属月份数据集 + * @return void + * @Author zhangyong + * @Date 14:17 2020-09-03 + **/ + private void insertIndexDataMonthlyByGridScore(String month, String year, String customerId, List gridScoreDTOS){ + List monthlyFormDTOList = new ArrayList<>(); + // 根据网格id进行分组,最后组装一条数据 一个网格 对应 4条数据 + Map> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId)); + String[] orgIds = new String[collect.size()]; + int j = 0; + for(Map.Entry> gridScore : collect.entrySet()){ + IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); + // 网格id + orgIds[j] = gridScore.getKey(); + j++; + for ( int i = 0; i < gridScore.getValue().size(); i++){ + if (NumConstant.ONE_STR.equals(gridScore.getValue().get(i).getIsTotal())){ + // 是总分 + if (IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode().equals(gridScore.getValue().get(i).getIndexCode())){ + // 总指数 = 网格相关 + monthlyFormDTO.setIndexTotal(gridScore.getValue().get(i).getScore()); + } + } else { + // 赋值 党建能力、治理能力、服务能力 + monthlyFormDTO = this.setValueAblityMonthlyFor(gridScore.getValue().get(i).getIndexCode(), + gridScore.getValue().get(i).getScore(), + monthlyFormDTO); + } + } + // 查询网格的 上级组织id 和 组织名称 + ScreenCustomerGridDTO parentGridInfo = screenCustomerGridDao.selectParentGridInfo(customerId, gridScore.getKey()); + if (null == parentGridInfo){ + throw new RuntimeException("在screen_customer_grid表中未查询到该客户下的网格信息:customerId =" + customerId + ", gridId = " + gridScore.getKey()); + } + // 补充表中其他字段 + monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, gridScore.getKey(), + parentGridInfo.getParentAgencyId(), parentGridInfo.getGridName(), monthlyFormDTO); + monthlyFormDTOList.add(monthlyFormDTO); + } + screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds); + screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); + } + + /** + * 社区相关分数表 数据 插入月表 screenIndexDataMonthlyDao + * + * @param month 08 + * @param year 2020 + * @param customerId 客户id + * @param communityScoreDTOS 社区相关分数表 当前客户所属月份数据集 + * @return void + * @Author zhangyong + * @Date 14:17 2020-09-03 + **/ + private void insertIndexDataMonthlyByCommunityScore(String month, String year, String customerId, List communityScoreDTOS){ + List monthlyFormDTOList = new ArrayList<>(); + // 根据组织id 进行分组,最后组装一条数据 一个组织id 对应 4条数据 + Map> collect = communityScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId)); + String[] orgIds = new String[collect.size()]; + int j = 0; + for(Map.Entry> communityScore : collect.entrySet()){ + IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); + // 组织id + orgIds[j] = communityScore.getKey(); + j++; + for ( int i = 0; i < communityScore.getValue().size(); i++){ + if (NumConstant.ONE_STR.equals(communityScore.getValue().get(i).getIsTotal())){ + // 是总分 + if (IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode().equals(communityScore.getValue().get(i).getIndexCode())){ + // 总指数 = 社区相关 + monthlyFormDTO.setIndexTotal(communityScore.getValue().get(i).getScore()); + } + } else { + // 赋值 党建能力、治理能力、服务能力 + monthlyFormDTO = this.setValueAblityMonthlyFor(communityScore.getValue().get(i).getIndexCode(), + communityScore.getValue().get(i).getScore(), + monthlyFormDTO); + } + } + + // 当前组织 的上级组织id + String parentAgencyId = communityScore.getValue().get(NumConstant.ZERO).getParentAgencyId(); + // 查询 组织名称 + String agencyName = screenCustomerAgencyDao.selectParentAgencyInfo(customerId, communityScore.getKey()); + if (null == agencyName){ + throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + communityScore.getKey()); + } + // 补充表中其他字段 + monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, communityScore.getKey(), + parentAgencyId, agencyName, monthlyFormDTO); + // 补充表中其他字段 + monthlyFormDTOList.add(monthlyFormDTO); + } + screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds); + screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); + } + + /** + * 将区直部门分值表 数据 插入月表 screenIndexDataMonthlyDao + * + * @param month 08 + * @param year 2020 + * @param customerId 客户id + * @param deptScoreDTOS 区直部门分值表 当前客户所属月份数据集 + * @return void + * @Author zhangyong + * @Date 14:17 2020-09-03 + **/ + private void insertIndexDataMonthlyByDeptScore(String month, String year, String customerId, List deptScoreDTOS){ + List monthlyFormDTOList = new ArrayList<>(); + // 根据部门id 进行分组,最后组装一条数据 一个部门id 对应 4条数据 + Map> collect = deptScoreDTOS.stream().collect(Collectors.groupingBy(DeptScoreDTO::getDeptId)); + String[] orgIds = new String[collect.size()]; + int j = 0; + for(Map.Entry> deptScore : collect.entrySet()){ + IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); + // 部门id + orgIds[j] = deptScore.getKey(); + j++; + for ( int i = 0; i < deptScore.getValue().size(); i++){ + if (NumConstant.ONE_STR.equals(deptScore.getValue().get(i).getIsTotal())){ + // 是总分 总指数 = IS_TOTAL = 1 + monthlyFormDTO.setIndexTotal(deptScore.getValue().get(i).getScore()); + } else { + // 赋值 党建能力、治理能力、服务能力 + monthlyFormDTO = this.setValueAblityMonthlyFor(deptScore.getValue().get(i).getIndexCode(), + deptScore.getValue().get(i).getScore(), + monthlyFormDTO); + } + } + // 查询网格的 上级组织id 和 组织名称 + ScreenCustomerDeptEntity parentDeptInfo = screenCustomerDeptDao.selectParentDeptInfo(customerId, deptScore.getKey()); + if (null == parentDeptInfo){ + throw new RuntimeException("在screen_customer_dept表中未查询到该客户下的父级信息:customerId =" + customerId + ", deptId = " + deptScore.getKey()); + } + // 补充表中其他字段 + monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, deptScore.getKey(), + parentDeptInfo.getParentAgencyId(), parentDeptInfo.getDeptName(), monthlyFormDTO); + monthlyFormDTOList.add(monthlyFormDTO); + } + screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds); + screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); + } + + /** + * 将区/街道相关分数表 数据 插入月表 screenIndexDataMonthlyDao + * + * @param month 08 + * @param year 2020 + * @param customerId 客户id + * @param agencyScoreDTOS 区/街道相关分数表 当前客户所属月份数据集 + * @return void + * @Author zhangyong + * @Date 14:17 2020-09-03 + **/ + private void insertIndexDataMonthlyByAgencyScore(String month, String year, String customerId, List agencyScoreDTOS){ + List monthlyFormDTOList = new ArrayList<>(); + // 根据组织id(eg:社区或者街道id) 进行分组,最后组装一条数据 一个组织id 对应 4条数据 + Map> collect = agencyScoreDTOS.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId)); + String[] orgIds = new String[collect.size()]; + int j = 0; + for(Map.Entry> agencyScore : collect.entrySet()){ + IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); + // 组织id(eg:社区或者街道id) + orgIds[j] = agencyScore.getKey(); + j++; + for ( int i = 0; i < agencyScore.getValue().size(); i++){ + if (NumConstant.ONE_STR.equals(agencyScore.getValue().get(i).getIsTotal())){ + // 是总分 总指数 = IS_TOTAL = 1 + monthlyFormDTO.setIndexTotal(agencyScore.getValue().get(i).getScore()); + } else { + // 赋值 党建能力、治理能力、服务能力 + monthlyFormDTO = this.setValueAblityMonthlyFor(agencyScore.getValue().get(i).getIndexCode(), + agencyScore.getValue().get(i).getScore(), + monthlyFormDTO); + } + } + // 当前组织 的上级组织id + String parentAgencyId = agencyScore.getValue().get(NumConstant.ZERO).getParentAgencyId(); + // 查询 组织名称 + String agencyName = screenCustomerAgencyDao.selectParentAgencyInfo(customerId, agencyScore.getKey()); + if (null == agencyName){ + throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + agencyScore.getKey()); + } + // 补充表中其他字段 + monthlyFormDTO = this.supplementIndexDataMonthlyTable(year, month, OrgTypeConstant.GRID, agencyScore.getKey(), + parentAgencyId, agencyName, monthlyFormDTO); + monthlyFormDTOList.add(monthlyFormDTO); + } + screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, year, month, orgIds); + screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); + } + + /** + * 指数-指数数据(每月数值) 表 字段补全,待新增 + * @param year 2020 + * @param month 08 + * @param orgType 组织类别 agency:组织;部门:department;网格:grid + * @param orgId 组织Id 可以为网格,机关id + * @param parentId 上级组织id + * @param orgName 组织名称 + * @param monthlyFormDTO 待新增的DTO + * @return com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO + * @Author zhangyong + * @Date 15:29 2020-09-03 + **/ + private IndexDataMonthlyFormDTO supplementIndexDataMonthlyTable(String year, String month, String orgType, String orgId, String parentId, + String orgName, IndexDataMonthlyFormDTO monthlyFormDTO){ + monthlyFormDTO.setYearId(year); + monthlyFormDTO.setMonthId(year + month); + monthlyFormDTO.setOrgType(orgType); + monthlyFormDTO.setOrgId(orgId); + // 根据网格id,查询其上级组织id、组织名称 + monthlyFormDTO.setParentId(parentId); + monthlyFormDTO.setOrgName(orgName); + return monthlyFormDTO; + } + + /** + * 赋值 党建能力、治理能力、服务能力 + * (总指数 赋默认值) + * @param IndexCode 组织类别 + * @param Score 分数 + * @param monthlyFormDTO 待保存的数据 + * @return com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO + * @Author zhangyong + * @Date 09:26 2020-09-04 + **/ + private IndexDataMonthlyFormDTO setValueAblityMonthlyFor(String IndexCode, BigDecimal Score, + IndexDataMonthlyFormDTO monthlyFormDTO){ + // 赋默认值 + if (null == monthlyFormDTO.getIndexTotal() && null == monthlyFormDTO.getPartyDevAblity() + && null == monthlyFormDTO.getGovernAblity() && null == monthlyFormDTO.getServiceAblity()){ + BigDecimal zero = new BigDecimal(NumConstant.ZERO); + monthlyFormDTO.setIndexTotal(zero); + monthlyFormDTO.setPartyDevAblity(zero); + monthlyFormDTO.setGovernAblity(zero); + monthlyFormDTO.setServiceAblity(zero); + } + // 赋实际值 + if (IndexCodeEnum.DANG_JIAN_NENG_LI.getCode().equals(IndexCode)){ + // 党建能力 + monthlyFormDTO.setPartyDevAblity(Score); + } else if (IndexCodeEnum.ZHI_LI_NENG_LI.getCode().equals(IndexCode)){ + // 治理能力 + monthlyFormDTO.setGovernAblity(Score); + } else if (IndexCodeEnum.FU_WU_NENG_LI.getCode().equals(IndexCode)){ + // 服务能力 + monthlyFormDTO.setServiceAblity(Score); + } + return monthlyFormDTO; + } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCollService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCollService.java index d499b86c08..1e6dca0080 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCollService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCollService.java @@ -100,7 +100,7 @@ public interface ScreenCollService { * @Author zhangyong * @Date 10:52 2020-08-18 **/ - void insertDifficultyData(List formDTO, String customerId); + void insertDifficultyData(DifficultyDataFormDTO formDTO, String customerId); /** * 2、党员基本情况 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCollServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCollServiceImpl.java index 0b205efb5a..6018622deb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCollServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCollServiceImpl.java @@ -30,6 +30,7 @@ import com.epmet.service.evaluationindex.screen.ScreenCollService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.math.BigDecimal; import java.util.ArrayList; @@ -198,13 +199,13 @@ public class ScreenCollServiceImpl implements ScreenCollService { @DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) @Override @Transactional(rollbackFor = Exception.class) - public void insertDifficultyData(List formDTO, String customerId) { - if (null != formDTO && formDTO.size() > NumConstant.ZERO){ - for (int i = NumConstant.ZERO; i < formDTO.size(); i++){ - screenDifficultyDataDao.deleteDifficultyData(customerId, formDTO.get(i).getEventId(), formDTO.get(i).getOrgId()); - } - - screenDifficultyDataDao.batchInsertDifficultyData(formDTO, customerId); + public void insertDifficultyData(DifficultyDataFormDTO formDTO, String customerId) { + if(formDTO.getIsFirst()){ + //直接删除当前客户下所有的数据 + screenDifficultyDataDao.deleteDifficultyData(customerId); + } + if (null != formDTO && !CollectionUtils.isEmpty(formDTO.getDiffcultyDataList())){ + screenDifficultyDataDao.batchInsertDifficultyData(formDTO.getDiffcultyDataList(), customerId); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java index 7f21b81ee0..d24fec3ee8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java @@ -210,7 +210,7 @@ public class DimAgencyServiceImpl extends BaseServiceImpl getAgencyListByCustomerId(String customerId) { if (StringUtils.isBlank(customerId)){ diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml index cd0c93b654..179fd5c9eb 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml @@ -43,8 +43,27 @@ AND data_type = #{dataType} + + - SELECT CUSTOMER_ID, AGENCY_ID, @@ -64,4 +83,23 @@ AND INDEX_CODE != "jiedaoxiangguan" AND data_type = #{dataType} - \ No newline at end of file + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml index 3f38b0dbbc..3c6fb2ea55 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml @@ -3,6 +3,16 @@ + + delete from fact_index_cpc_score + where + CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} + and MONTH_ID = #{monthId,jdbcType=VARCHAR} + + and INDEX_CODE = #{indexCode,jdbcType=VARCHAR} + + + @@ -18,14 +28,6 @@ - - delete from fact_index_cpc_score - where - CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} - and MONTH_ID = #{monthId,jdbcType=VARCHAR} - and INDEX_CODE = #{indexCode,jdbcType=VARCHAR} - - + SELECT + CUSTOMER_ID customerId, + DEPT_ID deptId, + YEAR_ID yearId, + MONTH_ID monthId, + IS_TOTAL isTotal, + SCORE score, + INDEX_CODE indexCode + FROM + fact_index_dept_score + WHERE + DEL_FLAG = '0' + AND CUSTOMER_ID = #{customerId} + AND MONTH_ID = #{monthId} + ORDER BY DEPT_ID + + + + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml index 05d4b206a3..8336f33e9a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml @@ -3,10 +3,11 @@ - + delete from fact_index_party_ablity_cpc_monthly - where CUSTOMER_ID = #{customerId} AND AGENCY_ID = #{agencyId} AND GRID_ID = #{gridId} AND USER_ID = #{userId} - AND YEAR_ID = #{yearId} AND MONTH_ID = #{monthId} AND QUARTER_ID = #{quarterId} + where CUSTOMER_ID = #{customerId} + AND MONTH_ID = #{monthId} + limit 1000 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml index c3da270827..07e3b05b94 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml @@ -84,4 +84,22 @@ GROUP BY fics.agency_id - \ No newline at end of file + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml index 9d2176f678..b6eed400a2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml @@ -24,4 +24,23 @@ AND figc.index_code = #{indexCode} GROUP BY figc.agency_id - \ No newline at end of file + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml index 4d16660ed3..dda779d7b9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml @@ -60,4 +60,14 @@ + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml index d014071995..8937212e71 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml @@ -64,4 +64,15 @@ AND m.CUSTOMER_ID =#{customerId} AND m.DEPT_ID =#{deptId} + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml index fdb4f2407c..7a8c216fea 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml @@ -105,4 +105,16 @@ AND m.CUSTOMER_ID =#{customerId} AND m.GRID_ID = #{gridId} + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenDifficultyDataDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenDifficultyDataDao.xml index cfeba4c7b7..051f14cbcf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenDifficultyDataDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenDifficultyDataDao.xml @@ -5,7 +5,7 @@ delete from screen_difficulty_data - where CUSTOMER_ID = #{customerId} AND EVENT_ID = #{eventId} AND ORG_ID = #{orgId} + where CUSTOMER_ID = #{customerId} diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppFormDTO.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppFormDTO.java index 36a504a135..00b99a500e 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppFormDTO.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/dto/form/ExternalAppFormDTO.java @@ -9,8 +9,9 @@ public class ExternalAppFormDTO { public interface AddExternalApp {} public interface UpdateExternalApp {} + public interface UpdateAppSecret {} - @NotBlank(message = "缺少应用ID", groups = { UpdateExternalApp.class }) + @NotBlank(message = "缺少应用ID", groups = { UpdateExternalApp.class, UpdateAppSecret.class }) private String appId; @NotBlank(message = "缺少应用名称", groups = { AddExternalApp.class, UpdateExternalApp.class }) diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java index 4b7004ca20..c272d83675 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java @@ -1,5 +1,6 @@ package com.epmet.controller; +import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; @@ -109,4 +110,20 @@ public class ExternalAppController { return new Result>().ok(customerIds); } + /** + * 重置应用秘钥 + * @param formDTO + * @return + */ + @PostMapping("/resetsecret") + public Result resetSecret(@RequestBody ExternalAppFormDTO formDTO) { + ValidatorUtils.validateEntity(formDTO, ExternalAppFormDTO.UpdateAppSecret.class); + String newSecret = externalAppService.resetSecret(formDTO.getAppId()); + if (StringUtils.isBlank(newSecret)) { + return new Result().error(EpmetErrorCode.OPER_EXT_APP_SECRET_RESET_FAIL.getCode(), + EpmetErrorCode.OPER_EXT_APP_SECRET_RESET_FAIL.getMsg()); + } + return new Result().ok(newSecret); + } + } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java index f56aa08cb0..fd2342c7c6 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppSecretDao.java @@ -40,4 +40,5 @@ public interface ExternalAppSecretDao extends BaseDao { */ ExternalAppSecretEntity getSecretsByAppId(@Param("appId") String appId); + int updateSecret(@Param("appId") String appId, @Param("secret") String secret); } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java index 7b714d18db..a2352ec41e 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java @@ -36,4 +36,6 @@ public interface ExternalAppService { PageData listPage(Integer pageNo, Integer pageSize, String customerId); List getCustomerIds(); + + String resetSecret(String appId); } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java index 1968cd4f29..c6b106c1a5 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java @@ -136,4 +136,13 @@ public class ExternalAppServiceImpl implements ExternalAppService { return externalAppDao.getCustomerIds(); } + @Override + public String resetSecret(String appId) { + String secret = genSecret(); + if (externalAppSecretDao.updateSecret(appId, secret) > 0) { + return secret; + } + return null; + } + } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppSecretDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppSecretDao.xml index e207a36013..995dbd0270 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppSecretDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppSecretDao.xml @@ -15,6 +15,13 @@ + + + update external_app_secret + set SECRET=#{secret} + where ID = #{appId} + +