|
|
@ -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 |
|
|
|