|
|
@ -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; |
|
|
@ -37,7 +34,6 @@ import com.epmet.datareport.service.plugins.ScreenWorkRecordOrgDailyService; |
|
|
|
import com.epmet.datareport.utils.DateUtils; |
|
|
|
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; |
|
|
@ -48,7 +44,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 +70,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 +93,44 @@ 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<>(); |
|
|
|
|
|
|
|
returnDto.getSubRankList().addAll(subAgencyRankList); |
|
|
|
returnDto.getSubRankList().addAll(subGridList); |
|
|
|
//随手记类型编码;对应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 为空")); |
|
|
|
return returnDto; |
|
|
|
} |
|
|
|
//1)、当前组织的自身的数据
|
|
|
|
List<WorkRecordSubRank> currentAgency = baseDao.selectCurrentAgency(formDTO.getAgencyId(),dateId,typeCodeList); |
|
|
|
//2)、下级所有组织
|
|
|
|
List<WorkRecordSubRank> subAgencyRankList = new ArrayList<>(); |
|
|
|
for(String agencyId:agencyInfoDTO.getSubAgencyIds()){ |
|
|
|
WorkRecordSubRank agencyRes= baseDao.selectUpToCalAgency(agencyId,dateId,typeCodeList); |
|
|
|
subAgencyRankList.add(agencyRes); |
|
|
|
} |
|
|
|
//3)、直属网格
|
|
|
|
List<WorkRecordSubRank> subGridList=new ArrayList<>(); |
|
|
|
for(String gridId:agencyInfoDTO.getSubGridIds()){ |
|
|
|
WorkRecordSubRank gridRes=baseDao.selectUpToCalGrid(gridId,dateId,typeCodeList); |
|
|
|
subGridList.add(gridRes); |
|
|
|
} |
|
|
|
|
|
|
|
if(CollectionUtils.isNotEmpty(subAgencyRankList)){ |
|
|
|
returnDto.getSubRankList().addAll(subAgencyRankList); |
|
|
|
} |
|
|
|
if(CollectionUtils.isNotEmpty(subGridList)){ |
|
|
|
returnDto.getSubRankList().addAll(subGridList); |
|
|
|
} |
|
|
|
|
|
|
|
// log.info("returnDto.getSubRankList()="+returnDto.getSubRankList());
|
|
|
|
int participateUserTotal = 0; |
|
|
|
int participateTotal = 0; |
|
|
|