| | |
| | | for (String fieldName : sameFields) { |
| | | Object fieldValue1 = getFieldValue(object1, fieldName); |
| | | Object fieldValue2 = getFieldValue(object2, fieldName); |
| | | if (isSame(fieldValue1, fieldValue2)) { |
| | | log.info("字段{}信息一致,{}-{}", fieldName, fieldValue1, fieldValue2); |
| | | }else { |
| | | if (!isSame(fieldValue1, fieldValue2)) { |
| | | log.info("字段{}信息不一致,{}_{}-{}_{}", fieldName, object1.getClass(), fieldValue1, object2.getClass(), fieldValue2); |
| | | return false; |
| | | } |
| | | } |
| | |
| | | Field field = null; |
| | | try { |
| | | field = aClass.getDeclaredField(fieldName); |
| | | } catch (NoSuchFieldException e) { |
| | | return null; |
| | | } |
| | | field.setAccessible(true); // 设置为可访问 |
| | | try { |
| | | // 设置为可访问 |
| | | field.setAccessible(true); |
| | | return field.get(object); |
| | | } catch (IllegalAccessException e) { |
| | | } catch (NoSuchFieldException | IllegalAccessException e) { |
| | | log.error("字段{}缺失,对象{}", fieldName, object); |
| | | return null; |
| | | } |
| | | } |