Commit ccbffefe9ee1ef22545ca5422257d7750109259c

Authored by 肖超群
2 parents 09e076dd 4518a02d

Merge branch 'develop4' of http://www.huahengrobot.com:90/wms/wms4 into develop4

ant-design-vue-jeecg/src/views/user/LoginAccount.vue
... ... @@ -18,7 +18,6 @@
18 18 show-search
19 19 placeholder="请选择仓库!"
20 20 option-filter-prop="label"
21   - :filter-option="filterOption"
22 21 v-model="model.warehouseCode">
23 22 <a-select-option v-for="item in warehouseList" :key="item.name" :value="item.code">{{
24 23 item.name
... ... @@ -62,7 +61,7 @@ export default {
62 61 required: true, message: '请输入密码!', validator: 'click'
63 62 }],
64 63 warehouseCode: [{
65   - required: true, message: '请选择仓库!', validator: 'click'
  64 + required: true, message: '请选择仓库!', trigger: "change" ,validator: 'click'
66 65 }],
67 66 }
68 67 }
... ... @@ -98,7 +97,9 @@ export default {
98 97 let obj = getWarehouseByUserCode(that.querySource);
99 98 obj.then((res) => {
100 99 that.warehouseList = res.result;
101   - this.model.warehouseCode = this.warehouseList[0].code;
  100 + if (this.warehouseList != null) {
  101 + this.model.warehouseCode = this.warehouseList[0].code;
  102 + }
102 103 })
103 104 },
104 105  
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/acs/controller/AcsController.java
... ... @@ -9,6 +9,8 @@ import org.jeecg.common.api.vo.Result;
9 9 import org.jeecg.modules.wms.api.acs.entity.AcsStatus;
10 10 import org.jeecg.modules.wms.api.acs.service.IAcsService;
11 11 import org.jeecg.modules.wms.config.address.service.IAddressService;
  12 +import org.jeecg.modules.wms.framework.aspectj.dto.ApiAuthentication;
  13 +import org.jeecg.modules.wms.framework.aspectj.dto.ApiAuthentication.ApiAuthenticationBuild;
12 14 import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger;
13 15 import org.jeecg.modules.wms.framework.controller.HuahengBaseController;
14 16 import org.jeecg.modules.wms.task.agvTask.service.IAgvTaskService;
... ... @@ -18,6 +20,7 @@ import org.jeecg.utils.constant.QuantityConstant;
18 20 import org.springframework.transaction.annotation.Transactional;
19 21 import org.springframework.web.bind.annotation.PostMapping;
20 22 import org.springframework.web.bind.annotation.RequestBody;
  23 +import org.springframework.web.bind.annotation.RequestHeader;
