解决double超出精度转成科学记数法的问题
parent
ee64140219
commit
9275631cd8
|
@ -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));
|
||||
|
|
|
@ -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<Object> 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)){
|
|
@ -1,16 +0,0 @@
|
|||
package xuanran.wang.http_test.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* <h1>请求路径参数替换</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/3/10 17:00
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.PARAMETER})
|
||||
@Documented
|
||||
public @interface CusPathQuery {
|
||||
String value();
|
||||
}
|
|
@ -11,5 +11,5 @@ import java.lang.annotation.*;
|
|||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE})
|
||||
@Documented
|
||||
public @interface CusRequest {
|
||||
public @interface CusRequestClient {
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package xuanran.wang.http_test.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* <h1>路径参数 可以修饰map,字段 如果是字段那就会将</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/3/10 13:06
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Documented
|
||||
public @interface GetPathValue {
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package xuanran.wang.http_test.annotations;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* <h1>post请求体</h1>
|
||||
*
|
||||
* @author xuanran.wang
|
||||
* @date 2023/3/10 13:48
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.PARAMETER)
|
||||
@Documented
|
||||
public @interface PostBody {
|
||||
}
|
|
@ -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;
|
|
@ -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;
|
||||
//
|
||||
///**
|
||||
// * <h1>post方法解析</h1>
|
||||
// *
|
||||
// * @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<String, String>) arg;
|
||||
// }else if(arg instanceof String){
|
||||
// String json = JSONObject.toJSONString(arg);
|
||||
// return JSONObject.parseObject(json, Map.class);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return new HashMap();
|
||||
// }
|
||||
//}
|
|
@ -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;
|
||||
//
|
||||
///**
|
||||
// * <h1>请求头处理</h1>
|
||||
// *
|
||||
// * @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<String, String> 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<String, String> 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;
|
||||
// }
|
||||
//}
|
|
@ -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<String, String>) arg);
|
||||
requestEntity.getPathParams().putAll((Map<? extends String, ? extends String>) arg);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue