|
|
@ -3,14 +3,17 @@ package com.hzu.bookingsystem.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.VO.ResultVO;
|
|
|
|
import com.hzu.bookingsystem.VO.ResultVO;
|
|
|
|
import com.hzu.bookingsystem.bean.LabRecordBean;
|
|
|
|
import com.hzu.bookingsystem.bean.LabRecordBean;
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.bean.LabTimeBean;
|
|
|
|
import com.hzu.bookingsystem.converter.Map2Object;
|
|
|
|
import com.hzu.bookingsystem.converter.Map2Object;
|
|
|
|
import com.hzu.bookingsystem.dto.LabRecordDTO;
|
|
|
|
import com.hzu.bookingsystem.dto.LabRecordDTO;
|
|
|
|
import com.hzu.bookingsystem.service.LabRecordService;
|
|
|
|
import com.hzu.bookingsystem.service.LabRecordService;
|
|
|
|
|
|
|
|
import com.hzu.bookingsystem.service.LabTimeService;
|
|
|
|
import com.hzu.bookingsystem.utils.ResultVOUtil;
|
|
|
|
import com.hzu.bookingsystem.utils.ResultVOUtil;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
|
@ -22,8 +25,12 @@ public class LabRecordController {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private LabRecordService labrecordService;
|
|
|
|
private LabRecordService labrecordService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private LabTimeService labTimeService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private UserController userController;
|
|
|
|
private UserController userController;
|
|
|
|
|
|
|
|
|
|
|
|
// 根据id查看实验室记录
|
|
|
|
// 根据id查看实验室记录
|
|
|
|
@GetMapping(value = "/findlabrecord/{lr_id}")
|
|
|
|
@GetMapping(value = "/findlabrecord/{lr_id}")
|
|
|
|
public ResultVO<Map<String, LabRecordBean>> FindLabRecordId(@PathVariable("lr_id") Integer lr_id) {
|
|
|
|
public ResultVO<Map<String, LabRecordBean>> FindLabRecordId(@PathVariable("lr_id") Integer lr_id) {
|
|
|
@ -85,4 +92,55 @@ public class LabRecordController {
|
|
|
|
List<LabRecordDTO> labRecordDTOList = labrecordService.findRecordListByUId(userController.getUIdByCookie(request));
|
|
|
|
List<LabRecordDTO> labRecordDTOList = labrecordService.findRecordListByUId(userController.getUIdByCookie(request));
|
|
|
|
return ResultVOUtil.success(labRecordDTOList);
|
|
|
|
return ResultVOUtil.success(labRecordDTOList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 更改选课时间段
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@PostMapping(value = "/updateWeeks", consumes = "application/json")
|
|
|
|
|
|
|
|
public ResultVO updateWeeks(@RequestBody Map<String, Object> map, HttpServletRequest request) {
|
|
|
|
|
|
|
|
//1. 转换对象
|
|
|
|
|
|
|
|
LabTimeBean labTime = (LabTimeBean) Map2Object.map2Object(map, LabTimeBean.class);
|
|
|
|
|
|
|
|
Integer uc_id = (Integer)map.get("uc_id");
|
|
|
|
|
|
|
|
List<Integer> weeks = (List<Integer>)map.get("weeks");
|
|
|
|
|
|
|
|
System.out.println(labTime);
|
|
|
|
|
|
|
|
System.out.println(uc_id);
|
|
|
|
|
|
|
|
System.out.println(weeks);
|
|
|
|
|
|
|
|
//2. 定义对象
|
|
|
|
|
|
|
|
LabRecordBean labRecordBean = new LabRecordBean();
|
|
|
|
|
|
|
|
labRecordBean.setStatus(0);
|
|
|
|
|
|
|
|
labRecordBean.setUcId(uc_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//3. DAO
|
|
|
|
|
|
|
|
List<Integer> weekAble = labTimeService.findWeeksAble(labTime.getLabId(),labTime.getYear(),labTime.getSemester(),labTime.getDay(),labTime.getTime(),uc_id);
|
|
|
|
|
|
|
|
//判断是否选择不可选周数
|
|
|
|
|
|
|
|
for (Integer i :weeks){
|
|
|
|
|
|
|
|
if (!weekAble.contains(i))
|
|
|
|
|
|
|
|
return ResultVOUtil.error(-1,"选择了不可选的周数");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<LabTimeBean> labTimeBeanList = labTimeService.findTimes(labTime.getLabId(),labTime.getYear(),labTime.getSemester(),labTime.getDay(),labTime.getTime());
|
|
|
|
|
|
|
|
//过滤不可选取
|
|
|
|
|
|
|
|
for (LabTimeBean labTimeBean: labTimeBeanList){
|
|
|
|
|
|
|
|
if (!weekAble.contains(labTimeBean.getWeek()))
|
|
|
|
|
|
|
|
labTimeBeanList.remove(labTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//4. 删除record
|
|
|
|
|
|
|
|
for (LabTimeBean labTimeBean: labTimeBeanList){
|
|
|
|
|
|
|
|
labrecordService.deleteByLtIdAndUcId(labTimeBean.getLtId(),uc_id);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//5. 插入record
|
|
|
|
|
|
|
|
for (LabTimeBean labTimeBean: labTimeBeanList){
|
|
|
|
|
|
|
|
if (weeks.contains(labTimeBean.getWeek())){
|
|
|
|
|
|
|
|
LabRecordBean labRecordBean1 = new LabRecordBean().builder()
|
|
|
|
|
|
|
|
.ltId(labTimeBean.getLtId())
|
|
|
|
|
|
|
|
.ucId(uc_id)
|
|
|
|
|
|
|
|
.status(0)
|
|
|
|
|
|
|
|
.build();
|
|
|
|
|
|
|
|
labrecordService.add(labRecordBean1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ResultVOUtil.success();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|