zouxuan 3 роки тому
батько
коміт
590002b649

+ 1 - 1
mec-biz/src/main/java/com/ym/mec/biz/dal/dao/StudentOperatingVisitDao.java

@@ -16,7 +16,7 @@ public interface StudentOperatingVisitDao extends BaseDAO<Long, StudentOperating
     */
     void updateVisit(@Param("studentId") Integer studentId);
 
-    void deleteByUserId(@Param("userIds") List<Integer> userIds, @Param("month") String month);
+    void deleteByUserId(@Param("month") String month);
 
     void batchAdd(@Param("userIds") List<Integer> userIds, @Param("month") String month);
 

+ 12 - 17
mec-biz/src/main/java/com/ym/mec/biz/service/impl/StudentServiceImpl.java

@@ -224,8 +224,9 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public boolean updateOperatingTempTag() {
-        List<StudentCourseTimesDto> studentCourseTimesDtoList = courseScheduleStudentPaymentDao.queryStudentNotStartCourseTimesOfOnline();
+        /*List<StudentCourseTimesDto> studentCourseTimesDtoList = courseScheduleStudentPaymentDao.queryStudentNotStartCourseTimesOfOnline();
         Map<Integer, StudentCourseTimesDto> map = studentCourseTimesDtoList.stream().collect(Collectors.toMap(StudentCourseTimesDto::getUserId, s -> s));
         //查询服务指标为0的用户
         List<Student> unlabeledStudentList = studentDao.queryByOperatingTempTag(0);
@@ -254,23 +255,17 @@ public class StudentServiceImpl extends BaseServiceImpl<Integer, Student> implem
                 s.setOperatingTag(0);
                 updateStudentList.add(s);
             }
-        }
-
-        if (updateStudentList.size() > 0) {
-            studentDao.batchUpdate(updateStudentList);
-            String month = DateUtil.format(new Date(), DateUtil.ISO_YEAR_MONTH_FORMAT);
-            List<Integer> operatingUserIds0 = updateStudentList.stream().filter(e -> e.getOperatingTag().equals(0)).map(e -> e.getUserId()).collect(Collectors.toList());
-            if(!CollectionUtils.isEmpty(operatingUserIds0)){
-                studentOperatingVisitDao.deleteByUserId(operatingUserIds0,month);
-            }
-            List<Integer> operatingUserIds = updateStudentList.stream().filter(e -> e.getOperatingTag().equals(1)).map(e -> e.getUserId()).collect(Collectors.toList());
+        }*/
+        String month = DateUtil.format(new Date(), DateUtil.ISO_YEAR_MONTH_FORMAT);
+        studentOperatingVisitDao.deleteByUserId(month);
+        List<Student> updateStudentList = studentDao.queryByOperatingTempTag(1);
+        if (!CollectionUtils.isEmpty(updateStudentList)) {
+            List<Integer> operatingUserIds = updateStudentList.stream().map(e -> e.getUserId()).collect(Collectors.toList());
+            List<Integer> userIds = studentOperatingVisitDao.queryUserIds(month);
+            operatingUserIds.removeAll(userIds);
             if(!CollectionUtils.isEmpty(operatingUserIds)){
-                List<Integer> userIds = studentOperatingVisitDao.queryUserIds(month);
-                operatingUserIds.removeAll(userIds);
-                if(!CollectionUtils.isEmpty(operatingUserIds)){
-                    //需要新增的用户
-                    studentOperatingVisitDao.batchAdd(operatingUserIds,month);
-                }
+                //需要新增的用户
+                studentOperatingVisitDao.batchAdd(operatingUserIds,month);
             }
         }
         return true;

+ 4 - 4
mec-biz/src/main/resources/config/mybatis/StudentOperatingVisitMapper.xml

@@ -67,10 +67,10 @@ month_ = #{month},
 		DELETE FROM student_operating_visit WHERE id_ = #{id} 
 	</delete>
 	<delete id="deleteByUserId">
-		DELETE FROM student_operating_visit WHERE user_id_ NOT IN
-		<foreach collection="userIds" item="item" open="(" separator="," close=")">
-			#{item}
-		</foreach>
+		delete from student_operating_visit where id_ IN (
+		SELECT a.id_ FROM (select sov.id_ from student_operating_visit sov
+		left join student s ON s.user_id_ = sov.user_id_
+		where s.operating_tag_ = 0 AND sov.month_ = #{month})a)
 	</delete>
 
 	<!-- 分页查询 -->