Browse Source

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

dev_shibei_match
wxz 5 years ago
parent
commit
1843d90ed1
  1. 36
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java
  2. 11
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/BranchBuildTrendResultDTO.java
  3. 11
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.java
  4. 12
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenPartyBranchDataDao.java
  5. 7
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/GrassrootsPartyDevServiceImpl.java
  6. 32
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java
  7. 10
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/ModuleConstant.java
  8. 24
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml
  9. 4
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java
  10. 52
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDTO.java
  11. 30
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDetailDTO.java
  12. 2
      epmet-module/data-statistical/data-statistical-server/pom.xml
  13. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  14. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityGridMonthlyDao.java
  15. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexPartyAblityCpcMonthlyDao.java
  16. 86
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java
  17. 69
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java
  18. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java
  19. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java
  20. 85
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java
  21. 92
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/GridScoreEntity.java
  22. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java
  23. 260
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java
  24. 344
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java
  25. 8
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java
  26. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java
  27. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java
  28. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java
  29. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityGridMonthlyDao.xml
  30. 74
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexPartyAblityCpcMonthlyDao.xml
  31. 136
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml
  32. 115
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml
  33. 11
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml
  34. 13
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml

36
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java

@ -9,6 +9,7 @@
package com.epmet.commons.tools.utils;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
@ -33,6 +34,11 @@ public class DateUtils {
public static final List<Integer> Q3Months = Arrays.asList(7, 8, 9);
public static final List<Integer> Q4Months = Arrays.asList(10, 11, 12);
public static final List<String> Q1MonthsStrList = Arrays.asList("1", "2", "3","01","02","03");
public static final List<String> Q2MonthsStrList = Arrays.asList("4", "5", "6","04", "05", "06");
public static final List<String> Q3MonthsStrList = Arrays.asList("7", "8", "9","07", "08", "09");
public static final List<String> Q4MonthsStrList = Arrays.asList("10", "11", "12");
/** 时间格式(yyyy-MM-dd) */
public final static String DATE_PATTERN = "yyyy-MM-dd";
/** 时间格式(yyyy-MM-dd HH:mm:ss) */
@ -298,6 +304,29 @@ public class DateUtils {
return 4;
}
/**
* 获取季度
* @param monthId yyyyMM
* @return yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
public static String getQuarterId(String monthId) {
String year = monthId.substring(0, 4);
String month = monthId.substring(4, 6);
if (Q1MonthsStrList.contains(month)) {
return year.concat("Q1");
}
if (Q2MonthsStrList.contains(month)) {
return year.concat("Q2");
}
if (Q3MonthsStrList.contains(month)) {
return year.concat("Q3");
}
if(Q4MonthsStrList.contains(month)){
return year.concat("Q4");
}
return StrConstant.EPMETY_STR;
}
/**
* 根据季度查询季度的月份列表
* @param quarterIndex
@ -557,4 +586,11 @@ public class DateUtils {
System.out.println(comparteDate(yesterDay,today));
System.out.println(comparteDate(tomorrow,today));
}
public static String getYearId(String monthId) {
if (StringUtils.isNotBlank(monthId) && monthId.length() > 4) {
return monthId.substring(NumConstant.ZERO, NumConstant.FOUR);
}
return StrConstant.EPMETY_STR;
}
}

11
epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/BranchBuildTrendResultDTO.java

@ -1,5 +1,6 @@
package com.epmet.screen.dto.result;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
@ -28,4 +29,14 @@ public class BranchBuildTrendResultDTO implements Serializable {
private List<BranchTrendSeriesDataResultDTO> seriesData;
/**
* 总组织次数
* */
private Integer totalOrganizationCount = NumConstant.ZERO;
/**
* 总参与人数
* */
private Integer totalJoinUserCount = NumConstant.ZERO;
}

11
epmet-module/data-report/data-report-client/src/main/java/com/epmet/screen/dto/result/VolunteerServiceResultDTO.java

@ -1,5 +1,6 @@
package com.epmet.screen.dto.result;
import com.epmet.commons.tools.constant.NumConstant;
import lombok.Data;
import java.io.Serializable;
@ -33,4 +34,14 @@ public class VolunteerServiceResultDTO implements Serializable {
* 平均参与人次
*/
private List<Integer> averageJoinUserData;
/**
* 总组织次数
* */
private Integer totalOrganizationCount = NumConstant.ZERO;
/**
* 总参与人数
* */
private Integer totalJoinUserCount = NumConstant.ZERO;
}

12
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/screen/ScreenPartyBranchDataDao.java

@ -68,4 +68,16 @@ public interface ScreenPartyBranchDataDao {
* @date 2020.08.20 09:46
**/
List<BranchBuildOrderByCountResultDTO> selectBranchDataByTypeOrder(@Param("agencyId")String agencyId,@Param("category")String category,@Param("monthId")String monthId,@Param("bottomMonthId")String bottomMonthId);
/**
* @Description 查询组织总数或者总参与人数
* @param category
* @param type
* @param agencyId
* @param monthId
* @return
* @author wangc
* @date 2020.08.28 17:56
**/
Integer selectTotalOrganizationCount(@Param("category") String category,@Param("type") String type, @Param("agencyId") String agencyId,@Param("monthId") String monthId);
}

7
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/GrassrootsPartyDevServiceImpl.java

@ -155,7 +155,12 @@ public class GrassrootsPartyDevServiceImpl implements GrassrootsPartyDevService
result.setSeriesData(dataArray);
result.setLegend(null == result.getLegend() ? new ArrayList<>() : result.getLegend());
//总组织次数
Integer totalOrganizationCount = screenPartyBranchDataDao.selectTotalOrganizationCount(param.getCategory(),ModuleConstant.PARAM_BRANCH_DATA_TYPE_ORGAN,param.getAgencyId(),monthMap.keySet().iterator().next());
//总参与人数
Integer totalJoinUserCount = screenPartyBranchDataDao.selectTotalOrganizationCount(param.getCategory(),ModuleConstant.PARAM_BRANCH_DATA_TYPE_JOIN,param.getAgencyId(),monthMap.keySet().iterator().next());
result.setTotalOrganizationCount(null == totalOrganizationCount ? NumConstant.ZERO : totalOrganizationCount);
result.setTotalJoinUserCount(null == totalJoinUserCount ? NumConstant.ZERO : totalJoinUserCount);
return result;
}

32
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/screen/impl/PartyMemberLeadServiceImpl.java

