|
|
|
@ -19,16 +19,15 @@ import com.ruoyi.applet.pojo.dto.filterQualifiedUsersVo; |
|
|
|
import com.ruoyi.common.exception.ServiceException; |
|
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.model.domain.AppletAddress; |
|
|
|
import com.ruoyi.model.domain.AppletOrder; |
|
|
|
import com.ruoyi.model.domain.AppletOutDate; |
|
|
|
import com.ruoyi.model.domain.*; |
|
|
|
import com.ruoyi.model.service.IAppletAddressService; |
|
|
|
import com.ruoyi.model.service.IAppletOutDateService; |
|
|
|
import com.ruoyi.model.service.IAppletUsersTeacherService; |
|
|
|
import lombok.extern.log4j.Log4j2; |
|
|
|
import org.apache.commons.collections.CollectionUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.ruoyi.model.mapper.AppUsersMapper; |
|
|
|
import com.ruoyi.model.domain.AppUsers; |
|
|
|
import com.ruoyi.model.service.IAppUsersService; |
|
|
|
|
|
|
|
/** |
|
|
|
@ -53,6 +52,9 @@ public class AppUsersServiceImpl extends ServiceImpl<AppUsersMapper, AppUsers> i |
|
|
|
@Autowired |
|
|
|
private IAppletAddressService appletAddressService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private IAppletUsersTeacherService appletUsersTeacherService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询用户 |
|
|
|
* |
|
|
|
@ -137,20 +139,35 @@ public class AppUsersServiceImpl extends ServiceImpl<AppUsersMapper, AppUsers> i |
|
|
|
public List<AppUsers> filterQualifiedUsers(filterQualifiedUsersVo filterVo) { |
|
|
|
List<AppUsers> qualifiedTechnicians = new ArrayList<>(); |
|
|
|
|
|
|
|
// 排除的地址 |
|
|
|
ArrayList<Long> notAddressIds = new ArrayList<>(); |
|
|
|
|
|
|
|
// 缓存的地址列表 |
|
|
|
List<AppletAddress> addressList = new ArrayList<>(); |
|
|
|
|
|
|
|
LambdaQueryChainWrapper<AppletAddress> addressQW = appletAddressService.lambdaQuery(); |
|
|
|
|
|
|
|
List<Date> dates = new ArrayList<>(); |
|
|
|
|
|
|
|
//查询的用户id |
|
|
|
List<Long> qualifiedUserId = new ArrayList<>(); |
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
|
|
|
|
//根据不接单日期排除地址 |
|
|
|
// |
|
|
|
if (ObjectUtils.isNotEmpty(filterVo.getTimeArray())){ |
|
|
|
for (String d : filterVo.getTimeArray()) { |
|
|
|
try { |
|
|
|
dates.add(sdf.parse(d)); |
|
|
|
} catch (ParseException e) { |
|
|
|
log.error(e.getMessage()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//根据订单的查询服务日期 |
|
|
|
if (ObjectUtils.isNotEmpty(filterVo.getOrderId())){ |
|
|
|
List<Date> dates = omsOrderServiceMapper.selectList(Wrappers.<OmsOrderService> |
|
|
|
lambdaQuery() |
|
|
|
.select(OmsOrderService::getServiceDate) |
|
|
|
.eq(OmsOrderService::getOrderId, filterVo.getOrderId())) |
|
|
|
omsOrderServiceMapper.selectList(Wrappers.<OmsOrderService> |
|
|
|
lambdaQuery() |
|
|
|
.select(OmsOrderService::getServiceDate) |
|
|
|
.eq(OmsOrderService::getOrderId, filterVo.getOrderId())) |
|
|
|
.stream().map(n -> { |
|
|
|
try { |
|
|
|
return sdf.parse(n.getServiceDate()); |
|
|
|
@ -158,18 +175,19 @@ public class AppUsersServiceImpl extends ServiceImpl<AppUsersMapper, AppUsers> i |
|
|
|
return null; |
|
|
|
} |
|
|
|
}) |
|
|
|
.filter(n -> ObjectUtils.isNotEmpty(n)) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
.filter(ObjectUtils::isNotEmpty) |
|
|
|
.forEach(dates::add); |
|
|
|
} |
|
|
|
|
|
|
|
if (!dates.isEmpty()){ |
|
|
|
appletOutDateService.lambdaQuery().in(AppletOutDate::getDate, dates) |
|
|
|
.select(AppletOutDate::getAddressId) |
|
|
|
.groupBy(AppletOutDate::getAddressId) |
|
|
|
.list().stream().forEach(n -> |
|
|
|
.select(AppletOutDate::getAddressId) |
|
|
|
.groupBy(AppletOutDate::getAddressId) |
|
|
|
.list().forEach(n -> |
|
|
|
notAddressIds.add(n.getAddressId()) |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 2. 根据订单经纬度查询范围内的地址 |
|
|
|
if (ObjectUtils.isNotEmpty(filterVo.getLatitude()) && |
|
|
|
ObjectUtils.isNotEmpty(filterVo.getLongitude())) { |
|
|
|
@ -201,7 +219,6 @@ public class AppUsersServiceImpl extends ServiceImpl<AppUsersMapper, AppUsers> i |
|
|
|
.list(); |
|
|
|
|
|
|
|
// 3. 筛选在范围内的地址 |
|
|
|
List<Long> qualifiedUserId = new ArrayList<>(); |
|
|
|
for (AppletAddress address : addressList) { |
|
|
|
if (StringUtils.isNotEmpty(address.getLatitude()) && |
|
|
|
StringUtils.isNotEmpty(address.getLongitude()) && |
|
|
|
@ -228,18 +245,41 @@ public class AppUsersServiceImpl extends ServiceImpl<AppUsersMapper, AppUsers> i |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 4. 根据地址ID和技师等级查询符合条件的技师 |
|
|
|
qualifiedTechnicians = appUsersMapper.selectList( |
|
|
|
Wrappers.<AppUsers>lambdaQuery() |
|
|
|
.eq(ObjectUtils.isNotEmpty(filterVo.getCompanionLevel()),AppUsers::getUserBcsRole, filterVo.getCompanionLevel()) |
|
|
|
.eq(AppUsers::getUserBcs, 1) |
|
|
|
|
|
|
|
//4、根据技师中的信息进行筛选 |
|
|
|
if (ObjectUtils.isNotEmpty(filterVo.getSex()) |
|
|
|
|| StringUtils.isNotEmpty(filterVo.getPetTypes())){ |
|
|
|
ArrayList<Long> ids = new ArrayList<>(); |
|
|
|
List<AppletUsersTeacher> list = appletUsersTeacherService.lambdaQuery() |
|
|
|
.eq(ObjectUtils.isNotEmpty(filterVo.getSex()), AppletUsersTeacher::getSex, filterVo.getSex()) |
|
|
|
.like(StringUtils.isNotEmpty(filterVo.getPetTypes()), AppletUsersTeacher::getPetType, filterVo.getPetTypes()) |
|
|
|
.select(AppletUsersTeacher::getUserId, AppletUsersTeacher::getSex) |
|
|
|
.list(); |
|
|
|
|
|
|
|
for (AppletUsersTeacher teacher : list) { |
|
|
|
if (teacher != null && teacher.getUserId() != null){ |
|
|
|
ids.add(teacher.getUserId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
qualifiedUserId = (List<Long>) CollectionUtils.intersection(qualifiedUserId, ids); |
|
|
|
} |
|
|
|
|
|
|
|
// 5. 根据地址ID和技师等级查询符合条件的技师 |
|
|
|
if (!qualifiedUserId.isEmpty()){ |
|
|
|
qualifiedTechnicians = appUsersMapper.selectList( |
|
|
|
Wrappers.<AppUsers>lambdaQuery() |
|
|
|
.eq(ObjectUtils.isNotEmpty(filterVo.getCompanionLevel()), AppUsers::getUserBcsRole, filterVo.getCompanionLevel()) |
|
|
|
.eq(AppUsers::getUserBcs, 1) |
|
|
|
// .and(ObjectUtils.isNotEmpty(filterVo.getCompanionLevel()), n -> { |
|
|
|
// n.eq(AppUsers::getUserBcsRole, filterVo.getCompanionLevel()) |
|
|
|
// .or() |
|
|
|
// .in(filterVo.getCompanionLevel() == 0, AppUsers::getUserBcsRole, 1,2); |
|
|
|
// }) |
|
|
|
.in(qualifiedUserId.size() > 0, AppUsers::getUserId, qualifiedUserId) |
|
|
|
); |
|
|
|
.like(StringUtils.isNotEmpty(filterVo.getStaffName()), AppUsers::getUserName, filterVo.getStaffName()) |
|
|
|
.in(AppUsers::getUserId, qualifiedUserId) |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
for (AppUsers users : qualifiedTechnicians) { |
|
|
|
|