Commit bf678bba52ba94aaa62e0d484d4b6daa98a28a54

Authored by 谭毅彬
1 parent adea95ab

工具类包路径优化

Signed-off-by: TanYibin <5491541@qq.com>
Showing 14 changed files with 22 additions and 119 deletions
huaheng-wms-core/src/main/java/org/jeecg/JeecgSystemApplication.java
... ... @@ -18,6 +18,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
18 18 import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
19 19 import org.springframework.boot.builder.SpringApplicationBuilder;
20 20 import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
  21 +import org.springframework.cache.annotation.EnableCaching;
21 22 import org.springframework.context.ConfigurableApplicationContext;
22 23 import org.springframework.core.env.Environment;
23 24  
... ... @@ -28,6 +29,7 @@ import net.bytebuddy.asm.Advice.This;
28 29 * 单体启动类(采用此类启动为单体模式)
29 30 */
30 31 @Slf4j
  32 +@EnableCaching
31 33 @SpringBootApplication
32 34 @EnableAutoConfiguration(exclude = {MongoAutoConfiguration.class})
33 35 public class JeecgSystemApplication extends SpringBootServletInitializer {
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/acs/controller/AcsController.java
... ... @@ -15,9 +15,9 @@ import org.jeecg.modules.wms.framework.aspectj.PassApiAuthentication;
15 15 import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger;
16 16 import org.jeecg.modules.wms.framework.controller.HuahengBaseController;
17 17 import org.jeecg.modules.wms.task.agvTask.service.IAgvTaskService;
  18 +import org.jeecg.utils.OkHttpUtils;
18 19 import org.jeecg.utils.StringUtils;
19 20 import org.jeecg.utils.constant.QuantityConstant;
20   -import org.jeecg.utils.http.OkHttpUtils;
21 21 import org.springframework.transaction.annotation.Transactional;
22 22 import org.springframework.web.bind.annotation.PostMapping;
23 23 import org.springframework.web.bind.annotation.RequestBody;
... ... @@ -47,7 +47,8 @@ public class AcsController extends HuahengBaseController {
47 47 @ResponseBody
48 48 @PostMapping(value = "/testTokenCheck")
49 49 public Result<?> testTokenCheck(@RequestBody Map<String, String> paramMap, HttpServletRequest request) {
50   - String url = "http://127.0.0.1:8080/wms/api/wms/acs/testTokenCheck";
  50 +// String url = "http://127.0.0.1:8080/wms/api/wms/acs/testTokenCheck";
  51 + String url = addressService.getUrlByParam(QuantityConstant.ADDRESS_ERP_BACK_RECEIPT);
51 52 String body = OkHttpUtils.sendPostByJsonStr(url, JSON.toJSONString(paramMap));
52 53 return Result.ok(body);
53 54 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/acs/service/impl/AcsServiceImpl.java
... ... @@ -10,9 +10,9 @@ import org.jeecg.modules.wms.config.location.entity.Location;
10 10 import org.jeecg.modules.wms.config.location.service.ILocationService;
11 11 import org.jeecg.modules.wms.task.agvTask.entity.AgvTask;
12 12 import org.jeecg.modules.wms.task.agvTask.service.IAgvTaskService;
  13 +import org.jeecg.utils.OkHttpUtils;
13 14 import org.jeecg.utils.StringUtils;
14 15 import org.jeecg.utils.constant.QuantityConstant;
15   -import org.jeecg.utils.http.OkHttpUtils;
16 16 import org.springframework.stereotype.Service;
17 17  
18 18 import com.alibaba.fastjson.JSON;
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/erp/service/impl/ErpServiceImpl.java
... ... @@ -38,9 +38,9 @@ import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentDetail;
38 38 import org.jeecg.modules.wms.shipment.shipmentHeader.entity.ShipmentHeader;
39 39 import org.jeecg.modules.wms.shipment.shipmentHeader.service.IShipmentDetailService;
40 40 import org.jeecg.modules.wms.shipment.shipmentHeader.service.IShipmentHeaderService;
  41 +import org.jeecg.utils.OkHttpUtils;
41 42 import org.jeecg.utils.StringUtils;
42 43 import org.jeecg.utils.constant.QuantityConstant;
43   -import org.jeecg.utils.http.OkHttpUtils;
44 44 import org.springframework.stereotype.Service;
45 45 import org.springframework.transaction.annotation.Transactional;
46 46  
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mes/servuce/impl/MesServiceImpl.java
... ... @@ -33,9 +33,9 @@ import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail;
33 33 import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader;
34 34 import org.jeecg.modules.wms.task.taskHeader.service.ITaskDetailService;
35 35 import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService;
  36 +import org.jeecg.utils.OkHttpUtils;
36 37 import org.jeecg.utils.StringUtils;
37 38 import org.jeecg.utils.constant.QuantityConstant;
38   -import org.jeecg.utils.http.OkHttpUtils;
39 39 import org.springframework.stereotype.Service;
40 40 import org.springframework.transaction.annotation.Transactional;
41 41  
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java
... ... @@ -35,9 +35,9 @@ import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail;
35 35 import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader;
36 36 import org.jeecg.modules.wms.task.taskHeader.service.ITaskDetailService;
37 37 import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService;
  38 +import org.jeecg.utils.OkHttpUtils;
38 39 import org.jeecg.utils.StringUtils;
39 40 import org.jeecg.utils.constant.QuantityConstant;
40   -import org.jeecg.utils.http.OkHttpUtils;
41 41 import org.springframework.stereotype.Service;
42 42 import org.springframework.transaction.annotation.Transactional;
43 43  
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/address/service/impl/AddressServiceImpl.java
... ... @@ -6,6 +6,7 @@ import org.apache.commons.math3.analysis.function.Add;
6 6 import org.jeecg.modules.wms.config.address.entity.Address;
7 7 import org.jeecg.modules.wms.config.address.mapper.AddressMapper;
8 8 import org.jeecg.modules.wms.config.address.service.IAddressService;
  9 +import org.springframework.cache.annotation.Cacheable;
9 10 import org.springframework.stereotype.Service;
10 11  
11 12 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
... ... @@ -40,6 +41,7 @@ public class AddressServiceImpl extends ServiceImpl&lt;AddressMapper, Address&gt; impl
40 41 }
41 42  
42 43 @Override
  44 + @Cacheable(cacheNames = "getUrlByParam", key = "#root.methodName + '_' + #param")
43 45 public String getUrlByParam(String param) {
44 46 LambdaQueryWrapper<Address> addressLambdaQueryWrapper = Wrappers.lambdaQuery();
45 47 addressLambdaQueryWrapper.eq(Address::getParam, param);
... ... @@ -49,5 +51,4 @@ public class AddressServiceImpl extends ServiceImpl&lt;AddressMapper, Address&gt; impl
49 51 }
50 52 return address.getUrl();
51 53 }
52   -
53 54 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/controller/HuahengBaseController.java
... ... @@ -5,7 +5,7 @@ import java.util.concurrent.TimeUnit;
5 5 import javax.annotation.Nonnull;
6 6  
7 7 import org.jeecg.common.api.vo.Result;
8   -import org.jeecg.utils.RedissonDistributedLocker;
  8 +import org.jeecg.utils.support.RedissonDistributedLocker;
9 9 import org.springframework.beans.factory.annotation.Autowired;
10 10  
11 11 import cn.hutool.core.date.SystemClock;
... ...
huaheng-wms-core/src/main/java/org/jeecg/utils/http/OkHttpUtils.java renamed to huaheng-wms-core/src/main/java/org/jeecg/utils/OkHttpUtils.java
1   -package org.jeecg.utils.http;
  1 +package org.jeecg.utils;
2 2  
3 3 import com.alibaba.fastjson.JSON;
4 4 import com.alibaba.fastjson.TypeReference;
... ... @@ -117,7 +117,7 @@ public class OkHttpUtils {
117 117 }
118 118 } catch (Exception e) {
119 119 String errorString = StrUtil.format("执行GET请求异常!url:{},header:{},param:{} {}", url, JSON.toJSONString(headers), param, e.getMessage());
120   - log.error(errorString, e);
  120 + log.error(errorString);
121 121 ApiLogAspect.setApiLogException(apiLog, e);
122 122 throw new RuntimeException(errorString, e);
123 123 } finally {
... ... @@ -168,7 +168,7 @@ public class OkHttpUtils {
168 168 }
169 169 } catch (Exception e) {
170 170 String errorString = StrUtil.format("执行POST请求异常!url:{},header:{},param:{} {}", url, JSON.toJSONString(headers), param, e.getMessage());
171   - log.error(errorString, e);
  171 + log.error(errorString);
172 172 ApiLogAspect.setApiLogException(apiLog, e);
173 173 throw new RuntimeException(errorString, e);
174 174 } finally {
... ... @@ -193,7 +193,6 @@ public class OkHttpUtils {
193 193 headers.put("Content-Type", "application/json");// 设置发送数据的格式
194 194 Request.Builder builder = new Request.Builder();
195 195 buildHeader(builder, headers);
196   - // using above json body as a input to post API call
197 196 RequestBody body = RequestBody.create(MEDIA_TYPE_JSON, jsonString);
198 197 Request request = builder.url(url).post(body).build();
199 198 Response response = null;
... ... @@ -212,7 +211,7 @@ public class OkHttpUtils {
212 211 }
213 212 } catch (Exception e) {
214 213 String errorString = StrUtil.format("执行POST请求异常!url:{},header:{},param:{} {}", url, JSON.toJSONString(headers), jsonString, e.getMessage());
215   - log.error(errorString, e);
  214 + log.error(errorString);
216 215 ApiLogAspect.setApiLogException(apiLog, e);
217 216 throw new RuntimeException(errorString, e);
218 217 } finally {
... ... @@ -260,10 +259,8 @@ public class OkHttpUtils {
260 259 this.maxRentry = maxRentry;
261 260 }
262 261  
  262 + /** 递归 2次下发请求,如果仍然失败 则返回 null 但是 intercept must not return null. 返回 null 会报 IllegalStateException 异常 */
263 263 public Response intercept(@NotNull Chain chain) throws IOException {
264   - /*
265   - * 递归 2次下发请求,如果仍然失败 则返回 null 但是 intercept must not return null. 返回 null 会报 IllegalStateException 异常
266   - */
267 264 return retry(chain, 0);
268 265 }
269 266  
... ... @@ -283,5 +280,4 @@ public class OkHttpUtils {
283 280 return response;
284 281 }
285 282 }
286   -
287 283 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/utils/StringUtils.java
1 1 package org.jeecg.utils;
2 2  
3   -import org.apache.commons.lang.text.StrBuilder;
4   -import org.jeecg.utils.support.StrFormatter;
5   -
6 3 import java.lang.reflect.Field;
7 4 import java.util.Collection;
8 5 import java.util.Map;
9 6  
  7 +import org.apache.commons.lang.text.StrBuilder;
  8 +
10 9 /**
11 10 * 字符串工具类
12 11 * @author huaheng
... ... @@ -238,25 +237,6 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
238 237 }
239 238  
240 239 /**
241   - * 格式化文本, {} 表示占位符<br>
242   - * 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
243   - * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
244   - * 例:<br>
245   - * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
246   - * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
247   - * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
248   - * @param template 文本模板,被替换的部分用 {} 表示
249   - * @param params 参数值
250   - * @return 格式化后的文本
251   - */
252   - public static String format(String template, Object... params) {
253   - if (isEmpty(params) || isEmpty(template)) {
254   - return template;
255   - }
256   - return StrFormatter.format(template, params);
257   - }
258   -
259   - /**
260 240 * 驼峰首字符小写
261 241 */
262 242 public static String uncapitalize(String str) {
... ...
huaheng-wms-core/src/main/java/org/jeecg/utils/HuahengShiroConfig.java renamed to huaheng-wms-core/src/main/java/org/jeecg/utils/config/HuahengShiroConfig.java
1   -package org.jeecg.utils;
  1 +package org.jeecg.utils.config;
2 2  
3 3 import java.util.LinkedHashMap;
4 4 import java.util.Map;
... ...
huaheng-wms-core/src/main/java/org/jeecg/utils/CustomLogContextListener.java renamed to huaheng-wms-core/src/main/java/org/jeecg/utils/listener/CustomLogContextListener.java
1   -package org.jeecg.utils;
  1 +package org.jeecg.utils.listener;
2 2  
3 3 import ch.qos.logback.classic.Level;
4 4 import ch.qos.logback.classic.Logger;
... ...
huaheng-wms-core/src/main/java/org/jeecg/utils/RedissonDistributedLocker.java renamed to huaheng-wms-core/src/main/java/org/jeecg/utils/support/RedissonDistributedLocker.java
1   -package org.jeecg.utils;
  1 +package org.jeecg.utils.support;
2 2  
3 3 import java.util.concurrent.TimeUnit;
4 4  
... ...
huaheng-wms-core/src/main/java/org/jeecg/utils/support/StrFormatter.java deleted
1   -package org.jeecg.utils.support;
2   -
3   -import org.jeecg.utils.StringUtils;
4   -
5   -/**
6   - * 字符串格式化
7   - * @author huaheng
8   - */
9   -public class StrFormatter {
10   -
11   - public static final String EMPTY_JSON = "{}";
12   - public static final char C_BACKSLASH = '\\';
13   - public static final char C_DELIM_START = '{';
14   - public static final char C_DELIM_END = '}';
15   -
16   - /**
17   - * 格式化字符串<br>
18   - * 此方法只是简单将占位符 {} 按照顺序替换为参数<br>
19   - * 如果想输出 {} 使用 \\转义 { 即可,如果想输出 {} 之前的 \ 使用双转义符 \\\\ 即可<br>
20   - * 例:<br>
21   - * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
22   - * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
23   - * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
24   - * @param strPattern 字符串模板
25   - * @param argArray 参数列表
26   - * @return 结果
27   - */
28   - public static String format(final String strPattern, final Object... argArray) {
29   - if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) {
30   - return strPattern;
31   - }
32   - final int strPatternLength = strPattern.length();
33   -
34   - // 初始化定义好的长度以获得更好的性能
35   - StringBuilder sbuf = new StringBuilder(strPatternLength + 50);
36   -
37   - int handledPosition = 0;
38   - int delimIndex;// 占位符所在位置
39   - for (int argIndex = 0; argIndex < argArray.length; argIndex++) {
40   - delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
41   - if (delimIndex == -1) {
42   - if (handledPosition == 0) {
43   - return strPattern;
44   - } else { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
45   - sbuf.append(strPattern, handledPosition, strPatternLength);
46   - return sbuf.toString();
47   - }
48   - } else {
49   - if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) {
50   - if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) {
51   - // 转义符之前还有一个转义符,占位符依旧有效
52   - sbuf.append(strPattern, handledPosition, delimIndex - 1);
53   - sbuf.append(Convert.utf8Str(argArray[argIndex]));
54   - handledPosition = delimIndex + 2;
55   - } else {
56   - // 占位符被转义
57   - argIndex--;
58   - sbuf.append(strPattern, handledPosition, delimIndex - 1);
59   - sbuf.append(C_DELIM_START);
60   - handledPosition = delimIndex + 1;
61   - }
62   - } else {
63   - // 正常占位符
64   - sbuf.append(strPattern, handledPosition, delimIndex);
65   - sbuf.append(Convert.utf8Str(argArray[argIndex]));
66   - handledPosition = delimIndex + 2;
67   - }
68   - }
69   - }
70   - // append the characters following the last {} pair.
71   - // 加入最后一个占位符后所有的字符
72   - sbuf.append(strPattern, handledPosition, strPattern.length());
73   -
74   - return sbuf.toString();
75   - }
76   -
77   -}