|
|
@ -17,15 +17,16 @@ |
|
|
|
|
|
|
|
package com.epmet.datareport.service.plugins.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.DataSourceConstant; |
|
|
|
import com.epmet.datareport.dao.plugins.ScreenCustomerWorkRecordDictDao; |
|
|
|
import com.epmet.datareport.dao.plugins.ScreenWorkRecordOrgDailyDao; |
|
|
@ -34,23 +35,26 @@ import com.epmet.datareport.entity.plugins.ScreenWorkRecordOrgDailyEntity; |
|
|
|
import com.epmet.datareport.service.evaluationindex.screen.AgencyService; |
|
|
|
import com.epmet.datareport.service.plugins.ScreenWorkRecordOrgDailyService; |
|
|
|
import com.epmet.datareport.utils.DateUtils; |
|
|
|
import com.epmet.dto.result.ScreenCustomerAgencyDTO; |
|
|
|
import com.epmet.dto.AgencyInfoDTO; |
|
|
|
import com.epmet.evaluationindex.screen.constant.ScreenConstant; |
|
|
|
import com.epmet.feign.OperCrmOpenFeignClient; |
|
|
|
import com.epmet.plugins.ScreenWorkRecordOrgDailyDTO; |
|
|
|
import com.epmet.plugins.form.VoluntaryServiceTrendFormDTO; |
|
|
|
import com.epmet.plugins.form.WorkRecordRankFormDTO; |
|
|
|
import com.epmet.plugins.form.WorkRecordTrendFormDTO; |
|
|
|
import com.epmet.plugins.result.WorkRecordRankResultDTO; |
|
|
|
import com.epmet.plugins.result.WorkRecordTrendResultDTO; |
|
|
|
import com.epmet.plugins.result.*; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.atomic.AtomicInteger; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
@ -71,7 +75,8 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl<ScreenW |
|
|
|
private ScreenCustomerWorkRecordDictDao screenCustomerWorkRecordDictDao; |
|
|
|
@Autowired |
|
|
|
private ScreenWorkRecordOrgMonthlyDao screenWorkRecordOrgMonthlyDao; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private OperCrmOpenFeignClient operCrmOpenFeignClient; |
|
|
|
@Override |
|
|
|
public PageData<ScreenWorkRecordOrgDailyDTO> page(Map<String, Object> params) { |
|
|
|
IPage<ScreenWorkRecordOrgDailyEntity> page = baseDao.selectPage( |
|
|
@ -124,30 +129,54 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl<ScreenW |
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) |
|
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) |
|
|
|
@Override |
|
|
|
public WorkRecordRankResultDTO rankList(WorkRecordRankFormDTO formDTO) { |
|
|
|
////todo 待完善 直属网格是否显示?
|
|
|
|
ScreenCustomerAgencyDTO agencyDTO = agencyService.queryAgencyInfo(formDTO.getAgencyId()); |
|
|
|
if (null == agencyDTO) { |
|
|
|
throw new RenException(String.format("获取组织信息异常,agencyId:%s", formDTO.getAgencyId())); |
|
|
|
List<String> customerIds=new ArrayList<>(); |
|
|
|
Result<List<String>> result=operCrmOpenFeignClient.getAllSubCustomerIds(formDTO.getCustomerId()); |
|
|
|
if (result.success() && CollectionUtils.isNotEmpty(result.getData())) { |
|
|
|
customerIds.addAll(result.getData()); |
|
|
|
} |
|
|
|
String dateId = baseDao.selectLatestDateId(formDTO.getCustomerId()); |
|
|
|
log.info(String.format("最近一次上传dateId:%s", dateId)); |
|
|
|
if (agencyDTO.getLevel().equals("community")) { |
|
|
|
log.warn("【工作日志】本机及下级排名接口待完善"); |
|
|
|
//todo
|
|
|
|
return new WorkRecordRankResultDTO(0, 0, new ArrayList<>()); |
|
|
|
} else { |
|
|
|
//非社区的
|
|
|
|
List<WorkRecordRankResultDTO> resultDTOList = baseDao.selectCurrentAgency(agencyDTO.getAreaCode(), formDTO.getDataType(), dateId); |
|
|
|
if(!CollectionUtils.isEmpty(resultDTOList)){ |
|
|
|
WorkRecordRankResultDTO resultDTO=resultDTOList.get(0); |
|
|
|
resultDTO.setSubRankList(baseDao.selectSubList(agencyDTO.getAreaCode(), agencyDTO.getAgencyId(), formDTO.getDataType(), formDTO.getTopRow(), dateId)); |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
customerIds.add(formDTO.getCustomerId()); |
|
|
|
String dateId= baseDao.selectLatestDateId(customerIds); |
|
|
|
if(StringUtils.isBlank(dateId)){ |
|
|
|
log.warn("selectLatestDateId dateId is null customerIds" + JSON.toJSONString(customerIds)); |
|
|
|
} |
|
|
|
WorkRecordRankResultDTO returnDto = new WorkRecordRankResultDTO(); |
|
|
|
AgencyInfoDTO agencyInfoDTO = agencyService.getAgencyInfoDTO(formDTO.getAreaCode(), formDTO.getAgencyId()); |
|
|
|
//当前组织的自身的数据
|
|
|
|
List<WorkRecordSubRank> currentAgency = baseDao.selectCurrentAgency(formDTO.getAgencyId(), |
|
|
|
formDTO.getDataType(), |
|
|
|
formDTO.getCustomerId(), |
|
|
|
dateId); |
|
|
|
//下级所有组织
|
|
|
|
List<WorkRecordSubRank> subAgencyRankList = baseDao.selectSubList( |
|
|
|
CollectionUtils.isNotEmpty(agencyInfoDTO.getSubAgencyIds()) ? agencyInfoDTO.getSubAgencyIds() : new ArrayList<>(), |
|
|
|
formDTO.getDataType(), |
|
|
|
formDTO.getCustomerId(), |
|
|
|
dateId); |
|
|
|
//直属网格
|
|
|
|
List<WorkRecordSubRank> subGridList = baseDao.selectSubGridList( |
|
|
|
CollectionUtils.isNotEmpty(agencyInfoDTO.getSubGridIds()) ? agencyInfoDTO.getSubGridIds() : new ArrayList<>(), |
|
|
|
formDTO.getDataType(), |
|
|
|
formDTO.getCustomerId(), |
|
|
|
dateId); |
|
|
|
if (CollectionUtils.isNotEmpty(currentAgency)) { |
|
|
|
returnDto.getSubRankList().addAll(currentAgency); |
|
|
|
} |
|
|
|
return new WorkRecordRankResultDTO(); |
|
|
|
returnDto.getSubRankList().addAll(subAgencyRankList); |
|
|
|
returnDto.getSubRankList().addAll(subGridList); |
|
|
|
int participateUserTotal = 0; |
|
|
|
int participateTotal = 0; |
|
|
|
for (WorkRecordSubRank subAgency : returnDto.getSubRankList()) { |
|
|
|
participateUserTotal += subAgency.getParticipateUserTotal(); |
|
|
|
participateTotal += subAgency.getParticipateTotal(); |
|
|
|
} |
|
|
|
returnDto.setParticipateTotal(participateTotal); |
|
|
|
returnDto.setParticipateUserTotal(participateUserTotal); |
|
|
|
returnDto.setSubRankList(CollectionUtils.isNotEmpty(returnDto.getSubRankList()) && returnDto.getSubRankList().size() >= formDTO.getTopRow() ? |
|
|
|
returnDto.getSubRankList().subList(NumConstant.ZERO, formDTO.getTopRow()) : returnDto.getSubRankList()); |
|
|
|
return returnDto; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -204,4 +233,64 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl<ScreenW |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param formDTO |
|
|
|
* @return com.epmet.plugins.result.VoluntaryServiceTrendResultDTO |
|
|
|
* @author yinzuomei |
|
|
|
* @description 7、【工作日志】党员志愿者服务近12月趋势图 |
|
|
|
* @Date 2021/2/27 19:56 |
|
|
|
**/ |
|
|
|
@Override |
|
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true) |
|
|
|
public VoluntaryServiceTrendResultDTO voluntaryServiceTrend(VoluntaryServiceTrendFormDTO formDTO) { |
|
|
|
VoluntaryServiceTrendResultDTO resultDTO = new VoluntaryServiceTrendResultDTO(); |
|
|
|
//近12个月的monthId集合,["202002","202003","202004","202005","202006","202007","202008","202009","202010","202011","202012","202101"]
|
|
|
|
List<String> monthIdList = com.epmet.commons.tools.utils.DateUtils.getMonthIdList(formDTO.getEndMonthId(), NumConstant.ELEVEN); |
|
|
|
// log.info(JSON.toJSONString(monthIdList));
|
|
|
|
|
|
|
|
AgencyInfoDTO agencyInfoDTO = agencyService.getAgencyInfoDTO(formDTO.getAreaCode(), formDTO.getAgencyId()); |
|
|
|
List<String> orgIds = new ArrayList<>(); |
|
|
|
orgIds.addAll(agencyInfoDTO.getSubAgencyIds()); |
|
|
|
orgIds.add(agencyInfoDTO.getAgencyId()); |
|
|
|
orgIds.addAll(agencyInfoDTO.getSubGridIds()); |
|
|
|
List<VoluntaryServiceTrendDTO> list = screenWorkRecordOrgMonthlyDao.selectVoluntaryServiceTrendDTO(formDTO.getCustomerId(), |
|
|
|
orgIds, |
|
|
|
monthIdList.get(NumConstant.ZERO), |
|
|
|
monthIdList.get(NumConstant.ELEVEN)); |
|
|
|
Map<String, VoluntaryServiceTrendDTO> dtoMap = new HashMap<>(); |
|
|
|
if (!org.springframework.util.CollectionUtils.isEmpty(list)) { |
|
|
|
dtoMap = list.stream().collect(Collectors.toMap(VoluntaryServiceTrendDTO::getMonthId, Function.identity(), (key1, key2) -> key2)); |
|
|
|
} |
|
|
|
|
|
|
|
//要返回的横坐标:["02月","03月","04月","05月","06月","07月","08月","09月","10月","11月","12月","01月"]
|
|
|
|
List<String> xAxis = new ArrayList<>(); |
|
|
|
List<Integer> organizeList = new ArrayList<>(); |
|
|
|
List<Integer> joinUserList = new ArrayList<>(); |
|
|
|
List<Integer> avgUserList = new ArrayList<>(); |
|
|
|
|
|
|
|
for (String monthId : monthIdList) { |
|
|
|
xAxis.add(monthId.substring(NumConstant.FOUR, NumConstant.SIX).concat(ScreenConstant.MONTH)); |
|
|
|
if (null != dtoMap.get(monthId) && null != dtoMap.get(monthId).getOrganizeTotal()) { |
|
|
|
organizeList.add(dtoMap.get(monthId).getOrganizeTotal()); |
|
|
|
} else { |
|
|
|
organizeList.add(NumConstant.ZERO); |
|
|
|
} |
|
|
|
if (null != dtoMap.get(monthId) && null != dtoMap.get(monthId).getParticipateUserTotal()) { |
|
|
|
joinUserList.add(dtoMap.get(monthId).getParticipateUserTotal()); |
|
|
|
} else { |
|
|
|
joinUserList.add(NumConstant.ZERO); |
|
|
|
} |
|
|
|
if (null != dtoMap.get(monthId) && null != dtoMap.get(monthId).getAvgParticipateUserTotal()) { |
|
|
|
avgUserList.add(dtoMap.get(monthId).getAvgParticipateUserTotal()); |
|
|
|
} else { |
|
|
|
avgUserList.add(NumConstant.ZERO); |
|
|
|
} |
|
|
|
} |
|
|
|
resultDTO.setXAxis(xAxis); |
|
|
|
resultDTO.setOrganizeList(organizeList); |
|
|
|
resultDTO.setJoinUserList(joinUserList); |
|
|
|
resultDTO.setAvgUserList(avgUserList); |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
|
|
|
|
} |