From 9275631cd829a3ba2031c14d13867c958750dfb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=AE=A3=E7=84=B6?= Date: Tue, 4 Apr 2023 17:15:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3double=E8=B6=85=E5=87=BA?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6=E8=BD=AC=E6=88=90=E7=A7=91=E5=AD=A6=E8=AE=B0?= =?UTF-8?q?=E6=95=B0=E6=B3=95=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/service/DealWithMapping.java | 16 +++- ...viceImpl.java => UserServiceImplBack.java} | 2 + .../http_test/annotations/CusPathQuery.java | 16 ---- ...{CusRequest.java => CusRequestClient.java} | 2 +- .../http_test/annotations/GetPathValue.java | 15 ---- .../wang/http_test/annotations/PostBody.java | 15 ---- ...ant.java => CusRequestClientConstant.java} | 2 +- ...andle.java => CusRequestBeforeHandle.java} | 0 .../wang/http_test/handle/PostTypeHandle.java | 35 -------- .../http_test/handle/RequestHeaderHandle.java | 81 ------------------- ...rseHandle.java => CusPathParseHandle.java} | 4 +- 11 files changed, 21 insertions(+), 167 deletions(-) rename src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/{UserServiceImpl.java => UserServiceImplBack.java} (98%) delete mode 100644 src/test/java/xuanran/wang/http_test/annotations/CusPathQuery.java rename src/test/java/xuanran/wang/http_test/annotations/{CusRequest.java => CusRequestClient.java} (86%) delete mode 100644 src/test/java/xuanran/wang/http_test/annotations/GetPathValue.java delete mode 100644 src/test/java/xuanran/wang/http_test/annotations/PostBody.java rename src/test/java/xuanran/wang/http_test/constant/{RequestUtilConstant.java => CusRequestClientConstant.java} (89%) rename src/test/java/xuanran/wang/http_test/handle/{RequestBeforeHandle.java => CusRequestBeforeHandle.java} (100%) delete mode 100644 src/test/java/xuanran/wang/http_test/handle/PostTypeHandle.java delete mode 100644 src/test/java/xuanran/wang/http_test/handle/RequestHeaderHandle.java rename src/test/java/xuanran/wang/http_test/handle/path_handle/{CusFieldKeyParseHandle.java => CusPathParseHandle.java} (89%) diff --git a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java index 712fc01..1219d1e 100644 --- a/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java +++ b/src/main/java/weaver/xiao/commons/config/service/DealWithMapping.java @@ -21,6 +21,7 @@ import weaver.zwl.common.ToolUtil; import java.io.InputStream; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; +import java.math.BigDecimal; import java.security.SecureRandom; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -115,7 +116,20 @@ public class DealWithMapping extends ToolUtil { continue; } if ("DECIMAL".equalsIgnoreCase(type) || "NUMERIC".equalsIgnoreCase(type)) { - map.put(key, rs.getDouble(i)); + /** + * @author xuanran.wang + * @data 2023-04-04 + * @desc 解决double超出精度转成科学记数法的问题 + */ + String val = Util.null2String(rs.getString(i)); + BigDecimal decimal; + if(StringUtils.isBlank(val)){ + decimal = new BigDecimal("0"); + }else { + decimal = new BigDecimal(val); + } + map.put(key, decimal); +// map.put(key, rs.getDouble(i)); continue; } map.put(key, rs.getString(i)); diff --git a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImpl.java b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImplBack.java similarity index 98% rename from src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImpl.java rename to src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImplBack.java index 01d336e..759e1e2 100644 --- a/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImpl.java +++ b/src/main/java/weaver/xuanran/wang/shyl_mq/service/impl/UserServiceImplBack.java @@ -68,6 +68,7 @@ public class UserServiceImpl extends CusInfoActionService { // 通过外键获取部门信息数据为空 throw new CustomerException("The department information data obtained by foreign key is empty!"); } + logger.info(Util.logStr("depInfoByOutKey : {}", JSONObject.toJSONString(depInfoByOutKey))); nextHrmId = getNextHrmId(); List params = initHrmParam(nextHrmId, userInfo, depInfoByOutKey); String departmentId = Util.null2DefaultStr(depInfoByOutKey.get("departmentId"), ""); @@ -177,6 +178,7 @@ public class UserServiceImpl extends CusInfoActionService { // 通过外键获取部门信息数据为空 throw new CustomerException("The department information data obtained by foreign key is empty!"); } + logger.info(Util.logStr("depInfoByOutKey : {}", JSONObject.toJSONString(depInfoByOutKey))); // oa人员id String hrmId = consumerMapper.getHrmIdByOutKey(userInfoId); if(StringUtils.isBlank(hrmId)){ diff --git a/src/test/java/xuanran/wang/http_test/annotations/CusPathQuery.java b/src/test/java/xuanran/wang/http_test/annotations/CusPathQuery.java deleted file mode 100644 index 3d43003..0000000 --- a/src/test/java/xuanran/wang/http_test/annotations/CusPathQuery.java +++ /dev/null @@ -1,16 +0,0 @@ -package xuanran.wang.http_test.annotations; - -import java.lang.annotation.*; - -/** - *

请求路径参数替换

- * - * @author xuanran.wang - * @date 2023/3/10 17:00 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.PARAMETER}) -@Documented -public @interface CusPathQuery { - String value(); -} diff --git a/src/test/java/xuanran/wang/http_test/annotations/CusRequest.java b/src/test/java/xuanran/wang/http_test/annotations/CusRequestClient.java similarity index 86% rename from src/test/java/xuanran/wang/http_test/annotations/CusRequest.java rename to src/test/java/xuanran/wang/http_test/annotations/CusRequestClient.java index ef05213..c1ea590 100644 --- a/src/test/java/xuanran/wang/http_test/annotations/CusRequest.java +++ b/src/test/java/xuanran/wang/http_test/annotations/CusRequestClient.java @@ -11,5 +11,5 @@ import java.lang.annotation.*; @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) @Documented -public @interface CusRequest { +public @interface CusRequestClient { } diff --git a/src/test/java/xuanran/wang/http_test/annotations/GetPathValue.java b/src/test/java/xuanran/wang/http_test/annotations/GetPathValue.java deleted file mode 100644 index 65dd302..0000000 --- a/src/test/java/xuanran/wang/http_test/annotations/GetPathValue.java +++ /dev/null @@ -1,15 +0,0 @@ -package xuanran.wang.http_test.annotations; - -import java.lang.annotation.*; - -/** - *

路径参数 可以修饰map,字段 如果是字段那就会将

- * - * @author xuanran.wang - * @date 2023/3/10 13:06 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PARAMETER) -@Documented -public @interface GetPathValue { -} diff --git a/src/test/java/xuanran/wang/http_test/annotations/PostBody.java b/src/test/java/xuanran/wang/http_test/annotations/PostBody.java deleted file mode 100644 index 2f704c8..0000000 --- a/src/test/java/xuanran/wang/http_test/annotations/PostBody.java +++ /dev/null @@ -1,15 +0,0 @@ -package xuanran.wang.http_test.annotations; - -import java.lang.annotation.*; - -/** - *

post请求体

- * - * @author xuanran.wang - * @date 2023/3/10 13:48 - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PARAMETER) -@Documented -public @interface PostBody { -} diff --git a/src/test/java/xuanran/wang/http_test/constant/RequestUtilConstant.java b/src/test/java/xuanran/wang/http_test/constant/CusRequestClientConstant.java similarity index 89% rename from src/test/java/xuanran/wang/http_test/constant/RequestUtilConstant.java rename to src/test/java/xuanran/wang/http_test/constant/CusRequestClientConstant.java index d8f6c83..d368610 100644 --- a/src/test/java/xuanran/wang/http_test/constant/RequestUtilConstant.java +++ b/src/test/java/xuanran/wang/http_test/constant/CusRequestClientConstant.java @@ -6,7 +6,7 @@ package xuanran.wang.http_test.constant; * @author xuanran.wang * @date 2023/3/10 14:01 */ -public class RequestUtilConstant { +public class CusRequestClientConstant { public static final int GET = 0; public static final int POST = 1; public static final int DELETE = 2; diff --git a/src/test/java/xuanran/wang/http_test/handle/RequestBeforeHandle.java b/src/test/java/xuanran/wang/http_test/handle/CusRequestBeforeHandle.java similarity index 100% rename from src/test/java/xuanran/wang/http_test/handle/RequestBeforeHandle.java rename to src/test/java/xuanran/wang/http_test/handle/CusRequestBeforeHandle.java diff --git a/src/test/java/xuanran/wang/http_test/handle/PostTypeHandle.java b/src/test/java/xuanran/wang/http_test/handle/PostTypeHandle.java deleted file mode 100644 index 7b75eeb..0000000 --- a/src/test/java/xuanran/wang/http_test/handle/PostTypeHandle.java +++ /dev/null @@ -1,35 +0,0 @@ -//package xuanran.wang.http_test.handle; -// -//import com.alibaba.fastjson.JSONObject; -//import xuanran.wang.http_test.annotations.PostBody; -// -//import java.lang.reflect.Method; -//import java.lang.reflect.Parameter; -//import java.util.HashMap; -//import java.util.Map; -// -///** -// *

post方法解析

-// * -// * @author xuanran.wang -// * @date 2023/3/10 13:54 -// */ -//public class PostTypeHandle implements RequestBeforeHandle { -// @Override -// public Map handle(String url, Method method, Object[] args) { -// Parameter[] parameters = method.getParameters(); -// for (int i = 0; i < parameters.length; i++) { -// PostBody postBody = parameters[i].getDeclaredAnnotation(PostBody.class); -// if(postBody != null){ -// Object arg = args[i]; -// if(arg instanceof Map){ -// return (Map) arg; -// }else if(arg instanceof String){ -// String json = JSONObject.toJSONString(arg); -// return JSONObject.parseObject(json, Map.class); -// } -// } -// } -// return new HashMap(); -// } -//} diff --git a/src/test/java/xuanran/wang/http_test/handle/RequestHeaderHandle.java b/src/test/java/xuanran/wang/http_test/handle/RequestHeaderHandle.java deleted file mode 100644 index 6d2d99b..0000000 --- a/src/test/java/xuanran/wang/http_test/handle/RequestHeaderHandle.java +++ /dev/null @@ -1,81 +0,0 @@ -//package xuanran.wang.http_test.handle; -// -//import aiyh.utils.Util; -//import aiyh.utils.excention.CustomerException; -//import org.apache.commons.collections.CollectionUtils; -//import org.apache.commons.collections.MapUtils; -//import org.apache.commons.lang3.StringUtils; -//import xuanran.wang.http_test.annotations.header.CusRequestHeader; -//import xuanran.wang.http_test.interfaces.CusCreateRequestHeader; -// -//import java.lang.reflect.Method; -//import java.lang.reflect.Parameter; -//import java.util.HashMap; -//import java.util.Map; -// -///** -// *

请求头处理

-// * -// * @author xuanran.wang -// * @date 2023/3/10 14:42 -// */ -//public class RequestHeaderHandle implements RequestBeforeHandle { -// @Override -// public Object handle(String url, Method method, Object[] args) { -// CusRequestHeader methodCusRequestHeader = method.getDeclaredAnnotation(CusRequestHeader.class); -// if(methodCusRequestHeader == null){ -// return new HashMap<>(); -// } -// // 数组形式 -// String[] headersArr = methodCusRequestHeader.cusHeaders(); -// HashMap headers = new HashMap<>(); -// if(headersArr != null){ -// for (String headerStr : headersArr) { -// String[] split = headerStr.split(":"); -// String key = Util.null2DefaultStr(split[0],"").trim(); -// String val = Util.null2DefaultStr(split[1],"").trim(); -// if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){ -// headers.put(key, val); -// } -// } -// } -// -// // java代码自定义 -// String path = Util.null2DefaultStr(methodCusRequestHeader.cusHeadersClassPath(),""); -// if(StringUtils.isNotBlank(path)){ -// Class clazz; -// try { -// clazz = Class.forName(path); -// } catch (ClassNotFoundException e) { -// throw new CustomerException(Util.logStr("自定义请求头java类文件没找到!: {}", path)); -// } -// if(!clazz.isAssignableFrom(CusCreateRequestHeader.class)){ -// throw new CustomerException(Util.logStr("当前类路径:[{}] ,未实现CusCreateRequestHeader接口!", path)); -// } -// CusCreateRequestHeader o; -// try { -// o = (CusCreateRequestHeader) clazz.newInstance(); -// }catch (InstantiationException | IllegalAccessException e) { -// throw new CustomerException(Util.logStr("实例化 [{}] 对象失败! error:{}", path, e.getMessage())); -// } -// Map cusCreateHeader = o.createHeader(); -// if(MapUtils.isNotEmpty(cusCreateHeader)){ -// headers.putAll(cusCreateHeader); -// } -// } -// // 参数中 -// Parameter[] parameters = method.getParameters(); -// for (int i = 0; i < parameters.length; i++) { -// Parameter parameter = parameters[i]; -// CusRequestHeader requestHeader = parameter.getAnnotation(CusRequestHeader.class); -// if(requestHeader != null){ -// String val = Util.null2DefaultStr(args[i], "").trim(); -// String key = requestHeader.value().trim(); -// if(StringUtils.isNotBlank(key) && StringUtils.isNotBlank(val)){ -// headers.put(key, val); -// } -// } -// } -// return headers; -// } -//} diff --git a/src/test/java/xuanran/wang/http_test/handle/path_handle/CusFieldKeyParseHandle.java b/src/test/java/xuanran/wang/http_test/handle/path_handle/CusPathParseHandle.java similarity index 89% rename from src/test/java/xuanran/wang/http_test/handle/path_handle/CusFieldKeyParseHandle.java rename to src/test/java/xuanran/wang/http_test/handle/path_handle/CusPathParseHandle.java index 19ab94e..d9cf5b8 100644 --- a/src/test/java/xuanran/wang/http_test/handle/path_handle/CusFieldKeyParseHandle.java +++ b/src/test/java/xuanran/wang/http_test/handle/path_handle/CusPathParseHandle.java @@ -2,7 +2,7 @@ package xuanran.wang.http_test.handle.path_handle; import aiyh.utils.Util; import org.apache.commons.lang3.StringUtils; -import xuanran.wang.http_test.annotations.CusPathQuery; +import xuanran.wang.http_test.annotations.request_path.CusPathQuery; import xuanran.wang.http_test.entity.CusRequestEntity; import xuanran.wang.http_test.handle.RequestBeforeHandle; @@ -33,7 +33,7 @@ public class CusFieldKeyParseHandle implements RequestBeforeHandle { }else { Class clazz = parameter.getType(); if(clazz.isAssignableFrom(Map.class)){ - requestEntity.setPathParams((Map) arg); + requestEntity.getPathParams().putAll((Map) arg); } } }