Commit b121da7ae8398ca2ab9117b00915189cbae0c334

Authored by 周峰
2 parents ad79c7aa 8c0cc7fb

Merge branch 'develop4' of http://172.16.29.40:8010/wms/wms4 into develop4

huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java
1 1 package org.jeecg;
2 2  
3   -import java.net.Inet4Address;
4   -import java.net.Inet6Address;
5   -import java.net.InetAddress;
6   -import java.net.NetworkInterface;
7   -import java.net.SocketException;
8   -import java.net.UnknownHostException;
  3 +import java.net.*;
9 4 import java.util.Enumeration;
10 5  
11 6 import javax.transaction.SystemException;
12 7  
13 8 import org.jeecg.common.util.oConvertUtils;
14 9 import org.springframework.boot.SpringApplication;
15   -//import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
16 10 import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
17 11 import org.springframework.boot.autoconfigure.SpringBootApplication;
18 12 import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
... ... @@ -20,10 +14,12 @@ import org.springframework.boot.builder.SpringApplicationBuilder;
20 14 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
21 15 import org.springframework.cache.annotation.EnableCaching;
22 16 import org.springframework.context.ConfigurableApplicationContext;
  17 +import org.springframework.context.annotation.ComponentScan;
  18 +import org.springframework.context.annotation.ComponentScan.Filter;
  19 +import org.springframework.context.annotation.FilterType;
