Commit 3b0ddf6e by huangjinxin

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

2 parents bfade5c7 a2141fda
package com.dituhui.pea.order.controller;
import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.common.jackson.DateUtil;
import com.dituhui.pea.order.common.jackson.JsonUtil;
import com.dituhui.pea.order.dto.OrganizationTreeDTO;
import com.dituhui.pea.order.dto.param.*;
......@@ -18,6 +19,7 @@ import java.io.IOException;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.Date;
import java.util.List;
/**
* PEA 对外接口
......@@ -215,7 +217,8 @@ public class PeaApiController {
@PostMapping("/order/increase/query")
public Result<Order> orderIncrease(@Validated @RequestBody EngineerOrderParam requestParam) {
return Result.success(new Order());
return Result.success(peaOuterAPIService.orderIncreaseQuery(requestParam.getEngineerCode(), requestParam.getLocation(),
requestParam.getIdleDuration()));
}
/**
......@@ -228,7 +231,11 @@ public class PeaApiController {
@PostMapping("/order/increase/confirm")
public Result<OrderConfirmResult> orderConfirm(@Validated @RequestBody OrderConfirmParam requestParam) {
return Result.success(new OrderConfirmResult());
OrderConfirmResult result = new OrderConfirmResult();
result.setEngineerCode(requestParam.getEngineerCode());
result.setOrderId(requestParam.getOrderId());
result.setAppointmentStatus(requestParam.getAppointmentResult());
return Result.success(result);
}
......@@ -245,28 +252,26 @@ public class PeaApiController {
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
@NotNull @RequestParam("date") Date date) {
OrderDTO.AppointResult appointResult = peaOuterAPIService.engineerCode(engineerCode, DateUtil.fromDate(date).toLocalDate());
return Result.success(new OrderDTO.AppointResult());
return Result.success(appointResult);
}
/**
* 9.1GET 两点间里程和耗时查询
*
* @param origin 出发点经纬度
* @param destination 目的地
* @param vehicle 交通工具:1汽车;2电动车;3自行车;4步行;默认是汽车
* @return 两点间里程和耗时
* @apiNote 根据交通工具查询两个坐标点之间的里程和耗时
*/
@GetMapping("/base/distance")
public Result<BaseDistance> baseDistance(@NotBlank @RequestParam("origin") String origin,
@NotBlank @RequestParam("destination") String destination,
Integer vehicle) {
@PostMapping("/base/distance")
public Result<BaseDistance> baseDistance(@RequestBody BaseDistanceParam param) {
return Result.success(new BaseDistance());
BaseDistance result = new BaseDistance();
result.setOrigin(param.getOrigin());
result.setDestination(param.getDestination());
result.setVehicle(param.getVehicle());
return Result.success(result);
}
......
......@@ -20,4 +20,8 @@ public interface OrderInfoDao extends JpaRepository<OrderInfoEntity, Long>, JpaS
List<OrderInfoEntity> findAllByDtAndOrderIdIn(LocalDate dt, List<String> orderIds);
List<OrderInfoEntity> findByEngineerCodeAndDtAndAppointmentStatusIn(String engineerCode, LocalDate dt, List<String> appointmentStatus);
List<OrderInfoEntity> findByDtAndOrgTeamIdAndAppointmentStatusIn(LocalDate dt, String orgTeamId, List<String> appointmentStatus);
OrderInfoEntity findTopBySkillAndAppointmentStatus(String skill, String status);
List<OrderInfoEntity> findByServiceStatusAndEngineerCode(String serviceStatus, String engineerCode);
}
......@@ -12,11 +12,11 @@ public class BaseDistance {
/**
* 出发点 经度,纬度
*/
private String origin;
private BaseLocation origin;
/**
* 目的地 经度,纬度
*/
private String destination;
private BaseLocation destination;
/**
* 交通工具,1汽车;2电动车;3骑车;4步行
*/
......
package com.dituhui.pea.order.dto.param;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class BaseDistanceParam {
/**
* 出发点经纬度
*/
private BaseLocation origin;
/**
* 出发点经纬度
*/
private BaseLocation destination;
/**
* 交通工具:1汽车;2电动车;3自行车;默认是汽车
*/
private Integer vehicle = 1;
}
package com.dituhui.pea.order.dto.param;
import lombok.Getter;
import lombok.Setter;
import javax.validation.constraints.NotNull;
@Setter
@Getter
public class BaseLocation {
/**
* 地址纬度
*/
@NotNull
private Double latitude;
/**
* 地址经度
*/
@NotNull
private Double longitude;
}
......@@ -42,12 +42,12 @@ public class Order {
/**
* 分类
*/
private String product_type;
private String productType;
/**
* 需要的技能
*/
private String service_type;
private String serviceType;
/**
* 预计需要服务的时长
......@@ -69,6 +69,8 @@ public class Order {
/**
* 客户期望上门最晚时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date expectTimeEnd;
/**
......
package com.dituhui.pea.order.feign;
import com.dituhui.pea.order.feign.bean.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 调用Bean接口
*/
@FeignClient(url = "${bean.server}", name = "beanRemoteService")
public interface IBeanRemoteService {
/**
* 接口调用的accessToken获取。
*
* @param requestParam 请求参数
* @return accessToken 以及过期时间
* @apiNote 调用BEAN系统Api接口时需要先获取accessToken,放入header中用于验证。
*/
@PostMapping("/api/openapi/service/auth/get_access_token")
BeanR<AccessToken.Result> getAccessToken(@RequestBody AccessToken.Request requestParam);
/**
* 通过部门ids获取部门列表信息,如果不传入部门ids则获取全部。
*
* @param accessToken ACCESS_TOKEN
* @return BEAN组织架构部门信息
* @apiNote BEAN提供批量获取BEAN组织架构部门信息的接口,提供的字段包括:部门名称、部门ID、父部门ID、子部门ID列表等
*/
@GetMapping("/api/openapi/department/detail")
BeanR<Department> departmentDetail(@RequestHeader(name = "accessToken") String accessToken, @RequestParam("id") String id);
/**
* 查询BEAN维护的分部列表(大区-分部-分站&外围)
*
* @param accessToken ACCESS_TOKEN
* @return 部门列表
*/
@GetMapping("/api/openapi/department/queryBranchList")
BeanR<List<BranchRes>> departmentBranchList(@RequestHeader(name = "accessToken") String accessToken);
/**
* 获取人员列表
*
* @param accessToken ACCESS_TOKEN
* @param departmentId 部门Id,返回部门下所有用户(不包含子部门的用户)
* @return Bean 账号信息
* @apiNote BEAN提供批量获取BEAN账号信息的接口,提供字段包括:账号姓名、账号联系方式、所属部门等信息
*/
@GetMapping("/api/openapi/user/queryList")
BeanR<List<BeanAccountInfo>> queryUserList(@RequestHeader(name = "accessToken") String accessToken, @RequestParam("departmentId") String departmentId);
}
package com.dituhui.pea.order.feign.bean;
import lombok.Getter;
import lombok.Setter;
/**
* AccessToken 请求问题
*/
@Setter
@Getter
public class AccessToken {
/**
* accessToken 访问参数
*/
@Setter
@Getter
public static class Request {
/**
* 应用id需要在BEAN系统添加应用后生成
*/
private String appKey;
/**
* 当前时间时间戳
*/
private Long timestamp;
/**
* MD5(${secretKey}_${timestamp})
* 应用的secretKey和时间戳字段通过下划线拼接后MD5加密(不区分大小写
*/
private String verifyCode;
}
@Setter
@Getter
public static class Result {
/**
* accessToken
*/
private String access_token;
/**
* accessToken到期时间
*/
private String expire_time;
}
}
\ No newline at end of file
package com.dituhui.pea.order.feign.bean;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* BEAN 账号信息
*/
@Setter
@Getter
public class BeanAccountInfo {
/**
* BEAN账号ID
*/
private String id;
/**
* 账号中心ID
*/
private String centerId;
/**
* hr系统员工编号
*/
private String hrId;
/**
* 姓名
*/
private String userName;
/**
* 联系电话
*/
private String cellPhone;
/**
* 所在部门id集合
*/
private List<String> departmentIds;
}
package com.dituhui.pea.order.feign.bean;
import lombok.Getter;
import lombok.Setter;
/**
* bean 返回数据通用结构
*
* @param <E> 实际业务结果对象
*/
@Setter
@Getter
public class BeanR<E> {
/**
* 返回提示信息
*/
private String message;
/**
* 状态码
*/
private Integer errorCode;
/**
* 成功&失败
*/
private Boolean succ;
/**
* 数据对象
*/
private E data;
}
package com.dituhui.pea.order.feign.bean;
import lombok.Getter;
import lombok.Setter;
/**
*
*/
@Setter
@Getter
public class BranchRes {
/**
* 账户中心部门id
*/
private String bsId;
/**
* 部门名称
*/
private String name;
/**
* 部门缩写
*/
private String abbreviation;
/**
* 部门负责人联系方式
*/
private String phone;
/**
* 上级部门id
*/
private String bsParentId;
/**
* 部门类型
*/
private String type;
/**
* 1:启用 0:禁用 -1:注销
*/
private int enable;
}
package com.dituhui.pea.order.feign.bean;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* 部门列表详细信息
*/
@Setter
@Getter
public class Department {
/**
* Bean系统的部门ID UUID
*/
private String id;
/**
* 账号中心部门id
*/
private String bsDeptId;
/**
* 部门名称
*/
private String tagName;
/**
* 部门描述 非必须
*/
private String desc;
/**
* 部门缩写
*/
private String abbreviation;
/**
* 部门编号
*/
private String code;
/**
* 部门负责人联系方式
*/
private String phone;
/**
* 上级部门ID(存疑, 文档没有本字段描述)
*/
private String parentId;
/**
* 所属大区
*/
private String belongedRegion;
/**
* 所属分部
*/
private String belongedBranch;
/**
* 部分级别 集团、大区、分部
*/
private String deptLevel;
/**
* 类型 分站、外围、寄修中心
*/
private String deptType;
/**
* 是否启用外围仓 0未启用 1启用
*/
private int peripheralWarehouseEnabled;
/**
* 最长配件保留时长(天)
*/
private int partReserveTimeMax;
/**
* 状态 1启用 0禁用
*/
private int enable;
/**
* 子部门列表跟外层结构相同
*/
private List<Department> children;
}
......@@ -2,6 +2,11 @@ package com.dituhui.pea.order.service;
import com.dituhui.pea.order.dto.param.EstimateDTO;
import com.dituhui.pea.order.dto.param.Location;
import com.dituhui.pea.order.dto.param.Order;
import com.dituhui.pea.order.dto.param.OrderDTO;
import java.time.LocalDate;
import java.util.List;
/**
* PEA 对外服务接口API 定义
......@@ -19,4 +24,17 @@ public interface PeaOuterAPIService {
*/
EstimateDTO.VisitResult estimateVisitService(String brand, String productType, String serviceType,
Location clientLocation);
/**
* 根据技术员当前位置和空闲时间段,返回附近的n张尚未分配,且不需要备件的工单,技术员逐条顺序联系客户确认
*
* @param engineerCode 工程师工号
* @param location 地址坐标信息
* @param idleDuration 空闲时长 至少空闲多久以上,单位:分钟
* @return 不需要的备件且符合条件的多个未分配工单
*/
Order orderIncreaseQuery(String engineerCode, Location location, Integer idleDuration);
OrderDTO.AppointResult engineerCode(String engineerCode, LocalDate localDate);
}
package com.dituhui.pea.order.service.impl;
import com.dituhui.pea.order.common.jackson.DateUtil;
import com.dituhui.pea.order.dao.OrderInfoDao;
import com.dituhui.pea.order.dao.OrgGroupDao;
import com.dituhui.pea.order.dto.param.EstimateDTO;
import com.dituhui.pea.order.dto.param.Location;
import com.dituhui.pea.order.dto.param.Order;
import com.dituhui.pea.order.dto.param.OrderDTO;
import com.dituhui.pea.order.entity.OrderInfoEntity;
import com.dituhui.pea.order.entity.OrgGroupEntity;
import com.dituhui.pea.order.service.PeaOuterAPIService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 对外接口实现
*/
......@@ -20,6 +32,7 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService {
* 分部数据访问层
*/
private final OrgGroupDao orgGroupDao;
private final OrderInfoDao orderInfoDao;
@Override
public EstimateDTO.VisitResult estimateVisitService(String brand, String productType, String serviceType, Location clientLocation) {
......@@ -43,4 +56,63 @@ public class PeaOuterAPIServiceImpl implements PeaOuterAPIService {
return visitResult;
}
@Override
public Order orderIncreaseQuery(String engineerCode, Location location, Integer idleDuration) {
OrderInfoEntity sss = orderInfoDao.findTopBySkillAndAppointmentStatus("标准安装", "INIT");
Order order = new Order();
order.setOrderId(sss.getOrderId());
order.setName(sss.getName());
order.setPhone(sss.getPhone());
order.setBrand(sss.getBrand());
order.setProductType(sss.getType());
order.setFaultDescribe(sss.getFaultDescribe());
order.setExpectTimeBegin(DateUtil.toDate(sss.getExpectTimeBegin()));
order.setExpectTimeEnd(DateUtil.toDate(sss.getExpectTimeEnd()));
order.setApplyNote(sss.getApplyNote());
Location orderLocation = new Location();
orderLocation.setAddress(sss.getAddress());
orderLocation.setLongitude(Double.parseDouble(sss.getX()));
orderLocation.setLatitude(Double.parseDouble(sss.getY()));
order.setLocation(orderLocation);
return order;
}
@Override
public OrderDTO.AppointResult engineerCode(String engineerCode, LocalDate localDate) {
OrderDTO.AppointResult result = new OrderDTO.AppointResult();
result.setEngineerCode(engineerCode);
result.setDate(DateUtil.toDate(localDate));
List<OrderInfoEntity> finishedOrder = orderInfoDao.findByServiceStatusAndEngineerCode("INIT", engineerCode);
List<OrderDTO.AppointmentOrderResult> collect = Optional.ofNullable(finishedOrder).orElse(Collections.emptyList())
.stream()
.map(this::order2AppointmentOrderResult)
.collect(Collectors.toList());
result.setOrders(collect);
return result;
}
private OrderDTO.AppointmentOrderResult order2AppointmentOrderResult(OrderInfoEntity orderInfo) {
OrderDTO.AppointmentOrderResult result = new OrderDTO.AppointmentOrderResult();
result.setOrderId(orderInfo.getOrderId());
result.setOrderStatus(orderInfo.getServiceStatus());
result.setPlanBeginTime(DateUtil.toDate(orderInfo.getPlanStartTime()));
// result.setPlanDistance();
result.setPlanDuration(orderInfo.getTakeTime() * 60);
if (Objects.nonNull(orderInfo.getActualStartTime())) {
result.setActualBeginTime(DateUtil.toDate(orderInfo.getActualStartTime()));
result.setActualDuration(orderInfo.getArriveElapsed() * 60);
result.setActualDistance(orderInfo.getArriveDistance());
}
return result;
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!