Browse Source

批量删除 插入

master
zxc 5 years ago
parent
commit
3687272c2c
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java
  2. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java
  3. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java
  4. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunitySubScoreDao.java
  5. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  6. 40
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  7. 40
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  8. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml
  9. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySubScoreDao.xml
  10. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml
  11. 1
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySubScoreDao.xml

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java

@ -51,7 +51,7 @@ public interface AgencyScoreDao extends BaseDao<AgencyScoreEntity> {
* @author zxc * @author zxc
* @date 2020/9/2 15:47 * @date 2020/9/2 15:47
*/ */
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("dataType")String dataType); Integer deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("dataType")String dataType,@Param("delNum")Integer delNum);
/** /**
* @Description 查询fact_index_agency_score相关信息 * @Description 查询fact_index_agency_score相关信息

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

@ -50,6 +50,6 @@ public interface AgencySubScoreDao extends BaseDao<AgencyScoreEntity> {
* @author zxc * @author zxc
* @date 2020/9/2 15:47 * @date 2020/9/2 15:47
*/ */
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("dataType") String dataType); Integer deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("dataType") String dataType,@Param("delNum")Integer delNum);
} }

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java

@ -50,7 +50,7 @@ public interface CommunityScoreDao extends BaseDao<FactIndexCommunityScoreEntity
* @author zxc * @author zxc
* @date 2020/9/1 9:03 上午 * @date 2020/9/1 9:03 上午
*/ */
void deleteOldRecord(@Param("customerId") String customerId,@Param("monthId")String monthId); Integer deleteOldRecord(@Param("customerId") String customerId,@Param("monthId")String monthId,@Param("delNum")Integer delNum);
/** /**
* @Description 查询社区相关信息 * @Description 查询社区相关信息

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunitySubScoreDao.java

@ -50,6 +50,6 @@ public interface CommunitySubScoreDao extends BaseDao<FactIndexCommunityScoreEnt
* @author zxc * @author zxc
* @date 2020/9/1 9:03 上午 * @date 2020/9/1 9:03 上午
*/ */
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId); Integer deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId,@Param("delNum")Integer delNum);
} }

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

