|
@@ -7,20 +7,25 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.db.Db;
|
|
import cn.hutool.db.Db;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.google.gson.JsonArray;
|
|
import com.google.gson.JsonArray;
|
|
|
|
|
+import com.google.gson.JsonObject;
|
|
|
|
|
+import com.google.gson.JsonParser;
|
|
|
import com.xjrsoft.common.constant.GlobalConstant;
|
|
import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
import com.xjrsoft.common.enums.DeleteMark;
|
|
|
import com.xjrsoft.common.enums.EnabledMark;
|
|
import com.xjrsoft.common.enums.EnabledMark;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
import com.xjrsoft.common.utils.DatasourceUtil;
|
|
import com.xjrsoft.common.utils.DatasourceUtil;
|
|
|
import com.xjrsoft.module.base.entity.BaseSemester;
|
|
import com.xjrsoft.module.base.entity.BaseSemester;
|
|
|
|
|
+import com.xjrsoft.module.courseTable.entity.CourseTable;
|
|
|
import com.xjrsoft.module.courseTable.service.ICourseTableService;
|
|
import com.xjrsoft.module.courseTable.service.ICourseTableService;
|
|
|
import com.xjrsoft.module.schedule.dto.CourseTableAdjustDto;
|
|
import com.xjrsoft.module.schedule.dto.CourseTableAdjustDto;
|
|
|
import com.xjrsoft.module.schedule.dto.CourseTableDto;
|
|
import com.xjrsoft.module.schedule.dto.CourseTableDto;
|
|
|
|
|
+import com.xjrsoft.module.schedule.dto.CourseTablePreCheckDto;
|
|
|
import com.xjrsoft.module.schedule.entity.CourseReceiveMsg;
|
|
import com.xjrsoft.module.schedule.entity.CourseReceiveMsg;
|
|
|
import com.xjrsoft.module.schedule.entity.JianyueData;
|
|
import com.xjrsoft.module.schedule.entity.JianyueData;
|
|
|
import com.xjrsoft.module.schedule.service.ICourseReceiveMsgService;
|
|
import com.xjrsoft.module.schedule.service.ICourseReceiveMsgService;
|
|
|
import com.xjrsoft.module.schedule.service.IJianyueDataService;
|
|
import com.xjrsoft.module.schedule.service.IJianyueDataService;
|
|
|
import com.xjrsoft.module.schedule.util.DataUtil;
|
|
import com.xjrsoft.module.schedule.util.DataUtil;
|
|
|
|
|
+import com.xjrsoft.module.schedule.util.ScheduleUtil;
|
|
|
import com.xjrsoft.module.schedule.vo.CourseListVo;
|
|
import com.xjrsoft.module.schedule.vo.CourseListVo;
|
|
|
import com.xjrsoft.module.schedule.vo.CourseTableVo;
|
|
import com.xjrsoft.module.schedule.vo.CourseTableVo;
|
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
|
|
@@ -38,6 +43,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
import javax.sql.DataSource;
|
|
import javax.sql.DataSource;
|
|
|
import java.time.DayOfWeek;
|
|
import java.time.DayOfWeek;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
import java.util.HashSet;
|
|
@@ -182,27 +188,96 @@ public class ScheduleController {
|
|
|
@ApiOperation(value = "可以调课的课程")
|
|
@ApiOperation(value = "可以调课的课程")
|
|
|
@SaCheckPermission("evaluateobject:detail")
|
|
@SaCheckPermission("evaluateobject:detail")
|
|
|
public RT<List<CourseListVo>> adjustList(CourseTableAdjustDto dto){
|
|
public RT<List<CourseListVo>> adjustList(CourseTableAdjustDto dto){
|
|
|
- if(dto.getAdjustDate() == null || dto.getTeacherId() == null){
|
|
|
|
|
- return RT.error("请传入调整日期和教师id");
|
|
|
|
|
- }
|
|
|
|
|
- List<CourseListVo> list = courseTableService.getAdjustList(dto);
|
|
|
|
|
- if(list.isEmpty()){
|
|
|
|
|
- return RT.error("暂无可调课程");
|
|
|
|
|
- }
|
|
|
|
|
- return RT.ok(list);
|
|
|
|
|
|
|
+// if(dto.getAdjustDate() == null || dto.getTeacherId() == null){
|
|
|
|
|
+// return RT.error("请传入调整日期和教师id");
|
|
|
|
|
+// }
|
|
|
|
|
+// List<CourseListVo> list = courseTableService.getAdjustList(dto);
|
|
|
|
|
+// if(list.isEmpty()){
|
|
|
|
|
+// return RT.error("暂无可调课程");
|
|
|
|
|
+// }
|
|
|
|
|
+ return RT.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@GetMapping(value = "/pre-check")
|
|
@GetMapping(value = "/pre-check")
|
|
|
@ApiOperation(value = "预检查")
|
|
@ApiOperation(value = "预检查")
|
|
|
@SaCheckPermission("evaluateobject:detail")
|
|
@SaCheckPermission("evaluateobject:detail")
|
|
|
- public RT<List<CourseListVo>> preCheck(CourseTableAdjustDto dto){
|
|
|
|
|
- if(dto.getAdjustDate() == null || dto.getTeacherId() == null){
|
|
|
|
|
- return RT.error("请传入调整日期和教师id");
|
|
|
|
|
|
|
+ public RT<String> preCheck(CourseTablePreCheckDto dto) throws Exception {
|
|
|
|
|
+ if(dto.getPreCheckType() != null){
|
|
|
|
|
+ if(dto.getPreCheckType() == 1){
|
|
|
|
|
+ CourseTable courseTable = courseTableService.getById(dto.getCourseId());
|
|
|
|
|
+ CourseTable swapCourseTable = courseTableService.getById(dto.getSwapCourseId());
|
|
|
|
|
+ JsonObject preCheck = getExtendPreCheck(dto, courseTable, swapCourseTable);
|
|
|
|
|
+ if(!preCheck.get("data").getAsBoolean()){
|
|
|
|
|
+ return RT.error(preCheck.get("msg").getAsString());
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if(dto.getPreCheckType() == 2){
|
|
|
|
|
+ CourseTable courseTable = courseTableService.getById(dto.getCourseId());
|
|
|
|
|
+ JsonObject jsonObject = substitutePreTestin(dto, courseTable);
|
|
|
|
|
+ if(!jsonObject.get("data").getAsBoolean()){
|
|
|
|
|
+ return RT.error(jsonObject.get("msg").getAsString());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return RT.ok("ok");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 顶课预检查
|
|
|
|
|
+ * @param dto
|
|
|
|
|
+ * @param courseTable
|
|
|
|
|
+ * @return 检查结果
|
|
|
|
|
+ */
|
|
|
|
|
+ JsonObject substitutePreTestin(CourseTablePreCheckDto dto, CourseTable courseTable) throws Exception {
|
|
|
|
|
+ JsonParser jsonParser = new JsonParser();
|
|
|
|
|
+ String url = ScheduleUtil.apiUrl + "RescheduleApply/Extend/Substitute/PreTesting";
|
|
|
|
|
+ JsonObject jsonObject = new JsonObject();
|
|
|
|
|
+ jsonObject.addProperty("timetableId", courseTable.getJianyueId());
|
|
|
|
|
+ jsonObject.addProperty("isCycles", Boolean.FALSE);
|
|
|
|
|
+ JsonArray extendIds = new JsonArray();
|
|
|
|
|
+ extendIds.add(dto.getSubTeacherId());
|
|
|
|
|
+ jsonObject.add("extendIds", extendIds);
|
|
|
|
|
+ //获取时间戳
|
|
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
|
|
+ //生成签名
|
|
|
|
|
+ String sign = ScheduleUtil.createSign(timestamp);
|
|
|
|
|
+ String result = ScheduleUtil.doPost(url, jsonObject.toString(), sign, timestamp);
|
|
|
|
|
+ if(StrUtil.isEmpty(result)){
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
- List<CourseListVo> list = courseTableService.getAdjustList(dto);
|
|
|
|
|
- if(list.isEmpty()){
|
|
|
|
|
- return RT.error("暂无可调课程");
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return jsonParser.parse(result).getAsJsonObject();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 调课预检查
|
|
|
|
|
+ * @param courseTable 需要调整的课程
|
|
|
|
|
+ * @param swapCourseTable 对调的课程
|
|
|
|
|
+ * @return 检查结果
|
|
|
|
|
+ */
|
|
|
|
|
+ JsonObject getExtendPreCheck(CourseTablePreCheckDto dto, CourseTable courseTable, CourseTable swapCourseTable) throws Exception {
|
|
|
|
|
+ JsonParser jsonParser = new JsonParser();
|
|
|
|
|
+ String url = ScheduleUtil.apiUrl + "RescheduleApply/Extend/PreTesting";
|
|
|
|
|
+ JsonObject jsonObject = new JsonObject();
|
|
|
|
|
+ jsonObject.addProperty("timetableId", courseTable.getJianyueId());
|
|
|
|
|
+ jsonObject.addProperty("isCycles", Boolean.FALSE);
|
|
|
|
|
+// jsonObject.addProperty("startDate", "2024-01-01");
|
|
|
|
|
+// jsonObject.addProperty("endDate", "2024-01-31");
|
|
|
|
|
+// jsonObject.addProperty("dayOfweek", 5);
|
|
|
|
|
+ jsonObject.addProperty("numberOfday", swapCourseTable.getTimeNumber());
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+ jsonObject.addProperty("date", dto.getSwapDate().format(formatter));
|
|
|
|
|
+ jsonObject.addProperty("reschduleId", courseTable.getJianyueId());
|
|
|
|
|
+
|
|
|
|
|
+ //获取时间戳
|
|
|
|
|
+ long timestamp = System.currentTimeMillis();
|
|
|
|
|
+ //生成签名
|
|
|
|
|
+ String sign = ScheduleUtil.createSign(timestamp);
|
|
|
|
|
+ String result = ScheduleUtil.doPost(url, jsonObject.toString(), sign, timestamp);
|
|
|
|
|
+ if(StrUtil.isEmpty(result)){
|
|
|
|
|
+ return null;
|
|
|
}
|
|
}
|
|
|
- return RT.ok(list);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return jsonParser.parse(result).getAsJsonObject();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|