|
|
@ -19,14 +19,11 @@ 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.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; |
|
|
@ -36,8 +33,9 @@ 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.AgencyInfoDTO; |
|
|
|
import com.epmet.dto.ScreenCustomerAgencyCommonDTO; |
|
|
|
import com.epmet.dto.ScreenCustomerGridCommonDTO; |
|
|
|
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; |
|
|
@ -48,7 +46,6 @@ 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 java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
@ -75,16 +72,6 @@ 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( |
|
|
|
getPage(params, FieldConstant.CREATED_TIME, false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
return getPageData(page, ScreenWorkRecordOrgDailyDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public List<ScreenWorkRecordOrgDailyDTO> list(Map<String, Object> params) { |
|
|
@ -108,65 +95,65 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl<ScreenW |
|
|
|
return ConvertUtils.sourceToTarget(entity, ScreenWorkRecordOrgDailyDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void save(ScreenWorkRecordOrgDailyDTO dto) { |
|
|
|
ScreenWorkRecordOrgDailyEntity entity = ConvertUtils.sourceToTarget(dto, ScreenWorkRecordOrgDailyEntity.class); |
|
|
|
insert(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void update(ScreenWorkRecordOrgDailyDTO dto) { |
|
|
|
ScreenWorkRecordOrgDailyEntity entity = ConvertUtils.sourceToTarget(dto, ScreenWorkRecordOrgDailyEntity.class); |
|
|
|
updateById(entity); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void delete(String[] ids) { |
|
|
|
// 逻辑删除(@TableLogic 注解)
|
|
|
|
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|
|
|
} |
|
|
|
|
|
|
|
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true) |
|
|
|
@Override |
|
|
|
public WorkRecordRankResultDTO rankList(WorkRecordRankFormDTO formDTO) { |
|
|
|
List<String> customerIds=new ArrayList<>(); |
|
|
|
Result<List<String>> result=operCrmOpenFeignClient.getAllSubCustomerIds(formDTO.getCustomerId()); |
|
|
|
// log.info("根据customerId查询其所有下级子客户id result: "+JSON.toJSONString(result));
|
|
|
|
if (result.success() && CollectionUtils.isNotEmpty(result.getData())) { |
|
|
|
customerIds.addAll(result.getData()); |
|
|
|
} |
|
|
|
customerIds.add(formDTO.getCustomerId()); |
|
|
|
String dateId= baseDao.selectLatestDateId(customerIds); |
|
|
|
if(StringUtils.isBlank(dateId)){ |
|
|
|
dateId= com.epmet.commons.tools.utils.DateUtils.getBeforeNDay(NumConstant.ONE); |
|
|
|
log.warn("dateId 赋值为"+dateId+" ; selectLatestDateId dateId is null customerIds" + JSON.toJSONString(customerIds)); |
|
|
|
} |
|
|
|
//默认截止到前一天
|
|
|
|
String dateId= com.epmet.commons.tools.utils.DateUtils.getBeforeNDay(NumConstant.ONE); |
|
|
|
WorkRecordRankResultDTO returnDto = new WorkRecordRankResultDTO(); |
|
|
|
AgencyInfoDTO agencyInfoDTO = agencyService.getAgencyInfoDTO(formDTO.getAreaCode(), formDTO.getAgencyId()); |
|
|
|
// log.info("agencyInfoDTO: "+JSON.toJSONString(agencyInfoDTO));
|
|
|
|
//当前组织的自身的数据
|
|
|
|
List<WorkRecordSubRank> currentAgency = baseDao.selectCurrentAgency(formDTO.getAgencyId(), |
|
|
|
formDTO.getDataType(), |
|
|
|
formDTO.getCustomerId(), |
|
|
|
dateId); |
|
|
|
//下级所有组织
|
|
|
|
List<WorkRecordSubRank> subAgencyRankList = CollectionUtils.isNotEmpty(agencyInfoDTO.getSubAgencyIds()) ? baseDao.selectSubList( |
|
|
|
agencyInfoDTO.getSubAgencyIds(), |
|
|
|
formDTO.getDataType(), |
|
|
|
formDTO.getCustomerId(), |
|
|
|
dateId) : new ArrayList<>(); |
|
|
|
//直属网格
|
|
|
|
List<WorkRecordSubRank> subGridList = CollectionUtils.isNotEmpty(agencyInfoDTO.getSubGridIds()) ? baseDao.selectSubGridList( |
|
|
|
agencyInfoDTO.getSubGridIds(), |
|
|
|
formDTO.getDataType(), |
|
|
|
formDTO.getCustomerId(), |
|
|
|
dateId) : new ArrayList<>(); |
|
|
|
log.info("agencyInfoDTO: "+JSON.toJSONString(agencyInfoDTO)); |
|
|
|
|
|
|
|
//随手记类型编码;对应screen_customer_work_record_dict的资源编码
|
|
|
|
List<String> typeCodeList=baseDao.selectCustomerTypeCode(formDTO.getDataType(),formDTO.getCustomerId()); |
|
|
|
if(CollectionUtils.isEmpty(typeCodeList)){ |
|
|
|
log.warn(String.format("当前customerId=%s,screen_customer_work_record_dict 为空")); |
|
|
|
} |
|
|
|
|
|
|
|
//1)、当前组织的自身的数据
|
|
|
|
WorkRecordSubRank currentAgency = baseDao.selectCurrentAgency(formDTO.getAgencyId(),dateId,typeCodeList); |
|
|
|
//2)、下级所有组织
|
|
|
|
List<WorkRecordSubRank> subAgencyRankList = new ArrayList<>(); |
|
|
|
for(ScreenCustomerAgencyCommonDTO agencyCommonDTO:agencyInfoDTO.getSubAgencies()){ |
|
|
|
WorkRecordSubRank agencyRes= baseDao.selectUpToCalAgency(agencyCommonDTO.getAgencyId(),dateId,typeCodeList); |
|
|
|
if(null !=agencyRes){ |
|
|
|
subAgencyRankList.add(agencyRes); |
|
|
|
}else{ |
|
|
|
WorkRecordSubRank agencyDefault=new WorkRecordSubRank(); |
|
|
|
agencyDefault.setOrgId(agencyCommonDTO.getAgencyId()); |
|
|
|
agencyDefault.setName(agencyCommonDTO.getAgencyName()); |
|
|
|
agencyDefault.setParticipateTotal(0); |
|
|
|
agencyDefault.setParticipateUserTotal(0); |
|
|
|
agencyDefault.setIsDefault("yes"); |
|
|
|
subAgencyRankList.add(agencyDefault); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
//3)、直属网格
|
|
|
|
List<WorkRecordSubRank> subGridList=new ArrayList<>(); |
|
|
|
for(ScreenCustomerGridCommonDTO gridCommonDTO:agencyInfoDTO.getSubGrids()){ |
|
|
|
WorkRecordSubRank gridRes=baseDao.selectUpToCalGrid(gridCommonDTO.getGridId(),dateId,typeCodeList); |
|
|
|
if (null != gridRes) { |
|
|
|
subGridList.add(gridRes); |
|
|
|
} else { |
|
|
|
WorkRecordSubRank gridResDefault = new WorkRecordSubRank(); |
|
|
|
gridResDefault.setOrgId(gridCommonDTO.getGridId()); |
|
|
|
gridResDefault.setName(gridCommonDTO.getGridName()); |
|
|
|
gridResDefault.setParticipateTotal(0); |
|
|
|
gridResDefault.setParticipateUserTotal(0); |
|
|
|
gridResDefault.setIsDefault("yes"); |
|
|
|
subAgencyRankList.add(gridResDefault); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(subAgencyRankList)){ |
|
|
|
returnDto.getSubRankList().addAll(subAgencyRankList); |
|
|
|
} |
|
|
|
if(CollectionUtils.isNotEmpty(subGridList)){ |
|
|
|
returnDto.getSubRankList().addAll(subGridList); |
|
|
|
} |
|
|
|
|
|
|
|
returnDto.getSubRankList().addAll(subAgencyRankList); |
|
|
|
returnDto.getSubRankList().addAll(subGridList); |
|
|
|
// log.info("returnDto.getSubRankList()="+returnDto.getSubRankList());
|
|
|
|
int participateUserTotal = 0; |
|
|
|
int participateTotal = 0; |
|
|
@ -174,11 +161,9 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl<ScreenW |
|
|
|
participateUserTotal += subAgency.getParticipateUserTotal(); |
|
|
|
participateTotal += subAgency.getParticipateTotal(); |
|
|
|
} |
|
|
|
if (CollectionUtils.isNotEmpty(currentAgency)) { |
|
|
|
for (WorkRecordSubRank m : currentAgency) { |
|
|
|
participateUserTotal += m.getParticipateUserTotal(); |
|
|
|
participateTotal += m.getParticipateTotal(); |
|
|
|
} |
|
|
|
if (null != currentAgency) { |
|
|
|
participateUserTotal += currentAgency.getParticipateUserTotal(); |
|
|
|
participateTotal += currentAgency.getParticipateTotal(); |
|
|
|
} |
|
|
|
returnDto.setParticipateTotal(participateTotal); |
|
|
|
returnDto.setParticipateUserTotal(participateUserTotal); |
|
|
@ -262,9 +247,9 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl<ScreenW |
|
|
|
|
|
|
|
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()); |
|
|
|
orgIds.addAll(agencyInfoDTO.getSubAgencies().stream().map(agency->agency.getAgencyId()).collect(Collectors.toSet())); |
|
|
|
orgIds.add(agencyInfoDTO.getCurrentAgencyId()); |
|
|
|
orgIds.addAll(agencyInfoDTO.getSubGrids().stream().map(grid->grid.getGridId()).collect(Collectors.toSet())); |
|
|
|
List<VoluntaryServiceTrendDTO> list = screenWorkRecordOrgMonthlyDao.selectVoluntaryServiceTrendDTO(formDTO.getCustomerId(), |
|
|
|
orgIds, |
|
|
|
monthIdList.get(NumConstant.ZERO), |
|
|
|