1、修改同步组织
2、新增北斗定位
This commit is contained in:
+74
@@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.transport.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运单车辆实时定位结果
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "运单车辆实时定位结果")
|
||||||
|
public class WaybillLocateVO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "运单ID")
|
||||||
|
private Long waybillId;
|
||||||
|
|
||||||
|
@Schema(description = "车牌号")
|
||||||
|
private String vehicleNo;
|
||||||
|
|
||||||
|
@Schema(description = "经度")
|
||||||
|
private BigDecimal longitude;
|
||||||
|
|
||||||
|
@Schema(description = "纬度")
|
||||||
|
private BigDecimal latitude;
|
||||||
|
|
||||||
|
@Schema(description = "地址")
|
||||||
|
private String address;
|
||||||
|
|
||||||
|
@Schema(description = "定位时间")
|
||||||
|
private String locateTime;
|
||||||
|
|
||||||
|
@Schema(description = "速度")
|
||||||
|
private String speed;
|
||||||
|
|
||||||
|
@Schema(description = "方向")
|
||||||
|
private String direction;
|
||||||
|
|
||||||
|
@Schema(description = "LBS原始数据")
|
||||||
|
private Map<String, Object> rawData;
|
||||||
|
}
|
||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.transport.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运单历史轨迹结果
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "运单历史轨迹结果")
|
||||||
|
public class WaybillTrackVO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "运单ID")
|
||||||
|
private Long waybillId;
|
||||||
|
|
||||||
|
@Schema(description = "车牌号")
|
||||||
|
private String vehicleNo;
|
||||||
|
|
||||||
|
@Schema(description = "开始日期")
|
||||||
|
private String startDate;
|
||||||
|
|
||||||
|
@Schema(description = "结束日期")
|
||||||
|
private String endDate;
|
||||||
|
|
||||||
|
@Schema(description = "轨迹点数量")
|
||||||
|
private Integer total;
|
||||||
|
|
||||||
|
@Schema(description = "轨迹点列表")
|
||||||
|
private List<WaybillTrackPointVO> points = new ArrayList<>();
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Schema(description = "轨迹点")
|
||||||
|
public static class WaybillTrackPointVO implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "车牌号")
|
||||||
|
private String vehicleNo;
|
||||||
|
|
||||||
|
@Schema(description = "经度")
|
||||||
|
private BigDecimal longitude;
|
||||||
|
|
||||||
|
@Schema(description = "纬度")
|
||||||
|
private BigDecimal latitude;
|
||||||
|
|
||||||
|
@Schema(description = "定位时间")
|
||||||
|
private String locateTime;
|
||||||
|
|
||||||
|
@Schema(description = "速度")
|
||||||
|
private String speed;
|
||||||
|
|
||||||
|
@Schema(description = "方向")
|
||||||
|
private String direction;
|
||||||
|
|
||||||
|
@Schema(description = "地址")
|
||||||
|
private String address;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -33,7 +33,11 @@ iam:
|
|||||||
profile-authorization: ${IAM_SSO_PROFILE_AUTHORIZATION:YjNlZmU0ODEwMzJiNGJhZTpkYzQ5NDY1NmQ4MzE0NThjODI5MzlmNzA2ZjliNDY3MQ==}
|
profile-authorization: ${IAM_SSO_PROFILE_AUTHORIZATION:YjNlZmU0ODEwMzJiNGJhZTpkYzQ5NDY1NmQ4MzE0NThjODI5MzlmNzA2ZjliNDY3MQ==}
|
||||||
page-size: ${IAM_SSO_ACCOUNT_PAGE_SIZE:50}
|
page-size: ${IAM_SSO_ACCOUNT_PAGE_SIZE:50}
|
||||||
|
|
||||||
# OA人员同步走同一 gwzh 网关,仅需 Authorization(与可用 curl 一致)
|
# OA组织/人员同步走同一 gwzh 网关,仅需 Authorization(与可用 curl 一致)
|
||||||
thirdParty:
|
thirdParty:
|
||||||
oa:
|
oa:
|
||||||
|
baseUrl: ${OA_BASE_URL:http://172.16.204.83:38000}
|
||||||
|
queryCompanyPageUrl: ${OA_QUERY_COMPANY_PAGE_URL:/gwzh/OA/OA_GET_COMPANY_LIST}
|
||||||
|
queryDepartmentPageUrl: ${OA_QUERY_DEPARTMENT_PAGE_URL:/gwzh/OA/OA_GET_DEPARTMENT_LIST}
|
||||||
|
queryPersonPageUrl: ${OA_QUERY_PERSON_PAGE_URL:/gwzh/OA/OA_GET_USER_LIST}
|
||||||
authorization: ${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=}}
|
authorization: ${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=}}
|
||||||
|
|||||||
@@ -31,6 +31,10 @@
|
|||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-transport-api</artifactId>
|
<artifactId>blade-transport-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springblade</groupId>
|
||||||
|
<artifactId>blade-lbs-api</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-user-api</artifactId>
|
<artifactId>blade-user-api</artifactId>
|
||||||
|
|||||||
+19
@@ -53,6 +53,8 @@ import org.springblade.transport.pojo.dto.WaybillImportBatchRequest;
|
|||||||
import org.springblade.transport.pojo.vo.BusinessRemoveResultVO;
|
import org.springblade.transport.pojo.vo.BusinessRemoveResultVO;
|
||||||
import org.springblade.transport.pojo.vo.LoadingManageVO;
|
import org.springblade.transport.pojo.vo.LoadingManageVO;
|
||||||
import org.springblade.transport.pojo.vo.WaybillImportBatchVO;
|
import org.springblade.transport.pojo.vo.WaybillImportBatchVO;
|
||||||
|
import org.springblade.transport.pojo.vo.WaybillLocateVO;
|
||||||
|
import org.springblade.transport.pojo.vo.WaybillTrackVO;
|
||||||
import org.springblade.transport.pojo.vo.WaybillPunchRecordsVO;
|
import org.springblade.transport.pojo.vo.WaybillPunchRecordsVO;
|
||||||
import org.springblade.transport.pojo.vo.WaybillVO;
|
import org.springblade.transport.pojo.vo.WaybillVO;
|
||||||
import org.springblade.transport.pojo.dto.WaybillMileageRequest;
|
import org.springblade.transport.pojo.dto.WaybillMileageRequest;
|
||||||
@@ -109,6 +111,23 @@ public class WaybillController extends BladeController {
|
|||||||
return R.data(waybillService.listPunchRecords(waybillId));
|
return R.data(waybillService.listPunchRecords(waybillId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/locate")
|
||||||
|
@ApiOperationSupport(order = 1)
|
||||||
|
@Operation(summary = "车辆实时定位", description = "按运单绑定车牌调用 LBS_LOCATE")
|
||||||
|
public R<WaybillLocateVO> locate(@Parameter(description = "运单ID", required = true) @RequestParam Long id) {
|
||||||
|
return R.data(waybillService.locateVehicle(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("/track")
|
||||||
|
@ApiOperationSupport(order = 1)
|
||||||
|
@Operation(summary = "车辆历史轨迹", description = "按运单绑定车牌 + 日期区间调用 LBS_LOCATE")
|
||||||
|
public R<WaybillTrackVO> track(
|
||||||
|
@Parameter(description = "运单ID", required = true) @RequestParam Long id,
|
||||||
|
@Parameter(description = "开始日期 YYYY-MM-DD", required = true) @RequestParam String startDate,
|
||||||
|
@Parameter(description = "结束日期 YYYY-MM-DD", required = true) @RequestParam String endDate) {
|
||||||
|
return R.data(waybillService.trackVehicle(id, startDate, endDate));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
@ApiOperationSupport(order = 2)
|
@ApiOperationSupport(order = 2)
|
||||||
@Operation(summary = "分页", description = "传入waybill")
|
@Operation(summary = "分页", description = "传入waybill")
|
||||||
|
|||||||
+20
@@ -28,6 +28,8 @@ import org.springblade.transport.excel.WaybillExcel;
|
|||||||
import org.springblade.transport.pojo.entity.Waybill;
|
import org.springblade.transport.pojo.entity.Waybill;
|
||||||
import org.springblade.transport.pojo.vo.BusinessRemoveResultVO;
|
import org.springblade.transport.pojo.vo.BusinessRemoveResultVO;
|
||||||
import org.springblade.transport.pojo.vo.LoadingManageVO;
|
import org.springblade.transport.pojo.vo.LoadingManageVO;
|
||||||
|
import org.springblade.transport.pojo.vo.WaybillLocateVO;
|
||||||
|
import org.springblade.transport.pojo.vo.WaybillTrackVO;
|
||||||
import org.springblade.transport.pojo.vo.WaybillPunchRecordsVO;
|
import org.springblade.transport.pojo.vo.WaybillPunchRecordsVO;
|
||||||
import org.springblade.transport.pojo.vo.WaybillVO;
|
import org.springblade.transport.pojo.vo.WaybillVO;
|
||||||
import org.springblade.transport.pojo.dto.WaybillMileageRequest;
|
import org.springblade.transport.pojo.dto.WaybillMileageRequest;
|
||||||
@@ -49,6 +51,24 @@ public interface IWaybillService extends BaseService<Waybill> {
|
|||||||
*/
|
*/
|
||||||
WaybillPunchRecordsVO listPunchRecords(Long waybillId);
|
WaybillPunchRecordsVO listPunchRecords(Long waybillId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运单车辆实时定位(按运单绑定车牌调用 LBS)
|
||||||
|
*
|
||||||
|
* @param id 运单ID
|
||||||
|
* @return 定位结果
|
||||||
|
*/
|
||||||
|
WaybillLocateVO locateVehicle(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运单历史轨迹回放(按运单绑定车牌 + 日期区间调用 LBS)
|
||||||
|
*
|
||||||
|
* @param id 运单ID
|
||||||
|
* @param startDate 开始日期 YYYY-MM-DD
|
||||||
|
* @param endDate 结束日期 YYYY-MM-DD
|
||||||
|
* @return 轨迹结果
|
||||||
|
*/
|
||||||
|
WaybillTrackVO trackVehicle(Long id, String startDate, String endDate);
|
||||||
|
|
||||||
Waybill syncDriverAcceptState(Waybill waybill);
|
Waybill syncDriverAcceptState(Waybill waybill);
|
||||||
boolean submit(Waybill waybill);
|
boolean submit(Waybill waybill);
|
||||||
boolean saveDraft(Waybill waybill);
|
boolean saveDraft(Waybill waybill);
|
||||||
|
|||||||
+197
-3
@@ -25,6 +25,7 @@ package org.springblade.transport.service.impl;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.springblade.core.log.exception.ServiceException;
|
import org.springblade.core.log.exception.ServiceException;
|
||||||
import org.springblade.core.mp.base.BaseServiceImpl;
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
||||||
import org.springblade.core.tool.jackson.JsonUtil;
|
import org.springblade.core.tool.jackson.JsonUtil;
|
||||||
@@ -32,10 +33,10 @@ import org.springblade.core.tool.utils.BeanUtil;
|
|||||||
import org.springblade.core.tool.utils.Func;
|
import org.springblade.core.tool.utils.Func;
|
||||||
import org.springblade.system.cache.UserCache;
|
import org.springblade.system.cache.UserCache;
|
||||||
import org.springblade.system.pojo.entity.Dept;
|
import org.springblade.system.pojo.entity.Dept;
|
||||||
|
import org.springblade.thirdparty.lbs.feign.ILbsClient;
|
||||||
|
import org.springblade.thirdparty.lbs.pojo.dto.LbsLocateRequest;
|
||||||
|
import org.springblade.thirdparty.lbs.pojo.vo.LbsLocateResponse;
|
||||||
import org.springblade.transport.excel.WaybillExcel;
|
import org.springblade.transport.excel.WaybillExcel;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import org.springblade.transport.mapper.WaybillEnroutePunchMapper;
|
import org.springblade.transport.mapper.WaybillEnroutePunchMapper;
|
||||||
import org.springblade.transport.mapper.WaybillMapper;
|
import org.springblade.transport.mapper.WaybillMapper;
|
||||||
import org.springblade.transport.mapper.WaybillNodePunchMapper;
|
import org.springblade.transport.mapper.WaybillNodePunchMapper;
|
||||||
@@ -49,6 +50,8 @@ import org.springblade.transport.pojo.entity.WaybillNodePunch;
|
|||||||
import org.springblade.transport.pojo.dto.WaybillMileageRequest;
|
import org.springblade.transport.pojo.dto.WaybillMileageRequest;
|
||||||
import org.springblade.transport.pojo.vo.BusinessRemoveResultVO;
|
import org.springblade.transport.pojo.vo.BusinessRemoveResultVO;
|
||||||
import org.springblade.transport.pojo.vo.LoadingManageVO;
|
import org.springblade.transport.pojo.vo.LoadingManageVO;
|
||||||
|
import org.springblade.transport.pojo.vo.WaybillLocateVO;
|
||||||
|
import org.springblade.transport.pojo.vo.WaybillTrackVO;
|
||||||
import org.springblade.transport.pojo.vo.WaybillPunchPhotoVO;
|
import org.springblade.transport.pojo.vo.WaybillPunchPhotoVO;
|
||||||
import org.springblade.transport.pojo.vo.WaybillPunchRecordItemVO;
|
import org.springblade.transport.pojo.vo.WaybillPunchRecordItemVO;
|
||||||
import org.springblade.transport.pojo.vo.WaybillPunchRecordsVO;
|
import org.springblade.transport.pojo.vo.WaybillPunchRecordsVO;
|
||||||
@@ -67,7 +70,11 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
@@ -111,6 +118,9 @@ public class WaybillServiceImpl extends BaseServiceImpl<WaybillMapper, Waybill>
|
|||||||
@jakarta.annotation.Resource
|
@jakarta.annotation.Resource
|
||||||
private WaybillEnroutePunchMapper waybillEnroutePunchMapper;
|
private WaybillEnroutePunchMapper waybillEnroutePunchMapper;
|
||||||
|
|
||||||
|
@jakarta.annotation.Resource
|
||||||
|
private ILbsClient lbsClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IPage<WaybillVO> selectWaybillPage(IPage<Waybill> page, WaybillVO waybill) {
|
public IPage<WaybillVO> selectWaybillPage(IPage<Waybill> page, WaybillVO waybill) {
|
||||||
IPage<Waybill> entityPage = page(page, buildQuery(waybill));
|
IPage<Waybill> entityPage = page(page, buildQuery(waybill));
|
||||||
@@ -128,6 +138,190 @@ public class WaybillServiceImpl extends BaseServiceImpl<WaybillMapper, Waybill>
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WaybillLocateVO locateVehicle(Long id) {
|
||||||
|
Waybill waybill = requireWaybillWithVehicleNo(id, "无法实时定位");
|
||||||
|
String vehicleNo = waybill.getVehicleNo().trim();
|
||||||
|
LbsLocateResponse response = invokeLbsLocate(id, vehicleNo, new LbsLocateRequest(vehicleNo), "实时定位");
|
||||||
|
List<Map<String, Object>> pointMaps = extractLbsPointMaps(response.getData());
|
||||||
|
if (pointMaps.isEmpty()) {
|
||||||
|
throw new ServiceException("暂无车辆实时定位数据");
|
||||||
|
}
|
||||||
|
return buildLocateVO(id, vehicleNo, pointMaps.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WaybillTrackVO trackVehicle(Long id, String startDate, String endDate) {
|
||||||
|
Waybill waybill = requireWaybillWithVehicleNo(id, "无法查询历史轨迹");
|
||||||
|
String vehicleNo = waybill.getVehicleNo().trim();
|
||||||
|
String normalizedStart = normalizeTrackDate(startDate, "开始日期");
|
||||||
|
String normalizedEnd = normalizeTrackDate(endDate, "结束日期");
|
||||||
|
if (LocalDate.parse(normalizedStart).isAfter(LocalDate.parse(normalizedEnd))) {
|
||||||
|
throw new ServiceException("开始日期不能晚于结束日期");
|
||||||
|
}
|
||||||
|
LbsLocateResponse response = invokeLbsLocate(id, vehicleNo,
|
||||||
|
new LbsLocateRequest(vehicleNo, normalizedStart, normalizedEnd), "历史轨迹");
|
||||||
|
List<Map<String, Object>> pointMaps = extractLbsPointMaps(response.getData());
|
||||||
|
WaybillTrackVO trackVO = new WaybillTrackVO();
|
||||||
|
trackVO.setWaybillId(id);
|
||||||
|
trackVO.setVehicleNo(vehicleNo);
|
||||||
|
trackVO.setStartDate(normalizedStart);
|
||||||
|
trackVO.setEndDate(normalizedEnd);
|
||||||
|
List<WaybillTrackVO.WaybillTrackPointVO> points = new ArrayList<>();
|
||||||
|
for (Map<String, Object> pointMap : pointMaps) {
|
||||||
|
WaybillTrackVO.WaybillTrackPointVO point = buildTrackPoint(vehicleNo, pointMap);
|
||||||
|
if (point.getLongitude() != null && point.getLatitude() != null) {
|
||||||
|
points.add(point);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
trackVO.setPoints(points);
|
||||||
|
trackVO.setTotal(points.size());
|
||||||
|
return trackVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Waybill requireWaybillWithVehicleNo(Long id, String actionTip) {
|
||||||
|
if (id == null) {
|
||||||
|
throw new ServiceException("运单ID不能为空");
|
||||||
|
}
|
||||||
|
Waybill waybill = getById(id);
|
||||||
|
if (waybill == null || Objects.equals(waybill.getIsDeleted(), 1)) {
|
||||||
|
throw new ServiceException("运单不存在");
|
||||||
|
}
|
||||||
|
String vehicleNo = Func.toStr(waybill.getVehicleNo(), "").trim();
|
||||||
|
if (Func.isEmpty(vehicleNo)) {
|
||||||
|
throw new ServiceException("运单未绑定车牌号," + actionTip);
|
||||||
|
}
|
||||||
|
waybill.setVehicleNo(vehicleNo);
|
||||||
|
return waybill;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LbsLocateResponse invokeLbsLocate(Long waybillId, String vehicleNo, LbsLocateRequest request, String scene) {
|
||||||
|
LbsLocateResponse response;
|
||||||
|
try {
|
||||||
|
response = lbsClient.locate(request);
|
||||||
|
} catch (Exception exception) {
|
||||||
|
log.error("调用LBS{}失败 waybillId={}, vehicleNo={}", scene, waybillId, vehicleNo, exception);
|
||||||
|
throw new ServiceException("调用车辆" + scene + "接口失败");
|
||||||
|
}
|
||||||
|
if (response == null || !response.isSuccess()) {
|
||||||
|
String errorMessage = response == null ? "车辆" + scene + "无返回" : response.errorMessage();
|
||||||
|
throw new ServiceException(errorMessage);
|
||||||
|
}
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalizeTrackDate(String dateText, String fieldName) {
|
||||||
|
if (Func.isEmpty(dateText)) {
|
||||||
|
throw new ServiceException(fieldName + "不能为空");
|
||||||
|
}
|
||||||
|
String normalized = dateText.trim();
|
||||||
|
try {
|
||||||
|
return LocalDate.parse(normalized, DateTimeFormatter.ISO_LOCAL_DATE).toString();
|
||||||
|
} catch (DateTimeParseException exception) {
|
||||||
|
throw new ServiceException(fieldName + "格式必须为YYYY-MM-DD");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提取 LBS 轨迹点列表,兼容 data 数组 或 data.list 数组
|
||||||
|
*/
|
||||||
|
private List<Map<String, Object>> extractLbsPointMaps(JsonNode dataNode) {
|
||||||
|
List<Map<String, Object>> pointMaps = new ArrayList<>();
|
||||||
|
if (dataNode == null || dataNode.isNull()) {
|
||||||
|
return pointMaps;
|
||||||
|
}
|
||||||
|
JsonNode listNode = dataNode;
|
||||||
|
if (dataNode.isObject() && dataNode.has("list")) {
|
||||||
|
listNode = dataNode.get("list");
|
||||||
|
}
|
||||||
|
if (listNode != null && listNode.isArray()) {
|
||||||
|
for (JsonNode item : listNode) {
|
||||||
|
if (item != null && item.isObject()) {
|
||||||
|
pointMaps.add(JsonUtil.toMap(item.toString()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pointMaps;
|
||||||
|
}
|
||||||
|
if (dataNode.isObject()) {
|
||||||
|
pointMaps.add(JsonUtil.toMap(dataNode.toString()));
|
||||||
|
}
|
||||||
|
return pointMaps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将 LBS 单点数据归一化为实时定位结果
|
||||||
|
*/
|
||||||
|
private WaybillLocateVO buildLocateVO(Long waybillId, String vehicleNo, Map<String, Object> pointMap) {
|
||||||
|
WaybillLocateVO locateVO = new WaybillLocateVO();
|
||||||
|
locateVO.setWaybillId(waybillId);
|
||||||
|
locateVO.setVehicleNo(vehicleNo);
|
||||||
|
locateVO.setRawData(pointMap);
|
||||||
|
fillPointFields(locateVO, pointMap);
|
||||||
|
return locateVO;
|
||||||
|
}
|
||||||
|
|
||||||
|
private WaybillTrackVO.WaybillTrackPointVO buildTrackPoint(String vehicleNo, Map<String, Object> pointMap) {
|
||||||
|
WaybillTrackVO.WaybillTrackPointVO point = new WaybillTrackVO.WaybillTrackPointVO();
|
||||||
|
point.setVehicleNo(vehicleNo);
|
||||||
|
fillPointFields(point, pointMap);
|
||||||
|
return point;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillPointFields(WaybillLocateVO target, Map<String, Object> pointMap) {
|
||||||
|
target.setLongitude(firstDecimal(pointMap, "longitude", "lon", "lng", "x", "jd", "Longitude", "LON", "LNG", "JD", "X"));
|
||||||
|
target.setLatitude(firstDecimal(pointMap, "latitude", "lat", "y", "wd", "Latitude", "LAT", "WD", "Y"));
|
||||||
|
target.setAddress(firstText(pointMap, "address", "addr", "adr", "wz", "Address", "ADDR", "ADR"));
|
||||||
|
target.setLocateTime(firstText(pointMap, "locationTime", "pos_time", "locateTime", "gpsTime", "gpstime", "time", "gpszdsj", "GPSTime", "Time"));
|
||||||
|
target.setSpeed(firstText(pointMap, "speed", "v", "sd", "Speed", "SD", "V"));
|
||||||
|
target.setDirection(firstText(pointMap, "direct", "direction", "h", "fx", "Direction", "FX", "course", "H"));
|
||||||
|
String responseVehicleNo = firstText(pointMap, "cph", "vehicleNo", "plateNo", "CPH");
|
||||||
|
if (Func.isNotEmpty(responseVehicleNo)) {
|
||||||
|
target.setVehicleNo(responseVehicleNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillPointFields(WaybillTrackVO.WaybillTrackPointVO target, Map<String, Object> pointMap) {
|
||||||
|
target.setLongitude(firstDecimal(pointMap, "longitude", "lon", "lng", "x", "jd", "Longitude", "LON", "LNG", "JD", "X"));
|
||||||
|
target.setLatitude(firstDecimal(pointMap, "latitude", "lat", "y", "wd", "Latitude", "LAT", "WD", "Y"));
|
||||||
|
target.setAddress(firstText(pointMap, "address", "addr", "adr", "wz", "Address", "ADDR", "ADR"));
|
||||||
|
target.setLocateTime(firstText(pointMap, "locationTime", "pos_time", "locateTime", "gpsTime", "gpstime", "time", "gpszdsj", "GPSTime", "Time"));
|
||||||
|
target.setSpeed(firstText(pointMap, "speed", "v", "sd", "Speed", "SD", "V"));
|
||||||
|
target.setDirection(firstText(pointMap, "direct", "direction", "h", "fx", "Direction", "FX", "course", "H"));
|
||||||
|
String responseVehicleNo = firstText(pointMap, "cph", "vehicleNo", "plateNo", "CPH");
|
||||||
|
if (Func.isNotEmpty(responseVehicleNo)) {
|
||||||
|
target.setVehicleNo(responseVehicleNo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BigDecimal firstDecimal(Map<String, Object> rawData, String... keys) {
|
||||||
|
String text = firstText(rawData, keys);
|
||||||
|
if (Func.isEmpty(text)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return new BigDecimal(text.trim());
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String firstText(Map<String, Object> rawData, String... keys) {
|
||||||
|
if (rawData == null || rawData.isEmpty() || keys == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (String key : keys) {
|
||||||
|
Object value = rawData.get(key);
|
||||||
|
if (value == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String text = String.valueOf(value).trim();
|
||||||
|
if (Func.isNotEmpty(text) && !"null".equalsIgnoreCase(text)) {
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WaybillPunchRecordsVO listPunchRecords(Long waybillId) {
|
public WaybillPunchRecordsVO listPunchRecords(Long waybillId) {
|
||||||
WaybillPunchRecordsVO vo = new WaybillPunchRecordsVO();
|
WaybillPunchRecordsVO vo = new WaybillPunchRecordsVO();
|
||||||
|
|||||||
@@ -8,3 +8,10 @@ spring:
|
|||||||
url: ${blade.datasource.dev.url}
|
url: ${blade.datasource.dev.url}
|
||||||
username: ${blade.datasource.dev.username}
|
username: ${blade.datasource.dev.username}
|
||||||
password: ${blade.datasource.dev.password}
|
password: ${blade.datasource.dev.password}
|
||||||
|
|
||||||
|
# LBS 车辆实时定位(Authorization 与 OA 人员接口一致)
|
||||||
|
thirdParty:
|
||||||
|
lbs:
|
||||||
|
baseUrl: ${LBS_BASE_URL:http://172.16.204.83:38000}
|
||||||
|
locateUrl: ${LBS_LOCATE_URL:/gwzh/LBS/LBS_LOCATE}
|
||||||
|
authorization: ${LBS_AUTHORIZATION:${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=}}}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springblade</groupId>
|
||||||
|
<artifactId>blade-third-party-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>blade-lbs-api</artifactId>
|
||||||
|
<name>${project.artifactId}</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springblade</groupId>
|
||||||
|
<artifactId>blade-core-tool</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
+69
@@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.thirdparty.lbs.config;
|
||||||
|
|
||||||
|
import feign.Logger;
|
||||||
|
import feign.Request;
|
||||||
|
import org.springblade.thirdparty.lbs.interceptor.LbsRequestInterceptor;
|
||||||
|
import org.springframework.cloud.openfeign.clientconfig.FeignClientConfigurer;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LBS Feign 客户端配置。
|
||||||
|
* <p>
|
||||||
|
* 关闭父上下文继承,避免全局 BladeFeignRequestInterceptor 透传登录态请求头导致 gwzh 400。
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
public class LbsFeignClientConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FeignClientConfigurer feignClientConfigurer() {
|
||||||
|
return new FeignClientConfigurer() {
|
||||||
|
@Override
|
||||||
|
public boolean inheritParentConfiguration() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public LbsRequestInterceptor requestInterceptor(LbsProperties lbsProperties) {
|
||||||
|
return new LbsRequestInterceptor(lbsProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Logger.Level feignLoggerLevel() {
|
||||||
|
return Logger.Level.FULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public Request.Options options() {
|
||||||
|
return new Request.Options(10, TimeUnit.SECONDS, 60, TimeUnit.SECONDS, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
+54
@@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.thirdparty.lbs.config;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LBS 配置
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ConfigurationProperties(prefix = "third-party.lbs")
|
||||||
|
public class LbsProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LBS 网关基础地址
|
||||||
|
*/
|
||||||
|
private String baseUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆实时定位路径
|
||||||
|
*/
|
||||||
|
private String locateUrl = "/gwzh/LBS/LBS_LOCATE";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gwzh 网关 Authorization(Basic),与 OA 人员接口一致
|
||||||
|
*/
|
||||||
|
private String authorization;
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.thirdparty.lbs.config;
|
||||||
|
|
||||||
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 第三方 LBS 自动配置
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@EnableConfigurationProperties(LbsProperties.class)
|
||||||
|
@Configuration
|
||||||
|
public class ThirdPartyLbsAutoConfiguration {
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.thirdparty.lbs.constant;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LBS 常量
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
public final class LbsConstant {
|
||||||
|
|
||||||
|
private LbsConstant() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功响应码(文档标注)
|
||||||
|
*/
|
||||||
|
public static final int SUCCESS_STATUS = 200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成功响应码(字符串)
|
||||||
|
*/
|
||||||
|
public static final String SUCCESS_STATUS_TEXT = "200";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gwzh 常见成功码(与 OA 一致)
|
||||||
|
*/
|
||||||
|
public static final String SUCCESS_CODE = "1";
|
||||||
|
}
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.thirdparty.lbs.feign;
|
||||||
|
|
||||||
|
import org.springblade.thirdparty.lbs.config.LbsFeignClientConfig;
|
||||||
|
import org.springblade.thirdparty.lbs.pojo.dto.LbsLocateRequest;
|
||||||
|
import org.springblade.thirdparty.lbs.pojo.vo.LbsLocateResponse;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LBS 接口
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@FeignClient(name = "LBS", url = "${thirdParty.lbs.baseUrl}", configuration = LbsFeignClientConfig.class)
|
||||||
|
public interface ILbsClient {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆实时定位
|
||||||
|
*
|
||||||
|
* @param request 请求(cph=车牌号)
|
||||||
|
* @return 定位结果
|
||||||
|
*/
|
||||||
|
@PostMapping("${thirdParty.lbs.locateUrl:/gwzh/LBS/LBS_LOCATE}")
|
||||||
|
LbsLocateResponse locate(@RequestBody LbsLocateRequest request);
|
||||||
|
}
|
||||||
+115
@@ -0,0 +1,115 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.thirdparty.lbs.interceptor;
|
||||||
|
|
||||||
|
import feign.RequestInterceptor;
|
||||||
|
import feign.RequestTemplate;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springblade.core.tool.utils.StringUtil;
|
||||||
|
import org.springblade.thirdparty.lbs.config.LbsProperties;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
|
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LBS Feign 请求拦截器:仅发送 Authorization + Content-Type,与 OA 人员接口一致。
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class LbsRequestInterceptor implements RequestInterceptor {
|
||||||
|
|
||||||
|
private static final String BASIC_PREFIX = "Basic ";
|
||||||
|
private static final String BEARER_PREFIX = "Bearer ";
|
||||||
|
private static final Set<String> KEEP_HEADERS = Set.of(
|
||||||
|
HttpHeaders.AUTHORIZATION.toLowerCase(Locale.ROOT),
|
||||||
|
HttpHeaders.CONTENT_TYPE.toLowerCase(Locale.ROOT)
|
||||||
|
);
|
||||||
|
|
||||||
|
private final LbsProperties lbsProperties;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(RequestTemplate template) {
|
||||||
|
stripUnwantedHeaders(template);
|
||||||
|
template.header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE);
|
||||||
|
|
||||||
|
String authorization = normalizeAuthorization(lbsProperties.getAuthorization());
|
||||||
|
if (StringUtil.isNotBlank(authorization)) {
|
||||||
|
template.header(HttpHeaders.AUTHORIZATION, authorization);
|
||||||
|
} else {
|
||||||
|
log.warn("LBS Feign 未配置 third-party.lbs.authorization,gwzh 网关可能拒绝请求");
|
||||||
|
}
|
||||||
|
|
||||||
|
logRequest(template);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logRequest(RequestTemplate template) {
|
||||||
|
String bodyText = "";
|
||||||
|
byte[] body = template.body();
|
||||||
|
if (body != null && body.length > 0) {
|
||||||
|
Charset charset = template.requestCharset() == null ? StandardCharsets.UTF_8 : template.requestCharset();
|
||||||
|
bodyText = new String(body, charset);
|
||||||
|
}
|
||||||
|
log.info("LBS Feign 请求 method={}, url={}{}{}, headers={}, body={}",
|
||||||
|
template.method(),
|
||||||
|
template.feignTarget() == null ? "" : template.feignTarget().url(),
|
||||||
|
template.path(),
|
||||||
|
template.queryLine() == null ? "" : template.queryLine(),
|
||||||
|
template.headers(),
|
||||||
|
bodyText);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stripUnwantedHeaders(RequestTemplate template) {
|
||||||
|
Map<String, Collection<String>> headers = template.headers();
|
||||||
|
List<String> headerNames = new ArrayList<>(headers.keySet());
|
||||||
|
for (String headerName : headerNames) {
|
||||||
|
if (!KEEP_HEADERS.contains(headerName.toLowerCase(Locale.ROOT))) {
|
||||||
|
template.removeHeader(headerName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalizeAuthorization(String authorization) {
|
||||||
|
if (StringUtil.isBlank(authorization)) {
|
||||||
|
return authorization;
|
||||||
|
}
|
||||||
|
if (StringUtil.startsWithIgnoreCase(authorization, BASIC_PREFIX)
|
||||||
|
|| StringUtil.startsWithIgnoreCase(authorization, BEARER_PREFIX)) {
|
||||||
|
return authorization;
|
||||||
|
}
|
||||||
|
return BASIC_PREFIX + authorization;
|
||||||
|
}
|
||||||
|
}
|
||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.thirdparty.lbs.pojo.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LBS 定位/历史轨迹请求
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class LbsLocateRequest implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车牌号
|
||||||
|
*/
|
||||||
|
private String cph;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始日期,格式 YYYY-MM-DD(历史轨迹)
|
||||||
|
*/
|
||||||
|
@JsonProperty("start_date")
|
||||||
|
private String startDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结束日期,格式 YYYY-MM-DD(历史轨迹)
|
||||||
|
*/
|
||||||
|
@JsonProperty("end_date")
|
||||||
|
private String endDate;
|
||||||
|
|
||||||
|
public LbsLocateRequest(String cph) {
|
||||||
|
this.cph = cph;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LbsLocateRequest(String cph, String startDate, String endDate) {
|
||||||
|
this.cph = cph;
|
||||||
|
this.startDate = startDate;
|
||||||
|
this.endDate = endDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
+100
@@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* BladeX Commercial License Agreement
|
||||||
|
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
|
||||||
|
* <p>
|
||||||
|
* Use of this software is governed by the Commercial License Agreement
|
||||||
|
* obtained after purchasing a license from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 1. This software is for development use only under a valid license
|
||||||
|
* from BladeX.
|
||||||
|
* <p>
|
||||||
|
* 2. Redistribution of this software's source code to any third party
|
||||||
|
* without a commercial license is strictly prohibited.
|
||||||
|
* <p>
|
||||||
|
* 3. Licensees may copyright their own code but cannot use segments
|
||||||
|
* from this software for such purposes. Copyright of this software
|
||||||
|
* remains with BladeX.
|
||||||
|
* <p>
|
||||||
|
* Using this software signifies agreement to this License, and the software
|
||||||
|
* must not be used for illegal purposes.
|
||||||
|
* <p>
|
||||||
|
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
|
||||||
|
* not liable for any claims arising from secondary or illegal development.
|
||||||
|
* <p>
|
||||||
|
* Author: Chill Zhuang (bladejava@qq.com)
|
||||||
|
*/
|
||||||
|
package org.springblade.thirdparty.lbs.pojo.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springblade.thirdparty.lbs.constant.LbsConstant;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* LBS 定位/历史轨迹响应
|
||||||
|
*
|
||||||
|
* @author Chill
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class LbsLocateResponse implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 响应代码,200 为正确
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 兼容 code 字段(网关常返回 "1")
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示信息
|
||||||
|
*/
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 提示信息(兼容 message)
|
||||||
|
*/
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 定位/轨迹数据(数组,或 {list,total})
|
||||||
|
*/
|
||||||
|
private JsonNode data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否成功
|
||||||
|
*/
|
||||||
|
public boolean isSuccess() {
|
||||||
|
if (status != null && (status == LbsConstant.SUCCESS_STATUS || status == 1)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (code == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String normalized = code.trim();
|
||||||
|
return LbsConstant.SUCCESS_STATUS_TEXT.equals(normalized)
|
||||||
|
|| LbsConstant.SUCCESS_CODE.equals(normalized);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误信息
|
||||||
|
*/
|
||||||
|
public String errorMessage() {
|
||||||
|
if (msg != null && !msg.isBlank()) {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
if (message != null && !message.isBlank()) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
return "LBS接口调用失败";
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
org.springblade.thirdparty.lbs.config.ThirdPartyLbsAutoConfiguration
|
||||||
Vendored
+2
-2
@@ -26,7 +26,7 @@ public interface IOAClient {
|
|||||||
* @param param
|
* @param param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("${thirdParty.oa.queryCompanyPageUrl:/api/hrm/resful/getHrmsubcompanyWithPage}")
|
@PostMapping("${thirdParty.oa.queryCompanyPageUrl:/gwzh/OA/OA_GET_COMPANY_LIST}")
|
||||||
OAResponse<OACompanyResponse> queryCompanyPage(@RequestBody OASearch<OACompanySearch> param);
|
OAResponse<OACompanyResponse> queryCompanyPage(@RequestBody OASearch<OACompanySearch> param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -34,7 +34,7 @@ public interface IOAClient {
|
|||||||
* @param param
|
* @param param
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("${thirdParty.oa.queryDepartmentPage:/api/hrm/resful/getHrmdepartmentWithPage}")
|
@PostMapping("${thirdParty.oa.queryDepartmentPageUrl:/gwzh/OA/OA_GET_DEPARTMENT_LIST}")
|
||||||
OAResponse<OADepartmentResponse> queryDepartmentPage(@RequestBody OASearch<OADepartmentSearch> param);
|
OAResponse<OADepartmentResponse> queryDepartmentPage(@RequestBody OASearch<OADepartmentSearch> param);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
<name>${project.artifactId}</name>
|
<name>${project.artifactId}</name>
|
||||||
<modules>
|
<modules>
|
||||||
<module>blade-oa-api</module>
|
<module>blade-oa-api</module>
|
||||||
|
<module>blade-lbs-api</module>
|
||||||
<module>blade-mk-api</module>
|
<module>blade-mk-api</module>
|
||||||
<module>blade-wps-api</module>
|
<module>blade-wps-api</module>
|
||||||
<module>blade-ocr-api</module>
|
<module>blade-ocr-api</module>
|
||||||
|
|||||||
@@ -86,9 +86,16 @@ thirdParty:
|
|||||||
baseUrl: http://127.0.0.1:8080
|
baseUrl: http://127.0.0.1:8080
|
||||||
oa:
|
oa:
|
||||||
# OA开放接口地址
|
# OA开放接口地址
|
||||||
baseUrl: http://127.0.0.1:8080
|
baseUrl: http://172.16.204.83:38000
|
||||||
|
queryCompanyPageUrl: /gwzh/OA/OA_GET_COMPANY_LIST
|
||||||
|
queryDepartmentPageUrl: /gwzh/OA/OA_GET_DEPARTMENT_LIST
|
||||||
queryPersonPageUrl: /gwzh/OA/OA_GET_USER_LIST
|
queryPersonPageUrl: /gwzh/OA/OA_GET_USER_LIST
|
||||||
authorization: ${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=}}
|
authorization: ${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=}}
|
||||||
|
lbs:
|
||||||
|
# LBS 网关地址(车辆实时定位)
|
||||||
|
baseUrl: http://172.16.204.83:38000
|
||||||
|
locateUrl: /gwzh/LBS/LBS_LOCATE
|
||||||
|
authorization: ${LBS_AUTHORIZATION:${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=}}}
|
||||||
track:
|
track:
|
||||||
# 轨迹开放接口地址
|
# 轨迹开放接口地址
|
||||||
baseUrl: http://127.0.0.1:8080
|
baseUrl: http://127.0.0.1:8080
|
||||||
|
|||||||
@@ -58,9 +58,16 @@ thirdParty:
|
|||||||
baseUrl: http://127.0.0.1:8080
|
baseUrl: http://127.0.0.1:8080
|
||||||
oa:
|
oa:
|
||||||
# OA开放接口地址
|
# OA开放接口地址
|
||||||
baseUrl: http://127.0.0.1:8080
|
baseUrl: http://172.16.204.83:38000
|
||||||
|
queryCompanyPageUrl: /gwzh/OA/OA_GET_COMPANY_LIST
|
||||||
|
queryDepartmentPageUrl: /gwzh/OA/OA_GET_DEPARTMENT_LIST
|
||||||
queryPersonPageUrl: /gwzh/OA/OA_GET_USER_LIST
|
queryPersonPageUrl: /gwzh/OA/OA_GET_USER_LIST
|
||||||
authorization: ${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=}}
|
authorization: ${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=}}
|
||||||
|
lbs:
|
||||||
|
# LBS 网关地址(车辆实时定位)
|
||||||
|
baseUrl: http://172.16.204.83:38000
|
||||||
|
locateUrl: /gwzh/LBS/LBS_LOCATE
|
||||||
|
authorization: ${LBS_AUTHORIZATION:${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:Z3d6aF90bXMtOVJJU0RVN1U6YW0yYkcwWnBJZ0RQZmtrSjNaZkZjUDBSaGFuSEtxQng=}}}
|
||||||
track:
|
track:
|
||||||
# 轨迹开放接口地址
|
# 轨迹开放接口地址
|
||||||
baseUrl: http://127.0.0.1:8080
|
baseUrl: http://127.0.0.1:8080
|
||||||
|
|||||||
@@ -10,9 +10,16 @@ thirdParty:
|
|||||||
baseUrl: ${WPS_BASE_URL:http://127.0.0.1:8080}
|
baseUrl: ${WPS_BASE_URL:http://127.0.0.1:8080}
|
||||||
oa:
|
oa:
|
||||||
# OA开放接口地址
|
# OA开放接口地址
|
||||||
baseUrl: ${OA_BASE_URL:http://127.0.0.1:8080}
|
baseUrl: ${OA_BASE_URL:http://172.16.204.83:38000}
|
||||||
|
queryCompanyPageUrl: ${OA_QUERY_COMPANY_PAGE_URL:/gwzh/OA/OA_GET_COMPANY_LIST}
|
||||||
|
queryDepartmentPageUrl: ${OA_QUERY_DEPARTMENT_PAGE_URL:/gwzh/OA/OA_GET_DEPARTMENT_LIST}
|
||||||
queryPersonPageUrl: ${OA_QUERY_PERSON_PAGE_URL:/gwzh/OA/OA_GET_USER_LIST}
|
queryPersonPageUrl: ${OA_QUERY_PERSON_PAGE_URL:/gwzh/OA/OA_GET_USER_LIST}
|
||||||
authorization: ${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:}}
|
authorization: ${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:}}
|
||||||
|
lbs:
|
||||||
|
# LBS 网关地址(车辆实时定位)
|
||||||
|
baseUrl: ${LBS_BASE_URL:${OA_BASE_URL:http://172.16.204.83:38000}}
|
||||||
|
locateUrl: ${LBS_LOCATE_URL:/gwzh/LBS/LBS_LOCATE}
|
||||||
|
authorization: ${LBS_AUTHORIZATION:${OA_AUTHORIZATION:${IAM_SSO_AUTHORIZATION:}}}
|
||||||
track:
|
track:
|
||||||
# 轨迹开放接口地址
|
# 轨迹开放接口地址
|
||||||
baseUrl: ${TRACK_BASE_URL:http://127.0.0.1:8080}
|
baseUrl: ${TRACK_BASE_URL:http://127.0.0.1:8080}
|
||||||
|
|||||||
@@ -124,6 +124,11 @@
|
|||||||
<artifactId>blade-oa-api</artifactId>
|
<artifactId>blade-oa-api</artifactId>
|
||||||
<version>${revision}</version>
|
<version>${revision}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springblade</groupId>
|
||||||
|
<artifactId>blade-lbs-api</artifactId>
|
||||||
|
<version>${revision}</version>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springblade</groupId>
|
<groupId>org.springblade</groupId>
|
||||||
<artifactId>blade-open-api</artifactId>
|
<artifactId>blade-open-api</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user