Commit 7186b6c1 by Ren Ping

Merge remote-tracking branch 'origin/develop' into develop

2 parents a4fe31c8 9b3a3543
......@@ -6,7 +6,7 @@ import lombok.Data;
public class DistanceDTO {
/**
* 单位 公里
* 单位 米
*/
float dis;
/**
......
......@@ -6,6 +6,8 @@ import com.dituhui.pea.order.dto.BusinessServiceBlockAddReqDTO;
import com.dituhui.pea.order.dto.BusinessServiceBlockRemoveReqDTO;
import com.dituhui.pea.order.dto.BusinessServiceBlockUpdateReqDTO;
import com.dituhui.pea.order.service.BusinessBlockService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -26,16 +28,29 @@ public class BusinessBlockController {
* @param size 分页-页大小
* @param layerId 图层ID(筛选项)
* @param teamId 小队ID(筛选项)
* @param orderBy 排序字段 默认"teamId"
* @param direction 排序方向 desc降序/asc升序 默认"asc"
* @return
*/
@GetMapping("/business/service/block/list")
public Result<?> businessSeverBlocks(@RequestParam String levelType, @RequestParam String levelValue,
@RequestParam int page, @RequestParam int size,
@RequestParam(required = false) String layerId,
@RequestParam(required = false) String teamId) {
@RequestParam(required = false) String teamId,
@RequestParam(required = false) String orderBy,
@RequestParam(required = false) String direction
) {
if (StringUtils.isEmpty(orderBy)) {
orderBy = "teamId";
}
if (StringUtils.isEmpty(direction)) {
direction = "asc";
}
Result<?> res = null;
try {
res = businessBlockService.businessServerBlocks(levelType, levelValue, page, size, layerId, teamId);
res = businessBlockService.businessServerBlocks(levelType, levelValue, page, size, layerId, teamId, orderBy,
direction);
} catch (BusinessException e) {
return Result.failed(e.getMessage());
}
......
......@@ -82,27 +82,27 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and (service_status ='INIT' or service_status ='CONTACTED') " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > expect_time_begin and org_cluster_id = :orgCusterId", nativeQuery = true)
"and DATE_SUB(NOW(), INTERVAL 10 MINUTE) > plan_start_time and org_cluster_id = :orgCusterId", nativeQuery = true)
long countDelayByDtAndOrgClusterId(LocalDate dt, String orgCusterId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and (service_status ='INIT' or service_status ='CONTACTED') " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > expect_time_begin and org_group_id = :orgGroupId", nativeQuery = true)
"and DATE_SUB(NOW(), INTERVAL 10 MINUTE) > plan_start_time and org_group_id = :orgGroupId", nativeQuery = true)
long countDelayByDtAndOrgGroupId(LocalDate dt, String orgGroupId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and (service_status ='INIT' or service_status ='CONTACTED') " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > expect_time_begin and org_branch_id = :orgBranchId", nativeQuery = true)
"and DATE_SUB(NOW(), INTERVAL 10 MINUTE) > plan_start_time and org_branch_id = :orgBranchId", nativeQuery = true)
long countDelayByDtAndOrgBranchId(LocalDate dt, String orgBranchId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and service_status ='STARTED' and actual_end_time is null " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_cluster_id = :orgCusterId", nativeQuery = true)
"and DATE_SUB(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_cluster_id = :orgCusterId", nativeQuery = true)
long countOvertimeByDtAndOrgClusterId(LocalDate dt, String orgCusterId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and service_status ='STARTED' and actual_end_time is null " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_group_id = :orgGroupId", nativeQuery = true)
"and DATE_SUB(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_group_id = :orgGroupId", nativeQuery = true)
long countOvertimeByDtAndOrgGroupId(LocalDate dt, String orgGroupId);
@Query(value = "SELECT count(*) from order_info WHERE dt =:dt and service_status ='STARTED' and actual_end_time is null " +
"and DATE_ADD(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_branch_id = :orgBranchId", nativeQuery = true)
"and DATE_SUB(NOW(), INTERVAL 10 MINUTE) > plan_end_time and org_branch_id = :orgBranchId", nativeQuery = true)
long countOvertimeByDtAndOrgBranchId(LocalDate dt, String orgBranchId);
@Query(value = "from OrderInfoEntity where orderStatus <> 'CANCELED'"
......
......@@ -43,4 +43,14 @@ public class OrderServiceListReq {
* 服务状态
*/
private List<String> serviceStatus;
/**
* 1所需工时、2创建时间、3预约单状态、4指派状态、5指派策略、6服务状态 默认2创建时间
*/
private Integer orderByField = 2;
/**
* 1正序、2倒序 默认2倒序
*/
private Integer orderBy = 2;
}
\ No newline at end of file
......@@ -4,7 +4,7 @@ import com.dituhui.pea.common.Result;
public interface BusinessBlockService {
Result<?> businessServerBlocks(String levelType, String levelValue, int page, int size, String layerId, String teamId);
Result<?> businessServerBlocks(String levelType, String levelValue, int page, int size, String layerId, String teamId, String orderBy, String direction);
Result<?> businessServiceBlockAdd(String layerId, String teamId);
......
......@@ -62,7 +62,7 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
private EncryptionUtil encryptionUtil;
@Override
public Result<?> businessServerBlocks(String levelType, String levelValue, int page, int size, String layerId, String teamId) {
public Result<?> businessServerBlocks(String levelType, String levelValue, int page, int size, String layerId, String teamId, String orderBy, String direction) {
BusinessServerBlocksRespDTO resp = new BusinessServerBlocksRespDTO();
List<OrgTeamEntity> teams = new ArrayList<>();
......@@ -116,7 +116,19 @@ public class BusinessBlockServiceImpl implements BusinessBlockService {
}
return criteriaBuilder.and(statusPredicate, teamIdPredicate, layerIdPredicate);
};
Sort sort = Sort.by(Sort.Order.asc("teamId"));
Sort sort = null;
switch (direction) {
case "asc":
case "ASC":
case "Asc":
sort = Sort.by(Sort.Order.asc(orderBy));
break;
case "desc":
case "DESC":
case "Desc":
sort = Sort.by(Sort.Order.desc(orderBy));
break;
}
PageRequest pageRequest = PageRequest.of(page - 1, size, sort);
Page<MapBlockInfoEntity> pg = mapBlockInfoDao.findAll(specification, pageRequest);
......
......@@ -7,6 +7,7 @@ import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.ListUtils;
import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.common.jackson.JsonUtil;
import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListReq;
import com.dituhui.pea.order.dto.DispatchEngineerOrderListResp;
......@@ -348,6 +349,7 @@ public class DispatchServiceImpl implements DispatchService {
SkillInfoEntity skill = skillInfoDao.getByBrandAndTypeAndSkill(CommonUtil.fixBrand(entity.getBrand()), entity.getType(), entity.getSkill());
List<OrderInfoEntity> engineerOrders = orderInfoDao.findByDtAndEngineerCode(localDate, engineer.getEngineerCode());
Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer);
log.info("插入订单信息------------->{}", JsonUtil.toJson(entityResult));
if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
// return Result.failed("当前工程师无法预约合适时间");
errorList.add("单号:" + entity.getOrderId());
......
......@@ -10,6 +10,7 @@ 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.common.jackson.JsonUtil;
import com.dituhui.pea.order.dao.EngineerInfoDao;
import com.dituhui.pea.order.dao.EngineerSkillGroupDao;
import com.dituhui.pea.order.dao.OrderInfoDao;
......@@ -232,6 +233,7 @@ public class OrderAssignImpl implements OrderAssign {
//判断工程师订单当日工单时间安排
List<OrderInfoEntity> engineerOrders = orderInfoDao.findByDtAndEngineerCode(entity.getDt(), engineer.getEngineerCode());
Result<OrderInfoEntity> entityResult = orderInfoService.insterEngineerOrders(engineerOrders, entity, skill, byTeamId, engineer);
log.info("插入订单信息------------->{}", JsonUtil.toJson(entityResult));
if (!entityResult.getCode().equals(ResultEnum.SUCCESS.getCode())) {
String desc = StatusCodeEnum.ENGINEER_IS_LEAVE_TIME.getDesc();
desc = String.format(desc, orderId, engineer.getName());
......
......@@ -478,6 +478,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
@Override
public Result<OrderInfoEntity> insterEngineerOrders(List<OrderInfoEntity> engineerOrders, OrderInfoEntity insertOrder, SkillInfoEntity skillInfo, OrgTeamEntity orgTeam, EngineerInfoEntity engineer) {
//查询工程师当天请假时间
log.info("待插入订单信息------------->{}", JsonUtil.toJson(insertOrder));
List<OccupyInfoDetail> engineerLeaveTimeSlice = engineerCalendarService.getEngineerWorkDayCalendar(engineer.getEngineerCode(), insertOrder.getDt());
log.info("【engineerWorkTimeSlice】结果------------->{}", JsonUtil.toJson(engineerLeaveTimeSlice));
// 没有单直接返回
......@@ -487,6 +488,8 @@ public class OrderInfoServiceImpl implements OrderInfoService {
return Result.failed(insertOrder);
}
LocalDateTime planStartTime = (LocalDateTime) handleLeaveTimeResult.getResult();
insertOrder.setArriveElapsed(0);
insertOrder.setArriveDistance(0);
insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
......@@ -517,6 +520,8 @@ public class OrderInfoServiceImpl implements OrderInfoService {
return Result.failed(insertOrder);
}
LocalDateTime planStartTime = (LocalDateTime) handleLeaveTimeResult.getResult();
insertOrder.setArriveElapsed(0);
insertOrder.setArriveDistance(0);
insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
......@@ -537,7 +542,10 @@ public class OrderInfoServiceImpl implements OrderInfoService {
int moveTime = 0;
for (int i = 0; i < orderSegments.size(); i++) {
OrderSegment orderSegment = orderSegments.get(i);
if (isMove && !orderSegment.getOrderId().equals(insertOrder.getOrderId()) && moveTime > 0) {
if (isMove) {
if (orderSegment.getOrderId().equals(insertOrder.getOrderId())) {
continue;
}
OrderInfoEntity nestOrder = orderInfoDao.getByOrderId(orderSegment.getOrderId());
nestOrder.setPlanStartTime(nestOrder.getPlanStartTime().plusMinutes(moveTime));
nestOrder.setPlanEndTime(nestOrder.getPlanEndTime().plusMinutes(moveTime));
......@@ -560,13 +568,18 @@ public class OrderInfoServiceImpl implements OrderInfoService {
return Result.failed(insertOrder);
}
LocalDateTime planStartTime = (LocalDateTime) handleLeaveTimeResult.getResult();
//第一个没有在途时长
if (i == 0) {
insertOrder.setArriveElapsed(0);
insertOrder.setArriveDistance(0);
}
insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
OrderInfoEntity nestOrder = orderInfoDao.getByOrderId(nestOrderSegment.getOrderId());
nestOrder.setArriveElapsed(roadTime);
nestOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue());
nestOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis()).intValue());
if (orderSegment.getStart().plusMinutes(takeTime + roadTime).compareTo(nestOrder.getPlanStartTime()) > 0) {
long minutes = Duration.between(nestOrder.getPlanStartTime(), planStartTime.plusMinutes(skillInfo.getTakeTime() + roadTime)).toMinutes();
nestOrder.setPlanStartTime(nestOrder.getPlanStartTime().plusMinutes(minutes));
......@@ -587,18 +600,14 @@ public class OrderInfoServiceImpl implements OrderInfoService {
LocalDateTime planStartTime = (LocalDateTime) handleLeaveTimeResult.getResult();
if (orderSegment.getEnd().plusMinutes(roadTime).compareTo(planStartTime) <= 0) {
//下一单为待插入订单且为最后一单直接返回
insertOrder.setArriveElapsed(roadTime);
insertOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis()).intValue());
if (i == orderSegments.size() - 2) {
insertOrder.setTakeTime(skillInfo.getTakeTime());
insertOrder.setPlanStartTime(planStartTime);
insertOrder.setPlanEndTime(planStartTime.plusMinutes(skillInfo.getTakeTime()));
insertOrder.setArriveElapsed(roadTime);
insertOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue());
return Result.success(insertOrder);
}
OrderInfoEntity nestOrder = orderInfoDao.getByOrderId(nestOrderSegment.getOrderId());
nestOrder.setArriveElapsed(roadTime);
nestOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue());
orderInfoDao.save(nestOrder);
continue;
}
insertOrder.setTakeTime(skillInfo.getTakeTime());
......@@ -611,12 +620,16 @@ public class OrderInfoServiceImpl implements OrderInfoService {
log.info("【getRoadDistancePrev】结果------------->{}", JsonUtil.toJson(roadResultPrev));
int roadTimePrev = BigDecimal.valueOf(roadResultPrev.getResult().getTime()).divide(BigDecimal.valueOf(60), 0, RoundingMode.HALF_UP).intValue();
insertOrder.setArriveElapsed(roadTimePrev);
insertOrder.setArriveDistance(BigDecimal.valueOf(roadResultPrev.getResult().getDis() * 1000).intValue());
insertOrder.setArriveDistance(BigDecimal.valueOf(roadResultPrev.getResult().getDis()).intValue());
} else {
// 第一单没有在途时长
insertOrder.setArriveElapsed(0);
insertOrder.setArriveDistance(0);
}
OrderInfoEntity nestOrder = orderInfoDao.getByOrderId(orderSegment.getOrderId());
nestOrder.setArriveElapsed(roadTime);
nestOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis() * 1000).intValue());
nestOrder.setArriveDistance(BigDecimal.valueOf(distanceDTO.getDis()).intValue());
long minutes = Duration.between(nestOrder.getPlanStartTime(), planStartTime.plusMinutes(skillInfo.getTakeTime() + roadTime)).toMinutes();
nestOrder.setPlanStartTime(nestOrder.getPlanStartTime().plusMinutes(minutes));
nestOrder.setPlanEndTime(nestOrder.getPlanEndTime().plusMinutes(minutes));
......
......@@ -21,6 +21,7 @@ import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.service.OrderServiceDetail;
import com.dituhui.pea.order.utils.OrderUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
......@@ -82,7 +83,7 @@ public class OrderServiceDetailImpl implements OrderServiceDetail {
res.setStatus(order.getOrderStatus());
res.setAppointmentStatus(order.getAppointmentStatus());
res.setOrderStatus(order.getOrderStatus());
res.setServiceStatus(order.getServiceStatus());
res.setServiceStatus(OrderUtil.handleServiceStatus(order));
res.setLocation(String.format("%s,%s", order.getX(), order.getY()));
res.setItems(items);
......
......@@ -13,13 +13,16 @@ import com.dituhui.pea.order.dto.OrderServiceList;
import com.dituhui.pea.order.dto.OrderServiceListReq;
import com.dituhui.pea.order.dto.OrderServiceListResp;
import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.enums.ServiceStatusEnum;
import com.dituhui.pea.order.service.OrderServiceListService;
import com.dituhui.pea.order.utils.OrderUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
......@@ -61,7 +64,21 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
lqw.in(StringUtils.isNotEmpty(reqDTO.getOrderId()), OrderInfo::getOrderId, reqDTO.getOrderId().split(","));
}
lqw.eq(StringUtils.isNotEmpty(reqDTO.getPhone()), OrderInfo::getPhone, reqDTO.getPhone());
lqw.in(ListUtils.isNotEmpty(reqDTO.getServiceStatus()), OrderInfo::getServiceStatus, reqDTO.getServiceStatus());
if (ListUtils.isNotEmpty(reqDTO.getServiceStatus())) {
List<String> serviceStatus = reqDTO.getServiceStatus();
if (serviceStatus.contains(ServiceStatusEnum.DELAY.getCode())) {
serviceStatus.add(ServiceStatusEnum.INIT.getCode());
serviceStatus.add(ServiceStatusEnum.CONTACTED.getCode());
lqw.le(OrderInfo::getPlanStartTime, LocalDateTime.now().minusMinutes(10));
}
if (serviceStatus.contains(ServiceStatusEnum.UNFINISHED.getCode())) {
serviceStatus.add(ServiceStatusEnum.STARTED.getCode());
lqw.isNotNull(OrderInfo::getActualEndTime);
lqw.le(OrderInfo::getPlanEndTime, LocalDateTime.now().minusMinutes(10));
}
serviceStatus = serviceStatus.stream().distinct().collect(Collectors.toList());
lqw.in(OrderInfo::getServiceStatus, serviceStatus);
}
lqw.in(ListUtils.isNotEmpty(reqDTO.getOrderStatus()), OrderInfo::getOrderStatus, reqDTO.getOrderStatus());
lqw.in(ListUtils.isNotEmpty(reqDTO.getBranchIds()), OrderInfo::getOrgBranchId, reqDTO.getBranchIds());
lqw.in(ListUtils.isNotEmpty(reqDTO.getGroupIds()), OrderInfo::getOrgGroupId, reqDTO.getGroupIds());
......@@ -69,8 +86,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentType()), OrderInfo::getAppointmentMethod, reqDTO.getAppointmentType());
lqw.in(ListUtils.isNotEmpty(reqDTO.getAppointmentStatus()), OrderInfo::getAppointmentStatus, reqDTO.getAppointmentStatus());
lqw.in(ListUtils.isNotEmpty(reqDTO.getPriorities()), OrderInfo::getBeanPriority, reqDTO.getPriorities());
lqw.orderByDesc(OrderInfo::getCreateTime);
lqw = handleOrderBy(lqw, reqDTO);
if (ListUtils.isNotEmpty(reqDTO.getEngineerCodes())) {
lqw.and(w ->
w.in(OrderInfo::getEngineerCode, reqDTO.getEngineerCodes())
......@@ -149,7 +165,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
record.setAppointmentType(o.getAppointmentMethod());
record.setAppointmentStatus(o.getAppointmentStatus());
record.setOrderStatus(o.getOrderStatus());
record.setServiceStatus(o.getServiceStatus());
record.setServiceStatus(OrderUtil.handleServiceStatus(o));
record.setDispatcher(o.getDispatcher());
record.setCreateTime(TimeUtils.IsoTimestamp2DateTime(o.getCreateTime()));
......@@ -195,6 +211,35 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
}
/**
* 处理订单排序
*
* @param lqw
* @param reqDTO
* @return
*/
private LambdaQueryWrapper<OrderInfo> handleOrderBy(LambdaQueryWrapper<OrderInfo> lqw, OrderServiceListReq reqDTO) {
if (reqDTO.getOrderByField() == 1) {
lqw.orderBy(true, reqDTO.getOrderBy() == 1, OrderInfo::getTakeTime);
}
if (reqDTO.getOrderByField() == 2) {
lqw.orderBy(true, reqDTO.getOrderBy() == 1, OrderInfo::getCreateTime);
}
if (reqDTO.getOrderByField() == 3) {
lqw.orderBy(true, reqDTO.getOrderBy() == 1, OrderInfo::getOrderStatus);
}
if (reqDTO.getOrderByField() == 4) {
lqw.orderBy(true, reqDTO.getOrderBy() == 1, OrderInfo::getAppointmentStatus);
}
if (reqDTO.getOrderByField() == 5) {
lqw.orderBy(true, reqDTO.getOrderBy() == 1, OrderInfo::getAppointmentMethod);
}
if (reqDTO.getOrderByField() == 6) {
lqw.orderBy(true, reqDTO.getOrderBy() == 1, OrderInfo::getServiceStatus);
}
return lqw;
}
/**
* 获取团队配件仓地址
*
* @param orders
......@@ -271,7 +316,7 @@ public class OrderServiceListServiceImpl implements OrderServiceListService {
record.setAppointmentType(o.getAppointmentMethod());
record.setAppointmentStatus(o.getAppointmentStatus());
record.setOrderStatus(o.getOrderStatus());
record.setServiceStatus(o.getServiceStatus());
record.setServiceStatus(OrderUtil.handleServiceStatus(o));
record.setDispatcher(o.getDispatcher());
record.setCreateTime(TimeUtils.IsoLocalDateTime2String(o.getCreateTime()));
......
package com.dituhui.pea.order.utils;
import cn.hutool.core.util.ObjectUtil;
import com.dituhui.pea.order.entity.OrderInfo;
import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.enums.OrderPeaTagsEnum;
import com.dituhui.pea.order.enums.ServiceStatusEnum;
import org.apache.commons.lang3.StringUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -60,16 +62,91 @@ public class OrderUtil {
/**
* 处理工单状态,主要处理以延迟和已超时
*
* @param order
* @return
*/
public static String handleServiceStatus(OrderInfo order) {
if (isDelay(order)) {
return ServiceStatusEnum.DELAY.getCode();
}
if (isOvertime(order)) {
return ServiceStatusEnum.UNFINISHED.getCode();
}
return order.getServiceStatus();
}
/**
* 判断订单是否是延迟订单
*
* @param order
* @return
*/
public static Boolean isDelay(OrderInfo order) {
if (order.getDt().isBefore(LocalDate.now())) {
return false;
}
if (!order.getServiceStatus().equals(ServiceStatusEnum.INIT.getCode()) && !order.getServiceStatus().equals(ServiceStatusEnum.CONTACTED.getCode())) {
return false;
}
if (ObjectUtil.isNull(order.getPlanStartTime())) {
if (order.getExpectTimeBegin().getTime() + 10 * 60 * 1000 < System.currentTimeMillis()) {
return true;
}
}
if (order.getPlanStartTime().getTime() + 10 * 60 * 1000 < System.currentTimeMillis()) {
return true;
}
return false;
}
/**
* 判断订单是否是延迟订单
*
* @param order
* @return
*/
public static Boolean isOvertime(OrderInfo order) {
if (order.getDt().isBefore(LocalDate.now())) {
return false;
}
if (!order.getServiceStatus().equals(ServiceStatusEnum.STARTED.getCode()) || ObjectUtil.isNotNull(order.getActualEndTime())) {
return false;
}
if (ObjectUtil.isNull(order.getPlanEndTime())) {
if (order.getExpectTimeEnd().getTime() + 10 * 60 * 1000 < System.currentTimeMillis()) {
return true;
}
}
if (order.getPlanEndTime().getTime() + 10 * 60 * 1000 < System.currentTimeMillis()) {
return true;
}
return false;
}
/**
* 判断订单是否是延迟订单
*
* @param order
* @return
*/
public static Boolean isDelay(OrderInfoEntity order) {
if (order.getDt().isBefore(LocalDate.now())) {
return false;
}
if (!order.getServiceStatus().equals(ServiceStatusEnum.INIT.getCode()) && !order.getServiceStatus().equals(ServiceStatusEnum.CONTACTED.getCode())) {
return false;
}
if (order.getExpectTimeBegin().plusMinutes(10).isBefore(LocalDateTime.now())) {
if (ObjectUtil.isNull(order.getPlanEndTime())) {
if (order.getExpectTimeEnd().plusMinutes(10).isBefore(LocalDateTime.now())) {
return true;
}
}
if (order.getPlanStartTime().plusMinutes(10).isBefore(LocalDateTime.now())) {
return true;
}
return false;
......@@ -83,9 +160,17 @@ public class OrderUtil {
* @return
*/
public static Boolean isOvertime(OrderInfoEntity order) {
if (order.getDt().isBefore(LocalDate.now())) {
return false;
}
if (!order.getServiceStatus().equals(ServiceStatusEnum.STARTED.getCode()) || ObjectUtil.isNotNull(order.getActualEndTime())) {
return false;
}
if (ObjectUtil.isNull(order.getPlanEndTime())) {
if (order.getExpectTimeEnd().plusMinutes(10).isBefore(LocalDateTime.now())) {
return true;
}
}
if (order.getPlanEndTime().plusMinutes(10).isBefore(LocalDateTime.now())) {
return true;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!