nbcio-boot从3.0升级到3.1的出现用户管理和数据字典bug
升级后出现
系统管理里的用户管理出现下面问题
2023-08-17 09:44:38.902 [http-nio-8080-exec-4] [1;31mERROR[0;39m [36mo.jeecg.common.exception.JeecgBootExceptionHandler:69[0;39m - java.lang.String cannot be cast to java.lang.Long
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
at org.jeecg.common.aspect.DictAspect.parseDictText(DictAspect.java:139)
at org.jeecg.common.aspect.DictAspect.doAround(DictAspect.java:62)
at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at org.jeecg.modules.system.controller.SysUserController$$EnhancerBySpringCGLIB$$604f6775.queryPageList(<generated>)
数据字典出现下面问题
2023-08-17 09:50:23.491 [http-nio-8080-exec-2] [1;31mERROR[0;39m [36mo.jeecg.common.exception.JeecgBootExceptionHandler:69[0;39m - java.lang.String cannot be cast to java.lang.Long
java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Long
at org.jeecg.common.aspect.DictAspect.parseDictText(DictAspect.java:139)
at org.jeecg.common.aspect.DictAspect.doAround(DictAspect.java:62)
at sun.reflect.GeneratedMethodAccessor150.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:634)
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:624)
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:72)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:97)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.proceed(CglibAopProxy.java:763)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:708)
at org.jeecg.modules.system.controller.SysDictItemController$$EnhancerBySpringCGLIB$$824a46d6.queryPageList(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
上面两个问题主要都是DictAspect.parseDictText出现问题,具体看就是这个函数里面的一个日期转换到string出问题,目前不需要了,可以注释掉了,注释掉后正常,代码如下:
-
private void parseDictText(Object result) {
-
if (result instanceof Result) {
-
if (((Result) result).getResult() instanceof IPage) {
-
List<JSONObject> items = new ArrayList<>();
-
-
//step.1 筛选出加了 Dict 注解的字段列表
-
List<Field> dictFieldList = new ArrayList<>();
-
// 字典数据列表, key = 字典code,value=数据列表
-
Map<String, List<String>> dataListMap = new HashMap<>();
-
-
for (Object record : ((IPage) ((Result) result).getResult()).getRecords()) {
-
ObjectMapper mapper = new ObjectMapper();
-
String json="{}";
-
try {
-
//解决@JsonFormat注解解析不了的问题详见SysAnnouncement类的@JsonFormat
-
//json = mapper.writeValueAsString(record); //改用objectMapper,解决java8 LocalDateTime JSON解析问题
-
json = objectMapper.writeValueAsString(record);
-
} catch (JsonProcessingException e) {
-
log.error("json解析失败" e.getMessage(),e);
-
}
-
JSONObject item = JSONObject.parseObject(json);
-
//update-begin--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
-
//for (Field field : record.getClass().getDeclaredFields()) {
-
// 遍历所有字段,把字典Code取出来,放到 map 里
-
for (Field field : oConvertUtils.getAllFields(record)) {
-
String value = item.getString(field.getName());
-
if (oConvertUtils.isEmpty(value)) {
-
continue;
-
}
-
//update-end--Author:scott -- Date:20190603 ----for:解决继承实体字段无法翻译问题------
-
if (field.getAnnotation(Dict.class) != null) {
-
if (!dictFieldList.contains(field)) {
-
dictFieldList.add(field);
-
}
-
String code = field.getAnnotation(Dict.class).dicCode();
-
String text = field.getAnnotation(Dict.class).dicText();
-
String table = field.getAnnotation(Dict.class).dictTable();
-
-
List<String> dataList;
-
String dictCode = code;
-
if (!StringUtils.isEmpty(table)) {
-
dictCode = String.format("%s,%s,%s", table, text, code);
-
}
-
dataList = dataListMap.computeIfAbsent(dictCode, k -> new ArrayList<>());
-
this.listAddAllDeduplicate(dataList, Arrays.asList(value.split(",")));
-
}
-
//date类型默认转换string格式化日期
-
/*if (field.getType().getName().equals("java.util.Date")&&field.getAnnotation(JsonFormat.class)==null&&item.get(field.getName())!=null){
-
SimpleDateFormat aDate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
-
}*/
-
}
-
items.add(item);
-
}
-
-
//step.2 调用翻译方法,一次性翻译
-
Map<String, List<DictModel>> translText = this.translateAllDict(dataListMap);
-
-
//step.3 将翻译结果填充到返回结果里
-
for (JSONObject record : items) {
-
for (Field field : dictFieldList) {
-
String code = field.getAnnotation(Dict.class).dicCode();
-
String text = field.getAnnotation(Dict.class).dicText();
-
String table = field.getAnnotation(Dict.class).dictTable();
-
-
String fieldDictCode = code;
-
if (!StringUtils.isEmpty(table)) {
-
fieldDictCode = String.format("%s,%s,%s", table, text, code);
-
}
-
-
String value = record.getString(field.getName());
-
if (oConvertUtils.isNotEmpty(value)) {
-
List<DictModel> dictModels = translText.get(fieldDictCode);
-
if(dictModels==null || dictModels.size()==0){
-
continue;
-
}
-
-
String textValue = this.translDictText(dictModels, value);
-
log.debug(" 字典Val : " textValue);
-
log.debug(" __翻译字典字段__ " field.getName() CommonConstant.DICT_TEXT_SUFFIX ": " textValue);
-
-
// TODO-sun 测试输出,待删
-
log.debug(" ---- dictCode: " fieldDictCode);
-
log.debug(" ---- value: " value);
-
log.debug(" ----- text: " textValue);
-
log.debug(" ---- dictModels: " JSON.toJSONString(dictModels));
-
-
record.put(field.getName() CommonConstant.DICT_TEXT_SUFFIX, textValue);
-
}
-
}
-
}
-
-
((IPage) ((Result) result).getResult()).setRecords(items);
-
}
-
-
}
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /boutique/detail/tanhiahfka
-
微信小程序没声音怎么办
PHP中文网 06-15 -
excel图片置于文字下方的方法
PHP中文网 06-27 -
怎样阻止微信小程序自动打开
PHP中文网 06-13 -
微信人名旁边有个图标有什么用
PHP中文网 03-11 -
微信提示登录环境异常是什么意思原因
PHP中文网 04-09 -
微信获取用户openid失败怎么办
PHP中文网 03-26 -
photoshop怎么把印章抠出并放在另一张图上
PHP中文网 06-15 -
EhViewer(E绅士)最新版_ehviewer白色版彩色版_Ehviewer显示网络错误怎么办?e站进不去了怎么办
Evanpatchouli 09-19 -
Excel筛选和排序是灰色的怎么办
PHP中文网 06-22 -
photoshop蒙版画笔没反应怎么办
PHP中文网 06-24