@ -19,6 +19,7 @@ import com.epmet.screen.dto.form.VolunteerServiceFormDTO;
import com.epmet.screen.dto.result.*;
import com.epmet.screen.constant.*;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -126,6 +127,13 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService {
List<Integer> joinData = new ArrayList<>();
List<Integer> averageJoinUserData = new ArrayList<>();
result.setXAxis(this.getXPro());
//创建缺省值对象
VolunteerServiceResult defaultObj = new VolunteerServiceResult();
defaultObj.setAverageJoinUserData(NumConstant.ZERO);
defaultObj.setJoinData(NumConstant.ZERO);
defaultObj.setOrganizeData(NumConstant.ZERO);
//倒叙取十二个月的数据,从本月开始,有可能取不到十二条,要对X轴空白的缺口进行填补
List<VolunteerServiceResult> volunteerServiceResults = screenPartyBranchDataDao.selectVolunteerServiceResult(volunteerServiceFormDTO.getAgencyId());
if (volunteerServiceResults.size() == NumConstant.ZERO){
for (int i = NumConstant.ZERO; i <= NumConstant.TWELVE; i++) {
@ -138,15 +146,39 @@ public class PartyMemberLeadServiceImpl implements PartyMemberLeadService {
result.setAverageJoinUserData(averageJoinUserData);
return result;
}
Set<String> yyyyMMList = dateUtils.getXpro().keySet();
yyyyMMList.forEach(mm -> {
Optional<VolunteerServiceResult> opt = volunteerServiceResults.stream()
.filter(obj -> StringUtils.equals(mm,obj.getMonthId())).findAny();
VolunteerServiceResult find = opt.isPresent() ? opt.get() : defaultObj;
//VolunteerServiceResult find = Optional.ofNullable(opt.isPresent() ? opt.get() : null).orElse(defaultObj);
organizeData.add(find.getOrganizeData());
joinData.add(find.getJoinData());
averageJoinUserData.add(find.getAverageJoinUserData());
});
/*
List<VolunteerServiceResult> collect = volunteerServiceResults.stream().sorted(Comparator.comparing(VolunteerServiceResult::getMonthId)).collect(Collectors.toList());
collect.forEach(volunteer -> {
organizeData.add(volunteer.getOrganizeData());
joinData.add(volunteer.getJoinData());
averageJoinUserData.add(volunteer.getAverageJoinUserData());
});
*/
result.setOrganizeData(organizeData);
result.setJoinData(joinData);
result.setAverageJoinUserData(averageJoinUserData);
String bottomMonthId = yyyyMMList.iterator().next();
//总组织次数
Integer totalOrganizationCount = screenPartyBranchDataDao.selectTotalOrganizationCount(ModuleConstant.KEY_BRANCH_CATEGORY_VOLUNTARY_SERVICE,ModuleConstant.PARAM_BRANCH_DATA_TYPE_ORGAN,volunteerServiceFormDTO.getAgencyId(),bottomMonthId);
//总参与人数
Integer totalJoinUserCount = screenPartyBranchDataDao.selectTotalOrganizationCount(ModuleConstant.KEY_BRANCH_CATEGORY_VOLUNTARY_SERVICE,ModuleConstant.PARAM_BRANCH_DATA_TYPE_JOIN,volunteerServiceFormDTO.getAgencyId(),bottomMonthId);
result.setTotalOrganizationCount(null == totalOrganizationCount ? NumConstant.ZERO : totalOrganizationCount);
result.setTotalJoinUserCount(null == totalJoinUserCount ? NumConstant.ZERO : totalJoinUserCount);
return result;
}

10
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/utils/ModuleConstant.java

@ -21,4 +21,14 @@ public interface ModuleConstant {
String PARAM_DIFFICULTY_TYPE_MOST_DEPTS = "mostdepts";
String PARAM_DIFFICULTY_TYPE_MOST_HANDLED = "mosthandled";
/**
* 支部建设情况折线图 查询数据类型 组织次数
* */
String PARAM_BRANCH_DATA_TYPE_ORGAN = "organize";
/**
* 支部建设情况折线图 查询数据类型 参与人数
* */
String PARAM_BRANCH_DATA_TYPE_JOIN = "joinuser";
}

24
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenPartyBranchDataDao.xml

@ -29,7 +29,6 @@
screen_party_branch_data
WHERE
DEL_FLAG = '0'
AND ORG_TYPE = 'agency'
AND ORG_ID = #{agencyId}
AND TYPE = #{category}
AND MONTH_ID <![CDATA[ >= ]]> #{bottomMonthId}
@ -73,16 +72,33 @@
<select id="selectVolunteerServiceResult" resultType="com.epmet.screen.dto.result.VolunteerServiceResult">
SELECT
month_id AS monthId,
organize_count AS organizeData,
join_user_count AS joinData,
average_join_user_count AS averageJoinUserData
SUM(organize_count) AS organizeData,
SUM(join_user_count) AS joinData,
SUM(average_join_user_count) AS averageJoinUserData
FROM
screen_party_branch_data
WHERE
del_flag = '0'
AND org_id = #{agencyId}
AND type = 'voluntaryservice'
GROUP BY MONTH_ID
ORDER BY MONTH_ID DESC
LIMIT 12
</select>
<!-- 查询组织总数或者总参与人数 -->
<select id="selectTotalOrganizationCount" resultType="int">
SELECT
CASE #{type} WHEN 'organize' THEN SUM(ORGANIZE_COUNT)
ELSE SUM(JOIN_USER_COUNT)
END AS data
FROM
screen_party_branch_data
WHERE
DEL_FLAG = '0'
AND ORG_ID = #{agencyId}
AND TYPE = #{category}
AND MONTH_ID <![CDATA[ >= ]]> #{monthId}
</select>
</mapper>

4
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java

@ -12,7 +12,11 @@ public interface IndexCalConstant {
String GRID_ID="GRID_ID";
String AGENCY_ID="AGENCY_ID";
String CUSTOMER_ID="CUSTOMER_ID";
String MONTH_ID="MONTH_ID";
String USER_ID="USER_ID";
}

52
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDTO.java

@ -0,0 +1,52 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 网格相关分值
*
* @author yinzuomei@elink-cn.com
* @date 2020/8/31 16:38
*/
@Data
public class GridScoreDTO implements Serializable {
/**
* 网格Id
*/
private String gridId;
/**
* 客户Id
*/
private String customerId;
/**
* 网格所属的机关Id
*/
private String agencyId;
/**
* 所有上级ID用英文逗号分开
*/
private String allParentIds;
/**
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
private List<GridScoreDetailDTO> detailList;
}

30
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/GridScoreDetailDTO.java

@ -0,0 +1,30 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 网格相关分值
*
* @author yinzuomei@elink-cn.com
* @date 2020/8/31 16:39
*/
@Data
public class GridScoreDetailDTO implements Serializable {
/**
* 1总分0不是
*/
private String isTotal;
/**
* 分值
*/
private BigDecimal score;
/**
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli网格相关wanggexiangguan
*/
private String indexCode;
}

2
epmet-module/data-statistical/data-statistical-server/pom.xml

@ -195,7 +195,7 @@
<spring.redis.port>6379</spring.redis.port>
<spring.redis.password>123456</spring.redis.password>
<!-- nacos -->
<nacos.register-enabled>true</nacos.register-enabled>
<nacos.register-enabled>false</nacos.register-enabled>
<nacos.server-addr>192.168.1.130:8848</nacos.server-addr>
<nacos.discovery.namespace>6ceab336-d004-4acf-89c6-e121d06f4988</nacos.discovery.namespace>
<nacos.config.namespace></nacos.config.namespace>

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

@ -44,7 +44,7 @@ public class IndexCalculateController {
}
@PostMapping("getMax")
public Result getMax(){
CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO("c1","202008");
CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO("b09527201c4409e19d1dbc5e3c3429a1","202008");
cpcIndexCalculateService.cpcIndexCalculate(calculateCommonFormDTO);
return new Result();
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexcoll/FactIndexGovrnAblityGridMonthlyDao.java

@ -18,6 +18,7 @@
package com.epmet.dao.indexcoll;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.PageQueryGridFormDTO;
import com.epmet.dto.indexcollect.form.GridGovrnAbilityFormDTO;
import com.epmet.entity.indexcoll.FactIndexGovrnAblityGridMonthlyEntity;
@ -85,4 +86,13 @@ public interface FactIndexGovrnAblityGridMonthlyDao extends BaseDao<FactIndexGov
* @Date 2020/8/27 13:10
**/
Map<String, Object> selectGovrnAblityGridMinAndMax(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* @return int
* @param formDTO
* @author yinzuomei
* @description 查询当前月共上传了多少条记录治理能力-网格相关事实表
* @Date 2020/8/31 14:31
**/
int selectCount(CalculateCommonFormDTO formDTO);
}

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

@ -23,7 +23,6 @@ import com.epmet.entity.indexcoll.FactIndexPartyAblityCpcMonthlyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@ -70,7 +69,7 @@ public interface FactIndexPartyAblityCpcMonthlyDao extends BaseDao<FactIndexPart
void batchInsertFactIndexPartyAblityCpcMonthly(@Param("list") List<GridPartyMemberDataFormDTO> list,
@Param("customerId") String customerId);
Map<String,BigDecimal> getCountByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId);
List<Map<String, Object>> getCountByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("offset") Integer offset, @Param("pageSize") Integer pageSize);
Map<String, BigDecimal> getExtremeValue(@Param("customerId") String customerId);
Map<String, Object> getExtremeValue(@Param("customerId") String customerId);
}

86
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/CpcScoreDao.java

@ -0,0 +1,86 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao.indexscore;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.entity.indexscore.CpcScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
/**
* 党员相关分值
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
*/
@Mapper
public interface CpcScoreDao extends BaseDao<CpcScoreEntity> {
/**
* @param customerId
* @param monthId
* @param gridId
* @return java.math.BigDecimal
* @author yinzuomei
* @description 获取网格内党员的联系群众能力考评分平均值
* @Date 2020/8/31 10:56
**/
BigDecimal selectGridContactMassesAvgValue(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("gridId") String gridId);
/**
* @param formDTO
* @return java.util.List<java.math.BigDecimal>
* @author yinzuomei
* @description 获取网格内党员的联系群众能力考评分平均值的最大值最小值
* @Date 2020/8/31 12:10
**/
List<BigDecimal> selectListGridContactMassesAvgValue(CalculateCommonFormDTO formDTO);
/**
* @param calculateCommonFormDTO
* @return java.util.List<java.math.BigDecimal>
* @author yinzuomei
* @description 网格内党员的参与议事能力考评分平均值 最大值最小值
* @Date 2020/8/31 14:42
**/
List<BigDecimal> selectListJoinIssueAvgValue(CalculateCommonFormDTO calculateCommonFormDTO);
/**
* @param customerId
* @param monthId
* @param gridId
* @return java.math.BigDecimal
* @author yinzuomei
* @description 组织内党员的参与议事能力考评分平均值
* @Date 2020/8/31 15:51
**/
BigDecimal selectGridJoinIssueAvgValue(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("gridId") String gridId);
int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode);
List<CpcScoreEntity> getPartScore(@Param("customerId") String customerId, @Param("monthId") String monthId);
int insertBatch(@Param("list") Collection<CpcScoreEntity> values);
}