23 20 import org.springframework.core.env.Environment;
24 21  
25 22 import lombok.extern.slf4j.Slf4j;
26   -import net.bytebuddy.asm.Advice.This;
27 23  
28 24 /**
29 25 * 单体启动类(采用此类启动为单体模式)
... ... @@ -32,6 +28,7 @@ import net.bytebuddy.asm.Advice.This;
32 28 @EnableCaching
33 29 @SpringBootApplication
34 30 @EnableAutoConfiguration(exclude = {MongoAutoConfiguration.class})
  31 +@ComponentScan(excludeFilters = {@Filter(type = FilterType.REGEX, pattern = {"org.jeecg.config.mybatis.MybatisInterceptor"})})
35 32 public class JeecgSystemApplication extends SpringBootServletInitializer {
36 33  
37 34 @Override
... ... @@ -46,17 +43,13 @@ public class JeecgSystemApplication extends SpringBootServletInitializer {
46 43 String port = env.getProperty("server.port");
47 44 String profiles = env.getProperty("spring.profiles.active");
48 45 String path = oConvertUtils.getString(env.getProperty("server.servlet.context-path"));
49   - log.info("\n----------------------------------------------------------\n\t"
50   - + "Application HUAHENG WMS4 is running! Access urls:\n\n\t"
51   - + "WEB Local: \thttp://localhost:" + port + path + "/index.html\n\t"
52   - + "API Local: \thttp://localhost:" + port + path + "/\n\n\t"
53   - + "WEB External: \thttp://" + ip + ":" + port + path + "/index.html\n\t"
54   - + "API External: \thttp://" + ip + ":" + port + path + "/\n\n\t"
55   - + "Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n\n\t"
56   - + "The following profiles are active: [" + profiles + "]\n"
  46 + log.info("\n----------------------------------------------------------\n\t" + "Application HUAHENG WMS4 is running! Access urls:\n\n\t"
  47 + + "WEB Local: \thttp://localhost:" + port + path + "/index.html\n\t" + "API Local: \thttp://localhost:" + port + path + "/\n\n\t"
  48 + + "WEB External: \thttp://" + ip + ":" + port + path + "/index.html\n\t" + "API External: \thttp://" + ip + ":" + port + path + "/\n\n\t"
  49 + + "Swagger文档: \thttp://" + ip + ":" + port + path + "/doc.html\n\n\t" + "The following profiles are active: [" + profiles + "]\n"
57 50 + "----------------------------------------------------------");
58 51 }
59   -
  52 +
60 53 public static InetAddress getLocalHostExactAddress() {
61 54 try {
62 55 InetAddress inetAddress = null;
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java
... ... @@ -41,7 +41,7 @@ public class WcsController extends HuahengBaseController {
41 41 @ResponseBody
42 42 @ApiLogger(apiName = "仓位分配", from = "WCS")
43 43 public Result warecellAllocation(@RequestBody WarecellDomain warecellDomain, HttpServletRequest req) {
44   - String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);
  44 + String warehouseCode = warecellDomain.getWarehouseCode();
45 45 if (StringUtils.isEmpty(warehouseCode)) {
46 46 return Result.error("仓位分配, 仓库号为空");
47 47 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/config/HuahengBatisInterceptor.java 0 → 100644
  1 +package org.jeecg.modules.wms.framework.config;
  2 +
  3 +import java.lang.reflect.Field;
  4 +import java.util.Date;
  5 +import java.util.Properties;
  6 +
  7 +import org.apache.ibatis.binding.MapperMethod;
  8 +import org.apache.ibatis.executor.Executor;
  9 +import org.apache.ibatis.mapping.MappedStatement;
  10 +import org.apache.ibatis.mapping.SqlCommandType;
  11 +import org.apache.ibatis.plugin.*;
  12 +import org.apache.shiro.SecurityUtils;
  13 +import org.jeecg.common.system.vo.LoginUser;
  14 +import org.jeecg.common.util.oConvertUtils;
  15 +import org.springframework.stereotype.Component;
  16 +
  17 +import lombok.extern.slf4j.Slf4j;
  18 +
  19 +@Slf4j
  20 +@Component
  21 +@Intercepts({@Signature(type = Executor.class, method = "update", args = {MappedStatement.class, Object.class})})
  22 +public class HuahengBatisInterceptor implements Interceptor {
  23 +
  24 + @Override
  25 + public Object intercept(Invocation invocation) throws Throwable {
  26 + MappedStatement mappedStatement = (MappedStatement)invocation.getArgs()[0];
  27 + String sqlId = mappedStatement.getId();
  28 + log.debug("------sqlId------" + sqlId);
  29 + SqlCommandType sqlCommandType = mappedStatement.getSqlCommandType();
  30 + Object parameter = invocation.getArgs()[1];
  31 + log.debug("------sqlCommandType------" + sqlCommandType);
  32 +
  33 + if (parameter == null) {
  34 + return invocation.proceed();
  35 + }
  36 + if (SqlCommandType.INSERT == sqlCommandType) {
  37 + LoginUser sysUser = this.getLoginUser();
  38 + Field[] fields = oConvertUtils.getAllFields(parameter);
  39 + for (Field field : fields) {
  40 + log.debug("------field.name------" + field.getName());
  41 + try {
  42 + if ("createBy".equals(field.getName())) {
  43 + field.setAccessible(true);
  44 + Object local_createBy = field.get(parameter);
  45 + field.setAccessible(false);
  46 + if (local_createBy == null || local_createBy.equals("")) {
  47 + if (sysUser != null) {
  48 + // 登录人账号
  49 + field.setAccessible(true);
  50 + field.set(parameter, sysUser.getRealname());
  51 + field.setAccessible(false);
  52 + }
  53 + }
  54 + }
  55 + // 注入创建时间
  56 + if ("createTime".equals(field.getName())) {
  57 + field.setAccessible(true);
  58 + Object local_createDate = field.get(parameter);
  59 + field.setAccessible(false);
  60 + if (local_createDate == null || local_createDate.equals("")) {
  61 + field.setAccessible(true);
  62 + field.set(parameter, new Date());
  63 + field.setAccessible(false);
  64 + }
  65 + }
  66 + // 注入部门编码
  67 + if ("sysOrgCode".equals(field.getName())) {
  68 + field.setAccessible(true);
  69 + Object local_sysOrgCode = field.get(parameter);
  70 + field.setAccessible(false);
  71 + if (local_sysOrgCode == null || local_sysOrgCode.equals("")) {
  72 + // 获取登录用户信息
  73 + if (sysUser != null) {
  74 + field.setAccessible(true);
  75 + field.set(parameter, sysUser.getOrgCode());
  76 + field.setAccessible(false);
  77 + }
  78 + }
  79 + }
  80 + } catch (Exception e) {
  81 + }
  82 + }
  83 + }
  84 + if (SqlCommandType.UPDATE == sqlCommandType) {
  85 + LoginUser sysUser = this.getLoginUser();
  86 + Field[] fields = null;
  87 + if (parameter instanceof MapperMethod.ParamMap) {
  88 + MapperMethod.ParamMap<?> p = (MapperMethod.ParamMap<?>)parameter;
  89 + // update-begin-author:scott date:20190729 for:批量更新报错issues/IZA3Q--
  90 + if (p.containsKey("et")) {
  91 + parameter = p.get("et");
  92 + } else {
  93 + parameter = p.get("param1");
  94 + }
  95 + // update-end-author:scott date:20190729 for:批量更新报错issues/IZA3Q-
  96 +
  97 + // update-begin-author:scott date:20190729 for:更新指定字段时报错 issues/#516-
  98 + if (parameter == null) {
  99 + return invocation.proceed();
  100 + }
  101 + // update-end-author:scott date:20190729 for:更新指定字段时报错 issues/#516-
  102 +
  103 + fields = oConvertUtils.getAllFields(parameter);
  104 + } else {
  105 + fields = oConvertUtils.getAllFields(parameter);
  106 + }
  107 +
  108 + for (Field field : fields) {
  109 + log.debug("------field.name------" + field.getName());
  110 + try {
  111 + if ("updateBy".equals(field.getName())) {
  112 + // 获取登录用户信息
  113 + if (sysUser != null) {
  114 + // 登录账号
  115 + field.setAccessible(true);
  116 + field.set(parameter, sysUser.getRealname());
  117 + field.setAccessible(false);
  118 + }
  119 + }
  120 + if ("updateTime".equals(field.getName())) {
  121 + field.setAccessible(true);
  122 + field.set(parameter, new Date());
  123 + field.setAccessible(false);
  124 + }
  125 + } catch (Exception e) {
  126 + e.printStackTrace();
  127 + }
  128 + }
  129 + }
  130 + return invocation.proceed();
  131 + }
  132 +
  133 + @Override
  134 + public Object plugin(Object target) {
  135 + return Plugin.wrap(target, this);
  136 + }
  137 +
  138 + @Override
  139 + public void setProperties(Properties properties) {
  140 + // TODO Auto-generated method stub
  141 + }
  142 +
  143 + // update-begin--Author:scott Date:20191213 for:关于使用Quzrtz 开启线程任务, #465
  144 + private LoginUser getLoginUser() {
  145 + LoginUser sysUser = null;
  146 + try {
  147 + sysUser = SecurityUtils.getSubject().getPrincipal() != null ? (LoginUser)SecurityUtils.getSubject().getPrincipal() : null;
  148 + } catch (Exception e) {
  149 + sysUser = null;
  150 + }
  151 + return sysUser;
  152 + }
  153 +
  154 +}
... ...
huaheng-wms-core/src/main/java/org/jeecg/utils/HuahengJwtUtil.java
... ... @@ -10,8 +10,6 @@ import org.jeecg.common.exception.JeecgBootException;
10 10 import org.jeecg.common.util.oConvertUtils;
11 11 import org.jeecg.modules.wms.framework.aspectj.dto.ApiAuthentication;
12 12 import org.jeecg.modules.wms.framework.aspectj.dto.RSA256Key;
13   -import org.springframework.beans.factory.annotation.Autowired;
14   -import org.springframework.core.env.Environment;
15 13  
16 14 import com.auth0.jwt.JWT;
17 15 import com.auth0.jwt.JWTVerifier;
... ... @@ -21,7 +19,6 @@ import com.auth0.jwt.interfaces.DecodedJWT;
21 19  
22 20 import cn.hutool.core.date.DatePattern;
23 21 import cn.hutool.core.date.DateUtil;
24   -import net.bytebuddy.asm.Advice.This;
25 22  
26 23 public class HuahengJwtUtil {
27 24  
... ... @@ -158,8 +155,8 @@ public class HuahengJwtUtil {
158 155 public static void main(String[] args) throws Exception {
159 156 ApiAuthentication apiAuthentication = new ApiAuthentication();
160 157 // 生成TOKEN必填参数
161   - apiAuthentication.setOperator("TanYibin"); // Token提供方
162   - apiAuthentication.setAudience("ACS001"); // Token使用方
  158 + apiAuthentication.setOperator("youjie"); // Token提供方
  159 + apiAuthentication.setAudience("pda"); // Token使用方
163 160 apiAuthentication.setExpireDateTime(DateUtil.parse("2099-12-31 23:59:59", DatePattern.NORM_DATETIME_PATTERN)); // Token失效时间
164 161  
165 162 String tokenString = sign(apiAuthentication);
... ...