Browse Source

区直部门总分计算

dev_shibei_match
yinzuomei 5 years ago
parent
commit
ee4a6ecb0c
  1. 47
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/DeotScore.java
  2. 32
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/DeptScoreDetailDTO.java
  3. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  4. 13
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java
  5. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptSubScoreDao.java
  6. 6
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java
  7. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java
  8. 87
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java
  9. 15
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java
  10. 1
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  11. 39
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml
  12. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml
  13. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml
  14. 6
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml

47
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/DeotScore.java

@ -0,0 +1,47 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 区直部门-相关分值
*
* @author yinzuomei@elink-cn.com
* @date 2020/9/10 18:13
*/
@Data
public class DeotScore implements Serializable {
/**
* 部门id
*/
private String deptId;
/**
* 客户Id
*/
private String customerId;
/**
* 部门所属的机关Id
*/
private String agencyId;
/**
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
private List<DeptScoreDetailDTO> detailList;
}

32
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/DeptScoreDetailDTO.java

@ -0,0 +1,32 @@
package com.epmet.dto.indexcal;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 区直部门相关分值
*
* @author yinzuomei@elink-cn.com
* @date 2020/9/10 17:56
*/
@Data
public class DeptScoreDetailDTO implements Serializable {
private static final long serialVersionUID = -1520962964833708922L;
/**
* 1总分0不是
*/
private String isTotal;
/**
* 分值
*/
private BigDecimal score;
/**
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli网格相关quzhibumen
*/
private String indexCode;
}

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

@ -157,6 +157,8 @@ public class DemoController {
private FactIndexServiceAblityGridMonthlyDao factIndexServiceAblityGridMonthlyDao;
@Autowired
private ScreenCustomerGridDao screenCustomerGridDao;
@Autowired
private CpcIndexCalculateService cpcIndexCalculateService;
// private static Integer testcal=100;
@PostMapping("testcal")
@ -165,7 +167,9 @@ public class DemoController {
// //查询总记录数
// List<GridScoreDTO> gridScoreDTOList=gridScoreDao.selectList(formDTO);
// return new Result<List<GridScoreDTO>>().ok(gridScoreDTOList);
// gridCorreLationService.calculateGridCorreLation(formDTO);
cpcIndexCalculateService.cpcIndexCalculate(formDTO);
gridCorreLationService.calculateGridCorreLation(formDTO);
deptScoreService.calculateDeptCorreLation(formDTO);
return new Result();
}

13
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java

@ -18,6 +18,8 @@
package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.DeotScore;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.dto.indexcal.DeptScoreDTO;
import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity;
@ -79,7 +81,7 @@ public interface DeptScoreDao extends BaseDao<DeptScoreEntity> {
int deleteByDeptIdAndMonthId(@Param("customerId") String customerId,
@Param("monthId")String monthId,
@Param("indexCode") String indexCode,
@Param("deleteSize") int deleteSize);
@Param("deleteSize") Integer deleteSize);
/**
* @return int
@ -89,4 +91,13 @@ public interface DeptScoreDao extends BaseDao<DeptScoreEntity> {
* @Date 2020/9/10 10:40
**/
int insertBatchEntity(@Param("list") List<DeptScoreEntity> deptScoreEntityList);
/**
* @return java.util.List<com.epmet.dto.indexcal.DeptScoreDTO>
* @param formDTO
* @author yinzuomei
* @description 查询每个部门下所有的指标对应的分值
* @Date 2020/9/10 18:07
**/
List<DeotScore> selectList(CalculateCommonFormDTO formDTO);
}

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptSubScoreDao.java

@ -53,8 +53,8 @@ public interface DeptSubScoreDao extends BaseDao<DeptSubScoreEntity> {
* @description 批量删除
* @Date 2020/9/10 12:28
**/
int deleteByDeptIdAndMonthId(@Param("customerId") String customerId,
int deleteBatches(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("allParentIndexCode") String allParentIndexCode,
@Param("deleteSize") int deleteSize);
@Param("deleteSize") Integer deleteSize);
}

6
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java

@ -40,16 +40,16 @@ public interface GridScoreDao extends BaseDao<GridScoreEntity> {
* @param customerId
* @param monthId
* @param indexCode
* @param deleteNum
* @param deleteSize
* @return int
* @author yinzuomei
* @description
* @Date 2020/8/31 14:00
**/
int deleteByCusAndMonthId(@Param("customerId") String customerId,
int deleteBatches(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("indexCode") String indexCode,
@Param("deleteNum") int deleteNum);
@Param("deleteSize") Integer deleteSize);
/**
* @return int

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

@ -51,7 +51,7 @@ public interface GridSubScoreDao extends BaseDao<GridSubScoreEntity> {
* @description 批量删除
* @Date 2020/9/10 13:36
**/
int deleteByDeptIdAndMonthId(@Param("customerId") String customerId,
int deleteBatches(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("allParentIndexCode") String allParentIndexCode,
@Param("deleteSize") Integer deleteSize);

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

@ -31,9 +31,10 @@ import com.epmet.dao.evaluationindex.indexcal.DeptScoreDao;
import com.epmet.dao.evaluationindex.indexcal.DeptSubScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerDeptDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.*;
import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.DeptSubScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.GridScoreEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
@ -63,6 +64,8 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
@ -94,26 +97,38 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
* @param formDTO
* @return java.lang.Boolean
* @author yinzuomei
* @description 区直部门分值计算
* @description 区直部门相关-分值计算
* @Date 2020/8/26 10:51
**/
@Override
public Boolean calculateDeptCorreLation(CalculateCommonFormDTO formDTO) {
//获取指标权重
calculateZhiLiNengLiScore(formDTO);
calculateDeptTotalScore(formDTO);
return true;
}
/**
* @return void
* @param formDTO
* @author yinzuomei
* @description 区直部门-党建能力分值计算
* @Date 2020/9/10 17:21
**/
private void calculateZhiLiNengLiScore(CalculateCommonFormDTO formDTO) {
//获取区直部门的治理能力下,五级指标权重
List<IndexGroupDetailEntity> indexGroupDetailEntityList = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.QU_ZHI_BU_MEN.getCode(),
IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(indexGroupDetailEntityList)) {
log.warn("calculateDeptCorreLation customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【区直部门:治理能力】指标权重信息不存在");
throw new RenException("客户【区直部门:治理能力】下级指标权重信息不存在");
}
log.info(JSON.toJSONString(indexGroupDetailEntityList));
// 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;
return;
}
//2、计算最大最小值
Map<String, Object> minAndMaxMap = factIndexGovrnAblityDeptMonthlyDao.selectExtremeValue(formDTO);
@ -139,7 +154,61 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
calculateScore(formDTO,indexMap,crrentFactRecordList);
}
} while (!CollectionUtils.isEmpty(list) && pageNo++ > 0);
return true;
log.info("区直部门-治理能力- 计算完成");
}
/**
* @return void
* @param formDTO
* @author yinzuomei
* @description 区直部门总分
* @Date 2020/9/10 17:20
**/
private void calculateDeptTotalScore(CalculateCommonFormDTO formDTO) {
//计算区直部门总分
List<IndexGroupDetailEntity> indexList = getDetailListByParentCode.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.QU_ZHI_BU_MEN.getCode());
if (CollectionUtils.isEmpty(indexList)) {
log.warn("calculateDeptTotalScore customerId:{} have not any indexGroupDetail", formDTO.getCustomerId());
throw new RenException("客户【区直部门】下级指标权重信息不存在");
}
//查询总记录数
List<DeotScore> deptScoreDTOList = deptScoreDao.selectList(formDTO);
if(CollectionUtils.isEmpty(deptScoreDTOList)){
log.error("calculateDeptTotalScore deptScoreDao.selectList return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId());
throw new RenException("客户一级指标分值记录不存在");
}
Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity()));
List<DeptScoreEntity> deotScoreEntityList = new ArrayList<>();
for (DeotScore deptScore : deptScoreDTOList) {
DeptScoreEntity deptScoreEntity = ConvertUtils.sourceToTarget(deptScore, DeptScoreEntity.class);
deptScoreEntity.setIsTotal(NumConstant.ONE_STR);
deptScoreEntity.setIndexCode(IndexCodeEnum.QU_ZHI_BU_MEN.getCode());
deptScoreEntity.setScore(BigDecimal.ZERO);
deptScoreEntity.setAllParentIndexCode(NumConstant.ZERO_STR);
for (DeptScoreDetailDTO deptScoreDetailDTO : deptScore.getDetailList()) {
BigDecimal indexScore = deptScoreDetailDTO.getScore().multiply(indexMap.get(deptScoreDetailDTO.getIndexCode()).getWeight());
deptScoreEntity.setScore(deptScoreEntity.getScore().add(indexScore));
}
deotScoreEntityList.add(deptScoreEntity);
}
//先删除
int effectRow;
do {
effectRow = deptScoreDao.deleteByDeptIdAndMonthId(formDTO.getCustomerId(),
formDTO.getMonthId(),
IndexCodeEnum.QU_ZHI_BU_MEN.getCode(),
IndexCalConstant.DELETE_SIZE);
} while (effectRow > NumConstant.ZERO);
//后新增
if (!CollectionUtils.isEmpty(deotScoreEntityList)) {
//批量插入
List<List<DeptScoreEntity>> partition = ListUtils.partition(deotScoreEntityList, IndexCalConstant.INSERT_SIZE);
partition.forEach(list -> {
deptScoreDao.insertBatchEntity(list);
});
}
}
/**
@ -165,7 +234,7 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
//删除明细时,需要根据分组删,比方说当前计算的是区直部门治理能力,主表需要删除indexCode=zhilinengli的,明细需要删除区直部门:治理能力下面所有的指标明细
int detailDelteNum;
do {
detailDelteNum = deptSubScoreDao.deleteByDeptIdAndMonthId(formDTO.getCustomerId(),
detailDelteNum = deptSubScoreDao.deleteBatches(formDTO.getCustomerId(),
formDTO.getMonthId(),
allParentIndexCode,
IndexCalConstant.DELETE_SIZE);

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

@ -18,7 +18,6 @@ import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthly
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.indexcal.*;
import com.epmet.entity.evaluationindex.indexcal.DeptSubScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.GridScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.GridSubScoreEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
@ -340,7 +339,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
int masterDeleteNum;
do {
//一次删除50条
masterDeleteNum = gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(),
masterDeleteNum = gridScoreDao.deleteBatches(formDTO.getCustomerId(),
formDTO.getMonthId(),
indexCode,
IndexCalConstant.DELETE_SIZE);
@ -348,7 +347,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
//删除明细时,需要根据分组删,比方说当前计算的是网格相关-党建能力,主表需要删除indexCode=dangjiannengli的,明细需要删除网格相关:党建能力 下面所有的指标明细
int detailDelteNum;
do {
detailDelteNum = gridSubScoreDao.deleteByDeptIdAndMonthId(formDTO.getCustomerId(),
detailDelteNum = gridSubScoreDao.deleteBatches(formDTO.getCustomerId(),
formDTO.getMonthId(),
allParentIndexCode,
IndexCalConstant.DELETE_SIZE);
@ -706,8 +705,16 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
}
gridScoreEntityList.add(gridScoreEntity);
}
//先删除
int effectRow;
do {
effectRow =gridScoreDao.deleteBatches(formDTO.getCustomerId(),
formDTO.getMonthId(),
indexCode,
IndexCalConstant.DELETE_SIZE);
} while (effectRow > NumConstant.ZERO);
//批量插入
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, IndexCalConstant.DELETE_SIZE);
//批量插入
List<List<GridScoreEntity>> partition = ListUtils.partition(gridScoreEntityList, IndexCalConstant.INSERT_SIZE);
partition.forEach(list -> {

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

@ -210,7 +210,6 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
List<SubAgencyScoreAvgResultDTO> deptScoreAvgList = deptScoreDao.selectGovernDeptScoreAvg(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
if (CollectionUtils.isEmpty(deptScoreAvgList)) {
log.error("查询所有直属部门治理能力平均值集合为空");
return;
} else{
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(deptScoreAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> governAvg = ListUtils.partition(deptScoreAvgList, IndexCalConstant.PAGE_SIZE);

39
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml

@ -63,7 +63,9 @@
<if test="indexCode != null and indexCode !=''">
and INDEX_CODE=#{indexCode}
</if>
limit #{deleteSize}
<if test="deleteSize != null">
limit #{deleteSize}
</if>
</delete>
<!-- 批量插入计算结果 -->
@ -110,4 +112,39 @@
)
</foreach>
</insert>
<resultMap id="DeptScoreDTOMap" type="com.epmet.dto.indexcal.DeotScore">
<result property="deptId" column="DEPT_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<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.DeptScoreDetailDTO" >
<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="DeptScoreDTOMap">
SELECT
m.DEPT_ID,
m.CUSTOMER_ID,
m.AGENCY_ID,
m.QUARTER_ID,
m.YEAR_ID,
m.MONTH_ID,
m.IS_TOTAL,
M.SCORE,
M.INDEX_CODE
FROM
fact_index_dept_score m
WHERE
m.DEL_FLAG = '0'
AND m.IS_TOTAL='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/indexcal/DeptSubScoreDao.xml

@ -46,11 +46,13 @@
</insert>
<!-- 批量删除 -->
<delete id="deleteByDeptIdAndMonthId" parameterType="map">
<delete id="deleteBatches" parameterType="map">
delete from fact_index_dept_sub_score
where CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
and ALL_PARENT_INDEX_CODE=#{allParentIndexCode}
limit #{deleteSize}
<if test="deleteSize != null">
limit #{deleteSize}
</if>
</delete>
</mapper>

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

@ -24,7 +24,7 @@
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<delete id="deleteByCusAndMonthId" parameterType="map">
<delete id="deleteBatches" parameterType="map">
DELETE
FROM
fact_index_grid_score
@ -32,7 +32,9 @@
CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND INDEX_CODE = #{indexCode}
limit #{deleteNum}
<if test="deleteSize != null">
limit #{deleteSize}
</if>
</delete>
<!-- 批量插入计算结果 -->

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

@ -49,7 +49,7 @@
</insert>
<!-- 批量删除 -->
<delete id="deleteByDeptIdAndMonthId">
<delete id="deleteBatches">
DELETE
FROM
fact_index_grid_sub_score
@ -57,6 +57,8 @@
CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND ALL_PARENT_INDEX_CODE = #{allParentIndexCode}
limit #{deleteSize}
<if test="deleteSize != null">
limit #{deleteSize}
</if>
</delete>
</mapper>
Loading…
Cancel
Save