Browse Source

Merge remote-tracking branch 'remotes/origin/dev_screen_data' into dev_temp

master
jianjun 5 years ago
parent
commit
49f2961fc2
  1. 1
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyScoreDTO.java
  2. 6
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java
  3. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/ScreenCollFormDTO.java
  4. 18
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java
  5. 39
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiScreenCollController.java
  6. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java
  7. 107
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java
  8. 3
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java
  9. 105
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunitySubScoreDao.java
  10. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcScoreDao.java
  11. 86
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcSubScoreDao.java
  12. 92
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/DeptSubScoreDao.java
  13. 114
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/GridSubScoreDao.java
  14. 90
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/AgencySubScoreEntity.java
  15. 90
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/CpcSubScoreEntity.java
  16. 90
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/DeptSubScoreEntity.java
  17. 95
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/indexcal/GridSubScoreEntity.java
  18. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java
  19. 36
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/CpcIndexCalculateServiceImpl.java
  20. 125
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateCommunityServiceImpl.java
  21. 93
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateDistrictServiceImpl.java
  22. 125
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java
  23. 105
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateStreetServiceImpl.java
  24. 365
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  25. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ShiBeiScreenCollService.java
  26. 4
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ShiBeiScreenCollServiceImpl.java
  27. 10
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml
  28. 160
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySubScoreDao.xml
  29. 8
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml
  30. 156
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySubScoreDao.xml
  31. 7
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml
  32. 144
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcSubScoreDao.xml
  33. 103
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/DeptSubScoreDao.xml
  34. 188
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/GridSubScoreDao.xml

1
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/indexcal/AgencyScoreDTO.java