69
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java

@ -0,0 +1,69 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao.indexscore;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.GridScoreDTO;
import com.epmet.entity.indexscore.GridScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 网格相关分值
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
*/
@Mapper
public interface GridScoreDao extends BaseDao<GridScoreEntity> {
/**
* @param customerId
* @param monthId
* @param indexCode
* @param isTotal 1总分0不是
* @return int
* @author yinzuomei
* @description
* @Date 2020/8/31 14:00
**/
int deleteByCusAndMonthId(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("indexCode") String indexCode,
@Param("isTotal") String isTotal);
/**
* @return int
* @param gridScoreEntityList
* @author yinzuomei
* @description
* @Date 2020/8/31 14:01
**/
int insertBatches(List<GridScoreEntity> gridScoreEntityList);
/**
* @return java.util.List<com.epmet.dto.indexcal.GridScoreDTO>
* @param formDTO
* @author yinzuomei
* @description
* @Date 2020/8/31 16:42
**/
List<GridScoreDTO> selectList(CalculateCommonFormDTO formDTO);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/IndexGroupDetailDao.java

@ -34,4 +34,6 @@ import java.util.List;
public interface IndexGroupDetailDao extends BaseDao<IndexGroupDetailEntity> {
List<IndexGroupDetailEntity> getDetailListByParentCode(@Param("customerId") String customerId, @Param("indexCode") String indexCode);
List<IndexGroupDetailEntity> getDetailListLikeParentCode(@Param("customerId") String customerId, @Param("parentIndexCode") String parentIndexCode);
}

10
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/screen/ScreenCustomerGridDao.java

@ -84,4 +84,14 @@ public interface ScreenCustomerGridDao extends BaseDao<ScreenCustomerGridEntity>
* @Date 2020/8/27 14:42
**/
List<ScreenCustomerGridDTO> pageListByCustomerId(PageQueryGridFormDTO formDTO);
/**
* @param customerId 客户id
* @param gridId 网格id
* @return java.lang.String
* @author yinzuomei
* @description 查询网格所属的组织id
* @Date 2020/8/31 12:35
**/
ScreenCustomerGridDTO selectParentAgencyId(@Param("customerId") String customerId, @Param("gridId") String gridId);
}

85
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/CpcScoreEntity.java

@ -0,0 +1,85 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.indexscore;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 党员相关分值
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("fact_index_cpc_score")
public class CpcScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id
*/
private String customerId;
/**
* 网格所属的机关Id
*/
private String agencyId;
/**
* 网格Id
*/
private String gridId;
/**
* 年维度Id: yyyy
*/
private String yearId;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
/**
* 用户id
*/
private String userId;
/**
* 分值
*/
private BigDecimal score;
/**
* 指标code
*/
private String indexCode;
/**
* 是否是总分 1是0不是
*/
private String isTotal;
}

92
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/indexscore/GridScoreEntity.java

@ -0,0 +1,92 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.indexscore;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
import java.util.Date;
/**
* 网格相关分值
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("fact_index_grid_score")
public class GridScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id
*/
private String customerId;
/**
* 网格Id
*/
private String gridId;
/**
* 网格所属的机关Id
*/
private String agencyId;
/**
* 所有上级ID用英文逗号分开
*/
private String allParentIds;
/**
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
/**
* 1总分0不是
*/
private String isTotal;
/**
* 分值
*/
private BigDecimal score;
/**
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli网格相关wanggexiangguan
*/
private String indexCode;
}

1
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java

