1、修改同步组织

2、新增北斗定位
This commit is contained in:
2026-09-18 21:12:01 +08:00
parent 3b26591f9d
commit a2e23ea264
24 changed files with 1031 additions and 9 deletions
@@ -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>
@@ -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);
}
}
@@ -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 网关 AuthorizationBasic),与 OA 人员接口一致
*/
private String authorization;
}
@@ -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 {
}
@@ -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";
}
@@ -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);
}
@@ -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.authorizationgwzh 网关可能拒绝请求");
}
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;
}
}
@@ -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;
}
}
@@ -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接口调用失败";
}
}
@@ -0,0 +1 @@
org.springblade.thirdparty.lbs.config.ThirdPartyLbsAutoConfiguration