| | |
| | | package com.xiaopeng.maintenance.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.feignClient.account.XpOperationsUserClient; |
| | | import com.xiaopeng.api.model.account.XpOperationsUser; |
| | | import com.xiaopeng.api.model.maintenance.XpCruiseCheckInRecord; |
| | | import com.xiaopeng.common.core.web.page.PageInfo; |
| | | import com.xiaopeng.maintenance.mapper.XpCruiseCheckInRecordMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class XpCruiseCheckInRecordServiceImpl extends ServiceImpl<XpCruiseCheckInRecordMapper, XpCruiseCheckInRecord> implements IXpCruiseCheckInRecordService { |
| | |
| | | @Resource |
| | | private XpCruiseCheckInRecordMapper xpCruiseCheckInRecordMapper; |
| | | |
| | | @Resource |
| | | private XpOperationsUserClient xpOperationsUserClient; |
| | | @Override |
| | | public PageInfo<XpCruiseCheckInRecordVO> pageList(XpCruiseCheckInRecordQuery query) { |
| | | |
| | | PageInfo<XpCruiseCheckInRecordVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize()); |
| | | List<XpCruiseCheckInRecordVO> list = xpCruiseCheckInRecordMapper.selectCruiseCheckInRecordList(pageInfo, query); |
| | | pageInfo.setRecords(list); |
| | | |
| | | List<Long> ids = list.stream().map(XpCruiseCheckInRecordVO::getOperationsUserId).collect(Collectors.toList()); |
| | | List<XpOperationsUser> xpOperationsUsers = xpOperationsUserClient.listByIds(ids).getData(); |
| | | Map<Long, XpOperationsUser> userMap = xpOperationsUsers.stream().collect(Collectors.toMap(XpOperationsUser::getId, Function.identity())); |
| | | list.forEach(record -> { |
| | | XpOperationsUser user = userMap.get(record.getOperationsUserId()); |
| | | if (user != null) { |
| | | record.setOperationsUserId(user.getId()); |
| | | record.setOperationsUserName(user.getNickName()); |
| | | record.setPhoneNumber(user.getPhoneNumber()); |
| | | } |
| | | }); |
| | | |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public XpCruiseCheckInRecordVO detail(Long id) { |
| | | XpCruiseCheckInRecordVO vo = xpCruiseCheckInRecordMapper.detail(id); |
| | | List<Long> ids = Collections.singletonList(vo.getOperationsUserId()); |
| | | List<XpOperationsUser> xpOperationsUsers = xpOperationsUserClient.listByIds(ids).getData(); |
| | | Map<Long, XpOperationsUser> userMap = xpOperationsUsers.stream().collect(Collectors.toMap(XpOperationsUser::getId, Function.identity())); |
| | | XpOperationsUser user = userMap.get(vo.getOperationsUserId()); |
| | | if (user != null) { |
| | | vo.setOperationsUserId(user.getId()); |
| | | vo.setOperationsUserName(user.getNickName()); |
| | | vo.setPhoneNumber(user.getPhoneNumber()); |
| | | } |
| | | return xpCruiseCheckInRecordMapper.detail(id); |
| | | } |
| | | |
| | | @Override |
| | | public XpCruiseCheckInRecordVO statistics(XpCruiseCheckInStatisticsQuery query) { |
| | | return xpCruiseCheckInRecordMapper.selectCruiseCheckInStatistics(query); |
| | | |
| | | XpCruiseCheckInRecordVO vo = xpCruiseCheckInRecordMapper.selectCruiseCheckInStatistics(query); |
| | | |
| | | List<Long> ids = Collections.singletonList(vo.getOperationsUserId()); |
| | | List<XpOperationsUser> xpOperationsUsers = xpOperationsUserClient.listByIds(ids).getData(); |
| | | Map<Long, XpOperationsUser> userMap = xpOperationsUsers.stream().collect(Collectors.toMap(XpOperationsUser::getId, Function.identity())); |
| | | |
| | | XpOperationsUser user = userMap.get(vo.getOperationsUserId()); |
| | | if (user != null) { |
| | | vo.setOperationsUserId(user.getId()); |
| | | vo.setOperationsUserName(user.getNickName()); |
| | | vo.setPhoneNumber(user.getPhoneNumber()); |
| | | } |
| | | |
| | | return vo; |
| | | } |
| | | |
| | | |
| | | } |