diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopic.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopic.java index de104c22..35cd30c3 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopic.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopic.java @@ -1,6 +1,7 @@ package com.adc.da.slrs.sarLawsTopic.entity; import com.adc.da.att.entity.AttFileEO; +import com.adc.da.utils.annotation.CompareField; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -30,6 +31,7 @@ public class SarLawsTopic implements Serializable { /** * 课题名称 */ + @CompareField(fieldName = "课题名称") @ApiModelProperty(value = "课题名称") @TableField(value = "TOPIC_NAME") private String topicName; @@ -37,6 +39,7 @@ public class SarLawsTopic implements Serializable { /** * 课题承办单位 */ + @CompareField(fieldName = "课题承办单位") @ApiModelProperty(value = "课题承办单位") @TableField(value = "ORGANIZER") private String organizer; @@ -44,6 +47,7 @@ public class SarLawsTopic implements Serializable { /** * 课题指导单位 */ + @CompareField(fieldName = "课题指导单位") @ApiModelProperty(value = "课题指导单位") @TableField(value = "GUIDANCE_UNIT") private String guidanceUnit; @@ -51,6 +55,7 @@ public class SarLawsTopic implements Serializable { /** * 课题参与单位 */ + @CompareField(fieldName = "课题参与单位") @ApiModelProperty(value = "课题参与单位") @TableField(value = "PARTICIPATING_UNIT") private String participatingUnit; @@ -58,6 +63,7 @@ public class SarLawsTopic implements Serializable { /** * 开始时间 */ + @CompareField(fieldName = "启动时间") @ApiModelProperty(value = "启动时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @TableField(value = "START_TIME") @@ -66,6 +72,7 @@ public class SarLawsTopic implements Serializable { /** * 结题时间 */ + @CompareField(fieldName = "结题时间") @ApiModelProperty(value = "结题时间") @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd") @TableField(value = "CLOSE_TIME") @@ -74,6 +81,7 @@ public class SarLawsTopic implements Serializable { /** * 课题状态 */ + @CompareField(fieldName = "课题状态") @ApiModelProperty(value = "课题状态") @TableField(value = "TOPIC_STATUS") private String topicStatus; @@ -81,6 +89,7 @@ public class SarLawsTopic implements Serializable { /** * 课题费用(万元) */ + @CompareField(fieldName = "课题费用") @ApiModelProperty(value = "课题费用") @TableField(value = "TOPIC_COST") private String topicCost; @@ -88,6 +97,7 @@ public class SarLawsTopic implements Serializable { /** * 协议 */ + @CompareField(fieldName = "协议文件") @ApiModelProperty("协议文件") @TableField(value = "AGREEMENT") private String agreement; @@ -99,6 +109,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组会议列表 */ + @CompareField(fieldName = "课题组会议列表") @ApiModelProperty(value = "课题组会议列表") @TableField(exist = false) private List meetingList; @@ -106,6 +117,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组研究方案 */ + @CompareField(fieldName = "researchPlan") @ApiModelProperty(value = "课题研究方案") @TableField(value = "RESEARCH_PLAN") private String researchPlan; @@ -117,6 +129,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组研究成果 */ + @CompareField(fieldName = "课题组研究成果") @ApiModelProperty(value = "课题组研究成果") @TableField(value = "RESEARCH_FINDINGS") private String researchFindings; @@ -131,6 +144,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组其他 */ + @CompareField(fieldName = "课题组其他文件") @ApiModelProperty(value = "课题组其他文件") @TableField(value = "RESEARCH_GROUP_OTHER") private String researchGroupOther; @@ -142,6 +156,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组会议资料 */ + @CompareField(fieldName = "课题组会议资料") @ApiModelProperty(value = "课题组会议资料") @TableField(value = "CONFERENCE_MATERIALS") private String conferenceMaterials; @@ -153,6 +168,7 @@ public class SarLawsTopic implements Serializable { /** * 课题组联系方式 */ + @CompareField(fieldName = "课题组联系方式") @ApiModelProperty(value = "课题组联系方式列表") @TableField(exist = false) private List topicContactInformationList; @@ -160,6 +176,7 @@ public class SarLawsTopic implements Serializable { /** * 内部资料立项报告 */ + @CompareField(fieldName = "内部资料立项报告") @ApiModelProperty(value = "内部资料立项报告") @TableField(value = "INSIDE_PROJECT_PROPOSAL_REPORT") private String insideProjectProposalRepost; @@ -171,6 +188,7 @@ public class SarLawsTopic implements Serializable { /** * 内部资料研究方案 */ + @CompareField(fieldName = "内部资料研究方案") @ApiModelProperty(value = "内部资料研究方案") @TableField(value = "INSIDE_RESEARCH_PLAN") private String insideResearchPlan; @@ -182,6 +200,7 @@ public class SarLawsTopic implements Serializable { /** * 内部资料会议资料 */ + @CompareField(fieldName = "内部资料会议资料") @ApiModelProperty(value = "内部资料会议资料") @TableField(value = "INSIDE_CONFERENCE_MATERIALS") private String insideConferenceMaterials; @@ -193,6 +212,7 @@ public class SarLawsTopic implements Serializable { /** * 内部会议研究成果 */ + @CompareField(fieldName = "内部会议研究成果") @ApiModelProperty(value = "内部会议研究成果") @TableField(value = "INSIDE_RESEARCH_FINDINGS") private String insideResearchFindings; @@ -204,6 +224,7 @@ public class SarLawsTopic implements Serializable { /** * 内部会议其他 */ + @CompareField(fieldName = "内部会议其他文件") @ApiModelProperty(value = "内部会议其他文件") @TableField(value = "INSIDE_OTHER") private String insideOther; @@ -215,6 +236,7 @@ public class SarLawsTopic implements Serializable { /** * 内部联系方式 */ + @CompareField(fieldName = "内部联系方式列表") @ApiModelProperty(value = "内部联系方式列表") @TableField(exist = false) private List insideContactInformationList; diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicMeeting.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicMeeting.java index cd7d6cde..fcb1ff22 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicMeeting.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/entity/SarLawsTopicMeeting.java @@ -1,6 +1,7 @@ package com.adc.da.slrs.sarLawsTopic.entity; import cn.afterturn.easypoi.excel.annotation.Excel; +import com.adc.da.utils.annotation.CompareField; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; @@ -31,6 +32,7 @@ public class SarLawsTopicMeeting implements Serializable { /** * 会议名称 */ + @CompareField(fieldName = "会议名称") @TableField(value = "MEETING_NAME") @Excel(name = "会议名称", orderNum = "0", type = 1) private String meetingName; @@ -38,6 +40,7 @@ public class SarLawsTopicMeeting implements Serializable { /** * 会议时间 */ + @CompareField(fieldName = "会议时间") @TableField(value = "MEETING_TIME") @Excel(name = "会议时间", orderNum = "1", type = 1) private String meetingTime; @@ -45,6 +48,7 @@ public class SarLawsTopicMeeting implements Serializable { /** * 会议地点 */ + @CompareField(fieldName = "会议地点") @TableField(value = "MEETING_ADDRESS") @Excel(name = "会议地点", orderNum = "2", type = 1) private String meetingAddress; @@ -52,6 +56,7 @@ public class SarLawsTopicMeeting implements Serializable { /** * 参会人员(内部) */ + @CompareField(fieldName = "参会人员(内部)") @TableField(value = "PARTICIPANTS") @Excel(name = "参会人员(内部)", orderNum = "3", type = 1) private String participants; @@ -59,6 +64,7 @@ public class SarLawsTopicMeeting implements Serializable { /** * 会议主要内容 */ + @CompareField(fieldName = "会议主要内容") @TableField(value = "MEETING_CONTENT") @Excel(name = "会议主要内容", orderNum = "4", type = 1) private String meetingContent; diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicMeetingService.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicMeetingService.java index 0b79192f..e449f900 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicMeetingService.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/SarLawsTopicMeetingService.java @@ -3,6 +3,8 @@ package com.adc.da.slrs.sarLawsTopic.service; import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicMeeting; import com.baomidou.mybatisplus.extension.service.IService; +import java.util.List; + /** * @author tjzdw * @description 针对表【sar_laws_topic_meeting(政策课题组会议)】的数据库操作Service @@ -10,4 +12,6 @@ import com.baomidou.mybatisplus.extension.service.IService; */ public interface SarLawsTopicMeetingService extends IService { + public List compareTopicMeeting(SarLawsTopicMeeting oldTopicMeeting, SarLawsTopicMeeting newTopicMeeting); + } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicMeetingServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicMeetingServiceImpl.java index c694e6ba..7d9e7683 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicMeetingServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicMeetingServiceImpl.java @@ -1,11 +1,17 @@ package com.adc.da.slrs.sarLawsTopic.service.impl; +import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic; +import com.adc.da.utils.annotation.CompareField; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopicMeeting; import com.adc.da.slrs.sarLawsTopic.service.SarLawsTopicMeetingService; import com.adc.da.slrs.sarLawsTopic.dao.SarLawsTopicMeetingMapper; import org.springframework.stereotype.Service; +import java.lang.reflect.Field; +import java.text.SimpleDateFormat; +import java.util.*; + /** * @author tjzdw * @description 针对表【sar_laws_topic_meeting(政策课题组会议)】的数据库操作Service实现 @@ -15,6 +21,35 @@ import org.springframework.stereotype.Service; public class SarLawsTopicMeetingServiceImpl extends ServiceImpl implements SarLawsTopicMeetingService{ + public List compareTopicMeeting(SarLawsTopicMeeting oldTopicMeeting, SarLawsTopicMeeting newTopicMeeting) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + List changes = new ArrayList<>(); + // 获取TopicMeeting类的所有字段 + Field[] fields = SarLawsTopic.class.getDeclaredFields(); + for (Field field : fields) { + boolean annotationPresent = field.isAnnotationPresent(CompareField.class); + if (annotationPresent) { + try { + field.setAccessible(true); + Object oldValue = field.get(oldTopicMeeting); + Object newValue = field.get(newTopicMeeting); + if (oldValue instanceof Date && newValue instanceof Date) { + oldValue = sdf.format((Date)oldValue); + newValue = sdf.format((Date)newValue); + } + if (!Objects.equals(oldValue, newValue)) { + // 对比其他字段 + CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0]; + changes.add(annotationsByType.fieldName() + "由\"" + oldValue + "\"改为\"" + newValue + "\""); + } + } catch (IllegalAccessException e) { + // 处理异常 + e.printStackTrace(); + } + } + } + return changes; + } } diff --git a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicServiceImpl.java b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicServiceImpl.java index ba03c0d9..bd73fb58 100644 --- a/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicServiceImpl.java +++ b/adc-da-slrs/src/main/java/com/adc/da/slrs/sarLawsTopic/service/impl/SarLawsTopicServiceImpl.java @@ -17,6 +17,7 @@ import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog; import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService; import com.adc.da.util.LoginUserUtil; import com.adc.da.util.UUIDUtils; +import com.adc.da.utils.annotation.CompareField; import com.adc.da.utils.util.FieldConvertUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -168,6 +169,9 @@ public class SarLawsTopicServiceImpl extends ServiceImpl compareLawsTopic(SarLawsTopic oldLawsTopic, SarLawsTopic newLawsTopic) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); List changes = new ArrayList<>(); - // 不需要比较的字段 - String[] ignoreFields = {"id","validFlag","createTime","modifyTime","agreementList","researchPlanList", - "researchFindingsList","researchGroupOtherList","conferenceMaterialsList","insideProjectProposalRepostList", - "insideResearchPlanList","insideConferenceMaterialsList","insideResearchFindingsList","insideOtherList","serialVersionUID"}; + // 文件字段 String[] fileAttIdFields = {"agreement","researchPlan","researchFindings","researchGroupOther","conferenceMaterials", "insideProjectProposalRepost","insideResearchPlan","insideConferenceMaterials","insideResearchFindings","insideOther"}; - List ignoreFieldList = Arrays.asList(ignoreFields); List fileAttIdFieldList = Arrays.asList(fileAttIdFields); // 获取SarLawsTopic类的所有字段 Field[] fields = SarLawsTopic.class.getDeclaredFields(); for (Field field : fields) { - if (!ignoreFieldList.contains(field.getName())) { + boolean annotationPresent = field.isAnnotationPresent(CompareField.class); + if (annotationPresent) { try { field.setAccessible(true); Object oldValue = field.get(oldLawsTopic); Object newValue = field.get(newLawsTopic); + if (oldValue instanceof Date && newValue instanceof Date) { + oldValue = sdf.format((Date)oldValue); + newValue = sdf.format((Date)newValue); + } if (!Objects.equals(oldValue, newValue)) { // 对比文件字段 if (fileAttIdFieldList.contains(field.getName())) { @@ -555,31 +561,27 @@ public class SarLawsTopicServiceImpl extends ServiceImpl oldLawsTopicList = (List) oldInvoke; + List newLawsTopicList = (List) newInvoke; + isListEqual(oldLawsTopicList, newLawsTopicList); + } else if ("topicContactInformationList".equals(field.getName()) || "insideContactInformationList".equals(field.getName())) { + CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0]; + changes.add(annotationsByType.fieldName() + "被变更"); + } else { // 对比其他字段 - ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0]; - changes.add(annotationsByType.value() + "由\"" + oldValue + "\"改为\"" + newValue + "\""); + CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0]; + changes.add(annotationsByType.fieldName() + "由\"" + oldValue + "\"改为\"" + newValue + "\""); } } } catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) { @@ -635,6 +637,27 @@ public class SarLawsTopicServiceImpl extends ServiceImpl