21 24 import org.springframework.web.bind.annotation.RequestMapping;
22 25 import org.springframework.web.bind.annotation.ResponseBody;
23 26 import org.springframework.web.bind.annotation.RestController;
... ... @@ -44,6 +47,7 @@ public class AcsController extends HuahengBaseController {
44 47 @ResponseBody
45 48 @PostMapping(value = "/testTokenCheck")
46 49 public Result<?> testTokenCheck(@RequestBody Map<String, String> paramMap, HttpServletRequest request) {
  50 + String audience = ApiAuthentication.getInstance().getAudience();
47 51 String url = "http://127.0.0.1:8080/wms/api/wms/acs/testTokenCheck";
48 52 String body = OkHttpUtils.sendPostByJsonStr(url, JSON.toJSONString(paramMap));
49 53 // String url = addressService.getUrlByParam(QuantityConstant.ADDRESS_AGV_TASK_ASSIGN);
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/ApiAuthenticationAspect.java
... ... @@ -11,6 +11,7 @@ import org.aspectj.lang.annotation.Before;
11 11 import org.aspectj.lang.annotation.Pointcut;
12 12 import org.aspectj.lang.reflect.MethodSignature;
13 13 import org.bouncycastle.crypto.RuntimeCryptoException;
  14 +import org.jeecg.modules.wms.framework.aspectj.dto.ApiAuthentication;
14 15 import org.jeecg.modules.wms.framework.aspectj.dto.RSA256Key;
15 16 import org.jeecg.utils.HuahengJwtUtil;
16 17 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -78,7 +79,9 @@ public class ApiAuthenticationAspect {
78 79 try {
79 80 Algorithm algorithm = Algorithm.RSA256(rsa256Key.getPublicKey(), rsa256Key.getPrivateKey());
80 81 JWTVerifier verifier = JWT.require(algorithm).withIssuer(HuahengJwtUtil.HUAHENG_SYSTEM_ID).build();
81   - verifier.verify(token);
  82 + DecodedJWT jwt = verifier.verify(token);
  83 + new ApiAuthentication.ApiAuthenticationBuild().operator(jwt.getClaim("operator").asString()).audience(jwt.getAudience().get(0)).issuer(jwt.getIssuer())
  84 + .issuedAt(jwt.getIssuedAt()).expireDateTime(jwt.getExpiresAt()).bulid();;
82 85 } catch (JWTVerificationException e) {
83 86 log.error(e.getMessage());
84 87 throw e;
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/aspectj/dto/ApiAuthentication.java
... ... @@ -9,13 +9,15 @@ import cn.hutool.core.date.DateUtil;
9 9 import lombok.Data;
10 10  
11 11 /**
12   - * 接口认证Token生成对象
  12 + * 接口认证Token对象
13 13 * @author TanYibin
14 14 * @createDate 2023年2月14日
15 15 */
16 16 @Data
17 17 public class ApiAuthentication {
18 18  
  19 + private static final ThreadLocal<ApiAuthentication> REQUEST_HEADER_CONTEXT_THREAD_LOCAL = new ThreadLocal<>();
  20 +
19 21 /** Token提供方 */
20 22 private String operator;
21 23  
... ... @@ -25,7 +27,80 @@ public class ApiAuthentication {
25 27 /** Token签发方(WMS) */
26 28 private String issuer = HuahengJwtUtil.HUAHENG_SYSTEM_ID;
27 29  
  30 + /** 签发时间 */
  31 + private Date issuedAt;
  32 +
28 33 /** 失效时间 */
29 34 private Date expireDateTime;
30 35  
  36 + public ApiAuthentication() {}
  37 +
  38 + public static ApiAuthentication getInstance() {
  39 + return REQUEST_HEADER_CONTEXT_THREAD_LOCAL.get();
  40 + }
  41 +
  42 + public void setContext(ApiAuthentication context) {
  43 + REQUEST_HEADER_CONTEXT_THREAD_LOCAL.set(context);
  44 + }
  45 +
  46 + public static void clean() {
  47 + REQUEST_HEADER_CONTEXT_THREAD_LOCAL.remove();
  48 + }
  49 +
  50 + private ApiAuthentication(ApiAuthenticationBuild apiAuthenticationBuild) {
  51 + this.operator = apiAuthenticationBuild.operator;
  52 + this.audience = apiAuthenticationBuild.audience;
  53 + this.issuer = apiAuthenticationBuild.issuer;
  54 + this.issuedAt = apiAuthenticationBuild.issuedAt;
  55 + this.expireDateTime = apiAuthenticationBuild.expireDateTime;
  56 + setContext(this);
  57 + }
  58 +
  59 + public static class ApiAuthenticationBuild {
  60 +
  61 + /** Token提供方 */
  62 + private String operator;
  63 +
  64 + /** Token使用方 */
  65 + private String audience; // 观众,相当于接受者
  66 +
  67 + /** Token签发方(WMS) */
  68 + private String issuer = HuahengJwtUtil.HUAHENG_SYSTEM_ID;
  69 +
  70 + /** 签发时间 */
  71 + private Date issuedAt;
  72 +
  73 + /** 失效时间 */
  74 + private Date expireDateTime;
  75 +
  76 + public ApiAuthenticationBuild operator(String operator) {
  77 + this.operator = operator;
  78 + return this;
  79 + }
  80 +
  81 + public ApiAuthenticationBuild audience(String audience) {
  82 + this.audience = audience;
  83 + return this;
  84 + }
  85 +
  86 + public ApiAuthenticationBuild issuer(String issuer) {
  87 + this.issuer = issuer;
  88 + return this;
  89 + }
  90 +
  91 + public ApiAuthenticationBuild issuedAt(Date issuedAt) {
  92 + this.issuedAt = issuedAt;
  93 + return this;
  94 + }
  95 +
  96 + public ApiAuthenticationBuild expireDateTime(Date expireDateTime) {
  97 + this.expireDateTime = expireDateTime;
  98 + return this;
  99 + }
  100 +
  101 + public ApiAuthentication bulid() {
  102 + return new ApiAuthentication(this);
  103 + }
  104 + }
  105 +
31 106 }
... ...