diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java index 663731dc1b..0c3f798318 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java @@ -38,10 +38,14 @@ public enum EnvEnum { } public static EnvEnum getCurrentEnv(){ - Environment environment = SpringContextUtils.getBean(Environment.class); - String[] activeProfiles = environment.getActiveProfiles(); - if (activeProfiles != null && activeProfiles.length > 0) { - return getEnum(activeProfiles[0]); + try { + Environment environment = SpringContextUtils.getBean(Environment.class); + String[] activeProfiles = environment.getActiveProfiles(); + if (activeProfiles != null && activeProfiles.length > 0) { + return getEnum(activeProfiles[0]); + } + } catch (Exception e) { + e.printStackTrace(); } return EnvEnum.UN_KNOWN; } diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/IndexCalculateForm.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/IndexCalculateForm.java index 49e30cdb21..af11109fa3 100644 --- a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/IndexCalculateForm.java +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/IndexCalculateForm.java @@ -3,6 +3,7 @@ package com.epmet.dto.screen.form; import lombok.Data; import java.io.Serializable; +import java.util.List; /** * desc:初始化客户指标权重参数实体类 @@ -12,9 +13,9 @@ import java.io.Serializable; public class IndexCalculateForm implements Serializable { private static final long serialVersionUID = 3280392511156378209L; /** - * desc:客户id + * desc:客户ids */ - private String customerId; + private List customerIds; /** * desc:月份id diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java index cba12740c5..6b9d8d45e1 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java @@ -1,6 +1,5 @@ package com.epmet.controller; -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.screen.form.IndexCalculateForm; @@ -25,7 +24,7 @@ public class IndexCalculateController { private IndexCalculateService indexCalculateService; /** - * 1、党建能力-党员相关指标计算(按照月份) + * 1、按照客户计算指标(按照月份) * * @param externalAppRequestParam * @param formDTO @@ -33,10 +32,9 @@ public class IndexCalculateController { * @Author zhangyong * @Date 10:52 2020-08-20 **/ - @ExternalAppRequestAuth @PostMapping("cpc") public Result cpcIndexCalculate(ExternalAppRequestParam externalAppRequestParam, @RequestBody IndexCalculateForm formDTO) { - indexCalculateService.cpcIndexCalculate(formDTO); + indexCalculateService.indexCalculate(formDTO); return new Result(); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java index 387a369af1..5d786e5113 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java @@ -36,7 +36,7 @@ public interface FactIndexPartyAblityCpcMonthlyDao extends BaseDao list, - @Param("customerId")String customerId); + @Param("customerId") String customerId); + + List getCountByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateService.java index a43dcc2907..70c49c77fe 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateService.java @@ -12,6 +12,7 @@ public interface IndexCalculateService { /** * desc:计算党员相关指标 * @param formDTO + * @return */ - void cpcIndexCalculate(IndexCalculateForm formDTO); + Boolean indexCalculate(IndexCalculateForm formDTO); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java index 7aff662edf..4558c87927 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java @@ -1,16 +1,63 @@ package com.epmet.service.screen.impl; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao; import com.epmet.dto.screen.form.IndexCalculateForm; +import com.epmet.entity.indexcoll.FactIndexPartyAblityCpcMonthlyEntity; +import com.epmet.feign.EpmetCommonServiceOpenFeignClient; import com.epmet.service.screen.IndexCalculateService; +import com.epmet.util.DimIdGenerator; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.Date; +import java.util.List; /** * @author liujianjun */ +@Slf4j @Service public class IndexCalculateServiceImpl implements IndexCalculateService { + @Autowired + private EpmetCommonServiceOpenFeignClient epmetCommonServiceOpenFeignClient; + @Autowired + private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao; + @Override - public void cpcIndexCalculate(IndexCalculateForm formDTO) { + public Boolean indexCalculate(IndexCalculateForm formDTO) { + if (StringUtils.isBlank(formDTO.getMonthId())) { + //默认 当前月份-1 + formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1))); + } + //按照客户分组 + if (CollectionUtils.isEmpty(formDTO.getCustomerIds())) { + Result> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); + if (!externalCustomerIdsResult.success()) { + log.error("cpcIndexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); + return false; + } + formDTO.setCustomerIds(externalCustomerIdsResult.getData()); + } + formDTO.getCustomerIds().forEach(customerId -> { + //计算党员 + try { + List list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(customerId, formDTO.getMonthId()); + } catch (Exception e) { + + } + + //计算网格 + //TODO + + //计算社区 + //TODO + }); + return true; } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml index 7ece13bb19..709e17ab36 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml @@ -174,7 +174,3 @@ thread: queueCapacity: @thread.pool.queue-capacity@ keepAlive: @thread.pool.keep-alive@ -dingTalk: - robot: - webHook: @dingTalk.robot.webHook@ - secret: @dingTalk.robot.secret@ \ No newline at end of file diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml index c64ce8f35e..92b5a882fa 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml @@ -94,4 +94,22 @@ + + diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java index d23de0c0e2..caa9bd6301 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java @@ -39,4 +39,11 @@ public interface EpmetCommonServiceOpenFeignClient { */ @PostMapping("/commonservice/externalapp/auth") Result externalAppAuth(@RequestBody ExternalAppAuthFormDTO formDTO); + + /** + * 获取外部应用客户Id + * @return + */ + @PostMapping("/commonservice/externalapp/getcustomerids") + Result> getExternalCustomerIds(); } diff --git a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java index 555e502062..f21808fc8c 100644 --- a/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java +++ b/epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java @@ -29,4 +29,9 @@ public class EpmetCommonServiceOpenFeignClientFallback implements EpmetCommonSer public Result externalAppAuth(ExternalAppAuthFormDTO formDTO) { return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "externalAppAuth", formDTO); } + + @Override + public Result> getExternalCustomerIds() { + return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "getExternalCustomerIds", null); + } } 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 976c4e4ef0..dfd846c5d0 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 @@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.util.List; + @RestController @RequestMapping("/externalapp") public class ExternalAppController { @@ -95,4 +97,14 @@ public class ExternalAppController { return new Result>().ok(page); } + /** + * 获取客户ids + * @return + */ + @PostMapping("/getcustomerids") + public Result> list() { + List customerIds = externalAppService.getCustomerIds(); + return new Result>().ok(customerIds); + } + } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java index 73f6bd3407..45dda5390a 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java @@ -39,4 +39,6 @@ public interface ExternalAppDao extends BaseDao { ExternalAppResultDTO getByNameAndCustomerId(@Param("appName") String appName, @Param("customerId") String customerId); List list(@Param("customerId") String customerId); + + List getCustomerIds(); } \ 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 dff718695f..7b714d18db 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 @@ -20,6 +20,8 @@ package com.epmet.service; import com.epmet.commons.tools.page.PageData; import com.epmet.dto.result.ExternalAppResultDTO; +import java.util.List; + /** * 外部应用列表 * @@ -32,4 +34,6 @@ public interface ExternalAppService { ExternalAppResultDTO updateById(String appId, String appName, String customerId); PageData listPage(Integer pageNo, Integer pageSize, String customerId); + + List getCustomerIds(); } \ 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 5f92de268e..1968cd4f29 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 @@ -130,4 +130,10 @@ public class ExternalAppServiceImpl implements ExternalAppService { return new PageData<>(list, pageInfo.getTotal()); } + @Override + public List getCustomerIds() { + + return externalAppDao.getCustomerIds(); + } + } \ No newline at end of file diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml index 588f735da7..62d5823a96 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml @@ -60,5 +60,9 @@ AND DEL_FLAG = 0 + + \ No newline at end of file