Browse Source

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

master
yinzuomei 5 years ago
parent
commit
0b88f1e19d
  1. 17
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/constant/IndexCalConstant.java
  2. 51
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java
  3. 46
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityGovernAvgResultDTO.java
  4. 8
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/OrgGovrnAbilityFormDTO.java
  5. 2
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridAvgResultDTO.java
  6. 14
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  7. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java
  8. 45
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.java
  9. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java
  10. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java
  11. 25
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java
  12. 11
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java
  13. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/DeptScoreEntity.java
  14. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyEntity.java
  15. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/eum/IndexCodeEnum.java
  16. 12
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/GridCorreLationService.java
  17. 192
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java
  18. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java
  19. 105
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  20. 422
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  21. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCollServiceImpl.java
  22. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java
  23. 22
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml
  24. 73
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.xml
  25. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml
  26. 26
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml
  27. 69
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml
  28. 12
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml

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

@ -12,8 +12,14 @@ public interface IndexCalConstant {
String GRID_ID="GRID_ID";
String DEPT_ID="DEPT_ID";
String AGENCY_ID="AGENCY_ID";
String PARENT_AGENCY_ID = "parentAgencyId";
String PARENT_ID = "PARENT_ID";
String CUSTOMER_ID="CUSTOMER_ID";
String MONTH_ID="MONTH_ID";
@ -45,4 +51,15 @@ public interface IndexCalConstant {
String monthId="202008";
String insertUser="yinzuomei";
String INDEX_DETAIL_LIST_NULL = "指标明细查询集合为空";
String COMMUNITY_PARTY_AVG_NULL = "查询下属所有【社区】的党建能力平均值集合为空";
String GRID_PARTY_AVG_NULL = "查询下属所有【网格】的党建能力平均值集合为空";
String STREET_PUBLISH_ARTICLE_LIST_NULL = "查询【街道】名义发文数量集合为空";
String COMMUNITY_PUBLISH_ARTICLE_LIST_NULL = "查询【社区】名义发文数量集合为空";
String INDEX_CODE_NULL = "指标Code未查询出对应字段 【 %s 】";
String STREET_GOVERN_ABILITY_NULL = "查询【街道】治理能力的六个五级指标集合为空";
String COMMUNITY_GOVERN_ABILITY_NULL = "查询【社区】治理能力的六个五级指标集合为空";
String STREET_SERVICE_ABILITY_NULL = "查询街道活动组织次数集合为空";
String COMMUNITY_SERVICE_ABILITY_NULL = "查询社区活动组织次数集合为空";
}

51
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityAvgResultDTO.java

@ -0,0 +1,51 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author zxc
* @DateTime 2020/9/2 6:01 下午
*/
@Data
public class SubCommunityAvgResultDTO implements Serializable {
private static final long serialVersionUID = 7681907923515081626L;
/**
*
*/
private String customerId;
/**
* 机关ID
*/
private String agencyId;
/**
* 上级组织ID
*/
private String parentId;
/**
* 月度ID
*/
private String monthId;
/**
* 季度ID
*/
private String quarterId;
/**
* 年度ID
*/
private String yearId;
/**
* 分数
*/
private BigDecimal score;
}

46
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/SubCommunityGovernAvgResultDTO.java

@ -0,0 +1,46 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* @Author zxc
* @DateTime 2020/9/2 5:54 下午
*/
@Data
public class SubCommunityGovernAvgResultDTO implements Serializable {
private static final long serialVersionUID = 4591964909777753497L;
/**
* 机关ID
*/
private String agencyId;
/**
* 上级组织ID
*/
private String parentId;
/**
* 月度ID
*/
private String monthId;
/**
* 季度ID
*/
private String quarterId;
/**
* 年度ID
*/
private String yearId;
/**
* 分数
*/
private BigDecimal score;
}

8
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcollect/form/OrgGovrnAbilityFormDTO.java

@ -71,7 +71,13 @@ public class OrgGovrnAbilityFormDTO implements Serializable {
private BigDecimal satisfactionRatio;
/**
* 超期项目率
* 社区超期项目率dataTyp=commnuity有值
*/
private BigDecimal overdueProjectRatio;
/**
* 街道办结项目的处理效率, data_type=street时有值
*/
private BigDecimal handleProjectRatio;
}

2
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridPartyAvgResultDTO.java → epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/result/SubGridAvgResultDTO.java

@ -10,7 +10,7 @@ import java.math.BigDecimal;
* @DateTime 2020/8/28 3:15 下午
*/
@Data
public class SubGridPartyAvgResultDTO implements Serializable {
public class SubGridAvgResultDTO implements Serializable {
private static final long serialVersionUID = 1592381327492545907L;

14
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -17,8 +17,10 @@ import com.epmet.entity.evaluationindex.indexcoll.FactIndexServiceAblityGridMont
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.stats.DimAgencyEntity;
import com.epmet.service.StatsDemoService;
import com.epmet.service.evaluationindex.indexcal.DeptScoreService;
import com.epmet.service.evaluationindex.indexcal.GridCorreLationService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateStreetService;
import com.epmet.service.stats.DimAgencyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -50,6 +52,10 @@ public class DemoController {
private IndexCalculateCommunityService indexCalculateCommunityService;
@Autowired
private GridCorreLationService gridCorreLationService;
@Autowired
private IndexCalculateStreetService indexCalculateStreetService;
@Autowired
private DeptScoreService deptScoreService;
@GetMapping("testAlarm")
public void testAlarm() {
@ -159,6 +165,7 @@ public class DemoController {
// List<GridScoreDTO> gridScoreDTOList=gridScoreDao.selectList(formDTO);
// return new Result<List<GridScoreDTO>>().ok(gridScoreDTOList);
gridCorreLationService.calculateGridCorreLation(formDTO);
// deptScoreService.calculateDeptCorreLation(formDTO);
return new Result();
}
@ -442,4 +449,11 @@ public class DemoController {
entity.setUpdatedBy(IndexCalConstant.insertUser);
return entity;
}
@PostMapping("streetZxc")
public void getStreet(){
String customerId = "b09527201c4409e19d1dbc5e3c3429a1";
String monthId = "202008";
indexCalculateStreetService.calStreetAll(customerId,monthId);
}
}

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

@ -19,6 +19,7 @@ package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.entity.evaluationindex.indexcal.AgencyScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -52,5 +53,13 @@ public interface AgencyScoreDao extends BaseDao<AgencyScoreEntity> {
*/
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("dataType")String dataType);
/**
* @Description 查询街道相关信息
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/1 9:41 上午
*/
List<AgencyScoreDTO> selectStreetInfo(@Param("customerId") String customerId, @Param("monthId")String monthId,@Param("dataType")String dataType);
}

45
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.java

@ -17,12 +17,14 @@ package com.epmet.dao.evaluationindex.indexcoll; /**
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcollect.form.DeptGovrnAbilityFormDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 治理能力-部门相关数据
@ -63,4 +65,47 @@ public interface FactIndexGovrnAblityDeptMonthlyDao extends BaseDao<FactIndexGov
* @Date 10:52 2020-08-20
**/
void batchInsertFactIndexGovrnAblityDeptMonthly(@Param("list") List<DeptGovrnAbilityFormDTO> list, @Param("customerId")String customerId);
/**
* @return java.lang.Integer
* @param calculateCommonFormDTO
* @author yinzuomei
* @description 查询fact_index_govrn_ablity_dept_monthly治理能力-区直部门相关数据 当前月共上传了多少条记录
* @Date 2020/9/3 9:31
**/
Integer selectCount(CalculateCommonFormDTO calculateCommonFormDTO);
/**
* @return java.util.Map<java.lang.String,java.lang.Object>
* @param calculateCommonFormDTO
* @author yinzuomei
* @description 计算最大最小值
* @Date 2020/9/3 9:36
**/
Map<String, Object> selectExtremeValue(CalculateCommonFormDTO calculateCommonFormDTO);
/**
* @return java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
* @param customerId 客户id
* @param monthId yyyyMM
* @param offset
* @param pageSize
* @author yinzuomei
* @description
* @Date 2020/9/3 11:00
**/
List<Map<String, Object>> selectListByMonthId(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("offset") Integer offset,
@Param("pageSize") Integer pageSize);
/**
* @return com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity
* @param customerId
* @param monthId
* @author yinzuomei
* @description 只有一条数据时用
* @Date 2020/9/3 16:45
**/
FactIndexGovrnAblityDeptMonthlyEntity selectOneRecord(@Param("customerId") String customerId, @Param("monthId")String monthId);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.java

@ -64,7 +64,7 @@ public interface FactIndexGovrnAblityOrgMonthlyDao extends BaseDao<FactIndexGovr
void batchInsertFactIndexGovrnAblityOrgMonthly(@Param("list") List<OrgGovrnAbilityFormDTO> list, @Param("customerId")String customerId);
/**
* @Description 社区治理能力各个参数查询被吹哨次数办结项目数项目响应度超期项目率办结项目率办结项目满意度
* @Description 社区治理能力各个参数查询被吹哨次数办结项目数项目响应度超期项目率街道办结项目的处理效率level为street时存在办结项目率办结项目满意度
* @param customerId
* @param monthId
* @author zxc

12
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexCommunityScoreDao.java

@ -18,6 +18,9 @@
package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.SubCommunityGovernAvgResultDTO;
import com.epmet.dto.indexcal.SubCommunityPartyAvgResultDTO;
import com.epmet.dto.indexcal.SubCommunityAvgResultDTO;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.entity.evaluationindex.screen.FactIndexCommunityScoreEntity;
import org.apache.ibatis.annotations.Mapper;
@ -61,4 +64,13 @@ public interface FactIndexCommunityScoreDao extends BaseDao<FactIndexCommunitySc
*/
List<FactIndexCommunityScoreDTO> selectCommunityInfo(@Param("customerId") String customerId,@Param("monthId")String monthId);
/**
* @Description 街道下级所有社区得分平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:51 下午
*/
List<SubCommunityAvgResultDTO> selectSubCommAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
}

25
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/FactIndexGridScoreDao.java

@ -19,7 +19,7 @@ package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO;
import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO;
import com.epmet.dto.screen.result.SubGridAvgResultDTO;
import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO;
import com.epmet.entity.evaluationindex.screen.FactIndexGridScoreEntity;
import org.apache.ibatis.annotations.Mapper;
@ -37,30 +37,11 @@ import java.util.List;
public interface FactIndexGridScoreDao extends BaseDao<FactIndexGridScoreEntity> {
/**
* @Description 下属所有网格的党建能力平均值
* @Description 下属所有网格的平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/28 3:20 下午
*/
List<SubGridPartyAvgResultDTO> selectSubGridPartyAvgScore(@Param("customerId")String customerId,@Param("monthId")String monthId);
/**
* @Description 社区下属所有网格治理能力汇总平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 9:19 上午
*/
List<SubGridGovernAvgResultDTO> selectSubGridGovernAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* @Description 社区下级所有网格服务能力得分平均值
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:51 下午
*/
List<SubGridServiceAvgResultDTO> selectSubGridServiceAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
List<SubGridAvgResultDTO> selectSubGridAvgScore(@Param("customerId")String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode);
}

11
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerDeptDao.java

@ -22,6 +22,7 @@ import com.epmet.dto.screencoll.form.CustomerDeptFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
@ -56,4 +57,14 @@ public interface ScreenCustomerDeptDao extends BaseDao<ScreenCustomerDeptEntity>
* @Date 10:52 2020-08-18
**/
void batchInsertCustomerDept(@Param("list") List<CustomerDeptFormDTO> list, @Param("customerId")String customerId);
/**
* @param customerId
* @param deptId
* @return com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity
* @author yinzuomei
* @description 查询部门所属组织id
* @Date 2020/9/3 16:32
**/
ScreenCustomerDeptEntity selectParentAgencyId(@Param("customerId") String customerId, @Param("deptId") String deptId);
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/DeptScoreEntity.java

@ -48,9 +48,9 @@ public class DeptScoreEntity extends BaseEpmetEntity {
private String deptId;
/**
* 所有上级ID用英文逗号分开
* 部门所属的组织id
*/
private String allParentIds;
private String agencyId;
/**
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyEntity.java

@ -98,8 +98,12 @@ public class FactIndexGovrnAblityOrgMonthlyEntity extends BaseEpmetEntity {
private BigDecimal satisfactionRatio;
/**
* 超期项目率
* 社区超期项目率dataTyp=commnuity有值
*/
private BigDecimal overdueProjectRatio;
/**
* 街道办结项目的处理效率, data_type=street时有值
*/
private BigDecimal handleProjectRatio;
}

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

@ -28,6 +28,9 @@ public enum IndexCodeEnum {
XIA_SHU_SUO_YOU_WGDDJNLPJZ("xiashusuoyouwgddjnlpjz","下属所有网格的党建能力(平均值)",5),
SHE_QU_XIA_SHU_SYWGZLNLHZPJZ("shequxiashusywgzlnlhzpjz","社区下属所有网格治理能力汇总(平均值)",5),
SHE_QU_XIA_JI_SYWGFWNLDFPJZ("shequxiajisywgfwnldfpjz","社区下级所有网格服务能力得分(平均值) ",5),
JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ("jiedaoxiashusysqdjnlhzpjz","街道下属所有社区党建能力汇总(平均值)",5),
JIE_DAO_XIA_SHU_SYSQZLNLHZ("jiedaoxiashusysqzlnlhz","街道下属所有社区治理能力汇总 (平均值) ",5),
JIE_DAO_XIA_SHU_SQFWNLDFPYZ("jiedaoxiashusqfwnldfpjz","街道下属社区服务能力得分 (平均值) ",5),
;
private String code;

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

@ -3,7 +3,10 @@ package com.epmet.service.evaluationindex.indexcal;
import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.PageQueryGridFormDTO;
import com.epmet.support.normalizing.batch.IndexInputVO;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -41,4 +44,13 @@ public interface GridCorreLationService {
* @Date 2020/8/27 14:48
**/
List<ScreenCustomerGridDTO> pageGridList(PageQueryGridFormDTO formDTO);
/**
* @return java.util.HashMap<java.lang.String,java.math.BigDecimal>
* @param indexMap
* @author yinzuomei
* @description 通用计算方法
* @Date 2020/9/3 16:07
**/
HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap);
}

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

@ -19,21 +19,42 @@ package com.epmet.service.evaluationindex.indexcal.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerDeptDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.DeptScoreService;
import com.epmet.service.evaluationindex.indexcal.GridCorreLationService;
import com.epmet.service.evaluationindex.indexcal.IndexCodeFieldReService;
import com.epmet.service.evaluationindex.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.IndexInputVO;
import com.epmet.support.normalizing.batch.SampleValue;
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.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -49,6 +70,14 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
private IndexGroupDetailService getDetailListByParentCode;
@Autowired
private FactIndexGovrnAblityDeptMonthlyDao factIndexGovrnAblityDeptMonthlyDao;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@Autowired
private GridCorreLationService gridCorreLationService;
@Autowired
private ScreenCustomerDeptDao screenCustomerDeptDao;
@Autowired
private DeptScoreDao deptScoreDao;
/**
* @param formDTO
@ -60,15 +89,170 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
@Override
public Boolean calculateDeptCorreLation(CalculateCommonFormDTO formDTO) {
//获取指标权重
List<IndexGroupDetailEntity> parentIndexDetails = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(),
List<IndexGroupDetailEntity> indexGroupDetailEntityList = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.QU_ZHI_BU_MEN.getCode(),
IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(parentIndexDetails)) {
if (CollectionUtils.isEmpty(indexGroupDetailEntityList)) {
log.warn("calculateDeptCorreLation customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【区直部门:治理能力】指标权重信息不存在");
}
log.info(JSON.toJSONString(parentIndexDetails));
return null;
log.info(JSON.toJSONString(indexGroupDetailEntityList));
//1、查询总记录数
int total = factIndexGovrnAblityDeptMonthlyDao.selectCount(formDTO);
if (NumConstant.ZERO == total) {
log.warn(String.format("customerId=%s,monthId=%s,fact_index_govrn_ablity_dept_monthly have not any fact record", formDTO.getCustomerId(), formDTO.getMonthId()));
return Boolean.FALSE;
} else if (NumConstant.ONE == total) {
//只有一个网格时
log.warn(String.format("customerId:%s,monthId:%s,only one fact_index_govrn_ablity_dept_monthly record", formDTO.getCustomerId(), formDTO.getMonthId()));
this.handleOneGridScene(formDTO);
return Boolean.TRUE;
}
//2、计算最大最小值
Map<String, Object> minAndMaxMap = factIndexGovrnAblityDeptMonthlyDao.selectExtremeValue(formDTO);
if (CollectionUtils.isEmpty(minAndMaxMap)) {
log.warn("calculateDeptCorreLation getExtremeValue customerId:{} fact_index_govrn_ablity_dept_monthly have not any fact record", formDTO.getCustomerId());
throw new RenException("【区直部门:治理能力】指标原始数据记录不存在");
}
//3、构造入参 指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = buildDeptCorrelationIndexInputVO(indexGroupDetailEntityList, minAndMaxMap);
//4、分批计算
int pageNo = NumConstant.ONE;
int pageSize = IndexCalConstant.PAGE_SIZE;
//分页查询 要计算的原始数据
List<Map<String, Object>> list = null;
do {
list = factIndexGovrnAblityDeptMonthlyDao.selectListByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize);
if (!CollectionUtils.isEmpty(list)) {
//遍历指标分组 计算分数
List<Map<String, Object>> crrentFactRecordList = list;
calculateScore(formDTO,indexMap,crrentFactRecordList);
}
} while (!CollectionUtils.isEmpty(list) && pageNo++ > 0);
return true;
}
/**
* @return void
* @param formDTO
* @param indexMap
* @author yinzuomei
* @description 计算分值并保存结果
* @Date 2020/9/3 11:14
**/
private void calculateScore(CalculateCommonFormDTO formDTO, Map<String, IndexInputVO<BigDecimal>> indexMap,List<Map<String, Object>> recordList) {
//遍历每一个网格的记录
recordList.forEach(recordMap -> {
//遍历所有的指标
indexMap.forEach((key, indexInputVO) -> {
if (StringUtils.isNotBlank(indexCodeFieldReService.getFieldNameByIndexCode(key))) {
//对应的数值
String sampleValueStr = (String) recordMap.get(indexCodeFieldReService.getFieldNameByIndexCode(key));
//构造样本值对象
SampleValue<BigDecimal> currentGridIndexValue = new SampleValue((String) recordMap.get(IndexCalConstant.DEPT_ID), new BigDecimal(sampleValueStr));
indexInputVO.getIndexValueVOs().add(currentGridIndexValue);
}
});
});
HashMap<String, BigDecimal> resultMap = gridCorreLationService.calculate(indexMap);
//保存中间表记录
this.saveDeptScoreEntity(formDTO,resultMap);
}
/**
* @return void
* @param formDTO
* @param resultMap
* @author yinzuomei
* @description fact_index_dept_score
* @Date 2020/9/3 16:11
**/
@Transactional(rollbackFor = Exception.class)
public void saveDeptScoreEntity(CalculateCommonFormDTO formDTO, HashMap<String, BigDecimal> resultMap) {
String quarterId = DateUtils.getQuarterId(formDTO.getMonthId());
String yearId = DateUtils.getYearId(formDTO.getMonthId());
resultMap.forEach((deptId, governAblityScore) -> {
DeptScoreEntity deptScoreEntity = new DeptScoreEntity();
deptScoreEntity.setCustomerId(formDTO.getCustomerId());
deptScoreEntity.setDeptId(deptId);
deptScoreEntity.setIsTotal(NumConstant.ZERO_STR);
deptScoreEntity.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
ScreenCustomerDeptEntity deptEntity = screenCustomerDeptDao.selectParentAgencyId(formDTO.getCustomerId(), deptId);
if (null != deptEntity) {
if(StringUtils.isNotBlank(deptEntity.getParentAgencyId())){
deptScoreEntity.setAgencyId(deptEntity.getParentAgencyId());
}
}
deptScoreEntity.setQuarterId(quarterId);
deptScoreEntity.setYearId(yearId);
deptScoreEntity.setMonthId(formDTO.getMonthId());
deptScoreEntity.setScore(governAblityScore);
deptScoreDao.insert(deptScoreEntity);
});
}
/**
* @param formDTO
* @return void
* @author yinzuomei
* @description
* @Date 2020/9/3 9:35
**/
private void handleOneGridScene(CalculateCommonFormDTO formDTO) {
FactIndexGovrnAblityDeptMonthlyEntity entity = factIndexGovrnAblityDeptMonthlyDao.selectOneRecord(formDTO.getCustomerId(), formDTO.getMonthId());
HashMap<String, BigDecimal> resultMap = new HashMap<>();
resultMap.put(entity.getDeptId(), new BigDecimal(NumConstant.FIFTY_STR));
this.saveDeptScoreEntity(formDTO, resultMap);
}
/**
* @param indexList
* @param minAndMaxMap
* @return java.util.Map<java.lang.String, com.epmet.support.normalizing.batch.IndexInputVO < java.math.BigDecimal>>
* @author yinzuomei
* @description
* @Date 2020/9/3 9:31
**/
private Map<String, IndexInputVO<BigDecimal>> buildDeptCorrelationIndexInputVO(List<IndexGroupDetailEntity> indexList,
Map<String, Object> minAndMaxMap) {
Map<String, IndexInputVO<BigDecimal>> map = new HashMap<>();
for (IndexGroupDetailEntity index : indexList) {
//获取指标对应的列名
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(index.getIndexCode());
if (StringUtils.isBlank(fieldName)) {
log.error("index_code:{} not find field_name", index.getIndexCode());
continue;
}
String minValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MIN);
String maxValueKey = fieldName.concat(StrConstant.UNDER_LINE).concat(StrConstant.MAX);
BigDecimal minValue = new BigDecimal(String.valueOf(minAndMaxMap.get(minValueKey)));
BigDecimal maxValue = new BigDecimal(String.valueOf(minAndMaxMap.get(maxValueKey)));
//有阈值,且最大值>阈值,则最大值赋值为阈值
if (new BigDecimal(NumConstant.ONE_NEG_STR).compareTo(index.getThreshold()) != NumConstant.ZERO
&& maxValue.compareTo(index.getThreshold()) == NumConstant.ONE) {
maxValue = index.getThreshold();
}
//分值计算器
ScoreCalculator scoreCalculator = new BigDecimalScoreCalculator(minValue,
maxValue,
ScoreConstants.MIN_SCORE,
ScoreConstants.MAX_SCORE,
Correlation.getCorrelation(index.getCorrelation())
);
List<SampleValue<BigDecimal>> sampleValueList = new ArrayList<>();
IndexInputVO indexInputVO1 = new IndexInputVO(index.getIndexCode(),
sampleValueList,
index.getThreshold(),
// new BigDecimal("-1"), //FOR TEST
index.getWeight(),
scoreCalculator);
map.put(index.getIndexCode(), indexInputVO1);
}
return map;
}
}

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

