Commit 5bd34645 by huangjinxin

fix:工程师当天工单统计

1 parent 9faeb170
......@@ -32,6 +32,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findByEngineerCodeAndDtAndAppointmentStatusIn(String engineerCode, LocalDate dt, List<String> appointmentStatus, Sort sort);
List<OrderInfoEntity> findByDtAndEngineerCode(LocalDate dt, String engineerCode, Sort sort);
List<OrderInfoEntity> findByDtAndOrgTeamIdAndAppointmentStatusIn(LocalDate dt, String orgTeamId, List<String> appointmentStatus);
OrderInfoEntity findTopBySkillAndAppointmentStatus(String skill, String status);
......
......@@ -4,6 +4,6 @@ package com.dituhui.pea.order.enums;
* 订单流程枚举类
*/
public enum OrderFlowEnum {
// 指派状态: INIT-待指派/PRE-预指派/CONFIRM-确认指派(通知BEAN)
INIT, PRE, CONFIRM,
// 指派状态: INIT-待指派/PRE-预指派/CONFIRM-确认指派(通知BEAN)/CANCELED-已取消
INIT, PRE, CONFIRM,CANCELED
}
......@@ -102,4 +102,14 @@ public interface EngineerCalendarService {
* @return 全天休息(含请假)返回true, 否则false
*/
boolean engineerTargetLeave(String engineerCode, LocalDate targetDate);
/**
* 判定工程师当天是否请假(非派工时间)或者休息
*
* @param engineerCode 工程师编号
* @param targetDate 目标日期
* @return 休息(含请假)返回true, 否则false
*/
boolean engineerDayLeave(String engineerCode, LocalDate targetDate);
}
......@@ -748,6 +748,18 @@ public class EngineerCalendarServiceImpl implements EngineerCalendarService {
return true;
}
@Override
public boolean engineerDayLeave(String engineerCode, LocalDate targetDate) {
boolean leaveDay = engineerWorkDay(engineerCode, targetDate);
if (!leaveDay) {
return leaveDay;
}
//日程表事件记录时间
List<CapacityEngineerCalendarEntity> configs = capacityEngineerCalendarDao.findCalendarByWorkdayAndEngineerCode(DateTimeUtil.formatDate(targetDate), engineerCode);
return !CollectionUtils.isEmpty(configs);
}
private EngineerCalendarDTO.Calendar getEmptyCalendar(String teamId, String date) {
// 初始化一天的日历
EngineerCalendarDTO.Calendar calendar = new EngineerCalendarDTO.Calendar();
......
......@@ -184,7 +184,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
//处理一家多单逻辑
Result<String> deleteMultipleOrders = this.deleteMultipleOrders(orderInfo.getMultipleOrders(), orderInfo.getOrderId());
if (!deleteMultipleOrders.getCode().equals(ResultEnum.SUCCESS.getCode())) {
throw new BusinessException("改约日期失败");
throw new BusinessException("取消工单失败");
}
OrgGroupEntity orgGroupEntity = null;
......
......@@ -14,7 +14,10 @@ import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.*;
import com.dituhui.pea.order.entity.*;
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.VehicleEnum;
import com.dituhui.pea.order.service.EngineerCalendarService;
import com.dituhui.pea.order.service.ScheduleService;
import com.dituhui.pea.order.utils.CommonUtil;
import com.dituhui.pea.order.utils.OrderUtil;
......@@ -63,6 +66,9 @@ public class ScheduleServiceImpl implements ScheduleService {
@Autowired
private SkillInfoDao skillInfoDao;
@Autowired
private EngineerCalendarService engineerCalendarService;
@Override
public Result<?> getScheduleSummary(LocalDate date, String levelType, List<String> levelValue) {
List<ScheduleSummaryResp.ItemDTO> items = new ArrayList<>();
......@@ -211,7 +217,7 @@ public class ScheduleServiceImpl implements ScheduleService {
EngineerInfoEntity engineer = engineerInfoDao.getByEngineerCode(engineerCode);
if (engineer == null) {
throw new BusinessException("分销员不存在");
throw new BusinessException("工程师不存在");
}
EngineerBusinessEntity engineerBusinessEntity = engineerBusinessDao.getByEngineerCode(engineerCode);
List<LabelValueDTO> emptyTips = new ArrayList<>();
......@@ -223,9 +229,11 @@ public class ScheduleServiceImpl implements ScheduleService {
sortType = "asc";
}
Sort sort = Sort.by(Sort.Direction.valueOf(sortType.toUpperCase()), sortColumn);
List<OrderInfoEntity> orderAppointments = orderInfoDao.findByEngineerCodeAndDtAndAppointmentStatusIn(
engineerCode, date, List.of(OrderFlowEnum.PRE.name(), OrderFlowEnum.CONFIRM.name()), sort);
//查询包含已取消在内所以工单,后续数据筛选只用预指派和确认指派数据
List<OrderInfoEntity> orderAppointmentsAll = orderInfoDao.findByDtAndEngineerCode(date, engineerCode, sort);
List<OrderInfoEntity> orderAppointments = orderAppointmentsAll.stream().filter(e -> (e.getAppointmentStatus()
.equals(OrderFlowEnum.PRE.name())) || e.getAppointmentStatus().equals(OrderFlowEnum.CONFIRM.name()))
.collect(Collectors.toList());
List<TimeLineDTO> timelines = new ArrayList<>();
int sumDistance = 0;
int sumElapsed = 0;
......@@ -248,8 +256,11 @@ public class ScheduleServiceImpl implements ScheduleService {
}
Map<String, List<OrderInfoEntity>> statusGroup = orderAppointments.stream().collect(Collectors.groupingBy(OrderInfoEntity::getServiceStatus));
Map<String, List<OrderInfoEntity>> orderStatusGroup = orderAppointmentsAll.stream().collect(Collectors.groupingBy(OrderInfoEntity::getOrderStatus));
List<OrderInfoEntity> empty = new ArrayList<>();
Integer countPending = statusGroup.getOrDefault("INIT", empty).size() + statusGroup.getOrDefault("CONTACTED", empty).size() + statusGroup.getOrDefault("PENDING", empty).size();
Integer countPending = statusGroup.getOrDefault(ServiceStatusEnum.CONTACTED.getCode(), empty).size() +
statusGroup.getOrDefault(ServiceStatusEnum.PENDING.getCode(), empty).size();
// statusGroup.getOrDefault(ServiceStatusEnum.INIT.getCode(), empty).size() +
ScheduleEngineerOverviewDynamics dynamics = new ScheduleEngineerOverviewDynamics();
dynamics.setGroupName(groupName);
......@@ -258,13 +269,14 @@ public class ScheduleServiceImpl implements ScheduleService {
dynamics.setPhone(engineer.getPhone());
dynamics.setGrade(engineer.getGrade());
dynamics.setDate(TimeUtils.IsoLocalDate2String(date));
dynamics.setStatus("上班");
// 判断工程师是否请假
dynamics.setStatus(engineerCalendarService.engineerDayLeave(engineer.getEngineerCode(), date) ? "非派工类出勤" : "上班");
dynamics.setOrderCount(orderAppointments.size());
dynamics.setToServiceCount(countPending);
dynamics.setInServiceCount(statusGroup.getOrDefault("STARTED", empty).size());
dynamics.setFinishedCount(statusGroup.getOrDefault("FINISHED", empty).size());
dynamics.setCanceledCount(statusGroup.getOrDefault("CANCELED", empty).size());
dynamics.setRescheduledCount(statusGroup.getOrDefault("RESCHEDULED", empty).size());
dynamics.setInServiceCount(statusGroup.getOrDefault(ServiceStatusEnum.STARTED.getCode(), empty).size());
dynamics.setFinishedCount(statusGroup.getOrDefault(ServiceStatusEnum.FINISHED.getCode(), empty).size());
dynamics.setCanceledCount(orderStatusGroup.getOrDefault(OrderStatusEnum.CANCELED.getCode(), empty).size());
dynamics.setRescheduledCount(orderStatusGroup.getOrDefault(OrderStatusEnum.RESCHEDULED.getCode(), empty).size());
dynamics.setRoadTotalElapsedTime(new BigDecimal(sumElapsed)
.divide(new BigDecimal(60), 2, RoundingMode.HALF_UP)
.stripTrailingZeros()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!