Commit 077e2451 by Ren Ping

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

2 parents 1e784b08 acca7d28
package com.dituhui.pea.order.constant;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 改约原因常量
*/
public class OrderReschedulingReason {
public static Map<String, List<String>> ReschedulingReasonMap = new HashMap<>() {
{
put("服务设备/工具相关", new ArrayList<>() {
{
add("缺少常用必备工具");
add("交通工具不可用");
}
});
put("服务物料/配件相关", new ArrayList<>() {
{
add("配件准备错误");
add("配件未到货");
add("加单服务,没有所需配件");
add("缺少可用的安装类附件");
add("缺少可用的清洁类产品");
add("缺少可用的清洁类产品");
add("缺少可用的消耗品(生料带、鞋套等)");
add("缺少服务所需纸质工单");
}
});
put("服务政策/流程相关", new ArrayList<>() {
{
add("超派");
add("重复单(工程师发起申请按钮,由CC校验取消)");
add("服务指派不准确");
add("转入车间服务流程");
add("退换机方案沟通中");
add("不接受退换机政策");
add("用户考虑费用问题");
add("用户不认可收费标准");
add("用户考虑安装/维修方案");
add("用户不接受维修标准");
add("用户考虑软性故障相关解释");
add("没有相关安装/维修操作指导(不提供此服务)");
}
});
put("安装、维修环境(极端天气)", new ArrayList<>() {
{
add("安装、维修环境不符");
add("极端天气,无法正常上门");
}
});
put("服务关联人员相关", new ArrayList<>() {
{
add("预约排期问题");
add("用户希望更换其他工程师上门");
add("服务工程师技能不符");
add("突发的事件导致工程师无法上门(如请假、生病、事故)");
add("等待支持岗位(投诉组、分部、技术支持)提供方案");
add("拉修/退换机的物流服务不到位");
add("售前送货的物流服务不到位");
}
});
put("暂无法关单,初始服务已完成", new ArrayList<>() {
{
add("用户希望观察使用一段时间");
add("用户本人不在现场");
add("TSS软件系统故障");
add("配件代码未维护进系统");
}
});
put("用户相关", new ArrayList<>() {
{
add("用户不接电话且已短信通知用户(改约3次以内)");
add("3天6次未联系上用户");
add("无法满足消费者夜间上门需求(非加单)");
add("用户期望的服务时间与其他用户冲突");
add("上门前得知外部人员已服务");
add("用户要求自行来分部购买配/附件(仅仓管可选)");
add("机器已退/换,不再需要上门服务(仅行政/用户/CC可选)");
add("非BSH产品");
add("用户主动提出往后改约(必须短信通知用户)");
add("机器故障已消除(仅行政/用户/CC可选)");
add("消费者希望提前上门");
}
});
put("其它原因", new ArrayList<>() {
{
}
});
}
};
}
...@@ -4,7 +4,6 @@ import com.dituhui.pea.common.BusinessException; ...@@ -4,7 +4,6 @@ import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.enums.StatusCodeEnum; import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.jackson.DateUtil; import com.dituhui.pea.order.common.jackson.DateUtil;
import com.dituhui.pea.order.common.jackson.JsonUtil;
import com.dituhui.pea.order.dao.TableCodeCheckDao; import com.dituhui.pea.order.dao.TableCodeCheckDao;
import com.dituhui.pea.order.dto.param.BaseDistance; import com.dituhui.pea.order.dto.param.BaseDistance;
import com.dituhui.pea.order.dto.param.BaseDistanceParam; import com.dituhui.pea.order.dto.param.BaseDistanceParam;
...@@ -37,13 +36,10 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -37,13 +36,10 @@ import org.springframework.web.bind.annotation.RestController;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import java.io.IOException;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.ZoneId; import java.time.ZoneId;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -66,22 +62,6 @@ public class PeaApiController { ...@@ -66,22 +62,6 @@ public class PeaApiController {
private final TableCodeCheckDao tableCodeCheckDao; private final TableCodeCheckDao tableCodeCheckDao;
private static final String capacity = "{\"groupId\": \"G100038\", \"params\": {\"beginDate\": \"2023-07-21\", \"endDate\": \"2023-07-27\", \"services\": [{\"brand\": \"博世\", \"productType\": \"多门冰箱\", \"serviceType\": \"商场样机安装\"}], \"location\": {\"addressId\":\"21231231\", \"latitude\": 120.608463, \"longitude\": 31.318442, \"name\": \"江苏省苏州市姑苏区蒋庙前\", \"address\": \"江苏省苏州市姑苏区解放大街123号\"}}, \"takeTime\": 720, \"datas\": [{\"date\": \"2023-07-21\", \"segments\": [{\"maxDuration\": 90, \"name\": \"全天\", \"beginTime\": \"2023-07-21 08:00:00\", \"endTime\": \"2023-07-21 17:59:59\", \"status\": 1, \"remain\": 3500}, {\"maxDuration\": 45, \"name\": \"上午\", \"beginTime\": \"2023-07-21 08:00:00\", \"endTime\": \"2023-07-21 11:59:59\", \"status\": 1, \"remain\": 2500}, {\"maxDuration\": 60, \"name\": \"下午\", \"beginTime\": \"2023-07-21 13:00:00\", \"endTime\": \"2023-07-21 17:59:59\", \"status\": 0, \"remain\": 1000}, {\"maxDuration\": 60, \"name\": \"时间段\", \"beginTime\": \"2023-07-21 13:00:00\", \"endTime\": \"2023-07-21 15:00:00\", \"status\": 1, \"remain\": 480}]}]}";
private static final String day_capacity = "{\"groupId\": \"G100038\", \"params\": {\"beginDate\": \"2023-07-21\", \"endDate\": \"2023-07-27\", \"services\": [{\"brand\": \"博世\", \"productType\": \"多门冰箱\", \"serviceType\": \"商场样机安装\"}], \"location\": {\"addressId\": \"21231231\", \"latitude\": 120.608463, \"longitude\": 31.318442, \"name\": \"江苏省苏州市姑苏区蒋庙前\", \"address\": \"江苏省苏州市姑苏区解放大街123号\"}}, \"takeTime\": 720, \"datas\": [{\"date\": \"2023-07-21\", \"segments\": [{\"maxDuration\": 90, \"name\": \"全天\", \"beginTime\": \"2023-07-21 08:00:00\", \"endTime\": \"2023-07-21 17:59:59\", \"status\": 1, \"remain\": 3500}]}]}";
private static final String half_capacity = "{\"groupId\": \"G100038\", \"params\": {\"beginDate\": \"2023-07-21\", \"endDate\": \"2023-07-27\", \"services\": [{\"brand\": \"博世\", \"productType\": \"多门冰箱\", \"serviceType\": \"商场样机安装\"}], \"location\": {\"addressId\": \"21231231\", \"latitude\": 120.608463, \"longitude\": 31.318442, \"name\": \"江苏省苏州市姑苏区蒋庙前\", \"address\": \"江苏省苏州市姑苏区解放大街123号\"}}, \"takeTime\": 720, \"datas\": [{\"date\": \"2023-07-22\", \"segments\": [{\"maxDuration\": 90, \"name\": \"全天\", \"beginTime\": \"2023-07-22 08:00:00\", \"endTime\": \"2023-07-22 17:59:59\", \"status\": 1, \"remain\": 3500}, {\"maxDuration\": 45, \"name\": \"上午\", \"beginTime\": \"2023-07-22 08:00:00\", \"endTime\": \"2023-07-22 11:59:59\", \"status\": 1, \"remain\": 2500}, {\"maxDuration\": 60, \"name\": \"下午\", \"beginTime\": \"2023-07-22 13:00:00\", \"endTime\": \"2023-07-22 17:59:59\", \"status\": 0, \"remain\": 1000}]}]}";
private static final String half_capacity2 = "{\"groupId\": \"G100038\", \"params\": {\"beginDate\": \"2023-07-21\", \"endDate\": \"2023-07-27\", \"services\": [{\"brand\": \"博世\", \"productType\": \"多门冰箱\", \"serviceType\": \"商场样机安装\"}], \"location\": {\"addressId\": \"21231231\", \"latitude\": 120.608463, \"longitude\": 31.318442, \"name\": \"江苏省苏州市姑苏区蒋庙前\", \"address\": \"江苏省苏州市姑苏区解放大街123号\"}}, \"takeTime\": 720, \"datas\": [{\"date\": \"2023-07-21\", \"segments\": [{\"maxDuration\": 90, \"name\": \"全天\", \"beginTime\": \"2023-07-21 08:00:00\", \"endTime\": \"2023-07-21 17:59:59\", \"status\": 1, \"remain\": 1000}, {\"maxDuration\": 60, \"name\": \"下午\", \"beginTime\": \"2023-07-21 13:00:00\", \"endTime\": \"2023-07-21 17:59:59\", \"status\": 0, \"remain\": 1000}]}]}";
private static final String date_capacity = "{\"groupId\": \"G100038\", \"params\": {\"beginDate\": \"2023-07-21\", \"endDate\": \"2023-07-27\", \"services\": [{\"brand\": \"博世\", \"productType\": \"多门冰箱\", \"serviceType\": \"商场样机安装\"}], \"location\": {\"addressId\": \"21231231\", \"latitude\": 120.608463, \"longitude\": 31.318442, \"name\": \"江苏省苏州市姑苏区蒋庙前\", \"address\": \"江苏省苏州市姑苏区解放大街123号\"}}, \"takeTime\": 720, \"datas\": [{\"date\": \"2023-07-23\", \"segments\": [{\"maxDuration\": 90, \"name\": \"全天\", \"beginTime\": \"2023-07-23 08:00:00\", \"endTime\": \"2023-07-23 17:59:59\", \"status\": 1, \"remain\": 480}, {\"maxDuration\": 60, \"name\": \"时间段\", \"beginTime\": \"2023-07-23 13:00:00\", \"endTime\": \"2023-07-23 15:00:00\", \"status\": 1, \"remain\": 480}]}]}";
private static final String stage = "{\"orderId\": \"X10001\", \"engineerCode\": \"E12005\", \"engineerName\": \"祝枝山\", \"engineerCodeAssist\": \"E12446\", \"engineerNameAssist\": \"李晓阳\", \"planVisitTime\": \"2023-07-27 12:00:00\", \"realtimeInfo\": {\"engineerLocation\": {\"latitude\": 31.349701, \"longitude\": 120.675945, \"address\": \"江苏省苏州市苏州工业园区和顺路\", \"name\": \"和顺大酒店\"}, \"estimate\": {\"distance\": 2300, \"arriveTime\": \"2023-07-27 12:12:00\"}}}";
private static Map<String, String> makeMap = new HashMap<>() {
{
put("120.056196,28.910257", day_capacity);
put("120.675945,31.349701", half_capacity);
put("120.721813,31.303003", half_capacity2);
put("120.763953,31.318573", date_capacity);
}
};
/** /**
* 3.1GET 查询技术员日历 * 3.1GET 查询技术员日历
* *
...@@ -215,13 +195,8 @@ public class PeaApiController { ...@@ -215,13 +195,8 @@ public class PeaApiController {
* @apiNote 查询预约单状态,返回指定技术员(主,副)信息、推荐上门时间。如果查询为服务当日,增加对应技术员准实时位置,距离公里数,预计到达时间等 * @apiNote 查询预约单状态,返回指定技术员(主,副)信息、推荐上门时间。如果查询为服务当日,增加对应技术员准实时位置,距离公里数,预计到达时间等
*/ */
@GetMapping("/order/stage/query") @GetMapping("/order/stage/query")
public Result<OrderDTO.StageResult> orderStage(@NotBlank @RequestParam("orderId") String orderId) throws IOException { public Result<OrderDTO.StageResult> orderStage(@NotBlank @RequestParam("orderId") String orderId) {
return Result.success(orderCreateService.orderStage(orderId));
OrderDTO.StageResult stageResult = JsonUtil.parse(stage, OrderDTO.StageResult.class).get();
stageResult.setOrderId(orderId);
return Result.success(stageResult);
} }
/** /**
......
...@@ -40,4 +40,14 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS ...@@ -40,4 +40,14 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findByMultipleOrdersAndOrderIdNot(String multipleOrders, String orderId); List<OrderInfoEntity> findByMultipleOrdersAndOrderIdNot(String multipleOrders, String orderId);
List<OrderInfoEntity> findByMultipleOrders(String multipleOrders); List<OrderInfoEntity> findByMultipleOrders(String multipleOrders);
/**
* 获取工程师指定日期内的所有工单
*
* @param engineerCode 工程师编码
* @param targetDate 指定日期
* @return 指定工程师在指定日期内的所有工单
*/
@Query(value = "SELECT * FROM order_info oi WHERE (engineer_code = :engineerCode OR engineer_code_sub =:engineerCode) AND dt = :targetDate", nativeQuery = true)
List<OrderInfoEntity> getEngineerDateOrder(String engineerCode, String targetDate);
} }
...@@ -3,6 +3,8 @@ package com.dituhui.pea.order.dto; ...@@ -3,6 +3,8 @@ package com.dituhui.pea.order.dto;
import com.dituhui.pea.order.dto.param.Location; import com.dituhui.pea.order.dto.param.Location;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.NotBlank;
@Data @Data
public class OrderReschedule { public class OrderReschedule {
private String orderId; private String orderId;
...@@ -23,4 +25,27 @@ public class OrderReschedule { ...@@ -23,4 +25,27 @@ public class OrderReschedule {
* 备注 * 备注
*/ */
private String description; private String description;
/**
* 设备品牌(博世/西门子)
*/
private String brand;
/**
* 产品类别
*/
private String productType;
/**
* 服务类型
*/
private String serviceType;
/**
* 改约原因
*/
private String reschedulingReason;
} }
...@@ -199,6 +199,26 @@ public class OrderDTO { ...@@ -199,6 +199,26 @@ public class OrderDTO {
*/ */
private Location happenLocation; private Location happenLocation;
/**
* 设备品牌(博世/西门子)
*/
private String brand;
/**
* 产品类别
*/
private String productType;
/**
* 服务类型
*/
private String serviceType;
/**
* 改约原因
*/
private String reschedulingReason;
} }
/** /**
......
...@@ -240,4 +240,10 @@ public class OrderInfoEntity { ...@@ -240,4 +240,10 @@ public class OrderInfoEntity {
*/ */
@Column(name = "is_cutoff") @Column(name = "is_cutoff")
private Integer isCutoff = 0; private Integer isCutoff = 0;
/**
* 改约原因
*/
@Column(name = "rescheduling_reason")
private String reschedulingReason;
} }
...@@ -98,7 +98,7 @@ public class BeanUserDetail { ...@@ -98,7 +98,7 @@ public class BeanUserDetail {
/** /**
* 常用出发地址,常驻的工作地址 * 常用出发地址,常驻的工作地址
*/ */
private String address; private Address address;
/** /**
* 等级=大修、零售、项目、鉴定、寄修 * 等级=大修、零售、项目、鉴定、寄修
*/ */
......
...@@ -18,7 +18,6 @@ package com.dituhui.pea.order.service; ...@@ -18,7 +18,6 @@ package com.dituhui.pea.order.service;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.OrderCreateReqDTO;
import com.dituhui.pea.order.dto.param.OrderDTO; import com.dituhui.pea.order.dto.param.OrderDTO;
public interface OrderCreateService { public interface OrderCreateService {
...@@ -28,4 +27,12 @@ public interface OrderCreateService { ...@@ -28,4 +27,12 @@ public interface OrderCreateService {
Result<?> createOrder(OrderDTO.OrderCreateRequest orderCreateReqDTO) Result<?> createOrder(OrderDTO.OrderCreateRequest orderCreateReqDTO)
throws BusinessException; throws BusinessException;
/**
* 预约单服务进度查询
*
* @param orderId 工单号码
* @return 工单进度信息
* @apiNote 查询预约单状态,返回指定技术员(主,副)信息、推荐上门时间。如果查询为服务当日,增加对应技术员准实时位置,距离公里数,预计到达时间等
*/
OrderDTO.StageResult orderStage(String orderId);
} }
...@@ -234,7 +234,9 @@ public class BeanRemoteServiceImpl { ...@@ -234,7 +234,9 @@ public class BeanRemoteServiceImpl {
} }
Department data = departmentBeanR.getData(); Department data = departmentBeanR.getData();
//处理大区,分部数据 //处理大区,分部数据
if (StringUtils.isNotBlank(data.getDeptLevel())) { if (StringUtils.isBlank(data.getDeptLevel())) {
return Result.failed("组织级别不能为空");
}
if (data.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) { if (data.getDeptLevel().equals(BeanOrgLevelEnum.REGION.getCode())) {
OrgClusterEntity clusterEntity = orgClusterDao.getByClusterId(data.getId()); OrgClusterEntity clusterEntity = orgClusterDao.getByClusterId(data.getId());
if (ObjUtil.isNull(clusterEntity)) { if (ObjUtil.isNull(clusterEntity)) {
...@@ -252,7 +254,8 @@ public class BeanRemoteServiceImpl { ...@@ -252,7 +254,8 @@ public class BeanRemoteServiceImpl {
clusterEntity.setReserveTimeMax(data.getPartReserveTimeMax()); clusterEntity.setReserveTimeMax(data.getPartReserveTimeMax());
clusterEntity.setBsDeptId(data.getBsDeptId()); clusterEntity.setBsDeptId(data.getBsDeptId());
orgClusterDao.save(clusterEntity); orgClusterDao.save(clusterEntity);
} else if (data.getDeptLevel().equals(BeanOrgLevelEnum.BRANCH.getCode())) { }
if (data.getDeptLevel().equals(BeanOrgLevelEnum.BRANCH.getCode())) {
OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(data.getId()); OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(data.getId());
if (ObjUtil.isNull(branchEntity)) { if (ObjUtil.isNull(branchEntity)) {
branchEntity = new OrgBranchEntity(); branchEntity = new OrgBranchEntity();
...@@ -273,10 +276,8 @@ public class BeanRemoteServiceImpl { ...@@ -273,10 +276,8 @@ public class BeanRemoteServiceImpl {
orgBranchDao.save(branchEntity); orgBranchDao.save(branchEntity);
branchMap.put(data.getBsDeptId(), branchEntity); branchMap.put(data.getBsDeptId(), branchEntity);
} }
} if ((data.getDeptLevel().equalsIgnoreCase(BeanOrgLevelEnum.STATION.getCode()))) {
//处理分站外围数据 //处理分站外围数据
if (StringUtils.isNotBlank(data.getDeptType()) && (data.getDeptType().equals(BeanOrgLevelEnum.STATION.getCode())
|| data.getDeptType().equals(BeanOrgLevelEnum.PERIPHERY.getCode()))) {
OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(data.getId()); OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(data.getId());
if (ObjUtil.isNull(groupEntity)) { if (ObjUtil.isNull(groupEntity)) {
groupEntity = new OrgGroupEntity(); groupEntity = new OrgGroupEntity();
...@@ -371,7 +372,7 @@ public class BeanRemoteServiceImpl { ...@@ -371,7 +372,7 @@ public class BeanRemoteServiceImpl {
//处理分站外围 //处理分站外围
groupEntity.setKind(CollectionUtils.isEmpty(data.getType()) ? 4 : BeanPointTypeEnum.getTypeByClazz(data.getType().get(0))); groupEntity.setKind(CollectionUtils.isEmpty(data.getType()) ? 4 : BeanPointTypeEnum.getTypeByClazz(data.getType().get(0)));
groupEntity.setCategory(2); groupEntity.setCategory(2);
groupEntity.setAddress(data.getBusinessAddress().getAddress()); groupEntity.setAddress(data.getBusinessAddress().getAll());
groupEntity.setX(data.getBusinessAddress().getLongitude()); groupEntity.setX(data.getBusinessAddress().getLongitude());
groupEntity.setY(data.getBusinessAddress().getLatitude()); groupEntity.setY(data.getBusinessAddress().getLatitude());
orgGroupDao.save(groupEntity); orgGroupDao.save(groupEntity);
......
...@@ -596,7 +596,7 @@ public class DispatchServiceImpl implements DispatchService { ...@@ -596,7 +596,7 @@ public class DispatchServiceImpl implements DispatchService {
//过滤 //过滤
List<OrderInfoEntity> orders = records.stream() List<OrderInfoEntity> orders = records.stream()
.filter(r -> r.getOrderStatus().equals("NORMAL")) .filter(r -> !r.getOrderStatus().equals(OrderStatusEnum.CANCELED))
.collect(Collectors.toList()); .collect(Collectors.toList());
return orders.stream().collect(Collectors.groupingBy(OrderInfoEntity::getEngineerCode)); return orders.stream().collect(Collectors.groupingBy(OrderInfoEntity::getEngineerCode));
......
...@@ -18,26 +18,53 @@ package com.dituhui.pea.order.service.impl; ...@@ -18,26 +18,53 @@ package com.dituhui.pea.order.service.impl;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.common.ResultEnum; import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.enums.StatusCodeEnum; import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.*; import com.dituhui.pea.order.common.CapacityUtils;
import com.dituhui.pea.order.dao.*; import com.dituhui.pea.order.common.DateUtils;
import com.dituhui.pea.order.dto.*; import com.dituhui.pea.order.common.Distance;
import com.dituhui.pea.order.common.EngineerUtils;
import com.dituhui.pea.order.common.OrderAssignCheck;
import com.dituhui.pea.order.common.SaasUtils;
import com.dituhui.pea.order.dao.EngineerBusinessDao;
import com.dituhui.pea.order.dao.EngineerInfoDao;
import com.dituhui.pea.order.dao.EngineerSkillDao;
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;
import com.dituhui.pea.order.dto.LabelValueDTO;
import com.dituhui.pea.order.dto.MsgDTO;
import com.dituhui.pea.order.dto.ParameterRespDTO;
import com.dituhui.pea.order.dto.param.Location; import com.dituhui.pea.order.dto.param.Location;
import com.dituhui.pea.order.dto.param.OrderDTO; import com.dituhui.pea.order.dto.param.OrderDTO;
import com.dituhui.pea.order.dto.param.OrgTeamInfo; import com.dituhui.pea.order.dto.param.OrgTeamInfo;
import com.dituhui.pea.order.entity.*; import com.dituhui.pea.order.entity.EngineerBusinessEntity;
import com.dituhui.pea.order.entity.EngineerInfoEntity;
import com.dituhui.pea.order.entity.EngineerSkillEntity;
import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrgBranchEntity;
import com.dituhui.pea.order.entity.OrgTeamEngineerEntity;
import com.dituhui.pea.order.entity.OrgTeamEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.enums.AppointmentMethodEnum; import com.dituhui.pea.order.enums.AppointmentMethodEnum;
import com.dituhui.pea.order.enums.OrderEventEnum; import com.dituhui.pea.order.enums.OrderEventEnum;
import com.dituhui.pea.order.enums.OrderFlowEnum; import com.dituhui.pea.order.enums.OrderFlowEnum;
import com.dituhui.pea.order.enums.OrderStatusEnum; import com.dituhui.pea.order.enums.OrderStatusEnum;
import com.dituhui.pea.order.service.*; import com.dituhui.pea.order.service.CommonService;
import com.dituhui.pea.order.service.FendanService;
import com.dituhui.pea.order.service.MsgService;
import com.dituhui.pea.order.service.OrderCreateService;
import com.dituhui.pea.order.service.OrderInfoService;
import com.dituhui.pea.order.utils.CommonUtil; import com.dituhui.pea.order.utils.CommonUtil;
import com.dituhui.pea.pojo.saas.req.AdministrativeDistrictReq; import com.dituhui.pea.pojo.saas.req.AdministrativeDistrictReq;
import com.dituhui.pea.pojo.saas.resp.AdministrativeDistrictResp; import com.dituhui.pea.pojo.saas.resp.AdministrativeDistrictResp;
import com.dituhui.pea.util.DateUtil; import com.dituhui.pea.util.DateUtil;
import io.seata.core.context.RootContext; import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -48,7 +75,12 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -48,7 +75,12 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDate; import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -79,6 +111,8 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -79,6 +111,8 @@ public class OrderCreateServiceImpl implements OrderCreateService {
@Autowired @Autowired
private EngineerInfoDao engineerInfoDao; private EngineerInfoDao engineerInfoDao;
@Autowired
private EngineerBusinessDao engineerBusinessDao;
@Autowired @Autowired
private OrgTeamEngineerDao orgTeamEngineerDao; private OrgTeamEngineerDao orgTeamEngineerDao;
...@@ -131,6 +165,115 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -131,6 +165,115 @@ public class OrderCreateServiceImpl implements OrderCreateService {
} }
@Override @Override
public OrderDTO.StageResult orderStage(String orderId) {
//获取工单信息
OrderInfoEntity orderInfo = orderInfoDao.getByOrderId(orderId);
if (Objects.isNull(orderInfo)) {
throw new BusinessException("没有找到" + orderId + "相关的工单信息");
}
OrderDTO.StageResult stageResult = new OrderDTO.StageResult();
stageResult.setOrderId(orderInfo.getOrderId());
final String engineerCode = orderInfo.getEngineerCode();
stageResult.setEngineerCode(engineerCode);
stageResult.setEngineerName(orderInfo.getEngineerName());
final String engineerCodeSub = orderInfo.getEngineerCodeSub();
if (StringUtils.isNotBlank(engineerCodeSub)) {
stageResult.setEngineerCodeAssist(engineerCodeSub);
//查询辅助工程师信息
EngineerInfoEntity subEngineerInfo = engineerInfoDao.getByEngineerCode(engineerCodeSub);
stageResult.setEngineerNameAssist(subEngineerInfo.getName());
}
//获取计划上门时间
final LocalDateTime planStartTime = orderInfo.getPlanStartTime();
Date palnDate = com.dituhui.pea.order.common.jackson.DateUtil.toDate(planStartTime);
stageResult.setPlanVisitTime(palnDate);
if (Objects.isNull(planStartTime) || !LocalDate.now().equals(planStartTime.toLocalDate())) {
return stageResult;
}
//如果计划时间为今天 则返回工程师位置信息
Location location = engineerDateLocation(engineerCode);
OrderDTO.RealtimeInfo realtimeInfo = new OrderDTO.RealtimeInfo();
realtimeInfo.setEngineerLocation(location);
OrderDTO.Estimate estimate = new OrderDTO.Estimate();
// 计算两点间距离
Pair distanceAndDuration = getDistanceAndDuration(location.getLatitude(), location.getLongitude(),
Double.parseDouble(orderInfo.getX()), Double.parseDouble(orderInfo.getY()));
estimate.setDistance((double) distanceAndDuration.getDistance());
estimate.setArriveTime(palnDate);
realtimeInfo.setEstimate(estimate);
stageResult.setRealtimeInfo(realtimeInfo);
return stageResult;
}
private Pair getDistanceAndDuration(double x1, double y1, double x2, double y2) {
Distance cal = new Distance();
long distance = Math.round(cal.calculateDistance(x1, y1, x2, y2) * 1.4); // 单位为米
long duration = distance / (19 * 1000 / 60); // 时间为分钟,假设电动车速度为19km/h
return new Pair((int) distance, (int) duration);
}
@Data
class Pair {
private int distance;
private int duration;
public Pair(int distance, int duration) {
this.distance = distance;
this.duration = duration;
}
}
private Location engineerDateLocation(String engineerCode) {
final LocalDate currentDate = LocalDate.now();
List<OrderInfoEntity> engineerDateOrderList = orderInfoDao.getEngineerDateOrder(engineerCode, DateUtils.formatDate(currentDate));
Set<String> ss = Set.of("CANCELED", "RESCHEDULED");
engineerDateOrderList = engineerDateOrderList.stream()
.filter(e -> !ss.contains(e.getOrderStatus()))
.collect(Collectors.toList());
Location location = new Location();
//查询工程师已开始的工单
Optional<OrderInfoEntity> startedOrder = engineerDateOrderList.stream()
.filter(e -> Objects.equals("STARTED", e.getServiceStatus()))
.max(Comparator.comparing(OrderInfoEntity::getPlanStartTime));
if (startedOrder.isPresent()) {
OrderInfoEntity startedOrderInfo = startedOrder.get();
location.setAddress(startedOrderInfo.getAddress());
location.setLongitude(Double.parseDouble(startedOrderInfo.getX()));
location.setLatitude(Double.parseDouble(startedOrderInfo.getY()));
return location;
}
//如果没有已开始的工单 查询 最后一个已完成工单
Optional<OrderInfoEntity> finishedOrder = engineerDateOrderList.stream()
.filter(e -> Objects.equals("FINISHED", e.getServiceStatus()))
.max(Comparator.comparing(OrderInfoEntity::getActualEndTime));
if (finishedOrder.isPresent()) {
OrderInfoEntity finishedOrderInfo = finishedOrder.get();
location.setAddress(finishedOrderInfo.getAddress());
location.setLongitude(Double.parseDouble(finishedOrderInfo.getX()));
location.setLatitude(Double.parseDouble(finishedOrderInfo.getY()));
} else {
// 如果都没有, 则获取工程师出发地址
EngineerBusinessEntity byEngineerCode = engineerBusinessDao.getByEngineerCode(engineerCode);
location.setAddress(byEngineerCode.getAddress());
location.setLongitude(Double.parseDouble(byEngineerCode.getX()));
location.setLatitude(Double.parseDouble(byEngineerCode.getY()));
}
return location;
}
@Override
@Transactional @Transactional
public Result<?> createOrder(OrderDTO.OrderCreateRequest req) { public Result<?> createOrder(OrderDTO.OrderCreateRequest req) {
log.info("[createOrder] req: {}", JSONObject.toJSONString(req)); log.info("[createOrder] req: {}", JSONObject.toJSONString(req));
...@@ -141,11 +284,14 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -141,11 +284,14 @@ public class OrderCreateServiceImpl implements OrderCreateService {
orderId = s.substring(s.length() - 9); orderId = s.substring(s.length() - 9);
} }
OrderInfoEntity byOrderId = orderInfoDao.getByOrderId(req.getOrderId()); OrderInfoEntity byOrderId = orderInfoDao.getByOrderId(req.getOrderId());
String peaBrand = fixBrand(req.getBrand());
if (ObjectUtil.isNotNull(byOrderId)) { if (ObjectUtil.isNotNull(byOrderId)) {
return Result.failed(StatusCodeEnum.ORDER_EXISTS); return Result.failed(StatusCodeEnum.ORDER_EXISTS);
} }
SkillInfoEntity skillInfoEntity = skillInfoDao.getByBrandAndTypeAndSkill(peaBrand, req.getProductType(), req.getServiceType());
String peaBrand = fixBrand(req.getBrand()); if (ObjectUtil.isNull(skillInfoEntity)) {
return Result.failed(StatusCodeEnum.ORDER_SKILL_NOT_EXISTS);
}
Location location = req.getLocation(); Location location = req.getLocation();
//预处理字段 //预处理字段
entity.setExpectTimeBegin(DateUtil.fromDate(req.getExpectBegin())); entity.setExpectTimeBegin(DateUtil.fromDate(req.getExpectBegin()));
...@@ -179,7 +325,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -179,7 +325,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
engineerName = engineerInfo.getName(); engineerName = engineerInfo.getName();
entity.setEngineerName(engineerInfo.getName()); entity.setEngineerName(engineerInfo.getName());
entity.setEngineerPhone(engineerInfo.getPhone()); entity.setEngineerPhone(engineerInfo.getPhone());
entity.setEngineerPhone(engineerInfo.getPhone()); entity.setEngineerCode(engineerInfo.getEngineerCode());
entity.setOrgClusterId(byTeamId.getClusterId()); entity.setOrgClusterId(byTeamId.getClusterId());
entity.setOrgBranchId(byTeamId.getBranchId()); entity.setOrgBranchId(byTeamId.getBranchId());
entity.setOrgGroupId(byTeamId.getGroupId()); entity.setOrgGroupId(byTeamId.getGroupId());
...@@ -189,7 +335,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -189,7 +335,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
//特殊时间段 //特殊时间段
Integer special = CommonUtil.isSpecial(entity.getExpectTimeBegin().toLocalTime(), Integer special = CommonUtil.isSpecial(entity.getExpectTimeBegin().toLocalTime(),
entity.getExpectTimeEnd().toLocalTime(), byTeamId.getWorkOn(), byTeamId.getWorkOff()); entity.getExpectTimeEnd().toLocalTime(), byTeamId.getWorkOn(), byTeamId.getWorkOff());
Integer cutoff = CommonUtil.isCutoff(LocalDateTime.now(), byTeamId.getWorkOff()); Integer cutoff = CommonUtil.isCutoff(entity.getExpectTimeBegin(), byTeamId.getWorkOff());
entity.setIsCutoff(cutoff); entity.setIsCutoff(cutoff);
entity.setIsSpecialTime(special); entity.setIsSpecialTime(special);
} else { } else {
...@@ -210,7 +356,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -210,7 +356,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
//发送通知分部消息 //发送通知分部消息
sendMsg(branchEntity.getBranchId(), orderId, entity.getExpectTimeBegin().toLocalDate()); sendMsg(branchEntity.getBranchId(), orderId, entity.getExpectTimeBegin().toLocalDate());
Integer cutoff = CommonUtil.isCutoff(LocalDateTime.now(), null); Integer cutoff = CommonUtil.isCutoff(entity.getExpectTimeBegin(), null);
entity.setIsCutoff(cutoff); entity.setIsCutoff(cutoff);
} else { } else {
// 根据分单工作队,填写clusterId/branchId/groupId/teamId等 // 根据分单工作队,填写clusterId/branchId/groupId/teamId等
...@@ -223,7 +369,7 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -223,7 +369,7 @@ public class OrderCreateServiceImpl implements OrderCreateService {
//特殊时间段 //特殊时间段
Integer special = CommonUtil.isSpecial(entity.getExpectTimeBegin().toLocalTime(), Integer special = CommonUtil.isSpecial(entity.getExpectTimeBegin().toLocalTime(),
entity.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff()); entity.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff());
Integer cutoff = CommonUtil.isCutoff(LocalDateTime.now(), teamInfo.getWorkOff()); Integer cutoff = CommonUtil.isCutoff(entity.getExpectTimeBegin(), teamInfo.getWorkOff());
// 处理cutoff 动态排班结束后创建的当日单和次日单 // 处理cutoff 动态排班结束后创建的当日单和次日单
boolean isTomorrow = DateUtil.judgeTimeIsisTomorrow(entity.getExpectTimeBegin()); boolean isTomorrow = DateUtil.judgeTimeIsisTomorrow(entity.getExpectTimeBegin());
//次日单自动批量 //次日单自动批量
...@@ -272,8 +418,6 @@ public class OrderCreateServiceImpl implements OrderCreateService { ...@@ -272,8 +418,6 @@ public class OrderCreateServiceImpl implements OrderCreateService {
entity.setWorkshop(false); entity.setWorkshop(false);
// 处理技能和标签 // 处理技能和标签
SkillInfoEntity skillInfoEntity = skillInfoDao.getByBrandAndTypeAndSkill(peaBrand, req.getProductType(), req.getServiceType());
assert skillInfoEntity != null;
entity.setTakeTime(skillInfoEntity.getTakeTime()); entity.setTakeTime(skillInfoEntity.getTakeTime());
String joinTags = CollectionUtils.isEmpty(req.getOrderTags()) ? "" : String.join(",", req.getOrderTags()); String joinTags = CollectionUtils.isEmpty(req.getOrderTags()) ? "" : String.join(",", req.getOrderTags());
entity.setBeanTags(joinTags); entity.setBeanTags(joinTags);
......
...@@ -7,17 +7,11 @@ import com.dituhui.pea.common.Result; ...@@ -7,17 +7,11 @@ import com.dituhui.pea.common.Result;
import com.dituhui.pea.common.ResultEnum; import com.dituhui.pea.common.ResultEnum;
import com.dituhui.pea.enums.StatusCodeEnum; import com.dituhui.pea.enums.StatusCodeEnum;
import com.dituhui.pea.order.common.TimeUtils; import com.dituhui.pea.order.common.TimeUtils;
import com.dituhui.pea.order.dao.OrderInfoDao; import com.dituhui.pea.order.dao.*;
import com.dituhui.pea.order.dao.OrgBranchDao;
import com.dituhui.pea.order.dao.OrgGroupDao;
import com.dituhui.pea.order.dao.SkillInfoDao;
import com.dituhui.pea.order.dto.MsgDTO; import com.dituhui.pea.order.dto.MsgDTO;
import com.dituhui.pea.order.dto.OrderReschedule; import com.dituhui.pea.order.dto.OrderReschedule;
import com.dituhui.pea.order.dto.param.*; import com.dituhui.pea.order.dto.param.*;
import com.dituhui.pea.order.entity.OrderInfoEntity; import com.dituhui.pea.order.entity.*;
import com.dituhui.pea.order.entity.OrgBranchEntity;
import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.entity.SkillInfoEntity;
import com.dituhui.pea.order.enums.AppointmentMethodEnum; import com.dituhui.pea.order.enums.AppointmentMethodEnum;
import com.dituhui.pea.order.enums.BeanServiceFlowEnum; import com.dituhui.pea.order.enums.BeanServiceFlowEnum;
import com.dituhui.pea.order.enums.OrderStatusEnum; import com.dituhui.pea.order.enums.OrderStatusEnum;
...@@ -70,6 +64,9 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -70,6 +64,9 @@ public class OrderInfoServiceImpl implements OrderInfoService {
@Autowired @Autowired
private OrgGroupDao orgGroupDao; private OrgGroupDao orgGroupDao;
@Autowired
private OrgTeamDao orgTeamDao;
/** /**
* 新增订单处理一家多单逻辑 * 新增订单处理一家多单逻辑
...@@ -168,7 +165,7 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -168,7 +165,7 @@ public class OrderInfoServiceImpl implements OrderInfoService {
orderInfo.setDescription(request.getDescription()); orderInfo.setDescription(request.getDescription());
} }
//处理一家多单逻辑 //处理一家多单逻辑
Result<String> deleteMultipleOrders = this.deleteMultipleOrders(orderInfo.getMultipleOrders(), orderInfo.getAddressId()); Result<String> deleteMultipleOrders = this.deleteMultipleOrders(orderInfo.getMultipleOrders(), orderInfo.getOrderId());
if (!deleteMultipleOrders.getCode().equals(ResultEnum.SUCCESS.getCode())) { if (!deleteMultipleOrders.getCode().equals(ResultEnum.SUCCESS.getCode())) {
throw new BusinessException("改约日期失败"); throw new BusinessException("改约日期失败");
} }
...@@ -179,24 +176,16 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -179,24 +176,16 @@ public class OrderInfoServiceImpl implements OrderInfoService {
//组装改约接口 //组装改约接口
OrderReschedule reschedule = new OrderReschedule(); OrderReschedule reschedule = new OrderReschedule();
reschedule.setOrderId(orderInfo.getOrderId()); reschedule.setOrderId(orderInfo.getOrderId());
reschedule.setHappenLocation(request.getHappenLocation());
reschedule.setOrderId(orderInfo.getOrderId());
reschedule.setBrand(request.getBrand());
reschedule.setProductType(request.getProductType());
reschedule.setServiceType(request.getServiceType());
reschedule.setReschedulingReason(request.getReschedulingReason());
reschedule.setExpectBegin(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeBegin())); reschedule.setExpectBegin(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeBegin()));
reschedule.setExpectEnd(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeEnd())); reschedule.setExpectEnd(DateUtil.handleDate(request.getNewReservationTime(), orderInfo.getExpectTimeEnd()));
Location location = request.getHappenLocation();
if (ObjectUtil.isNull(location)) {
location = new Location();
location.setLongitude(Double.valueOf(orderInfo.getX()));
location.setLatitude(Double.valueOf(orderInfo.getY()));
location.setAddress(orderInfo.getAddress());
location.setAddressId(orderInfo.getAddressId());
} else {
orderInfo.setX(location.getLongitude().toString());
orderInfo.setY(location.getLatitude().toString());
orderInfo.setAddress(location.getAddress());
orderInfo.setAddressId(location.getAddressId());
}
reschedule.setHappenLocation(location);
if (StringUtils.isNotBlank(request.getDescription())) { if (StringUtils.isNotBlank(request.getDescription())) {
orderInfo.setDescription(request.getDescription()); reschedule.setDescription(request.getDescription());
} }
return this.orderReschedule(reschedule); return this.orderReschedule(reschedule);
...@@ -221,32 +210,92 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -221,32 +210,92 @@ public class OrderInfoServiceImpl implements OrderInfoService {
} }
LocalDateTime expectEnd = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectEnd()); LocalDateTime expectEnd = TimeUtils.IsoDateTime2LocalDateTime(req.getExpectEnd());
OrderInfoEntity order = orderInfoDao.getByOrderId(req.getOrderId()); OrderInfoEntity order = orderInfoDao.getByOrderId(req.getOrderId());
if (ObjectUtil.isNull(order)) {
throw new BusinessException("订单不存在");
}
LocalDate orderDt = order.getDt(); LocalDate orderDt = order.getDt();
order.setDt(expectBegin.toLocalDate()); order.setDt(expectBegin.toLocalDate());
order.setExpectTimeBegin(expectBegin); order.setExpectTimeBegin(expectBegin);
order.setExpectTimeEnd(expectEnd); order.setExpectTimeEnd(expectEnd);
order.setExpectTimeDesc(req.getExpectDesc()); order.setExpectTimeDesc(req.getExpectDesc());
order.setOrderStatus(OrderStatusEnum.RESCHEDULED.getCode()); order.setOrderStatus(OrderStatusEnum.RESCHEDULED.getCode());
if (order == null) { boolean skillUpdate = false;
throw new BusinessException("订单不存在"); if (StringUtils.isNotBlank(req.getBrand()) && !CommonUtil.fixBrand(req.getBrand()).equals(order.getBrand())) {
order.setBrand(CommonUtil.fixBrand(req.getBrand()));
skillUpdate = true;
}
if (StringUtils.isNotBlank(req.getServiceType()) && !req.getServiceType().equals(order.getType())) {
order.setSkill(req.getServiceType());
skillUpdate = true;
}
if (StringUtils.isNotBlank(req.getProductType()) && !req.getProductType().equals(order.getSkill())) {
order.setType(req.getProductType());
skillUpdate = true;
}
//渲染地址,判断地址是否变更
Location location = req.getHappenLocation();
if (ObjectUtil.isNull(location)) {
location = new Location();
location.setLongitude(Double.valueOf(order.getX()));
location.setLatitude(Double.valueOf(order.getY()));
location.setAddress(order.getAddress());
location.setAddressId(order.getAddressId());
} else {
order.setX(location.getLongitude().toString());
order.setY(location.getLatitude().toString());
order.setAddress(location.getAddress());
order.setAddressId(location.getAddressId());
if (!order.getAddressId().equals(location.getAddressId())) {
skillUpdate = true;
//更正省市区
AdministrativeDistrictReq administrativeDistrictReq = new AdministrativeDistrictReq();
administrativeDistrictReq.setPoints(location.getLongitude() + "," + location.getLatitude());
Result<AdministrativeDistrictResp> adminDistrict = fendanService.getAdminDistrict(administrativeDistrictReq);
if (ObjectUtil.isNotEmpty(adminDistrict) && ObjectUtil.isNotEmpty(adminDistrict.getResult())) {
order.setProvince(adminDistrict.getResult().getSubNames().getProvince());
order.setCity(adminDistrict.getResult().getSubNames().getCity());
order.setCounty(adminDistrict.getResult().getSubNames().getCounty());
}
}
} }
order.setReschedulingReason(StringUtils.isNotBlank(req.getReschedulingReason()) ? req.getReschedulingReason() : order.getReschedulingReason());
OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(order.getOrgGroupId()); OrgGroupEntity groupEntity = orgGroupDao.getByGroupId(order.getOrgGroupId());
//是否今天 //是否今天
boolean isToday = DateUtil.judgeTimeIsToday(expectBegin); boolean isToday = DateUtil.judgeTimeIsToday(expectBegin);
//是否到人 //是否到人
boolean isBelong = StringUtils.isNotEmpty(order.getEngineerCode()); boolean isBelong = StringUtils.isNotEmpty(order.getEngineerCode());
// 是否网点 // 是否网点
//网点都需要重新指派
boolean isNetwork = ObjectUtil.isNull(groupEntity) ? false : groupEntity.getCategory() == 2; boolean isNetwork = ObjectUtil.isNull(groupEntity) ? false : groupEntity.getCategory() == 2;
String branchId = order.getOrgBranchId(); String branchId = order.getOrgBranchId();
String clusterId = order.getOrgClusterId(); String clusterId = order.getOrgClusterId();
//网点都需要重新指派
String teamId = order.getOrgTeamId();
// 当天单变更技能直接人工指派
if (isToday && skillUpdate) {
if (order.getIsAppointEngineer() != 1) {
order.setOrgTeamId(null);
order.setOrgGroupId(null);
order.setEngineerPhone(null);
order.setEngineerName(null);
order.setEngineerCode(null);
order.setEngineerPhone(null);
teamId = null;
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin());
}
} else {
// a.已派人-改约到未来 // a.已派人-改约到未来
// i.自有:优先改约指派给当前工程师 // i.自有:优先改约指派给当前工程师
// ii.网点:优先改约指派给当前网点 // ii.网点:优先改约指派给当前网点
// (不给当前工程师) // (不给当前工程师)
if (!isToday && isBelong) { if (!isToday && isBelong && skillUpdate) {
} else if (isToday && isBelong) { //地址变更需要从新分单
order = orderFendan(order, req, location);
clusterId = order.getOrgClusterId();
branchId = order.getOrgBranchId();
} else if (isToday && isBelong && order.getIsAppointEngineer() != 1) {
// b.已派人-改约到当天 // b.已派人-改约到当天
// i.自有:优先改约指派给当前工程师 // i.自有:优先改约指派给当前工程师
// (会影响该工程师当天后续工单的时 // (会影响该工程师当天后续工单的时
...@@ -270,29 +319,70 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -270,29 +319,70 @@ public class OrderInfoServiceImpl implements OrderInfoService {
order.setEngineerCode(null); order.setEngineerCode(null);
clusterId = order.getOrgClusterId(); clusterId = order.getOrgClusterId();
branchId = order.getOrgBranchId(); branchId = order.getOrgBranchId();
teamId = null;
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin()); sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin());
} }
} }
} else if (!isToday && !isBelong) { } else if (!isToday && !isBelong) {
// a.未派人-改约到未来 // a.未派人-改约到未来
// i.动态排班 // i.动态排班
order = orderFendan(order, req, location);
clusterId = order.getOrgClusterId();
branchId = order.getOrgBranchId();
} else if (isToday && !isBelong) {
// b.未派人-改约到当天
// i.人工指派
order.setOrgTeamId(null);
order.setOrgGroupId(null);
order.setEngineerPhone(null);
order.setEngineerName(null);
order.setEngineerCode(null);
teamId = null;
sendMsg(order.getOrgBranchId(), order.getOrderId(), req.getExpectBegin());
}
}
//处理一家多单
// order = handleMultipleOrders(order);
if (!orderDt.isEqual(expectBegin.toLocalDate())) {
order = handleMultipleOrders(order);
}
// 处理特殊时间,cutoff
Integer special = 0;
Integer cutoff = 0;
if (StringUtils.isNotBlank(teamId)) {
OrgTeamEntity teamInfo = orgTeamDao.getByTeamId(teamId);
special = CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(),
order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff());
cutoff = CommonUtil.isCutoff(order.getExpectTimeBegin(), teamInfo.getWorkOff());
} else {
cutoff = CommonUtil.isCutoff(order.getExpectTimeBegin(), null);
}
order.setIsCutoff(cutoff);
order.setIsSpecialTime(special);
order.setOrgClusterId(clusterId);
order.setOrgBranchId(branchId);
orderInfoDao.save(order);
// 登记事件
commonService.addOrderEvent(req.getOrderId(), "", "PEA", req.getOperator(), OrderStatusEnum.RESCHEDULED.getDescription(), OrderStatusEnum.RESCHEDULED.getDescription(), "");
return Result.success(null);
}
/**
* 订单重新分单
*
* @param order
* @param req
* @param location
* @return
*/
private OrderInfoEntity orderFendan(OrderInfoEntity order, OrderReschedule req, Location location) {
order.setServiceStatus(ServiceStatusEnum.INIT.getCode()); order.setServiceStatus(ServiceStatusEnum.INIT.getCode());
if (StringUtils.isBlank(req.getDescription())) { if (StringUtils.isBlank(req.getDescription())) {
order.setDescription(order.getDescription()); order.setDescription(order.getDescription());
} }
Location location = req.getHappenLocation();
if (ObjectUtil.isNull(location)) {
location = new Location();
location.setLongitude(Double.valueOf(order.getX()));
location.setLatitude(Double.valueOf(order.getY()));
location.setAddress(order.getAddress());
location.setAddressId(order.getAddressId());
} else {
order.setX(location.getLongitude().toString());
order.setY(location.getLongitude().toString());
order.setAddress(location.getAddress());
order.setAddressId(location.getAddressId());
}
//获取省市区 //获取省市区
AdministrativeDistrictReq administrativeDistrictReq = new AdministrativeDistrictReq(); AdministrativeDistrictReq administrativeDistrictReq = new AdministrativeDistrictReq();
administrativeDistrictReq.setPoints(location.getLongitude() + "," + location.getLatitude()); administrativeDistrictReq.setPoints(location.getLongitude() + "," + location.getLatitude());
...@@ -309,49 +399,23 @@ public class OrderInfoServiceImpl implements OrderInfoService { ...@@ -309,49 +399,23 @@ public class OrderInfoServiceImpl implements OrderInfoService {
fendanReq.setProductType(order.getType()); fendanReq.setProductType(order.getType());
fendanReq.setServiceType(order.getSkill()); fendanReq.setServiceType(order.getSkill());
fendanReq.setLocation(location); fendanReq.setLocation(location);
Result<OrgTeamInfo> fendanResult = fendanService.fendanToGroupCapacity(fendanReq, 2, order.getDt(), expectBegin.toLocalTime(), expectEnd.toLocalTime()); Result<OrgTeamInfo> fendanResult = fendanService.fendanToGroupCapacity(fendanReq, 2, order.getDt(), order.getExpectTimeBegin().toLocalTime(), order.getExpectTimeEnd().toLocalTime());
if (!fendanResult.getCode().equals(ResultEnum.SUCCESS.getCode()) || ObjectUtil.isNull(fendanResult.getResult())) { if (!fendanResult.getCode().equals(ResultEnum.SUCCESS.getCode()) || ObjectUtil.isNull(fendanResult.getResult())) {
if (fendanResult.getCode().equals(StatusCodeEnum.FENDAN_IS_TRANSCEND.getCode())) { if (fendanResult.getCode().equals(StatusCodeEnum.FENDAN_IS_TRANSCEND.getCode())) {
order.setTranscend(1); order.setTranscend(1);
} }
OrgBranchEntity branchEntity = orgBranchDao.findByCitycodeListLike("%" + adminDistrict.getResult().getSubNames().getCity() + "%"); OrgBranchEntity branchEntity = orgBranchDao.findByCitycodeListLike("%" + adminDistrict.getResult().getSubNames().getCity() + "%");
clusterId = branchEntity.getClusterId();
branchId = branchEntity.getBranchId();
sendMsg(branchEntity.getBranchId(), order.getOrderId(), req.getExpectBegin()); sendMsg(branchEntity.getBranchId(), order.getOrderId(), req.getExpectBegin());
} else { } else {
// 根据分单工作队,填写clusterId/branchId/groupId/teamId等 // 根据分单工作队,填写clusterId/branchId/groupId/teamId等
OrgTeamInfo teamInfo = fendanResult.getResult(); OrgTeamInfo teamInfo = fendanResult.getResult();
clusterId = teamInfo.getClusterId();
branchId = teamInfo.getBranchId();
order.setOrgGroupId(teamInfo.getGroupId()); order.setOrgGroupId(teamInfo.getGroupId());
order.setOrgTeamId(teamInfo.getTeamId()); order.setOrgTeamId(teamInfo.getTeamId());
//处理超派,特殊时间段 //处理超派,特殊时间段
order.setIsSpecialTime(CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(), // order.setIsSpecialTime(CommonUtil.isSpecial(order.getExpectTimeBegin().toLocalTime(),
order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff())); // order.getExpectTimeEnd().toLocalTime(), teamInfo.getWorkOn(), teamInfo.getWorkOff()));
}
} else if (isToday && !isBelong) {
// b.未派人-改约到当天
// i.人工指派
OrgBranchEntity branchEntity = orgBranchDao.getByBranchId(order.getOrgBranchId());
clusterId = branchEntity.getClusterId();
branchId = branchEntity.getBranchId();
order.setOrgTeamId(null);
order.setOrgGroupId(null);
sendMsg(branchEntity.getBranchId(), order.getOrderId(), req.getExpectBegin());
} }
return order;
//处理一家多单
// order = handleMultipleOrders(order);
if (!orderDt.isEqual(expectBegin.toLocalDate())) {
order = handleMultipleOrders(order);
}
order.setOrgClusterId(clusterId);
order.setOrgBranchId(branchId);
orderInfoDao.save(order);
// 登记事件
commonService.addOrderEvent(req.getOrderId(), "", "PEA-WEB", req.getOperator(), OrderStatusEnum.RESCHEDULED.getDescription(), OrderStatusEnum.RESCHEDULED.getDescription(), "");
return Result.success(null);
} }
private void sendMsg(String branchId, String orderId, String reservationTime) { private void sendMsg(String branchId, String orderId, String reservationTime) {
......
...@@ -85,6 +85,7 @@ public class CommonUtil { ...@@ -85,6 +85,7 @@ public class CommonUtil {
/** /**
* 判断是否cutoff * 判断是否cutoff
* 今日单或今日cutoff之后的次日单
* *
* @return * @return
*/ */
...@@ -96,7 +97,7 @@ public class CommonUtil { ...@@ -96,7 +97,7 @@ public class CommonUtil {
return 0; return 0;
} }
LocalDateTime workOff = LocalDate.now().atTime(Integer.parseInt(strOff.split(":")[0]), Integer.parseInt(strOff.split(":")[1]), 0); LocalDateTime workOff = LocalDate.now().atTime(Integer.parseInt(strOff.split(":")[0]), Integer.parseInt(strOff.split(":")[1]), 0);
if (localTime.isAfter(workOff)) { if (LocalDateTime.now().isAfter(workOff) && DateUtil.judgeTimeIsisTomorrow(localTime)) {
return 1; return 1;
} }
return 0; return 0;
...@@ -111,4 +112,8 @@ public class CommonUtil { ...@@ -111,4 +112,8 @@ public class CommonUtil {
} }
} }
public static void main(String[] args) {
isCutoff(LocalDateTime.now(), "18:00");
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!