Commit 3caad275 authored by alex yao's avatar alex yao

fix(scheduler): 优化软件著作权构建项逻辑

- 移除合并字段数组的方式,改为分别处理baseInfo和技术内容字段
- 将technicalContent字段的处理提取到单独的循环中
- 为technicalContent字段添加相同的反射访问和值转换逻辑
- 保持原有的异常处理机制确保程序稳定性
- 简化代码结构提高可读性和维护性
parent 39305f55
......@@ -277,14 +277,7 @@ public class SoftwareCopyRightScheduler {
private void buildItem(BaseInfo baseInfo, List<Item> items, TechnicalContent technicalContent) {
// 处理baseInfo,technicalContent的所有字段
java.lang.reflect.Field[] baseInfoFields = baseInfo.getClass().getDeclaredFields();
java.lang.reflect.Field[] technicalContentFields = technicalContent.getClass().getDeclaredFields();
java.lang.reflect.Field[] fileds =
new java.lang.reflect.Field[baseInfoFields.length + technicalContentFields.length];
System.arraycopy(baseInfoFields, 0, fileds, 0, baseInfoFields.length);
System.arraycopy(technicalContentFields, 0, fileds, baseInfoFields.length, technicalContentFields.length);
for (java.lang.reflect.Field field : fileds) {
for (java.lang.reflect.Field field : baseInfoFields) {
field.setAccessible(true);
try {
Object value = field.get(baseInfo);
......@@ -305,6 +298,29 @@ public class SoftwareCopyRightScheduler {
continue;
}
}
java.lang.reflect.Field[] technicalContentFields = technicalContent.getClass().getDeclaredFields();
for (java.lang.reflect.Field field : technicalContentFields) {
field.setAccessible(true);
try {
Object value = field.get(technicalContent);
List<String> values = new ArrayList<>();
if (value == null) {
values.add(StringUtils.SPACE);
}
if (value != null) {
values.add(value.toString());
}
Item item = new Item();
item.setKey(field.getName());
item.setValue(values);
item.setType("text");
items.add(item);
} catch (IllegalAccessException e) {
//todo 记录错误但继续处理其他字段
continue;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment