|
@@ -1,19 +1,23 @@
|
|
|
package com.ym.mec.biz.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ym.mec.auth.api.entity.SysUser;
|
|
|
import com.ym.mec.biz.dal.dao.*;
|
|
|
+import com.ym.mec.biz.dal.dto.CourseConvertLogDto;
|
|
|
import com.ym.mec.biz.dal.entity.*;
|
|
|
+import com.ym.mec.biz.dal.page.ConvertLogQueryInfo;
|
|
|
import com.ym.mec.biz.service.CourseConvertLogService;
|
|
|
import com.ym.mec.biz.service.SysUserService;
|
|
|
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.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Service
|
|
@@ -31,6 +35,8 @@ public class CourseConvertLogServiceImpl extends BaseServiceImpl<Integer, Course
|
|
|
private TeacherAttendanceDao teacherAttendanceDao;
|
|
|
@Autowired
|
|
|
private SysUserService sysUserService;
|
|
|
+ @Autowired
|
|
|
+ private ClassGroupDao classGroupDao;
|
|
|
|
|
|
@Override
|
|
|
public BaseDAO<Integer, CourseConvertLog> getDAO() {
|
|
@@ -47,9 +53,10 @@ public class CourseConvertLogServiceImpl extends BaseServiceImpl<Integer, Course
|
|
|
public CourseConvertLog save(String oldCourseIds, List<Integer> newClassGroupIds, List<Long> courseIdList,
|
|
|
List<CourseScheduleTeacherSalary> teacherSalaries,
|
|
|
List<CourseScheduleStudentPayment> studentPayments) {
|
|
|
- Integer userId = sysUserService.getUserId();
|
|
|
+ SysUser user = sysUserService.getUser();
|
|
|
CourseConvertLog courseConvertLog = new CourseConvertLog();
|
|
|
- courseConvertLog.setOperator(userId);
|
|
|
+ courseConvertLog.setOperatorName(user.getRealName());
|
|
|
+ courseConvertLog.setOperator(user.getId());
|
|
|
courseConvertLog.setOldCourseIds(oldCourseIds);
|
|
|
String userIds = studentPayments.stream().map(e -> e.getUserId().toString()).distinct().collect(Collectors.joining(","));
|
|
|
courseConvertLog.setStudentIds(userIds);
|
|
@@ -67,7 +74,10 @@ public class CourseConvertLogServiceImpl extends BaseServiceImpl<Integer, Course
|
|
|
|
|
|
//获取课程列表
|
|
|
List<CourseSchedule> courseSchedules = courseScheduleDao.findByCourseScheduleIds(oldCourseIdList);
|
|
|
- courseConvertLog.setOldClassIds(courseSchedules.stream().map(e->e.getClassGroupId().toString()).distinct().collect(Collectors.joining(",")));
|
|
|
+ Integer oldClassId = courseSchedules.stream().map(e -> e.getClassGroupId()).findFirst().get();
|
|
|
+ ClassGroup classGroup = classGroupDao.get(oldClassId);
|
|
|
+ courseConvertLog.setOldClassId(oldClassId);
|
|
|
+ courseConvertLog.setOldClassName(classGroup.getName());
|
|
|
courseConvertLog.setOldCourseJson(JSONObject.toJSONString(courseSchedules));
|
|
|
//删除课程
|
|
|
courseScheduleDao.batchDeleteCourseSchedulesWithoutCheck(oldCourseIdList);
|
|
@@ -83,4 +93,29 @@ public class CourseConvertLogServiceImpl extends BaseServiceImpl<Integer, Course
|
|
|
courseConvertLogDao.insert(courseConvertLog);
|
|
|
return courseConvertLog;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageInfo<CourseConvertLogDto> queryConvertPage(ConvertLogQueryInfo queryInfo) {
|
|
|
+ PageInfo<CourseConvertLogDto> pageInfo = new PageInfo<>(queryInfo.getPage(), queryInfo.getRows());
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
+ MapUtil.populateMap(params, queryInfo);
|
|
|
+
|
|
|
+ List<CourseConvertLogDto> dataList = null;
|
|
|
+ int count = courseConvertLogDao.countConvertPage(params);
|
|
|
+ if (count > 0) {
|
|
|
+ pageInfo.setTotal(count);
|
|
|
+ params.put("offset", pageInfo.getOffset());
|
|
|
+ dataList = courseConvertLogDao.queryConvertPage(params);
|
|
|
+ for (CourseConvertLogDto dto : dataList) {
|
|
|
+ dto.setConvertCourseNum(dto.getOldCourseIds().split(",").length);
|
|
|
+ dto.setConvertAfterClassNum(dto.getNewClassIds().split(",").length);
|
|
|
+ dto.setConvertAfterCourseNum(dto.getNewCourseIds().split(",").length);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (count == 0) {
|
|
|
+ dataList = new ArrayList<>();
|
|
|
+ }
|
|
|
+ pageInfo.setRows(dataList);
|
|
|
+ return pageInfo;
|
|
|
+ }
|
|
|
}
|