Browse Source

Merge remote-tracking branch 'origin/dev_screen_data' into dev_temp

master
yinzuomei 5 years ago
parent
commit
ecccd7523e
  1. 6
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java
  2. 26
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  3. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java
  4. 23
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java

6
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CalculateCommonFormDTO.java

@ -1,7 +1,9 @@
package com.epmet.dto.indexcal; package com.epmet.dto.indexcal;
import com.epmet.commons.tools.validator.group.CustomerClientShowGroup;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
import java.io.Serializable; import java.io.Serializable;
/** /**
@ -13,6 +15,9 @@ import java.io.Serializable;
@Data @Data
public class CalculateCommonFormDTO implements Serializable { public class CalculateCommonFormDTO implements Serializable {
private static final long serialVersionUID = -5689788391963427717L; private static final long serialVersionUID = -5689788391963427717L;
public interface CancelCalculateGroup extends CustomerClientShowGroup {}
/** /**
* 月份id: yyyyMM * 月份id: yyyyMM
*/ */
@ -21,6 +26,7 @@ public class CalculateCommonFormDTO implements Serializable {
/** /**
* 客户id * 客户id
*/ */
@NotBlank(message = "客户id不能为空", groups = { CancelCalculateGroup.class })
private String customerId; private String customerId;
public CalculateCommonFormDTO() { public CalculateCommonFormDTO() {

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

@ -7,6 +7,7 @@ import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.utils.HttpClientManager;
import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService; import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.service.evaluationindex.indexcal.IndexCalculateService;
@ -21,6 +22,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.*; import java.util.concurrent.*;
/** /**
@ -52,6 +55,8 @@ public class IndexCalculateController {
// 计算同步锁 // 计算同步锁
private Object statsCalLock = new Object(); private Object statsCalLock = new Object();
private Map<String, Future> futureMap = new HashMap<>();
/** /**
* 按照客户计算所有指标(按照月份) * 按照客户计算所有指标(按照月份)
* *
@ -72,7 +77,7 @@ public class IndexCalculateController {
log.error(String.format("该客户正在执行计算,请勿重复提交计算请求。", customerId)); log.error(String.format("该客户正在执行计算,请勿重复提交计算请求。", customerId));
return new Result<Boolean>().ok(false); return new Result<Boolean>().ok(false);
} }
singleThreadPool.execute(() -> { Future<?> future = singleThreadPool.submit(() -> {
formDTO.setCustomerId(customerId); formDTO.setCustomerId(customerId);
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
@ -80,7 +85,9 @@ public class IndexCalculateController {
log.error("客户Id:{},全部指标计算完成,总耗时:{}秒", customerId, (System.currentTimeMillis() - start) / 1000); log.error("客户Id:{},全部指标计算完成,总耗时:{}秒", customerId, (System.currentTimeMillis() - start) / 1000);
} }
redisUtils.set(RedisKeys.getCustomerStatsCalFlag(customerId), false); redisUtils.set(RedisKeys.getCustomerStatsCalFlag(customerId), false);
futureMap.remove(customerId);
}); });
futureMap.put(customerId, future);
redisUtils.set(RedisKeys.getCustomerStatsCalFlag(customerId), true); redisUtils.set(RedisKeys.getCustomerStatsCalFlag(customerId), true);
} }
} else { } else {
@ -92,6 +99,23 @@ public class IndexCalculateController {
return new Result<Boolean>().ok(true); return new Result<Boolean>().ok(true);
} }
/**
* 终止计算
* @param form
* @return
*/
@PostMapping("stopcalculate")
public Result stopcalculate(@RequestBody CalculateCommonFormDTO form) {
ValidatorUtils.validateEntity(form);
String customerId = form.getCustomerId();
Future future = this.futureMap.get(customerId);
if (future != null && !future.isCancelled()) {
future.cancel(true);
}
return new Result();
}
@PostMapping("reAll") @PostMapping("reAll")
public Result<Boolean> calculateAll(@RequestBody CalculateCommonFormDTO formDTO) { public Result<Boolean> calculateAll(@RequestBody CalculateCommonFormDTO formDTO) {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();

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

@ -120,7 +120,7 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
IndexCodeEnum.QU_ZHI_BU_MEN.getCode(), IndexCodeEnum.QU_ZHI_BU_MEN.getCode(),
IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(indexGroupDetailEntityList)) { if (CollectionUtils.isEmpty(indexGroupDetailEntityList)) {
log.warn("calculateDeptCorreLation customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); log.error("calculateDeptCorreLation customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【区直部门:治理能力】下级指标权重信息不存在"); throw new RenException("客户【区直部门:治理能力】下级指标权重信息不存在");
} }
// log.info(JSON.toJSONString(indexGroupDetailEntityList)); // log.info(JSON.toJSONString(indexGroupDetailEntityList));
@ -169,14 +169,16 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
List<IndexGroupDetailEntity> indexList = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), List<IndexGroupDetailEntity> indexList = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.QU_ZHI_BU_MEN.getCode()); IndexCodeEnum.QU_ZHI_BU_MEN.getCode());
if (CollectionUtils.isEmpty(indexList)) { if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateDeptTotalScore customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); log.error("calculateDeptTotalScore customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【区直部门】下级指标权重信息不存在"); throw new RenException("客户【区直部门】下级指标权重信息不存在");
} }
//查询总记录数 //查询总记录数
List<DeotScore> deptScoreDTOList = deptScoreDao.selectList(formDTO); List<DeotScore> deptScoreDTOList = deptScoreDao.selectList(formDTO);
if(CollectionUtils.isEmpty(deptScoreDTOList)){ if(CollectionUtils.isEmpty(deptScoreDTOList)){
log.error("calculateDeptTotalScore deptScoreDao.selectList return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); log.warn("calculateDeptTotalScore deptScoreDao.selectList return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId());
throw new RenException("客户一级指标分值记录不存在"); // throw new RenException("客户一级指标分值记录不存在");
log.warn(String.format("customerId=%s,monthId=%s,fact_index_dept_score have not any fact record", formDTO.getCustomerId(), formDTO.getMonthId()));
return;
} }
Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity())); Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity()));
List<DeptScoreEntity> deotScoreEntityList = new ArrayList<>(); List<DeptScoreEntity> deotScoreEntityList = new ArrayList<>();
@ -339,7 +341,7 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
//获取指标对应的列名 //获取指标对应的列名
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode()); String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode());
if (StringUtils.isBlank(fieldName)) { if (StringUtils.isBlank(fieldName)) {
log.error("index_code:{} not find field_name", index.getIndexCode()); log.warn("index_code:{} not find field_name", index.getIndexCode());
continue; continue;
} }
String minValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MIN); String minValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MIN);

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

