From 4d6adb90b30943ce7c55580d14b152ff4f8ea251 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Mon, 31 Aug 2020 18:10:07 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E7=9B=B8=E5=85=B3-=E6=9A=82?= =?UTF-8?q?=E5=AD=98V3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dao/indexscore/GridScoreDao.java | 2 +- .../impl/GridCorreLationServiceImpl.java | 47 +++++++++++++++---- .../mapper/indexscore/GridScoreDao.xml | 35 +++++++++++++- 3 files changed, 71 insertions(+), 13 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java index 30196d21f9..71316cf4f4 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/indexscore/GridScoreDao.java +++ b/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 { * @param customerId * @param monthId * @param indexCode - * @param isTotal + * @param isTotal 1:总分;0不是 * @return int * @author yinzuomei * @description diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java index 0700e33f7b..74afb589f3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/indexcal/impl/GridCorreLationServiceImpl.java +++ b/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 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 indexList) { + private void calculateGridTotal(CalculateCommonFormDTO formDTO, List indexList, String indexCode) { //查询总记录数 - List gridScoreDTOList=gridScoreDao.selectList(formDTO); - // 保存中间表 TODO -// saveGridCorreLationDangJian(formDTO, resultMapList,IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode(),NumConstant.ONE_STR); + List gridScoreDTOList = gridScoreDao.selectList(formDTO); + Map indexMap = indexList.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, Function.identity())); + List 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 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml index 6f739c3e36..35a12160ce 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/indexscore/GridScoreDao.xml @@ -78,7 +78,38 @@ - + 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} \ No newline at end of file