fix: 政策课题修改记录代码修改
This commit is contained in:
@@ -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<SarLawsTopicMeeting> 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<SarLawsContactInformation> 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<SarLawsContactInformation> insideContactInformationList;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+4
@@ -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<SarLawsTopicMeeting> {
|
||||
|
||||
public List<String> compareTopicMeeting(SarLawsTopicMeeting oldTopicMeeting, SarLawsTopicMeeting newTopicMeeting);
|
||||
|
||||
}
|
||||
|
||||
+35
@@ -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<SarLawsTopicMeetingMapper, SarLawsTopicMeeting>
|
||||
implements SarLawsTopicMeetingService{
|
||||
|
||||
public List<String> compareTopicMeeting(SarLawsTopicMeeting oldTopicMeeting, SarLawsTopicMeeting newTopicMeeting) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<String> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+51
-28
@@ -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<SarLawsTopicMapper, Sar
|
||||
return true;
|
||||
}
|
||||
lawsTopic.setModifyTime(new Date());
|
||||
for (String s : compareList) {
|
||||
log.error("====================变更项====================" + s);
|
||||
}
|
||||
int update = this.baseMapper.updateById(lawsTopic);
|
||||
// 比较列表字段是否经过修改,如果经过修改,先删除,再添加
|
||||
if (compareList.contains("课题组会议列表被变更")) {
|
||||
@@ -512,23 +516,25 @@ public class SarLawsTopicServiceImpl extends ServiceImpl<SarLawsTopicMapper, Sar
|
||||
* @return 差异
|
||||
*/
|
||||
public List<String> compareLawsTopic(SarLawsTopic oldLawsTopic, SarLawsTopic newLawsTopic) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
List<String> 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<String> ignoreFieldList = Arrays.asList(ignoreFields);
|
||||
List<String> 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<SarLawsTopicMapper, Sar
|
||||
}
|
||||
}
|
||||
// 获取字段名称
|
||||
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
|
||||
changes.add(annotationsByType.value() + "由\"" + String.join(",",oldFileNameList) + "\"改为\"" + String.join(",",fileNameList) + "\"");
|
||||
CompareField annotationsByType = field.getAnnotationsByType(CompareField.class)[0];
|
||||
changes.add(annotationsByType.fieldName() + "由\"" + String.join(",",oldFileNameList) + "\"改为\"" + String.join(",",fileNameList) + "\"");
|
||||
// 对比列表字段
|
||||
} else if ("meetingList".equals(field.getName()) || "topicContactInformationList".equals(field.getName())
|
||||
|| "insideContactInformationList".equals(field.getName())) {
|
||||
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
|
||||
changes.add(annotationsByType.value() + "被变更");
|
||||
} else if ("startTime".equals(field.getName()) || "closeTime".equals(field.getName())) {
|
||||
ApiModelProperty annotationsByType = field.getAnnotationsByType(ApiModelProperty.class)[0];
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String oldDateStr = null;
|
||||
String newDateStr = null;
|
||||
if (oldValue != null) {
|
||||
Date oldDate = (Date) oldValue;
|
||||
oldDateStr = sdf.format(oldDate);
|
||||
} else if ("meetingList".equals(field.getName())) {
|
||||
String fieldName = field.getName().substring(0, 1).toUpperCase() + field.getName().substring(1);
|
||||
Method method = SarLawsTopic.class.getMethod("get" + fieldName + "List");
|
||||
Object oldInvoke = method.invoke(oldLawsTopic);
|
||||
Object newInvoke = method.invoke(newLawsTopic);
|
||||
if (oldInvoke == null && newInvoke == null) {
|
||||
continue;
|
||||
}
|
||||
if (newValue!= null) {
|
||||
Date newDate = (Date) newValue;
|
||||
newDateStr = sdf.format(newDate);
|
||||
}
|
||||
changes.add(annotationsByType.value() + "由\"" + oldDateStr + "\"改为\"" + newDateStr + "\"");
|
||||
}else {
|
||||
List<SarLawsTopicMeeting> oldLawsTopicList = (List<SarLawsTopicMeeting>) oldInvoke;
|
||||
List<SarLawsTopicMeeting> newLawsTopicList = (List<SarLawsTopicMeeting>) 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<SarLawsTopicMapper, Sar
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.adc.da.utils.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface CompareField {
|
||||
String fieldName() default "";
|
||||
}
|
||||
Reference in New Issue
Block a user