自动化立体仓库 - WMS系统
ZY
2024-09-20 9ef9076a630ead624c2c24bee28454836eb25b84
src/main/java/com/zy/asrs/utils/MatCompareUtils.java
@@ -1,6 +1,8 @@
package com.zy.asrs.utils;
import com.core.common.Cools;
import com.zy.asrs.entity.OrderDetl;
import com.zy.common.model.LocDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -23,8 +25,8 @@
        for (String fieldName : sameFields) {
            Object fieldValue1 = getFieldValue(object1, fieldName);
            Object fieldValue2 = getFieldValue(object2, fieldName);
            if (isSame(fieldValue1, fieldValue2)) {
                log.info("字段{}信息一致,{}-{}", fieldName, fieldValue1, fieldValue2);
            if (!isSame(fieldValue1, fieldValue2)) {
                log.info("字段{}信息不一致,{}_{}-{}_{}", fieldName, object1.getClass(), fieldValue1, object2.getClass(), fieldValue2);
                return false;
            }
        }
@@ -46,15 +48,21 @@
        Field field = null;
        try {
            field = aClass.getDeclaredField(fieldName);
        } catch (NoSuchFieldException e) {
            throw new RuntimeException(e);
        }
        field.setAccessible(true); // 设置为可访问
        try {
            // 设置为可访问
            field.setAccessible(true);
            return field.get(object);
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (NoSuchFieldException | IllegalAccessException e) {
            log.error("字段{}缺失,对象{}", fieldName, object);
            return null;
        }
    }
    public static void main(String[] args) {
        LocDto locDto = new LocDto();
        locDto.setMatnr("123");
        OrderDetl orderDetl = new OrderDetl();
        orderDetl.setMatnr("123");
        System.out.println(compare(locDto, orderDetl));
    }
}