Browse Source

将计算结果抽取到 大屏相关数据表

dev_shibei_match
jianjun 5 years ago
parent
commit
df55e4a6cf
  1. 16
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  2. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java
  3. 67
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java

16
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java

@ -1,9 +1,10 @@
package com.epmet.controller;
import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth;
import com.epmet.commons.extappauth.bean.ExternalAppRequestParam;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.IndexCalculateForm;
import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService;
import com.epmet.util.DimIdGenerator;
@ -40,8 +41,19 @@ public class IndexCalculateController {
* @Author zhangyong
* @Date 10:52 2020-08-20
**/
@ExternalAppRequestAuth
@PostMapping("all")
public Result<Boolean> indexCalculate(@RequestBody IndexCalculateForm formDTO) {
public Result<Boolean> indexCalculate(ExternalAppRequestParam externalAppRequestParam, @RequestBody CalculateCommonFormDTO formDTO) {
formDTO.setCustomerId(externalAppRequestParam.getCustomerId());
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
if (aBoolean) {
return new Result<Boolean>().ok(true);
}
return new Result<Boolean>().error("指标计算失败");
}
@PostMapping("reAll")
public Result<Boolean> calculateAll(@RequestBody CalculateCommonFormDTO formDTO) {
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
if (aBoolean) {
return new Result<Boolean>().ok(true);

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java

@ -1,6 +1,6 @@
package com.epmet.service.evaluationindex.indexcal;
import com.epmet.dto.screen.form.IndexCalculateForm;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
/**
* 指标计算service
@ -11,8 +11,9 @@ import com.epmet.dto.screen.form.IndexCalculateForm;
public interface IndexCalculateService {
/**
* desc按照客户计算所有指标(按照月份)
*
* @param formDTO
* @return
*/
Boolean indexCalculate(IndexCalculateForm formDTO);
Boolean indexCalculate(CalculateCommonFormDTO formDTO);
}

67
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java

@ -2,21 +2,22 @@ package com.epmet.service.evaluationindex.indexcal.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.IndexCalculateForm;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.redis.IndexCodeFieldReRedis;
import com.epmet.service.evaluationindex.indexcal.*;
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService;
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.ArrayList;
import java.util.Date;
import java.util.List;
@ -44,26 +45,33 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
private IndexCalculateDistrictService indexCalculateDistrictService;
@Autowired
private DeptScoreService deptScoreService;
@Autowired
private FactIndexCollectService factIndexCollectService;
@Override
public Boolean indexCalculate(IndexCalculateForm formDTO) {
public Boolean indexCalculate(CalculateCommonFormDTO formDTO) {
try {
if (StringUtils.isBlank(formDTO.getMonthId())) {
//默认 当前月份-1
formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1)));
}
//按照客户分组
if (CollectionUtils.isEmpty(formDTO.getCustomerIds())) {
List<String> customerIds = new ArrayList<>();
if (StringUtils.isBlank(formDTO.getCustomerId())) {
Result<List<String>> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds();
if (!externalCustomerIdsResult.success()) {
log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail");
return false;
}
formDTO.setCustomerIds(externalCustomerIdsResult.getData());
customerIds = externalCustomerIdsResult.getData();
} else {
customerIds.add(formDTO.getCustomerId());
}
Boolean flag = false;
for (String customerId : formDTO.getCustomerIds()) {
for (String customerId : customerIds) {
CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO(customerId, formDTO.getMonthId());
try {
//计算党员相关的
try {
CalculateCommonFormDTO param = new CalculateCommonFormDTO(customerId, formDTO.getMonthId());
@ -71,7 +79,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
log.info("indexCalculate cpcIndexCalculate return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate cpcIndexCalculate exception", e);
break;
throw new RenException("indexCalculate cpcIndexCalculate exception", e);
}
//计算网格
@ -80,42 +88,55 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
log.info("indexCalculate calculateGridCorreLation return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calculateGridCorreLation exception", e);
break;
throw new RenException("indexCalculate calculateGridCorreLation exception", e);
}
//计算社区
try {
indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calAll return result:{}", flag);
flag = indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calCommunityAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);
break;
log.error("indexCalculate calCommunityAll exception", e);
throw new RenException("indexCalculate calAll exception", e);
}
//计算街道
try {
indexCalculateStreetService.calStreetAll(customerId,formDTO.getMonthId());
log.info("indexCalculate calAll return result:{}", flag);
flag = indexCalculateStreetService.calStreetAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calStreetAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);
break;
log.error("indexCalculate calStreetAll exception", e);
throw new RenException("indexCalculate calStreetAll exception", e);
}
//计算区直属
try {
deptScoreService.calculateDeptCorreLation(calculateCommonFormDTO);
log.info("indexCalculate calAll return result:{}", flag);
flag = deptScoreService.calculateDeptCorreLation(calculateCommonFormDTO);
log.info("indexCalculate calculateDeptCorreLation return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);
break;
log.error("indexCalculate calculateDeptCorreLation exception", e);
throw new RenException("indexCalculate calculateDeptCorreLation exception", e);
}
//计算全区
try {
indexCalculateDistrictService.calDistrictAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calAll return result:{}", flag);
log.info("indexCalculate calDistrictAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);
break;
log.error("indexCalculate calDistrictAll exception", e);
throw new RenException("indexCalculate calDistrictAll exception", e);
}
} catch (RenException e) {
flag = false;
}
//计算完毕后 将结果插入大屏相关数据表
if (flag) {
try {
factIndexCollectService.insertScreenIndexDataMonthlyAndYearly(formDTO.getMonthId(), formDTO.getCustomerId());
} catch (Exception e) {
log.error("indexCalculate insertScreenIndexDataMonthlyAndYearly exception", e);
flag = false;
}
}
}
return flag;

Loading…
Cancel
Save