|
@ -4,11 +4,13 @@ import com.alibaba.fastjson.JSON; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.epmet.LingShanAgentServiceProcessStatusEnum; |
|
|
import com.epmet.LingShanAgentServiceProcessStatusEnum; |
|
|
|
|
|
import com.epmet.commons.tools.constant.ServiceConstant; |
|
|
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|
|
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.EpmetException; |
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
import com.epmet.commons.tools.exception.ExceptionUtils; |
|
|
|
|
|
import com.epmet.commons.tools.feign.ResultDataResolver; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
import com.epmet.commons.tools.redis.common.CustomerOrgRedis; |
|
|
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; |
|
|
import com.epmet.commons.tools.redis.common.CustomerResiUserRedis; |
|
@ -22,14 +24,15 @@ import com.epmet.commons.tools.utils.PidUtils; |
|
|
import com.epmet.constant.OrgInfoConstant; |
|
|
import com.epmet.constant.OrgInfoConstant; |
|
|
import com.epmet.dao.LingshanAgentServiceCategoryDao; |
|
|
import com.epmet.dao.LingshanAgentServiceCategoryDao; |
|
|
import com.epmet.dao.LingshanAgentServiceRecordDao; |
|
|
import com.epmet.dao.LingshanAgentServiceRecordDao; |
|
|
|
|
|
import com.epmet.dataaggre.dto.epmetuser.result.LingshanServiceAgentAgentList; |
|
|
|
|
|
import com.epmet.dataaggre.feign.DataAggregatorOpenFeignClient; |
|
|
|
|
|
import com.epmet.dto.IcResiUserDTO; |
|
|
import com.epmet.dto.form.lingshan.AgentServiceResiSubmitFormDTO; |
|
|
import com.epmet.dto.form.lingshan.AgentServiceResiSubmitFormDTO; |
|
|
import com.epmet.dto.result.LoginUserDetailsResultDTO; |
|
|
import com.epmet.dto.result.LoginUserDetailsResultDTO; |
|
|
import com.epmet.dto.result.agentservice.AgentServiceList4WorkPcResultDTO; |
|
|
import com.epmet.dto.result.agentservice.*; |
|
|
import com.epmet.dto.result.agentservice.LingShanAgentServiceCategoryResultDTO; |
|
|
|
|
|
import com.epmet.dto.result.agentservice.ResiMyCreatedAgentServiceResultDTO; |
|
|
|
|
|
import com.epmet.dto.result.agentservice.WorkServiceAgentResultDTO; |
|
|
|
|
|
import com.epmet.entity.LingshanAgentServiceCategoryEntity; |
|
|
import com.epmet.entity.LingshanAgentServiceCategoryEntity; |
|
|
import com.epmet.entity.LingshanAgentServiceRecordEntity; |
|
|
import com.epmet.entity.LingshanAgentServiceRecordEntity; |
|
|
|
|
|
import com.epmet.feign.EpmetUserOpenFeignClient; |
|
|
import com.epmet.remote.EpmetUserRemoteService; |
|
|
import com.epmet.remote.EpmetUserRemoteService; |
|
|
import com.epmet.service.LingShanAgentServiceService; |
|
|
import com.epmet.service.LingShanAgentServiceService; |
|
|
import com.github.pagehelper.PageHelper; |
|
|
import com.github.pagehelper.PageHelper; |
|
@ -40,13 +43,13 @@ import org.redisson.api.RLock; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import java.util.Date; |
|
|
import java.util.*; |
|
|
import java.util.List; |
|
|
import java.util.function.Function; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceService { |
|
|
public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceService, ResultDataResolver { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private LingshanAgentServiceCategoryDao agentServiceCategoryDao; |
|
|
private LingshanAgentServiceCategoryDao agentServiceCategoryDao; |
|
@ -60,6 +63,12 @@ public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceServ |
|
|
@Autowired |
|
|
@Autowired |
|
|
private EpmetUserRemoteService epmetUserRemoteService; |
|
|
private EpmetUserRemoteService epmetUserRemoteService; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private DataAggregatorOpenFeignClient dataAggregatorOpenFeignClient; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private EpmetUserOpenFeignClient userOpenFeignClient; |
|
|
|
|
|
|
|
|
public static final String AGENT_SERVICE_LOCK_PREFIX = "lingshan:agentservice:statuschange:"; |
|
|
public static final String AGENT_SERVICE_LOCK_PREFIX = "lingshan:agentservice:statuschange:"; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
@ -368,4 +377,157 @@ public class LingShanAgentServiceServiceImpl implements LingShanAgentServiceServ |
|
|
String agencyName = agencyInfo.getOrganizationName(); |
|
|
String agencyName = agencyInfo.getOrganizationName(); |
|
|
return agencyName.concat("-").concat(gridInfo.getGridName()); |
|
|
return agencyName.concat("-").concat(gridInfo.getGridName()); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<ScreenCatalogueQtyStatsRstDTO> screenCatalogueQtyStats(String orgId, String orgType) { |
|
|
|
|
|
|
|
|
|
|
|
ArrayList<ScreenCatalogueQtyStatsRstDTO> rl = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
// 代办员
|
|
|
|
|
|
Integer c = getResultDataOrThrowsException(dataAggregatorOpenFeignClient.lingshanScreenAgentQty(orgId, orgType), |
|
|
|
|
|
ServiceConstant.DATA_AGGREGATOR_SERVER, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "查询代办员数量失败"); |
|
|
|
|
|
|
|
|
|
|
|
rl.add(new ScreenCatalogueQtyStatsRstDTO("agent", "代办员", c)); |
|
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<LingshanAgentServiceRecordEntity> q = new LambdaQueryWrapper<>(); |
|
|
|
|
|
|
|
|
|
|
|
String orgIdPath; |
|
|
|
|
|
|
|
|
|
|
|
if (OrgInfoConstant.AGENCY.equals(orgType)) { |
|
|
|
|
|
// 行政组织
|
|
|
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(orgId); |
|
|
|
|
|
orgIdPath = PidUtils.convertPid2OrgIdPath(agencyInfo.getId(), agencyInfo.getPids()); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 网格
|
|
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(orgId); |
|
|
|
|
|
orgIdPath = PidUtils.convertPid2OrgIdPath(gridInfo.getId(), gridInfo.getPids()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 未办结事件
|
|
|
|
|
|
q.eq(LingshanAgentServiceRecordEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
|
|
|
|
|
q.likeRight(LingshanAgentServiceRecordEntity::getOrgIdPath, orgIdPath); |
|
|
|
|
|
q.eq(LingshanAgentServiceRecordEntity::getProcessStatus, LingShanAgentServiceProcessStatusEnum.ACCEPTED); //已受理=未办结
|
|
|
|
|
|
|
|
|
|
|
|
rl.add(new ScreenCatalogueQtyStatsRstDTO("service_unclosed", "未办结事件", agentServiceRecordDao.selectCount(q))); |
|
|
|
|
|
|
|
|
|
|
|
// 已办结事件
|
|
|
|
|
|
q.clear(); |
|
|
|
|
|
q.eq(LingshanAgentServiceRecordEntity::getCustomerId, EpmetRequestHolder.getLoginUserCustomerId()); |
|
|
|
|
|
q.likeRight(LingshanAgentServiceRecordEntity::getOrgIdPath, orgIdPath); |
|
|
|
|
|
q.eq(LingshanAgentServiceRecordEntity::getProcessStatus, LingShanAgentServiceProcessStatusEnum.CLOSED); //已受理=未办结
|
|
|
|
|
|
|
|
|
|
|
|
rl.add(new ScreenCatalogueQtyStatsRstDTO("service_closed", "已办结事件", agentServiceRecordDao.selectCount(q))); |
|
|
|
|
|
|
|
|
|
|
|
return rl; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<LingShanScreenAgentRstDTO> screenAgentList(String orgType, String orgId) { |
|
|
|
|
|
// 此时一个工作人员可能对应两个网格,也即这个列表里面,可能有同一个agentId对应多个GridId数据,笛卡尔积
|
|
|
|
|
|
List<LingshanServiceAgentAgentList> agentList = getResultDataOrThrowsException(dataAggregatorOpenFeignClient.screenAgentList(orgId, orgType), |
|
|
|
|
|
ServiceConstant.DATA_AGGREGATOR_SERVER, EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), null, "查询代办员列表失败"); |
|
|
|
|
|
|
|
|
|
|
|
Set<String> agentIds = agentList.stream().map(LingshanServiceAgentAgentList::getAgentId).collect(Collectors.toSet()); |
|
|
|
|
|
|
|
|
|
|
|
// 拼接一个二维map;得到每一个agentId和gridId和统计数量列表
|
|
|
|
|
|
// <agentId:<gridId:LingShanScreenAgentRstDTO>>
|
|
|
|
|
|
HashMap<String, Map<String, LingShanScreenAgentRstDTO>> staffsIdAndStatsDatasInGrid = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
List<LingShanScreenAgentRstDTO> agents = agentServiceRecordDao.screenAgentListAndServiceQty(agentIds); |
|
|
|
|
|
agents.stream().forEach(agent -> { |
|
|
|
|
|
Map<String, LingShanScreenAgentRstDTO> gridIdAndStatsData = staffsIdAndStatsDatasInGrid.get(agent.getAgentId()); |
|
|
|
|
|
if (gridIdAndStatsData == null) { |
|
|
|
|
|
gridIdAndStatsData = new HashMap<>(); |
|
|
|
|
|
staffsIdAndStatsDatasInGrid.put(agent.getAgentId(), gridIdAndStatsData); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LingShanScreenAgentRstDTO statsDataInGrid = gridIdAndStatsData.get(agent.getGridId()); |
|
|
|
|
|
if (statsDataInGrid == null) { |
|
|
|
|
|
gridIdAndStatsData.put(agent.getGridId(), agent); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return agentList.stream().map(agent -> { |
|
|
|
|
|
LingShanScreenAgentRstDTO d = new LingShanScreenAgentRstDTO(); |
|
|
|
|
|
d.setGridId(agent.getGridId()); |
|
|
|
|
|
d.setMobile(agent.getMobile()); |
|
|
|
|
|
d.setAgentId(agent.getAgentId()); |
|
|
|
|
|
d.setAgentName(agent.getAgentName()); |
|
|
|
|
|
d.setLatitude(agent.getLatitude()); |
|
|
|
|
|
d.setLongitude(agent.getLongitude()); |
|
|
|
|
|
d.setClosedServiceQty(0); |
|
|
|
|
|
d.setUnClosedServiceQty(0); |
|
|
|
|
|
// 赋值数量
|
|
|
|
|
|
Map<String, LingShanScreenAgentRstDTO> gridIdsAndStats = staffsIdAndStatsDatasInGrid.get(agent.getAgentId()); |
|
|
|
|
|
if (gridIdsAndStats != null) { |
|
|
|
|
|
LingShanScreenAgentRstDTO statsOfGrid = gridIdsAndStats.get(agent.getGridId()); |
|
|
|
|
|
if (statsOfGrid != null) { |
|
|
|
|
|
d.setClosedServiceQty(statsOfGrid.getClosedServiceQty()); |
|
|
|
|
|
d.setUnClosedServiceQty(statsOfGrid.getUnClosedServiceQty()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return d; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public List<LingShanScreenServiceRstDTO> screenServiceList(String orgType, String orgId, String dataType) { |
|
|
|
|
|
String orgIdPath; |
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isAnyBlank(orgType, orgId)) { |
|
|
|
|
|
LoginUserDetailsResultDTO loginUserDetails = epmetUserRemoteService.getLoginUserDetails(); |
|
|
|
|
|
orgIdPath = loginUserDetails.getOrgIdPath(); |
|
|
|
|
|
} else { |
|
|
|
|
|
if (OrgInfoConstant.AGENCY.equals(orgType)) { |
|
|
|
|
|
AgencyInfoCache agencyInfo = CustomerOrgRedis.getAgencyInfo(orgId); |
|
|
|
|
|
orgIdPath = PidUtils.convertPid2OrgIdPath(agencyInfo.getId(), agencyInfo.getPids()); |
|
|
|
|
|
} else { |
|
|
|
|
|
GridInfoCache gridInfo = CustomerOrgRedis.getGridInfo(orgId); |
|
|
|
|
|
orgIdPath = PidUtils.convertPid2OrgIdPath(gridInfo.getId(), gridInfo.getPids()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer processStatus; |
|
|
|
|
|
if ("service_unclosed".equals(dataType)) { |
|
|
|
|
|
processStatus = LingShanAgentServiceProcessStatusEnum.ACCEPTED.getStatusCode(); |
|
|
|
|
|
} else if ("service_closed".equals(dataType)) { |
|
|
|
|
|
processStatus = LingShanAgentServiceProcessStatusEnum.CLOSED.getStatusCode(); |
|
|
|
|
|
} else { |
|
|
|
|
|
processStatus = -100; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
LambdaQueryWrapper<LingshanAgentServiceRecordEntity> q = new LambdaQueryWrapper<>(); |
|
|
|
|
|
q.likeRight(LingshanAgentServiceRecordEntity::getOrgIdPath, orgIdPath); |
|
|
|
|
|
q.eq(LingshanAgentServiceRecordEntity::getProcessStatus, processStatus); |
|
|
|
|
|
|
|
|
|
|
|
List<LingshanAgentServiceRecordEntity> serviceRecords = agentServiceRecordDao.selectList(q); |
|
|
|
|
|
return serviceRecords.stream().map(rec -> { |
|
|
|
|
|
LingShanScreenServiceRstDTO d = new LingShanScreenServiceRstDTO(); |
|
|
|
|
|
CustomerStaffInfoCacheResult agentInfo = CustomerStaffRedis.getStaffInfo(EpmetRequestHolder.getLoginUserCustomerId(), rec.getAgentId()); |
|
|
|
|
|
if (agentInfo != null) { |
|
|
|
|
|
d.setAgentMobile(agentInfo.getMobile()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// todo 此处要查什么??申请人家庭住址?申请人家庭住址是什么?
|
|
|
|
|
|
// IcResiUserDTO resiUser = getResultDataOrReturnNull(userOpenFeignClient.getIcResiUserDTO(rec.getApplicantId()), ServiceConstant.EPMET_USER_SERVER);
|
|
|
|
|
|
// if (resiUser == null) {
|
|
|
|
|
|
// log.error("【灵山大屏】代办事件列表:查询申请人信息失败,申请人ID:" + rec.getApplicantId());
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// GridInfoCache resiUserGridInfo = CustomerOrgRedis.getGridInfo(resiUser.getGridId());
|
|
|
|
|
|
// if (resiUserGridInfo == null) {
|
|
|
|
|
|
// log.error("【灵山大屏】代办事件列表:查询申请人所属网格信息失败,申请人ID:" + rec.getApplicantId());
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
// d.setApplicantHomeAddress(resiUserGridInfo.getGridName());
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
d.setContent(rec.getContent()); |
|
|
|
|
|
d.setCreatedTime(rec.getCreatedTime()); |
|
|
|
|
|
d.setApplicantName(rec.getApplicantName()); |
|
|
|
|
|
d.setApplicantMobile(rec.getContactMobile()); |
|
|
|
|
|
d.setAgentName(rec.getAgentName()); |
|
|
|
|
|
return d; |
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
} |
|
|
|
|
|
} |