Browse Source

网格相关修改:插入五级指标明细

dev
yinzuomei 5 years ago
parent
commit
b96eaef26b
  1. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptScoreDao.java
  2. 66
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptSubScoreDao.java
  3. 16
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridScoreDao.java
  4. 84
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java
  5. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/AgencySubScoreEntity.java
  6. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/CpcSubScoreEntity.java
  7. 7
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/DeptSubScoreEntity.java
  8. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/GridSubScoreEntity.java
  9. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/GridCorreLationService.java
  10. 98
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/DeptScoreServiceImpl.java
  11. 119
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/GridCorreLationServiceImpl.java
  12. 50
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptScoreDao.xml
  13. 71
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml
  14. 50
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridScoreDao.xml
  15. 151
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml

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

@ -45,17 +45,6 @@ public interface DeptScoreDao extends BaseDao<DeptScoreEntity> {
**/
List<DeptScoreDTO> selectListDeptScore(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* 批量插入 区直部门分值表
*
* @param list
* @param customerId
* @return void
* @Author zhangyong
* @Date 11:11 2020-09-04
**/
void batchInsertDeptScoreData(@Param("list") List<DeptScoreEntity> list, @Param("customerId")String customerId);
/**
* 根据入参查询 区直部门分值表id
* @param customerId
@ -79,12 +68,25 @@ public interface DeptScoreDao extends BaseDao<DeptScoreEntity> {
/**
* @return int
* @param customerId
* @param monthId
* @param deptId
* @param customerId 客户id
* @param monthId 月id
* @param indexCode 不必填
* @param deleteSize
* @author yinzuomei
* @description
* @description 根据客户id+monthId,删除这个月某个指标所有的数据 一次至多删除50条
* @Date 2020/9/7 14:30
**/
int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, @Param("monthId")String monthId,@Param("deptId") String deptId);
int deleteByDeptIdAndMonthId(@Param("customerId") String customerId,
@Param("monthId")String monthId,
@Param("indexCode") String indexCode,
@Param("deleteSize") int deleteSize);
/**
* @return int
* @param deptScoreEntityList
* @author yinzuomei
* @description 批量插入计算结果
* @Date 2020/9/10 10:40
**/
int insertBatchEntity(@Param("list") List<DeptScoreEntity> deptScoreEntityList);
}

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

