浏览代码

修改生成月份的问题

王昭 2 年之前
父节点
当前提交
dcb9054c5c
共有 1 个文件被更改,包括 8 次插入1 次删除
  1. 8 1
      mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPreVisitServiceImpl.java

+ 8 - 1
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentPreVisitServiceImpl.java

@@ -16,6 +16,7 @@ import com.ym.mec.util.date.DateUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
 import java.util.*;
 
 @Service
@@ -41,7 +42,13 @@ public class StudentPreVisitServiceImpl extends BaseServiceImpl<Integer, Student
 			studentPreVisit.setTeacherId(student4operating.getTeacherId());
 			studentPreVisit.setTeacherName(student4operating.getTeacherName());
 			studentPreVisit.setOrgname(student4operating.getOrganName());
-			studentPreVisit.setVisitCycle(DateUtil.format(new Date(),"yyyy-MM"));
+			SimpleDateFormat sf=new SimpleDateFormat("yyyy-MM");
+			GregorianCalendar gc=new GregorianCalendar();
+			gc.setTime(new Date());
+			gc.add(2,-1);
+			String format = sf.format(gc.getTime());
+			//这里月份进行了减一,因为生成的上月的数据
+			studentPreVisit.setVisitCycle(format);
 			studentPreVisit.setIsVisit(0);
 			studentPreVisits.add(studentPreVisit);
 		}