Browse Source

Merge remote-tracking branch 'remotes/origin/dev_screen_data_2.0' into dev_screen_data_an_2.0

master
jianjun 5 years ago
parent
commit
cbcd9970ef
  1. 31
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AdvancedBranchRankFormDTO.java
  2. 53
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/IndexAdvanceBranchRankResultDTO.java
  3. 11
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java
  4. 7
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java
  5. 7
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/IndexService.java
  6. 28
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java
  7. 22
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml
  8. 5
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/screencoll/form/IndexDataMonthlyFormDTO.java
  9. 45
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java
  10. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java
  11. 2
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenIndexDataMonthlyEntity.java
  12. 72
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  13. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  14. 3
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml
  15. 8
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml

31
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/form/AdvancedBranchRankFormDTO.java

@ -0,0 +1,31 @@
package com.epmet.evaluationindex.screen.dto.form;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import java.io.Serializable;
/**
* 先进排行-先进支部排行--接口入参
* @Author sun
*/
@Data
public class AdvancedBranchRankFormDTO implements Serializable {
private static final long serialVersionUID = -8674763412362557239L;
/**
* 机关Id
* */
@NotBlank(message = "机关Id不能为空" , groups = AdvancedBranchRankFormDTO.AddUserInternalGroup.class)
private String agencyId;
/**
* 显示多少条
* */
@Min(value = 1, message = "查询条数必须大于0", groups = {AdvancedBranchRankFormDTO.AddUserInternalGroup.class })
private Integer topNum;
/**
* 月份Id
* */
private String monthId;
public interface AddUserInternalGroup {}
}

53
epmet-module/data-report/data-report-client/src/main/java/com/epmet/evaluationindex/screen/dto/result/IndexAdvanceBranchRankResultDTO.java

@ -0,0 +1,53 @@
package com.epmet.evaluationindex.screen.dto.result;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 先进排行-先进支部排行--接口返参
*
* @Author sun
*/
@Data
public class IndexAdvanceBranchRankResultDTO implements Serializable {
private static final long serialVersionUID = 330099297596334388L;
/**
* 名称 XXXX社区党委
*/
private String name;
/**
* 指标得分
*/
@JsonIgnore
private String totalScore;
private BigDecimal scroe;
/**
* 党员数
*/
private Integer partyMemberNum;
/**
* 议题数
*/
private Integer issueNum;
/**
* 项目数
*/
private Integer projectNum;
/**
* 满意度 90.64% 返回字符串前端直接显示
*/
private String satisfactionRatio;
/**
* 结案率 94.3% 返回字符串前端直接显示
*/
private String closedProjectRatio;
}

11
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/screen/IndexController.java

@ -113,5 +113,16 @@ public class IndexController {
return new Result<IndexScoreResultDTO>().ok(indexService.indexScore(formDTO)); return new Result<IndexScoreResultDTO>().ok(indexService.indexScore(formDTO));
} }
/**
* @param formDTO
* @Description 先进排行-先进支部排行
* @author sun
*/
@PostMapping("advancedbranchrank")
Result<List<IndexAdvanceBranchRankResultDTO>> advancedBranchRank(@RequestBody AdvancedBranchRankFormDTO formDTO){
ValidatorUtils.validateEntity(formDTO, AdvancedBranchRankFormDTO.AddUserInternalGroup.class);
return new Result<List<IndexAdvanceBranchRankResultDTO>>().ok(indexService.advancedBranchRank(formDTO));
}
} }

7
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java

@ -88,4 +88,11 @@ public interface ScreenIndexDataMonthlyDao{
* @author sun * @author sun
*/ */
IndexScoreResultDTO selectMonthData(IndexScoreFormDTO formDTO); IndexScoreResultDTO selectMonthData(IndexScoreFormDTO formDTO);
/**
* @param formDTO
* @Description 先进排行-先进支部排行
* @author sun
*/
List<IndexAdvanceBranchRankResultDTO> selectRankList(AdvancedBranchRankFormDTO formDTO);
} }

