|
@@ -1,6 +1,21 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
+import java.text.ParseException;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import com.ym.mec.biz.dal.dao.CourseScheduleStudentPaymentDao;
|
|
|
import com.ym.mec.biz.dal.dao.StudentDao;
|
|
|
+import com.ym.mec.biz.dal.dto.StudentCourseTimesDto;
|
|
|
import com.ym.mec.biz.dal.entity.Student;
|
|
|
import com.ym.mec.biz.dal.page.StudentQueryInfo;
|
|
|
import com.ym.mec.biz.service.StudentService;
|
|
@@ -8,17 +23,15 @@ import com.ym.mec.common.dal.BaseDAO;
|
|
|
import com.ym.mec.common.page.PageInfo;
|
|
|
import com.ym.mec.common.service.impl.BaseServiceImpl;
|
|
|
import com.ym.mec.util.collection.MapUtil;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
-import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implements StudentService {
|
|
|
|
|
|
@Autowired
|
|
|
private StudentDao studentDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CourseScheduleStudentPaymentDao courseScheduleStudentPaymentDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, Student> getDAO() {
|
|
@@ -56,4 +69,32 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
|
|
|
return student.getUserId().longValue();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public boolean updateOperatingTag() throws ParseException {
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = sdf.parse("2020-02-08");
|
|
|
+ List<StudentCourseTimesDto> studentCourseTimesDtoList = courseScheduleStudentPaymentDao.queryStudentCourseTimesOfOnline(date);
|
|
|
+ Map<Integer,StudentCourseTimesDto> map = studentCourseTimesDtoList.stream().collect(Collectors.toMap(StudentCourseTimesDto::getUserId, s -> s));
|
|
|
+ //查询服务指标为0的用户
|
|
|
+ List<Student> studentList = studentDao.queryByOperatingTag(0);
|
|
|
+
|
|
|
+ List<Student> updateStudentList = new ArrayList<Student>();
|
|
|
+ StudentCourseTimesDto dto = null;
|
|
|
+ for(Student s : studentList){
|
|
|
+ dto = map.get(s.getUpdateTime());
|
|
|
+ if(dto != null){
|
|
|
+ if(dto.getTotalCourseTimes() != dto.getFreePracticeCourseTimes()){
|
|
|
+ updateStudentList.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(updateStudentList.size() > 0){
|
|
|
+ studentDao.batchUpdate(updateStudentList);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|