@ -370,7 +370,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 调用计算器计算每个指标下各个网格的总分
* @Date 2020/8/30 21:40
**/
private HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
@Override
public HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
//构造入参
List<IndexInputVO> indexInputVOS = this.getIndexInputVOList(indexMap);
log.info("计算的参数"+JSON.toJSONString(indexInputVOS));

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

@ -14,9 +14,7 @@ import com.epmet.dao.evaluationindex.screen.FactIndexCommunityScoreDao;
import com.epmet.dao.evaluationindex.screen.FactIndexGridScoreDao;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
import com.epmet.dto.screen.result.SubGridGovernAvgResultDTO;
import com.epmet.dto.screen.result.SubGridPartyAvgResultDTO;
import com.epmet.dto.screen.result.SubGridServiceAvgResultDTO;
import com.epmet.dto.screen.result.SubGridAvgResultDTO;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateCommunityService;
@ -70,33 +68,35 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/8/26 10:46 上午
*/
@Transactional(rollbackFor = Exception.class)
public Boolean communityPartyCalculate(String customerId, String monthId) {
// 党建能力
// 根据all_parent_index_code 获取指标明细
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error("指标明细查询集合为空");
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String,String> pid = new HashMap<>();
//下属所有网格的党建能力平均值
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.XIA_SHU_SUO_YOU_WGDDJNLPJZ.getCode().equals(detail.getIndexCode())) {
List<SubGridPartyAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridPartyAvgScore(customerId, monthId);
List<SubGridAvgResultDTO> subGridPartyAvgScore = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) {
log.error("查询下属所有网格的党建能力平均值集合为空");
log.error(IndexCalConstant.GRID_PARTY_AVG_NULL);
return;
}else if (subGridPartyAvgScore.size() == NumConstant.ONE){
sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
pid.put(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),subGridPartyAvgScore.get(NumConstant.ZERO).getParentId());
sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (subGridPartyAvgScore.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexEnd = NumConstant.TEN;
List<List<SubGridPartyAvgResultDTO>> partition = ListUtils.partition(subGridPartyAvgScore, indexEnd);
partition.forEach(publish -> {
List<List<SubGridAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, indexEnd);
subPartyAvgList.forEach( party -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
party.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -107,26 +107,28 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
} else {
// 社区名义发文数量
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL);
if (CollectionUtils.isEmpty(mapList)) {
log.error("查询社区名义发文数量集合为空");
List<Map<String, Object>> publishArticleCountList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL);
if (CollectionUtils.isEmpty(publishArticleCountList)) {
log.error(IndexCalConstant.COMMUNITY_PUBLISH_ARTICLE_LIST_NULL);
return;
}
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error("指标Code未查询出对应字段 【" + detail.getIndexCode() + "】");
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
return;
}else if (mapList.size() == NumConstant.ONE){
sizeOne(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
}else if (publishArticleCountList.size() == NumConstant.ONE){
pid.put(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (mapList.size() > NumConstant.ONE) {
List<BigDecimal> decimalList = mapList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
}else if (publishArticleCountList.size() > NumConstant.ONE) {
List<BigDecimal> decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(mapList, 10);
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(publishArticleCountList, IndexCalConstant.PAGE_SIZE);
publishArticleList.forEach( publish -> {
ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
@ -138,7 +140,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
return true;
}
@ -150,26 +152,28 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/8/26 1:40 下午
*/
@Transactional(rollbackFor = Exception.class)
public Boolean communityGovernAbilityCalculate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error("指标明细查询集合为空");
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String,String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.SHE_QU_XIA_SHU_SYWGZLNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubGridGovernAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridGovernAvgScore(customerId, monthId);
List<SubGridAvgResultDTO> subGridGovernAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (subGridGovernAvg.size() == NumConstant.ONE) {
sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
pid.put(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),subGridGovernAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (subGridGovernAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridGovernAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, 10);
List<List<SubGridAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, IndexCalConstant.PAGE_SIZE);
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -182,24 +186,26 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
// 治理能力的六个五级指标
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL);
if (CollectionUtils.isEmpty(communityGovernAbility)){
log.error("查询治理能力的六个五级指标集合为空");
log.error(IndexCalConstant.COMMUNITY_GOVERN_ABILITY_NULL);
return;
}else if (communityGovernAbility.size() == NumConstant.ONE) {
sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
pid.put(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (communityGovernAbility.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error("指标Code未查询出对应字段 【" + detail.getIndexCode() + "】");
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
return;
}
List<BigDecimal> decimalList = communityGovernAbility.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> governAbilityList = ListUtils.partition(communityGovernAbility, 10);
List<List<Map<String, Object>>> governAbilityList = ListUtils.partition(communityGovernAbility, IndexCalConstant.PAGE_SIZE);
governAbilityList.forEach(governAbility -> {
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
governAbility.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
@ -211,7 +217,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
return true;
}
@ -223,28 +229,30 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/8/31 1:38 下午
*/
@Transactional(rollbackFor = Exception.class)
public Boolean communityServiceAbilityCalculate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error("指标明细查询集合为空");
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String,String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.SHE_QU_XIA_JI_SYWGFWNLDFPJZ.getCode().equals(indexCode)) {
List<SubGridServiceAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridServiceAvgScore(customerId, monthId);
List<SubGridAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (subGridServiceAvg.size() == NumConstant.ONE) {
sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId().toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
pid.put(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),subGridServiceAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
return;
} else if (subGridServiceAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridServiceAvgResultDTO>> serviceAvgList = ListUtils.partition(subGridServiceAvg, 10);
List<List<SubGridAvgResultDTO>> serviceAvgList = ListUtils.partition(subGridServiceAvg, IndexCalConstant.PAGE_SIZE);
serviceAvgList.forEach(serviceAvg -> {
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
serviceAvg.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
@ -255,24 +263,26 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
} else {
List<Map<String, Object>> communityActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMap(customerId, monthId,IndexCalConstant.COMMUNITY_LEVEL);
if (CollectionUtils.isEmpty(communityActivityCountList)) {
log.error("查询社区活动组织次数集合为空");
log.error(IndexCalConstant.COMMUNITY_SERVICE_ABILITY_NULL);
return;
}else if (communityActivityCountList.size() == NumConstant.ONE) {
sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
pid.put(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
return;
} else if (communityActivityCountList.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error("指标Code未查询出对应字段 【" + detail.getIndexCode() + "】");
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
return;
}
List<BigDecimal> decimalList = communityActivityCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> communityActivityList = ListUtils.partition(communityActivityCountList, 10);
List<List<Map<String, Object>>> communityActivityList = ListUtils.partition(communityActivityCountList, IndexCalConstant.PAGE_SIZE);
communityActivityList.forEach(communityActivity -> {
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
communityActivity.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
@ -284,7 +294,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode());
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
return true;
}
@ -319,6 +329,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE);
value.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
score.setParentAgencyId(community.getParentAgencyId());
});
result.add(score);
});
@ -377,6 +388,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/9/1 4:24 下午
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<FactIndexCommunityScoreDTO> subAllGridList) {
if (!CollectionUtils.isEmpty(subAllGridList)) {
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId, indexCode);
@ -394,7 +406,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<FactIndexCommunityScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode) {
public List<FactIndexCommunityScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,Map<String,String> pid) {
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO();
@ -406,6 +418,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
score.setIsTotal(isTotal);
score.setIndexCode(indexCode);
score.setScore(v);
pid.forEach((agency,parentAgency) -> {
if (k.equals(agency)){
score.setParentAgencyId(parentAgency);
}
});
result.add(score);
});
return result;
@ -419,10 +436,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/9/2 2:40 下午
*/
public void sizeOne(String agencyId,String customerId,String monthId,String indexCode){
public void sizeOne(String agencyId,String customerId,String monthId,String indexCode,Map<String,String> pid){
HashMap<String, BigDecimal> scoreCountOfSampleId = new HashMap<>();
scoreCountOfSampleId.put(agencyId,new BigDecimal(NumConstant.FIFTY));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode);
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode,pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

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

@ -1,10 +1,42 @@
package com.epmet.service.evaluationindex.indexcal.impl;
import com.alibaba.druid.util.StringUtils;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.AgencyScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.screen.FactIndexCommunityScoreDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubCommunityAvgResultDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateStreetService;
import com.epmet.service.evaluationindex.indexcal.IndexCodeFieldReService;
import com.epmet.service.evaluationindex.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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
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.*;
import java.util.stream.Collectors;
/**
* @Author zxc
@ -15,6 +47,21 @@ import org.springframework.stereotype.Service;
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetService {
@Autowired
private FactIndexPartyAblityOrgMonthlyDao factIndexPartyAblityOrgMonthlyDao;
@Autowired
private FactIndexGovrnAblityOrgMonthlyDao factIndexGovrnAblityOrgMonthlyDao;
@Autowired
private FactIndexServiceAblityOrgMonthlyDao factIndexServiceAblityOrgMonthlyDao;
@Autowired
private IndexGroupDetailService indexGroupDetailService;
@Autowired
private IndexCodeFieldReService indexCodeFieldReService;
@Autowired
private FactIndexCommunityScoreDao communityScoreDao;
@Autowired
private AgencyScoreDao agencyScoreDao;
/**
* @Description 计算街道相关总分
* @param customerId
@ -24,6 +71,379 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
*/
@Override
public Boolean calStreetAll(String customerId, String monthId) {
return null;
Boolean aBoolean = streetPartyCalculate(customerId, monthId);//党建能力
if (!aBoolean.equals(true)) {
throw new RenException("calculate street-party-ability failure ......");
}
Boolean bBoolean = streetGovernAbilityCalculate(customerId, monthId);// 治理能力
if (!bBoolean.equals(true)) {
throw new RenException("calculate street-govern-ability failure ......");
}
Boolean cBoolean = streetServiceAbilityCalculate(customerId, monthId);// 服务能力
if (!cBoolean.equals(true)) {
throw new RenException("calculate street-service-ability failure ......");
}
Boolean dBoolean = streetRelate(customerId, monthId);
if (!dBoolean.equals(true)) {
throw new RenException("calculate street-all insert failure ......");
}
return true;
}
/**
* @param customerId
* @Description 社区名义发文数量计算党建能力
* @author zxc
* @date 2020/8/26 10:46 上午
*/
public Boolean streetPartyCalculate(String customerId, String monthId) {
// 党建能力
// 根据all_parent_index_code 获取指标明细
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String,String> pid = new HashMap<>();
//下属所有社区的党建能力平均值
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQDJNLHZPJZ.getCode().equals(detail.getIndexCode())) {
List<SubCommunityAvgResultDTO> subCommPartyAvgScore = communityScoreDao.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
if (CollectionUtils.isEmpty(subCommPartyAvgScore)) {
log.error(IndexCalConstant.COMMUNITY_PARTY_AVG_NULL);
return;
}else if (subCommPartyAvgScore.size() == NumConstant.ONE){
pid.put(subCommPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),subCommPartyAvgScore.get(NumConstant.ZERO).getParentId());
sizeOne(subCommPartyAvgScore.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (subCommPartyAvgScore.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexEnd = NumConstant.TEN;
List<List<SubCommunityAvgResultDTO>> partition = ListUtils.partition(subCommPartyAvgScore, indexEnd);
partition.forEach(publish -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
} else {
// 街道名义发文数量
List<Map<String, Object>> mapList = factIndexPartyAblityOrgMonthlyDao.selectPublishArticleCountMap(customerId, monthId, IndexCalConstant.STREET_LEVEL);
if (CollectionUtils.isEmpty(mapList)) {
log.error(IndexCalConstant.STREET_PUBLISH_ARTICLE_LIST_NULL);
return;
}
String fieldName = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldName)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
return;
}else if (mapList.size() == NumConstant.ONE){
pid.put(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),mapList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
return;
}else if (mapList.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(mapList.stream().map(m -> new BigDecimal(m.get(fieldName).toString())).collect(Collectors.toList()));
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(mapList, IndexCalConstant.PAGE_SIZE);
publishArticleList.forEach(publish -> {
ScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
publish.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldName))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
return true;
}
/**
* @Description 街道治理能力
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/26 1:40 下午
*/
public Boolean streetGovernAbilityCalculate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String,String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SYSQZLNLHZ.getCode().equals(detail.getIndexCode())) {
List<SubCommunityAvgResultDTO> subGridGovernAvg = communityScoreDao.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (subGridGovernAvg.size() == NumConstant.ONE) {
pid.put(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),subGridGovernAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (subGridGovernAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubCommunityAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, IndexCalConstant.PAGE_SIZE);
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
} else {
// 治理能力的六个五级指标
List<Map<String, Object>> communityGovernAbility = factIndexGovrnAblityOrgMonthlyDao.selectCommunityGovernAbility(customerId, monthId,IndexCalConstant.STREET_LEVEL);
if (CollectionUtils.isEmpty(communityGovernAbility)){
log.error(IndexCalConstant.STREET_GOVERN_ABILITY_NULL);
return;
}else if (communityGovernAbility.size() == NumConstant.ONE) {
pid.put(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
return;
} else if (communityGovernAbility.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
System.err.println(fieldNameByIndexCode);
System.err.println(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
return;
}
List<BigDecimal> decimalList = communityGovernAbility.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> governAbilityList = ListUtils.partition(communityGovernAbility, IndexCalConstant.PAGE_SIZE);
governAbilityList.forEach(governAbility -> {
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
governAbility.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
return true;
}
/**
* @Description 街道服务能力
* @param customerId
* @param monthId
* @author zxc
* @date 2020/8/31 1:38 下午
*/
public Boolean streetServiceAbilityCalculate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (CollectionUtils.isEmpty(detailListByParentCode)) {
log.error(IndexCalConstant.INDEX_DETAIL_LIST_NULL);
return false;
}
List<IndexInputVO> indexInputVOS = new ArrayList<>();
Map<String,String> pid = new HashMap<>();
detailListByParentCode.forEach(detail -> {
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.JIE_DAO_XIA_SHU_SQFWNLDFPYZ.getCode().equals(indexCode)) {
List<SubCommunityAvgResultDTO> subCommServiceAvg = communityScoreDao.selectSubCommAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (subCommServiceAvg.size() == NumConstant.ONE) {
pid.put(subCommServiceAvg.get(NumConstant.ZERO).getAgencyId(),subCommServiceAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subCommServiceAvg.get(NumConstant.ZERO).getAgencyId(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
return;
} else if (subCommServiceAvg.size() > NumConstant.ONE) {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subCommServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubCommunityAvgResultDTO>> serviceAvgList = ListUtils.partition(subCommServiceAvg, IndexCalConstant.PAGE_SIZE);
serviceAvgList.forEach(serviceAvg -> {
BigDecimalScoreCalculator sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
serviceAvg.forEach(c -> {
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
} else {
List<Map<String, Object>> communityActivityCountList = factIndexServiceAblityOrgMonthlyDao.selectActivityCountMap(customerId, monthId,IndexCalConstant.STREET_LEVEL);
if (CollectionUtils.isEmpty(communityActivityCountList)) {
log.error(IndexCalConstant.STREET_SERVICE_ABILITY_NULL);
return;
}else if (communityActivityCountList.size() == NumConstant.ONE) {
pid.put(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(),customerId,monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid);
return;
} else if (communityActivityCountList.size() > NumConstant.ONE) {
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
return;
}
List<BigDecimal> decimalList = communityActivityCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> communityActivityList = ListUtils.partition(communityActivityCountList, IndexCalConstant.PAGE_SIZE);
communityActivityList.forEach(communityActivity -> {
ScoreCalculator<Integer> sc1 = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.POSITIVE);
List<SampleValue> index1SampleValues = new ArrayList<>();
communityActivity.forEach(c -> {
pid.put(c.get(IndexCalConstant.AGENCY_ID).toString(),c.get(IndexCalConstant.PARENT_ID).toString());
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),pid
);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
return true;
}
/**
* @Description 街道相关计算
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/3 9:21 上午
*/
public Boolean streetRelate(String customerId, String monthId) {
List<IndexGroupDetailEntity> detailListByParentCode = indexGroupDetailService.getDetailListByParentCode(customerId, IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
List<AgencyScoreDTO> agencyScoreList = agencyScoreDao.selectStreetInfo(customerId, monthId, IndexCalConstant.STREET_LEVEL);
detailListByParentCode.forEach(detail -> {
agencyScoreList.forEach(community -> {
if (detail.getIndexCode().equals(community.getIndexCode())) {
community.setScore(community.getScore().multiply(detail.getWeight()));
}
});
});
Map<String, List<AgencyScoreDTO>> collect = agencyScoreList.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId));
List<AgencyScoreDTO> result = new ArrayList<>();
collect.forEach((key, value) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
score.setIsTotal(NumConstant.ONE_STR);
score.setCustomerId(customerId);
score.setAgencyId(key);
score.setMonthId(monthId);
score.setYearId(DateUtils.getYearId(monthId));
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setIndexCode(IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode());
score.setDataType(IndexCalConstant.STREET_LEVEL);
value.forEach(street -> {
score.setScore(score.getScore().add(street.getScore()));
score.setParentAgencyId(street.getParentAgencyId());
});
result.add(score);
});
deleteAndInsert(customerId, monthId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), result);
return true;
}
/**
* @param list
* @Description BigDecimal类型获取最大数和最小数
* @author zxc
* @date 2020/8/27 1:30 下午
*/
public MaxAndMinBigDecimalResultDTO getMaxAndMinBigDecimal(List<BigDecimal> list) {
BigDecimal max = Collections.max(list);
BigDecimal min = Collections.min(list);
MaxAndMinBigDecimalResultDTO result = new MaxAndMinBigDecimalResultDTO();
result.setMax(max);
result.setMin(min);
return result;
}
/**
* @param customerId
* @param monthId
* @param indexCode
* @param subAllCommunityList
* @Description 先删除记录在插入
* @author zxc
* @date 2020/9/1 4:24 下午
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<AgencyScoreDTO> subAllCommunityList) {
if (!CollectionUtils.isEmpty(subAllCommunityList)) {
agencyScoreDao.deleteOldRecord(customerId, monthId, indexCode,IndexCalConstant.STREET_LEVEL);
agencyScoreDao.insertStreetRecord(subAllCommunityList);
}
}
/**
* @Description
* @param scoreCountOfSampleId 指标计算结果
* @param customerId 客户ID
* @param monthId 月份ID
* @param isTotal 是否 总分党建+治理+服务
* @param indexCode 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunenglixx相关xx相关
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<AgencyScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,Map<String,String> pid) {
List<AgencyScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
score.setCustomerId(customerId);
score.setAgencyId(k);
score.setMonthId(monthId);
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setYearId(DateUtils.getYearId(monthId));
score.setIsTotal(isTotal);
score.setIndexCode(indexCode);
score.setScore(v);
pid.forEach((agency,parentAgency) -> {
if (k.equals(agency)){
score.setParentAgencyId(parentAgency);
}
});
result.add(score);
});
return result;
}
/**
* @Description 当查询结果为一条时调用此方法
* @param agencyId
* @param customerId
* @param monthId
* @author zxc
* @date 2020/9/2 2:40 下午
*/
public void sizeOne(String agencyId,String customerId,String monthId,String indexCode,Map<String,String> pid){
HashMap<String, BigDecimal> scoreCountOfSample = new HashMap<>();
scoreCountOfSample.put(agencyId,new BigDecimal(NumConstant.FIFTY));
List<AgencyScoreDTO> result = getResult(scoreCountOfSample, customerId, monthId, NumConstant.ZERO_STR, indexCode,pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

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

@ -83,7 +83,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
@Autowired
private ScreenPublicPartiTotalDataDao screenPublicPartiTotalDataDao;
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertPartyUserRankData(List<PartyUserRankDataFormDTO> formDTO,String customerId) {
@ -98,7 +98,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertPartyLinkMassesData(List<PartyLinkMassesDataFormDTO> formDTO, String customerId) {
@ -113,7 +113,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertPartyBranchData(List<PartyBranchDataFormDTO> formDTO, String customerId) {
@ -131,7 +131,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertOrgRankData(List<OrgRankDataFormDTO> formDTO, String customerId) {
@ -149,7 +149,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertGovernRankData(List<GovernRankDataFormDTO> formDTO, String customerId) {
@ -167,7 +167,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertEventData(List<EventDataFormDTO> formDTO, String customerId) {
@ -195,7 +195,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertDifficultyData(List<DifficultyDataFormDTO> formDTO, String customerId) {
@ -208,7 +208,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertCpcbaseData(List<CpcBaseDataFormDTO> formDTO, String customerId) {
@ -223,7 +223,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertIndexDataMonthly(List<IndexDataMonthlyFormDTO> formDTO, String customerId) {
@ -241,7 +241,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertIndexDataYearly(List<IndexDataYearlyFormDTO> formDTO, String customerId) {
@ -258,7 +258,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertCustomerDept(List<CustomerDeptFormDTO> formDTO, String customerId) {
@ -273,7 +273,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertCustomerGrid(List<CustomerGridFormDTO> formDTO, String customerId) {
@ -288,7 +288,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertCustomerAgency(List<CustomerAgencyFormDTO> formDTO, String customerId) {
@ -303,7 +303,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertUserTotalData(List<UserTotalDataFormDTO> formDTO, String customerId) {
@ -318,7 +318,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertUserJoin(List<UserJoinFormDTO> formDTO, String customerId) {
@ -437,7 +437,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertPioneerData(List<PioneerDataFormDTO> formDTO, String customerId) {
@ -452,7 +452,7 @@ public class ScreenCollServiceImpl implements ScreenCollService {
}
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
@Transactional(rollbackFor = Exception.class)
public void insertPublicPartiTotalData(List<PublicPartiTotalDataFormDTO> formDTO, String customerId) {

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/stats/impl/DimAgencyServiceImpl.java

@ -21,11 +21,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.DimAgencyConstant;
import com.epmet.constant.RobotConstant;
@ -210,7 +210,7 @@ public class DimAgencyServiceImpl extends BaseServiceImpl<DimAgencyDao, DimAgenc
return baseDao.selectTopAgency(customerId);
}
@DataSource(value = DataSourceConstant.STATS, datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
public List<DimAgencyEntity> getAgencyListByCustomerId(String customerId) {
if (StringUtils.isBlank(customerId)){

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

@ -42,4 +42,26 @@
AND index_code = #{indexCode}
AND data_type = #{dataType}
</delete>
<!-- 查询街道相关信息 -->
<select id="selectStreetInfo" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">
SELECT
CUSTOMER_ID,
AGENCY_ID,
MONTH_ID,
QUARTER_ID,
YEAR_ID,
SCORE,
INDEX_CODE,
PARENT_AGENCY_ID
FROM
fact_index_agency_score
WHERE
del_flag = 0
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND IS_TOTAL = "0"
AND INDEX_CODE != "jiedaoxiangguan"
AND data_type = #{dataType}
</select>
</mapper>

73
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityDeptMonthlyDao.xml

@ -79,4 +79,77 @@
</foreach>
</insert>
<!-- 查询(治理能力-区直部门相关数据 )当前月共上传了多少条记录 -->
<select id="selectCount" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultType="java.lang.Integer">
SELECT
count( 1 ) AS total
FROM
fact_index_govrn_ablity_dept_monthly m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID=#{monthId}
</select>
<!-- 计算最大最小值 -->
<select id="selectExtremeValue" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultType="java.util.Map">
SELECT
m.CUSTOMER_ID,
m.DEPT_ID,
m.MONTH_ID,
MIN(m.TRANSFERED_COUNT) as TRANSFERED_COUNT_MIN,
MAX(m.TRANSFERED_COUNT) as TRANSFERED_COUNT_MAX,
MIN(m.CLOSED_PROJECT_COUNT) as CLOSED_PROJECT_COUNT_MIN,
MAX(m.CLOSED_PROJECT_COUNT) as CLOSED_PROJECT_COUNT_MAX,
MIN(m.RESP_PROJECT_RATIO) as RESP_PROJECT_RATIO_MIN_MAX,
MAX(m.RESP_PROJECT_RATIO) as RESP_PROJECT_RATIO_MAX,
MIN(m.HANDLE_PROJECT_RATIO) as HANDLE_PROJECT_RATIO_MIN,
MAX(m.HANDLE_PROJECT_RATIO) as HANDLE_PROJECT_RATIO_MAX,
MIN(M.CLOSED_PROJECT_RATIO) as CLOSED_PROJECT_RATIO_MIN,
MAX(M.CLOSED_PROJECT_RATIO) as CLOSED_PROJECT_RATIO_MAX,
MIN(M.SATISFACTION_RATIO) as SATISFACTION_RATIO_MIN,
MAX(M.SATISFACTION_RATIO) as SATISFACTION_RATIO_MAX
FROM
fact_index_govrn_ablity_dept_monthly m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID =#{monthId}
</select>
<!-- 分页查询事实记录 -->
<select id="selectListByMonthId" parameterType="map" resultType="java.util.Map">
SELECT
m.CUSTOMER_ID,
m.AGENCY_ID,
m.DEPT_ID,
m.MONTH_ID,
m.TRANSFERED_COUNT,
m.CLOSED_PROJECT_COUNT,
m.RESP_PROJECT_RATIO,
m.HANDLE_PROJECT_RATIO,
m.CLOSED_PROJECT_RATIO,
SATISFACTION_RATIO
FROM
fact_index_govrn_ablity_dept_monthly m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID =#{monthId}
ORDER BY
m.DEPT_ID ASC
LIMIT #{offset},#{pageSize}
</select>
<!-- 只有一条数据时用 -->
<select id="selectOneRecord" parameterType="map" resultType="com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity">
SELECT
m.DEPT_ID
FROM
fact_index_govrn_ablity_dept_monthly m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID =#{monthId}
</select>
</mapper>

6
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcoll/FactIndexGovrnAblityOrgMonthlyDao.xml

@ -18,6 +18,7 @@
<result property="closedProjectRatio" column="CLOSED_PROJECT_RATIO"/>
<result property="satisfactionRatio" column="SATISFACTION_RATIO"/>
<result property="overdueProjectRatio" column="OVERDUE_PROJECT_RATIO"/>
<result property="handleProjectRatio" column="HANDLE_PROJECT_RATIO"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
@ -53,6 +54,7 @@
CLOSED_PROJECT_RATIO,
SATISFACTION_RATIO,
OVERDUE_PROJECT_RATIO,
HANDLE_PROJECT_RATIO,
DEL_FLAG,
REVISION,
CREATED_BY,
@ -76,6 +78,7 @@
#{item.closedProjectRatio},
#{item.satisfactionRatio},
#{item.overdueProjectRatio},
#{item.handleProjectRatio},
0,
0,
'APP_USER',
@ -99,7 +102,8 @@
RESP_PROJECT_RATIO,
OVERDUE_PROJECT_RATIO,
CLOSED_PROJECT_RATIO,
SATISFACTION_RATIO
SATISFACTION_RATIO,
HANDLE_PROJECT_RATIO
FROM
fact_index_govrn_ablity_org_monthly
WHERE

26
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexCommunityScoreDao.xml

@ -50,14 +50,38 @@
QUARTER_ID,
YEAR_ID,
SCORE,
INDEX_CODE
INDEX_CODE,
PARENT_AGENCY_ID
FROM
fact_index_community_score
WHERE
del_flag = 0
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND IS_TOTAL = "0"
AND INDEX_CODE != "shequxiangguan"
</select>
<!-- 街道下级所有社区服务能力得分平均值 -->
<select id="selectSubCommAvgScore" resultType="com.epmet.dto.indexcal.SubCommunityAvgResultDTO">
SELECT
fics.agency_id,
fics.month_id,
fics.quarter_id,
fics.year_id,
AVG( fics.score ) AS score,
fics.customer_id,
sca.pid AS parentId
FROM
fact_index_community_score fics
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fics.AGENCY_ID
WHERE
fics.del_flag = '0'
AND sca.DEL_FLAG = 0
AND fics.customer_id = #{customerId}
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
GROUP BY fics.agency_id
</select>
</mapper>

69
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/FactIndexGridScoreDao.xml

@ -3,60 +3,25 @@
<mapper namespace="com.epmet.dao.evaluationindex.screen.FactIndexGridScoreDao">
<!-- 下属所有网格的党建能力平均值 -->
<select id="selectSubGridPartyAvgScore" resultType="com.epmet.dto.screen.result.SubGridPartyAvgResultDTO">
<!-- 下属所有网格的平均值 -->
<select id="selectSubGridAvgScore" resultType="com.epmet.dto.screen.result.SubGridAvgResultDTO">
SELECT
agency_id,
month_id,
quarter_id,
year_id,
AVG( score ) AS score,
customer_id
figc.agency_id AS agencyId,
figc.month_id as monthId,
figc.quarter_id as quarterId,
figc.year_id as yearId,
AVG( figc.score ) AS score,
figc.customer_id as customerId,
sca.pid AS parentId
FROM
fact_index_grid_score
fact_index_grid_score figc
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = figc.AGENCY_ID
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = 'dangjiannengli'
GROUP BY agency_id
</select>
<!-- 社区下属所有网格治理能力汇总平均值 -->
<select id="selectSubGridGovernAvgScore" resultType="com.epmet.dto.screen.result.SubGridGovernAvgResultDTO">
SELECT
agency_id,
month_id,
quarter_id,
year_id,
AVG( score ) AS score,
customer_id
FROM
fact_index_grid_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = 'zhilinengli'
GROUP BY agency_id
</select>
<!-- 社区下级所有网格服务能力得分平均值 -->
<select id="selectSubGridServiceAvgScore" resultType="com.epmet.dto.screen.result.SubGridServiceAvgResultDTO">
SELECT
agency_id,
month_id,
quarter_id,
year_id,
AVG( score ) AS score,
customer_id
FROM
fact_index_grid_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = 'fuwunengli'
GROUP BY agency_id
figc.del_flag = '0'
AND sca.DEL_FLAG = 0
AND figc.customer_id = #{customerId}
AND figc.month_id = #{monthId}
AND figc.index_code = #{indexCode}
GROUP BY figc.agency_id
</select>
</mapper>

12
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerDeptDao.xml

@ -52,4 +52,16 @@
</foreach>
</insert>
<!-- 查询部门所属组织id -->
<select id="selectParentAgencyId" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity">
SELECT
m.PARENT_AGENCY_ID
FROM
screen_customer_dept m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.DEPT_ID =#{deptId}
</select>
</mapper>

Loading…
Cancel
Save