7
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/IndexService.java

@ -69,4 +69,11 @@ public interface IndexService {
* @author sun * @author sun
*/ */
IndexScoreResultDTO indexScore(IndexScoreFormDTO formDTO); IndexScoreResultDTO indexScore(IndexScoreFormDTO formDTO);
/**
* @param formDTO
* @Description 先进排行-先进支部排行
* @author sun
*/
List<IndexAdvanceBranchRankResultDTO> advancedBranchRank(AdvancedBranchRankFormDTO formDTO);
} }

28
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/IndexServiceImpl.java

@ -11,9 +11,11 @@ import com.epmet.evaluationindex.screen.constant.ScreenConstant;
import com.epmet.evaluationindex.screen.dto.form.*; import com.epmet.evaluationindex.screen.dto.form.*;
import com.epmet.evaluationindex.screen.dto.result.*; import com.epmet.evaluationindex.screen.dto.result.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.jsoup.helper.DataUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.unit.DataUnit;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.text.NumberFormat; import java.text.NumberFormat;
@ -298,4 +300,30 @@ public class IndexServiceImpl implements IndexService {
return resultDTO; return resultDTO;
} }
/**
* @param formDTO
* @Description 先进排行-先进支部排行
* @author sun
*/
@Override
public List<IndexAdvanceBranchRankResultDTO> advancedBranchRank(AdvancedBranchRankFormDTO formDTO) {
//根据当前所选组织,查询screen_index_data_monthly中类型为网格的按照总指数倒序,关联screen_org_rank_data表取其他数据
//1.级联查询组织下所有网格的先进支部排行数据,按总指数降序
formDTO.setMonthId(DateUtils.getBeforeNMonth(1));
List<IndexAdvanceBranchRankResultDTO> list = screenIndexDataMonthlyDao.selectRankList(formDTO);
//2.遍历数据,小数保留一位小数,百分数添加百分号
NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMaximumFractionDigits(1);
list.forEach(l->{
BigDecimal num = new BigDecimal(l.getTotalScore()).setScale(1, BigDecimal.ROUND_HALF_UP).stripTrailingZeros();
l.setScroe(num);
BigDecimal num1 = new BigDecimal(l.getSatisfactionRatio()).setScale(1, BigDecimal.ROUND_HALF_UP);
l.setSatisfactionRatio(num1 + "%");
BigDecimal num2 = new BigDecimal(l.getClosedProjectRatio()).setScale(1, BigDecimal.ROUND_HALF_UP);
l.setClosedProjectRatio(num2 + "%");
});
return list;
}
} }

22
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenIndexDataMonthlyDao.xml

