Browse Source

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

master
yinzuomei 5 years ago
parent
commit
c6a648db10
  1. 20
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyCalResultDTO.java
  2. 21
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CommunityCalResultDTO.java
  3. 4
      epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml
  4. 4
      epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml
  5. 25
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  6. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java
  7. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java
  8. 36
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  9. 45
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  10. 43
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  11. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySubScoreDao.xml
  12. 4
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySubScoreDao.xml

20
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyCalResultDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/9/9 5:52 下午
*/
@Data
public class AgencyCalResultDTO implements Serializable {
private static final long serialVersionUID = 2482954776048082386L;
private List<AgencyScoreDTO> oneTwoLevel;
private List<AgencyScoreDTO> fiveLevel;
}

21
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/CommunityCalResultDTO.java

@ -0,0 +1,21 @@
package com.epmet.dto.indexcal;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @Author zxc
* @DateTime 2020/9/10 9:19 上午
*/
@Data
public class CommunityCalResultDTO implements Serializable {
private static final long serialVersionUID = 2482954776048082386L;
private List<FactIndexCommunityScoreDTO> oneLevel;
private List<FactIndexCommunityScoreDTO> fiveLevel;
}

4
epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-dev.yml

@ -9,10 +9,10 @@ services:
volumes:
- "/opt/epmet-cloud-logs/dev:/logs"
environment:
RUN_INSTRUCT: "java -Xms32m -Xmx250m -jar ./app.jar"
RUN_INSTRUCT: "java -Xms32m -Xmx512m -jar ./app.jar"
restart: "unless-stopped"
deploy:
resources:
limits:
cpus: '0.1'
memory: 300M
memory: 600M

4
epmet-module/data-statistical/data-statistical-server/deploy/docker-compose-test.yml

@ -9,10 +9,10 @@ services:
volumes:
- "/opt/epmet-cloud-logs/test:/logs"
environment:
RUN_INSTRUCT: "java -Xms32m -Xmx250m -jar ./app.jar"
RUN_INSTRUCT: "java -Xms32m -Xmx512m -jar ./app.jar"
restart: "unless-stopped"
deploy:
resources:
limits:
cpus: '0.1'
memory: 300M
memory: 600M

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