@ -24,6 +24,7 @@ public enum IndexCodeEnum {
DANG_WU_HUO_DONG("dangwuhuodong", "党务活动", 4),
LIAN_XI_QUN_ZHONG("lianxiqunzhong", "联系群众", 4),
ZUZHINEIDANGYDLXQZNLKPFPJZ("zuzhineidangydlxqznlkpfpjz","组织内党员的联系群众能力考评分(平均值)",5),
ZUZHINEIDANGYDSYYSNLKPFPJZ("zuzhineidangydsyysnlkpfpjz","组织内党员的参与议事能力考评分(平均值)",5),
;
private String code;

260
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/CpcIndexCalculateServiceImpl.java

@ -1,22 +1,38 @@
package com.epmet.service.indexcal.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao;
import com.epmet.dao.indexscore.CpcScoreDao;
import com.epmet.dao.screen.IndexCodeFieldReDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.entity.indexscore.CpcScoreEntity;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.indexcal.CpcIndexCalculateService;
import com.epmet.service.indexcal.IndexCodeFieldReService;
import com.epmet.service.screen.IndexGroupDetailService;
import com.epmet.support.normalizing.BigDecimalScoreCalculator;
import com.epmet.support.normalizing.Correlation;
import com.epmet.support.normalizing.ScoreCalculator;
import com.epmet.support.normalizing.ScoreConstants;
import com.epmet.support.normalizing.batch.BatchScoreCalculator;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.SampleValue;
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.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
@Slf4j
@Service
@ -29,35 +45,231 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
private IndexGroupDetailService getDetailListByParentCode;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@Autowired
private CpcScoreDao cpcScoreDao;
@Override
public Boolean cpcIndexCalculate(CalculateCommonFormDTO formDTO) {
//计算最大最小值
Map<String, BigDecimal> minAndMaxList = factIndexPartyAblityCpcMonthlyDao.getExtremeValue(formDTO.getCustomerId());
if (CollectionUtils.isEmpty(minAndMaxList)){
log.warn("cpcIndexCalculate customerId:{} have not any fact record",formDTO.getCustomerId());
return false;
calculatePartScore(formDTO);
calculateTotalScore(formDTO);
return true;
}
/**
* desc: 计算总分
*
* @param formDTO
*/
private void calculateTotalScore(CalculateCommonFormDTO formDTO) {
//获取指标权重
List<IndexGroupDetailEntity> parentIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode());
if (CollectionUtils.isEmpty(parentIndexDetails)) {
log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
return;
}
//获取指标权重信息
List<IndexGroupDetailEntity> indexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(),IndexCodeEnum.CAN_YU_YI_SHI.getCode());
if (CollectionUtils.isEmpty(indexDetails)){
log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail",formDTO.getCustomerId());
return false;
//获取数据
List<CpcScoreEntity> list = null;
Map<String, CpcScoreEntity> cpcScoreTotalMap = new HashMap<>();
Map<String, IndexGroupDetailEntity> indexWeightMap = parentIndexDetails.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, o -> o));
list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId());
if (!CollectionUtils.isEmpty(list)) {
Map<String, List<CpcScoreEntity>> userGroupMap = list.stream().collect(Collectors.groupingBy(CpcScoreEntity::getUserId));
userGroupMap.forEach((userId, partScoreList) -> {
CpcScoreEntity totalEntity = null;
for (CpcScoreEntity part : partScoreList) {
IndexGroupDetailEntity indexGroupDetailEntity = indexWeightMap.get(part.getIndexCode());
if (totalEntity == null) {
totalEntity = ConvertUtils.sourceToTarget(part, CpcScoreEntity.class);
totalEntity.setIsTotal(NumConstant.ONE_STR);
totalEntity.setIndexCode(indexGroupDetailEntity.getIndexCode());
cpcScoreTotalMap.put(userId, totalEntity);
}
BigDecimal total = part.getScore().multiply(indexGroupDetailEntity.getWeight());
totalEntity.setScore(totalEntity.getScore().add(total));
}
});
}
insertBatch(cpcScoreTotalMap.values().stream().collect(Collectors.toList()));
}
private void insertBatch(Collection<CpcScoreEntity> values) {
cpcScoreDao.insertBatch(values);
}
private void calculatePartScore(CalculateCommonFormDTO formDTO) {
Map<String, String> indexCodeFieldReList = indexCodeFieldReService.getIndexCodeFieldReMap();
if (CollectionUtils.isEmpty(indexCodeFieldReList)){
log.warn("cpcIndexCalculate have any indexcodefieldre");
return false;
if (CollectionUtils.isEmpty(indexCodeFieldReList)) {
log.error("cpcIndexCalculate have any indexcodefieldre");
return;
}
//计算最大最小值
Map<String, Object> minAndMaxMap = factIndexPartyAblityCpcMonthlyDao.getExtremeValue(formDTO.getCustomerId());
if (CollectionUtils.isEmpty(minAndMaxMap)) {
log.warn("cpcIndexCalculate getExtremeValue customerId:{} have not any fact record", formDTO.getCustomerId());
return;
}
//指标集合
//对指标进行分组
//Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = indexDetails.stream().collect(Collectors.groupingBy(IndexGroupDetailEntity::getAllParentIndexCode));
//获取指标权重信息 -参与议事
List<IndexGroupDetailEntity> canyuyishiIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.CAN_YU_YI_SHI.getCode());
if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) {
log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
return;
}
List<IndexGroupDetailEntity> dangwuhongdongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_WU_HUO_DONG.getCode());
if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) {
log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
return;
}
String indexCode = null;
String fieldName = null;
for (IndexGroupDetailEntity indexDetail : indexDetails) {
indexCode = indexDetail.getIndexCode();
fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode);
List<IndexGroupDetailEntity> lianxiqunzhongIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode(), IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode());
if (CollectionUtils.isEmpty(canyuyishiIndexDetails)) {
log.warn("cpcIndexCalculate customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
return;
}
Map<String, List<IndexGroupDetailEntity>> groupIndexDetailsMap = new HashMap<>();
groupIndexDetailsMap.put(IndexCodeEnum.CAN_YU_YI_SHI.getCode(), canyuyishiIndexDetails);
groupIndexDetailsMap.put(IndexCodeEnum.DANG_WU_HUO_DONG.getCode(), dangwuhongdongIndexDetails);
groupIndexDetailsMap.put(IndexCodeEnum.LIAN_XI_QUN_ZHONG.getCode(), lianxiqunzhongIndexDetails);
List<Map<String, Object>> list = null;
int pageNo = 1;
int pageSize = 10;
do {
list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize);
if (!CollectionUtils.isEmpty(list)) {
//遍历指标分组 计算分数
List<Map<String, Object>> finalList = list;
groupIndexDetailsMap.forEach((parentIndexCode, details) -> {
calculate(formDTO, details, finalList, minAndMaxMap, parentIndexCode);
});
}
} while (!CollectionUtils.isEmpty(list) && pageNo++ > 0);
}
private void calculate(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexDetailList, List<Map<String, Object>> finalList, Map<String, Object> minAndMaxMap, String parentIndexCode) {
Map<String, IndexInputVO<BigDecimal>> indexMap = getIndexInputVO(indexDetailList, minAndMaxMap);
Map<String, CpcScoreEntity> scoreEntityMap = new HashMap<>();
//遍历指标 进行计算
for (Map.Entry<String, IndexInputVO<BigDecimal>> entry : indexMap.entrySet()) {
String indexCode = entry.getKey();
IndexInputVO<BigDecimal> value = entry.getValue();
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(indexCode);
if (StringUtils.isBlank(fieldName)) {
log.error("cpcIndexCalculate fieldName error");
continue;
}
for (Map<String, Object> cpcCount : finalList) {
//对应的数值
String userId = String.valueOf(cpcCount.get(IndexCalConstant.USER_ID));
String sampleValueStr = String.valueOf(cpcCount.get(fieldName));
CpcScoreEntity cpcScoreEntity = new CpcScoreEntity();
cpcScoreEntity.setYearId(DimIdGenerator.getYearDimId(DateUtils.addDateMonths(new Date(), -1)));
cpcScoreEntity.setCustomerId(formDTO.getCustomerId());
cpcScoreEntity.setAgencyId(String.valueOf(cpcCount.get(IndexCalConstant.AGENCY_ID)));
cpcScoreEntity.setGridId(String.valueOf(cpcCount.get(IndexCalConstant.GRID_ID)));
cpcScoreEntity.setUserId(userId);
cpcScoreEntity.setIsTotal(NumConstant.ZERO_STR);
cpcScoreEntity.setMonthId(formDTO.getMonthId());
cpcScoreEntity.setScore(new BigDecimal(0));
cpcScoreEntity.setIndexCode(parentIndexCode);
scoreEntityMap.put(userId, cpcScoreEntity);
//构造样本值对象
SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) cpcCount.get(IndexCalConstant.USER_ID), new BigDecimal(sampleValueStr));
value.getIndexValueVOs().add(currentGridIndexValue);
}
}
log.warn("计算的参数:{}", indexMap);
HashMap<String, BigDecimal> result = calculate(indexMap);
log.info(JSON.toJSONString(minAndMaxList));
Map<String, BigDecimal> list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId());
return null;
//处理结果
saveCpcScore(formDTO, scoreEntityMap, parentIndexCode, result);
}
@Transactional(rollbackFor = Exception.class)
public void saveCpcScore(CalculateCommonFormDTO formDTO, Map<String, CpcScoreEntity> indexDetails, String parentIndexCode, HashMap<String, BigDecimal> result) {
cpcScoreDao.deleteByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), parentIndexCode);
List<CpcScoreEntity> list = new ArrayList<>();
result.forEach((userId, score) -> {
CpcScoreEntity cpcScoreEntity = indexDetails.get(userId);
cpcScoreEntity.setScore(score);
list.add(cpcScoreEntity);
});
this.insertBatch(list);
}
/**
* @param indexMap
* @return java.util.List<com.epmet.support.normalizing.batch.IndexOutputVO>
* @author yinzuomei
* @description
* @Date 2020/8/30 21:40
**/
private HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
//构造入参
List<IndexInputVO> indexInputVOS = indexMap.values().stream().collect(Collectors.toList());
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
}
/**
* @param indexList 指标集合
* @param minAndMaxMap 最大值最小值集合
* @return java.util.Map<java.lang.String, com.epmet.support.normalizing.batch.IndexInputVO>
* @author yinzuomei
* @description
* @Date 2020/8/30 15:56
**/
private Map<String, IndexInputVO<BigDecimal>> getIndexInputVO(List<IndexGroupDetailEntity> indexList, Map<String, Object> minAndMaxMap) {
Map<String, IndexInputVO<BigDecimal>> map = new HashMap<>();
for (int indexNum = 0; indexNum < indexList.size(); indexNum++) {
IndexGroupDetailEntity index = indexList.get(indexNum);
IndexInputVO indexInputVO = new IndexInputVO();
// 指标code
indexInputVO.setIndexId(index.getIndexCode());
//权重
indexInputVO.setWeight(index.getWeight());
BigDecimal minValue = null;
BigDecimal maxValue = null;
//获取指标对应的列名
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode());
//最小值key
String minValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MIN);
//最大值key
String maxValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MAX);
minValue = new BigDecimal(String.valueOf(minAndMaxMap.get(minValueKey)));
maxValue = new BigDecimal(String.valueOf(minAndMaxMap.get(maxValueKey)));
//分值计算器
ScoreCalculator<Integer> scoreCalculator = new BigDecimalScoreCalculator(minValue,
maxValue,
ScoreConstants.MIN_SCORE,
ScoreConstants.MAX_SCORE,
Correlation.getCorrelation(index.getCorrelation())
);
indexInputVO.setScoreCalculator(scoreCalculator);
List<SampleValue<BigDecimal>> sampleValueList = new ArrayList<>();
indexInputVO.setIndexValueVOs(sampleValueList);
map.put(index.getIndexCode(), indexInputVO);
}
return map;
}
}

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

