From 8d842dd5b5ce762e9a8d67fe501dfd767383c43c Mon Sep 17 00:00:00 2001 From: zhaoqiaobo <583671871@qq.com> Date: Thu, 26 Dec 2024 15:34:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(all):=20=E7=B4=A2=E8=8F=B2=E4=BA=9A?= =?UTF-8?q?=E5=B7=A5=E5=8E=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1 增加华之韵物流对接 --- .../config/InterceptorAdapterConfig.java | 30 ++-- .../suofeiya/controller/OrderController.java | 33 +++- .../suofeiya/entity/DeliveryNoteEntity.java | 10 +- .../entity/FactoryOrderLogEntity.java | 5 + .../suofeiya/entity/OrderInfoEntity.java | 2 + .../suofeiya/entity/PackageInfoEntity.java | 4 + .../FactoryAccountsInterceptor.java | 1 - .../LocalServerLoginAccountsInterceptor.java | 145 ++++++++++++------ .../suofeiya/mapper/DeliveryNoteMapper.java | 3 + .../mapper/FactoryNodeOrderMapper.xml | 11 ++ .../suofeiya/mq/FactoryOrderListener.java | 5 +- .../pros/FactoryDataSuoFeiYaProperties.java | 8 +- .../suofeiya/service/DeliveryNoteService.java | 3 + .../service/impl/DeliveryNoteServiceImpl.java | 55 +++++-- .../suofeiya/vo/FactoryAuthVO.java | 26 ++++ .../suofeiya/vo/FactoryOrderDataVO.java | 27 ++++ 16 files changed, 288 insertions(+), 80 deletions(-) create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/vo/FactoryAuthVO.java create mode 100644 blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/vo/FactoryOrderDataVO.java diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/config/InterceptorAdapterConfig.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/config/InterceptorAdapterConfig.java index 1ce93e7dd..0e7464aa5 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/config/InterceptorAdapterConfig.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/config/InterceptorAdapterConfig.java @@ -1,32 +1,44 @@ package com.logpm.factorydata.suofeiya.config; -import com.logpm.factorydata.suofeiya.interceptor.FactoryAccountsInterceptor; import com.logpm.factorydata.suofeiya.interceptor.LocalServerLoginAccountsInterceptor; +import com.logpm.factorydata.suofeiya.pros.FactoryDataSuoFeiYaProperties; +import com.logpm.factorydata.suofeiya.service.DeliveryNoteService; import com.logpm.factorydata.suofeiya.service.IFactoryTokenService; -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.context.annotation.Lazy; import org.springframework.core.env.Environment; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import javax.annotation.Resource; + @Configuration -@AllArgsConstructor public class InterceptorAdapterConfig implements WebMvcConfigurer { - private final IFactoryTokenService factoryTokenService; - private final BladeRedis redis; - private final Environment environment; - private final RedisLockClient redisLockClient; - private final MockLoginService mockLoginService; + @Resource + private IFactoryTokenService factoryTokenService; + @Resource + private BladeRedis redis; + @Resource + private Environment environment; + @Resource + private RedisLockClient redisLockClient; + @Resource + private MockLoginService mockLoginService; + @Lazy + @Resource + private DeliveryNoteService deliveryNoteService; + @Resource + private FactoryDataSuoFeiYaProperties suoFeiYaProperties; @Override public void addInterceptors(InterceptorRegistry interceptorRegistry) { // interceptorRegistry.addInterceptor(new FactoryAccountsInterceptor(factoryTokenService)) // .addPathPatterns("/**").order(1); - interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis, environment,redisLockClient,mockLoginService)) + interceptorRegistry.addInterceptor(new LocalServerLoginAccountsInterceptor(redis, environment, redisLockClient, mockLoginService, suoFeiYaProperties, deliveryNoteService)) .addPathPatterns("/**").order(2); } } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/controller/OrderController.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/controller/OrderController.java index 57d4640f0..eaf0d67d2 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/controller/OrderController.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/controller/OrderController.java @@ -5,18 +5,20 @@ import cn.hutool.json.JSONUtil; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.logpm.factorydata.suofeiya.service.DeliveryNoteService; import com.logpm.factorydata.suofeiya.vo.DeliveryNoteVO; -import com.logpm.factorydata.suofeiya.vo.ParamVO; +import com.logpm.factorydata.suofeiya.vo.FactoryOrderDataVO; import com.logpm.factorydata.suofeiya.vo.Resp; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; -import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; + /** * 工厂订单 前端控制器 * @@ -26,16 +28,17 @@ import org.springframework.web.bind.annotation.RestController; @Slf4j @RestController @RequestMapping("/order") -@AllArgsConstructor @Api(value = "工厂订单", tags = "工厂订单") public class OrderController { - private final DeliveryNoteService service; + @Lazy + @Resource + private DeliveryNoteService service; @ResponseBody @PostMapping @ApiOperationSupport(order = 1) - @ApiOperation(value = "工厂订单", notes = "工厂订单") + @ApiOperation(value = "老系统-工厂订单", notes = "老系统-工厂订单") public Resp order(@RequestBody DeliveryNoteVO params) { String jsonStr = JSONUtil.toJsonStr(params); log.info("接收工厂订单:{} ", jsonStr); @@ -52,4 +55,24 @@ public class OrderController { return Resp.success(res); } + @ResponseBody + @PostMapping("/v1") + @ApiOperationSupport(order = 1) + @ApiOperation(value = "索菲亚-工厂订单", notes = "索菲亚-工厂订单") + public Resp orderV1(@RequestBody FactoryOrderDataVO vo) { + String jsonStr = JSONUtil.toJsonStr(vo); + log.info("接收工厂订单:{} ", jsonStr); + String res = ""; + try { + DeliveryNoteVO params = vo.getParams(); + if (ObjectUtil.isNotEmpty(params)) { + res = service.order(params); + } + } catch (Exception e) { + log.error("工厂订单异常:{} ", e); + return Resp.success("服务器异常"); + } + return Resp.success(res); + } + } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/DeliveryNoteEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/DeliveryNoteEntity.java index b03bc46f5..cd27decf7 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/DeliveryNoteEntity.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/DeliveryNoteEntity.java @@ -2,6 +2,7 @@ package com.logpm.factorydata.suofeiya.entity; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonProperty; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -20,6 +21,8 @@ import org.springblade.core.mp.base.BaseEntity; @EqualsAndHashCode(callSuper = true) public class DeliveryNoteEntity extends BaseEntity { + @ApiModelProperty(name = "租户", notes = "") + private String tenantCode; @ApiModelProperty(name = "日志id") private String logId; @ApiModelProperty(name = "渠道单号") @@ -39,7 +42,12 @@ public class DeliveryNoteEntity extends BaseEntity { private String gpsLeaveWhTime; @ApiModelProperty(name = "发货方地址") private String sendAddr; - @ApiModelProperty(name = "下单模式") + @ApiModelProperty(name = "中转物流商") + @JsonProperty("zCarrierName") + private String zCarrierName; + @ApiModelProperty(name = "供应商") + private String supplierName; + @ApiModelProperty(name = "订单类型(空为衣柜,”Z”为家品直发单)") private String orderType; @ApiModelProperty(name = "运输方式/产品类型") private String transportType; diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/FactoryOrderLogEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/FactoryOrderLogEntity.java index 8ed0335b7..329a8250f 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/FactoryOrderLogEntity.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/FactoryOrderLogEntity.java @@ -38,6 +38,11 @@ public class FactoryOrderLogEntity extends BaseEntity { */ @ApiModelProperty(name = "预留5", notes = "") private String reserve5; + /** + * 租户 + */ + @ApiModelProperty(name = "租户", notes = "") + private String tenantCode; /** * 日志文件存放地址 */ diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/OrderInfoEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/OrderInfoEntity.java index c6347b14f..430769915 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/OrderInfoEntity.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/OrderInfoEntity.java @@ -19,6 +19,8 @@ import org.springblade.core.mp.base.BaseEntity; @EqualsAndHashCode(callSuper = true) public class OrderInfoEntity extends BaseEntity { + @ApiModelProperty(name = "租户", notes = "") + private String tenantCode; @ApiModelProperty(name = "日志id") private String logId; @ApiModelProperty(name = "发货单id") diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/PackageInfoEntity.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/PackageInfoEntity.java index bea6a1f7f..befbb9e71 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/PackageInfoEntity.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/entity/PackageInfoEntity.java @@ -19,6 +19,8 @@ import org.springblade.core.mp.base.BaseEntity; @EqualsAndHashCode(callSuper = true) public class PackageInfoEntity extends BaseEntity { + @ApiModelProperty(name = "租户", notes = "") + private String tenantCode; @ApiModelProperty(name = "日志id") private String logId; @ApiModelProperty(name = "发货单id") @@ -37,6 +39,8 @@ public class PackageInfoEntity extends BaseEntity { private String orderNo; @ApiModelProperty(name = "重量") private String weight; + @ApiModelProperty(name = "数量") + private Double number; @ApiModelProperty(name = "体积") private String volume; @ApiModelProperty(name = "预留1", notes = "") diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/interceptor/FactoryAccountsInterceptor.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/interceptor/FactoryAccountsInterceptor.java index a34aa97e9..abf735a2f 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/interceptor/FactoryAccountsInterceptor.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/interceptor/FactoryAccountsInterceptor.java @@ -25,7 +25,6 @@ public class FactoryAccountsInterceptor implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { try { - RequestWrapper myRequestWrapper = new RequestWrapper(request); String body = myRequestWrapper.getBody(); JSONObject jsonObject = JSONObject.parseObject(body); diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/interceptor/LocalServerLoginAccountsInterceptor.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/interceptor/LocalServerLoginAccountsInterceptor.java index d9385aff8..b06d595bf 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/interceptor/LocalServerLoginAccountsInterceptor.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/interceptor/LocalServerLoginAccountsInterceptor.java @@ -1,84 +1,139 @@ package com.logpm.factorydata.suofeiya.interceptor; -import cn.hutool.http.HttpRequest; -import cn.hutool.http.HttpResponse; +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.crypto.digest.MD5; import com.alibaba.fastjson.JSONObject; -import lombok.AllArgsConstructor; +import com.logpm.factorydata.suofeiya.pros.FactoryDataSuoFeiYaProperties; +import com.logpm.factorydata.suofeiya.service.DeliveryNoteService; +import com.logpm.factorydata.suofeiya.vo.FactoryAuthVO; +import com.logpm.factorydata.suofeiya.wrapper.RequestWrapper; import lombok.extern.log4j.Log4j2; import org.springblade.common.cache.CacheNames; import org.springblade.common.component.MockLoginService; -import org.springblade.common.constant.LauncherConstant; 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.context.annotation.Lazy; import org.springframework.core.env.Environment; 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.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; -import java.util.HashMap; -import java.util.Map; +import java.time.Instant; import java.util.Objects; import java.util.concurrent.TimeUnit; @Log4j2 -@AllArgsConstructor public class LocalServerLoginAccountsInterceptor extends HandlerInterceptorAdapter { - private final BladeRedis bladeRedis; - private final Environment environment; - private final RedisLockClient redisLockClient; - private final MockLoginService mockLoginService; - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { + @Resource + private BladeRedis bladeRedis; + @Resource + private Environment environment; + @Resource + private RedisLockClient redisLockClient; + @Resource + private MockLoginService mockLoginService; + @Resource + private FactoryDataSuoFeiYaProperties suoFeiYaProperties; + @Lazy + @Resource + private DeliveryNoteService deliveryNoteService; + public LocalServerLoginAccountsInterceptor(BladeRedis redis, Environment environment, RedisLockClient redisLockClient, MockLoginService mockLoginService, FactoryDataSuoFeiYaProperties suoFeiYaProperties, DeliveryNoteService deliveryNoteService) { + this.bladeRedis = redis; + this.environment = environment; + this.redisLockClient = redisLockClient; + this.mockLoginService = mockLoginService; + this.suoFeiYaProperties = suoFeiYaProperties; + this.deliveryNoteService = deliveryNoteService; + } + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws CustomerException { try { - org.springblade.common.wrapper.CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request); - String account ="shujutongbu"; - String tenantId ="627683"; - 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); - } + RequestWrapper myRequestWrapper = new RequestWrapper(request); + String body = myRequestWrapper.getBody(); + JSONObject jsonObject = JSONObject.parseObject(body); + // 获取头中参数 + String authTime = request.getHeader("authTime"); + if (StrUtil.isEmpty(authTime)) { + returnJson(response, JSONObject.toJSONString(R.fail(1, "时间戳不能为空"))); + return false; + } + String sign = request.getHeader("sign"); + String companyCodeH = request.getHeader("companyCode"); + log.info("##########preHandle: authTime={},sign={},companyCodeH={}", authTime, sign, companyCodeH); + String companyCode = jsonObject.getString("companyCode"); + long secondTimestamp = Instant.now().getEpochSecond(); + // 验证时间 不能大于5秒 + if (StringUtil.isNotBlank(authTime)) { + long authTimeLong = Long.parseLong(authTime); + if (secondTimestamp - authTimeLong > 5) { + returnJson(response, JSONObject.toJSONString(R.fail(1, "认证不通过,时间戳过期"))); + return false; } } + // 验证签名 + String auth = suoFeiYaProperties.getAuth(); + String md5Hex = new String(MD5.create().digest(authTime + auth)).toUpperCase(); + if (!StrUtil.equals(md5Hex, sign)) { + returnJson(response, JSONObject.toJSONString(R.fail(1, "认证不通过,签名不正确"))); + return false; + } + String account = "shujutongbu"; + String tenantId = "627683"; + String authorizationHeader = "bG9jYWw6bG9jYWxfc2VjcmV0"; + if (StringUtil.isNotBlank(companyCode)) { + FactoryAuthVO authVO = deliveryNoteService.findFactoryAuth(companyCode); + if (ObjectUtil.isNotEmpty(authVO)) { + account = authVO.getLoginAccount(); + tenantId = authVO.getTenantCode(); + authorizationHeader = authVO.getAuthorizationHeader(); + org.springblade.common.wrapper.CustomHttpServletRequestWrapper wrappedRequest = new CustomHttpServletRequestWrapper(request); + 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); + } + } + } + // 发送登录请求 + 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 " + authorizationHeader); + ThreadLocalUtil.put("bladeContext", httpHeaders); + // 用包装后的request替换原始request + request = wrappedRequest; + RequestContextHolder.setRequestAttributes(new ServletRequestAttributes(request)); + return true; - // 修改或添加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; + } + } + return false; } catch (Exception e) { - returnJson(response, JSONObject.toJSONString(R.fail(500, "服务异常,请联系管理员"))); + returnJson(response, JSONObject.toJSONString(R.fail(5, "服务异常,请联系管理员"))); return false; } } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/DeliveryNoteMapper.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/DeliveryNoteMapper.java index f735d3539..71869ddbb 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/DeliveryNoteMapper.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/DeliveryNoteMapper.java @@ -2,7 +2,9 @@ package com.logpm.factorydata.suofeiya.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.logpm.factorydata.suofeiya.entity.DeliveryNoteEntity; +import com.logpm.factorydata.suofeiya.vo.FactoryAuthVO; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 发货单 mapper @@ -13,4 +15,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface DeliveryNoteMapper extends BaseMapper { + FactoryAuthVO findFactoryAuth(@Param("companyCode") String companyCode); } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/FactoryNodeOrderMapper.xml b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/FactoryNodeOrderMapper.xml index 34ad59325..90c7fd14d 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/FactoryNodeOrderMapper.xml +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mapper/FactoryNodeOrderMapper.xml @@ -2,4 +2,15 @@ + diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mq/FactoryOrderListener.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mq/FactoryOrderListener.java index 1087c6960..4805c5a9e 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mq/FactoryOrderListener.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/mq/FactoryOrderListener.java @@ -24,13 +24,13 @@ import com.logpm.factorydata.suofeiya.vo.PackageInfoVO; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springblade.common.constant.factorydata.FactoryDataConstants; +import org.springblade.core.secure.utils.AuthUtil; import org.springframework.amqp.core.ExchangeTypes; import org.springframework.amqp.rabbit.annotation.Exchange; import org.springframework.amqp.rabbit.annotation.Queue; import org.springframework.amqp.rabbit.annotation.QueueBinding; import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; import java.util.ArrayList; import java.util.List; @@ -97,6 +97,7 @@ public class FactoryOrderListener { vo.setOrderExtendField(JSONUtil.toJsonStr(vo.getOrderExtendFields())); } vo.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); + vo.setTenantCode(AuthUtil.getTenantId()); deliveryNoteService.save(vo); List orderInfos = vo.getOrderInfo(); if (CollUtil.isNotEmpty(orderInfos)) { @@ -106,6 +107,7 @@ public class FactoryOrderListener { BeanUtil.copyProperties(orderInfo, orderInfoEntity); orderInfoEntity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); orderInfoEntity.setDeliveryNoteId(vo.getId().toString()); + orderInfoEntity.setTenantCode(AuthUtil.getTenantId()); infoEntities.add(orderInfoEntity); } orderInfoService.saveBatch(infoEntities); @@ -117,6 +119,7 @@ public class FactoryOrderListener { BeanUtil.copyProperties(packageInfo, entity); entity.setDeliveryNoteId(vo.getId().toString()); entity.setLogId(ObjectUtil.isNotEmpty(logId) ? logId.toString() : null); + entity.setTenantCode(AuthUtil.getTenantId()); packageInfoEntities.add(entity); } packageInfoService.saveBatch(packageInfoEntities); diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/pros/FactoryDataSuoFeiYaProperties.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/pros/FactoryDataSuoFeiYaProperties.java index 02e3773ae..dc1ccc648 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/pros/FactoryDataSuoFeiYaProperties.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/pros/FactoryDataSuoFeiYaProperties.java @@ -9,12 +9,12 @@ import org.springframework.boot.context.properties.ConfigurationProperties; * @author pref */ @Data -@ConfigurationProperties(prefix = "logpm") +@ConfigurationProperties(prefix = "suofeiya") public class FactoryDataSuoFeiYaProperties { + /** - * 名称 + * 颁布给工厂的认证码 */ - private String name; - + private String auth; } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/DeliveryNoteService.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/DeliveryNoteService.java index eb5d66f8b..2a5d1fd1c 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/DeliveryNoteService.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/DeliveryNoteService.java @@ -2,6 +2,7 @@ package com.logpm.factorydata.suofeiya.service; import com.logpm.factorydata.suofeiya.entity.DeliveryNoteEntity; import com.logpm.factorydata.suofeiya.vo.DeliveryNoteVO; +import com.logpm.factorydata.suofeiya.vo.FactoryAuthVO; import org.springblade.core.mp.base.BaseService; /** @@ -15,4 +16,6 @@ public interface DeliveryNoteService extends BaseService { String order(DeliveryNoteVO vo); void buildAdvance(DeliveryNoteVO vo); + + FactoryAuthVO findFactoryAuth(String companyCode); } diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/DeliveryNoteServiceImpl.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/DeliveryNoteServiceImpl.java index 47dac7dec..9489260c3 100644 --- a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/DeliveryNoteServiceImpl.java +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/service/impl/DeliveryNoteServiceImpl.java @@ -17,12 +17,12 @@ import com.logpm.factorydata.suofeiya.mapper.DeliveryNoteMapper; import com.logpm.factorydata.suofeiya.service.DeliveryNoteService; import com.logpm.factorydata.suofeiya.service.FactoryOrderLogService; import com.logpm.factorydata.suofeiya.vo.DeliveryNoteVO; +import com.logpm.factorydata.suofeiya.vo.FactoryAuthVO; import com.logpm.factorydata.suofeiya.vo.OrderInfoVO; import com.logpm.factorydata.suofeiya.vo.PackageInfoVO; import com.logpm.factorydata.vo.SendMsg; import com.logpm.trunkline.entity.TrunklineAdvanceDetailEntity; import com.logpm.trunkline.entity.TrunklineAdvanceEntity; -import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.fileupload.FileItem; import org.apache.commons.fileupload.disk.DiskFileItemFactory; @@ -34,6 +34,8 @@ import org.springblade.common.constant.factorydata.FactoryDataConstants; import org.springblade.common.utils.FileLogsUtil; import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.oss.model.BladeFile; +import org.springblade.core.redis.cache.BladeRedis; +import org.springblade.core.secure.utils.AuthUtil; import org.springblade.core.tool.api.R; import org.springblade.resource.feign.IOssClient; import org.springframework.http.MediaType; @@ -41,11 +43,13 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.commons.CommonsMultipartFile; +import javax.annotation.Resource; import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.math.BigDecimal; import java.nio.file.Files; +import java.time.Duration; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -59,13 +63,18 @@ import java.util.Map; **/ @Slf4j @Service -@AllArgsConstructor public class DeliveryNoteServiceImpl extends BaseServiceImpl implements DeliveryNoteService { - private final IFactoryDataClient factoryDataClient; - private final FactoryOrderLogService factoryOrderLogService; - private final IOssClient ossClient; - private final IFactoryDataBaseClient baseClient; + @Resource + private IFactoryDataClient factoryDataClient; + @Resource + private FactoryOrderLogService factoryOrderLogService; + @Resource + private IOssClient ossClient; + @Resource + private IFactoryDataBaseClient baseClient; + @Resource + private BladeRedis bladeRedis; @Override public String order(DeliveryNoteVO vo) { @@ -77,6 +86,7 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl>> 文件路径 {}", logPath); MultipartFile multi = getMultipartFile(logPath); - //上传到服务器 + // 上传到服务器 R r = ossClient.fileUpload(multi, "sfy-order-logs"); if (r.isSuccess()) { BladeFile data = (BladeFile) r.getData(); diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/vo/FactoryAuthVO.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/vo/FactoryAuthVO.java new file mode 100644 index 000000000..125d9887b --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/vo/FactoryAuthVO.java @@ -0,0 +1,26 @@ +package com.logpm.factorydata.suofeiya.vo; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 物流商认证 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +public class FactoryAuthVO { + + @ApiModelProperty(name = "物流编码") + private String logisticsCode; + @ApiModelProperty(name = "秘钥") + private String appKey; + @ApiModelProperty(name = "租户") + private String tenantCode; + @ApiModelProperty(name = "登录账号") + private String loginAccount; + @ApiModelProperty(name = "Authorization头") + private String authorizationHeader; + +} diff --git a/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/vo/FactoryOrderDataVO.java b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/vo/FactoryOrderDataVO.java new file mode 100644 index 000000000..784eb71bf --- /dev/null +++ b/blade-service/logpm-factory-data/logpm-factory-data-suofeiya/src/main/java/com/logpm/factorydata/suofeiya/vo/FactoryOrderDataVO.java @@ -0,0 +1,27 @@ +package com.logpm.factorydata.suofeiya.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * 送货单 实体类 + * + * @author zhaoqiaobo + * @create 2024-04-26 + */ +@Data +@ApiModel(value = "索菲亚发货单", description = "索菲亚发货单") +public class FactoryOrderDataVO { + + @ApiModelProperty("加密后的密文") + private String digest; + @ApiModelProperty("时间戳 毫秒") + private Long timestamp; + @ApiModelProperty("公司编码") + private String companyCode; + + @ApiModelProperty("订单信息") + private DeliveryNoteVO params; + +}