bug: 内外部会议修改记录代码修改

This commit is contained in:
wxyclub
2023-11-27 11:36:18 +08:00
parent f0277ac730
commit 30cd5bf35e
2 changed files with 71 additions and 22 deletions
@@ -2,6 +2,7 @@ package com.adc.da.slrs.InsideOntSideMeeting.entity;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.base.entity.BaseEntity;
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;
@@ -35,6 +36,7 @@ public class InsideOutsideMeeting extends BaseEntity {
@TableId(value = "ID", type = IdType.ID_WORKER_STR)
private String id;
@CompareField(fieldName = "会议名称")
@ApiModelProperty(value = "会议名称")
@TableField("MEETING_NAME")
private String meetingName;
@@ -42,27 +44,33 @@ public class InsideOutsideMeeting extends BaseEntity {
/**
* 课题名称,可通过调取功能从政策课题模块中获取
*/
@CompareField(fieldName = "课题名称")
@ApiModelProperty(value = "课题名称")
@TableField("TOPIC_NAME")
private String topicName;
@CompareField(fieldName = "会议主办单位")
@ApiModelProperty(value = "会议主办单位")
@TableField("MEETING_ORGANIZER")
private String meetingOrganizer;
@CompareField(fieldName = "会议时间")
@ApiModelProperty(value = "会议时间")
@TableField("MEETING_TIME")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
private Date meetingTime;
@CompareField(fieldName = "会议地点")
@ApiModelProperty(value = "会议地点")
@TableField("MEETING_ADDRESS")
private String meetingAddress;
@CompareField(fieldName = "参会人员")
@ApiModelProperty(value = "参会人员")
@TableField("PARTICIPANTS")
private String participants;
@CompareField(fieldName = "会议纪要")
@ApiModelProperty(value = "会议纪要")
@TableField("MEETING_MINUTES")
private String meetingMinutes;
@@ -71,10 +79,12 @@ public class InsideOutsideMeeting extends BaseEntity {
@TableField(exist = false)
private List<AttFileEO> meetingMinutesList;
@CompareField(fieldName = "会议主要内容")
@ApiModelProperty(value = "会议主要内容")
@TableField("MEETING_CONTENT")
private String meetingContent;
@CompareField(fieldName = "1级会议分类")
@ApiModelProperty(value = "1级会议分类")
@TableField("FIRST_MEETING_TYPE")
private String firstMeetingType;
@@ -83,6 +93,7 @@ public class InsideOutsideMeeting extends BaseEntity {
@TableField(exist = false)
private String firstMeetingTypeName;
@CompareField(fieldName = "2级会议分类")
@ApiModelProperty(value = "2级会议分类")
@TableField("SECOND_MEETING_TYPE")
private String secondMeetingType;
@@ -91,6 +102,7 @@ public class InsideOutsideMeeting extends BaseEntity {
@TableField(exist = false)
private String secondMeetingTypeName;
@CompareField(fieldName = "会议议题")
@ApiModelProperty(value = "会议议题")
@TableField(exist = false)
private List<MeetingTopic> meetingTopicList;
@@ -13,12 +13,14 @@ import com.adc.da.slrs.InsideOntSideMeeting.entity.MeetingTopic;
import com.adc.da.slrs.InsideOntSideMeeting.service.InsideOutsideMeetingService;
import com.adc.da.slrs.InsideOntSideMeeting.service.MeetingTopicService;
import com.adc.da.slrs.sarLawsInformation.entity.SarLawsInformation;
import com.adc.da.slrs.sarLawsTopic.entity.SarLawsTopic;
import com.adc.da.slrs.sarUpdLog.entity.SarUpdLog;
import com.adc.da.slrs.sarUpdLog.service.ISarUpdLogService;
import com.adc.da.slrs.tsDictionaryType.entity.TsDicType;
import com.adc.da.slrs.tsDictionaryType.service.ITsDicTypeService;
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;
@@ -527,34 +529,43 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
* @return 差异
*/
public List<String> compareInsideOutsideMeeting(InsideOutsideMeeting oldMeeting, InsideOutsideMeeting newMeeting) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<String> changes = new ArrayList<>();
// 不需要比较的字段
String[] ignoreFields = {"id","validFlag","createTime","modifyTime","meetingMinutesList", "firstMeetingTypeName", "secondMeetingTypeName"};
List<String> ignoreFieldList = Arrays.asList(ignoreFields);
// 获取SarLawsInformation类的所有字段
Field[] fields = InsideOutsideMeeting.class.getDeclaredFields();
for (Field field : fields) {
if (!ignoreFieldList.contains(field.getName())) {
boolean annotationPresent = field.isAnnotationPresent(CompareField.class);
if (annotationPresent) {
try {
field.setAccessible(true);
String oldValue = String.valueOf(field.get(oldMeeting));
String newValue = String.valueOf(field.get(newMeeting));
Object oldValue = field.get(oldMeeting);
Object newValue = field.get(newMeeting);
if (oldValue instanceof Date){
oldValue = sdf.format((Date)oldValue);
}
if( newValue instanceof Date) {
newValue = sdf.format((Date)newValue);
}
if (!Objects.equals(oldValue, newValue)) {
if ("firstMeetingType".equals(field.getName()) || "secondMeetingType".equals(field.getName())) {
String oldValueStr = String.valueOf(oldValue);
String newValueStr = String.valueOf(newValue);
String typeName = "";
if (StringUtils.isNotBlank(newValue)) {
typeName = dicTypeService.getDicTypeNameByDicCode(newValue);
if (StringUtils.isNotBlank(newValueStr)) {
typeName = dicTypeService.getDicTypeNameByDicCode(newValueStr);
}
// 获取资料类型名称
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
Method method = InsideOutsideMeeting.class.getMethod("get" + fieldName + "Name");
Object oldTypeName = method.invoke(oldMeeting);
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + oldTypeName + "\"改为\"" + typeName + "\"");
CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0];
changes.add(annotationsByType.fieldName() + "\"" + oldTypeName + "\"改为\"" + typeName + "\"");
} else if ("meetingMinutes".equals(field.getName())) {
String oldValueStr = String.valueOf(oldValue);
String newValueStr = String.valueOf(newValue);
List<String> fileNameList = new ArrayList<>();
if (StringUtils.isNotBlank(newValue)) {
String[] split = newValue.split(",");
if (StringUtils.isNotBlank(newValueStr)) {
String[] split = newValueStr.split(",");
for (String attId : split) {
AttFileEO fileInfo = attFileEOService.getFileInfo(attId);
fileNameList.add(fileInfo.getOldFileName());
@@ -572,16 +583,22 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
}
}
// 获取字段名称
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "\"" + String.join(",",oldFileNameList) + "\"改为\"" + String.join(",",fileNameList) + "\"");
}
else if ("meetingTopicList".equals(field.getName())) {
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
changes.add(annotationsByType.value() + "被变更");
}
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() + "\"" + String.join(",",oldFileNameList) + "\"改为\"" + String.join(",",fileNameList) + "\"");
} else if ("meetingTopicList".equals(field.getName())) {
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
Method method = InsideOutsideMeeting.class.getMethod("get" + fieldName);
Object oldInvoke = method.invoke(oldMeeting);
Object newInvoke = method.invoke(newMeeting);
List<?> oldList = (List<?>) oldInvoke;
List<?> newList = (List<?>) newInvoke;
if (!isListEqual(oldList, newList)) {
CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0];
changes.add(annotationsByType.fieldName() + "被变更");
}
} else {
CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0];
changes.add(annotationsByType.fieldName() + "\"" + oldValue + "\"改为\"" + newValue + "\"");
}
}
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e) {
@@ -640,4 +657,24 @@ public class InsideOutsideMeetingServiceImpl extends ServiceImpl<InsideOutsideMe
}
return null;
}
public boolean isListEqual(List l0, List l1){
if (l0 == l1)
return true;
if (l0 == null && l1 == null)
return true;
if (l0 == null || l1 == null)
return false;
if (l0.size() != l1.size())
return false;
for (Object o : l0) {
if (!l1.contains(o))
return false;
}
for (Object o : l1) {
if (!l0.contains(o))
return false;
}
return true;
}
}