修改学生端关于课程的service

master
pd 4 years ago
parent a29537ee05
commit 12c4f755ea
  1. 23
      src/main/java/com/yipin/liuwanr/controller/AssesmentController.java
  2. 17
      src/main/java/com/yipin/liuwanr/controller/ExperimentallearningController.java
  3. 9
      src/main/java/com/yipin/liuwanr/controller/ProjectAndCourseController.java
  4. 2
      src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java
  5. 2
      src/main/java/com/yipin/liuwanr/mapper/ExperimentallearningMapper.java
  6. 4
      src/main/java/com/yipin/liuwanr/service/AssesmentService.java
  7. 7
      src/main/java/com/yipin/liuwanr/service/AttendanceService.java
  8. 16
      src/main/java/com/yipin/liuwanr/service/ExperimentallearningService.java
  9. 317
      src/main/java/com/yipin/liuwanr/service/PracticeService.java
  10. 21
      src/main/java/com/yipin/liuwanr/service/ProjectAndCourseService.java

@ -469,20 +469,17 @@ public class AssesmentController {
@GetMapping("/releaseAssesment")
Response releaseAssesment(@RequestParam Integer courseId){
Response resp = new Response();
if(StringUtils.isEmpty(courseId)){
resp.setStatus(300);
resp.setErrmessage("课程信息为空");
}else{
HashMap<String, Object> ret = service.releaseAssesment(courseId);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
HashMap<String, Object> ret = service.releaseAssesment(courseId);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
return resp;
}

@ -94,19 +94,14 @@ public class ExperimentallearningController {
@GetMapping("/queryStudentName")
Response queryStudentName(@RequestParam Integer courseId) {
Response resp = new Response();
if(StringUtils.isEmpty(courseId)){
resp.setStatus(300);
resp.setMessage("课程信息为空");
}else {
HashMap<String, Object> ret = service.queryStudentName(courseId);
int status = (int) ret.get("retcode");
if (status == 200) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
HashMap<String, Object> ret = service.queryStudentName(courseId);
int status = (int) ret.get("retcode");
if (status == 200) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
}
return resp;
}

@ -94,15 +94,11 @@ public class ProjectAndCourseController {
return resp;
}
//课程进度
@GetMapping("/getCourseSchedule")
Response getCourseSchedule(Integer courseId) {
Response resp = new Response();
if(StringUtils.isEmpty(courseId)) {
resp.setStatus(300);
resp.setErrmessage("课程id为空");
return resp;
}else {
HashMap<String, Object> ret = service.getCourseSchedule(courseId);
HashMap<String, Object> ret = service.getCourseSchedule(courseId);
int status = (int) ret.get("retcode");
if (status == 200) {
resp.setStatus(status);
@ -111,7 +107,6 @@ public class ProjectAndCourseController {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
}
return resp;
}
}

@ -57,7 +57,7 @@ public interface AssesmentMapper {
" <if test='releaseType!=null'>and a.releaseType=#{releaseType} </if>",
" <if test='assesmentState!=null'>and a.assesmentState=#{assesmentState} </if>",
" <if test='className!=null and className!=\"\"'>and c.className like concat('%',#{className},'%') </if>",
" GROUP BY a.id ORDER BY a.creationTime ORDER BY a.id desc ",
" GROUP BY a.id ORDER BY a.id desc ",
"</script> "})
List<Assesment> getByCondition(Assesment assesment);

@ -87,7 +87,7 @@ public interface ExperimentallearningMapper {
* @return
*/
@Select("select id,experimentId,experimentalClassId,classId from assessment a left join hr_project_management pm on a.experimentId=pm.projectId left join hr_course_tc tc on pm.systemId=tc.systemId" +
"where a.assesmentState=1 AND pm.state=1 and pm.isdel=0 AND pm.projectPermissions=1 and a.courseId=tc.courseId and tc.courseId=#{courseId} GROUP BY tc.systemId")
" where a.assesmentState=1 AND pm.state=1 and pm.isdel=0 AND pm.projectPermissions=1 and a.courseId=tc.courseId and tc.courseId=#{courseId} GROUP BY tc.systemId")
List<Assesment> queryAssesment(Integer courseId);

@ -615,7 +615,9 @@ public class AssesmentService {
public HashMap<String, Object> releaseAssesment(Integer courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
resp.put("retvalue", mapper.releaseAssesment(courseId));
if(courseId!=null){
resp.put("retvalue", mapper.releaseAssesment(courseId));
}
resp.put("retcode", 200);
} catch (Exception e) {
logger.error(e.getMessage());

@ -17,6 +17,7 @@ import com.yipin.liuwanr.entity.Attendance;
import com.yipin.liuwanr.entity.PageResult;
import com.yipin.liuwanr.helper.ExcelExportHelper;
import com.yipin.liuwanr.mapper.AttendanceMapper;
import org.springframework.util.StringUtils;
/**
* 考勤记录
@ -43,7 +44,7 @@ public class AttendanceService {
public HashMap<String, Object> queryAttendanceDetailed(Integer studentId,Integer courseId,Integer pageNo,Integer pageSize){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(courseId!=null&&studentId!=null){
if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){
PageHelper.startPage(pageNo, pageSize);
List<Attendance> list = mapper.getByCourseId(studentId,courseId);
PageInfo<Attendance> info=new PageInfo<Attendance>(list);
@ -75,7 +76,7 @@ public class AttendanceService {
*/
public HashMap<String, Object> exportPractice(HttpServletResponse response,Integer studentId,Integer courseId,String[] titles) {
try {
if(studentId!=null&&courseId!=null&&titles.length>0){
if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)&&titles.length>0){
String fileName="考勤记录.xls";
String sheetName="考勤记录";
List<Attendance> list = mapper.getByCourseId(studentId,courseId);
@ -104,7 +105,7 @@ public class AttendanceService {
HashMap<String, Object> resp = new HashMap<String, Object>();
Attendance attendance=new Attendance();
try {
if(studentId!=null&&courseId!=null){
if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){
attendance.setStudentName(mapper.getByStudentName(studentId));
List<Integer> projectIds=mapper.queryProjectIds(courseId);
attendance.setCount(projectIds.size());

@ -14,6 +14,7 @@ import com.yipin.liuwanr.entity.Attendance;
import com.yipin.liuwanr.entity.Project_Management;
import com.yipin.liuwanr.mapper.ExperimentallearningMapper;
import com.yipin.liuwanr.mapper.TeacherProjectAndCourseMapper;
import org.springframework.util.StringUtils;
/**
* 学生端_实验学习
@ -41,7 +42,7 @@ public class ExperimentallearningService {
public HashMap<String, Object> queryProject(Integer studentId, Integer courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(studentId!=null&&courseId!=null){
if(!StringUtils.isEmpty(courseId)&&!StringUtils.isEmpty(studentId)){
List<Integer> projectIds = mapper.queryIsAttendance(studentId, courseId);
List<Project_Management> projects = mapper2.getBySystemId(courseId, 0, null);
for (int i = 0; i < projects.size(); i++) {
@ -103,7 +104,7 @@ public class ExperimentallearningService {
public HashMap<String, Object> queryStudentName(Integer courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(courseId!=null){
if(!StringUtils.isEmpty(courseId)){
resp.put("retvalue", mapper.queryStudentName(courseId));
}
resp.put("retcode", 200);
@ -122,7 +123,7 @@ public class ExperimentallearningService {
public HashMap<String, Object> queryTeacherName(Integer courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(courseId!=null){
if(!StringUtils.isEmpty(courseId)){
resp.put("retvalue", mapper.queryTeacherName(courseId));
}
resp.put("retcode", 200);
@ -142,7 +143,10 @@ public class ExperimentallearningService {
HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> val = new HashMap<String, Object>();
try {
List<Assesment> assesments = mapper.queryAssesment(courseId);
List<Assesment> assesments=null;
if(!StringUtils.isEmpty(courseId)) {
assesments = mapper.queryAssesment(courseId);
}
// 查询出来该课程有多个考核开启,则不符合逻辑(一门课程一次只能开启一个考核,不能有多个)
if(!assesments.isEmpty()&&assesments.size()>0){
if (assesments.size() > 1) {
@ -161,13 +165,13 @@ public class ExperimentallearningService {
val.put("assesmentId", assesmentId);
}
}
resp.put("retvalue", val);
}
resp.put("retcode", 200);
resp.put("retvalue", val);
} catch (Exception e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
resp.put("retvalue", "查询考核信息失败");
return resp;
}
return resp;

@ -19,167 +19,174 @@ import com.yipin.liuwanr.helper.ExcelExportHelper;
import com.yipin.liuwanr.mapper.AssesmentMapper;
import com.yipin.liuwanr.mapper.RecordMapper;
import com.yipin.liuwanr.vo.PracticeRecordVo;
import org.springframework.util.StringUtils;
/**
* 练习记录
* @author 或然
*
* @author 或然
*/
@Service
public class PracticeService {
private static Logger logger = Logger.getLogger(PracticeService.class);
@Autowired
private RecordMapper mapper;
@Autowired
private AssesmentMapper assesment;
/**
* 练习记录 And 考核记录
* @param studentId
* @param projectPermissions
* @param pageNum
* @param pageSize
* @return
*/
public HashMap<String, Object> queryStudentByPage(Integer studentId,Integer projectPermissions,Integer courseId,Integer pageNum,Integer pageSize) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(studentId!=null&&courseId!=null&&projectPermissions!=null) {
PageHelper.startPage(pageNum, pageSize);
List<Record> records=mapper.getByStudentId(projectPermissions,courseId,studentId);
PageInfo<Record> info=new PageInfo<Record>(records);
int total1 = (int) info.getTotal();
int totalPages;
totalPages = total1 / pageSize;
if (total1 % pageSize != 0){
totalPages ++;
}
long total = total1;
resp.put("retvalue", new PageResult(total, records,totalPages));
}
resp.put("retcode", 200);
} catch (Exception e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
/**
* 练习记录 and 考核记录导出
* @param response
* @param studentId学生id
* @param projectPermissions权限(练习考核)
* @param titles(标题)
* @return
*/
public HashMap<String, Object> exportPractice(HttpServletResponse response,Integer studentId,Integer projectPermissions,Integer courseId,String[] titles) {
String fileName=null;
String sheetName=null;
try {
List<Record> records=mapper.getByStudentId(projectPermissions,courseId,studentId);
if(records.size()>0&&!records.isEmpty()) {
if(projectPermissions==0) {
fileName = "练习记录.xls";
sheetName = "练习记录";
}else if(projectPermissions==1){
fileName = "考核记录.xls";
sheetName = "考核记录";
}
HSSFWorkbook bos = ExcelExportHelper.exportPractice(records, sheetName,titles);
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-disposition","attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.flushBuffer();
bos.write(response.getOutputStream());
bos.close();
}
} catch (Exception e) {
logger.error(e.getMessage());
return null;
}
return null;
}
/**
* 练习信息
* @param studentId
* @return
*/
public HashMap<String, Object> queryPracticeVo(Integer studentId,Integer courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(studentId!=null&&courseId!=null){
// 学生个人的练习信息
PracticeRecordVo practiceVo = mapper.getByPracticeVO(studentId,courseId);
// 练习项目数量
Integer practiceNumber=mapper.queryPracticeNumber(courseId);
if(practiceNumber!=null) {
practiceVo.setPracticeNumber(practiceNumber);
// 求完成项目数量
Integer accomplishNumber=mapper.queryAccomplishNumber(studentId,courseId);
if(accomplishNumber!=null) {
practiceVo.setAccomplishNumber(accomplishNumber);
}
}else {
practiceVo.setPracticeNumber(0);
practiceVo.setAccomplishNumber(0);
}
// 练习总次数
Integer sumNumber=mapper.querySumNumber(studentId,courseId);
if(sumNumber!=null) {
practiceVo.setSumNumber(sumNumber);
}else {
practiceVo.setSumNumber(0);
}
PracticeRecordVo vo=mapper.queryCountry(courseId);
if(vo!=null) {
//全国实训积分平均分
practiceVo.setAvgintegral(vo.getAvgintegral());
//全国最高实训积分
practiceVo.setHeightintegral(vo.getHeightintegral());
}else {
//全国实训积分平均分
practiceVo.setAvgintegral(0);
//全国最高实训积分
practiceVo.setHeightintegral(0);
}
resp.put("retvalue", practiceVo);
}
resp.put("retcode", 200);
} catch (Exception e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
public HashMap<String, Object> queryAllExperiment(Integer coureseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if(coureseId!=null){
resp.put("retvalue", assesment.queryGetByAssesmentProject(coureseId));
}
resp.put("retcode", 200);
} catch (Exception e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
private static Logger logger = Logger.getLogger(PracticeService.class);
@Autowired
private RecordMapper mapper;
@Autowired
private AssesmentMapper assesment;
/**
* 练习记录 And 考核记录
*
* @param studentId
* @param projectPermissions
* @param pageNum
* @param pageSize
* @return
*/
public HashMap<String, Object> queryStudentByPage(Integer studentId, Integer projectPermissions, Integer courseId, Integer pageNum, Integer pageSize) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if (!StringUtils.isEmpty(courseId) && !StringUtils.isEmpty(studentId) && projectPermissions != null) {
PageHelper.startPage(pageNum, pageSize);
List<Record> records = mapper.getByStudentId(projectPermissions, courseId, studentId);
PageInfo<Record> info = new PageInfo<Record>(records);
int total1 = (int) info.getTotal();
int totalPages;
totalPages = total1 / pageSize;
if (total1 % pageSize != 0) {
totalPages++;
}
long total = total1;
resp.put("retvalue", new PageResult(total, records, totalPages));
}
resp.put("retcode", 200);
} catch (Exception e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
/**
* 练习记录 and 考核记录导出
*
* @param response
* @param studentId学生id
* @param projectPermissions权限(练习考核)
* @param titles(标题)
* @return
*/
public HashMap<String, Object> exportPractice(HttpServletResponse response, Integer studentId, Integer projectPermissions, Integer courseId, String[] titles) {
String fileName = null;
String sheetName = null;
List<Record> records = null;
try {
if (!StringUtils.isEmpty(courseId) && !StringUtils.isEmpty(studentId)) {
records = mapper.getByStudentId(projectPermissions, courseId, studentId);
}
if (records.size() > 0 && !records.isEmpty()) {
if (projectPermissions == 0) {
fileName = "练习记录.xls";
sheetName = "练习记录";
} else if (projectPermissions == 1) {
fileName = "考核记录.xls";
sheetName = "考核记录";
}
HSSFWorkbook bos = ExcelExportHelper.exportPractice(records, sheetName, titles);
response.setHeader("content-Type", "application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
response.flushBuffer();
bos.write(response.getOutputStream());
bos.close();
}
} catch (Exception e) {
logger.error(e.getMessage());
return null;
}
return null;
}
/**
* 练习信息
*
* @param studentId
* @return
*/
public HashMap<String, Object> queryPracticeVo(Integer studentId, Integer courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if (!StringUtils.isEmpty(courseId) && !StringUtils.isEmpty(studentId)) {
// 学生个人的练习信息
PracticeRecordVo practiceVo = mapper.getByPracticeVO(studentId, courseId);
// 练习项目数量
Integer practiceNumber = mapper.queryPracticeNumber(courseId);
if (practiceNumber != null) {
practiceVo.setPracticeNumber(practiceNumber);
// 求完成项目数量
Integer accomplishNumber = mapper.queryAccomplishNumber(studentId, courseId);
if (accomplishNumber != null) {
practiceVo.setAccomplishNumber(accomplishNumber);
}
} else {
practiceVo.setPracticeNumber(0);
practiceVo.setAccomplishNumber(0);
}
// 练习总次数
Integer sumNumber = mapper.querySumNumber(studentId, courseId);
if (sumNumber != null) {
practiceVo.setSumNumber(sumNumber);
} else {
practiceVo.setSumNumber(0);
}
PracticeRecordVo vo = mapper.queryCountry(courseId);
if (vo != null) {
//全国实训积分平均分
practiceVo.setAvgintegral(vo.getAvgintegral());
//全国最高实训积分
practiceVo.setHeightintegral(vo.getHeightintegral());
} else {
//全国实训积分平均分
practiceVo.setAvgintegral(0);
//全国最高实训积分
practiceVo.setHeightintegral(0);
}
resp.put("retvalue", practiceVo);
}
resp.put("retcode", 200);
} catch (Exception e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
public HashMap<String, Object> queryAllExperiment(Integer courseId) {
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if (!StringUtils.isEmpty(courseId)) {
resp.put("retvalue", assesment.queryGetByAssesmentProject(courseId));
}
resp.put("retcode", 200);
} catch (Exception e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "Inquiry Failed");
return resp;
}
return resp;
}
}

@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
import com.yipin.liuwanr.entity.Project_Management;
import com.yipin.liuwanr.mapper.TeacherProjectAndCourseMapper;
import org.springframework.util.StringUtils;
/**
*
@ -82,15 +83,17 @@ public class ProjectAndCourseService {
HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Integer> obj = new HashMap<String, Integer>();
try {
//完成的课程项目
Integer number=mapper.getCourseSchedule(courseId);
//总项目数量
List<Project_Management> project=mapper.getBySystemId(courseId,null, null);
obj.put("total",project.size());
if(number!=null){
obj.put("number",number);
}else{
obj.put("number",0);
if(StringUtils.isEmpty(courseId)){
//完成的课程项目
Integer number=mapper.getCourseSchedule(courseId);
//总项目数量
List<Project_Management> project=mapper.getBySystemId(courseId,null, null);
obj.put("total",project.size());
if(number!=null){
obj.put("number",number);
}else{
obj.put("number",0);
}
}
resp.put("retcode", 200);
resp.put("retvalue",obj);

Loading…
Cancel
Save