Browse Source

组织次数,参与人数

master
zxc 5 years ago
parent
commit
44e98321cd
  1. 210
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyGuideServiceImpl.java
  2. 5
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPartyBranchDataDao.xml

210
epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/PartyGuideServiceImpl.java

@ -1,8 +1,8 @@
package com.epmet.service.evaluationindex.extract.toscreen.impl;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.ScreenConstant;
import com.epmet.dto.extract.form.ScreenExtractFormDTO;
import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO;
@ -81,7 +81,7 @@ public class PartyGuideServiceImpl implements PartyGuideService {
if (!CollectionUtils.isEmpty(customerIds)){
String finalMonthId = monthId;
customerIds.forEach(oneCustomerId -> {
partyGuideExtractParty(oneCustomerId, finalMonthId);
// partyGuideExtractParty(oneCustomerId, finalMonthId);
partyGuideExtractOrganize(oneCustomerId,finalMonthId);
});
}
@ -271,67 +271,79 @@ public class PartyGuideServiceImpl implements PartyGuideService {
*/
public void disPoseOrganize(List<CustomerAgencyInfoResultDTO> agencyIdList, Boolean isGrid, String customerId, String monthId){
if (!CollectionUtils.isEmpty(agencyIdList)){
List<ScreenPartyBranchDataFormDTO> result = new ArrayList<>();
List<String> orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList());
List<String> orgIds = new ArrayList<>();
List<String> orgIdsAgency = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList());
orgIds.addAll(orgIdsAgency);
orgIdsAgency.forEach(orgId -> {
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(orgId, customerId);
List<String> gridIds = (List<String>) agencyMap.get(orgId);
orgIds.addAll(gridIds);
});
List<GridInfoResultDTO> directGridIds = gridService.selectDirectGrid(orgIdsAgency);
if (isGrid == false){
orgIds.addAll(directGridIds.stream().map(m -> m.getGridId()).collect(Collectors.toList()));
}
List<JoinUserCountResultDTO> joinUserCountByAgencyList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.AGENCY);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataByAgencyList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.AGENCY, orgIds);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchData = agencyService.selectAllAgencyIdToOrganize(customerId, monthId);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataListAgencyAll = gridService.selectAllGridIdToOrganize(customerId, monthId);
screenPartyBranchDataListAgencyAll.addAll(screenPartyBranchData);
List<ScreenPartyBranchDataFormDTO> finalResult = new ArrayList<>();
screenPartyBranchDataListAgencyAll.forEach(rl -> {
orgIds.forEach(orgId -> {
if (rl.getOrgId().equals(orgId)){
finalResult.add(rl);
}
});
});
if (isGrid == true){
List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.GRID);
agencyIdList.forEach(agency -> {
String agencyId = agency.getAgencyId();
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId);
List<String> gridIds = (List<String>) agencyMap.get(agencyId);
orgIds.addAll(gridIds);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, gridIds);
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){
screenPartyBranchDataList.forEach(party -> {
joinUserCountList.forEach(join -> {
if (party.getOrgId().equals(join.getOrgId())){
party.setAverageJoinUserCount(join.getJoinUserCount());
party.setAverageJoinUserCount(party.getOrganizeCount()==NumConstant.ZERO ? NumConstant.ZERO : party.getJoinUserCount() / party.getOrganizeCount());
party.setYearId(DateUtils.getYearId(monthId));
}
});
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, orgIds);
finalResult.forEach(fl -> {
screenPartyBranchDataList.forEach(sp -> {
if (fl.getOrgId().equals(sp.getOrgId())){
fl.setOrganizeCount(sp.getOrganizeCount());
}
});
}
result.addAll(screenPartyBranchDataList);
joinUserCountList.forEach(join -> {
if (fl.getOrgId().equals(join.getOrgId())){
fl.setJoinUserCount(join.getJoinUserCount());
}
});
fl.setAverageJoinUserCount(fl.getOrganizeCount()==NumConstant.ZERO ? NumConstant.ZERO : fl.getJoinUserCount() / fl.getOrganizeCount());
});
});
// 社区级别的
Map<String, List<ScreenPartyBranchDataFormDTO>> groupByAgency = result.stream().collect(Collectors.groupingBy(ScreenPartyBranchDataFormDTO::getParentId));
List<OrgNameResultDTO> orgNameAgencyList = agencyService.selectOrgNameAgency(orgIds);
groupByAgency.forEach((agencyId,actList) -> {
ScreenPartyBranchDataFormDTO form = new ScreenPartyBranchDataFormDTO();
if (!CollectionUtils.isEmpty(orgNameAgencyList)){
orgNameAgencyList.forEach(name -> {
if (agencyId.equals(name.getAgencyId())){
form.setOrgName(name.getAgencyName());
form.setParentId(name.getParentId());
}
Map<String, List<ScreenPartyBranchDataFormDTO>> groupByType = finalResult.stream().collect(Collectors.groupingBy(ScreenPartyBranchDataFormDTO::getOrgType));
groupByType.forEach((orgType,list) -> {
if (orgType.equals(ScreenConstant.GRID)){
Map<String, List<ScreenPartyBranchDataFormDTO>> groupByAgency = finalResult.stream().collect(Collectors.groupingBy(ScreenPartyBranchDataFormDTO::getParentId));
groupByAgency.forEach((agencyId,actList) -> {
finalResult.forEach(fl -> {
if (fl.getOrgId().equals(agencyId)){
fl.setOrganizeCount(actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount)));
fl.setJoinUserCount(actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount)));
screenPartyBranchDataByAgencyList.forEach(organize -> {
if (organize.getOrgId().equals(agencyId)){
fl.setOrganizeCount(calAdd(organize.getOrganizeCount(),actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount))));
}
});
joinUserCountByAgencyList.forEach(join -> {
if (join.getOrgId().equals(agencyId)){
fl.setJoinUserCount(calAdd(join.getJoinUserCount(),actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount))));
}
});
fl.setAverageJoinUserCount(fl.getOrganizeCount()==NumConstant.ZERO?NumConstant.ZERO : (fl.getJoinUserCount() / fl.getOrganizeCount()));
}
});
});
}
form.setOrgId(agencyId);
form.setCustomerId(customerId);
form.setOrgType(ScreenConstant.AGENCY);
form.setMonthId(monthId);
form.setYearId(DateUtils.getYearId(monthId));
form.setOrganizeCount(actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount)));
form.setJoinUserCount(actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount)));
screenPartyBranchDataByAgencyList.forEach(organize -> {
if (organize.getOrgId().equals(agencyId)){
form.setOrganizeCount(calAdd(organize.getOrganizeCount(),actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount))));
}
});
joinUserCountByAgencyList.forEach(join -> {
if (join.getOrgId().equals(agencyId)){
form.setJoinUserCount(calAdd(join.getJoinUserCount(),actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount))));
}
});
form.setAverageJoinUserCount(form.getOrganizeCount()==NumConstant.ZERO?NumConstant.ZERO : (form.getJoinUserCount() / form.getOrganizeCount()));
result.add(form);
});
delAndInsertOrganize(result,customerId,monthId,orgIds);
log.error("结果"+JSON.toJSONString(finalResult));
delOrganize(customerId,monthId,orgIds);
insertOrganize(finalResult);
}else {
List<GridInfoResultDTO> directGridIds = gridService.selectDirectGrid(orgIds);
agencyIdList.forEach(agency -> {
String agencyId = agency.getAgencyId();
List<String> disGridIds = new ArrayList<>();
@ -343,52 +355,46 @@ public class PartyGuideServiceImpl implements PartyGuideService {
// 存在直属网格
if (!CollectionUtils.isEmpty(disGridIds)){
orgIds.addAll(disGridIds);
List<ScreenPartyBranchDataFormDTO> gridResult = new ArrayList<>();
List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.GRID);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, disGridIds);
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){
screenPartyBranchDataList.forEach(party -> {
joinUserCountList.forEach(join -> {
if (party.getOrgId().equals(join.getOrgId())){
party.setAverageJoinUserCount(join.getJoinUserCount());
party.setAverageJoinUserCount(party.getOrganizeCount()==NumConstant.ZERO ? NumConstant.ZERO : party.getJoinUserCount() / party.getOrganizeCount());
party.setYearId(DateUtils.getYearId(monthId));
}
});
ScreenPartyBranchDataFormDTO copyParty = ConvertUtils.sourceToTarget(party, ScreenPartyBranchDataFormDTO.class);
gridResult.add(copyParty);
finalResult.forEach(r -> {
screenPartyBranchDataList.forEach(party ->{
if (r.getOrgId().equals(party.getOrgId())){
r.setOrganizeCount(party.getOrganizeCount());
}
});
}
joinUserCountList.forEach(join -> {
if (r.getOrgId().equals(join.getOrgId())){
r.setJoinUserCount(join.getJoinUserCount());
}
});
r.setAverageJoinUserCount(r.getOrganizeCount()==NumConstant.ZERO ? NumConstant.ZERO : r.getJoinUserCount() / r.getOrganizeCount());
});
}
delOrganize(customerId,monthId,orgIds);
List<ScreenPartyBranchDataFormDTO> disPartyBranchDataList = partyBranchDataService.selectScreenPartyBranchDataByOrgId(customerId, monthId, disGridIds);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = partyBranchDataService.selectScreenPartyBranchDataByParentId(customerId, monthId, agencyId);
screenPartyBranchDataList.addAll(disPartyBranchDataList);
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){
ScreenPartyBranchDataFormDTO form = new ScreenPartyBranchDataFormDTO();
form.setOrgId(agencyId);
form.setOrgType(ScreenConstant.AGENCY);
form.setOrgName(screenPartyBranchDataList.get(NumConstant.ZERO).getOrgName());
form.setCustomerId(customerId);
form.setMonthId(monthId);
form.setYearId(DateUtils.getYearId(monthId));
form.setParentId(screenPartyBranchDataList.get(NumConstant.ZERO).getParentId());
form.setJoinUserCount(screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount)));
form.setOrganizeCount(screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount)));
screenPartyBranchDataByAgencyList.forEach(organize -> {
if (organize.getOrgId().equals(agencyId)){
form.setOrganizeCount(calAdd(organize.getOrganizeCount(),screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount))));
}
});
joinUserCountByAgencyList.forEach(join -> {
if (join.getOrgId().equals(agencyId)){
form.setJoinUserCount(calAdd(join.getJoinUserCount(),screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount))));
}
finalResult.forEach(form -> {
form.setJoinUserCount(screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount)));
form.setOrganizeCount(screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount)));
screenPartyBranchDataByAgencyList.forEach(organize -> {
if (organize.getOrgId().equals(agencyId)){
form.setOrganizeCount(calAdd(organize.getOrganizeCount(),screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount))));
}
});
joinUserCountByAgencyList.forEach(join -> {
if (join.getOrgId().equals(agencyId)){
form.setJoinUserCount(calAdd(join.getJoinUserCount(),screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount))));
}
});
form.setAverageJoinUserCount(form.getOrganizeCount()==NumConstant.ZERO?NumConstant.ZERO : (form.getJoinUserCount() / form.getOrganizeCount()));
});
form.setAverageJoinUserCount(form.getOrganizeCount()==NumConstant.ZERO?NumConstant.ZERO : (form.getJoinUserCount() / form.getOrganizeCount()));
result.add(form);
}
});
delAndInsertOrganize(result,customerId,monthId,orgIds);
insertOrganize(finalResult);
}
}
}
@ -478,35 +484,19 @@ public class PartyGuideServiceImpl implements PartyGuideService {
* @date 2020/9/25 5:50 下午
*/
@Transactional(rollbackFor = Exception.class)
public void delAndInsertOrganize(List<ScreenPartyBranchDataFormDTO> result,String customerId, String monthId, List<String> orgIds){
List<ScreenPartyBranchDataFormDTO> screenPartyBranchData = agencyService.selectAllAgencyIdToOrganize(customerId, monthId);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = gridService.selectAllGridIdToOrganize(customerId, monthId);
screenPartyBranchDataList.addAll(screenPartyBranchData);
List<ScreenPartyBranchDataFormDTO> finalResult = new ArrayList<>();
screenPartyBranchDataList.forEach(rl -> {
orgIds.forEach(orgId -> {
if (rl.getOrgId().equals(orgId)){
finalResult.add(rl);
}
});
public void insertOrganize(List<ScreenPartyBranchDataFormDTO> result){
List<List<ScreenPartyBranchDataFormDTO>> partition = ListUtils.partition(result, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
partyBranchDataService.insertScreenPartyBranchData(p);
});
if (!CollectionUtils.isEmpty(result)){
finalResult.forEach(fr -> {
result.forEach(r -> {
if (fr.getOrgId().equals(r.getOrgId())){
BeanUtils.copyProperties(r,fr);
}
});
});
}
}
@Transactional(rollbackFor = Exception.class)
public void delOrganize(String customerId, String monthId, List<String> orgIds){
Integer delNum;
do {
delNum = partyBranchDataService.deleteOldScreenPartyBranchData(customerId, monthId, orgIds);
}while (delNum > NumConstant.ZERO);
List<List<ScreenPartyBranchDataFormDTO>> partition = ListUtils.partition(finalResult, NumConstant.ONE_HUNDRED);
partition.forEach(p -> {
partyBranchDataService.insertScreenPartyBranchData(p);
});
}
}

5
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenPartyBranchDataDao.xml

@ -151,9 +151,8 @@
spbd.CUSTOMER_ID,
spbd.YEAR_ID,
spbd.MONTH_ID,
spbd.PARENT_ID AS orgId,
spbd.ORG_ID AS orgId,
spbd.ORG_TYPE,
sca.AGENCY_NAME AS orgName,
IFNULL(spbd.ORGANIZE_COUNT,0) AS organizeCount,
IFNULL(spbd.JOIN_USER_COUNT,0) AS joinUserCount
FROM
@ -166,6 +165,6 @@
AND spbd.ORG_TYPE = 'agency'
AND spbd.CUSTOMER_ID = #{customerId}
AND spbd.MONTH_ID = #{monthId}
AND spbd.ORG_ID = #{parentId}
AND spbd.PARENT_ID = #{parentId}
</select>
</mapper>

Loading…
Cancel
Save