@ -132,6 +132,7 @@ public class AgencyScoreDTO implements Serializable {
this.score = new BigDecimal(NumConstant.ZERO);
this.indexCode = "";
this.dataType = IndexCalConstant.STREET_LEVEL;
this.allParentIndexCode = "";
this.delFlag = 0;
this.revision = 0;
this.createdBy = "APP_USER";

6
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screen/FactIndexCommunityScoreDTO.java

@ -84,6 +84,11 @@ public class FactIndexCommunityScoreDTO implements Serializable {
*/
private String indexCode;
/**
* 所有指标code拼接的字符串 冒号隔开
*/
private String allParentIndexCode;
/**
* 删除状态
*/
@ -124,6 +129,7 @@ public class FactIndexCommunityScoreDTO implements Serializable {
this.isTotal = "0";
this.score = new BigDecimal(0);
this.indexCode = "";
this.allParentIndexCode = "";
this.delFlag = 0;
this.revision = 0;
this.createdBy = "APP_USER";

5
epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/ScreenCollFormDTO.java

@ -31,6 +31,11 @@ public class ScreenCollFormDTO<T> implements Serializable {
*/
private String monthId;
/**
* yyyy
*/
private String yearId;
/**
* 数据集合
*/

18
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/IndexCalculateController.java

@ -1,9 +1,10 @@
package com.epmet.controller;
import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth;
import com.epmet.commons.extappauth.bean.ExternalAppRequestParam;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.IndexCalculateForm;
import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService;
import com.epmet.service.evaluationindex.indexcal.IndexCalculateService;
import com.epmet.util.DimIdGenerator;
@ -40,10 +41,21 @@ public class IndexCalculateController {
* @Author zhangyong
* @Date 10:52 2020-08-20
**/
@ExternalAppRequestAuth
@PostMapping("all")
public Result<Boolean> indexCalculate(@RequestBody IndexCalculateForm formDTO) {
public Result<Boolean> indexCalculate(ExternalAppRequestParam externalAppRequestParam, @RequestBody CalculateCommonFormDTO formDTO) {
formDTO.setCustomerId(externalAppRequestParam.getCustomerId());
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
if (aBoolean) {
return new Result<Boolean>().ok(true);
}
return new Result<Boolean>().error("指标计算失败");
}
@PostMapping("reAll")
public Result<Boolean> calculateAll(@RequestBody CalculateCommonFormDTO formDTO) {
Boolean aBoolean = indexCalculateService.indexCalculate(formDTO);
if (aBoolean){
if (aBoolean) {
return new Result<Boolean>().ok(true);
}
return new Result<Boolean>().error("指标计算失败");

39
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ShiBeiScreenCollController.java

@ -4,14 +4,13 @@ import com.epmet.commons.extappauth.annotation.ExternalAppRequestAuth;
import com.epmet.commons.extappauth.bean.ExternalAppRequestParam;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.screencoll.form.*;
import com.epmet.service.evaluationindex.screen.ScreenCollService;
import com.epmet.service.evaluationindex.screen.ShiBeiScreenCollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* 市北大屏数据采集api
@ -24,7 +23,7 @@ import java.util.List;
public class ShiBeiScreenCollController {
@Autowired
private ScreenCollService screenCollService;
private ShiBeiScreenCollService shiBeiScreenCollService;
/**
* 9党建引领|基层治理-居民党员积分排行榜
@ -38,7 +37,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("partyuserrankdata")
public Result partyUserRankData(ExternalAppRequestParam externalAppRequestParam, @RequestBody PartyUserRankDataListFormDTO formDTO) {
screenCollService.insertPartyUserRankData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertPartyUserRankData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -54,7 +53,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("partylinkmassesdata")
public Result partyLinkMassesData(ExternalAppRequestParam externalAppRequestParam, @RequestBody PartyLinkMassesDataListFormDTO formDTO) {
screenCollService.insertPartyLinkMassesData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertPartyLinkMassesData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -70,7 +69,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("meetdata")
public Result meetData(ExternalAppRequestParam externalAppRequestParam, @RequestBody PartyBranchDataListFormDTO formDTO) {
screenCollService.insertPartyBranchData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertPartyBranchData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -86,7 +85,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("orgrankdata")
public Result orgRankData(ExternalAppRequestParam externalAppRequestParam, @RequestBody OrgRankDataListFormDTO formDTO) {
screenCollService.insertOrgRankData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertOrgRankData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -102,7 +101,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("governrankdata")
public Result governRankData(ExternalAppRequestParam externalAppRequestParam, @RequestBody GovernRankDataListFormDTO formDTO) {
screenCollService.insertGovernRankData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertGovernRankData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -118,7 +117,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("eventdata")
public Result eventData(ExternalAppRequestParam externalAppRequestParam, @RequestBody EventDataListFormDTO formDTO) {
screenCollService.insertEventData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertEventData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -134,7 +133,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("difficultydata")
public Result difficultyData(ExternalAppRequestParam externalAppRequestParam, @RequestBody DifficultyDataFormDTO formDTO) {
screenCollService.insertDifficultyData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertDifficultyData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -150,7 +149,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("cpcbasedata")
public Result cpcbaseData(ExternalAppRequestParam externalAppRequestParam, @RequestBody CpcBaseDataListFormDTO formDTO) {
screenCollService.insertCpcbaseData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertCpcbaseData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -166,7 +165,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("indexdatamonthly")
public Result indexDataMonthly(ExternalAppRequestParam externalAppRequestParam, @RequestBody IndexDataListMonthlyFormDTO formDTO) {
screenCollService.insertIndexDataMonthly(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertIndexDataMonthly(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -184,7 +183,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("indexdatayearly")
public Result indexDataYearly(ExternalAppRequestParam externalAppRequestParam, @RequestBody IndexDataListYearlyFormDTO formDTO) {
screenCollService.insertIndexDataYearly(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertIndexDataYearly(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -200,7 +199,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("customerdept")
public Result customerDept(ExternalAppRequestParam externalAppRequestParam, @RequestBody CustomerDeptListFormDTO formDTO) {
screenCollService.insertCustomerDept(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertCustomerDept(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -216,7 +215,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("customergrid")
public Result customerGrid(ExternalAppRequestParam externalAppRequestParam, @RequestBody CustomerGridListFormDTO formDTO) {
screenCollService.insertCustomerGrid(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertCustomerGrid(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -232,7 +231,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("customeragency")
public Result customerAgency(ExternalAppRequestParam externalAppRequestParam, @RequestBody CustomerAgencyListFormDTO formDTO) {
screenCollService.insertCustomerAgency(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertCustomerAgency(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -248,7 +247,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("usertotaldata")
public Result userTotalData(ExternalAppRequestParam externalAppRequestParam, @RequestBody UserTotalDataListFormDTO formDTO) {
screenCollService.insertUserTotalData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertUserTotalData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -264,7 +263,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("userjoin")
public Result userJoin(ExternalAppRequestParam externalAppRequestParam, @RequestBody UserJoinListFormDTO formDTO) {
screenCollService.insertUserJoin(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertUserJoin(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -280,7 +279,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("pioneerdata")
public Result pioneerData(ExternalAppRequestParam externalAppRequestParam, @RequestBody PioneerDataListFormDTO formDTO) {
screenCollService.insertPioneerData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertPioneerData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
@ -297,7 +296,7 @@ public class ShiBeiScreenCollController {
@ExternalAppRequestAuth
@PostMapping("publicpartitotaldata")
public Result publicPartiTotalData(ExternalAppRequestParam externalAppRequestParam, @RequestBody PublicPartiTotalDataListFormDTO formDTO) {
screenCollService.insertPublicPartiTotalData(formDTO, externalAppRequestParam.getCustomerId());
shiBeiScreenCollService.insertPublicPartiTotalData(formDTO, externalAppRequestParam.getCustomerId());
return new Result();
}
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencyScoreDao.java

@ -48,11 +48,10 @@ public interface AgencyScoreDao extends BaseDao<AgencyScoreEntity> {
* @Description 删除旧记录
* @param customerId
* @param monthId
* @param indexCode
* @author zxc
* @date 2020/9/2 15:47
*/
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("indexCode")String indexCode,@Param("dataType")String dataType);
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId")String monthId, @Param("dataType")String dataType);
/**
* @Description 查询fact_index_agency_score相关信息

107
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/AgencySubScoreDao.java

@ -0,0 +1,107 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO;
import com.epmet.entity.evaluationindex.indexcal.AgencyScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* /街道相关分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-09-02
*/
@Mapper
public interface AgencySubScoreDao extends BaseDao<AgencyScoreEntity> {
/**
* @param lists
* @Description 街道中间表插入
* @author zxc
* @date 2020/8/27 5:05 下午
*/
void insertStreetRecord(@Param("lists") List<AgencyScoreDTO> lists);
/**
* @param customerId
* @param monthId
* @param indexCode
* @Description 删除旧记录
* @author zxc
* @date 2020/9/2 15:47
*/
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode, @Param("dataType") String dataType);
/**
* @param customerId
* @param monthId
* @Description 查询fact_index_agency_score相关信息
* @author zxc
* @date 2020/9/1 9:41 上午
*/
List<AgencyScoreDTO> selectAgencyScoreInfo(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("dataType") String dataType);
/**
* @param customerId
* @param monthId
* @Description 区下级街道得分平均值
* @author zxc
* @date 2020/8/31 1:51 下午
*/
List<SubAgencyScoreAvgResultDTO> selectAgencyScoreAvg(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode, @Param("dataType") String dataType);
/**
* 根据入参查询 /街道相关分数表 记录
*
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.indexcal.AgencyScoreDTO>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<AgencyScoreDTO> selectListAgencyScore(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* 批量插入区/街道相关分数表
*
* @param list
* @param customerId
* @return void
* @Author zhangyong
* @Date 11:11 2020-09-04
**/
void batchInsertAgencyScoreData(@Param("list") List<AgencyScoreEntity> list, @Param("customerId") String customerId);
/**
* 根据入参查询 /街道相关分数表id
*
* @param customerId
* @param monthId
* @return java.util.List<java.lang.String>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<String> selectListAgencyId(@Param("customerId") String customerId, @Param("monthId") String monthId);
}

3
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunityScoreDao.java

@ -47,11 +47,10 @@ public interface CommunityScoreDao extends BaseDao<FactIndexCommunityScoreEntity
* @Description 删除旧记录
* @param customerId
* @param monthId
* @param indexCode
* @author zxc
* @date 2020/9/1 9:03 上午
*/
void deleteOldRecord(@Param("customerId") String customerId,@Param("monthId")String monthId,@Param("indexCode")String indexCode);
void deleteOldRecord(@Param("customerId") String customerId,@Param("monthId")String monthId);
/**
* @Description 查询社区相关信息

105
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CommunitySubScoreDao.java

@ -0,0 +1,105 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.SubCommunityAvgResultDTO;
import com.epmet.dto.screen.FactIndexCommunityScoreDTO;
import com.epmet.entity.evaluationindex.screen.FactIndexCommunityScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 社区相关分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
*/
@Mapper
public interface CommunitySubScoreDao extends BaseDao<FactIndexCommunityScoreEntity> {
/**
* @param lists
* @Description 社区中间表插入
* @author zxc
* @date 2020/8/27 5:05 下午
*/
void insertCommunityPartyRecord(@Param("lists") List<FactIndexCommunityScoreDTO> lists);
/**
* @param customerId
* @param monthId
* @Description 删除旧记录
* @author zxc
* @date 2020/9/1 9:03 上午
*/
void deleteOldRecord(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* @param customerId
* @param monthId
* @Description 查询社区相关信息
* @author zxc
* @date 2020/9/1 9:41 上午
*/
List<FactIndexCommunityScoreDTO> selectCommunityInfo(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* 根据入参查询 查询社区相关信息
*
* @param customerId
* @param monthId
* @return java.util.List<com.epmet.dto.screen.FactIndexCommunityScoreDTO>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<FactIndexCommunityScoreDTO> selectListCommunityScore(@Param("customerId") String customerId, @Param("monthId") String monthId);
/**
* @param customerId
* @param monthId
* @Description 街道下级所有社区得分平均值
* @author zxc
* @date 2020/8/31 1:51 下午
*/
List<SubCommunityAvgResultDTO> selectSubCommAvgScore(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode);
/**
* 批量插入 社区相关分数表
*
* @param list
* @param customerId
* @return void
* @Author zhangyong
* @Date 11:11 2020-09-04
**/
void batchInsertCommunityScoreData(@Param("list") List<FactIndexCommunityScoreEntity> list, @Param("customerId") String customerId);
/**
* 根据入参查询 查询社区id
*
* @param customerId
* @param monthId
* @return java.util.List<java.util.String>
* @Author zhangyong
* @Date 10:43 2020-09-03
**/
List<String> selectListCommunityId(@Param("customerId") String customerId, @Param("monthId") String monthId);
}

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

@ -80,7 +80,7 @@ public interface CpcScoreDao extends BaseDao<CpcScoreEntity> {
int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode);
List<CpcScoreEntity> getPartScore(@Param("customerId") String customerId, @Param("monthId") String monthId);
List<CpcScoreEntity> getPartScore(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("allParentCode") String allParentCode);
int insertBatch(@Param("list") Collection<CpcScoreEntity> values);
}

86
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/indexcal/CpcSubScoreDao.java

@ -0,0 +1,86 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.dao.evaluationindex.indexcal;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
/**
* 党员相关分值
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
*/
@Mapper
public interface CpcSubScoreDao extends BaseDao<CpcScoreEntity> {
/**
* @param customerId
* @param monthId
* @param gridId
* @return java.math.BigDecimal
* @author yinzuomei
* @description 获取网格内党员的联系群众能力考评分平均值
* @Date 2020/8/31 10:56
**/
BigDecimal selectGridContactMassesAvgValue(@Param("customerId") String customerId,
@Param("monthId") String monthId,
@Param("gridId") String gridId);
/**
* @param formDTO
* @return java.util.List<java.math.BigDecimal>
* @author yinzuomei
* @description 获取网格内党员的联系群众能力考评分平均值的最大值最小值
* @Date 2020/8/31 12:10
**/
List<BigDecimal> selectListGridContactMassesAvgValue(CalculateCommonFormDTO formDTO);
/**
* @param calculateCommonFormDTO
* @return java.util.List<java.math.BigDecimal>
* @author yinzuomei
* @description 网格内党员的参与议事能力考评分平均值 最大值最小值
* @Date 2020/8/31 14:42
**/
List<BigDecimal> selectListJoinIssueAvgValue(CalculateCommonFormDTO calculateCommonFormDTO);
/**
* @param customerId
* @param monthId
* @param gridId
* @return java.math.BigDecimal
* @author yinzuomei
* @description 组织内党员的参与议事能力考评分平均值
* @Date 2020/8/31 15:51
**/
BigDecimal selectGridJoinIssueAvgValue(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("gridId") String gridId);
int deleteByMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("indexCode") String indexCode);
List<CpcScoreEntity> getPartScore(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("allParentCode") String allParentCode);
int insertBatch(@Param("list") Collection<CpcScoreEntity> values);
}

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

@ -0,0 +1,92 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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 org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 区直部门分值表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-09-02
*/
@Mapper
public interface DeptSubScoreDao extends BaseDao<DeptScoreEntity> {
/**
* 根据入参查询 区直部门分值表 记录
*
* @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
**/
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);
/**
* @param customerId
* @param monthId
* @param deptId
* @return int
* @author yinzuomei
* @description
* @Date 2020/9/7 14:30
**/
int deleteByDeptIdAndMonthId(@Param("customerId") String customerId, @Param("monthId") String monthId, @Param("deptId") String deptId);
}

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

@ -0,0 +1,114 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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 org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 网格相关分值
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
*/
@Mapper
public interface GridSubScoreDao extends BaseDao<GridScoreEntity> {
/**
* @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
* @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);
/**
* @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
**/
void batchInsertGridScoreData(@Param("list") List<FactIndexGridScoreDTO> list, @Param("customerId") String customerId);
}

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

@ -0,0 +1,90 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.evaluationindex.indexcal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* /街道相关分数表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-09-02
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("fact_index_sub_agency_score")
public class AgencySubScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id
*/
private String customerId;
/**
* 组织id(eg社区或者街道id)
*/
private String agencyId;
/**
* 上级组织id
*/
private String parentAgencyId;
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
/**
* 1总分0不是默认0
*/
private String isTotal;
/**
* 分值
*/
private BigDecimal score;
/**
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli街道相关jiedaoxiangguan全区相关:quanquxiangguan
*/
private String indexCode;
/**
* 数据类型 district 全区street街道
*/
private String dataType;
}

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

@ -0,0 +1,90 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.evaluationindex.indexcal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 党员相关分值
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("fact_index_sub_cpc_score")
public class CpcSubScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id
*/
private String customerId;
/**
* 网格所属的机关Id
*/
private String agencyId;
/**
* 网格Id
*/
private String gridId;
/**
* 年维度Id: yyyy
*/
private String yearId;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
/**
* 用户id
*/
private String userId;
/**
* 分值
*/
private BigDecimal score;
/**
* 指标code
*/
private String indexCode;
/**
* 所有指标code拼接的字符串 冒号隔开
*/
private String allParentIndexCode;
/**
* 是否是总分 1是0不是
*/
private String isTotal;
}

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

@ -0,0 +1,90 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.evaluationindex.indexcal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 区直部门分值表
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-09-02
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("fact_index_sub_dept_score")
public class DeptSubScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id
*/
private String customerId;
/**
* 部门id
*/
private String deptId;
/**
* 部门所属的组织id
*/
private String agencyId;
/**
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
/**
* 1总分0不是默认0
*/
private String isTotal;
/**
* 分值
*/
private BigDecimal score;
/**
* 治理能力zhilinengli
*/
private String indexCode;
/**
* 所有指标code拼接的字符串 冒号隔开
*/
private String allParentIndexCode;
}

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

@ -0,0 +1,95 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* <p>
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.epmet.entity.evaluationindex.indexcal;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* 网格相关分值
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2020-08-31
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("fact_index_sub_grid_score")
public class GridSubScoreEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户Id
*/
private String customerId;
/**
* 网格Id
*/
private String gridId;
/**
* 网格所属的机关Id
*/
private String agencyId;
/**
* 所有上级ID用英文逗号分开
*/
private String allParentIds;
/**
* 季度id: yyyyQ1yyyyQ2yyyyQ3yyyyQ4
*/
private String quarterId;
/**
* 年度ID: yyyy
*/
private String yearId;
/**
* 月维度Id: yyyyMM
*/
private String monthId;
/**
* 1总分0不是
*/
private String isTotal;
/**
* 分值
*/
private BigDecimal score;
/**
* 党建能力dangjiannengli治理能力zhilinengli服务能力fuwunengli网格相关wanggexiangguan
*/
private String indexCode;
/**
* 所有指标code拼接的字符串 冒号隔开
*/
private String allParentIndexCode;
}

5
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java

@ -1,6 +1,6 @@
package com.epmet.service.evaluationindex.indexcal;
import com.epmet.dto.screen.form.IndexCalculateForm;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
/**
* 指标计算service
@ -11,8 +11,9 @@ import com.epmet.dto.screen.form.IndexCalculateForm;
public interface IndexCalculateService {
/**
* desc按照客户计算所有指标(按照月份)
*
* @param formDTO
* @return
*/
Boolean indexCalculate(IndexCalculateForm formDTO);
Boolean indexCalculate(CalculateCommonFormDTO formDTO);
}

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

@ -73,7 +73,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
Map<String, IndexGroupDetailEntity> indexWeightMap = parentIndexDetails.stream().collect(Collectors.toMap(IndexGroupDetailEntity::getIndexCode, o -> o));
//获取数据
List<CpcScoreEntity> list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId());
List<CpcScoreEntity> list = cpcScoreDao.getPartScore(formDTO.getCustomerId(), formDTO.getMonthId(), IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode());
if (CollectionUtils.isEmpty(list)) {
log.error("calculateTotalScore cpcScoreDao.getPartScore return empty,customerId:{},monthId:{}", formDTO.getCustomerId(), formDTO.getMonthId());
throw new RenException("客户四级指标分值记录不存在");
@ -83,11 +83,16 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
CpcScoreEntity totalEntity = null;
for (CpcScoreEntity part : partScoreList) {
IndexGroupDetailEntity indexGroupDetailEntity = indexWeightMap.get(part.getIndexCode());
if (indexGroupDetailEntity == null) {
log.error(" indexCode:{} 在指标明细中不存在", part.getIndexCode());
continue;
}
if (totalEntity == null) {
totalEntity = ConvertUtils.sourceToTarget(part, CpcScoreEntity.class);
totalEntity.setIsTotal(NumConstant.ONE_STR);
totalEntity.setIndexCode(IndexCodeEnum.DANG_YUAN_XIANG_GUAN.getCode());
totalEntity.setScore(new BigDecimal(0));
totalEntity.setAllParentIndexCode(indexGroupDetailEntity.getAllParentIndexCode());
cpcScoreTotalMap.put(userId, totalEntity);
}
//自建群活跃度——议题转项目率 有阈值 >60%按60%算
@ -157,22 +162,11 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
do {
list = factIndexPartyAblityCpcMonthlyDao.getCountByMonthId(formDTO.getCustomerId(), formDTO.getMonthId(), (pageNo - 1) * pageSize, pageSize);
if (!CollectionUtils.isEmpty(list)) {
//如果是第一页且仅有一条数据 则直接给50分
if (pageNo == NumConstant.ONE && list.size() == NumConstant.ONE) {
List<CpcScoreEntity> insertList = new ArrayList<>();
for (String parentIndexCode : groupIndexDetailsMap.keySet()) {
insertList.add(handleOneGridScene(formDTO, parentIndexCode, list.get(0)));
}
if (CollectionUtils.isEmpty(insertList)) {
deleteAndInsertBatch(formDTO, insertList, null);
}
} else {
//遍历指标分组 计算分数
for (Map.Entry<String, List<IndexGroupDetailEntity>> entry : groupIndexDetailsMap.entrySet()) {
String parentIndexCode = entry.getKey();
List<IndexGroupDetailEntity> details = entry.getValue();
calculateScore(formDTO, details, list, minAndMaxMap, parentIndexCode);
}
//遍历指标分组 计算分数
for (Map.Entry<String, List<IndexGroupDetailEntity>> entry : groupIndexDetailsMap.entrySet()) {
String indexCode = entry.getKey();
List<IndexGroupDetailEntity> details = entry.getValue();
calculateScore(formDTO, details, list, minAndMaxMap, indexCode);
}
}
pageNo++;
@ -216,7 +210,7 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
cpcScoreEntity.setMonthId(formDTO.getMonthId());
cpcScoreEntity.setScore(new BigDecimal(0));
cpcScoreEntity.setIndexCode(parentIndexCode);
cpcScoreEntity.setAllParentIndexCode(value.getAllParentIndexCode());
scoreEntityMap.put(userId, cpcScoreEntity);
//构造样本值对象
@ -251,10 +245,14 @@ public class CpcIndexCalculateServiceImpl implements CpcIndexCalculateService {
result.forEach((userId, score) -> {
CpcScoreEntity cpcScoreEntity = indexDetails.get(userId);
cpcScoreEntity.setScore(score.getTotalScore());
String allParentIndexCode = score.getDetails().get(0).getAllParentIndexCode();
cpcScoreEntity.setAllParentIndexCode(allParentIndexCode.substring(0, allParentIndexCode.lastIndexOf(StrConstant.COLON)));
list.add(cpcScoreEntity);
CpcScoreEntity parent = ConvertUtils.sourceToTarget(cpcScoreEntity, CpcScoreEntity.class);
score.getDetails().forEach(o -> {
CpcScoreEntity child = ConvertUtils.sourceToTarget(o, CpcScoreEntity.class);
CpcScoreEntity child = ConvertUtils.sourceToTarget(parent, CpcScoreEntity.class);
child.setIndexCode(o.getIndexCode());
child.setAllParentIndexCode(o.getAllParentIndexCode());
child.setScore(o.getScore());
list.add(child);
});

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

@ -26,6 +26,7 @@ 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.CalculateResult;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.SampleValue;
import lombok.extern.slf4j.Slf4j;
@ -86,11 +87,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (CollectionUtils.isEmpty(subGridPartyAvgScore)) {
log.error(IndexCalConstant.GRID_PARTY_AVG_NULL);
return;
} else if (subGridPartyAvgScore.size() == NumConstant.ONE) {
pid.put(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(), subGridPartyAvgScore.get(NumConstant.ZERO).getParentId());
sizeOne(subGridPartyAvgScore.get(NumConstant.ZERO).getAgencyId(), customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid);
return;
} else if (subGridPartyAvgScore.size() > NumConstant.ONE) {
} else {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridPartyAvgScore.stream().map(o -> o.getScore()).collect(Collectors.toList()));
Integer indexEnd = NumConstant.TEN;
List<List<SubGridAvgResultDTO>> subPartyAvgList = ListUtils.partition(subGridPartyAvgScore, indexEnd);
@ -102,7 +99,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
@ -117,11 +114,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL, detail.getIndexCode()));
return;
} else if (publishArticleCountList.size() == NumConstant.ONE) {
pid.put(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid);
return;
} else if (publishArticleCountList.size() > NumConstant.ONE) {
} else {
List<BigDecimal> decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(publishArticleCountList, IndexCalConstant.PAGE_SIZE);
@ -133,7 +126,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -141,10 +134,11 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
log.info("communityPartyCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityPartyCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId);
deleteAndInsert(result);
return true;
}
@ -169,12 +163,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (CollectionUtils.isEmpty(subGridGovernAvg)){
log.error("社区下级治理能力平均分集合为空");
return;
}
if (subGridGovernAvg.size() == NumConstant.ONE) {
pid.put(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(), subGridGovernAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subGridGovernAvg.get(NumConstant.ZERO).getAgencyId(), customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
return;
} else if (subGridGovernAvg.size() > NumConstant.ONE) {
}else{
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridGovernAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridAvgResultDTO>> governAvg = ListUtils.partition(subGridGovernAvg, IndexCalConstant.PAGE_SIZE);
governAvg.forEach(avg -> {
@ -185,7 +174,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
@ -195,11 +184,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (CollectionUtils.isEmpty(communityGovernAbility)){
log.error(IndexCalConstant.COMMUNITY_GOVERN_ABILITY_NULL);
return;
}else if (communityGovernAbility.size() == NumConstant.ONE) {
pid.put(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
return;
} else if (communityGovernAbility.size() > NumConstant.ONE) {
}else{
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
@ -216,7 +201,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -224,10 +209,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityGovernAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -250,11 +235,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
String indexCode = detail.getIndexCode();
if (IndexCodeEnum.SHE_QU_XIA_JI_SYWGFWNLDFPJZ.getCode().equals(indexCode)) {
List<SubGridAvgResultDTO> subGridServiceAvg = factIndexGridScoreDao.selectSubGridAvgScore(customerId, monthId,IndexCodeEnum.FU_WU_NENG_LI.getCode());
if (subGridServiceAvg.size() == NumConstant.ONE) {
pid.put(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(), subGridServiceAvg.get(NumConstant.ZERO).getParentId());
sizeOne(subGridServiceAvg.get(NumConstant.ZERO).getAgencyId(), customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid);
if (CollectionUtils.isEmpty(subGridServiceAvg)) {
log.error("查询社区下级所有网格服务能力得分平均值集合为空");
return;
} else if (subGridServiceAvg.size() > NumConstant.ONE) {
} else {
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subGridServiceAvg.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubGridAvgResultDTO>> serviceAvgList = ListUtils.partition(subGridServiceAvg, IndexCalConstant.PAGE_SIZE);
serviceAvgList.forEach(serviceAvg -> {
@ -265,7 +249,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -274,11 +258,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
if (CollectionUtils.isEmpty(communityActivityCountList)) {
log.error(IndexCalConstant.COMMUNITY_SERVICE_ABILITY_NULL);
return;
}else if (communityActivityCountList.size() == NumConstant.ONE) {
pid.put(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid);
return;
} else if (communityActivityCountList.size() > NumConstant.ONE) {
}else{
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
@ -295,7 +275,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -303,10 +283,10 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId param:{}", JSON.toJSONString(indexInputVOS));
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreCountOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
log.info("communityServiceAbilityCalculate getScoreCountOfSampleId result:{}", JSON.toJSONString(scoreTotalOfSampleId));
List<FactIndexCommunityScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -338,13 +318,14 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
score.setYearId(DateUtils.getYearId(monthId));
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setIndexCode(IndexCalConstant.COMMUNITY_RELATE);
score.setAllParentIndexCode(NumConstant.ZERO_STR);
value.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
score.setParentAgencyId(community.getParentAgencyId());
});
result.add(score);
});
deleteAndInsert(customerId, monthId, IndexCalConstant.COMMUNITY_RELATE, result);
deleteAndInsert(result);
return true;
}
@ -391,18 +372,14 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
}
/**
* @param customerId
* @param monthId
* @param indexCode
* @param subAllGridList
* @Description 先删除记录在插入
* @author zxc
* @date 2020/9/1 4:24 下午
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<FactIndexCommunityScoreDTO> subAllGridList) {
public void deleteAndInsert(List<FactIndexCommunityScoreDTO> subAllGridList) {
if (!CollectionUtils.isEmpty(subAllGridList)) {
factIndexCommunityScoreDao.deleteOldRecord(customerId, monthId, indexCode);
factIndexCommunityScoreDao.insertCommunityPartyRecord(subAllGridList);
}
}
@ -417,7 +394,7 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<FactIndexCommunityScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, Map<String, String> pid) {
public List<FactIndexCommunityScoreDTO> getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode,String allParentIndexCode, Map<String, String> pid) {
List<FactIndexCommunityScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
FactIndexCommunityScoreDTO score = new FactIndexCommunityScoreDTO();
@ -428,29 +405,35 @@ public class IndexCalculateCommunityServiceImpl implements IndexCalculateCommuni
score.setYearId(DateUtils.getYearId(monthId));
score.setIsTotal(isTotal);
score.setIndexCode(indexCode);
score.setScore(v);
score.setScore(v.getTotalScore());
score.setAllParentIndexCode(allParentIndexCode);
pid.forEach((agency, parentAgency) -> {
if (k.equals(agency)) {
score.setParentAgencyId(parentAgency);
}
});
if (!CollectionUtils.isEmpty(v.getDetails())) {
v.getDetails().forEach(fiveDetail -> {
FactIndexCommunityScoreDTO s = new FactIndexCommunityScoreDTO();
s.setCustomerId(customerId);
s.setAgencyId(k);
s.setMonthId(monthId);
s.setQuarterId(DateUtils.getQuarterId(monthId));
s.setYearId(DateUtils.getYearId(monthId));
s.setIsTotal(isTotal);
s.setIndexCode(fiveDetail.getIndexCode());
s.setScore(fiveDetail.getScore());
s.setAllParentIndexCode(fiveDetail.getAllParentIndexCode());
pid.forEach((agency, parentAgency) -> {
if (k.equals(agency)) {
s.setParentAgencyId(parentAgency);
}
});
result.add(s);
});
}
result.add(score);
});
return result;
}
/**
* @param agencyId
* @param customerId
* @param monthId
* @Description 当查询结果为一条时调用此方法
* @author zxc
* @date 2020/9/2 2:40 下午
*/
public void sizeOne(String agencyId, String customerId, String monthId, String indexCode, Map<String, String> pid) {
HashMap<String, BigDecimal> scoreCountOfSampleId = new HashMap<>();
scoreCountOfSampleId.put(agencyId, new BigDecimal(NumConstant.FIFTY));
List<FactIndexCommunityScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode, pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

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

@ -24,6 +24,7 @@ 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.CalculateResult;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.SampleValue;
import lombok.extern.slf4j.Slf4j;
@ -121,7 +122,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
@ -136,11 +137,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL, detail.getIndexCode()));
return;
} else if (publishArticleCountList.size() == NumConstant.ONE) {
pid.put(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(publishArticleCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid);
return;
} else if (publishArticleCountList.size() > NumConstant.ONE) {
} else{
List<BigDecimal> decimalList = publishArticleCountList.stream().map(m -> new BigDecimal(m.get(fieldNameByIndexCode).toString())).collect(Collectors.toList());
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(decimalList);
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(publishArticleCountList, IndexCalConstant.PAGE_SIZE);
@ -152,16 +149,17 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
agencyScoreDao.deleteOldRecord(customerId, monthId,IndexCalConstant.DISTRICT_LEVEL);
deleteAndInsert(result);
return true;
}
@ -186,7 +184,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
if (CollectionUtils.isEmpty(districtGovernAvgList)) {
log.error("查询所有街道治理能力平均值集合为空");
return;
} else if (districtGovernAvgList.size() > NumConstant.ZERO) {
} else{
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(districtGovernAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> governAvg = ListUtils.partition(districtGovernAvgList, IndexCalConstant.PAGE_SIZE);
governAvg.forEach(avg -> {
@ -197,7 +195,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
@ -206,18 +204,18 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
if (CollectionUtils.isEmpty(deptScoreAvgList)) {
log.error("查询所有直属部门治理能力平均值集合为空");
return;
} else if (deptScoreAvgList.size() > NumConstant.ZERO) {
} else{
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(deptScoreAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> governAvg = ListUtils.partition(deptScoreAvgList, IndexCalConstant.PAGE_SIZE);
governAvg.forEach(avg -> {
List<SampleValue> index1SampleValues = new ArrayList<>();
avg.forEach(c -> {
pid.put(c.getParentId(),customerAgencyDao.selectPid(c.getParentId()));
pid.put(c.getAgencyId(),c.getParentId());
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
@ -226,9 +224,9 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -254,7 +252,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
if (CollectionUtils.isEmpty(subStreetAvgList)) {
log.error("查询区下属街道服务能力汇总平均值集合为空");
return;
} else if (subStreetAvgList.size() > NumConstant.ZERO) {
} else{
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(subStreetAvgList.stream().map(o -> o.getScore()).collect(Collectors.toList()));
List<List<SubAgencyScoreAvgResultDTO>> serviceAvgList = ListUtils.partition(subStreetAvgList, IndexCalConstant.PAGE_SIZE);
serviceAvgList.forEach(serviceAvg -> {
@ -265,7 +263,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
SampleValue s = new SampleValue(c.getParentId(), c.getScore());
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -274,9 +272,9 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -309,13 +307,14 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setDataType(IndexCalConstant.DISTRICT_LEVEL);
score.setIndexCode(IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode());
score.setAllParentIndexCode(NumConstant.ZERO_STR);
value.forEach(community -> {
score.setScore(score.getScore().add(community.getScore()));
score.setParentAgencyId(community.getParentAgencyId());
});
result.add(score);
});
deleteAndInsert(customerId, monthId, IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode(), result);
deleteAndInsert(result);
return true;
}
@ -335,18 +334,14 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
}
/**
* @param customerId
* @param monthId
* @param indexCode
* @param subAllDistrict
* @Description 先删除记录在插入
* @author zxc
* @date 2020/9/1 4:24 下午
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<AgencyScoreDTO> subAllDistrict) {
public void deleteAndInsert(List<AgencyScoreDTO> subAllDistrict) {
if (!CollectionUtils.isEmpty(subAllDistrict)) {
agencyScoreDao.deleteOldRecord(customerId, monthId, indexCode,IndexCalConstant.DISTRICT_LEVEL);
agencyScoreDao.insertStreetRecord(subAllDistrict);
}
}
@ -361,7 +356,7 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<AgencyScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, Map<String, String> pid) {
public List<AgencyScoreDTO> getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, String allParentIndexCode, Map<String, String> pid) {
List<AgencyScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
@ -372,30 +367,38 @@ public class IndexCalculateDistrictServiceImpl implements IndexCalculateDistrict
score.setYearId(DateUtils.getYearId(monthId));
score.setIsTotal(isTotal);
score.setIndexCode(indexCode);
score.setScore(v);
score.setScore(v.getTotalScore());
score.setAllParentIndexCode(allParentIndexCode);
score.setDataType(IndexCalConstant.DISTRICT_LEVEL);
pid.forEach((agency, parentAgency) -> {
if (k.equals(agency)) {
score.setParentAgencyId(parentAgency);
}
});
if (!CollectionUtils.isEmpty(v.getDetails())){
v.getDetails().forEach(streetScore -> {
AgencyScoreDTO s = new AgencyScoreDTO();
s.setCustomerId(customerId);
s.setAgencyId(k);
s.setMonthId(monthId);
s.setQuarterId(DateUtils.getQuarterId(monthId));
s.setYearId(DateUtils.getYearId(monthId));
s.setIsTotal(isTotal);
s.setIndexCode(streetScore.getIndexCode());
s.setScore(streetScore.getScore());
s.setAllParentIndexCode(streetScore.getAllParentIndexCode());
s.setDataType(IndexCalConstant.DISTRICT_LEVEL);
pid.forEach((agency, parentAgency) -> {
if (k.equals(agency)) {
s.setParentAgencyId(parentAgency);
}
});
result.add(s);
});
}
result.add(score);
});
return result;
}
/**
* @param agencyId
* @param customerId
* @param monthId
* @Description 当查询结果为一条时调用此方法
* @author zxc
* @date 2020/9/2 2:40 下午
*/
public void sizeOne(String agencyId, String customerId, String monthId, String indexCode, Map<String, String> pid) {
HashMap<String, BigDecimal> scoreCountOfSampleId = new HashMap<>();
scoreCountOfSampleId.put(agencyId, new BigDecimal(NumConstant.FIFTY));
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, indexCode, pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

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

@ -2,21 +2,22 @@ package com.epmet.service.evaluationindex.indexcal.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.DataSourceConstant;
import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.IndexCalculateForm;
import com.epmet.feign.EpmetCommonServiceOpenFeignClient;
import com.epmet.redis.IndexCodeFieldReRedis;
import com.epmet.service.evaluationindex.indexcal.*;
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService;
import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -44,78 +45,98 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
private IndexCalculateDistrictService indexCalculateDistrictService;
@Autowired
private DeptScoreService deptScoreService;
@Autowired
private FactIndexCollectService factIndexCollectService;
@Override
public Boolean indexCalculate(IndexCalculateForm formDTO) {
public Boolean indexCalculate(CalculateCommonFormDTO formDTO) {
try {
if (StringUtils.isBlank(formDTO.getMonthId())) {
//默认 当前月份-1
formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1)));
}
//按照客户分组
if (CollectionUtils.isEmpty(formDTO.getCustomerIds())) {
List<String> customerIds = new ArrayList<>();
if (StringUtils.isBlank(formDTO.getCustomerId())) {
Result<List<String>> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds();
if (!externalCustomerIdsResult.success()) {
log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail");
return false;
}
formDTO.setCustomerIds(externalCustomerIdsResult.getData());
customerIds = externalCustomerIdsResult.getData();
} else {
customerIds.add(formDTO.getCustomerId());
}
Boolean flag = false;
for (String customerId : formDTO.getCustomerIds()) {
for (String customerId : customerIds) {
CalculateCommonFormDTO calculateCommonFormDTO = new CalculateCommonFormDTO(customerId, formDTO.getMonthId());
//计算党员相关的
try {
CalculateCommonFormDTO param = new CalculateCommonFormDTO(customerId, formDTO.getMonthId());
flag = cpcIndexCalculateService.cpcIndexCalculate(param);
log.info("indexCalculate cpcIndexCalculate return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate cpcIndexCalculate exception", e);
break;
}
//计算党员相关的
try {
CalculateCommonFormDTO param = new CalculateCommonFormDTO(customerId, formDTO.getMonthId());
flag = cpcIndexCalculateService.cpcIndexCalculate(param);
log.info("indexCalculate cpcIndexCalculate return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate cpcIndexCalculate exception", e);
throw new RenException("indexCalculate cpcIndexCalculate exception", e);
}
//计算网格
try {
flag = gridCorreLationService.calculateGridCorreLation(calculateCommonFormDTO);
log.info("indexCalculate calculateGridCorreLation return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calculateGridCorreLation exception", e);
break;
}
//计算社区
try {
indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);
break;
}
//计算网格
try {
flag = gridCorreLationService.calculateGridCorreLation(calculateCommonFormDTO);
log.info("indexCalculate calculateGridCorreLation return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calculateGridCorreLation exception", e);
throw new RenException("indexCalculate calculateGridCorreLation exception", e);
}
//计算社区
try {
flag = indexCalculateCommunityService.calCommunityAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calCommunityAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calCommunityAll exception", e);
throw new RenException("indexCalculate calAll exception", e);
}
//计算街道
try {
indexCalculateStreetService.calStreetAll(customerId,formDTO.getMonthId());
log.info("indexCalculate calAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);
break;
}
//计算街道
try {
flag = indexCalculateStreetService.calStreetAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calStreetAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calStreetAll exception", e);
throw new RenException("indexCalculate calStreetAll exception", e);
}
//计算区直属
try {
deptScoreService.calculateDeptCorreLation(calculateCommonFormDTO);
log.info("indexCalculate calAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);
break;
//计算区直属
try {
flag = deptScoreService.calculateDeptCorreLation(calculateCommonFormDTO);
log.info("indexCalculate calculateDeptCorreLation return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calculateDeptCorreLation exception", e);
throw new RenException("indexCalculate calculateDeptCorreLation exception", e);
}
//计算全区
try {
indexCalculateDistrictService.calDistrictAll(customerId, formDTO.getMonthId());
log.info("indexCalculate calDistrictAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calDistrictAll exception", e);
throw new RenException("indexCalculate calDistrictAll exception", e);
}
} catch (RenException e) {
flag = false;
}
//计算全区
try {
indexCalculateDistrictService.calDistrictAll(customerId,formDTO.getMonthId());
log.info("indexCalculate calAll return result:{}", flag);
} catch (Exception e) {
log.error("indexCalculate calAll exception", e);
break;
//计算完毕后 将结果插入大屏相关数据表
if (flag) {
try {
factIndexCollectService.insertScreenIndexDataMonthlyAndYearly(formDTO.getMonthId(), formDTO.getCustomerId());
} catch (Exception e) {
log.error("indexCalculate insertScreenIndexDataMonthlyAndYearly exception", e);
flag = false;
}
}
}
return flag;

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

@ -12,7 +12,6 @@ import com.epmet.dao.evaluationindex.indexcal.CommunityScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityOrgMonthlyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.SubCommunityAvgResultDTO;
import com.epmet.dto.screen.result.MaxAndMinBigDecimalResultDTO;
@ -26,6 +25,7 @@ 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.CalculateResult;
import com.epmet.support.normalizing.batch.IndexInputVO;
import com.epmet.support.normalizing.batch.SampleValue;
import lombok.extern.slf4j.Slf4j;
@ -62,8 +62,6 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
private CommunityScoreDao communityScoreDao;
@Autowired
private AgencyScoreDao agencyScoreDao;
@Autowired
private ScreenCustomerAgencyDao customerAgencyDao;
/**
* @Description 计算街道相关总分
@ -128,7 +126,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
@ -143,11 +141,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
if (StringUtils.isEmpty(fieldName)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL, detail.getIndexCode()));
return;
} else if (mapList.size() == NumConstant.ONE) {
pid.put(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), mapList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(mapList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid);
return;
} else if (mapList.size() > NumConstant.ONE) {
}else{
MaxAndMinBigDecimalResultDTO maxAndMinBigDecimal = this.getMaxAndMinBigDecimal(mapList.stream().map(m -> new BigDecimal(m.get(fieldName).toString())).collect(Collectors.toList()));
List<List<Map<String, Object>>> publishArticleList = ListUtils.partition(mapList, IndexCalConstant.PAGE_SIZE);
publishArticleList.forEach(publish -> {
@ -158,16 +152,17 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldName))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(), result);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.DANG_JIAN_NENG_LI.getCode(),IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
agencyScoreDao.deleteOldRecord(customerId, monthId, IndexCalConstant.STREET_LEVEL);
deleteAndInsert(result);
return true;
}
@ -203,7 +198,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
index1SampleValues.add(s);
});
BigDecimalScoreCalculator sc = new BigDecimalScoreCalculator(maxAndMinBigDecimal.getMin(), maxAndMinBigDecimal.getMax(), ScoreConstants.MIN_SCORE, ScoreConstants.MAX_SCORE, Correlation.getCorrelation(detail.getCorrelation()));
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc);
indexInputVOS.add(index1VO);
});
}
@ -213,11 +208,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
if (CollectionUtils.isEmpty(communityGovernAbility)){
log.error(IndexCalConstant.STREET_GOVERN_ABILITY_NULL);
return;
}else if (communityGovernAbility.size() == NumConstant.ONE) {
pid.put(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityGovernAbility.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
return;
} else if (communityGovernAbility.size() > NumConstant.ONE) {
}else{
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
@ -234,16 +225,16 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), pid);
deleteAndInsert(customerId, monthId, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(), result);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.ZHI_LI_NENG_LI.getCode(),IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -280,7 +271,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
SampleValue s = new SampleValue(c.getAgencyId(), c.getScore());
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
@ -289,11 +280,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
if (CollectionUtils.isEmpty(communityActivityCountList)) {
log.error(IndexCalConstant.STREET_SERVICE_ABILITY_NULL);
return;
}else if (communityActivityCountList.size() == NumConstant.ONE) {
pid.put(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.PARENT_ID).toString());
sizeOne(communityActivityCountList.get(NumConstant.ZERO).get(IndexCalConstant.AGENCY_ID).toString(), customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid);
return;
} else if (communityActivityCountList.size() > NumConstant.ONE) {
}else{
String fieldNameByIndexCode = indexCodeFieldReService.getFieldNameByIndexCode(detail.getIndexCode());
if (StringUtils.isEmpty(fieldNameByIndexCode)) {
log.error(String.format(IndexCalConstant.INDEX_CODE_NULL,detail.getIndexCode()));
@ -310,17 +297,16 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
SampleValue s = new SampleValue((String) c.get(IndexCalConstant.AGENCY_ID), new BigDecimal(String.valueOf(c.get(fieldNameByIndexCode))));
index1SampleValues.add(s);
});
IndexInputVO index1VO = new IndexInputVO(detail.getIndexId(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
IndexInputVO index1VO = new IndexInputVO(detail.getIndexCode(), detail.getAllParentIndexCode(), index1SampleValues, detail.getThreshold(), detail.getWeight(), sc1);
indexInputVOS.add(index1VO);
});
}
}
});
BatchScoreCalculator batchScoreCalculator = new BatchScoreCalculator();
HashMap<String, BigDecimal> scoreCountOfSampleId = batchScoreCalculator.getScoreCountOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResult(scoreCountOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(), pid
);
deleteAndInsert(customerId, monthId, IndexCodeEnum.FU_WU_NENG_LI.getCode(), result);
HashMap<String, CalculateResult> scoreTotalOfSampleId = batchScoreCalculator.getScoreTotalOfSampleId(indexInputVOS);
List<AgencyScoreDTO> result = getResultB(scoreTotalOfSampleId, customerId, monthId, NumConstant.ZERO_STR, IndexCodeEnum.FU_WU_NENG_LI.getCode(),IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), pid);
deleteAndInsert(result);
return true;
}
@ -353,13 +339,14 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
score.setQuarterId(DateUtils.getQuarterId(monthId));
score.setIndexCode(IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode());
score.setDataType(IndexCalConstant.STREET_LEVEL);
score.setAllParentIndexCode(NumConstant.ZERO_STR);
value.forEach(street -> {
score.setScore(score.getScore().add(street.getScore()));
score.setParentAgencyId(street.getParentAgencyId());
});
result.add(score);
});
deleteAndInsert(customerId, monthId, IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode(), result);
deleteAndInsert(result);
return true;
}
@ -379,18 +366,14 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
}
/**
* @param customerId
* @param monthId
* @param indexCode
* @param subAllCommunityList
* @Description 先删除记录在插入
* @author zxc
* @date 2020/9/1 4:24 下午
*/
@Transactional(rollbackFor = Exception.class)
public void deleteAndInsert(String customerId, String monthId, String indexCode, List<AgencyScoreDTO> subAllCommunityList) {
public void deleteAndInsert(List<AgencyScoreDTO> subAllCommunityList) {
if (!CollectionUtils.isEmpty(subAllCommunityList)) {
agencyScoreDao.deleteOldRecord(customerId, monthId, indexCode,IndexCalConstant.STREET_LEVEL);
agencyScoreDao.insertStreetRecord(subAllCommunityList);
}
}
@ -405,7 +388,7 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
* @author zxc
* @date 2020/9/2 2:37 下午
*/
public List<AgencyScoreDTO> getResult(HashMap<String, BigDecimal> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, Map<String, String> pid) {
public List<AgencyScoreDTO> getResultB(HashMap<String, CalculateResult> scoreCountOfSampleId, String customerId, String monthId, String isTotal, String indexCode, String allParentIndexCode, Map<String, String> pid) {
List<AgencyScoreDTO> result = new ArrayList<>();
scoreCountOfSampleId.forEach((k, v) -> {
AgencyScoreDTO score = new AgencyScoreDTO();
@ -416,29 +399,37 @@ public class IndexCalculateStreetServiceImpl implements IndexCalculateStreetServ
score.setYearId(DateUtils.getYearId(monthId));
score.setIsTotal(isTotal);
score.setIndexCode(indexCode);
score.setScore(v);
score.setScore(v.getTotalScore());
score.setAllParentIndexCode(allParentIndexCode);
score.setDataType(IndexCalConstant.STREET_LEVEL);
pid.forEach((agency, parentAgency) -> {
if (k.equals(agency)) {
score.setParentAgencyId(parentAgency);
}
});
if (!CollectionUtils.isEmpty(v.getDetails())){
v.getDetails().forEach(streetScore -> {
AgencyScoreDTO s = new AgencyScoreDTO();
s.setCustomerId(customerId);
s.setAgencyId(k);
s.setMonthId(monthId);
s.setQuarterId(DateUtils.getQuarterId(monthId));
s.setYearId(DateUtils.getYearId(monthId));
s.setIsTotal(isTotal);
s.setIndexCode(streetScore.getIndexCode());
s.setScore(streetScore.getScore());
s.setDataType(IndexCalConstant.STREET_LEVEL);
s.setAllParentIndexCode(streetScore.getAllParentIndexCode());
pid.forEach((agency, parentAgency) -> {
if (k.equals(agency)) {
s.setParentAgencyId(parentAgency);
}
});
result.add(s);
});
}
result.add(score);
});
return result;
}
/**
* @param agencyId
* @param customerId
* @param monthId
* @Description 当查询结果为一条时调用此方法
* @author zxc
* @date 2020/9/2 2:40 下午
*/
public void sizeOne(String agencyId, String customerId, String monthId, String indexCode, Map<String, String> pid) {
HashMap<String, BigDecimal> scoreCountOfSample = new HashMap<>();
scoreCountOfSample.put(agencyId, new BigDecimal(NumConstant.FIFTY));
List<AgencyScoreDTO> result = getResult(scoreCountOfSample, customerId, monthId, NumConstant.ZERO_STR, indexCode, pid);
deleteAndInsert(customerId, monthId, indexCode, result);
}
}

365
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java

@ -226,7 +226,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
/**
* 目标将网格的 党建能力治理能力服务能力总指数 得分 整理后(4条合1条) 插入 指数-指数数据(月表)
* 如果网格相关分值表 中的网格数量不全需要从 网格(党支部)信息表 先查询到缺少的网格信息赋上默认值后在插入网格相关分值表 一对四
* 如果网格相关分值表 中的网格数量不全需要从 网格(党支部)信息表 先查询到缺少的网格信息赋上默认值后插入 指数-指数数据(月表)
*
* @param monthId
* @param customerId
@ -235,6 +235,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Date 13:44 2020-09-04
**/
private void startHandleIndexGridScore(String monthId, String customerId){
List<ScreenCustomerGridDTO> mismatchGridList = new ArrayList<>();
// 查询网格相关分值记录 表已经存在的网格id
List<String> indexGridIds = factIndexGridScoreDao.selectListGridId(customerId, monthId);
if (indexGridIds.size() > NumConstant.ZERO){
@ -244,25 +245,57 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
gridIds[i] = indexGridIds.get(i);
}
// 进行不匹配查询(即返回网格相关分值表 中不存在的网格信息)。
List<ScreenCustomerGridDTO> mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, gridIds);
// 将 网格相关分值表 中,本月份没有的网格信息,按照 4种类型,各新增一遍,赋默认值 0
if (mismatchGridList.size() > NumConstant.ZERO){
this.insertIndexGridScoreDefaultValue(monthId, customerId, mismatchGridList);
}
mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, gridIds);
} else {
// 将所有的网格按照 4种类型,各赋一遍默认值
List<ScreenCustomerGridDTO> mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, null);
this.insertIndexGridScoreDefaultValue(monthId, customerId, mismatchGridList);
mismatchGridList = screenCustomerGridDao.selectListMismatchGridInfo(customerId, null);
}
boolean delFlag = true;
if (!CollectionUtils.isEmpty(mismatchGridList)){
// 如果进行不匹配查询,查到了其他网格信息,一律赋默认值
this.insertIndexMonthlyByGridDefaultScore(monthId, customerId, mismatchGridList);
delFlag = false;
}
// 开始处理实际分数
// fact_index_grid_score 网格相关分值记录表 grid
List<FactIndexGridScoreDTO> gridScoreDTOS = factIndexGridScoreDao.selectListGridScore(customerId, monthId);
this.insertIndexDataMonthlyByGridScore(monthId, customerId, gridScoreDTOS);
// 开始处理实际分数
this.insertIndexDataMonthlyByGridScore(delFlag, monthId, customerId, gridScoreDTOS);
}
/**
* 将网格相关分值记录表中缺少的网格 数据赋默认值 插入月表 screenIndexDataMonthlyDao
*
* @param monthId 202008
* @param customerId 客户id
* @param gridScoreDTOS 网格相关分值记录表 当前客户不存在的网格数据集
* @return void
* @Author zhangyong
* @Date 14:17 2020-09-03
**/
private void insertIndexMonthlyByGridDefaultScore(String monthId, String customerId, List<ScreenCustomerGridDTO> gridScoreDTOS){
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
for (int i = NumConstant.ZERO; i < gridScoreDTOS.size(); i++){
IndexDataMonthlyFormDTO monthlyDTO = new IndexDataMonthlyFormDTO();
monthlyDTO.setIndexTotal(zero);
monthlyDTO.setPartyDevAblity(zero);
monthlyDTO.setServiceAblity(zero);
monthlyDTO.setGovernAblity(zero);
// 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScoreDTOS.get(i).getGridId(),
gridScoreDTOS.get(i).getParentAgencyId(), gridScoreDTOS.get(i).getGridName(), monthlyDTO);
monthlyFormDTOList.add(monthlyDTO);
}
int deleteNum;
do {
deleteNum = screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId,monthId);
} while (deleteNum != NumConstant.ZERO);
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
/**
* 将网格相关分值记录表 数据 插入月表 screenIndexDataMonthlyDao
*
* @param delFlag true: 执行删除语句false已经删过一次了本次只添加不删除
* @param monthId 202008
* @param customerId 客户id
* @param gridScoreDTOS 网格相关分值记录表 当前客户所属月份数据集
@ -270,7 +303,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Author zhangyong
* @Date 14:17 2020-09-03
**/
private void insertIndexDataMonthlyByGridScore(String monthId, String customerId, List<FactIndexGridScoreDTO> gridScoreDTOS){
private void insertIndexDataMonthlyByGridScore(boolean delFlag, String monthId, String customerId, List<FactIndexGridScoreDTO> gridScoreDTOS){
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据网格id进行分组,最后组装一条数据 一个网格 对应 4条数据
Map<String, List<FactIndexGridScoreDTO>> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId));
@ -313,14 +346,19 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, monthId);
if (delFlag){
int deleteNum;
do {
deleteNum = screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId,monthId);
} while (deleteNum != NumConstant.ZERO);
}
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
}
/**
* 目标将社区的 党建能力治理能力服务能力总指数 得分 整理后(4条合1条) 插入 指数-指数数据(月表)
* 如果社区相关分值表 中的社区数量不全需要从 组织机构信息 先查询到缺少的社区信息赋上默认值后在插入社区相关分值表 一对四
* 如果社区相关分值表 中的社区数量不全需要从 组织机构信息 先查询到缺少的社区信息赋上默认值后在插入 指数-指数数据(月表)
*
* @param monthId
* @param customerId
@ -329,6 +367,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Date 13:44 2020-09-04
**/
private void startHandleIndexCommunityScore(String monthId, String customerId){
List<ScreenCustomerAgencyEntity> mismatchAgencyList = new ArrayList<>();
// 查询社区相关分值记录id
List<String> indexCommunityIds = factIndexCommunityScoreDao.selectListCommunityId(customerId, monthId);
if (indexCommunityIds.size() > NumConstant.ZERO){
@ -338,23 +377,48 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
communityIds[i] = indexCommunityIds.get(i);
}
// 进行不匹配查询(即返回社区相关分值表 中不存在的社区信息)。
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, communityIds);
// 将 社区相关分数表 中,本月份没有的社区信息,按照 4种类型,各新增一遍,赋默认值 0
if (mismatchAgencyList.size() > NumConstant.ZERO){
this.insertIndexCommunityScoreDefaultValue(monthId, customerId, mismatchAgencyList);
}
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, communityIds);
} else {
// 将所有的社区按照 4种类型,各赋一遍默认值
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, null);
this.insertIndexCommunityScoreDefaultValue(monthId, customerId, mismatchAgencyList);
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, null);
}
if (!CollectionUtils.isEmpty(mismatchAgencyList)){
// 如果进行不匹配查询,查到了其他社区信息,一律赋默认值
this.insertIndexMonthlyByAgencyDefaultScore(monthId, customerId, mismatchAgencyList);
}
// 开始处理实际分数
// fact_index_community_score 社区相关分数表 agency
// 查询社区相关分值记录
List<FactIndexCommunityScoreDTO> communityScoreDTOS = factIndexCommunityScoreDao.selectListCommunityScore(customerId, monthId);
// 开始处理实际分数
this.insertIndexDataMonthlyByCommunityScore(monthId, customerId, communityScoreDTOS);
}
/**
* 社区相关分数表 中缺少的部门 数据赋默认值 插入月表 screenIndexDataMonthlyDao
*
* @param monthId 202008
* @param customerId 客户id
* @param communityScoreDTOS 社区相关分数表 当前客户不存在的网格数据集
* @return void
* @Author zhangyong
* @Date 14:17 2020-09-03
**/
private void insertIndexMonthlyByAgencyDefaultScore(String monthId, String customerId, List<ScreenCustomerAgencyEntity> communityScoreDTOS){
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
for (int i = NumConstant.ZERO; i < communityScoreDTOS.size(); i++){
IndexDataMonthlyFormDTO monthlyDTO = new IndexDataMonthlyFormDTO();
monthlyDTO.setIndexTotal(zero);
monthlyDTO.setPartyDevAblity(zero);
monthlyDTO.setServiceAblity(zero);
monthlyDTO.setGovernAblity(zero);
// 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, communityScoreDTOS.get(i).getAgencyId(),
communityScoreDTOS.get(i).getPid(), communityScoreDTOS.get(i).getAgencyName(), monthlyDTO);
monthlyFormDTOList.add(monthlyDTO);
}
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
/**
* 社区相关分数表 数据 插入月表 screenIndexDataMonthlyDao
*
@ -409,14 +473,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, monthId);
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
}
/**
* 目标将区直部门的 党建能力治理能力服务能力总指数 得分 整理后(4条合1条) 插入 指数-指数数据(月表)
* 如果 区直部门分值表 中的部门数量不全需要从 部门信息表 先查询到缺少的部门信息赋上默认值后在插入 区直部门分值表 一对四
* 如果 区直部门分值表 中的部门数量不全需要从 部门信息表 先查询到缺少的部门信息赋上默认值后在插入 指数-指数数据(月表)
*
* @param monthId
* @param customerId
@ -425,6 +488,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Date 13:44 2020-09-04
**/
private void startHandleIndexDeptScore(String monthId, String customerId){
List<ScreenCustomerDeptEntity> mismatchDeptList = new ArrayList<>();
// 查询社 区直部门分值表
List<String> indexDeptIds = deptScoreDao.selectListDeptId(customerId, monthId);
if (indexDeptIds.size() > NumConstant.ZERO){
@ -432,21 +496,48 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
for (int i = NumConstant.ZERO; i < indexDeptIds.size(); i++){
depeIds[i] = indexDeptIds.get(i);
}
List<ScreenCustomerDeptEntity> mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, depeIds);
if (mismatchDeptList.size() > NumConstant.ZERO){
this.insertIndexDeptScoreDefaultValueFor(monthId, customerId, mismatchDeptList);
}
mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, depeIds);
} else {
List<ScreenCustomerDeptEntity> mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, null);
this.insertIndexDeptScoreDefaultValueFor(monthId, customerId, mismatchDeptList);
mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, null);
}
if (!CollectionUtils.isEmpty(mismatchDeptList)){
// 如果进行不匹配查询,查到了其他部门信息,一律赋默认值
this.insertIndexMonthlyByDeptDefaultScore(monthId, customerId, mismatchDeptList);
}
// 开始处理实际分数
// fact_index_dept_score 区直部门分值表 department
// 查询社 区直部门分值表
List<DeptScoreDTO> deptScoreDTOS = deptScoreDao.selectListDeptScore(customerId, monthId);
// 开始处理实际分数
this.insertIndexDataMonthlyByDeptScore(monthId, customerId, deptScoreDTOS);
}
/**
* 区直部门分值表 中缺少的部门 数据赋默认值 插入月表 screenIndexDataMonthlyDao
*
* @param monthId 202008
* @param customerId 客户id
* @param deptScoreDTOS 区直部门分值表 当前客户不存在的部门数据集
* @return void
* @Author zhangyong
* @Date 14:17 2020-09-03
**/
private void insertIndexMonthlyByDeptDefaultScore(String monthId, String customerId, List<ScreenCustomerDeptEntity> deptScoreDTOS){
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
for (int i = NumConstant.ZERO; i < deptScoreDTOS.size(); i++){
IndexDataMonthlyFormDTO monthlyDTO = new IndexDataMonthlyFormDTO();
monthlyDTO.setIndexTotal(zero);
monthlyDTO.setPartyDevAblity(zero);
monthlyDTO.setServiceAblity(zero);
monthlyDTO.setGovernAblity(zero);
// 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, deptScoreDTOS.get(i).getDeptId(),
deptScoreDTOS.get(i).getParentAgencyId(), deptScoreDTOS.get(i).getDeptName(), monthlyDTO);
monthlyFormDTOList.add(monthlyDTO);
}
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
/**
* 将区直部门分值表 数据 插入月表 screenIndexDataMonthlyDao
*
@ -492,7 +583,6 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, monthId);
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
}
@ -508,23 +598,23 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Date 13:44 2020-09-04
**/
private void startHandleIndexAgencyScore(String monthId, String customerId){
List<ScreenCustomerAgencyEntity> mismatchAgencyList = new ArrayList<>();
List<String> indexAgencyIds = agencyScoreDaol.selectListAgencyId(customerId, monthId);
if (indexAgencyIds.size() > NumConstant.ZERO){
String[] agencyIds = new String[indexAgencyIds.size()];
for (int i = NumConstant.ZERO; i < indexAgencyIds.size(); i++){
agencyIds[i] = indexAgencyIds.get(i);
}
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, agencyIds);
if (mismatchAgencyList.size() > NumConstant.ZERO){
this.insertIndexAgencyScoreDefaultValueFor(monthId, customerId, mismatchAgencyList);
}
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, agencyIds);
} else {
List<ScreenCustomerAgencyEntity> mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, null);
this.insertIndexAgencyScoreDefaultValueFor(monthId, customerId, mismatchAgencyList);
mismatchAgencyList = screenCustomerAgencyDao.selectListMismatcAgencyInfo(customerId, null);
}
if (!CollectionUtils.isEmpty(mismatchAgencyList)){
this.insertIndexMonthlyByAgencyDefaultScore(monthId, customerId, mismatchAgencyList);
}
// 开始处理实际分数
// fact_index_agency_score 区/街道相关分数表 agency
List<AgencyScoreDTO> agencyScoreDTOS = agencyScoreDaol.selectListAgencyScore(customerId, monthId);
// 开始处理实际分数
this.insertIndexDataMonthlyByAgencyScore(monthId, customerId, agencyScoreDTOS);
}
@ -577,7 +667,6 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
monthlyFormDTOList.add(monthlyFormDTO);
}
if (monthlyFormDTOList.size() > NumConstant.ZERO){
screenIndexDataMonthlyDao.deleteIndexDataMonthly(customerId, monthId);
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
}
}
@ -647,195 +736,6 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
return monthlyFormDTO;
}
/**
* 新增 网格相关分值记录表 默认值一条网格按照组织类别的不同 需要插入4次
*
* @param monthId 202008
* @param customerId
* @param mismatchGridList 网格相关分值记录表 中缺少的网格集合
* @return void
* @Author zhangyong
* @Date 14:02 2020-09-04
**/
private void insertIndexGridScoreDefaultValue(String monthId, String customerId, List<ScreenCustomerGridDTO> mismatchGridList){
List<FactIndexGridScoreDTO> insertIndexGridScoreDTOS = new ArrayList<>();
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
for (ScreenCustomerGridDTO gridDTO : mismatchGridList){
FactIndexGridScoreDTO indexGridScoreDTO = new FactIndexGridScoreDTO();
// 赋默认值 - 党建能力指数
indexGridScoreDTO.setGridId(gridDTO.getGridId());
indexGridScoreDTO.setAgencyId(gridDTO.getParentAgencyId());
indexGridScoreDTO.setAllParentIds(gridDTO.getAllParentIds());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
indexGridScoreDTO.setQuarterId(DateUtils.getQuarterId(monthId));
indexGridScoreDTO.setYearId(getYearStr(monthId));
indexGridScoreDTO.setMonthId(monthId);
// 0 or 1
indexGridScoreDTO.setIsTotal(NumConstant.ZERO_STR);
indexGridScoreDTO.setScore(zero);
indexGridScoreDTO.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
indexGridScoreDTO.setDelFlag(NumConstant.ZERO_STR);
insertIndexGridScoreDTOS.add(indexGridScoreDTO);
FactIndexGridScoreDTO indexGridScoreDTO1 = ConvertUtils.sourceToTarget(indexGridScoreDTO, FactIndexGridScoreDTO.class);
// 赋默认值 - 治理能力
indexGridScoreDTO1.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
insertIndexGridScoreDTOS.add(indexGridScoreDTO1);
FactIndexGridScoreDTO indexGridScoreDTO2 = ConvertUtils.sourceToTarget(indexGridScoreDTO, FactIndexGridScoreDTO.class);
// 赋默认值 - 服务能力
indexGridScoreDTO2.setIndexCode(IndexCodeEnum.FU_WU_NENG_LI.getCode());
insertIndexGridScoreDTOS.add(indexGridScoreDTO2);
FactIndexGridScoreDTO indexGridScoreDTO3 = ConvertUtils.sourceToTarget(indexGridScoreDTO, FactIndexGridScoreDTO.class);
indexGridScoreDTO3.setIsTotal(NumConstant.ONE_STR);
// 赋默认值 - 网格相关
indexGridScoreDTO3.setIndexCode(IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode());
insertIndexGridScoreDTOS.add(indexGridScoreDTO3);
}
factIndexGridScoreDao.batchInsertGridScoreData(insertIndexGridScoreDTOS, customerId);
}
/**
* 新增 社区相关分数表 默认值一条组织id按照组织类别的不同 需要插入4次
*
* @param monthId
* @param customerId
* @param mismatchAgencyList
* @return void
* @Author zhangyong
* @Date 14:02 2020-09-04
**/
private void insertIndexCommunityScoreDefaultValue(String monthId, String customerId, List<ScreenCustomerAgencyEntity> mismatchAgencyList){
List<FactIndexCommunityScoreEntity> insertIndexCommunityScore = new ArrayList<>();
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
for (ScreenCustomerAgencyEntity agencyDTO : mismatchAgencyList){
FactIndexCommunityScoreEntity communityScore1 = new FactIndexCommunityScoreEntity();
// 赋默认值 - 党建能力指数
communityScore1.setAgencyId(agencyDTO.getAgencyId());
communityScore1.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
communityScore1.setQuarterId(DateUtils.getQuarterId(monthId));
communityScore1.setYearId(getYearStr(monthId));
communityScore1.setMonthId(monthId);
// 0 or 1
communityScore1.setIsTotal(NumConstant.ZERO_STR);
communityScore1.setScore(zero);
communityScore1.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
insertIndexCommunityScore.add(communityScore1);
// 赋默认值 - 治理能力
FactIndexCommunityScoreEntity communityScore2 = ConvertUtils.sourceToTarget(communityScore1, FactIndexCommunityScoreEntity.class);
communityScore2.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
insertIndexCommunityScore.add(communityScore2);
// 赋默认值 - 服务能力
FactIndexCommunityScoreEntity communityScore3 = ConvertUtils.sourceToTarget(communityScore1, FactIndexCommunityScoreEntity.class);
communityScore3.setIndexCode(IndexCodeEnum.FU_WU_NENG_LI.getCode());
insertIndexCommunityScore.add(communityScore3);
// 赋默认值 - 社区相关
FactIndexCommunityScoreEntity communityScore4 = ConvertUtils.sourceToTarget(communityScore1, FactIndexCommunityScoreEntity.class);
communityScore4.setIsTotal(NumConstant.ONE_STR);
communityScore4.setIndexCode(IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode());
insertIndexCommunityScore.add(communityScore4);
}
factIndexCommunityScoreDao.batchInsertCommunityScoreData(insertIndexCommunityScore, customerId);
}
/**
* 新增 区直部门分值表 默认值一条部门id按照组织类别的不同 需要插入1次
*
* @param monthId
* @param customerId
* @param mismatchDeptList
* @return void
* @Author zhangyong
* @Date 14:02 2020-09-04
**/
private void insertIndexDeptScoreDefaultValueFor(String monthId, String customerId, List<ScreenCustomerDeptEntity> mismatchDeptList){
List<DeptScoreEntity> insertIndexDeptScore = new ArrayList<>();
for (ScreenCustomerDeptEntity deptDTO : mismatchDeptList){
DeptScoreEntity deptScore2 = new DeptScoreEntity();
// 赋默认值 - 治理能力
deptScore2.setDeptId(deptDTO.getDeptId());
deptScore2.setAgencyId(deptDTO.getParentAgencyId());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
deptScore2.setQuarterId(DateUtils.getQuarterId(monthId));
deptScore2.setYearId(getYearStr(monthId));
deptScore2.setMonthId(monthId);
deptScore2.setIsTotal(NumConstant.ZERO_STR);
deptScore2.setScore(new BigDecimal(NumConstant.ZERO));
deptScore2.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
deptScore2.setDelFlag(NumConstant.ZERO_STR);
insertIndexDeptScore.add(deptScore2);
}
deptScoreDao.batchInsertDeptScoreData(insertIndexDeptScore, customerId);
}
/**
* 新增 /街道相关分数表 默认值一条组织id按照组织类别的不同 需要插入4次
*
* @param monthId
* @param customerId
* @param mismatchAgencyList
* @return void
* @Author zhangyong
* @Date 14:02 2020-09-04
**/
private void insertIndexAgencyScoreDefaultValueFor(String monthId, String customerId, List<ScreenCustomerAgencyEntity> mismatchAgencyList){
BigDecimal zero = new BigDecimal(NumConstant.ZERO);
List<AgencyScoreEntity> insertIndexAgencyScore = new ArrayList<>();
for (ScreenCustomerAgencyEntity agencyDTO : mismatchAgencyList){
if (OrgTypeConstant.COMMUNITY.equals(agencyDTO.getLevel()) || OrgTypeConstant.STREET.equals(agencyDTO.getLevel())
|| OrgTypeConstant.DISTRICT.equals(agencyDTO.getLevel())){
AgencyScoreEntity agencyScore1 = new AgencyScoreEntity();
// 赋默认值 - 党建能力指数
agencyScore1.setAgencyId(agencyDTO.getAgencyId());
agencyScore1.setParentAgencyId(agencyDTO.getPid());
//季度id: yyyyQ1、yyyyQ2、yyyyQ3、yyyyQ4
agencyScore1.setQuarterId(DateUtils.getQuarterId(monthId));
agencyScore1.setYearId(getYearStr(monthId));
agencyScore1.setMonthId(monthId);
// 0 or 1
agencyScore1.setIsTotal(NumConstant.ZERO_STR);
agencyScore1.setScore(zero);
agencyScore1.setIndexCode(IndexCodeEnum.DANG_JIAN_NENG_LI.getCode());
AgencyScoreEntity agencyScore2 = ConvertUtils.sourceToTarget(agencyScore1, AgencyScoreEntity.class);
// 赋默认值 - 治理能力
agencyScore2.setIndexCode(IndexCodeEnum.ZHI_LI_NENG_LI.getCode());
AgencyScoreEntity agencyScore3 = ConvertUtils.sourceToTarget(agencyScore1, AgencyScoreEntity.class);
// 赋默认值 - 服务能力
agencyScore3.setIndexCode(IndexCodeEnum.FU_WU_NENG_LI.getCode());
AgencyScoreEntity agencyScore4 = ConvertUtils.sourceToTarget(agencyScore1, AgencyScoreEntity.class);
agencyScore4.setIsTotal(NumConstant.ONE_STR);
if (OrgTypeConstant.COMMUNITY.equals(agencyDTO.getLevel())){
// 赋默认值 - 全区相关
agencyScore4.setIndexCode(IndexCodeEnum.QUAN_QU_XIANG_GUAN.getCode());
agencyScore4.setDataType(OrgTypeConstant.DISTRICT);
agencyScore1.setDataType(OrgTypeConstant.DISTRICT);
agencyScore2.setDataType(OrgTypeConstant.DISTRICT);
agencyScore3.setDataType(OrgTypeConstant.DISTRICT);
} else if (OrgTypeConstant.STREET.equals(agencyDTO.getLevel()) || OrgTypeConstant.DISTRICT.equals(agencyDTO.getLevel())){
// 赋默认值 - 街道相关
agencyScore4.setIndexCode(IndexCodeEnum.JIE_DAO_XIANG_GUAN.getCode());
agencyScore4.setDataType(OrgTypeConstant.STREET);
agencyScore1.setDataType(OrgTypeConstant.STREET);
agencyScore2.setDataType(OrgTypeConstant.STREET);
agencyScore3.setDataType(OrgTypeConstant.STREET);
}
insertIndexAgencyScore.add(agencyScore1);
insertIndexAgencyScore.add(agencyScore2);
insertIndexAgencyScore.add(agencyScore3);
insertIndexAgencyScore.add(agencyScore4);
}
}
agencyScoreDaol.batchInsertAgencyScoreData(insertIndexAgencyScore, customerId);
}
/**
* 根据年汇总今年各项得到计算平均值后 插入年表 screen_index_data_yearly
*
@ -848,7 +748,10 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
private void insertIndexDataYear(String monthId, String customerId){
List<IndexDataMonthlyFormDTO> monthlyFormList = screenIndexDataMonthlyDao.selectListIndexDataMonthlyByYear(customerId, getYearStr(monthId), getMonthStr(monthId));
if (monthlyFormList.size() > NumConstant.ZERO){
screenIndexDataYearlyDao.deleteIndexDataYearly(customerId, getYearStr(monthId));
int deleteNum;
do {
deleteNum = screenIndexDataYearlyDao.deleteIndexDataYearly(customerId, getYearStr(monthId));
} while (deleteNum != NumConstant.ZERO);
List<IndexDataYearlyFormDTO> entity = ConvertUtils.sourceToTarget(monthlyFormList, IndexDataYearlyFormDTO.class);
screenIndexDataYearlyDao.batchInsertIndexDataYearly(entity, customerId);
}

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ScreenCollService.java → epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/ShiBeiScreenCollService.java

@ -9,7 +9,7 @@ import java.util.List;
* @author yinzuomei@elink-cn.com
* @date 2020/8/18 10:25
*/
public interface ScreenCollService {
public interface ShiBeiScreenCollService {
/**
* 9党建引领|基层治理-居民党员积分排行榜

4
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ScreenCollServiceImpl.java → epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/ShiBeiScreenCollServiceImpl.java

@ -26,7 +26,7 @@ import com.epmet.dao.evaluationindex.screen.*;
import com.epmet.dto.screencoll.form.*;
import com.epmet.entity.evaluationindex.screen.ScreenEventImgDataEntity;
import com.epmet.entity.evaluationindex.screen.ScreenUserJoinEntity;
import com.epmet.service.evaluationindex.screen.ScreenCollService;
import com.epmet.service.evaluationindex.screen.ShiBeiScreenCollService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -45,7 +45,7 @@ import java.util.List;
*/
@Service
@DataSource(DataSourceConstant.EVALUATION_INDEX)
public class ScreenCollServiceImpl implements ScreenCollService {
public class ShiBeiScreenCollServiceImpl implements ShiBeiScreenCollService {
@Autowired
private ScreenPartyUserRankDataDao screenPartyUserRankDataDao;

10
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencyScoreDao.xml

@ -5,7 +5,7 @@
<!-- 【街道】中间表插入 -->
<insert id="insertStreetRecord">
INSERT INTO fact_index_agency_score (ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, DATA_TYPE, IS_TOTAL, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
INSERT INTO fact_index_agency_score (ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, DATA_TYPE, IS_TOTAL, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
@ -20,6 +20,7 @@
#{item.isTotal},
#{item.score},
#{item.indexCode},
#{item.allParentIndexCode},
#{item.delFlag},
#{item.revision},
#{item.createdBy},
@ -39,7 +40,6 @@
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = #{indexCode}
AND data_type = #{dataType}
</delete>
@ -79,9 +79,11 @@
del_flag = 0
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND IS_TOTAL = "0"
AND INDEX_CODE != "jiedaoxiangguan"
AND data_type = #{dataType}
AND IS_TOTAL = "0"
AND INDEX_CODE = "zhilinengli"
OR INDEX_CODE = "dangjiannengli"
OR INDEX_CODE = "fuwunengli"
</select>
<select id="selectAgencyScoreAvg" resultType="com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO">

160
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/AgencySubScoreDao.xml

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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.AgencySubScoreDao">
<!-- 【街道】中间表插入 -->
<insert id="insertStreetRecord">
INSERT INTO fact_index_agency_score (ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, DATA_TYPE, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
REPLACE ( UUID(), '-', '' ),
#{item.customerId},
#{item.agencyId},
#{item.parentAgencyId},
#{item.yearId},
#{item.quarterId},
#{item.monthId},
#{item.dataType},
#{item.score},
#{item.indexCode},
#{item.delFlag},
#{item.revision},
#{item.createdBy},
NOW(),
#{item.updatedBy},
NOW()
)
</foreach>
</insert>
<!-- 删除旧记录 -->
<delete id="deleteOldRecord">
DELETE
FROM
fact_index_agency_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = #{indexCode}
AND data_type = #{dataType}
</delete>
<select id="selectListAgencyScore" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">
SELECT
CUSTOMER_ID customerId,
AGENCY_ID agencyId,
PARENT_AGENCY_ID parentAgencyId,
YEAR_ID yearId,
MONTH_ID monthId,
SCORE score,
INDEX_CODE indexCode
FROM
fact_index_agency_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY AGENCY_ID
</select>
<!-- 查询街道相关信息 -->
<select id="selectAgencyScoreInfo" resultType="com.epmet.dto.indexcal.AgencyScoreDTO">
SELECT
CUSTOMER_ID,
AGENCY_ID,
MONTH_ID,
QUARTER_ID,
YEAR_ID,
SCORE,
INDEX_CODE,
PARENT_AGENCY_ID
FROM
fact_index_agency_score
WHERE
del_flag = 0
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND INDEX_CODE != "jiedaoxiangguan"
AND data_type = #{dataType}
</select>
<select id="selectAgencyScoreAvg" resultType="com.epmet.dto.indexcal.SubAgencyScoreAvgResultDTO">
SELECT
fics.agency_id,
fics.month_id,
fics.quarter_id,
fics.year_id,
ROUND(AVG( fics.score ),6) AS score,
fics.customer_id,
PARENT_AGENCY_ID AS parentId
FROM
fact_index_agency_score fics
WHERE
fics.del_flag = '0'
AND fics.customer_id = #{customerId}
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
AND fics.DATA_TYPE = #{dataType}
GROUP BY fics.parent_agency_id
</select>
<insert id="batchInsertAgencyScoreData" parameterType="map">
insert into fact_index_agency_score
(
ID,
CUSTOMER_ID,
AGENCY_ID,
PARENT_AGENCY_ID,
YEAR_ID,
QUARTER_ID,
MONTH_ID,
DATA_TYPE,
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.agencyId},
#{item.parentAgencyId},
#{item.yearId},
#{item.quarterId},
#{item.monthId},
#{item.dataType},
#{item.score},
#{item.indexCode},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
<select id="selectListAgencyId" resultType="String">
SELECT
AGENCY_ID agencyId
FROM
fact_index_agency_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY AGENCY_ID
</select>
</mapper>

8
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunityScoreDao.xml

@ -5,7 +5,7 @@
<!-- 党建能力【社区】中间表插入 -->
<insert id="insertCommunityPartyRecord">
INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, IS_TOTAL, SCORE, INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, IS_TOTAL, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
@ -19,6 +19,7 @@
#{item.isTotal},
#{item.score},
#{item.indexCode},
#{item.allParentIndexCode},
#{item.delFlag},
#{item.revision},
#{item.createdBy},
@ -38,7 +39,6 @@
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
AND index_code = #{indexCode}
</delete>
<!-- 查询社区相关信息 -->
@ -59,7 +59,9 @@
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND IS_TOTAL = "0"
AND INDEX_CODE != "shequxiangguan"
AND INDEX_CODE = "dangjiannengli"
OR INDEX_CODE = "zhilinengli"
OR INDEX_CODE = "fuwunengli"
</select>
<!-- 街道下级所有社区服务能力得分平均值 -->

156
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CommunitySubScoreDao.xml

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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.CommunitySubScoreDao">
<!-- 党建能力【社区】中间表插入 -->
<insert id="insertCommunityPartyRecord">
INSERT INTO fact_index_community_score ( ID, CUSTOMER_ID, AGENCY_ID, PARENT_AGENCY_ID, YEAR_ID, QUARTER_ID, MONTH_ID, SCORE, INDEX_CODE,ALL_PARENT_INDEX_CODE, DEL_FLAG, REVISION, CREATED_BY, CREATED_TIME, UPDATED_BY, UPDATED_TIME )
VALUES
<foreach collection="lists" item="item" separator=",">
(
REPLACE(UUID(),'-',''),
#{item.customerId},
#{item.agencyId},
#{item.parentAgencyId},
#{item.yearId},
#{item.quarterId},
#{item.monthId},
#{item.score},
#{item.indexCode},
#{item.allParentIndexCode},
#{item.delFlag},
#{item.revision},
#{item.createdBy},
NOW(),
#{item.updatedBy},
NOW()
)
</foreach>
</insert>
<!-- 删除旧记录 -->
<delete id="deleteOldRecord">
DELETE
FROM
fact_index_community_score
WHERE
del_flag = '0'
AND customer_id = #{customerId}
AND month_id = #{monthId}
</delete>
<!-- 查询社区相关信息 -->
<select id="selectCommunityInfo" resultType="com.epmet.dto.screen.FactIndexCommunityScoreDTO">
SELECT
CUSTOMER_ID,
AGENCY_ID,
MONTH_ID,
QUARTER_ID,
YEAR_ID,
SCORE,
INDEX_CODE,
PARENT_AGENCY_ID
FROM
fact_index_community_score
WHERE
del_flag = 0
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
AND INDEX_CODE = "dangjiannengli"
OR INDEX_CODE = "zhilinengli"
OR INDEX_CODE = "fuwunengli"
</select>
<!-- 街道下级所有社区服务能力得分平均值 -->
<select id="selectSubCommAvgScore" resultType="com.epmet.dto.indexcal.SubCommunityAvgResultDTO">
SELECT
fics.PARENT_AGENCY_ID AS agencyId,
fics.month_id,
fics.quarter_id,
fics.year_id,
ROUND(AVG( fics.score ),6) AS score,
fics.customer_id,
sca.pid AS parentId
FROM
fact_index_community_score fics
LEFT JOIN screen_customer_agency sca ON sca.AGENCY_ID = fics.PARENT_AGENCY_ID
WHERE
fics.del_flag = '0'
AND sca.DEL_FLAG = 0
AND fics.customer_id = #{customerId}
AND fics.month_id = #{monthId}
AND fics.index_code = #{indexCode}
GROUP BY fics.parent_agency_id
</select>
<select id="selectListCommunityScore" resultType="com.epmet.dto.screen.FactIndexCommunityScoreDTO">
SELECT
CUSTOMER_ID customerId,
AGENCY_ID agencyId,
PARENT_AGENCY_ID parentAgencyId,
YEAR_ID yearId,
MONTH_ID monthId,
SCORE score,
INDEX_CODE indexCode
FROM
fact_index_community_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY AGENCY_ID
</select>
<insert id="batchInsertCommunityScoreData" parameterType="map">
insert into fact_index_community_score
(
ID,
CUSTOMER_ID,
AGENCY_ID,
PARENT_AGENCY_ID,
YEAR_ID,
QUARTER_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.agencyId},
#{item.parentAgencyId},
#{item.yearId},
#{item.quarterId},
#{item.monthId},
#{item.score},
#{item.indexCode},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
<select id="selectListCommunityId" resultType="String">
SELECT
AGENCY_ID agencyId
FROM
fact_index_community_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY AGENCY_ID
</select>
</mapper>

7
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcScoreDao.xml

@ -32,7 +32,10 @@
select
CUSTOMER_ID,AGENCY_ID,GRID_ID,YEAR_ID,MONTH_ID,USER_ID,SCORE,INDEX_CODE FROM fact_index_cpc_score
WHERE
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR} and MONTH_ID = #{monthId,jdbcType=VARCHAR} AND IS_TOTAL = '0'
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
and MONTH_ID = #{monthId,jdbcType=VARCHAR}
and ALL_PARENT_INDEX_CODE = #{allParentCode,jdbcType=VARCHAR}
AND IS_TOTAL = '0'
</select>
@ -110,6 +113,7 @@
`IS_TOTAL`,
`SCORE`,
`INDEX_CODE`,
`ALL_PARENT_INDEX_CODE`,
`DEL_FLAG`,
`REVISION`,
`CREATED_BY`,
@ -130,6 +134,7 @@
#{item.isTotal},
#{item.score},
#{item.indexCode},
#{item.allParentIndexCode},
0,
0,
'APP_USER',

144
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/indexcal/CpcSubScoreDao.xml

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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.CpcSubScoreDao">
<delete id="deleteByMonthId">
delete from fact_index_cpc_score
where
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
and MONTH_ID = #{monthId,jdbcType=VARCHAR}
<if test="indexCode != null and indexCode !=''">
and INDEX_CODE = #{indexCode,jdbcType=VARCHAR}
</if>
</delete>
<resultMap type="com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity" id="cpcScoreMap">
<result property="id" column="ID"/>
<result property="customerId" column="CUSTOMER_ID"/>
<result property="agencyId" column="AGENCY_ID"/>
<result property="gridId" column="GRID_ID"/>
<result property="userId" column="USER_ID"/>
<result property="monthId" column="MONTH_ID"/>
<result property="delFlag" column="DEL_FLAG"/>
<result property="revision" column="REVISION"/>
<result property="createdBy" column="CREATED_BY"/>
<result property="createdTime" column="CREATED_TIME"/>
<result property="updatedBy" column="UPDATED_BY"/>
<result property="updatedTime" column="UPDATED_TIME"/>
</resultMap>
<select id="getPartScore" resultType="com.epmet.entity.evaluationindex.indexcal.CpcScoreEntity">
select
CUSTOMER_ID,AGENCY_ID,GRID_ID,YEAR_ID,MONTH_ID,USER_ID,SCORE,INDEX_CODE FROM fact_index_cpc_score
WHERE
CUSTOMER_ID = #{customerId,jdbcType=VARCHAR}
and MONTH_ID = #{monthId,jdbcType=VARCHAR}
and ALL_PARENT_INDEX_CODE = #{allParentCode,jdbcType=VARCHAR}
</select>
<!-- 获取网格内党员的联系群众能力考评分(平均值) -->
<select id="selectGridContactMassesAvgValue" parameterType="map" resultType="java.math.BigDecimal">
SELECT
round(AVG( SCORE ),6) AS AVG_CONTACT_MASSES_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
AND m.GRID_ID = #{gridId}
and m.INDEX_CODE='lianxiqunzhong'
GROUP BY
m.GRID_ID
</select>
<!-- 获取网格内党员的联系群众能力考评分(平均值)的最大值,最小值 -->
<select id="selectListGridContactMassesAvgValue" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultType="java.math.BigDecimal">
SELECT
round(AVG( SCORE ),6) AS AVG_CONTACT_MASSES_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
and m.INDEX_CODE='lianxiqunzhong'
GROUP BY
m.GRID_ID
</select>
<!-- 网格内党员的参与议事能力考评分(平均值) 最大值最小值 -->
<select id="selectListJoinIssueAvgValue" parameterType="com.epmet.dto.indexcal.CalculateCommonFormDTO" resultType="java.math.BigDecimal">
SELECT
round(AVG( SCORE ),6) AS AVG_JOIN_ISSUE_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
and m.INDEX_CODE='canyuyishi'
GROUP BY
m.GRID_ID
</select>
<!-- -->
<select id="selectGridJoinIssueAvgValue" parameterType="map" resultType="java.math.BigDecimal">
SELECT
round(AVG( SCORE ),6) AS AVG_CONTACT_MASSES_SCORE
FROM
fact_index_cpc_score m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID =#{customerId}
AND m.MONTH_ID = #{monthId}
AND m.GRID_ID = #{gridId}
and m.INDEX_CODE='canyuyishi'
GROUP BY
m.GRID_ID
</select>
<insert id="insertBatch">
INSERT INTO `fact_index_cpc_score` (
`ID`,
`CUSTOMER_ID`,
`GRID_ID`,
`AGENCY_ID`,
`YEAR_ID`,
`MONTH_ID`,
`USER_ID`,
`SCORE`,
`INDEX_CODE`,
`ALL_PARENT_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),
#{item.customerId},
#{item.gridId},
#{item.agencyId},
#{item.yearId},
#{item.monthId},
#{item.userId},
#{item.score},
#{item.indexCode},
#{item.allParentIndexCode},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</foreach>
</insert>
</mapper>

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

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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
(
ID,
CUSTOMER_ID,
DEPT_ID,
AGENCY_ID,
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.deptId},
#{item.agencyId},
#{item.quarterId},
#{item.yearId},
#{item.monthId},
#{item.score},
#{item.indexCode},
#{item.delFlag},
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</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>

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

@ -0,0 +1,188 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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.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` (
`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),
#{item.customerId},
#{item.gridId},
#{item.agencyId},
#{item.allParentIds},
#{item.quarterId},
#{item.yearId},
#{item.monthId},
#{item.isTotal},
#{item.score},
#{item.indexCode},
0,
0,
'APP_USER',
now(),
'APP_USER',
now()
)
</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
FROM
fact_index_grid_score
WHERE
DEL_FLAG = '0'
AND CUSTOMER_ID = #{customerId}
AND MONTH_ID = #{monthId}
ORDER BY GRID_ID
</select>
</mapper>
Loading…
Cancel
Save