|
@@ -2,10 +2,13 @@ package com.ruoyi.project.VRdemo.domain.imData;
|
|
|
|
|
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
|
import com.alibaba.excel.annotation.ExcelIgnore;
|
|
import com.alibaba.excel.annotation.ExcelProperty;
|
|
import com.alibaba.excel.annotation.ExcelProperty;
|
|
-import com.fasterxml.jackson.annotation.JsonFormat;
|
|
|
|
|
|
+import com.ruoyi.common.utils.StringUtils;
|
|
import com.ruoyi.common.utils.excel.DataConverter;
|
|
import com.ruoyi.common.utils.excel.DataConverter;
|
|
import com.ruoyi.project.VRdemo.domain.Thesis;
|
|
import com.ruoyi.project.VRdemo.domain.Thesis;
|
|
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
|
public class ThesisImData implements BaseImData<ThesisImData, Thesis> {
|
|
public class ThesisImData implements BaseImData<ThesisImData, Thesis> {
|
|
@@ -28,17 +31,50 @@ public class ThesisImData implements BaseImData<ThesisImData, Thesis> {
|
|
@ExcelProperty("关键词")
|
|
@ExcelProperty("关键词")
|
|
private String keyword;
|
|
private String keyword;
|
|
|
|
|
|
- @JsonFormat(pattern = "yyyy")
|
|
|
|
|
|
+ // @JsonFormat(pattern = "yyyy")
|
|
@ExcelProperty("答辩时间")
|
|
@ExcelProperty("答辩时间")
|
|
- private Date replyTime;
|
|
|
|
|
|
+ private String replyTime;
|
|
|
|
|
|
@ExcelProperty("学位")
|
|
@ExcelProperty("学位")
|
|
private String degree;
|
|
private String degree;
|
|
|
|
|
|
|
|
+ private static Date getDate(String replyTime) {
|
|
|
|
+ Date finalDate;
|
|
|
|
+ try {
|
|
|
|
+ // 根据输入字符串的长度选择合适的日期格式
|
|
|
|
+ SimpleDateFormat sdfInput;
|
|
|
|
+ if (replyTime.contains(".")) {
|
|
|
|
+ sdfInput = new SimpleDateFormat("yyyy.M");
|
|
|
|
+ } else {
|
|
|
|
+ sdfInput = new SimpleDateFormat("yyyy");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 设置lenient为false以进行严格的解析
|
|
|
|
+ sdfInput.setLenient(false);
|
|
|
|
+ // 解析日期字符串
|
|
|
|
+ Date date = sdfInput.parse(replyTime);
|
|
|
|
+ // 创建Calendar实例并设置年份和月份
|
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
|
+ calendar.setTime(date);
|
|
|
|
+ // 设置日期为每个月的第一天
|
|
|
|
+ calendar.set(Calendar.DAY_OF_MONTH, 1);
|
|
|
|
+ // 获取最终的日期
|
|
|
|
+ finalDate = calendar.getTime();
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ throw new RuntimeException("无法解析日期字符串: " + replyTime, e);
|
|
|
|
+ }
|
|
|
|
+ return finalDate;
|
|
|
|
+ }
|
|
|
|
+
|
|
@ExcelIgnore
|
|
@ExcelIgnore
|
|
DataConverter<ThesisImData, Thesis> converter = new DataConverter<>() {
|
|
DataConverter<ThesisImData, Thesis> converter = new DataConverter<>() {
|
|
@Override
|
|
@Override
|
|
protected Thesis convert(ThesisImData thesisImData) {
|
|
protected Thesis convert(ThesisImData thesisImData) {
|
|
|
|
+ Date finalDate = null;
|
|
|
|
+ if (!StringUtils.isEmpty(thesisImData.getReplyTime())) {
|
|
|
|
+ finalDate = getDate(thesisImData.getReplyTime());
|
|
|
|
+ }
|
|
|
|
+
|
|
Thesis thesis = new Thesis();
|
|
Thesis thesis = new Thesis();
|
|
thesis.setId(thesisImData.getId());
|
|
thesis.setId(thesisImData.getId());
|
|
thesis.setName(thesisImData.getName());
|
|
thesis.setName(thesisImData.getName());
|
|
@@ -46,7 +82,7 @@ public class ThesisImData implements BaseImData<ThesisImData, Thesis> {
|
|
thesis.setMajor(thesisImData.getMajor());
|
|
thesis.setMajor(thesisImData.getMajor());
|
|
thesis.setTitle(thesisImData.getTitle());
|
|
thesis.setTitle(thesisImData.getTitle());
|
|
thesis.setKeyword(thesisImData.getKeyword());
|
|
thesis.setKeyword(thesisImData.getKeyword());
|
|
- thesis.setReplyTime(thesisImData.getReplyTime());
|
|
|
|
|
|
+ thesis.setReplyTime(finalDate);
|
|
thesis.setDegree(thesisImData.getDegree());
|
|
thesis.setDegree(thesisImData.getDegree());
|
|
return thesis;
|
|
return thesis;
|
|
}
|
|
}
|
|
@@ -73,11 +109,11 @@ public class ThesisImData implements BaseImData<ThesisImData, Thesis> {
|
|
this.name = name;
|
|
this.name = name;
|
|
}
|
|
}
|
|
|
|
|
|
- public Date getReplyTime() {
|
|
|
|
|
|
+ public String getReplyTime() {
|
|
return replyTime;
|
|
return replyTime;
|
|
}
|
|
}
|
|
|
|
|
|
- public void setReplyTime(Date replyTime) {
|
|
|
|
|
|
+ public void setReplyTime(String replyTime) {
|
|
this.replyTime = replyTime;
|
|
this.replyTime = replyTime;
|
|
}
|
|
}
|
|
|
|
|