| | |
| | | package com.zt.common.utils; |
| | | |
| | | import cn.hutool.core.convert.Convert; |
| | | import cn.hutool.core.util.ReflectUtil; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.zt.common.entity.MapData; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | |
| | | import java.lang.reflect.Field; |
| | | import java.text.NumberFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | long msec = diff % 1000; |
| | | return hour + "小时" + min + "分钟" + sec + "秒" + msec + "毫秒"; |
| | | } |
| | | |
| | | public static boolean isActureChangeData(Object pageData, Object dbData) { |
| | | if (dbData == null) |
| | | return true; |
| | | Field[] fields = ReflectUtil.getFields(pageData.getClass()); |
| | | for (Field field : fields) { |
| | | field.setAccessible(true); |
| | | String fieldName = field.getName(); |
| | | String typeName = field.getType().getName().toLowerCase(); |
| | | String fieldsList = "serialversionuid,updater,updatedate,creator,createdate,tenantid,companyid,files,isdelete"; |
| | | if (!typeName.contains("com.zt.life.modules") && !typeName.equals("java.util.List") && !fieldsList.contains(fieldName.toLowerCase())) { |
| | | Object staticFieldValue = ReflectUtil.getFieldValue(pageData, field.getName()); |
| | | try { |
| | | Object staticFieldValue2 = ReflectUtil.getFieldValue(dbData, field.getName()); |
| | | if ("java.lang.string,java.lang.long".contains(typeName)) { |
| | | if ((staticFieldValue == null && staticFieldValue2 != null) || (staticFieldValue != null && staticFieldValue2 == null)) { |
| | | System.out.println(fieldName); |
| | | System.out.println(staticFieldValue); |
| | | System.out.println(staticFieldValue2); |
| | | return true; |
| | | } |
| | | if (staticFieldValue != null && staticFieldValue2 != null) { |
| | | if (!staticFieldValue.equals(staticFieldValue2)) { |
| | | System.out.println(fieldName); |
| | | System.out.println(staticFieldValue); |
| | | System.out.println(staticFieldValue2); |
| | | return true; |
| | | } |
| | | } |
| | | } else { |
| | | if (staticFieldValue != staticFieldValue2) { |
| | | System.out.println(fieldName); |
| | | System.out.println(staticFieldValue); |
| | | System.out.println(staticFieldValue2); |
| | | return true; |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | } |