当前位置: 首页 > news >正文

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);}}

http://www.lryc.cn/news/132121.html

相关文章:

  • Curson 编辑器
  • Shell编程学习之函数的应用
  • Fork/Join框架
  • LeetCode_字符串_中等_468.验证 IP 地址
  • ABAP Der Open SQL command is too big.
  • QChart类用来 管理 图表的:数据序列(series)、图例(legend)和坐标轴(axis)
  • Servlet+JDBC实战开发书店项目讲解第10篇:在线客服功能实现
  • CVE-2023-21292 AMS框架层高危漏洞分析
  • cuda、cuDNN、深度学习框架、pytorch、tentsorflow、keras这些概念之间的关系
  • 第二讲:BeanFactory的实现
  • vue2+Spring Boot2.7 大文件分片上传
  • Vite更新依赖缓存失败,强制更新依赖缓存
  • Linux命令200例:tail用来显示文件的末尾内容(常用)
  • 【Unity每日一记】进行发射,位置相关的方法总结
  • MISRA 2012学习笔记(3)-Rules 8.4-8.7
  • centos7组件搭建
  • webpack5和webpack4的一些区别
  • 攻防世界-fileclude
  • 深度学习的“前世今生”
  • 第一百一十九回 如何通过蓝牙设备读写数据
  • linux:Temporary failure in name resolutionCouldn’t resolve host
  • C 语言的 sprintf() 函数
  • 李沐pytorch学习-卷积网络及其实现
  • 记录:win10物理机ping不通虚拟机上的docker子网(已解决)
  • 深入浅出Pytorch函数——torch.nn.init.kaiming_normal_
  • D. Anton and School - 2
  • xcode把包打到高版本的iPhone里
  • PMP项目管理考试小结
  • 【NAS群晖drive异地访问】使用cpolar远程访问内网Synology Drive「内网穿透」
  • 【傅里叶级数与傅里叶变换】数学推导——2、[Part2:T = 2 π的周期函数的傅里叶级数展开] 及 [Part3:周期为2L的函数展开]