pref_mail@163.com
1 month ago
23 changed files with 531 additions and 19 deletions
@ -0,0 +1,18 @@
|
||||
<?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-service-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
</parent> |
||||
|
||||
<groupId>org.springblade</groupId> |
||||
<artifactId>logpm-data-sharing-api</artifactId> |
||||
<version>3.2.0.RELEASE</version> |
||||
|
||||
|
||||
</project> |
@ -0,0 +1,26 @@
|
||||
package com.logpm.datasharing.vo; |
||||
|
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @see com.logpm.datasharing.vo.WarehouseNumberVO |
||||
* 仓库数据 |
||||
* <li>始发仓</li> |
||||
* <li>中转仓</li> |
||||
* <li>目的仓</li> |
||||
*/ |
||||
@Data |
||||
public class WarehouseNumberVO { |
||||
|
||||
/** |
||||
* 仓库名称 |
||||
*/ |
||||
private String warehouseName; |
||||
|
||||
/** |
||||
* 数量 |
||||
*/ |
||||
private Integer number; |
||||
|
||||
|
||||
} |
@ -0,0 +1,137 @@
|
||||
package com.logpm.datasharing.vo; |
||||
|
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
|
||||
import java.io.Serializable; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 开放模块 |
||||
* 运单返回诗句 |
||||
*/ |
||||
@Data |
||||
public class WaybillInfoVO implements Serializable { |
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
|
||||
/** |
||||
* 运单状态 10部分入库 |
||||
* |
||||
* 20入库 |
||||
* |
||||
* 30部分中转 |
||||
* |
||||
* 40 中转 |
||||
* |
||||
* 50 目的仓部分到达 |
||||
* |
||||
* 60 目的仓到达 |
||||
* |
||||
* 70 配送部分装车 |
||||
* |
||||
* 80 配送装车 |
||||
* |
||||
* 90 部分签收 |
||||
* |
||||
* 100 已签收 |
||||
*/ |
||||
@ApiModelProperty(value = "运单状态") |
||||
private String statusName; |
||||
|
||||
|
||||
/** |
||||
* 运单号 |
||||
*/ |
||||
@ApiModelProperty(value = "运单号") |
||||
private String waybillNo; |
||||
|
||||
/** |
||||
* 目的仓 |
||||
*/ |
||||
@ApiModelProperty(value = "目的仓") |
||||
private String destinationWarehouseName; |
||||
|
||||
|
||||
|
||||
/** |
||||
* 发站仓 |
||||
*/ |
||||
@ApiModelProperty(value = "发站仓") |
||||
private String departureWarehouseName; |
||||
|
||||
|
||||
/** |
||||
* 发货单位 |
||||
*/ |
||||
@ApiModelProperty(value = "发货单位") |
||||
private String shipper; |
||||
|
||||
/** |
||||
* 发货人 |
||||
*/ |
||||
@ApiModelProperty(value = "发货人") |
||||
private String shipperName; |
||||
|
||||
/** |
||||
* 总数 |
||||
*/ |
||||
@ApiModelProperty(value = "总数") |
||||
private Integer totalCount; |
||||
|
||||
|
||||
/** |
||||
* 在途数量 |
||||
*/ |
||||
@ApiModelProperty(value = "总数") |
||||
private Integer onWayCount; |
||||
|
||||
|
||||
/** |
||||
* 收货单位 |
||||
*/ |
||||
@ApiModelProperty(value = "收货单位") |
||||
private String consignee; |
||||
|
||||
/** |
||||
* 收货人 |
||||
*/ |
||||
@ApiModelProperty(value = "收货人") |
||||
private String consigneeName; |
||||
|
||||
|
||||
/** |
||||
* 始发仓数量信息 |
||||
*/ |
||||
@ApiModelProperty(value = "始发仓数量信息") |
||||
private WarehouseNumberVO startWarehouseNumber; |
||||
|
||||
|
||||
/** |
||||
* 中转仓数量信息 |
||||
*/ |
||||
@ApiModelProperty(value = "中转仓数量信息") |
||||
private List<WarehouseNumberVO> middleWarehouseNumber; |
||||
|
||||
/** |
||||
* 目的仓数量信息 |
||||
*/ |
||||
@ApiModelProperty(value = "目的仓数量信息") |
||||
private WarehouseNumberVO endWarehouseNumber; |
||||
|
||||
/** |
||||
* 配送数量 |
||||
*/ |
||||
@ApiModelProperty(value = "配送数量") |
||||
private Integer deliveryNum ; |
||||
|
||||
/** |
||||
* 签收数量 |
||||
*/ |
||||
@ApiModelProperty(value = "签收数量") |
||||
private Integer signNum; |
||||
|
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,33 @@
|
||||
package com.logpm.datasharing.config; |
||||
|
||||
|
||||
import com.logpm.datasharing.interceptor.LocalServerLoginAccountsInterceptor; |
||||
import lombok.AllArgsConstructor; |
||||
import org.springblade.common.component.MockLoginService; |
||||
import org.springblade.core.redis.cache.BladeRedis; |
||||
import org.springblade.core.redis.lock.RedisLockClient; |
||||
import org.springframework.context.annotation.Configuration; |
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry; |
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
||||
|
||||
/** |
||||
* 为所有的的 |
||||
*/ |
||||
@Configuration |
||||
@AllArgsConstructor |
||||
public class InterceptorAdapterConfig implements WebMvcConfigurer { |
||||
|
||||
|
||||
private final BladeRedis redis; |
||||
|
||||
private final RedisLockClient redisLockClient; |
||||
private final MockLoginService mockLoginService; |
||||
|
||||
|
||||
@Override |
||||
public void addInterceptors(InterceptorRegistry interceptorRegistry) { |
||||
|
||||
interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis,redisLockClient,mockLoginService)).addPathPatterns("/search/**").order(1); |
||||
|
||||
} |
||||
} |
@ -0,0 +1,100 @@
|
||||
package com.logpm.datasharing.interceptor; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import lombok.AllArgsConstructor; |
||||
import lombok.extern.log4j.Log4j2; |
||||
import org.springblade.common.cache.CacheNames; |
||||
import org.springblade.common.component.MockLoginService; |
||||
import org.springblade.common.exception.CustomerException; |
||||
import org.springblade.common.wrapper.CustomHttpServletRequestWrapper; |
||||
import org.springblade.core.redis.cache.BladeRedis; |
||||
import org.springblade.core.redis.lock.LockType; |
||||
import org.springblade.core.redis.lock.RedisLockClient; |
||||
import org.springblade.core.tool.api.R; |
||||
import org.springblade.core.tool.utils.StringUtil; |
||||
import org.springblade.core.tool.utils.ThreadLocalUtil; |
||||
import org.springframework.http.HttpHeaders; |
||||
import org.springframework.web.context.request.RequestContextHolder; |
||||
import org.springframework.web.context.request.ServletRequestAttributes; |
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; |
||||
|
||||
import javax.servlet.http.HttpServletRequest; |
||||
import javax.servlet.http.HttpServletResponse; |
||||
import java.io.IOException; |
||||
import java.io.PrintWriter; |
||||
import java.util.Objects; |
||||
import java.util.concurrent.TimeUnit; |
||||
|
||||
@Log4j2 |
||||
@AllArgsConstructor |
||||
public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapter { |
||||
|
||||
private final BladeRedis bladeRedis; |
||||
private final RedisLockClient redisLockClient; |
||||
private final MockLoginService mockLoginService; |
||||
|
||||
@Override |
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { |
||||
|
||||
|
||||
try { |
||||
CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request); |
||||
String account ="shujutongbu"; |
||||
String tenantId = request.getHeader("tenantId"); |
||||
tenantId = StringUtil.isBlank(tenantId)?"627683":tenantId; |
||||
String key =CacheNames.LOCAL_SERVER_USER+tenantId+":"+account; |
||||
String lockKey =key+":lock"; |
||||
JSONObject data =bladeRedis.get(key); |
||||
if(Objects.isNull(data)){ |
||||
boolean flag = redisLockClient.tryLock(lockKey, LockType.FAIR, 5000, 10000, TimeUnit.MILLISECONDS); |
||||
if(flag){ |
||||
data =bladeRedis.get(key); |
||||
if(Objects.isNull(data)){ |
||||
data = mockLoginService.mockToken(tenantId,account); |
||||
bladeRedis.setEx(key,data,2591990L); |
||||
redisLockClient.unLock(lockKey, LockType.FAIR); |
||||
} |
||||
} |
||||
} |
||||
|
||||
// 修改或添加header
|
||||
|
||||
// 发送登录请求
|
||||
log.info("##########preHandle: request={}", request); |
||||
|
||||
wrappedRequest.addHeader("Blade-Auth", "bearer "+data.getString("access_token")); |
||||
HttpHeaders httpHeaders = new HttpHeaders(); |
||||
httpHeaders.add("Blade-Auth","bearer "+data.get("access_token") ); |
||||
httpHeaders.add( "Authorization", "Basic bG9jYWw6bG9jYWxfc2VjcmV0"); |
||||
ThreadLocalUtil.put("bladeContext", httpHeaders); |
||||
|
||||
|
||||
// 用包装后的request替换原始request
|
||||
request = wrappedRequest; |
||||
RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); |
||||
return true; |
||||
} catch (Exception e) { |
||||
returnJson(response, JSONObject.toJSONString(R.fail(500, "服务异常,请联系管理员"))); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
private void returnJson(HttpServletResponse response, String json) { |
||||
PrintWriter writer = null; |
||||
response.setCharacterEncoding("UTF-8"); |
||||
response.setContentType("application/json"); |
||||
try { |
||||
writer = response.getWriter(); |
||||
writer.print(json); |
||||
|
||||
} catch (IOException e) { |
||||
System.out.println(e.getMessage()); |
||||
} finally { |
||||
if (writer != null) { |
||||
writer.close(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue