Browse Source

网格相关-暂存V3

dev_shibei_match
yinzuomei 5 years ago
parent
commit
4d6adb90b3
  1. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java
  2. 47
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java
  3. 35
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml

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

@ -38,7 +38,7 @@ public interface GridScoreDao extends BaseDao<GridScoreEntity> {
* @param customerId
* @param monthId
* @param indexCode
* @param isTotal
* @param isTotal 1总分0不是
* @return int
* @author yinzuomei
* @description

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

@ -11,10 +11,7 @@ import com.epmet.dao.indexscore.CpcScoreDao;
import com.epmet.dao.indexscore.GridScoreDao;
import com.epmet.dao.screen.ScreenCustomerGridDao;
import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.CustomerGridInfoDTO;
import com.epmet.dto.indexcal.GridScoreDTO;
import com.epmet.dto.indexcal.PageQueryGridFormDTO;
import com.epmet.dto.indexcal.*;
import com.epmet.entity.indexscore.GridScoreEntity;
import com.epmet.entity.screen.IndexGroupDetailEntity;
import com.epmet.eum.IndexCodeEnum;
@ -33,6 +30,8 @@ import org.springframework.util.CollectionUtils;
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
* 网格相关service
@ -96,7 +95,7 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
List<IndexGroupDetailEntity> wgxgList = indexGroupDetailService.getDetailListByParentCode(formDTO.getCustomerId(),
IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
if (!CollectionUtils.isEmpty(wgxgList)) {
calculateGridTotal(formDTO, wgxgList);
calculateGridTotal(formDTO, wgxgList,IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
}
resultFlag = true;
return resultFlag;
@ -496,14 +495,42 @@ public class GridCorreLationServiceImpl implements GridCorreLationService {
* @description 计算网格相关总分
* @Date 2020/8/26 16:50
**/
private void calculateGridTotal(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList) {
private void calculateGridTotal(CalculateCommonFormDTO formDTO, List<IndexGroupDetailEntity> indexList, String indexCode) {
//查询总记录数
List<GridScoreDTO> gridScoreDTOList=gridScoreDao.selectList(formDTO);
// 保存中间表 TODO
// saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),NumConstant.ONE_STR);
List<GridScoreDTO> gridScoreDTOList = gridScoreDao.selectList(formDTO);
Map<String, IndexGroupDetailEntity> indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity()));
List<GridScoreEntity> gridScoreEntityList = new ArrayList<>();
gridScoreDTOList.forEach(gridScoreDTO -> {
GridScoreEntity gridScoreEntity = new GridScoreEntity();
gridScoreEntity.setCustomerId(gridScoreDTO.getCustomerId());
gridScoreEntity.setGridId(gridScoreDTO.getGridId());
gridScoreEntity.setIsTotal(NumConstant.ONE_STR);
gridScoreEntity.setIndexCode(indexCode);
gridScoreEntity.setAgencyId(gridScoreDTO.getAgencyId());
gridScoreEntity.setAllParentIds(gridScoreDTO.getAllParentIds());
gridScoreEntity.setQuarterId(gridScoreDTO.getQuarterId());
gridScoreEntity.setYearId(gridScoreDTO.getYearId());
gridScoreEntity.setMonthId(gridScoreDTO.getMonthId());
gridScoreEntity.setScore(BigDecimal.ZERO);
for(GridScoreDetailDTO gridScoreDetailDTO:gridScoreDTO.getDetailList()){
BigDecimal indexScore=gridScoreDetailDTO.getScore().multiply(indexMap.get(gridScoreDetailDTO.getIndexCode()).getWeight());
gridScoreEntity.setScore(gridScoreEntity.getScore().add(indexScore));
}
gridScoreEntityList.add(gridScoreEntity);
});
if (!CollectionUtils.isEmpty(gridScoreEntityList)) {
gridScoreDao.deleteByCusAndMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), indexCode, NumConstant.ONE_STR);
gridScoreDao.insertBatches(gridScoreEntityList);
}
}
public static void main(String[] args) {
BigDecimal totalScore=BigDecimal.ZERO;
for(int i=1;i<5;i++){
totalScore=totalScore.add(new BigDecimal("1.00"));
}
System.out.println(totalScore);
}
/**
* @param customerId
* @return com.epmet.dto.indexcal.CustomerGridInfoDTO

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

@ -78,7 +78,38 @@
</foreach>
</insert>
<select id="selectList" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultType="com.epmet.dto.indexcal.GridScoreDTO">
<resultMap id="GridScoreDTOMap" type="com.epmet.dto.indexcal.GridScoreDTO">
<result property="gridId" column="GRID_ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="allParentIds" column="ALL_PARENT_IDS"/>
<result property="quarterId" column="QUARTER_ID"/>
<result property="yearId" column="YEAR_ID"/>
<result property="monthId" column="MONTH_ID"/>
<collection property="detailList" ofType="com.epmet.dto.indexcal.GridScoreDetailDTO" >
<result property="isTotal" column="IS_TOTAL"/>
<result property="score" column="SCORE"/>
<result property="indexCode" column="INDEX_CODE"/>
</collection>
</resultMap>
<select id="selectList" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultMap="GridScoreDTOMap">
SELECT
m.GRID_ID,
m.CUSTOMER_ID,
m.AGENCY_ID,
m.ALL_PARENT_IDS,
m.QUARTER_ID,
m.YEAR_ID,
m.MONTH_ID,
m.IS_TOTAL,
M.SCORE,
M.INDEX_CODE
FROM
fact_index_grid_score m
WHERE
m.DEL_FLAG = '0'
AND m.IS_TOTAL='0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID =#{monthId}
</select>
</mapper>
Loading…
Cancel
Save