Browse Source

公式计算

dev_shibei_match
jianjun 5 years ago
parent
commit
3b8df373ec
  1. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java
  2. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/form/IndexCalculateForm.java
  3. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  4. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java
  5. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexCalculateService.java
  6. 49
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java
  7. 4
      epmet-module/data-statistical/data-statistical-server/src/main/resources/bootstrap.yml
  8. 18
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml
  9. 7
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/EpmetCommonServiceOpenFeignClient.java
  10. 5
      epmet-module/epmet-common-service/common-service-client/src/main/java/com/epmet/feign/fallback/EpmetCommonServiceOpenFeignClientFallback.java
  11. 12
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/controller/ExternalAppController.java
  12. 2
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/dao/ExternalAppDao.java
  13. 4
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/ExternalAppService.java
  14. 6
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java
  15. 4
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/EnvEnum.java

@ -38,11 +38,15 @@ public enum EnvEnum {
}
public static EnvEnum getCurrentEnv(){
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;
}

5
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<String> customerIds;
/**
* desc:月份id

6
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();
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java

@ -67,4 +67,6 @@ public interface FactIndexPartyAblityCpcMonthlyDao extends BaseDao<FactIndexPart
**/
void batchInsertFactIndexPartyAblityCpcMonthly(@Param("list") List<GridPartyMemberDataFormDTO> list,
@Param("customerId") String customerId);
List<FactIndexPartyAblityCpcMonthlyEntity> getCountByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId);
}

3
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);
}

49
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<List<String>> 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<FactIndexPartyAblityCpcMonthlyEntity> list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(customerId, formDTO.getMonthId());
} catch (Exception e) {
}
//计算网格
//TODO
//计算社区
//TODO
});
return true;
}
}

4
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@

18
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml

@ -94,4 +94,22 @@
</foreach>
</insert>
<select id="getCountByMonthId" resultMap="factIndexPartyAblityCpcMonthlyMap">
SELECT
CREATE_TOPIC_COUNT,
JOIN__TOPIC_COUNT,
SHIFT_ISSUE_COUNT,
SHIFT_PROJECT_COUNT,
JOIN_THREE_MEETS_COUNT,
GROUP_USER_COUNT,
GROUP_TOPIC_COUNT,
TOPIC_TO_ISSUE_RATIO,
GROUP_ACTIVE_USER_COUNT
FROM
fact_index_party_ablity_cpc_monthly
WHERE
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
AND MONTH_ID = #{monthId,jdbcType=VARCHAR}
</select>
</mapper>

7
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<ExternalAppAuthResultDTO> externalAppAuth(@RequestBody ExternalAppAuthFormDTO formDTO);
/**
* 获取外部应用客户Id
* @return
*/
@PostMapping("/commonservice/externalapp/getcustomerids")
Result<List<String>> getExternalCustomerIds();
}

5
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<ExternalAppAuthResultDTO> externalAppAuth(ExternalAppAuthFormDTO formDTO) {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "externalAppAuth", formDTO);
}
@Override
public Result<List<String>> getExternalCustomerIds() {
return ModuleUtils.feignConError(ServiceConstant.EPMET_COMMON_SERVICE, "getExternalCustomerIds", null);
}
}

12
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<PageData<ExternalAppResultDTO>>().ok(page);
}
/**
* 获取客户ids
* @return
*/
@PostMapping("/getcustomerids")
public Result<List<String>> list() {
List<String> customerIds = externalAppService.getCustomerIds();
return new Result<List<String>>().ok(customerIds);
}
}

2
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<ExternalAppEntity> {
ExternalAppResultDTO getByNameAndCustomerId(@Param("appName") String appName, @Param("customerId") String customerId);
List<ExternalAppResultDTO> list(@Param("customerId") String customerId);
List<String> getCustomerIds();
}

4
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<ExternalAppResultDTO> listPage(Integer pageNo, Integer pageSize, String customerId);
List<String> getCustomerIds();
}

6
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<String> getCustomerIds() {
return externalAppDao.getCustomerIds();
}
}

4
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml

@ -60,5 +60,9 @@
AND DEL_FLAG = 0
</select>
<select id="getCustomerIds" resultType="java.lang.String">
SELECT CUSTOMER_ID FROM external_app WHERE DEL_FLAG = 0
</select>
</mapper>
Loading…
Cancel
Save