@ -193,4 +193,26 @@
AND month_id = #{monthId} AND month_id = #{monthId}
</select> </select>
<select id="selectRankList" resultType="com.epmet.evaluationindex.screen.dto.result.IndexAdvanceBranchRankResultDTO">
SELECT
dm.org_name AS "name",
dm.index_total AS "totalScore",
rd.party_total AS "partyMemberNum",
rd.issue_total AS "issueNum",
rd.project_total AS "projectNum",
rd.close_project_ratio AS "closedProjectRatio",
rd.satisfaction_ratio AS "satisfactionRatio"
FROM
screen_index_data_monthly dm
INNER JOIN screen_org_rank_data rd ON dm.org_id = rd.org_id
AND dm.month_id = rd.month_id
WHERE
dm.del_flag = '0'
AND rd.del_flag = '0'
AND dm.org_type = 'grid'
AND dm.month_id = #{monthId}
AND dm.all_parent_ids LIKE concat('%', #{agencyId}, '%')
ORDER BY dm.index_total DESC
</select>
</mapper> </mapper>

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

@ -41,6 +41,11 @@ public class IndexDataMonthlyFormDTO implements Serializable {
*/ */
private String parentId; private String parentId;
/**
* 所有上级ID用英文逗号分开
*/
private String allParentIds;
/** /**
* 组织名称 * 组织名称
*/ */

45
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java

@ -11,21 +11,23 @@ import com.epmet.dao.evaluationindex.indexcal.GridScoreDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyDao;
import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyDao; import com.epmet.dao.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao; import com.epmet.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.dao.evaluationindex.screen.ScreenIndexDataMonthlyDao;
import com.epmet.dao.stats.DimCustomerDao; import com.epmet.dao.stats.DimCustomerDao;
import com.epmet.dao.stats.DimDateDao; import com.epmet.dao.stats.DimDateDao;
import com.epmet.dao.stats.DimMonthDao; import com.epmet.dao.stats.DimMonthDao;
import com.epmet.dto.AgencySubTreeDto; import com.epmet.dto.AgencySubTreeDto;
import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractOriginFormDTO;
import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO;
import com.epmet.dto.extract.form.ScreenExtractFormDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO;
import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyEntity; import com.epmet.entity.evaluationindex.indexcoll.FactIndexGovrnAblityGridMonthlyEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyEntity; import com.epmet.entity.evaluationindex.indexcoll.FactIndexPartyAblityGridMonthlyEntity;
import com.epmet.entity.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyEntity; import com.epmet.entity.evaluationindex.indexcoll.FactIndexServiceAblityGridMonthlyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity; import com.epmet.entity.evaluationindex.screen.ScreenCustomerGridEntity;
import com.epmet.entity.evaluationindex.screen.ScreenIndexDataMonthlyEntity;
import com.epmet.entity.stats.DimAgencyEntity; import com.epmet.entity.stats.DimAgencyEntity;
import com.epmet.entity.stats.DimCustomerEntity; import com.epmet.entity.stats.DimCustomerEntity;
import com.epmet.entity.stats.DimDateEntity; import com.epmet.entity.stats.DimDateEntity;
@ -37,8 +39,6 @@ import com.epmet.service.evaluationindex.extract.dataToIndex.IndexCollCommunityS
import com.epmet.service.evaluationindex.extract.dataToIndex.IndexCollStreetService; import com.epmet.service.evaluationindex.extract.dataToIndex.IndexCollStreetService;
import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectLogDailyService; import com.epmet.service.evaluationindex.extract.todata.FactOriginProjectLogDailyService;
import com.epmet.service.evaluationindex.extract.todata.FactOriginTopicMainDailyService; import com.epmet.service.evaluationindex.extract.todata.FactOriginTopicMainDailyService;
import com.epmet.service.evaluationindex.extract.todata.GroupExtractService;
import com.epmet.service.evaluationindex.extract.todata.ProjectExtractService;
import com.epmet.service.evaluationindex.extract.toscreen.*; import com.epmet.service.evaluationindex.extract.toscreen.*;
import com.epmet.service.evaluationindex.indexcal.*; import com.epmet.service.evaluationindex.indexcal.*;
import com.epmet.service.stats.DimAgencyService; import com.epmet.service.stats.DimAgencyService;
@ -718,5 +718,42 @@ public class DemoController {
} }
@Autowired
private ScreenIndexDataMonthlyDao screenIndexDataMonthlyDao;
@Autowired
private ScreenCustomerAgencyDao screenCustomerAgencyDao;
/**
* @return com.epmet.commons.tools.utils.Result
* @param
* @author yinzuomei
* @description screen_index_data_monthly 赋值ALL_PARENT_IDS
* @Date 2020/10/10 17:59
**/
@DataSource(DataSourceConstant.EVALUATION_INDEX)
@PostMapping("updateDeptIndexMonthly")
public Result updateDeptIndexMonthly(){
QueryWrapper<ScreenIndexDataMonthlyEntity> wrapper = new QueryWrapper<>();
wrapper.eq("ORG_TYPE", "department");
List<ScreenIndexDataMonthlyEntity> list=screenIndexDataMonthlyDao.selectList(wrapper);
int updateNum=0;
for(ScreenIndexDataMonthlyEntity entity:list){
if(StringUtils.isNotBlank(entity.getParentId())){
ScreenCustomerAgencyEntity agencyEntity=screenCustomerAgencyDao.selectByAgencyId(entity.getParentId());
if(null!=agencyEntity){
//根组织下的部门
if("0".equals(agencyEntity.getPid())){
log.info("根组织下的部门");
entity.setAllParentIds(agencyEntity.getAgencyId());
}else{
entity.setAllParentIds(agencyEntity.getPids().concat(",").concat(agencyEntity.getAgencyId()));
}
updateNum+=screenIndexDataMonthlyDao.updateParentIdsById(entity.getId(),entity.getAllParentIds());
}
}
}
log.info("影响行数="+updateNum);
return new Result();
}
} }

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java

