Commit 6d7f4d37 by 刘鑫

feat(工作日历): 修改检查日程时间窗时跳过正在被修改的日程

1 parent 4adf9aaa
......@@ -40,6 +40,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
......@@ -195,7 +196,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
if (time1.isBefore(LocalDateTime.now()) || time2.isBefore(LocalDateTime.now())) {
return Result.failed("只能更新未来时间");
}
Optional<CheckTime> checkTimeOptional = checkTimesHasOverlap(time1.toLocalDate(), engineerCode, time1, time2);
Optional<CheckTime> checkTimeOptional = checkTimesHasOverlap(time1.toLocalDate(), engineerCode, time1, time2, reqDTO.getPlanId());
if (checkTimeOptional.isPresent()) {
CheckTime checkTime = checkTimeOptional.get();
throw new BusinessException("工号为" + engineerCode + "的工程师在"
......@@ -313,7 +314,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
if (beginDate.isEqual(endDate)) {
LocalDateTime startTime = DateUtils.localDateTimeFromStr(beginTime);
LocalDateTime endTime1 = DateUtils.localDateTimeFromStr(endTime);
Optional<CheckTime> checkTimeOptional = checkTimesHasOverlap(endDate, engineerCode, startTime, endTime1);
Optional<CheckTime> checkTimeOptional = checkTimesHasOverlap(endDate, engineerCode, startTime, endTime1, "");
if (checkTimeOptional.isPresent()) {
CheckTime checkTime = checkTimeOptional.get();
throw new BusinessException("工号为" + engineerCode + "的工程师在"
......@@ -369,7 +370,7 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
e.setEndTime(DateUtils.localDateTimeFromStr(etime));
}
//校验是否有当天时间段的记录
Optional<CheckTime> checkTimeOptional = checkTimesHasOverlap(current, engineerCode, e.getStartTime(), e.getEndTime());
Optional<CheckTime> checkTimeOptional = checkTimesHasOverlap(current, engineerCode, e.getStartTime(), e.getEndTime(), "");
if (checkTimeOptional.isPresent()) {
CheckTime checkTime = checkTimeOptional.get();
throw new BusinessException("工号为" + engineerCode + "的工程师在"
......@@ -390,12 +391,18 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
}
private Optional<CheckTime> checkTimesHasOverlap(LocalDate date,
String engineerCode, LocalDateTime dynaStartTime, LocalDateTime dynaEndTime) {
String engineerCode, LocalDateTime dynaStartTime, LocalDateTime dynaEndTime,
String excludePlanId) {
//获取指定日期的工作人员日历
List<CapacityEngineerCalendarEntity> calendar = capacityEngineerCalendarDao.findCalendarByWorkdayAndEngineerCode(DateTimeUtil.formatDate(date), engineerCode);
if (CollectionUtils.isEmpty(calendar)) {
return Optional.empty();
}
if (StringUtils.isNotBlank(excludePlanId)) {
calendar = calendar.stream()
.filter(t -> !Objects.equals(t.getPlanId(), excludePlanId))
.collect(Collectors.toList());
}
//进行时间交集检查, 如果有交集返回 true 无则返回
return calendar.stream()
.filter(t -> {
......
......@@ -9,12 +9,11 @@ import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.common.OrderAssignCheck;
import com.dituhui.pea.order.common.Stapial4jUtil;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.common.jackson.DateUtil;
import com.dituhui.pea.order.dao.EngineerBusinessDao;
import com.dituhui.pea.order.dao.EngineerInfoDao;
import com.dituhui.pea.order.dao.EngineerSkillGroupDao;
import com.dituhui.pea.order.dao.OrderInfoDao;
import com.dituhui.pea.order.dao.OrgBranchDao;
import com.dituhui.pea.order.dao.OrgGroupDao;
import com.dituhui.pea.order.dao.OrgTeamDao;
import com.dituhui.pea.order.dao.OrgTeamEngineerDao;
import com.dituhui.pea.order.dao.SkillInfoDao;
......@@ -39,9 +38,8 @@ import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.enums.OrderStatusEnum;
import com.dituhui.pea.order.enums.ServiceStatusEnum;
import com.dituhui.pea.order.enums.TestimonialsEngineerTag;
import com.dituhui.pea.order.service.CapacityQueryService;
import com.dituhui.pea.order.service.CommonService;
import com.dituhui.pea.order.service.FendanService;
import com.dituhui.pea.order.service.EngineerCalendarService;
import com.dituhui.pea.order.service.MsgService;
import com.dituhui.pea.order.service.OrderAssign;
import com.dituhui.pea.order.service.OrderInfoService;
......@@ -114,25 +112,16 @@ public class OrderAssignImpl implements OrderAssign {
private OrderInfoService orderInfoService;
@Autowired
private OrgGroupDao orgGroupDao;
@Autowired
private FendanService fendanService;
@Autowired
private OrgBranchDao orgBranchDao;
@Autowired
private MsgService msgService;
@Autowired
private CapacityQueryService capacityQueryService;
@Autowired
private IUser userService;
@Autowired
private EngineerBusinessDao engineerBusinessDao;
@Autowired
private EngineerCalendarService engineerCalendarService;
@Transactional
@Override
......@@ -144,9 +133,12 @@ public class OrderAssignImpl implements OrderAssign {
}
String date = TimeUtils.IsoLocalDate2String(order.getDt());
LocalDate targetDate = LocalDate.parse(date, DateUtil.DATE_FORMATTER);
// 获取符合筛选条件的技术员
// 改造本方法 让其支持标签返回
List<TempEngineer> engineerLocationList = this.searchEngineerCodes(order, req.getDistance(), req.getKey(), req.getRecommend(), req.getUserId());
List<TempEngineer> engineerLocationList = this.searchEngineerCodes(order, req.getDistance(), req.getKey(),
req.getRecommend(), req.getUserId(), targetDate);
List<String> engineerCodes = engineerLocationList.stream().map(TempEngineer::getEngineerCode).collect(Collectors.toList());
Map<String, TempEngineer> engineerDistanceMap = engineerLocationList.stream().collect(Collectors.toMap(
TempEngineer::getEngineerCode,
......@@ -191,7 +183,7 @@ public class OrderAssignImpl implements OrderAssign {
engineerTag = TestimonialsEngineerTag.TEAM;
} else if (tempEngineer.getDistance().compareTo(judgeDistance) <= 0) {
engineerTag = TestimonialsEngineerTag.PERIPHERAL;
} else if (req.isSearch()){
} else if (req.isSearch()) {
engineerTag = TestimonialsEngineerTag.SEARCH;
} else {
engineerTag = TestimonialsEngineerTag.NONE;
......@@ -323,7 +315,8 @@ public class OrderAssignImpl implements OrderAssign {
return order;
}
private List<TempEngineer> searchEngineerCodes(OrderInfoEntity order, Double distance, String key, String recommend, String userId) {
private List<TempEngineer> searchEngineerCodes(OrderInfoEntity order, Double distance, String key, String recommend,
String userId, LocalDate targetDate) {
Set<String> engineerCodes1 = this.searchEngineerByRecommend(order, recommend, userId);
if (engineerCodes1.isEmpty()) {
log.info("recommend:{}筛选条件未找到技术员", recommend);
......@@ -364,8 +357,10 @@ public class OrderAssignImpl implements OrderAssign {
double orderLongitude = Double.parseDouble(order.getX());
double orderLatitude = Double.parseDouble(order.getY());
//TODO 排除当天已经请假或者休息的人员
//排除当天已经请假或者休息的人员
engineerCodes1 = engineerCodes1.stream()
.filter(engineerCode -> !engineerCalendarService.engineerTargetLeave(engineerCode, targetDate))
.collect(Collectors.toSet());
//均计算距离
List<TempEngineer> result = engineerCodes1.stream()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!