@ -2,15 +2,17 @@ package com.epmet.service.indexcal.impl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.indexcoll.FactIndexGovrnAblityGridMonthlyDao;
import com.epmet.dao.indexcoll.FactIndexPartyAblityGridMonthlyDao;
import com.epmet.dao.indexcoll.FactIndexServiceAblityGridMonthlyDao;
import com.epmet.dao.indexscore.CpcScoreDao;
import com.epmet.dao.indexscore.GridScoreDao;
import com.epmet.dao.screen.ScreenCustomerGridDao;
import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CustomerGridInfoDTO;
import com.epmet.dto.indexcal.PageQueryGridFormDTO;
import com.epmet.dto.indexcal.*;
import com.epmet.entity.indexscore.GridScoreEntity;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.indexcal.GridCorreLationService;
@ -23,6 +25,7 @@ import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
@ -51,6 +54,11 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
private IndexGroupDetailService indexGroupDetailService;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@Autowired
private CpcScoreDao cpcScoreDao;
@Autowired
private GridScoreDao gridScoreDao;
/**
* @param formDTO
@ -67,28 +75,28 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (!CollectionUtils.isEmpty(dangJianNengLiList)) {
//1、计算网格相关-党建能力
calculateGridCorreLationDangJian(formDTO, dangJianNengLiList);
calculateGridDangJian(formDTO, dangJianNengLiList);
}
/* List<IndexGroupDetailEntity> zhiLiNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
List<IndexGroupDetailEntity> zhiLiNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (!CollectionUtils.isEmpty(zhiLiNengLiList)) {
//2、计算网格相关-治理能力
calculateGridCorreLationZhiLi(formDTO, zhiLiNengLiList);
calculateGridZhiLi(formDTO, zhiLiNengLiList);
}
List<IndexGroupDetailEntity> fuWuNengLiList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),
IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (!CollectionUtils.isEmpty(fuWuNengLiList)) {
//3、计算网格相关-服务能力
calculateGridCorreLationFuWu(formDTO, fuWuNengLiList);
calculateGridFuWu(formDTO, fuWuNengLiList);
}
//计算网格相关总分
List<IndexGroupDetailEntity> wgxgList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
if (!CollectionUtils.isEmpty(wgxgList)) {
calculateGridCorreLationTotal(formDTO, wgxgList);
}*/
calculateGridTotal(formDTO, wgxgList,IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
}
resultFlag = true;
return resultFlag;
}
@ -101,7 +109,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 计算网格相关-党建能力
* @Date 2020/8/26 16:47
**/
private void calculateGridCorreLationDangJian(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
@Transactional(rollbackFor = Exception.class)
public void calculateGridDangJian(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
//查询总记录数
int total = factIndexPartyAblityGridMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
@ -115,6 +124,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
Map<String, Object> minAndMaxMap = queryPartyAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId());
//指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = getIndexInputVO(formDTO, indexList, minAndMaxMap);
List<HashMap<String, BigDecimal>> resultMapList=new ArrayList<>();
//分页查询采集记录
for (int pageNo = 1; pageNo <= totalPage; pageNo++) {
int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE;
@ -136,47 +146,140 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), new BigDecimal(sampleValueStr));
value.getIndexValueVOs().add(currentGridIndexValue);
} else if (IndexCodeEnum.ZUZHINEIDANGYDLXQZNLKPFPJZ.getCode().equals(key)) {
//组织内党员的联系群众能力考评分(平均值) TODO
logger.info("组织内党员的联系群众能力考评分(平均值) TODO");
//组织内党员的联系群众能力考评分(平均值)
logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理");
//网格内党员的联系群众能力考评分(平均值)
/* BigDecimal contactResiAblity = null;
SampleValue<BigDecimal> contactResiAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), contactResiAblity);
value.getIndexValueVOs().add(contactResiAblityValue);*/
String gridId=(String) recordMap.get(IndexCalConstant.GRID_ID);
BigDecimal contactMassesAvgValue = getGridContactMassesAvgValue(formDTO,gridId);
SampleValue<BigDecimal> contactMassesAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), contactMassesAvgValue);
value.getIndexValueVOs().add(contactMassesAblityValue);
}
});
});
List<IndexOutputVO> result = calculate(indexMap);
// TODO 处理结果
saveGridCorreLationDangJian(formDTO, indexList, result);
try {
for (IndexOutputVO m : result) {
logger.info("indexId=" + m.getIndexId());
for (SampleScore sampleScore : m.getIndexScoreVOs()) {
logger.info(String.format("网格id:%s,得分:%s", sampleScore.getSampleId(), sampleScore.getSampleScore()));
}
}
} catch (Exception e) {
}
HashMap<String, BigDecimal> resultMap = calculate(indexMap);
resultMapList.add(resultMap);
}
// 保存中间表
saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),NumConstant.ZERO_STR);
}
/**
* @return java.util.Map<java.lang.String,java.math.BigDecimal>
* @param calculateCommonFormDTO
* @author yinzuomei
* @description 获取网格内党员的联系群众能力考评分平均值的最大值最小值
* @Date 2020/8/31 9:51
**/
private Map<String, BigDecimal> getContactMassesAblityMap(CalculateCommonFormDTO calculateCommonFormDTO) {
Map<String, BigDecimal> map=new HashMap<>();
List<BigDecimal> list=cpcScoreDao.selectListGridContactMassesAvgValue(calculateCommonFormDTO);
if(!CollectionUtils.isEmpty(list)){
BigDecimal minValue=Collections.min(list);
BigDecimal maxValue=Collections.max(list);
map.put(StrConstant.MIN,minValue);
map.put(StrConstant.MAX,maxValue);
return map;
}
map.put(StrConstant.MIN,new BigDecimal(NumConstant.ZERO_STR));
map.put(StrConstant.MAX,new BigDecimal(NumConstant.ZERO_STR));
return map;
}
/**
* @return java.math.BigDecimal
* @param calculateCommonFormDTO
* @param gridId 网格id
* @author yinzuomei
* @description 获取网格组织内党员的联系群众能力考评分平均值
* @Date 2020/8/31 9:50
**/
private BigDecimal getGridContactMassesAvgValue(CalculateCommonFormDTO calculateCommonFormDTO,String gridId) {
BigDecimal result=cpcScoreDao.selectGridContactMassesAvgValue(calculateCommonFormDTO.getCustomerId(),calculateCommonFormDTO.getMonthId(),gridId);
if(null==result){
return new BigDecimal(NumConstant.ZERO_STR);
}
return result;
}
/**
* @param formDTO 客户id 月份id: yyyyMM
* @param indexList 指标集合
* @param indexOutputVOList
* @return java.math.BigDecimal
* @param formDTO
* @param gridId
* @author yinzuomei
* @description 组织内党员的参与议事能力考评分平均值
* @Date 2020/8/31 15:51
**/
private BigDecimal getGridJoinIssueAvgValue(CalculateCommonFormDTO formDTO, String gridId) {
BigDecimal result=cpcScoreDao.selectGridJoinIssueAvgValue(formDTO.getCustomerId(),formDTO.getMonthId(),gridId);
if(null==result){
return new BigDecimal(NumConstant.ZERO_STR);
}
return result;
}
/**
* @return java.util.Map<java.lang.String,java.math.BigDecimal>
* @param calculateCommonFormDTO
* @author yinzuomei
* @description 网格内党员的参与议事能力考评分平均值 最大值最小值
* @Date 2020/8/31 14:41
**/
private Map<String, BigDecimal> getJoinIssueAblityMap(CalculateCommonFormDTO calculateCommonFormDTO){
Map<String, BigDecimal> map=new HashMap<>();
List<BigDecimal> list=cpcScoreDao.selectListJoinIssueAvgValue(calculateCommonFormDTO);
if(!CollectionUtils.isEmpty(list)){
BigDecimal minValue=Collections.min(list);
BigDecimal maxValue=Collections.max(list);
map.put(StrConstant.MIN,minValue);
map.put(StrConstant.MAX,maxValue);
return map;
}
map.put(StrConstant.MIN,new BigDecimal(NumConstant.ZERO_STR));
map.put(StrConstant.MAX,new BigDecimal(NumConstant.ZERO_STR));
return map;
}
/**
* @param formDTO 客户id 月份id: yyyyMM
* @param resultMapList
* @param indexCode 指标编码
* @param isTotal 1总分0不是
* @return void
* @author yinzuomei
* @description 保存网格相关五级指标分值
* @description 保存网格相关三大能力
* @Date 2020/8/30 22:50
**/
private void saveGridCorreLationDangJian(CalculateCommonFormDTO formDTO,
List<IndexGroupDetailEntity> indexList,
List<IndexOutputVO> indexOutputVOList) {
Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity()));
List<HashMap<String, BigDecimal>> resultMapList,
String indexCode,
String isTotal) {
List<GridScoreEntity> gridScoreEntityList = new ArrayList<>();
String quarterId = DateUtils.getQuarterId(formDTO.getMonthId());
String yearId = DateUtils.getYearId(formDTO.getMonthId());
for (HashMap<String, BigDecimal> resultMap : resultMapList) {
resultMap.forEach((gridId, partyAblityScore) -> {
logger.info("网格id:" + gridId + ";分值:" + partyAblityScore);
GridScoreEntity gridScoreEntity = new GridScoreEntity();
gridScoreEntity.setCustomerId(formDTO.getCustomerId());
gridScoreEntity.setGridId(gridId);
gridScoreEntity.setIsTotal(isTotal);
gridScoreEntity.setIndexCode(indexCode);
ScreenCustomerGridDTO screenCustomerGridDTO = screenCustomerGridDao.selectParentAgencyId(formDTO.getCustomerId(), gridId);
if (null != screenCustomerGridDTO) {
gridScoreEntity.setAgencyId(screenCustomerGridDTO.getParentAgencyId());
gridScoreEntity.setAllParentIds(screenCustomerGridDTO.getAllParentIds());
}
gridScoreEntity.setQuarterId(quarterId);
gridScoreEntity.setYearId(yearId);
gridScoreEntity.setMonthId(formDTO.getMonthId());
gridScoreEntity.setScore(partyAblityScore);
gridScoreEntityList.add(gridScoreEntity);
});
}
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode,isTotal);
gridScoreDao.insertBatches(gridScoreEntityList);
}
}
/**
@ -186,11 +289,11 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description
* @Date 2020/8/30 21:40
**/
private List<IndexOutputVO> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
private HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
//构造入参
List<IndexInputVO> indexInputVOS = this.getIndexInputVOList(indexMap);
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
return batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
return batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
}
/**
@ -230,26 +333,31 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
BigDecimal minValue = null;
BigDecimal maxValue = null;
if (IndexCodeEnum.ZUZHINEIDANGYDLXQZNLKPFPJZ.getCode().equals(index.getIndexCode())) {
//组织内党员的联系群众能力考评分(平均值) TODO 获取最大值,最小值
logger.info("组织内党员的联系群众能力考评分(平均值) TODO");
/*Map<String,BigDecimal> contactResiAblityMap=;
minValue=contactResiAblityMap.get(StrConstant.MIN);
maxValue=contactResiAblityMap.get(StrConstant.MAX);*/
continue;
//组织内党员的联系群众能力考评分(平均值) 获取最大值,最小值
logger.info("组织内党员的联系群众能力考评分(平均值) 单独处理");
Map<String,BigDecimal> contactMassesAblityMap= this.getContactMassesAblityMap(formDTO);
minValue=contactMassesAblityMap.get(StrConstant.MIN);
maxValue=contactMassesAblityMap.get(StrConstant.MAX);
}else if(IndexCodeEnum.ZUZHINEIDANGYDSYYSNLKPFPJZ.getCode().equals(index.getIndexCode())){
logger.info("组织内党员的参与议事能力考评分(平均值) 单独处理");
Map<String,BigDecimal> joinIssueAblityMap= this.getJoinIssueAblityMap(formDTO);
minValue=joinIssueAblityMap.get(StrConstant.MIN);
maxValue=joinIssueAblityMap.get(StrConstant.MAX);
} else {
//获取指标对应的列名
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode());
// logger.info("fieldName=" + fieldName + ";index.getIndexCode()=" + index.getIndexCode());
//最小值key
if(StringUtils.isBlank(fieldName)){
logger.error("index_code:"+index.getIndexCode()+"not find field_name");
continue;
}
logger.info("INDEX_CODE=" + index.getIndexCode()+";FIELD_ID=" + fieldName );
String minValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MIN);
//最大值key
String maxValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MAX);
minValue = new BigDecimal(String.valueOf(minAndMaxMap.get(minValueKey)));
maxValue = new BigDecimal(String.valueOf(minAndMaxMap.get(maxValueKey)));
}
// logger.info("minValue="+minValue+";maxValue="+maxValue);
//分值计算器
ScoreCalculator<Integer> scoreCalculator = new BigDecimalScoreCalculator(minValue,
ScoreCalculator scoreCalculator = new BigDecimalScoreCalculator(minValue,
maxValue,
ScoreConstants.MIN_SCORE,
ScoreConstants.MAX_SCORE,
@ -272,10 +380,58 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 计算网格相关-治理能力
* @Date 2020/8/26 16:47
**/
private void calculateGridCorreLationZhiLi(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
private void calculateGridZhiLi(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
//查询总记录数
int total = factIndexGovrnAblityGridMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
logger.info(String.format("customerId:%s,monthId:%s,没有上传网格相关-治理能力-五级指标数据"), formDTO.getCustomerId(), formDTO.getMonthId());
return;
}
//总页数,进行批量查询,批量计算
int totalPage = (int) Math.ceil((double) total / IndexCalConstant.PAGE_SIZE);
logger.info(String.format("共%s条数据,分%s次计算", total, totalPage));
//每一组指标的最大值,key:code_MIN/MAX
Map<String, Object> minAndMaxMap = queryGovrnAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId());
//指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = getIndexInputVO(formDTO, indexList, minAndMaxMap);
List<HashMap<String, BigDecimal>> resultMapList=new ArrayList<>();
//分页查询采集记录
for (int pageNo = 1; pageNo <= totalPage; pageNo++) {
int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE;
//前10条
List<Map<String, Object>> recordList = queryListGovrnAblityGrid(new PageQueryGridFormDTO(formDTO.getCustomerId(),
formDTO.getMonthId(),
pageIndex,
pageNo,
IndexCalConstant.PAGE_SIZE));
//遍历每一个网格的记录
recordList.forEach(recordMap -> {
//遍历所有的指标
indexMap.forEach((key, value) -> {
//列名不为空
if (StringUtils.isNotBlank(indexCodeFieldReService.getFieldNameByIndexCode(key))) {
//对应的数值
String sampleValueStr = String.valueOf(recordMap.get(indexCodeFieldReService.getFieldNameByIndexCode(key)));
//构造样本值对象
SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), new BigDecimal(sampleValueStr));
value.getIndexValueVOs().add(currentGridIndexValue);
} else if (IndexCodeEnum.ZUZHINEIDANGYDSYYSNLKPFPJZ.getCode().equals(key)) {
logger.info("组织内党员的参与议事能力考评分(平均值) 单独处理");
String gridId=(String) recordMap.get(IndexCalConstant.GRID_ID);
BigDecimal joinAvgValue = getGridJoinIssueAvgValue(formDTO,gridId);
SampleValue<BigDecimal> contactMassesAblityValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), joinAvgValue);
value.getIndexValueVOs().add(contactMassesAblityValue);
}
});
});
HashMap<String, BigDecimal> resultMap = calculate(indexMap);
resultMapList.add(resultMap);
}
// 保存中间表
saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),NumConstant.ZERO_STR);
}
/**
* @param formDTO
* @param indexList
@ -284,8 +440,51 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 计算网格相关-服务能力
* @Date 2020/8/26 16:48
**/
private void calculateGridCorreLationFuWu(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
private void calculateGridFuWu(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
//查询总记录数
int total = factIndexGovrnAblityGridMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
logger.info(String.format("customerId:%s,monthId:%s,没有上传网格相关-服务能力-五级指标数据"), formDTO.getCustomerId(), formDTO.getMonthId());
return;
}
//总页数,进行批量查询,批量计算
int totalPage = (int) Math.ceil((double) total / IndexCalConstant.PAGE_SIZE);
logger.info(String.format("共%s条数据,分%s次计算", total, totalPage));
//每一组指标的最大值,key:code_MIN/MAX
Map<String, Object> minAndMaxMap = queryServiceAblityGridMinAndMax(formDTO.getCustomerId(), formDTO.getMonthId());
//指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = getIndexInputVO(formDTO, indexList, minAndMaxMap);
List<HashMap<String, BigDecimal>> resultMapList=new ArrayList<>();
//分页查询采集记录
for (int pageNo = 1; pageNo <= totalPage; pageNo++) {
int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE;
//前10条
List<Map<String, Object>> recordList = queryListServiceAblityGrid(new PageQueryGridFormDTO(formDTO.getCustomerId(),
formDTO.getMonthId(),
pageIndex,
pageNo,
IndexCalConstant.PAGE_SIZE));
//遍历每一个网格的记录
recordList.forEach(recordMap -> {
//遍历所有的指标
indexMap.forEach((key, value) -> {
//列名不为空
if (StringUtils.isNotBlank(indexCodeFieldReService.getFieldNameByIndexCode(key))) {
//对应的数值
String sampleValueStr = String.valueOf(recordMap.get(indexCodeFieldReService.getFieldNameByIndexCode(key)));
//构造样本值对象
SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) recordMap.get(IndexCalConstant.GRID_ID), new BigDecimal(sampleValueStr));
value.getIndexValueVOs().add(currentGridIndexValue);
}else{
logger.error("index_code:"+key+" not find field_name");
}
});
});
HashMap<String, BigDecimal> resultMap = calculate(indexMap);
resultMapList.add(resultMap);
}
// 保存中间表
saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.FU_WU_NENG_LI.getCode(),NumConstant.ZERO_STR);
}
/**
@ -296,11 +495,42 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 计算网格相关总分
* @Date 2020/8/26 16:50
**/
private void calculateGridCorreLationTotal(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
private void calculateGridTotal(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList, String indexCode) {
//查询总记录数
List<GridScoreDTO> gridScoreDTOList = gridScoreDao.selectList(formDTO);
Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity()));
List<GridScoreEntity> gridScoreEntityList = new ArrayList<>();
gridScoreDTOList.forEach(gridScoreDTO -> {
GridScoreEntity gridScoreEntity = new GridScoreEntity();
gridScoreEntity.setCustomerId(gridScoreDTO.getCustomerId());
gridScoreEntity.setGridId(gridScoreDTO.getGridId());
gridScoreEntity.setIsTotal(NumConstant.ONE_STR);
gridScoreEntity.setIndexCode(indexCode);
gridScoreEntity.setAgencyId(gridScoreDTO.getAgencyId());
gridScoreEntity.setAllParentIds(gridScoreDTO.getAllParentIds());
gridScoreEntity.setQuarterId(gridScoreDTO.getQuarterId());
gridScoreEntity.setYearId(gridScoreDTO.getYearId());
gridScoreEntity.setMonthId(gridScoreDTO.getMonthId());
gridScoreEntity.setScore(BigDecimal.ZERO);
for(GridScoreDetailDTO gridScoreDetailDTO:gridScoreDTO.getDetailList()){
BigDecimal indexScore=gridScoreDetailDTO.getScore().multiply(indexMap.get(gridScoreDetailDTO.getIndexCode()).getWeight());
gridScoreEntity.setScore(gridScoreEntity.getScore().add(indexScore));
}
gridScoreEntityList.add(gridScoreEntity);
});
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, NumConstant.ONE_STR);
gridScoreDao.insertBatches(gridScoreEntityList);
}
}
public static void main(String[] args) {
BigDecimal totalScore=BigDecimal.ZERO;
for(int i=1;i<5;i++){
totalScore=totalScore.add(new BigDecimal("1.00"));
}
System.out.println(totalScore);
}
/**
* @param customerId
* @return com.epmet.dto.indexcal.CustomerGridInfoDTO

8
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/IndexGroupDetailService.java

@ -35,4 +35,12 @@ public interface IndexGroupDetailService extends BaseService<IndexGroupDetailEnt
* @param indexCode
*/
List<IndexGroupDetailEntity> getDetailListByParentCode(String customerId,String... indexCode);
/**
* desc获取所有 包含该指标code的
* @param customerId
* @param parentIndexCode
* @return
*/
List<IndexGroupDetailEntity> getDetailListLikeParentCode(String customerId, String parentIndexCode);
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexCalculateServiceImpl.java