@ -8,6 +8,8 @@ import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService;
import com.epmet.util.DimIdGenerator;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.concurrent.*;
/**
* 指标计算controller
@ -23,9 +26,16 @@ import java.util.Date;
* @author liujianjun@elink-cn.com
* @date 2020/8/24 14:38
*/
@Slf4j
@RestController
@RequestMapping("indexcalculate")
public class IndexCalculateController {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("indexcalculate-pool-%d").build();
ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1,
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
@Autowired
private IndexCalculateService indexCalculateService;
@ -44,12 +54,15 @@ public class IndexCalculateController {
@ExternalAppRequestAuth
@PostMapping("all")
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("指标计算失败");
singleThreadPool.execute(() -> {
formDTO.setCustomerId(externalAppRequestParam.getCustomerId());
long start = System.currentTimeMillis();
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
if (aBoolean) {
log.error("全部指标计算完成,总耗时:{}秒", (System.currentTimeMillis() - start) / 1000);
}
});
return new Result<Boolean>().ok(true);
}
@PostMapping("reAll")

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java

@ -46,12 +46,11 @@ public interface AgencySubScoreDao extends BaseDao<AgencyScoreEntity> {
/**
* @param customerId
* @param monthId
* @param indexCode
* @Description 删除旧记录
* @author zxc
* @date 2020/9/2 15:47
*/
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode, @Param("dataType") String dataType);
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("dataType") String dataType);
/**
* @param customerId

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

@ -361,7 +361,11 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
}
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, isTotal);
gridScoreDao.insertBatches(gridScoreEntityList);
//批量插入
List<List<GridScoreEntity>> partition = ListUtils.partition(gridScoreEntityList, 100);
partition.forEach(list -> {
gridScoreDao.insertBatches(list);
});
}
}
@ -634,7 +638,11 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
}
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, NumConstant.ONE_STR);
gridScoreDao.insertBatches(gridScoreEntityList);
//批量插入
List<List<GridScoreEntity>> partition = ListUtils.partition(gridScoreEntityList, 100);
partition.forEach(list -> {
gridScoreDao.insertBatches(list);
});
}
}

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

@ -9,10 +9,12 @@ import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.CommunityScoreDao;
import com.epmet.dao.evaluationindex.indexcal.CommunitySubScoreDao;
import com.epmet.dao.evaluationindex.indexcal.GridScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao;
import com.epmet.dto.indexcal.CommunityCalResultDTO;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
import com.epmet.dto.screen.result.SubGridAvgResultDTO;
@ -63,6 +65,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
private CommunityScoreDao factIndexCommunityScoreDao;
@Autowired
private GridScoreDao factIndexGridScoreDao;
@Autowired
private CommunitySubScoreDao communitySubScoreDao;
/**
* @param customerId
@ -136,7 +140,8 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
log.info("communityPartyCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
communitySubScoreDao.deleteOldRecord(customerId,monthId);
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId);
deleteAndInsert(result);
return true;
@ -211,7 +216,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -285,7 +290,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
CommunityCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -325,7 +330,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
result.add(score);
});
deleteAndInsert(result);
factIndexCommunityScoreDao.insertCommunityPartyRecord(result);
return true;
}
@ -372,15 +377,18 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
/**
* @param subAllGridList
* @param result
* @Description 先删除记录在插入
* @author zxc
* @date 2020/9/1 4:24 下午
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(List<FactIndexCommunityScoreDTO> subAllGridList) {
if (!CollectionUtils.isEmpty(subAllGridList)) {
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList);
public void deleteAndInsert(CommunityCalResultDTO result) {
if (!CollectionUtils.isEmpty(result.getOneLevel())) {
factIndexCommunityScoreDao.insertCommunityPartyRecord(result.getOneLevel());
}
if (!CollectionUtils.isEmpty(result.getFiveLevel())){
communitySubScoreDao.insertCommunityPartyRecord(result.getFiveLevel());
}
}
@ -394,8 +402,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<FactIndexCommunityScoreDTO> getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,String allParentIndexCode, Map<String, String> pid) {
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
public CommunityCalResultDTO getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,String allParentIndexCode, Map<String, String> pid) {
CommunityCalResultDTO result = new CommunityCalResultDTO();
List<FactIndexCommunityScoreDTO> resultOne = new ArrayList<>();
List<FactIndexCommunityScoreDTO> resultFive = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO();
score.setCustomerId(customerId);
@ -429,11 +439,13 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
s.setParentAgencyId(parentAgency);
}
});
result.add(s);
resultFive.add(s);
});
}
result.add(score);
resultOne.add(score);
});
result.setOneLevel(resultOne);
result.setFiveLevel(resultFive);
return result;
}
}

45
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.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;
@ -8,9 +9,11 @@ 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.AgencySubScoreDao;
import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dto.indexcal.AgencyCalResultDTO;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
@ -59,6 +62,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
private DeptScoreDao deptScoreDao;
@Autowired
private ScreenCustomerAgencyDao customerAgencyDao;
@Autowired
private AgencySubScoreDao agencySubScoreDao;
/**
* @Description 计算全区相关总分
@ -157,8 +162,11 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
log.info("districtPartyAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("districtPartyAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
agencyScoreDao.deleteOldRecord(customerId, monthId,IndexCalConstant.DISTRICT_LEVEL);
agencySubScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.DISTRICT_LEVEL);
deleteAndInsert(result);
return true;
}
@ -225,7 +233,9 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
log.info("districtGovernAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("districtGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -273,7 +283,9 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
log.info("districtServiceAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("districtServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -314,7 +326,9 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
});
result.add(score);
});
deleteAndInsert(result);
if (!CollectionUtils.isEmpty(result)){
agencyScoreDao.insertStreetRecord(result);
}
return true;
}
@ -334,15 +348,18 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
}
/**
* @param subAllDistrict
* @param result
* @Description 先删除记录在插入
* @author zxc
* @date 2020/9/1 4:24 下午
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(List<AgencyScoreDTO> subAllDistrict) {
if (!CollectionUtils.isEmpty(subAllDistrict)) {
agencyScoreDao.insertStreetRecord(subAllDistrict);
public void deleteAndInsert(AgencyCalResultDTO result) {
if (!CollectionUtils.isEmpty(result.getOneTwoLevel())){
agencyScoreDao.insertStreetRecord(result.getOneTwoLevel());
}
if (!CollectionUtils.isEmpty(result.getFiveLevel())){
agencySubScoreDao.insertStreetRecord(result.getFiveLevel());
}
}
@ -356,8 +373,10 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<AgencyScoreDTO> getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, String allParentIndexCode, Map<String, String> pid) {
List<AgencyScoreDTO> result = new ArrayList<>();
public AgencyCalResultDTO getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, String allParentIndexCode, Map<String, String> pid) {
AgencyCalResultDTO result = new AgencyCalResultDTO();
List<AgencyScoreDTO> resultOne = new ArrayList<>();
List<AgencyScoreDTO> resultFive = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
score.setCustomerId(customerId);
@ -393,11 +412,13 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
s.setParentAgencyId(parentAgency);
}
});
result.add(s);
resultFive.add(s);
});
}
result.add(score);
resultOne.add(score);
});
result.setOneTwoLevel(resultOne);
result.setFiveLevel(resultFive);
return result;
}

43
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.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;
@ -8,10 +9,12 @@ 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.AgencySubScoreDao;
import com.epmet.dao.evaluationindex.indexcal.CommunityScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao;
import com.epmet.dto.indexcal.AgencyCalResultDTO;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubCommunityAvgResultDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
@ -62,6 +65,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
private CommunityScoreDao communityScoreDao;
@Autowired
private AgencyScoreDao agencyScoreDao;
@Autowired
private AgencySubScoreDao agencySubScoreDao;
/**
* @Description 计算街道相关总分
@ -160,7 +165,10 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
log.info("streetPartyAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("streetPartyAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
agencySubScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.STREET_LEVEL);
agencyScoreDao.deleteOldRecord(customerId, monthId, IndexCalConstant.STREET_LEVEL);
deleteAndInsert(result);
return true;
@ -233,7 +241,9 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
log.info("streetGovernAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("streetGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -305,7 +315,9 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
log.info("streetServiceAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("streetServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -346,7 +358,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
});
result.add(score);
});
deleteAndInsert(result);
agencyScoreDao.insertStreetRecord(result);
return true;
}
@ -366,15 +378,18 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
}
/**
* @param subAllCommunityList
* @param result
* @Description 先删除记录在插入
* @author zxc
* @date 2020/9/1 4:24 下午
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(List<AgencyScoreDTO> subAllCommunityList) {
if (!CollectionUtils.isEmpty(subAllCommunityList)) {
agencyScoreDao.insertStreetRecord(subAllCommunityList);
public void deleteAndInsert(AgencyCalResultDTO result) {
if (!CollectionUtils.isEmpty(result.getOneTwoLevel())) {
agencyScoreDao.insertStreetRecord(result.getOneTwoLevel());
}
if (!CollectionUtils.isEmpty(result.getFiveLevel())){
agencySubScoreDao.insertStreetRecord(result.getFiveLevel());
}
}
@ -388,8 +403,10 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<AgencyScoreDTO> getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, String allParentIndexCode, Map<String, String> pid) {
List<AgencyScoreDTO> result = new ArrayList<>();
public AgencyCalResultDTO getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, String allParentIndexCode, Map<String, String> pid) {
AgencyCalResultDTO result = new AgencyCalResultDTO();
List<AgencyScoreDTO> resultOne = new ArrayList<>();
List<AgencyScoreDTO> resultFive = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
score.setCustomerId(customerId);
@ -425,11 +442,13 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
s.setParentAgencyId(parentAgency);
}
});
result.add(s);
resultFive.add(s);
});
}
result.add(score);
resultOne.add(score);
});
result.setOneTwoLevel(resultOne);
result.setFiveLevel(resultFive);
return result;
}
}

6
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySubScoreDao.xml

@ -5,7 +5,7 @@
<!-- 【街道】中间表插入 -->
<insert id="insertStreetRecord">
INSERT INTO fact_index_agency_score (ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, DATA_TYPE, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
INSERT INTO fact_index_agency_sub_score (ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, DATA_TYPE, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
@ -19,6 +19,7 @@
#{item.dataType},
#{item.score},
#{item.indexCode},
#{item.allParentIndexCode},
#{item.delFlag},
#{item.revision},
#{item.createdBy},
@ -33,12 +34,11 @@
<delete id="deleteOldRecord">
DELETE
FROM
fact_index_agency_score
fact_index_agency_sub_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = #{indexCode}
AND data_type = #{dataType}
</delete>

4
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySubScoreDao.xml

@ -5,7 +5,7 @@
<!-- 党建能力【社区】中间表插入 -->
<insert id="insertCommunityPartyRecord">
INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
INSERT INTO fact_index_community_sub_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
@ -33,7 +33,7 @@
<delete id="deleteOldRecord">
DELETE
FROM
fact_index_community_score
fact_index_community_sub_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}

Loading…
Cancel
Save