|
|
@@ -14,6 +14,7 @@ import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.google.gson.JsonArray;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import com.google.gson.JsonParser;
|
|
|
+import com.xjrsoft.common.enums.CourseAdjustTypeEnum;
|
|
|
import com.xjrsoft.common.enums.TimeNumberEnum;
|
|
|
import com.xjrsoft.common.enums.TimePeriodEnum;
|
|
|
import com.xjrsoft.common.enums.WeekEnum;
|
|
|
@@ -34,6 +35,8 @@ import com.xjrsoft.module.courseTable.service.ICourseTableService;
|
|
|
import com.xjrsoft.module.courseTable.vo.ClassListVo;
|
|
|
import com.xjrsoft.module.schedule.dto.CourseTableAdjustDto;
|
|
|
import com.xjrsoft.module.schedule.dto.CourseTableDto;
|
|
|
+import com.xjrsoft.module.schedule.entity.WfCourseAdjust;
|
|
|
+import com.xjrsoft.module.schedule.mapper.CourseTableBakMapper;
|
|
|
import com.xjrsoft.module.schedule.util.ScheduleUtil;
|
|
|
import com.xjrsoft.module.schedule.vo.CourseDetailVo;
|
|
|
import com.xjrsoft.module.schedule.vo.CourseListVo;
|
|
|
@@ -58,6 +61,7 @@ import java.time.LocalDateTime;
|
|
|
import java.time.ZoneId;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -88,6 +92,8 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
private final ClassTimeMapper classTimeMapper;
|
|
|
private final BaseSemesterMapper baseSemesterMapper;
|
|
|
|
|
|
+ private final CourseTableBakMapper courseTableBakMapper;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean wordImport(InputStream inputStream) throws IOException {
|
|
|
@@ -186,12 +192,13 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
tableVo.setSemesterName(baseSemester.getName());
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
//计算本周是第几周
|
|
|
+ LocalDateTime startDateTime = LocalDateTime.ofInstant(baseSemester.getStartDate().toInstant(), ZoneId.systemDefault());
|
|
|
+ LocalDateTime endDateTime = LocalDateTime.ofInstant(baseSemester.getEndDate().toInstant(), ZoneId.systemDefault());
|
|
|
+ Duration between = Duration.between(startDateTime, endDateTime);
|
|
|
+ long days = between.toDays();
|
|
|
+ int weeks = (int) Math.ceil((double) days / 7);
|
|
|
if(dto.getWeek() == null){
|
|
|
- LocalDateTime startDateTime = LocalDateTime.ofInstant(baseSemester.getStartDate().toInstant(), ZoneId.systemDefault());
|
|
|
- LocalDateTime endDateTime = LocalDateTime.ofInstant(baseSemester.getEndDate().toInstant(), ZoneId.systemDefault());
|
|
|
- Duration between = Duration.between(startDateTime, endDateTime);
|
|
|
- long days = between.toDays();
|
|
|
- int weeks = (int) Math.ceil((double) days / 7);
|
|
|
+
|
|
|
for (int i = 0; i < weeks; i ++){
|
|
|
LocalDateTime startDate = startDateTime.plusDays(i * 7).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
LocalDateTime endDate = startDateTime.plusDays((i + 1) * 7).withHour(23).withMinute(59).withSecond(59).withNano(9999);
|
|
|
@@ -200,6 +207,10 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
+ LocalDateTime startDate = startDateTime.plusDays((dto.getWeek() - 1) * 7).withHour(0).withMinute(0).withSecond(0).withNano(0);
|
|
|
+ LocalDateTime endDate = startDateTime.plusDays(dto.getWeek() * 7).withHour(23).withMinute(59).withSecond(59).withNano(9999);
|
|
|
+ dto.setStartDate(startDate);
|
|
|
+ dto.setEndDate(endDate);
|
|
|
tableVo.setWeek("第" + dto.getWeek() + "周");
|
|
|
}
|
|
|
|
|
|
@@ -231,11 +242,10 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
* 调课顶课查询
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<CourseListVo> getAdjustList(Long teacherId, String adjustDate) {
|
|
|
+ public List<CourseListVo> getAdjustList(Long teacherId, Date adjustDate) {
|
|
|
CourseTableAdjustDto dto = new CourseTableAdjustDto();
|
|
|
- if(!StrUtil.isEmpty(adjustDate)){
|
|
|
- DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
|
|
- LocalDateTime localDateTime = LocalDateTime.parse(adjustDate, formatter);
|
|
|
+ if(!ObjectUtil.isEmpty(adjustDate)){
|
|
|
+ LocalDateTime localDateTime = adjustDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime();
|
|
|
DayOfWeek dayOfWeek = localDateTime.getDayOfWeek();
|
|
|
dto.setWeek(dayOfWeek.getValue());
|
|
|
}
|
|
|
@@ -245,25 +255,25 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public String getPreCheck(Integer preCheckType, Long courseId, Long swapCourseId, String swapDate, Long subTeacherId) {
|
|
|
- if(preCheckType != null){
|
|
|
- if(preCheckType == 1){
|
|
|
+ public String getPreCheck(String preCheckType, Long courseId, Long swapCourseId, Date swapDate, Long subTeacherId) {
|
|
|
+ if(preCheckType != null && !"".equals(preCheckType)){
|
|
|
+ if(CourseAdjustTypeEnum.courseExchange.getCode().equals(preCheckType)){
|
|
|
CourseTable courseTable = courseTableMapper.selectById(courseId);
|
|
|
CourseTable swapCourseTable = courseTableMapper.selectById(swapCourseId);
|
|
|
try {
|
|
|
JsonObject preCheck = getExtendPreCheck(swapDate, courseTable, swapCourseTable);
|
|
|
- if(!preCheck.get("data").getAsBoolean()){
|
|
|
+ if(!preCheck.get("data").getAsBoolean() && !preCheck.get("msg").isJsonNull()){
|
|
|
return preCheck.get("msg").getAsString();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
|
|
|
|
- }else if(preCheckType == 2){
|
|
|
+ }else if(CourseAdjustTypeEnum.courseSubstitute.getCode().equals(preCheckType)){
|
|
|
CourseTable courseTable = courseTableMapper.selectById(courseId);
|
|
|
try {
|
|
|
JsonObject jsonObject = substitutePreTestin(subTeacherId, courseTable);
|
|
|
- if(!jsonObject.get("data").getAsBoolean()){
|
|
|
+ if(!jsonObject.get("data").getAsBoolean() && !jsonObject.get("msg").isJsonNull()){
|
|
|
return jsonObject.get("msg").getAsString();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
@@ -274,6 +284,92 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Boolean adjustCourse(WfCourseAdjust courseAdjust) throws Exception {
|
|
|
+ if(CourseAdjustTypeEnum.courseExchange.getCode().equals(courseAdjust.getAdjustType())){
|
|
|
+ //调课,将双方课程的日期(schedule_date)、时段(time_period)、节次(time_number)、周(week)、星期几(1-7)(weeks)、星期中文(weeks_cn)对调
|
|
|
+ CourseTable courseTable = courseTableMapper.selectById(courseAdjust.getCourseId());
|
|
|
+ CourseTable swapCourseTable = courseTableMapper.selectById(courseAdjust.getExchangeCourseId());
|
|
|
+
|
|
|
+ CourseTable courseTableBak = BeanUtil.toBean(courseTable, CourseTable.class);
|
|
|
+ CourseTable swapCourseTableBak = BeanUtil.toBean(swapCourseTable, CourseTable.class);
|
|
|
+
|
|
|
+ courseTable.setScheduleDate(swapCourseTableBak.getScheduleDate());
|
|
|
+ courseTable.setTimePeriod(swapCourseTableBak.getTimePeriod());
|
|
|
+ courseTable.setTimeNumber(swapCourseTableBak.getTimeNumber());
|
|
|
+ courseTable.setWeek(swapCourseTableBak.getWeek());
|
|
|
+ courseTable.setWeeks(swapCourseTableBak.getWeeks());
|
|
|
+ courseTable.setWeeksCn(swapCourseTableBak.getWeeksCn());
|
|
|
+ courseTableMapper.updateById(courseTable);
|
|
|
+
|
|
|
+ swapCourseTable.setScheduleDate(courseTableBak.getScheduleDate());
|
|
|
+ swapCourseTable.setTimePeriod(courseTableBak.getTimePeriod());
|
|
|
+ swapCourseTable.setTimeNumber(courseTableBak.getTimeNumber());
|
|
|
+ swapCourseTable.setWeek(courseTableBak.getWeek());
|
|
|
+ swapCourseTable.setWeeks(courseTableBak.getWeeks());
|
|
|
+ swapCourseTable.setWeeksCn(courseTableBak.getWeeksCn());
|
|
|
+ courseTableMapper.updateById(swapCourseTable);
|
|
|
+ //提交调课接口
|
|
|
+ sendExchange(courseTableBak, swapCourseTableBak);
|
|
|
+
|
|
|
+ }else if(CourseAdjustTypeEnum.courseSubstitute.getCode().equals(courseAdjust.getAdjustType())){
|
|
|
+ CourseTable courseTable = courseTableMapper.selectById(courseAdjust.getCourseId());
|
|
|
+
|
|
|
+ courseTable.setTeacherId(courseAdjust.getExchangeTeacherId());
|
|
|
+ courseTableMapper.updateById(courseTable);
|
|
|
+ //提交顶课接口
|
|
|
+ sendSubstitute(courseTable, courseAdjust);
|
|
|
+ }
|
|
|
+ return Boolean.TRUE;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交顶课接口
|
|
|
+ * @param courseTable
|
|
|
+ * @param courseAdjust
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ void sendSubstitute(CourseTable courseTable, WfCourseAdjust courseAdjust) throws Exception {
|
|
|
+ String url = ScheduleUtil.apiUrl + "RescheduleApply/Extend/Substitute/Submit";
|
|
|
+ JsonObject jsonObject = new JsonObject();
|
|
|
+ jsonObject.addProperty("timetableId", courseTable.getJianyueId());
|
|
|
+ jsonObject.addProperty("isCycles", Boolean.FALSE);
|
|
|
+ jsonObject.addProperty("reason", courseAdjust.getReason());
|
|
|
+ JsonArray extendIds = new JsonArray();
|
|
|
+ extendIds.add(courseTable.getTeacherId());
|
|
|
+ jsonObject.add("extendIds", extendIds);
|
|
|
+
|
|
|
+ //获取时间戳
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+ //生成签名
|
|
|
+ String sign = ScheduleUtil.createSign(timestamp);
|
|
|
+ String result = ScheduleUtil.doPost(url, jsonObject.toString(), sign, timestamp);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交调课
|
|
|
+ * @param courseTable
|
|
|
+ * @param swapCourseTable
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ void sendExchange(CourseTable courseTable, CourseTable swapCourseTable) throws Exception {
|
|
|
+ String url = ScheduleUtil.apiUrl + "RescheduleApply/Extend/Submit";
|
|
|
+ JsonObject jsonObject = new JsonObject();
|
|
|
+ jsonObject.addProperty("timetableId", courseTable.getJianyueId());
|
|
|
+ jsonObject.addProperty("isCycles", Boolean.FALSE);
|
|
|
+
|
|
|
+ JsonArray extendIds = new JsonArray();
|
|
|
+ extendIds.add(courseTable.getTeacherId());
|
|
|
+ jsonObject.add("extendIds", extendIds);
|
|
|
+
|
|
|
+ //获取时间戳
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
+ //生成签名
|
|
|
+ String sign = ScheduleUtil.createSign(timestamp);
|
|
|
+ String result = ScheduleUtil.doPost(url, jsonObject.toString(), sign, timestamp);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 顶课预检查
|
|
|
* @param courseTable
|
|
|
@@ -306,7 +402,7 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
* @param swapCourseTable 对调的课程
|
|
|
* @return 检查结果
|
|
|
*/
|
|
|
- JsonObject getExtendPreCheck(String swapDate, CourseTable courseTable, CourseTable swapCourseTable) throws Exception {
|
|
|
+ JsonObject getExtendPreCheck(Date swapDate, CourseTable courseTable, CourseTable swapCourseTable) throws Exception {
|
|
|
JsonParser jsonParser = new JsonParser();
|
|
|
String url = ScheduleUtil.apiUrl + "RescheduleApply/Extend/PreTesting";
|
|
|
JsonObject jsonObject = new JsonObject();
|
|
|
@@ -316,7 +412,8 @@ public class CourseTableServiceImpl extends ServiceImpl<CourseTableMapper, Cours
|
|
|
// jsonObject.addProperty("endDate", "2024-01-31");
|
|
|
// jsonObject.addProperty("dayOfweek", 5);
|
|
|
jsonObject.addProperty("numberOfday", swapCourseTable.getTimeNumber());
|
|
|
- jsonObject.addProperty("date", swapDate);
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ jsonObject.addProperty("date", swapDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime().format(formatter));
|
|
|
jsonObject.addProperty("reschduleId", courseTable.getJianyueId());
|
|
|
|
|
|
//获取时间戳
|