@ -17,10 +17,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* @author liujianjun
@ -58,7 +56,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
CalculateCommonFormDTO calculateCommonFormDTO=new CalculateCommonFormDTO(customerId, formDTO.getMonthId());
//计算党员
try {
Map<String, BigDecimal> list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(customerId, formDTO.getMonthId());
//Map<String, BigDecimal> list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(customerId, formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize);
} catch (Exception e) {
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/screen/impl/IndexGroupDetailServiceImpl.java

@ -48,4 +48,9 @@ public class IndexGroupDetailServiceImpl extends BaseServiceImpl<IndexGroupDetai
}
return baseDao.getDetailListByParentCode(customerId,sb.deleteCharAt(sb.length()-1).toString());
}
@Override
public List<IndexGroupDetailEntity> getDetailListLikeParentCode(String customerId, String parentIndexCode) {
return baseDao.getDetailListLikeParentCode(customerId,parentIndexCode);
}
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/util/Pinyin4jUtil.java

@ -25,6 +25,8 @@ public class Pinyin4jUtil {
duoyinMap.put('率',new String[]{"lv"});
duoyinMap.put('员',new String[]{"yuan"});
duoyinMap.put('提',new String[]{"ti"});
duoyinMap.put('被',new String[]{"bei"});
duoyinMap.put('期',new String[]{"qi"});
}
/**
@ -192,5 +194,6 @@ public class Pinyin4jUtil {
public static void main(String[] args) {
System.out.println(getFirstSpellPinYin("区直部门",false));
System.out.println(getSpellPinYin("党员提出话题数",false,4));
System.out.println(getSpellPinYin("社区超期项目数",false,4));
}
}

11
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexcoll/FactIndexGovrnAblityGridMonthlyDao.xml

@ -138,4 +138,15 @@
and m.CUSTOMER_ID=#{customerId}
and m.MONTH_ID=#{monthId}
</select>
<select id="selectCount" resultType="java.lang.Integer" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO">
SELECT
count( 1 ) AS total
FROM
fact_index_govrn_ablity_grid_monthly m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID=#{monthId}
</select>
</mapper>

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

@ -3,33 +3,6 @@
<mapper namespace="com.epmet.dao.indexcoll.FactIndexPartyAblityCpcMonthlyDao">
<resultMap type="com.epmet.entity.indexcoll.FactIndexPartyAblityCpcMonthlyEntity" id="factIndexPartyAblityCpcMonthlyMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="parentId" column="PARENT_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="monthId" column="MONTH_ID"/>
<result property="quarterId" column="QUARTER_ID"/>
<result property="yearId" column="YEAR_ID"/>
<result property="createTopicCount" column="CREATE_TOPIC_COUNT"/>
<result property="joinTopicCount" column="JOIN_TOPIC_COUNT"/>
<result property="shiftIssueCount" column="SHIFT_ISSUE_COUNT"/>
<result property="shiftProjectCount" column="SHIFT_PROJECT_COUNT"/>
<result property="joinThreeMeetsCount" column="JOIN_THREE_MEETS_COUNT"/>
<result property="groupUserCount" column="GROUP_USER_COUNT"/>
<result property="groupTopicCount" column="GROUP_TOPIC_COUNT"/>
<result property="topicToIssueRatio" column="TOPIC_TO_ISSUE_RATIO"/>
<result property="groupActiveUserCount" column="GROUP_ACTIVE_USER_COUNT"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
<result property="userId" column="USER_ID"/>
</resultMap>
<delete id="deleteFactIndexPartyAblityCpcMonthly">
delete from fact_index_party_ablity_cpc_monthly
where CUSTOMER_ID = #{customerId} AND AGENCY_ID = #{agencyId} AND GRID_ID = #{gridId} AND USER_ID = #{userId}
@ -94,27 +67,7 @@
</foreach>
</insert>
<select id="getCountByMonthId" resultType="java.util.Map">
SELECT
CUSTOMER_ID,
AGENCY_ID,
PARENT_ID,
GRID_ID,
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>
<select id="getExtremeValue" resultType="java.util.Map">
SELECT
@ -142,4 +95,29 @@
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} AND DEL_FLAG = '0'
</select>
<select id="getCountByMonthId" resultType="java.util.Map">
SELECT
CUSTOMER_ID,
AGENCY_ID,
PARENT_ID,
GRID_ID,
USER_ID,
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}
LIMIT #{offset},#{pageSize}
</select>
</mapper>

136
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/CpcScoreDao.xml

@ -0,0 +1,136 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.indexscore.CpcScoreDao">
<resultMap type="com.epmet.entity.indexscore.CpcScoreEntity" id="cpcScoreMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="userId" column="USER_ID"/>
<result property="monthId" column="MONTH_ID"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<delete id="deleteByMonthId">
delete from fact_index_cpc_score where CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} and INDEX_CODE = #{indexCode,jdbcType=VARCHAR}
</delete>
<select id="getPartScore" resultType="com.epmet.entity.indexscore.CpcScoreEntity">
select
CUSTOMER_ID,AGENCY_ID,GRID_ID,YEAR_ID,MONTH_ID,USER_ID,SCORE,INDEX_CODE FROM fact_index_cpc_score
WHERE
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} AND IS_TOTAL = '0'
</select>
<!-- 获取网格内党员的联系群众能力考评分(平均值) -->
<select id="selectGridContactMassesAvgValue" parameterType="map" resultType="java.math.BigDecimal">
SELECT
AVG( SCORE ) AS AVG_CONTACT_MASSES_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
AND m.GRID_ID = #{gridId}
and m.INDEX_CODE='lianxiqunzhong'
GROUP BY
m.GRID_ID
</select>
<!-- 获取网格内党员的联系群众能力考评分(平均值)的最大值,最小值 -->
<select id="selectListGridContactMassesAvgValue" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultType="java.math.BigDecimal">
SELECT
AVG( SCORE ) AS AVG_CONTACT_MASSES_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
and m.INDEX_CODE='lianxiqunzhong'
GROUP BY
m.GRID_ID
</select>
<!-- 网格内党员的参与议事能力考评分(平均值) 最大值最小值 -->
<select id="selectListJoinIssueAvgValue" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultType="java.math.BigDecimal">
SELECT
AVG( SCORE ) AS AVG_JOIN_ISSUE_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
and m.INDEX_CODE='canyuyishi'
GROUP BY
m.GRID_ID
</select>
<!-- -->
<select id="selectGridJoinIssueAvgValue" parameterType="map" resultType="java.math.BigDecimal">
SELECT
AVG( SCORE ) AS AVG_CONTACT_MASSES_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
AND m.GRID_ID = #{gridId}
and m.INDEX_CODE='canyuyishi'
GROUP BY
m.GRID_ID
</select>
<insert id="insertBatch">
INSERT INTO `fact_index_cpc_score` (
`ID`,
`CUSTOMER_ID`,
`GRID_ID`,
`AGENCY_ID`,
`YEAR_ID`,
`MONTH_ID`,
`USER_ID`,
`IS_TOTAL`,
`SCORE`,
`INDEX_CODE`,
`DEL_FLAG`,
`REVISION`,
`CREATED_BY`,
`CREATED_TIME`,
`UPDATED_BY`,
`UPDATED_TIME`
)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{item.customerId},
#{item.gridId},
#{item.agencyId},
#{item.yearId},
#{item.monthId},
#{item.userId},
#{item.isTotal},
#{item.score},
#{item.indexCode},
'0',
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
</mapper>

115
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml

@ -0,0 +1,115 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.indexscore.GridScoreDao">
<resultMap type="com.epmet.entity.indexscore.GridScoreEntity" id="gridScoreMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="allParentIds" column="ALL_PARENT_IDS"/>
<result property="quarterId" column="QUARTER_ID"/>
<result property="yearId" column="YEAR_ID"/>
<result property="monthId" column="MONTH_ID"/>
<result property="isTotal" column="IS_TOTAL"/>
<result property="score" column="SCORE"/>
<result property="indexCode" column="INDEX_CODE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<delete id="deleteByCusAndMonthId" parameterType="map">
DELETE
FROM
fact_index_grid_score
WHERE
CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND INDEX_CODE = #{indexCode}
and IS_TOTAL=#{isTotal}
</delete>
<insert id="insertBatches">
INSERT INTO `fact_index_grid_score` (
`ID`,
`CUSTOMER_ID`,
`GRID_ID`,
`AGENCY_ID`,
`ALL_PARENT_IDS`,
`QUARTER_ID`,
`YEAR_ID`,
`MONTH_ID`,
`IS_TOTAL`,
`SCORE`,
`INDEX_CODE`,
`DEL_FLAG`,
`REVISION`,
`CREATED_BY`,
`CREATED_TIME`,
`UPDATED_BY`,
`UPDATED_TIME`
)
VALUES
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{item.customerId},
#{item.gridId},
#{item.agencyId},
#{item.allParentIds},
#{item.quarterId},
#{item.yearId},
#{item.monthId},
#{item.isTotal},
#{item.score},
#{item.indexCode},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
<resultMap id="GridScoreDTOMap" type="com.epmet.dto.indexcal.GridScoreDTO">
<result property="gridId" column="GRID_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="allParentIds" column="ALL_PARENT_IDS"/>
<result property="quarterId" column="QUARTER_ID"/>
<result property="yearId" column="YEAR_ID"/>
<result property="monthId" column="MONTH_ID"/>
<collection property="detailList" ofType="com.epmet.dto.indexcal.GridScoreDetailDTO" >
<result property="isTotal" column="IS_TOTAL"/>
<result property="score" column="SCORE"/>
<result property="indexCode" column="INDEX_CODE"/>
</collection>
</resultMap>
<select id="selectList" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultMap="GridScoreDTOMap">
SELECT
m.GRID_ID,
m.CUSTOMER_ID,
m.AGENCY_ID,
m.ALL_PARENT_IDS,
m.QUARTER_ID,
m.YEAR_ID,
m.MONTH_ID,
m.IS_TOTAL,
M.SCORE,
M.INDEX_CODE
FROM
fact_index_grid_score m
WHERE
m.DEL_FLAG = '0'
AND m.IS_TOTAL='0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID =#{monthId}
</select>
</mapper>

11
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/IndexGroupDetailDao.xml

@ -6,10 +6,19 @@
<select id="getDetailListByParentCode" resultType="com.epmet.entity.screen.IndexGroupDetailEntity">
select
ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD
ID,CUSTOMER_ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD, ALL_PARENT_INDEX_CODE
FROM index_group_detail
WHERE
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and STATUS = 'enable' and DEL_FLAG = '0'
and ALL_PARENT_INDEX_CODE = #{indexCode,jdbcType=VARCHAR}
</select>
<select id="getDetailListLikeParentCode" resultType="com.epmet.entity.screen.IndexGroupDetailEntity">
select
ID, CUSTOMER_ID, INDEX_GROUP_ID, INDEX_ID, INDEX_CODE, WEIGHT, THRESHOLD, ALL_PARENT_INDEX_CODE
FROM index_group_detail
WHERE
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and STATUS = 'enable' and DEL_FLAG = '0'
and ALL_PARENT_INDEX_CODE like concat(#{parentIndexCode,jdbcType=VARCHAR},'%')
</select>
</mapper>

13
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml

@ -92,4 +92,17 @@
order by m.GRID_ID asc
LIMIT #{pageIndex}, #{pageSize}
</select>
<!-- -->
<select id="selectParentAgencyId" parameterType="map" resultType="com.epmet.dto.ScreenCustomerGridDTO">
SELECT
PARENT_AGENCY_ID,
ALL_PARENT_IDS
FROM
screen_customer_grid m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.GRID_ID = #{gridId}
</select>
</mapper>

Loading…
Cancel
Save