@ -93,8 +93,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
return; return;
} else { } else {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList())); MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexEnd = NumConstant.TEN; List<List<SubGridAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, IndexCalConstant.PAGE_SIZE);
List<List<SubGridAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, indexEnd);
subPartyAvgList.forEach(party -> { subPartyAvgList.forEach(party -> {
List<SampleValue> index1SampleValues = new ArrayList<>(); List<SampleValue> index1SampleValues = new ArrayList<>();
party.forEach(c -> { party.forEach(c -> {
@ -141,8 +140,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS); HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
CommunityCalResultDTO 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); deleteOldRecord(customerId,monthId);
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId);
deleteAndInsert(result); deleteAndInsert(result);
return true; return true;
} }
@ -385,11 +383,35 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(CommunityCalResultDTO result) { public void deleteAndInsert(CommunityCalResultDTO result) {
if (!CollectionUtils.isEmpty(result.getOneLevel())) { if (!CollectionUtils.isEmpty(result.getOneLevel())) {
factIndexCommunityScoreDao.insertCommunityPartyRecord(result.getOneLevel()); List<List<FactIndexCommunityScoreDTO>> partition = ListUtils.partition(result.getOneLevel(), IndexCalConstant.INSERT_SIZE);
partition.forEach(p -> {
factIndexCommunityScoreDao.insertCommunityPartyRecord(p);
});
} }
if (!CollectionUtils.isEmpty(result.getFiveLevel())){ if (!CollectionUtils.isEmpty(result.getFiveLevel())){
communitySubScoreDao.insertCommunityPartyRecord(result.getFiveLevel()); List<List<FactIndexCommunityScoreDTO>> partition = ListUtils.partition(result.getFiveLevel(), IndexCalConstant.INSERT_SIZE);
partition.forEach(p -> {
communitySubScoreDao.insertCommunityPartyRecord(p);
});
}
} }
/**
* @Description
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/10 2:50 下午
*/
public void deleteOldRecord(String customerId,String monthId){
Integer num;
do {
num = factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId,IndexCalConstant.DELETE_SIZE);
}while (num != NumConstant.ZERO);
Integer subNum;
do {
subNum = communitySubScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.DELETE_SIZE);
}while (subNum != NumConstant.ZERO);
} }
/** /**

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

@ -165,9 +165,8 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
log.info("districtPartyAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("districtPartyAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("districtPartyAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); 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); 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); deleteOldRecord(customerId,monthId,IndexCalConstant.DISTRICT_LEVEL);
agencySubScoreDao.deleteOldRecord(customerId,monthId,IndexCalConstant.DISTRICT_LEVEL); insertDetail(result);
deleteAndInsert(result);
return true; return true;
} }
@ -236,7 +235,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
log.info("districtGovernAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("districtGovernAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("districtGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); 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); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result); insertDetail(result);
return true; return true;
} }
@ -286,7 +285,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
log.info("districtServiceAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("districtServiceAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("districtServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); 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); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result); insertDetail(result);
return true; return true;
} }
@ -347,6 +346,25 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
return result; return result;
} }
/**
* @Description
* @param customerId
* @param monthId
* @param dataType 数据类型 街道street全区district
* @author zxc
* @date 2020/9/10 2:50 下午
*/
public void deleteOldRecord(String customerId,String monthId,String dataType){
Integer num;
do {
num = agencyScoreDao.deleteOldRecord(customerId, monthId,dataType,IndexCalConstant.DELETE_SIZE);
}while (num != NumConstant.ZERO);
Integer subNum;
do {
subNum = agencySubScoreDao.deleteOldRecord(customerId,monthId,dataType,IndexCalConstant.DELETE_SIZE);
}while (subNum != NumConstant.ZERO);
}
/** /**
* @param result * @param result
* @Description 先删除记录在插入 * @Description 先删除记录在插入
@ -354,12 +372,18 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
* @date 2020/9/1 4:24 下午 * @date 2020/9/1 4:24 下午
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(AgencyCalResultDTO result) { public void insertDetail(AgencyCalResultDTO result) {
if (!CollectionUtils.isEmpty(result.getOneTwoLevel())){ if (!CollectionUtils.isEmpty(result.getOneTwoLevel())){
agencyScoreDao.insertStreetRecord(result.getOneTwoLevel()); List<List<AgencyScoreDTO>> partition = ListUtils.partition(result.getOneTwoLevel(), IndexCalConstant.INSERT_SIZE);
partition.forEach(p -> {
agencyScoreDao.insertStreetRecord(p);
});
} }
if (!CollectionUtils.isEmpty(result.getFiveLevel())){ if (!CollectionUtils.isEmpty(result.getFiveLevel())){
agencySubScoreDao.insertStreetRecord(result.getFiveLevel()); List<List<AgencyScoreDTO>> partition = ListUtils.partition(result.getFiveLevel(), IndexCalConstant.INSERT_SIZE);
partition.forEach(p -> {
agencySubScoreDao.insertStreetRecord(p);
});
} }
} }

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

@ -168,9 +168,8 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
log.info("streetPartyAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("streetPartyAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("streetPartyAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); 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); 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); deleteOldRecord(customerId, monthId, IndexCalConstant.STREET_LEVEL);
agencyScoreDao.deleteOldRecord(customerId, monthId, IndexCalConstant.STREET_LEVEL); insertDetail(result);
deleteAndInsert(result);
return true; return true;
} }
@ -244,7 +243,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
log.info("streetGovernAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("streetGovernAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("streetGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); 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); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result); insertDetail(result);
return true; return true;
} }
@ -318,7 +317,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
log.info("streetServiceAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS)); log.info("streetServiceAbilityCalculate getScoreTotalOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
log.info("streetServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId)); 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); AgencyCalResultDTO result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result); insertDetail(result);
return true; return true;
} }
@ -384,13 +383,38 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
* @date 2020/9/1 4:24 下午 * @date 2020/9/1 4:24 下午
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(AgencyCalResultDTO result) { public void insertDetail(AgencyCalResultDTO result) {
if (!CollectionUtils.isEmpty(result.getOneTwoLevel())) { if (!CollectionUtils.isEmpty(result.getOneTwoLevel())) {
agencyScoreDao.insertStreetRecord(result.getOneTwoLevel()); List<List<AgencyScoreDTO>> partition = ListUtils.partition(result.getOneTwoLevel(), IndexCalConstant.INSERT_SIZE);
partition.forEach(p -> {
agencyScoreDao.insertStreetRecord(p);
});
} }
if (!CollectionUtils.isEmpty(result.getFiveLevel())){ if (!CollectionUtils.isEmpty(result.getFiveLevel())){
agencySubScoreDao.insertStreetRecord(result.getFiveLevel()); List<List<AgencyScoreDTO>> partition = ListUtils.partition(result.getFiveLevel(), IndexCalConstant.INSERT_SIZE);
partition.forEach(p -> {
agencySubScoreDao.insertStreetRecord(p);
});
}
} }
/**
* @Description
* @param customerId
* @param monthId
* @param dataType 数据类型 街道street全区district
* @author zxc
* @date 2020/9/10 2:50 下午
*/
public void deleteOldRecord(String customerId,String monthId,String dataType){
Integer num;
do {
num = agencyScoreDao.deleteOldRecord(customerId, monthId,dataType,IndexCalConstant.DELETE_SIZE);
}while (num != NumConstant.ZERO);
Integer subNum;
do {
subNum = agencySubScoreDao.deleteOldRecord(customerId,monthId,dataType,IndexCalConstant.DELETE_SIZE);
}while (subNum != NumConstant.ZERO);
} }
/** /**

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml

@ -41,6 +41,7 @@
AND customer_id = #{customerId} AND customer_id = #{customerId}
AND month_id = #{monthId} AND month_id = #{monthId}
AND data_type = #{dataType} AND data_type = #{dataType}
LIMIT #{delNum}
</delete> </delete>
<select id="selectListAgencyScore" resultType="com.epmet.dto.indexcal.AgencyScoreDTO"> <select id="selectListAgencyScore" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">

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

@ -40,6 +40,7 @@
AND customer_id = #{customerId} AND customer_id = #{customerId}
AND month_id = #{monthId} AND month_id = #{monthId}
AND data_type = #{dataType} AND data_type = #{dataType}
LIMIT #{delNum}
</delete> </delete>
</mapper> </mapper>

1
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml

@ -39,6 +39,7 @@
del_flag = '0' del_flag = '0'
AND customer_id = #{customerId} AND customer_id = #{customerId}
AND month_id = #{monthId} AND month_id = #{monthId}
LIMIT #{delNum}
</delete> </delete>
<!-- 查询社区相关信息 --> <!-- 查询社区相关信息 -->

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

@ -38,6 +38,7 @@
del_flag = '0' del_flag = '0'
AND customer_id = #{customerId} AND customer_id = #{customerId}
AND month_id = #{monthId} AND month_id = #{monthId}
LIMIT #{delNum}
</delete> </delete>
</mapper> </mapper>

Loading…
Cancel
Save