|
|
@ -26,6 +26,7 @@ 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,18 +35,20 @@ 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.feign.OperCrmOpenFeignClient; |
|
|
|
import com.epmet.plugins.ScreenWorkRecordOrgDailyDTO; |
|
|
|
import com.epmet.plugins.form.WorkRecordRankFormDTO; |
|
|
|
import com.epmet.plugins.form.WorkRecordTrendFormDTO; |
|
|
|
import com.epmet.plugins.result.WorkRecordRankResultDTO; |
|
|
|
import com.epmet.plugins.result.WorkRecordSubRank; |
|
|
|
import com.epmet.plugins.result.WorkRecordTrendResultDTO; |
|
|
|
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; |
|
|
@ -71,7 +74,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 +128,46 @@ 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())) { |
|
|
|
log.info("包含子客户"); |
|
|
|
customerIds.add(formDTO.getCustomerId()); |
|
|
|
customerIds.addAll(result.getData()); |
|
|
|
} |
|
|
|
String dateId= baseDao.selectLatestDateId(customerIds); |
|
|
|
if(StringUtils.isBlank(dateId)){ |
|
|
|
throw new RenException("dateId is null"); |
|
|
|
} |
|
|
|
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; |
|
|
|
} |
|
|
|
WorkRecordRankResultDTO returnDto = new WorkRecordRankResultDTO(); |
|
|
|
//当前组织的自身的数据
|
|
|
|
AgencyInfoDTO agencyInfoDTO = agencyService.getAgencyInfoDTO(formDTO.getAreaCode(), formDTO.getAgencyId()); |
|
|
|
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); |
|
|
|
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(); |
|
|
|
} |
|
|
|
return new WorkRecordRankResultDTO(); |
|
|
|
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; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|