Browse Source

修改生成月份的问题

王昭 2 years ago
parent
commit
dcb9054c5c

+ 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);
 		}