@ -106,7 +106,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(), IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.DANG_JIAN_NENG_LI.getCode()); IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(indexList)) { if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateGridDangJian customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); log.error("calculateGridDangJian customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:党建能力】指标权重信息不存在"); throw new RenException("客户【网格相关:党建能力】指标权重信息不存在");
} }
//查询总记录数 //查询总记录数
@ -121,7 +121,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
//每一组指标的最大值,key:code_MIN/MAX //每一组指标的最大值,key:code_MIN/MAX
Map<String, Object> minAndMaxMap = queryPartyAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); Map<String, Object> minAndMaxMap = queryPartyAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId());
if (CollectionUtils.isEmpty(minAndMaxMap)) { if (CollectionUtils.isEmpty(minAndMaxMap)) {
log.error("calculateGridDangJian queryPartyAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId()); log.warn("calculateGridDangJian queryPartyAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId());
return; return;
} }
//指标集合 //指标集合
@ -463,7 +463,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
//获取指标对应的列名 //获取指标对应的列名
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode()); String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode());
if (StringUtils.isBlank(fieldName)) { if (StringUtils.isBlank(fieldName)) {
log.error("index_code:{} not find field_name",index.getIndexCode()); log.warn("index_code:{} not find field_name",index.getIndexCode());
continue; continue;
} }
// log.info("index_code2:{} ,field_name:{}",index.getIndexCode(),fieldName); // log.info("index_code2:{} ,field_name:{}",index.getIndexCode(),fieldName);
@ -509,7 +509,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(), IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.ZHI_LI_NENG_LI.getCode()); IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(indexList)) { if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateGridZhiLi customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); log.error("calculateGridZhiLi customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:治理能力】指标权重信息不存在"); throw new RenException("客户【网格相关:治理能力】指标权重信息不存在");
} }
//查询总记录数 //查询总记录数
@ -524,7 +524,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
//每一组指标的最大值,key:code_MIN/MAX //每一组指标的最大值,key:code_MIN/MAX
Map<String, Object> minAndMaxMap = queryGovrnAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); Map<String, Object> minAndMaxMap = queryGovrnAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId());
if (CollectionUtils.isEmpty(minAndMaxMap)) { if (CollectionUtils.isEmpty(minAndMaxMap)) {
log.error("calculateGridZhiLi queryGovrnAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId()); log.warn("calculateGridZhiLi queryGovrnAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId());
return; return;
} }
//指标集合 //指标集合
@ -582,7 +582,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(), IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.FU_WU_NENG_LI.getCode()); IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (CollectionUtils.isEmpty(indexList)) { if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateGridFuWu customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); log.error("calculateGridFuWu customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关:服务能力】指标权重信息不存在"); throw new RenException("客户【网格相关:服务能力】指标权重信息不存在");
} }
//查询总记录数 //查询总记录数
@ -597,7 +597,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
//每一组指标的最大值,key:code_MIN/MAX //每一组指标的最大值,key:code_MIN/MAX
Map<String, Object> minAndMaxMap = queryServiceAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId()); Map<String, Object> minAndMaxMap = queryServiceAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId());
if (CollectionUtils.isEmpty(minAndMaxMap)) { if (CollectionUtils.isEmpty(minAndMaxMap)) {
log.error("calculateGridFuWu queryServiceAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId()); log.warn("calculateGridFuWu queryServiceAblityGridMinAndMax customerId:{} monthId:{} have not any fact record", formDTO.getCustomerId(),formDTO.getMonthId());
return; return;
} }
//指标集合 //指标集合
@ -623,7 +623,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), new BigDecimal(sampleValueStr)); SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), new BigDecimal(sampleValueStr));
value.getIndexValueVOs().add(currentGridIndexValue); value.getIndexValueVOs().add(currentGridIndexValue);
} else { } else {
log.error("index_code:" + key + " not find field_name"); log.warn("index_code:" + key + " not find field_name");
} }
}); });
}); });
@ -649,14 +649,15 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(), List<IndexGroupDetailEntity> indexList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode()); IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
if (CollectionUtils.isEmpty(indexList)) { if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateGridTotal customerId:{} have not any indexGroupDetail", formDTO.getCustomerId()); log.error("calculateGridTotal customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【网格相关】指标权重信息不存在"); throw new RenException("客户【网格相关】指标权重信息不存在");
} }
//查询总记录数 //查询总记录数
List<GridScoreDTO> gridScoreDTOList = gridScoreDao.selectList(formDTO); List<GridScoreDTO> gridScoreDTOList = gridScoreDao.selectList(formDTO);
if(CollectionUtils.isEmpty(gridScoreDTOList)){ if(CollectionUtils.isEmpty(gridScoreDTOList)){
log.error("calculateGridTotal gridScoreDao.selectList return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId()); log.warn("calculateGridTotal gridScoreDao.selectList return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId());
throw new RenException("客户一级指标分值记录不存在"); // throw new RenException("客户一级指标分值记录不存在");
return;
} }
Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity())); Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity()));
List<GridScoreEntity> gridScoreEntityList = new ArrayList<>(); List<GridScoreEntity> gridScoreEntityList = new ArrayList<>();

Loading…
Cancel
Save