@ -18,12 +18,11 @@
package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.DeptScoreDTO;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.entity.evaluationindex.indexcal.DeptScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.DeptSubScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import javax.annotation.security.PermitAll;
import java.util.List;
/**
@ -33,60 +32,29 @@ import java.util.List;
* @since v1.0.0 2020-09-02
*/
@Mapper
public interface DeptSubScoreDao extends BaseDao<DeptScoreEntity> {
public interface DeptSubScoreDao extends BaseDao<DeptSubScoreEntity> {
/**
* 根据入参查询 区直部门分值表 记录
*
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.indexcal.DeptScoreDTO>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<DeptScoreDTO> selectListDeptScore(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* 批量插入 区直部门分值表
*
* @param list
* @param customerId
* @return void
* @Author zhangyong
* @Date 11:11 2020-09-04
**/
void batchInsertDeptScoreData(@Param("list") List<DeptScoreEntity> list, @Param("customerId") String customerId);
/**
* 根据入参查询 区直部门分值表id
*
* @param customerId
* @param monthId
* @return java.lang.String
* @Author zhangyong
* @Date 10:43 2020-09-03
* @param insertDeptSubList
* @return int
* @author yinzuomei
* @description 批量插入计算结果 五级指标分数值
* @Date 2020/9/10 10:39
**/
List<String> selectListDeptId(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* @param customerId
* @param monthId
* @param indexCode
* @Description 所有直属部门治理能力平均值
* @author zxc
* @date 2020/9/4 10:53 上午
*/
List<SubAgencyScoreAvgResultDTO> selectGovernDeptScoreAvg(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode);
int insertBatchEntity(@Param("list") List<DeptSubScoreEntity> insertDeptSubList);
/**
* @param customerId
* @param monthId
* @param deptId
* @param allParentIndexCode
* @param deleteSize 一次至多删除XX条记录
* @return int
* @author yinzuomei
* @description
* @Date 2020/9/7 14:30
* @description 批量删除
* @Date 2020/9/10 12:28
**/
int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("deptId") String deptId);
int deleteByDeptIdAndMonthId(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("allParentIndexCode") String allParentIndexCode,
@Param("deleteSize") int deleteSize);
}

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

@ -40,7 +40,7 @@ public interface GridScoreDao extends BaseDao<GridScoreEntity> {
* @param customerId
* @param monthId
* @param indexCode
* @param isTotal 1总分0不是
* @param deleteNum
* @return int
* @author yinzuomei
* @description
@ -49,7 +49,7 @@ public interface GridScoreDao extends BaseDao<GridScoreEntity> {
int deleteByCusAndMonthId(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("indexCode") String indexCode,
@Param("isTotal") String isTotal);
@Param("deleteNum") int deleteNum);
/**
* @return int
@ -58,7 +58,7 @@ public interface GridScoreDao extends BaseDao<GridScoreEntity> {
* @description
* @Date 2020/8/31 14:01
**/
int insertBatches(List<GridScoreEntity> gridScoreEntityList);
int insertBatches(@Param("list")List<GridScoreEntity> gridScoreEntityList);
/**
* @return java.util.List<com.epmet.dto.indexcal.GridScoreDTO>
@ -98,15 +98,5 @@ public interface GridScoreDao extends BaseDao<GridScoreEntity> {
**/
List<String> selectListGridId(@Param("customerId")String customerId, @Param("monthId")String monthId);
/**
* 批量插入 网格相关分值表
*
* @param list
* @param customerId
* @return void
* @Author zhangyong
* @Date 11:11 2020-09-04
**/
void batchInsertGridScoreData(@Param("list") List<FactIndexGridScoreDTO> list,@Param("customerId")String customerId);
}

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

@ -18,11 +18,7 @@
package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.GridScoreDTO;
import com.epmet.dto.screen.FactIndexGridScoreDTO;
import com.epmet.dto.screen.result.SubGridAvgResultDTO;
import com.epmet.entity.evaluationindex.indexcal.GridScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.GridSubScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -35,80 +31,28 @@ import java.util.List;
* @since v1.0.0 2020-08-31
*/
@Mapper
public interface GridSubScoreDao extends BaseDao<GridScoreEntity> {
public interface GridSubScoreDao extends BaseDao<GridSubScoreEntity> {
/**
* @param customerId
* @param monthId
* @param indexCode
* @param isTotal 1总分0不是
* @return int
* @author yinzuomei
* @description
* @Date 2020/8/31 14:00
**/
int deleteByCusAndMonthId(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("indexCode") String indexCode,
@Param("isTotal") String isTotal);
/**
* @param gridScoreEntityList
* @param gridSubScoreEntityList
* @return int
* @author yinzuomei
* @description
* @Date 2020/8/31 14:01
**/
int insertBatches(List<GridScoreEntity> gridScoreEntityList);
/**
* @param formDTO
* @return java.util.List<com.epmet.dto.indexcal.GridScoreDTO>
* @author yinzuomei
* @description
* @Date 2020/8/31 16:42
**/
List<GridScoreDTO> selectList(CalculateCommonFormDTO formDTO);
int insertBatches(@Param("list") List<GridSubScoreEntity> gridSubScoreEntityList);
/**
* @param customerId
* @param monthId
* @Description 下属所有网格的平均值
* @author zxc
* @date 2020/8/28 3:20 下午
*/
List<SubGridAvgResultDTO> selectSubGridAvgScore(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode);
/**
* 根据入参查询 网格相关分值记录
*
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.screen.FactIndexGridScoreDTO>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<FactIndexGridScoreDTO> selectListGridScore(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* 根据入参查询 网格id
*
* @param customerId
* @param monthId
* @return java.util.List<java.util.String>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<String> selectListGridId(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* 批量插入 网格相关分值表
*
* @param list
* @param customerId
* @return void
* @Author zhangyong
* @Date 11:11 2020-09-04
* @param allParentIndexCode
* @param deleteSize 一次至多删除XX条记录
* @return int
* @author yinzuomei
* @description 批量删除
* @Date 2020/9/10 13:36
**/
void batchInsertGridScoreData(@Param("list") List<FactIndexGridScoreDTO> list, @Param("customerId") String customerId);
int deleteByDeptIdAndMonthId(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("allParentIndexCode") String allParentIndexCode,
@Param("deleteSize") Integer deleteSize);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/AgencySubScoreEntity.java

@ -32,7 +32,7 @@ import java.math.BigDecimal;
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("fact_index_sub_agency_score")
@TableName("fact_index_agency_sub_score")
public class AgencySubScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/CpcSubScoreEntity.java

@ -32,7 +32,7 @@ import java.math.BigDecimal;
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("fact_index_sub_cpc_score")
@TableName("fact_index_cpc_sub_score")
public class CpcSubScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;

7
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/DeptSubScoreEntity.java

@ -32,7 +32,7 @@ import java.math.BigDecimal;
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("fact_index_sub_dept_score")
@TableName("fact_index_dept_sub_score")
public class DeptSubScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
@ -67,11 +67,6 @@ public class DeptSubScoreEntity extends BaseEpmetEntity {
*/
private String monthId;
/**
* 1总分0不是默认0
*/
private String isTotal;
/**
* 分值
*/

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/GridSubScoreEntity.java

@ -32,7 +32,7 @@ import java.math.BigDecimal;
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("fact_index_sub_grid_score")
@TableName("fact_index_grid_sub_score")
public class GridSubScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;

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

@ -3,6 +3,7 @@ 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.CalculateResult;
import com.epmet.support.normalizing.batch.IndexInputVO;
import java.math.BigDecimal;
@ -52,5 +53,5 @@ public interface GridCorreLationService {
* @description 通用计算方法
* @Date 2020/9/3 16:07
**/
HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap);
HashMap<String, CalculateResult> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap);
}

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

@ -23,14 +23,17 @@ 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.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
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.entity.evaluationindex.indexcal.DeptScoreEntity;
import com.epmet.entity.evaluationindex.indexcal.DeptSubScoreEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityDeptMonthlyEntity;
import com.epmet.entity.evaluationindex.screen.IndexGroupDetailEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
@ -43,9 +46,12 @@ 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.CalculateResult;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.IndexScoreVo;
import com.epmet.support.normalizing.batch.SampleValue;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -81,6 +87,8 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
private ScreenCustomerDeptDao screenCustomerDeptDao;
@Autowired
private DeptScoreDao deptScoreDao;
@Autowired
private DeptSubScoreDao deptSubScoreDao;
/**
* @param formDTO
@ -107,14 +115,6 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
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)) {
@ -123,7 +123,10 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
}
//3、构造入参 指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = buildDeptCorrelationIndexInputVO(indexGroupDetailEntityList, minAndMaxMap);
//4、分批计算
//4、先全部删除,后批量插入
//quzhibumen:zhilinengli
deleteBeforeDataList(formDTO,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.DEPT_ZL_ALL_PARENT_INDEX_CODE);
//5、分批计算
int pageNo = NumConstant.ONE;
int pageSize = IndexCalConstant.PAGE_SIZE;
//分页查询 要计算的原始数据
@ -139,6 +142,38 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
return true;
}
/**
* @param formDTO
* @param indexCode zhilinengli
* @param allParentIndexCode quzhibumen:zhilinengli
* @return void
* @author yinzuomei
* @description
* @Date 2020/9/10 12:15
**/
@Transactional(rollbackFor = Exception.class)
void deleteBeforeDataList(CalculateCommonFormDTO formDTO, String indexCode, String allParentIndexCode) {
int masterDeleteNum;
do {
//一次删除50条
masterDeleteNum = deptScoreDao.deleteByDeptIdAndMonthId(formDTO.getCustomerId(),
formDTO.getMonthId(),
indexCode,
IndexCalConstant.DELETE_SIZE);
} while (masterDeleteNum != NumConstant.ZERO);
//删除明细时,需要根据分组删,比方说当前计算的是区直部门治理能力,主表需要删除indexCode=zhilinengli的,明细需要删除区直部门:治理能力下面所有的指标明细
int detailDelteNum;
do {
detailDelteNum = deptSubScoreDao.deleteByDeptIdAndMonthId(formDTO.getCustomerId(),
formDTO.getMonthId(),
allParentIndexCode,
IndexCalConstant.DELETE_SIZE);
} while (detailDelteNum != NumConstant.ZERO);
log.info("delete fact_index_dept_score and fact_index_dept_sub_score complete");
}
/**
* @return void
* @param formDTO
@ -163,7 +198,7 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
});
});
HashMap<String, BigDecimal> resultMap = gridCorreLationService.calculate(indexMap);
HashMap<String, CalculateResult> resultMap = gridCorreLationService.calculate(indexMap);
//保存中间表记录
this.saveDeptScoreEntity(formDTO,resultMap);
}
@ -177,10 +212,12 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
* @Date 2020/9/3 16:11
**/
@Transactional(rollbackFor = Exception.class)
public void saveDeptScoreEntity(CalculateCommonFormDTO formDTO, HashMap<String, BigDecimal> resultMap) {
public void saveDeptScoreEntity(CalculateCommonFormDTO formDTO, HashMap<String, CalculateResult> resultMap) {
String quarterId = DateUtils.getQuarterId(formDTO.getMonthId());
String yearId = DateUtils.getYearId(formDTO.getMonthId());
resultMap.forEach((deptId, governAblityScore) -> {
List<DeptScoreEntity> deptScoreEntityList=new ArrayList<>();
List<DeptSubScoreEntity> deptSubScoreEntityList=new ArrayList<>();
resultMap.forEach((deptId, calculateResult) -> {
DeptScoreEntity deptScoreEntity = new DeptScoreEntity();
deptScoreEntity.setCustomerId(formDTO.getCustomerId());
deptScoreEntity.setDeptId(deptId);
@ -195,26 +232,29 @@ public class DeptScoreServiceImpl extends BaseServiceImpl<DeptScoreDao, DeptScor
deptScoreEntity.setQuarterId(quarterId);
deptScoreEntity.setYearId(yearId);
deptScoreEntity.setMonthId(formDTO.getMonthId());
deptScoreEntity.setScore(governAblityScore);
deptScoreDao.deleteByDeptIdAndMonthId(formDTO.getCustomerId(),formDTO.getMonthId(),deptId);
deptScoreDao.insert(deptScoreEntity);
deptScoreEntity.setScore(calculateResult.getTotalScore());
//区直部门治理能力的 上一级是 quzhibumen
////新增ALL_PARENT_INDEX_CODE 所有指标code拼接的字符串 冒号隔开
deptScoreEntity.setAllParentIndexCode(IndexCodeEnum.QU_ZHI_BU_MEN.getCode());
deptScoreEntityList.add(deptScoreEntity);
for(IndexScoreVo detail:calculateResult.getDetails()){
DeptSubScoreEntity deptSubScore= ConvertUtils.sourceToTarget(deptScoreEntity, DeptSubScoreEntity.class);
//重新赋值
deptSubScore.setIndexCode(detail.getIndexCode());
deptSubScore.setAllParentIndexCode(detail.getAllParentIndexCode());
deptSubScore.setScore(detail.getScore());
deptSubScoreEntityList.add(deptSubScore);
}
});
//本身是分页计算的,主表一次性插入
deptScoreDao.insertBatchEntity(deptScoreEntityList);
//明细表分组插入
List<List<DeptSubScoreEntity>> partitionDeptSubScoreList = ListUtils.partition(deptSubScoreEntityList, IndexCalConstant.INSERT_SIZE);
for (List<DeptSubScoreEntity> insertDeptSubList : partitionDeptSubScoreList) {
deptSubScoreDao.insertBatchEntity(insertDeptSubList);
}
}
/**
* @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

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

@ -11,13 +11,16 @@ import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.IndexCalConstant;
import com.epmet.dao.evaluationindex.indexcal.CpcScoreDao;
import com.epmet.dao.evaluationindex.indexcal.GridScoreDao;
import com.epmet.dao.evaluationindex.indexcal.GridSubScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyDao;
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;
import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcal.GridCorreLationService;
@ -27,11 +30,9 @@ 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.IndexOutputVO;
import com.epmet.support.normalizing.batch.SampleValue;
import com.epmet.support.normalizing.batch.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.ListUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -69,6 +70,8 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
private CpcScoreDao cpcScoreDao;
@Autowired
private GridScoreDao gridScoreDao;
@Autowired
private GridSubScoreDao gridSubScoreDao;
/**
@ -154,7 +157,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
}
//指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap);
List<HashMap<String, BigDecimal>> resultMapList = new ArrayList<>();
List<HashMap<String, CalculateResult>> resultMapList = new ArrayList<>();
//分页查询采集记录
for (int pageNo = 1; pageNo <= totalPage; pageNo++) {
int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE;
@ -186,11 +189,16 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
}
});
});
HashMap<String, BigDecimal> resultMap = calculate(indexMap);
HashMap<String, CalculateResult> resultMap = calculate(indexMap);
resultMapList.add(resultMap);
}
// 保存中间表
saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), NumConstant.ZERO_STR);
deleteBeforeDataList(formDTO,IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCalConstant.GRID_DJ_ALL_PARENT_INDEX_CODE);
saveGridCorreLationResult(formDTO,
resultMapList,
IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),
IndexCalConstant.GRID_DJ_ALL_PARENT_INDEX_CODE,
NumConstant.ZERO_STR);
}
/**
@ -318,6 +326,36 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
return map;
}
/**
* @return void
* @param formDTO
* @param indexCode 当前计算的指标党建能力治理能力服务能力
* @param allParentIndexCode
* @author yinzuomei
* @description
* @Date 2020/9/10 13:58
**/
private void deleteBeforeDataList(CalculateCommonFormDTO formDTO,String indexCode,String allParentIndexCode) {
//先删除
int masterDeleteNum;
do {
//一次删除50条
masterDeleteNum = gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(),
formDTO.getMonthId(),
indexCode,
IndexCalConstant.DELETE_SIZE);
} while (masterDeleteNum != NumConstant.ZERO);
//删除明细时,需要根据分组删,比方说当前计算的是网格相关-党建能力,主表需要删除indexCode=dangjiannengli的,明细需要删除网格相关:党建能力 下面所有的指标明细
int detailDelteNum;
do {
detailDelteNum = gridSubScoreDao.deleteByDeptIdAndMonthId(formDTO.getCustomerId(),
formDTO.getMonthId(),
allParentIndexCode,
IndexCalConstant.DELETE_SIZE);
} while (detailDelteNum != NumConstant.ZERO);
log.info("delete fact_index_grid_score and fact_index_grid_sub_score complete");
}
/**
* @param formDTO 客户id 月份id: yyyyMM
* @param resultMapList
@ -329,15 +367,18 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @Date 2020/8/30 22:50
**/
private void saveGridCorreLationResult(CalculateCommonFormDTO formDTO,
List<HashMap<String, BigDecimal>> resultMapList,
List<HashMap<String, CalculateResult>> resultMapList,
String indexCode,
String allParentIndexCode,
String isTotal) {
List<GridScoreEntity> gridScoreEntityList = new ArrayList<>();
String quarterId = DateUtils.getQuarterId(formDTO.getMonthId());
String yearId = DateUtils.getYearId(formDTO.getMonthId());
for (HashMap<String, BigDecimal> resultMap : resultMapList) {
resultMap.forEach((gridId, partyAblityScore) -> {
log.info("网格id:" + gridId + ";index_Code:"+indexCode+";分值:" + partyAblityScore);
//三大能力结果表
List<GridScoreEntity> gridScoreEntityList = new ArrayList<>();
//五级指标分值明细
List<GridSubScoreEntity> gridSubScoreList = new ArrayList<>();
for (HashMap<String, CalculateResult> resultMap : resultMapList) {
resultMap.forEach((gridId, calculateResult) -> {
GridScoreEntity gridScoreEntity = new GridScoreEntity();
gridScoreEntity.setCustomerId(formDTO.getCustomerId());
gridScoreEntity.setGridId(gridId);
@ -355,18 +396,36 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
gridScoreEntity.setQuarterId(quarterId);
gridScoreEntity.setYearId(yearId);
gridScoreEntity.setMonthId(formDTO.getMonthId());
gridScoreEntity.setScore(partyAblityScore);
gridScoreEntity.setScore(calculateResult.getTotalScore());
//新增ALL_PARENT_INDEX_CODE 所有指标code拼接的字符串 冒号隔开
gridScoreEntity.setAllParentIndexCode(IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
gridScoreEntityList.add(gridScoreEntity);
for(IndexScoreVo detail:calculateResult.getDetails()){
GridSubScoreEntity gridSubScoreEntity= ConvertUtils.sourceToTarget(gridScoreEntity, GridSubScoreEntity.class);
//重新赋值
gridSubScoreEntity.setIndexCode(detail.getIndexCode());
gridSubScoreEntity.setAllParentIndexCode(detail.getAllParentIndexCode());
gridSubScoreEntity.setScore(detail.getScore());
gridSubScoreList.add(gridSubScoreEntity);
}
});
}
//后新增
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, isTotal);
//批量插入
List<List<GridScoreEntity>> partition = ListUtils.partition(gridScoreEntityList, 100);
List<List<GridScoreEntity>> partition = ListUtils.partition(gridScoreEntityList, IndexCalConstant.INSERT_SIZE);
partition.forEach(list -> {
gridScoreDao.insertBatches(list);
});
}
if (!CollectionUtils.isEmpty(gridSubScoreList)) {
//批量插入
List<List<GridSubScoreEntity>> subPartition = ListUtils.partition(gridSubScoreList, IndexCalConstant.INSERT_SIZE);
subPartition.forEach(subList -> {
gridSubScoreDao.insertBatches(subList);
});
}
log.info("insert fact_index_grid_score and fact_index_grid_sub_score complete");
}
/**
@ -377,7 +436,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @Date 2020/8/30 21:40
**/
@Override
public HashMap<String, BigDecimal> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
public HashMap<String, CalculateResult> calculate(Map<String, IndexInputVO<BigDecimal>> indexMap) {
//构造入参
List<IndexInputVO> indexInputVOS = this.getIndexInputVOList(indexMap);
log.info("计算的参数"+JSON.toJSONString(indexInputVOS));
@ -387,7 +446,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
List<IndexOutputVO> listTemp=batchScoreCalculator.getScoreDetailOfIndexId(indexInputVOS);
log.info("计算的结果(List)"+JSON.toJSONString(listTemp));
HashMap<String, BigDecimal> resultMap = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
HashMap<String, CalculateResult> resultMap = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("计算的结果{}", resultMap);
return resultMap;
}
@ -503,7 +562,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
}
//指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap);
List<HashMap<String, BigDecimal>> resultMapList = new ArrayList<>();
List<HashMap<String, CalculateResult>> resultMapList = new ArrayList<>();
//分页查询采集记录
for (int pageNo = 1; pageNo <= totalPage; pageNo++) {
int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE;
@ -532,11 +591,16 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
}
});
});
HashMap<String, BigDecimal> resultMap = calculate(indexMap);
HashMap<String, CalculateResult> resultMap = calculate(indexMap);
resultMapList.add(resultMap);
}
// 保存中间表
saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), NumConstant.ZERO_STR);
deleteBeforeDataList(formDTO,IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCalConstant.GRID_ZL_ALL_PARENT_INDEX_CODE);
saveGridCorreLationResult(formDTO,
resultMapList,
IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),
IndexCalConstant.GRID_ZL_ALL_PARENT_INDEX_CODE,
NumConstant.ZERO_STR);
}
@ -572,7 +636,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
}
//指标集合
Map<String, IndexInputVO<BigDecimal>> indexMap = buildGridCorrelationIndexInputVO(formDTO, indexList, minAndMaxMap);
List<HashMap<String, BigDecimal>> resultMapList = new ArrayList<>();
List<HashMap<String, CalculateResult>> resultMapList = new ArrayList<>();
//分页查询采集记录
for (int pageNo = 1; pageNo <= totalPage; pageNo++) {
int pageIndex = (pageNo - NumConstant.ONE) * IndexCalConstant.PAGE_SIZE;
@ -597,11 +661,16 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
}
});
});
HashMap<String, BigDecimal> resultMap = calculate(indexMap);
HashMap<String, CalculateResult> resultMap = calculate(indexMap);
resultMapList.add(resultMap);
}
// 保存中间表
saveGridCorreLationResult(formDTO, resultMapList, IndexCodeEnum.FU_WU_NENG_LI.getCode(), NumConstant.ZERO_STR);
deleteBeforeDataList(formDTO,IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCalConstant.GRID_FW_ALL_PARENT_INDEX_CODE);
saveGridCorreLationResult(formDTO,
resultMapList,
IndexCodeEnum.FU_WU_NENG_LI.getCode(),
IndexCalConstant.GRID_FW_ALL_PARENT_INDEX_CODE,
NumConstant.ZERO_STR);
}
/**
@ -637,9 +706,9 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
gridScoreEntityList.add(gridScoreEntity);
}
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, NumConstant.ONE_STR);
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, IndexCalConstant.DELETE_SIZE);
//批量插入
List<List<GridScoreEntity>> partition = ListUtils.partition(gridScoreEntityList, 100);
List<List<GridScoreEntity>> partition = ListUtils.partition(gridScoreEntityList, IndexCalConstant.INSERT_SIZE);
partition.forEach(list -> {
gridScoreDao.insertBatches(list);
});

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

@ -43,7 +43,31 @@
GROUP BY fidc.agency_id
</select>
<insert id="batchInsertDeptScoreData" parameterType="map">
<select id="selectListDeptId" resultType="String">
SELECT
DEPT_ID deptId
FROM
fact_index_dept_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY DEPT_ID
</select>
<!-- 根据客户id+monthId,删除这个月某个指标所有的数据 -->
<delete id="deleteByDeptIdAndMonthId" parameterType="map">
delete from fact_index_dept_score where CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
<if test="indexCode != null and indexCode !=''">
and INDEX_CODE=#{indexCode}
</if>
limit #{deleteSize}
</delete>
<!-- 批量插入计算结果 -->
<insert id="insertBatchEntity">
insert into fact_index_dept_score
(
ID,
@ -56,7 +80,7 @@
IS_TOTAL,
SCORE,
INDEX_CODE,
ALL_PARENT_INDEX_CODE,
DEL_FLAG,
REVISION,
CREATED_BY,
@ -72,12 +96,12 @@
#{item.agencyId},
#{item.quarterId},
#{item.yearId},
#{item.monthId},
#{item.isTotal},
#{item.score},
#{item.indexCode},
#{item.delFlag},
#{item.allParentIndexCode},
0,
0,
'APP_USER',
now(),
@ -86,22 +110,4 @@
)
</foreach>
</insert>
<select id="selectListDeptId" resultType="String">
SELECT
DEPT_ID deptId
FROM
fact_index_dept_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY DEPT_ID
</select>
<delete id="deleteByDeptIdAndMonthId" parameterType="map">
delete from fact_index_dept_score where CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
and DEPT_ID=#{deptId}
</delete>
</mapper>

71
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml

@ -2,47 +2,9 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.epmet.dao.evaluationindex.indexcal.DeptSubScoreDao">
<select id="selectListDeptScore" resultType="com.epmet.dto.indexcal.DeptScoreDTO">
SELECT
CUSTOMER_ID customerId,
DEPT_ID deptId,
YEAR_ID yearId,
MONTH_ID monthId,
SCORE score,
INDEX_CODE indexCode
FROM
fact_index_dept_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY DEPT_ID
</select>
<!-- 所有直属部门治理能力平均值 -->
<select id="selectGovernDeptScoreAvg" resultType="com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO">
SELECT
fidc.agency_id,
fidc.month_id,
fidc.quarter_id,
fidc.year_id,
AVG( fidc.score ) AS score,
fidc.customer_id,
sca.pid AS parentId
FROM
fact_index_dept_score fidc
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fidc.AGENCY_ID
WHERE
fidc.del_flag = '0'
AND fidc.customer_id = #{customerId}
AND fidc.month_id = #{monthId}
AND fidc.index_code = #{indexCode}
GROUP BY fidc.agency_id
</select>
<insert id="batchInsertDeptScoreData" parameterType="map">
insert into fact_index_dept_score
<!-- 批量插入计算结果 五级指标分数值 -->
<insert id="insertBatchEntity">
insert into fact_index_dept_sub_score
(
ID,
CUSTOMER_ID,
@ -53,7 +15,7 @@
MONTH_ID,
SCORE,
INDEX_CODE,
ALL_PARENT_INDEX_CODE,
DEL_FLAG,
REVISION,
CREATED_BY,
@ -69,11 +31,11 @@
#{item.agencyId},
#{item.quarterId},
#{item.yearId},
#{item.monthId},
#{item.score},
#{item.indexCode},
#{item.delFlag},
#{item.allParentIndexCode},
0,
0,
'APP_USER',
now(),
@ -83,21 +45,12 @@
</foreach>
</insert>
<select id="selectListDeptId" resultType="String">
SELECT
DEPT_ID deptId
FROM
fact_index_dept_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY DEPT_ID
</select>
<!-- 批量删除 -->
<delete id="deleteByDeptIdAndMonthId" parameterType="map">
delete from fact_index_dept_score where CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
and DEPT_ID=#{deptId}
delete from fact_index_dept_sub_score
where CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
and ALL_PARENT_INDEX_CODE=#{allParentIndexCode}
limit #{deleteSize}
</delete>
</mapper>

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

@ -15,6 +15,7 @@
<result property="isTotal" column="IS_TOTAL"/>
<result property="score" column="SCORE"/>
<result property="indexCode" column="INDEX_CODE"/>
<result property="allParentIndexCode" column="ALL_PARENT_INDEX_CODE"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
@ -31,9 +32,10 @@
CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND INDEX_CODE = #{indexCode}
and IS_TOTAL=#{isTotal}
limit #{deleteNum}
</delete>
<!-- 批量插入计算结果 -->
<insert id="insertBatches">
INSERT INTO `fact_index_grid_score` (
`ID`,
@ -47,6 +49,7 @@
`IS_TOTAL`,
`SCORE`,
`INDEX_CODE`,
ALL_PARENT_INDEX_CODE,
`DEL_FLAG`,
`REVISION`,
`CREATED_BY`,
@ -68,6 +71,7 @@
#{item.isTotal},
#{item.score},
#{item.indexCode},
#{item.allParentIndexCode},
0,
0,
'APP_USER',
@ -156,50 +160,6 @@
ORDER BY GRID_ID
</select>
<insert id="batchInsertGridScoreData" parameterType="map">
insert into fact_index_grid_score
(
ID,
CUSTOMER_ID,
GRID_ID,
AGENCY_ID,
ALL_PARENT_IDS,
QUARTER_ID,
YEAR_ID,
MONTH_ID,
IS_TOTAL,
SCORE,
INDEX_CODE,
DEL_FLAG,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME
) values
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{customerId},
#{item.gridId},
#{item.agencyId},
#{item.allParentIds},
#{item.quarterId},
#{item.yearId},
#{item.monthId},
#{item.isTotal},
#{item.score},
#{item.indexCode},
#{item.delFlag},
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
<select id="selectListGridId" resultType="String">
SELECT

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

@ -3,18 +3,9 @@
<mapper namespace="com.epmet.dao.evaluationindex.indexcal.GridSubScoreDao">
<delete id="deleteByCusAndMonthId" parameterType="map">
DELETE
FROM
fact_index_grid_score
WHERE
CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND INDEX_CODE = #{indexCode}
</delete>
<!-- 批量插入计算结果 -->
<insert id="insertBatches">
INSERT INTO `fact_index_grid_score` (
INSERT INTO `fact_index_grid_sub_score` (
`ID`,
`CUSTOMER_ID`,
`GRID_ID`,
@ -25,6 +16,7 @@
`MONTH_ID`,
`SCORE`,
`INDEX_CODE`,
ALL_PARENT_INDEX_CODE,
`DEL_FLAG`,
`REVISION`,
`CREATED_BY`,
@ -46,6 +38,7 @@
#{item.isTotal},
#{item.score},
#{item.indexCode},
#{item.allParentIndexCode},
0,
0,
'APP_USER',
@ -56,133 +49,15 @@
</foreach>
</insert>
<resultMap id="GridScoreDTOMap" type="com.epmet.dto.indexcal.GridScoreDTO">
<result property="gridId" column="GRID_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="allParentIds" column="ALL_PARENT_IDS"/>
<result property="quarterId" column="QUARTER_ID"/>
<result property="yearId" column="YEAR_ID"/>
<result property="monthId" column="MONTH_ID"/>
<collection property="detailList" ofType="com.epmet.dto.indexcal.GridScoreDetailDTO" >
<result property="score" column="SCORE"/>
<result property="indexCode" column="INDEX_CODE"/>
</collection>
</resultMap>
<select id="selectList" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultMap="GridScoreDTOMap">
SELECT
m.GRID_ID,
m.CUSTOMER_ID,
m.AGENCY_ID,
m.ALL_PARENT_IDS,
m.QUARTER_ID,
m.YEAR_ID,
m.MONTH_ID,
M.SCORE,
M.INDEX_CODE
FROM
fact_index_grid_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID =#{monthId}
</select>
<!-- 下属所有网格的平均值 -->
<select id="selectSubGridAvgScore" resultType="com.epmet.dto.screen.result.SubGridAvgResultDTO">
SELECT
figc.agency_id AS agencyId,
figc.month_id as monthId,
figc.quarter_id as quarterId,
figc.year_id as yearId,
ROUND(AVG( figc.score ),6) AS score,
figc.customer_id as customerId,
sca.pid AS parentId
FROM
fact_index_grid_score figc
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = figc.AGENCY_ID
WHERE
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>
<select id="selectListGridScore" resultType="com.epmet.dto.screen.FactIndexGridScoreDTO">
SELECT
CUSTOMER_ID customerId,
GRID_ID gridId,
AGENCY_ID agencyId,
YEAR_ID yearId,
MONTH_ID monthId,
SCORE score,
INDEX_CODE indexCode
FROM
fact_index_grid_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY GRID_ID
</select>
<insert id="batchInsertGridScoreData" parameterType="map">
insert into fact_index_grid_score
(
ID,
CUSTOMER_ID,
GRID_ID,
AGENCY_ID,
ALL_PARENT_IDS,
QUARTER_ID,
YEAR_ID,
MONTH_ID,
SCORE,
INDEX_CODE,
DEL_FLAG,
REVISION,
CREATED_BY,
CREATED_TIME,
UPDATED_BY,
UPDATED_TIME
) values
<foreach collection="list" item="item" index="index" separator=",">
(
(SELECT REPLACE(UUID(), '-', '') AS id),
#{customerId},
#{item.gridId},
#{item.agencyId},
#{item.allParentIds},
#{item.quarterId},
#{item.yearId},
#{item.monthId},
#{item.score},
#{item.indexCode},
#{item.delFlag},
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
<select id="selectListGridId" resultType="String">
SELECT
GRID_ID gridId
<!-- 批量删除 -->
<delete id="deleteByDeptIdAndMonthId">
DELETE
FROM
fact_index_grid_score
fact_index_grid_sub_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY GRID_ID
</select>
CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND ALL_PARENT_INDEX_CODE = #{allParentIndexCode}
limit #{deleteNum}
</delete>
</mapper>
Loading…
Cancel
Save