| | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.feignClient.AppUserCarClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | import com.ruoyi.chargingPile.api.vo.TAccountingStrategyVO; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TOrderEvaluate; |
| | | import com.ruoyi.order.api.query.TOrderEvaluateQuery; |
| | | import com.ruoyi.order.api.vo.SiteDetailEvaluateVO; |
| | | import com.ruoyi.order.api.vo.TOrderEvaluateVO; |
| | | import com.ruoyi.order.mapper.TChargingOrderMapper; |
| | | import com.ruoyi.order.mapper.TOrderEvaluateMapper; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.util.Comparator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private TEvaluationTagClient evaluationTagClient; |
| | | @Autowired |
| | | private AppUserClient appUserClient; |
| | | @Autowired |
| | | private AppUserCarClient appUserCarClient; |
| | | @Autowired |
| | | private TOrderEvaluateTagMapper orderEvaluateTagMapper; |
| | | @Autowired |
| | | private TChargingOrderMapper chargingOrderMapper; |
| | | @Autowired |
| | | private TOrderEvaluateMapper orderEvaluateMapper; |
| | | @Override |
| | | public List<TEvaluationTagVO> getTagCount() { |
| | | // 查询标签列表 |
| | |
| | | List<Long> orderIds = tChargingOrders.stream().map(TChargingOrder::getId).collect(Collectors.toList()); |
| | | query.setOrderIds(orderIds); |
| | | List<TOrderEvaluateVO> list = this.baseMapper.pageList(query,pageInfo); |
| | | // 查询用户信息 |
| | | List<TAppUser> appUsers = appUserClient.getUserByIds(list.stream().map(TOrderEvaluateVO::getAppUserId).collect(Collectors.toList())).getData(); |
| | | // 查询用户绑定车辆品牌 |
| | | List<TAppUserCar> appUserCars = appUserCarClient.getCarByIds(list.stream().map(TOrderEvaluateVO::getAppUserCarId).collect(Collectors.toList())).getData(); |
| | | list.forEach(orderEvaluateVO -> { |
| | | TAppUser appUser = appUsers.stream().filter(user -> user.getId().equals(orderEvaluateVO.getAppUserId())).findFirst().orElse(null); |
| | | if(Objects.nonNull(appUser)){ |
| | | orderEvaluateVO.setName(appUser.getName()); |
| | | orderEvaluateVO.setAvatar(appUser.getAvatar()); |
| | | } |
| | | TAppUserCar appUserCar = appUserCars.stream().filter(car -> car.getId().equals(Long.parseLong(String.valueOf(orderEvaluateVO.getAppUserCarId())))).findFirst().orElse(null); |
| | | if(Objects.nonNull(appUserCar)){ |
| | | orderEvaluateVO.setCarName(appUserCar.getVehicleBrand()); |
| | | } |
| | | }); |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Override |
| | | public SiteDetailEvaluateVO getSiteDetailEveList(Integer siteId) { |
| | | SiteDetailEvaluateVO siteDetailEvaluateVO = new SiteDetailEvaluateVO(); |
| | | // 查询站点下的所有订单评价 |
| | | List<TOrderEvaluateVO> tChargingOrders = orderEvaluateMapper.getOrderEvaluateBySiteId(siteId); |
| | | if(!CollectionUtils.isEmpty(tChargingOrders)){ |
| | | siteDetailEvaluateVO.setOrderEvaluateVOS(tChargingOrders); |
| | | // 统计好评率 |
| | | long goodCount = tChargingOrders.stream().filter(orderEvaluateVO -> orderEvaluateVO.getMark()>=4).count(); |
| | | BigDecimal reviewRate = new BigDecimal(goodCount).divide(new BigDecimal(tChargingOrders.size())).setScale(2, BigDecimal.ROUND_HALF_UP); |
| | | siteDetailEvaluateVO.setReviewRate(reviewRate); |
| | | siteDetailEvaluateVO.setEvaluateCount(tChargingOrders.size()); |
| | | siteDetailEvaluateVO.setOrderEvaluateVOS(tChargingOrders.stream().limit(3).collect(Collectors.toList())); |
| | | } |
| | | return siteDetailEvaluateVO; |
| | | } |
| | | |
| | | /** |
| | | * 统计有图,好评,中差评数量 |
| | | * @param count |