Browse Source

组织次数,参与人数

master
zxc 5 years ago
parent
commit
44e98321cd
  1. 156
      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

156
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; 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.constant.NumConstant;
import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.DateUtils;
import com.epmet.constant.ScreenConstant; import com.epmet.constant.ScreenConstant;
import com.epmet.dto.extract.form.ScreenExtractFormDTO; import com.epmet.dto.extract.form.ScreenExtractFormDTO;
import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO;
@ -81,7 +81,7 @@ public class PartyGuideServiceImpl implements PartyGuideService {
if (!CollectionUtils.isEmpty(customerIds)){ if (!CollectionUtils.isEmpty(customerIds)){
String finalMonthId = monthId; String finalMonthId = monthId;
customerIds.forEach(oneCustomerId -> { customerIds.forEach(oneCustomerId -> {
partyGuideExtractParty(oneCustomerId, finalMonthId); // partyGuideExtractParty(oneCustomerId, finalMonthId);
partyGuideExtractOrganize(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){ public void disPoseOrganize(List<CustomerAgencyInfoResultDTO> agencyIdList, Boolean isGrid, String customerId, String monthId){
if (!CollectionUtils.isEmpty(agencyIdList)){ if (!CollectionUtils.isEmpty(agencyIdList)){
List<ScreenPartyBranchDataFormDTO> result = new ArrayList<>(); List<String> orgIds = new ArrayList<>();
List<String> orgIds = agencyIdList.stream().map(m -> m.getAgencyId()).collect(Collectors.toList()); 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<JoinUserCountResultDTO> joinUserCountByAgencyList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.AGENCY);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataByAgencyList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.AGENCY, orgIds); 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){ if (isGrid == true){
List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.GRID); List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.GRID);
agencyIdList.forEach(agency -> { agencyIdList.forEach(agency -> {
String agencyId = agency.getAgencyId(); List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, orgIds);
Map<String, Object> agencyMap = agencyService.selectAllSubAgencyId(agencyId, customerId); finalResult.forEach(fl -> {
List<String> gridIds = (List<String>) agencyMap.get(agencyId); screenPartyBranchDataList.forEach(sp -> {
orgIds.addAll(gridIds); if (fl.getOrgId().equals(sp.getOrgId())){
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, gridIds); fl.setOrganizeCount(sp.getOrganizeCount());
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){ }
screenPartyBranchDataList.forEach(party -> { });
joinUserCountList.forEach(join -> { joinUserCountList.forEach(join -> {
if (party.getOrgId().equals(join.getOrgId())){ if (fl.getOrgId().equals(join.getOrgId())){
party.setAverageJoinUserCount(join.getJoinUserCount()); fl.setJoinUserCount(join.getJoinUserCount());
party.setAverageJoinUserCount(party.getOrganizeCount()==NumConstant.ZERO ? NumConstant.ZERO : party.getJoinUserCount() / party.getOrganizeCount());
party.setYearId(DateUtils.getYearId(monthId));
} }
}); });
fl.setAverageJoinUserCount(fl.getOrganizeCount()==NumConstant.ZERO ? NumConstant.ZERO : fl.getJoinUserCount() / fl.getOrganizeCount());
}); });
}
result.addAll(screenPartyBranchDataList);
}); });
// 社区级别的 // 社区级别的
Map<String, List<ScreenPartyBranchDataFormDTO>> groupByAgency = result.stream().collect(Collectors.groupingBy(ScreenPartyBranchDataFormDTO::getParentId)); Map<String, List<ScreenPartyBranchDataFormDTO>> groupByType = finalResult.stream().collect(Collectors.groupingBy(ScreenPartyBranchDataFormDTO::getOrgType));
List<OrgNameResultDTO> orgNameAgencyList = agencyService.selectOrgNameAgency(orgIds); 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) -> { groupByAgency.forEach((agencyId,actList) -> {
ScreenPartyBranchDataFormDTO form = new ScreenPartyBranchDataFormDTO(); finalResult.forEach(fl -> {
if (!CollectionUtils.isEmpty(orgNameAgencyList)){ if (fl.getOrgId().equals(agencyId)){
orgNameAgencyList.forEach(name -> { fl.setOrganizeCount(actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount)));
if (agencyId.equals(name.getAgencyId())){ fl.setJoinUserCount(actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount)));
form.setOrgName(name.getAgencyName());
form.setParentId(name.getParentId());
}
});
}
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 -> { screenPartyBranchDataByAgencyList.forEach(organize -> {
if (organize.getOrgId().equals(agencyId)){ if (organize.getOrgId().equals(agencyId)){
form.setOrganizeCount(calAdd(organize.getOrganizeCount(),actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount)))); fl.setOrganizeCount(calAdd(organize.getOrganizeCount(),actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount))));
} }
}); });
joinUserCountByAgencyList.forEach(join -> { joinUserCountByAgencyList.forEach(join -> {
if (join.getOrgId().equals(agencyId)){ if (join.getOrgId().equals(agencyId)){
form.setJoinUserCount(calAdd(join.getJoinUserCount(),actList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount)))); 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.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 { }else {
List<GridInfoResultDTO> directGridIds = gridService.selectDirectGrid(orgIds);
agencyIdList.forEach(agency -> { agencyIdList.forEach(agency -> {
String agencyId = agency.getAgencyId(); String agencyId = agency.getAgencyId();
List<String> disGridIds = new ArrayList<>(); List<String> disGridIds = new ArrayList<>();
@ -343,35 +355,28 @@ public class PartyGuideServiceImpl implements PartyGuideService {
// 存在直属网格 // 存在直属网格
if (!CollectionUtils.isEmpty(disGridIds)){ if (!CollectionUtils.isEmpty(disGridIds)){
orgIds.addAll(disGridIds); orgIds.addAll(disGridIds);
List<ScreenPartyBranchDataFormDTO> gridResult = new ArrayList<>();
List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.GRID); List<JoinUserCountResultDTO> joinUserCountList = actUserRelationService.selectJoinUserCount(customerId, monthId, ScreenConstant.GRID);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, disGridIds); List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = actInfoService.selectActInfo(customerId, monthId, ScreenConstant.GRID, disGridIds);
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){ finalResult.forEach(r -> {
screenPartyBranchDataList.forEach(party ->{ screenPartyBranchDataList.forEach(party ->{
if (r.getOrgId().equals(party.getOrgId())){
r.setOrganizeCount(party.getOrganizeCount());
}
});
joinUserCountList.forEach(join -> { joinUserCountList.forEach(join -> {
if (party.getOrgId().equals(join.getOrgId())){ if (r.getOrgId().equals(join.getOrgId())){
party.setAverageJoinUserCount(join.getJoinUserCount()); r.setJoinUserCount(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); r.setAverageJoinUserCount(r.getOrganizeCount()==NumConstant.ZERO ? NumConstant.ZERO : r.getJoinUserCount() / r.getOrganizeCount());
gridResult.add(copyParty);
}); });
} }
} delOrganize(customerId,monthId,orgIds);
List<ScreenPartyBranchDataFormDTO> disPartyBranchDataList = partyBranchDataService.selectScreenPartyBranchDataByOrgId(customerId, monthId, disGridIds); List<ScreenPartyBranchDataFormDTO> disPartyBranchDataList = partyBranchDataService.selectScreenPartyBranchDataByOrgId(customerId, monthId, disGridIds);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = partyBranchDataService.selectScreenPartyBranchDataByParentId(customerId, monthId, agencyId); List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = partyBranchDataService.selectScreenPartyBranchDataByParentId(customerId, monthId, agencyId);
screenPartyBranchDataList.addAll(disPartyBranchDataList); screenPartyBranchDataList.addAll(disPartyBranchDataList);
if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){ if (!CollectionUtils.isEmpty(screenPartyBranchDataList)){
ScreenPartyBranchDataFormDTO form = new ScreenPartyBranchDataFormDTO(); finalResult.forEach(form -> {
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.setJoinUserCount(screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getJoinUserCount)));
form.setOrganizeCount(screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount))); form.setOrganizeCount(screenPartyBranchDataList.stream().collect(Collectors.summingInt(ScreenPartyBranchDataFormDTO::getOrganizeCount)));
screenPartyBranchDataByAgencyList.forEach(organize -> { screenPartyBranchDataByAgencyList.forEach(organize -> {
@ -385,10 +390,11 @@ public class PartyGuideServiceImpl implements PartyGuideService {
} }
}); });
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 下午 * @date 2020/9/25 5:50 下午
*/ */
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void delAndInsertOrganize(List<ScreenPartyBranchDataFormDTO> result,String customerId, String monthId, List<String> orgIds){ public void insertOrganize(List<ScreenPartyBranchDataFormDTO> result){
List<ScreenPartyBranchDataFormDTO> screenPartyBranchData = agencyService.selectAllAgencyIdToOrganize(customerId, monthId); List<List<ScreenPartyBranchDataFormDTO>> partition = ListUtils.partition(result, NumConstant.ONE_HUNDRED);
List<ScreenPartyBranchDataFormDTO> screenPartyBranchDataList = gridService.selectAllGridIdToOrganize(customerId, monthId); partition.forEach(p -> {
screenPartyBranchDataList.addAll(screenPartyBranchData); partyBranchDataService.insertScreenPartyBranchData(p);
List<ScreenPartyBranchDataFormDTO> finalResult = new ArrayList<>();
screenPartyBranchDataList.forEach(rl -> {
orgIds.forEach(orgId -> {
if (rl.getOrgId().equals(orgId)){
finalResult.add(rl);
}
});
});
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; Integer delNum;
do { do {
delNum = partyBranchDataService.deleteOldScreenPartyBranchData(customerId, monthId, orgIds); delNum = partyBranchDataService.deleteOldScreenPartyBranchData(customerId, monthId, orgIds);
}while (delNum > NumConstant.ZERO); }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.CUSTOMER_ID,
spbd.YEAR_ID, spbd.YEAR_ID,
spbd.MONTH_ID, spbd.MONTH_ID,
spbd.PARENT_ID AS orgId, spbd.ORG_ID AS orgId,
spbd.ORG_TYPE, spbd.ORG_TYPE,
sca.AGENCY_NAME AS orgName,
IFNULL(spbd.ORGANIZE_COUNT,0) AS organizeCount, IFNULL(spbd.ORGANIZE_COUNT,0) AS organizeCount,
IFNULL(spbd.JOIN_USER_COUNT,0) AS joinUserCount IFNULL(spbd.JOIN_USER_COUNT,0) AS joinUserCount
FROM FROM
@ -166,6 +165,6 @@
AND spbd.ORG_TYPE = 'agency' AND spbd.ORG_TYPE = 'agency'
AND spbd.CUSTOMER_ID = #{customerId} AND spbd.CUSTOMER_ID = #{customerId}
AND spbd.MONTH_ID = #{monthId} AND spbd.MONTH_ID = #{monthId}
AND spbd.ORG_ID = #{parentId} AND spbd.PARENT_ID = #{parentId}
</select> </select>
</mapper> </mapper>

Loading…
Cancel
Save