@ -95,4 +95,6 @@ public interface ScreenIndexDataMonthlyDao extends BaseDao<ScreenIndexDataMonthl
Integer deleteIndexDataMonthlyByOrgType(@Param("customerId") String customerId, Integer deleteIndexDataMonthlyByOrgType(@Param("customerId") String customerId,
@Param("monthId") String monthId, @Param("monthId") String monthId,
@Param("orgType") String orgType); @Param("orgType") String orgType);
int updateParentIdsById(@Param("id") String id, @Param("allParentIds") String allParentIds);
} }

2
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/entity/evaluationindex/screen/ScreenIndexDataMonthlyEntity.java

@ -109,4 +109,6 @@ public class ScreenIndexDataMonthlyEntity extends BaseEpmetEntity {
* 治理能力分数权重 * 治理能力分数权重
*/ */
private BigDecimal governAblityWeight; private BigDecimal governAblityWeight;
private String allParentIds;
} }

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

@ -2,6 +2,7 @@ package com.epmet.service.evaluationindex.indexcoll.impl;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; import com.epmet.commons.dynamic.datasource.annotation.DataSource;
import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.constant.DataSourceConstant; import com.epmet.constant.DataSourceConstant;
import com.epmet.constant.OrgTypeConstant; import com.epmet.constant.OrgTypeConstant;
@ -23,16 +24,20 @@ import com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity;
import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity; import com.epmet.entity.evaluationindex.screen.ScreenCustomerDeptEntity;
import com.epmet.eum.IndexCodeEnum; import com.epmet.eum.IndexCodeEnum;
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService;
import com.google.common.cache.Cache;
import com.google.common.cache.CacheBuilder;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -43,6 +48,7 @@ import java.util.stream.Collectors;
@Service @Service
@DataSource(DataSourceConstant.EVALUATION_INDEX) @DataSource(DataSourceConstant.EVALUATION_INDEX)
public class FactIndexCollectServiceImpl implements FactIndexCollectService { public class FactIndexCollectServiceImpl implements FactIndexCollectService {
Cache<String, String> allParentIds = CacheBuilder.newBuilder().expireAfterWrite(2, TimeUnit.HOURS).build();
@Autowired @Autowired
private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao; private FactIndexPartyAblityCpcMonthlyDao factIndexPartyAblityCpcMonthlyDao;
@ -219,6 +225,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly // 根据年,汇总今年各项得到,计算平均值后 插入年表 screen_index_data_yearly
this.insertIndexDataYear(monthId, customerId); this.insertIndexDataYear(monthId, customerId);
allParentIds.invalidateAll();
} }
/** /**
@ -283,6 +290,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段 // 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScoreDTOS.get(i).getGridId(), monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScoreDTOS.get(i).getGridId(),
gridScoreDTOS.get(i).getParentAgencyId(), gridScoreDTOS.get(i).getGridName(), monthlyDTO); gridScoreDTOS.get(i).getParentAgencyId(), gridScoreDTOS.get(i).getGridName(), monthlyDTO);
monthlyDTO.setAllParentIds(gridScoreDTOS.get(i).getAllParentIds());
monthlyFormDTOList.add(monthlyDTO); monthlyFormDTOList.add(monthlyDTO);
} }
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
@ -298,21 +306,26 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Author zhangyong * @Author zhangyong
* @Date 14:17 2020-09-03 * @Date 14:17 2020-09-03
**/ **/
private void insertIndexDataMonthlyByGridScore(String monthId, String customerId, List<FactIndexGridScoreDTO> gridScoreDTOS){ private void insertIndexDataMonthlyByGridScore(String monthId, String customerId, List<FactIndexGridScoreDTO> gridScoreDTOS) {
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>(); List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据网格id进行分组,最后组装一条数据 一个网格 对应 4条数据 // 根据网格id进行分组,最后组装一条数据 一个网格 对应 4条数据
Map<String, List<FactIndexGridScoreDTO>> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId)); Map<String, List<FactIndexGridScoreDTO>> collect = gridScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexGridScoreDTO::getGridId));
// 查询网格的 上级组织id 和 组织名称 // 查询网格的 上级组织id 和 组织名称
List<ScreenCustomerGridDTO> parentGridList = screenCustomerGridDao.selectListGridInfo(customerId); List<ScreenCustomerGridDTO> parentGridList = screenCustomerGridDao.selectListGridInfo(customerId);
for(Map.Entry<String,List<FactIndexGridScoreDTO>> gridScore : collect.entrySet()){ if (!CollectionUtils.isEmpty(parentGridList)) {
parentGridList.forEach(o -> {
allParentIds.put(o.getGridId(), o.getGridId());
});
}
for (Map.Entry<String, List<FactIndexGridScoreDTO>> gridScore : collect.entrySet()) {
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO();
// 给4个指数 赋默认值 // 给4个指数 赋默认值
monthlyFormDTO = this.setIndexDefaultValueFor(monthlyFormDTO); monthlyFormDTO = this.setIndexDefaultValueFor(monthlyFormDTO);
for ( int i = 0; i < gridScore.getValue().size(); i++){ for (int i = 0; i < gridScore.getValue().size(); i++) {
if (NumConstant.ONE_STR.equals(gridScore.getValue().get(i).getIsTotal())){ if (NumConstant.ONE_STR.equals(gridScore.getValue().get(i).getIsTotal())) {
// 是总分 // 是总分
if (IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode().equals(gridScore.getValue().get(i).getIndexCode())){ if (IndexCodeEnum.WANG_GE_XIANG_GUAN.getCode().equals(gridScore.getValue().get(i).getIndexCode())) {
// 总指数 = 网格相关 // 总指数 = 网格相关
monthlyFormDTO.setIndexTotal(gridScore.getValue().get(i).getScore()); monthlyFormDTO.setIndexTotal(gridScore.getValue().get(i).getScore());
} }
@ -339,6 +352,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段 // 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(), monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.GRID, gridScore.getKey(),
parentAgencyId, gridName, monthlyFormDTO); parentAgencyId, gridName, monthlyFormDTO);
monthlyFormDTO.setAllParentIds(allParentIds.getIfPresent(monthlyFormDTO.getOrgId()));
monthlyFormDTOList.add(monthlyFormDTO); monthlyFormDTOList.add(monthlyFormDTO);
} }
if (monthlyFormDTOList.size() > NumConstant.ZERO){ if (monthlyFormDTOList.size() > NumConstant.ZERO){
@ -409,6 +423,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段 // 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScoreDTOS.get(i).getAgencyId(), monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScoreDTOS.get(i).getAgencyId(),
communityScoreDTOS.get(i).getPid(), communityScoreDTOS.get(i).getAgencyName(), monthlyDTO); communityScoreDTOS.get(i).getPid(), communityScoreDTOS.get(i).getAgencyName(), monthlyDTO);
monthlyDTO.setAllParentIds(communityScoreDTOS.get(i).getPids());
monthlyFormDTOList.add(monthlyDTO); monthlyFormDTOList.add(monthlyDTO);
} }
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
@ -424,20 +439,25 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Author zhangyong * @Author zhangyong
* @Date 14:17 2020-09-03 * @Date 14:17 2020-09-03
**/ **/
private void insertIndexDataMonthlyByCommunityScore(String monthId, String customerId, List<FactIndexCommunityScoreDTO> communityScoreDTOS){ private void insertIndexDataMonthlyByCommunityScore(String monthId, String customerId, List<FactIndexCommunityScoreDTO> communityScoreDTOS) {
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>(); List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据组织id 进行分组,最后组装一条数据 一个组织id 对应 4条数据 // 根据组织id 进行分组,最后组装一条数据 一个组织id 对应 4条数据
Map<String, List<FactIndexCommunityScoreDTO>> collect = communityScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId)); Map<String, List<FactIndexCommunityScoreDTO>> collect = communityScoreDTOS.stream().collect(Collectors.groupingBy(FactIndexCommunityScoreDTO::getAgencyId));
// 根据客户id,查询区/街道 组织名称、id // 根据客户id,查询区/街道 组织名称、id
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId); List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId);
for(Map.Entry<String,List<FactIndexCommunityScoreDTO>> communityScore : collect.entrySet()){ if (!CollectionUtils.isEmpty(parentAgencyList)) {
parentAgencyList.forEach(o -> {
allParentIds.put(o.getAgencyId(), o.getPids());
});
}
for (Map.Entry<String, List<FactIndexCommunityScoreDTO>> communityScore : collect.entrySet()) {
IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO(); IndexDataMonthlyFormDTO monthlyFormDTO = new IndexDataMonthlyFormDTO();
// 给4个指数 赋默认值 // 给4个指数 赋默认值
monthlyFormDTO = this.setIndexDefaultValueFor(monthlyFormDTO); monthlyFormDTO = this.setIndexDefaultValueFor(monthlyFormDTO);
for ( int i = 0; i < communityScore.getValue().size(); i++){ for (int i = 0; i < communityScore.getValue().size(); i++) {
if (NumConstant.ONE_STR.equals(communityScore.getValue().get(i).getIsTotal())){ if (NumConstant.ONE_STR.equals(communityScore.getValue().get(i).getIsTotal())) {
// 是总分 // 是总分
if (IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode().equals(communityScore.getValue().get(i).getIndexCode())){ if (IndexCodeEnum.SHE_QU_XIANG_GUAN.getCode().equals(communityScore.getValue().get(i).getIndexCode())) {
// 总指数 = 社区相关 // 总指数 = 社区相关
monthlyFormDTO.setIndexTotal(communityScore.getValue().get(i).getScore()); monthlyFormDTO.setIndexTotal(communityScore.getValue().get(i).getScore());
} }
@ -465,6 +485,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段 // 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScore.getKey(), monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, communityScore.getKey(),
parentAgencyId, agencyName, monthlyFormDTO); parentAgencyId, agencyName, monthlyFormDTO);
monthlyFormDTO.setAllParentIds(allParentIds.getIfPresent(monthlyFormDTO.getOrgId()));
// 补充表中其他字段 // 补充表中其他字段
monthlyFormDTOList.add(monthlyFormDTO); monthlyFormDTOList.add(monthlyFormDTO);
} }
@ -497,7 +518,13 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, null); mismatchDeptList = screenCustomerDeptDao.selectListMismatchDeptInfo(customerId, null);
} }
if (!CollectionUtils.isEmpty(mismatchDeptList)){ if (!CollectionUtils.isEmpty(mismatchDeptList)) {
mismatchDeptList.forEach(o -> {
String pids = allParentIds.getIfPresent(o.getParentAgencyId());
if (!StringUtils.isEmpty(pids)) {
allParentIds.put(o.getDeptId(), pids.concat(StrConstant.COLON).concat(o.getParentAgencyId()));
}
});
// 如果进行不匹配查询,查到了其他部门信息,一律赋默认值 // 如果进行不匹配查询,查到了其他部门信息,一律赋默认值
this.insertIndexMonthlyByDeptDefaultScore(monthId, customerId, mismatchDeptList); this.insertIndexMonthlyByDeptDefaultScore(monthId, customerId, mismatchDeptList);
} }
@ -534,6 +561,7 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
// 补充表中其他字段 // 补充表中其他字段
monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScoreDTOS.get(i).getDeptId(), monthlyDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScoreDTOS.get(i).getDeptId(),
deptScoreDTOS.get(i).getParentAgencyId(), deptScoreDTOS.get(i).getDeptName(), monthlyDTO); deptScoreDTOS.get(i).getParentAgencyId(), deptScoreDTOS.get(i).getDeptName(), monthlyDTO);
monthlyDTO.setAllParentIds(allParentIds.getIfPresent(monthlyDTO.getOrgId()));
monthlyFormDTOList.add(monthlyDTO); monthlyFormDTOList.add(monthlyDTO);
} }
screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId); screenIndexDataMonthlyDao.batchInsertIndexDataMonthly(monthlyFormDTOList, customerId);
@ -579,12 +607,17 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
deptName = deptEntity.getDeptName(); deptName = deptEntity.getDeptName();
} }
} }
if ("".equals(parentAgencyId)){ if ("".equals(parentAgencyId)) {
throw new RuntimeException("在screen_customer_dept表中未查询到该客户下的父级信息:customerId =" + customerId + ", deptId = " + deptScore.getKey()); throw new RuntimeException("在screen_customer_dept表中未查询到该客户下的父级信息:customerId =" + customerId + ", deptId = " + deptScore.getKey());
} }
// 补充表中其他字段 // 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScore.getKey(), monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.DEPARTMENT, deptScore.getKey(),
parentAgencyId, deptName, monthlyFormDTO); parentAgencyId, deptName, monthlyFormDTO);
//部门表没有 allParentIds 所以直接获取 然后拼接
String ppIds = allParentIds.getIfPresent(monthlyFormDTO.getParentId());
if (!StringUtils.isEmpty(ppIds)) {
monthlyFormDTO.setAllParentIds(ppIds.concat(StrConstant.COLON).concat(monthlyFormDTO.getParentId()));
}
monthlyFormDTOList.add(monthlyFormDTO); monthlyFormDTOList.add(monthlyFormDTO);
} }
if (monthlyFormDTOList.size() > NumConstant.ZERO){ if (monthlyFormDTOList.size() > NumConstant.ZERO){
@ -634,13 +667,18 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
* @Author zhangyong * @Author zhangyong
* @Date 14:17 2020-09-03 * @Date 14:17 2020-09-03
**/ **/
private void insertIndexDataMonthlyByAgencyScore(String monthId, String customerId, List<AgencyScoreDTO> agencyScoreDTOS){ private void insertIndexDataMonthlyByAgencyScore(String monthId, String customerId, List<AgencyScoreDTO> agencyScoreDTOS) {
List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>(); List<IndexDataMonthlyFormDTO> monthlyFormDTOList = new ArrayList<>();
// 根据组织id(eg:社区或者街道id) 进行分组,最后组装一条数据 一个组织id 对应 4条数据 // 根据组织id(eg:社区或者街道id) 进行分组,最后组装一条数据 一个组织id 对应 4条数据
Map<String, List<AgencyScoreDTO>> collect = agencyScoreDTOS.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId)); Map<String, List<AgencyScoreDTO>> collect = agencyScoreDTOS.stream().collect(Collectors.groupingBy(AgencyScoreDTO::getAgencyId));
List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId); List<ScreenCustomerAgencyEntity> parentAgencyList = screenCustomerAgencyDao.selectListAgencyInfo(customerId);
int j = 0; int j = 0;
for(Map.Entry<String,List<AgencyScoreDTO>> agencyScore : collect.entrySet()){ if (!CollectionUtils.isEmpty(parentAgencyList)) {
parentAgencyList.forEach(o -> {
allParentIds.put(o.getAgencyId(), o.getPids());
});
}
for (Map.Entry<String, List<AgencyScoreDTO>> agencyScore : collect.entrySet()) {
if (NumConstant.ZERO_STR.equals(agencyScore.getKey())) { if (NumConstant.ZERO_STR.equals(agencyScore.getKey())) {
log.warn("insertIndexDataMonthlyByAgencyScore agencyyId is 0"); log.warn("insertIndexDataMonthlyByAgencyScore agencyyId is 0");
continue; continue;
@ -669,12 +707,16 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
agencyName = agencyScoreDTO.getAgencyName(); agencyName = agencyScoreDTO.getAgencyName();
} }
} }
if ("".equals(agencyName)){ if ("".equals(agencyName)) {
throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + agencyScore.getKey()); throw new RuntimeException("在screen_customer_agency表中未查询到该客户下的组织名称:customerId =" + customerId + ", agencyId = " + agencyScore.getKey());
} }
// 补充表中其他字段 // 补充表中其他字段
monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, agencyScore.getKey(), monthlyFormDTO = this.supplementIndexDataMonthlyTable(monthId, OrgTypeConstant.AGENCY, agencyScore.getKey(),
parentAgencyId, agencyName, monthlyFormDTO); parentAgencyId, agencyName, monthlyFormDTO);
if ("S2-C1".equals(monthlyFormDTO.getOrgId())) {
System.out.println("======" + allParentIds.getIfPresent(monthlyFormDTO.getOrgId()));
}
monthlyFormDTO.setAllParentIds(allParentIds.getIfPresent(monthlyFormDTO.getOrgId()));
monthlyFormDTOList.add(monthlyFormDTO); monthlyFormDTOList.add(monthlyFormDTO);
} }
if (monthlyFormDTOList.size() > NumConstant.ZERO){ if (monthlyFormDTOList.size() > NumConstant.ZERO){

3
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -81,7 +81,8 @@
<select id="selectListAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity"> <select id="selectListAgencyInfo" parameterType="map" resultType="com.epmet.entity.evaluationindex.screen.ScreenCustomerAgencyEntity">
SELECT SELECT
AGENCY_ID agencyId, AGENCY_ID agencyId,
AGENCY_NAME agencyName AGENCY_NAME agencyName,
PIDS pids
FROM FROM
screen_customer_agency screen_customer_agency
WHERE WHERE

3
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerGridDao.xml

@ -126,7 +126,8 @@
SELECT SELECT
GRID_ID gridId, GRID_ID gridId,
GRID_NAME gridName, GRID_NAME gridName,
PARENT_AGENCY_ID parentAgencyId PARENT_AGENCY_ID parentAgencyId,
ALL_PARENT_IDS allParentIds
FROM FROM
screen_customer_grid screen_customer_grid
WHERE WHERE

8
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml

@ -19,6 +19,7 @@
ORG_TYPE, ORG_TYPE,
ORG_ID, ORG_ID,
PARENT_ID, PARENT_ID,
ALL_PARENT_IDS,
ORG_NAME, ORG_NAME,
INDEX_TOTAL, INDEX_TOTAL,
PARTY_DEV_ABLITY, PARTY_DEV_ABLITY,
@ -43,6 +44,7 @@
#{item.orgType}, #{item.orgType},
#{item.orgId}, #{item.orgId},
#{item.parentId}, #{item.parentId},
#{item.allParentIds},
#{item.orgName}, #{item.orgName},
#{item.indexTotal}, #{item.indexTotal},
@ -99,4 +101,10 @@
where CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND ORG_TYPE = #{orgType} where CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND ORG_TYPE = #{orgType}
limit 1000; limit 1000;
</delete> </delete>
<update id="updateParentIdsById" parameterType="map">
update screen_index_data_monthly m3
SET m3.ALL_PARENT_IDS =#{allParentIds}
where m3.id=#{id}
</update>
</mapper> </mapper>

Loading…
Cancel
Save