From e35ca6465315f6b51ff8f25d6666ca1c89c7a536 Mon Sep 17 00:00:00 2001 From: mzh820631607 Date: Thu, 24 Sep 2020 17:36:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E6=95=99=E5=AD=A6=E5=AE=9E?= =?UTF-8?q?=E9=AA=8C=E8=AE=B0=E5=BD=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/msdw/tms/api/ClassTeachingApi.java | 2 +- .../tms/api/ProjectRcordControllerApi.java | 4 ++- .../controller/ClassTeachingController.java | 16 +++++------ .../controller/ProjectRecordController.java | 21 ++++++++++++--- .../com/msdw/tms/dao/ClassTeachingDao.java | 3 +++ .../com/msdw/tms/dao/ProjectRecordDao.java | 2 +- .../entity/ExperimentalTeachingEntity.java | 3 ++- .../msdw/tms/entity/vo/ProjectRecordVo.java | 5 ++++ .../tms/service/ProjectRecordService.java | 3 ++- .../impl/ClassTeachingServiceImpl.java | 11 ++++++++ .../impl/ProjectRecordServiceImpl.java | 6 +++-- .../resources/mapper/tms/ClassTeachingDao.xml | 27 +++++++++++++++---- .../resources/mapper/tms/ProjectRecordDao.xml | 9 +++++-- 13 files changed, 84 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/msdw/tms/api/ClassTeachingApi.java b/src/main/java/com/msdw/tms/api/ClassTeachingApi.java index d0efeda..3940de6 100644 --- a/src/main/java/com/msdw/tms/api/ClassTeachingApi.java +++ b/src/main/java/com/msdw/tms/api/ClassTeachingApi.java @@ -14,7 +14,7 @@ public interface ClassTeachingApi { @ApiOperation(value = "查询班级实验列表信息",notes = "查询班级实验列表信息") R queryTestRecord(Integer page, Integer size, Integer month, String startTime, String endTime, - String condition, Integer status, Integer isCode); + String condition, Integer status); @ApiOperation(value = "查看成绩",notes = "查看成绩") R queryAchievement(); diff --git a/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java b/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java index 70f2b68..6cbab25 100644 --- a/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java +++ b/src/main/java/com/msdw/tms/api/ProjectRcordControllerApi.java @@ -27,7 +27,9 @@ public interface ProjectRcordControllerApi { R getUserScore(Integer userid); @ApiOperation(value = "个人实验记录导出",notes = "个人实验记录导出") - void exportProjectRecord(HttpServletResponse response,Integer userId)throws Exception; + void exportProjectRecord(HttpServletResponse response,ProjectRecordVo list)throws Exception; +// @ApiOperation(value = "个人实验记录导出",notes = "个人实验记录导出") +// void exportProjectRecord(HttpServletResponse response,Integer userId)throws Exception; @ApiOperation(value = "修改实验报告分数",notes = "修改实验报告分数") R update(ProjectRecordEntity projectRecord); diff --git a/src/main/java/com/msdw/tms/controller/ClassTeachingController.java b/src/main/java/com/msdw/tms/controller/ClassTeachingController.java index b562a13..aebf9b3 100644 --- a/src/main/java/com/msdw/tms/controller/ClassTeachingController.java +++ b/src/main/java/com/msdw/tms/controller/ClassTeachingController.java @@ -32,12 +32,13 @@ public class ClassTeachingController implements ClassTeachingApi { */ @Override @GetMapping("userRecord") - public R queryTestRecord(@RequestParam Integer page, @RequestParam Integer size, Integer month,@RequestParam String startTime,@RequestParam String endTime, - String condition, @RequestParam Integer status,@RequestParam Integer isCode){ + public R queryTestRecord(@RequestParam Integer page, @RequestParam Integer size, Integer month,String startTime,String endTime, + String condition, @RequestParam Integer status){ ProjectRecordVo recordVo = new ProjectRecordVo(); - if (isCode==0){ - if (status!=0) {//不限定实验状态 + if (status==1||status==2||status==3) {//限定实验状态 recordVo.setStatus(status); + }else{//不限定实验状态 + recordVo.setStatus(null); } if(!StringUtils.isEmpty(condition)){ recordVo.setCondition(condition); @@ -45,20 +46,15 @@ public class ClassTeachingController implements ClassTeachingApi { if(!StringUtils.isEmpty(month)) { recordVo.setMonth(month); }else { - recordVo.setMonth(0); + recordVo.setMonth(null); if(!StringUtils.isEmpty(startTime)) { recordVo.setStartTime(startTime); }if(!StringUtils.isEmpty(endTime)) { recordVo.setEndTime(endTime); } } - recordVo.setIsCode(isCode); PageUtils page1 = classTeachingService.queryClassRecord(page,size,recordVo); return R.ok().put("page", page1); - }else if (isCode==1){ - return R.error("无需邀请码"); - } - return R.error("错误操作,isCode 不能为空"); } /** diff --git a/src/main/java/com/msdw/tms/controller/ProjectRecordController.java b/src/main/java/com/msdw/tms/controller/ProjectRecordController.java index 94d38fa..2e6333d 100644 --- a/src/main/java/com/msdw/tms/controller/ProjectRecordController.java +++ b/src/main/java/com/msdw/tms/controller/ProjectRecordController.java @@ -13,6 +13,7 @@ import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; import java.util.Arrays; +import java.util.List; /** * @@ -98,15 +99,27 @@ public class ProjectRecordController implements ProjectRcordControllerApi { /** * 导出个人项目记录 * @param response - * @param userId * @throws Exception */ @Override - @GetMapping("/user/exportProjectRecord") - public void exportProjectRecord(HttpServletResponse response,@RequestParam("userId") Integer userId)throws Exception{ - projectRecordService.exportProjectRecord(response,userId); + @PostMapping("/user/exportProjectRecord") + public void exportProjectRecord(HttpServletResponse response,@RequestBody ProjectRecordVo list)throws Exception{ + projectRecordService.exportProjectRecord(response,list); } + +// /** +// * 导出个人项目记录 +// * @param response +// * @param userId +// * @throws Exception +// */ +// @Override +// @GetMapping("/user/exportProjectRecord") +// public void exportProjectRecord(HttpServletResponse response,@RequestParam("userId") Integer userId)throws Exception{ +// projectRecordService.exportProjectRecord(response,userId); +// } + /** * 信息 */ diff --git a/src/main/java/com/msdw/tms/dao/ClassTeachingDao.java b/src/main/java/com/msdw/tms/dao/ClassTeachingDao.java index 2c4c815..d3abacd 100644 --- a/src/main/java/com/msdw/tms/dao/ClassTeachingDao.java +++ b/src/main/java/com/msdw/tms/dao/ClassTeachingDao.java @@ -12,4 +12,7 @@ public interface ClassTeachingDao { ExperimentalTeachingEntity queryInvitationCode(ExperimentalTeachingEntity experimentEntity); IPage getByClassRecord(Page page1, @Param("cla") ProjectRecordVo recordVo); + + void updateSurplusTime(@Param("cla") ProjectRecordVo recordVo); + void updateSurplusTimeNull(@Param("cla") ProjectRecordVo recordVo); } diff --git a/src/main/java/com/msdw/tms/dao/ProjectRecordDao.java b/src/main/java/com/msdw/tms/dao/ProjectRecordDao.java index abbf531..9df465c 100644 --- a/src/main/java/com/msdw/tms/dao/ProjectRecordDao.java +++ b/src/main/java/com/msdw/tms/dao/ProjectRecordDao.java @@ -24,7 +24,7 @@ public interface ProjectRecordDao extends BaseMapper { IPage getByUserExperimentRecord(Page page,@Param("pro") ProjectRecordEntity projectRecordEntity); - List getByUserRecordImport(ProjectRecordEntity projectRecordEntity); + List getByUserRecordImport(@Param("pro") ProjectRecordEntity projectRecordEntity,List projectIds); ProjectRecordVo getByUserScore(@Param("userid") Integer userId,@Param("isdel") Integer isdel); diff --git a/src/main/java/com/msdw/tms/entity/ExperimentalTeachingEntity.java b/src/main/java/com/msdw/tms/entity/ExperimentalTeachingEntity.java index b84e107..2ec27ac 100644 --- a/src/main/java/com/msdw/tms/entity/ExperimentalTeachingEntity.java +++ b/src/main/java/com/msdw/tms/entity/ExperimentalTeachingEntity.java @@ -45,5 +45,6 @@ public class ExperimentalTeachingEntity { private Integer isCode; //绑定用户Id private Integer userId; - + //实验倒计时 + private String surplusTime; } diff --git a/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java b/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java index ad66a0c..6addbe0 100644 --- a/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java +++ b/src/main/java/com/msdw/tms/entity/vo/ProjectRecordVo.java @@ -80,6 +80,11 @@ public class ProjectRecordVo extends ProjectRecordEntity implements Serializable */ private String experimentalClassName; + /** + * 封装多个项目id + */ + private List projectIds; + // /** // * 班级实验状态,0 不限,1 未发布,2 进行中,3 已完成 // */ diff --git a/src/main/java/com/msdw/tms/service/ProjectRecordService.java b/src/main/java/com/msdw/tms/service/ProjectRecordService.java index 4927e80..11ce9a7 100644 --- a/src/main/java/com/msdw/tms/service/ProjectRecordService.java +++ b/src/main/java/com/msdw/tms/service/ProjectRecordService.java @@ -6,6 +6,7 @@ import com.msdw.tms.entity.ProjectRecordEntity; import com.msdw.tms.entity.vo.ProjectRecordVo; import javax.servlet.http.HttpServletResponse; +import java.util.List; /** * @@ -22,7 +23,7 @@ public interface ProjectRecordService extends IService { ProjectRecordVo queryUserScore(Integer userId); - void exportProjectRecord(HttpServletResponse response,Integer userId)throws Exception; + void exportProjectRecord(HttpServletResponse response, ProjectRecordVo vo)throws Exception; PageUtils querySchoolRecord(Integer page,Integer size,ProjectRecordVo projectRecord); diff --git a/src/main/java/com/msdw/tms/service/impl/ClassTeachingServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/ClassTeachingServiceImpl.java index 2456b85..ccfdf83 100644 --- a/src/main/java/com/msdw/tms/service/impl/ClassTeachingServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/ClassTeachingServiceImpl.java @@ -11,6 +11,7 @@ import com.msdw.tms.service.ClassTeachingService; import org.apache.poi.ss.formula.functions.T; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; @Service public class ClassTeachingServiceImpl implements ClassTeachingService { @@ -23,11 +24,21 @@ public class ClassTeachingServiceImpl implements ClassTeachingService { return ex; } + /** + * 查询班级实验信息 + * @param page + * @param size + * @param recordVo + * @return + */ @Override + @Transactional public PageUtils queryClassRecord(Integer page, Integer size, ProjectRecordVo recordVo) { //分页对象 Page page1 = new Page<>(page, size); recordVo.setIsdel(Constant.IsDel.NOT_DEL.getType()); + this.classMapper.updateSurplusTimeNull(recordVo);//将已结束的实验的倒计时重置为0 + this.classMapper.updateSurplusTime(recordVo);//倒计时:设定倒计时的剩余时间 IPage schoolRecord = this.classMapper.getByClassRecord(page1, recordVo); PageUtils pageUtils = new PageUtils(schoolRecord); return pageUtils; diff --git a/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java b/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java index 29c2f6c..4506a33 100644 --- a/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java +++ b/src/main/java/com/msdw/tms/service/impl/ProjectRecordServiceImpl.java @@ -70,11 +70,13 @@ public class ProjectRecordServiceImpl extends ServiceImpl projectIds = vo.getProjectIds(); ProjectRecordEntity projectRecord = new ProjectRecordEntity().setUserid(userId).setIsdel(Constant.IsDel.NOT_DEL.getType()); - List projectRecordVos = this.baseMapper.getByUserRecordImport(projectRecord); + List projectRecordVos = this.baseMapper.getByUserRecordImport(projectRecord,projectIds); List importRequests = projectRecordVos.stream().map(project -> { ProjectRecordImportRequest request = new ProjectRecordImportRequest(); diff --git a/src/main/resources/mapper/tms/ClassTeachingDao.xml b/src/main/resources/mapper/tms/ClassTeachingDao.xml index 7327f7b..59cf6ec 100644 --- a/src/main/resources/mapper/tms/ClassTeachingDao.xml +++ b/src/main/resources/mapper/tms/ClassTeachingDao.xml @@ -10,6 +10,7 @@ SELECT id, experimental_class_name, + surplus_time, experiment_duration, experimental_name, experimental_number, @@ -19,11 +20,27 @@ FROM tms_experimental_teaching WHERE - `status` = #{cla.status} - and is_code = #{cla.isCode} - and ( project_name like concat('%',#{cla.condition},'%') or experimental_class_name like concat('%',#{cla.condition},'%') ) - and stop_time between #{cla.endTime} and #{cla.startTime} - and DATE_SUB(CURDATE(), INTERVAL #{cla.month} month ) <= date(stop_time) + is_del=0 + and `status` = #{cla.status} + and ( project_name like concat('%',#{cla.condition},'%') or experimental_class_name like concat('%',#{cla.condition},'%') ) + and stop_time between #{cla.endTime} and #{cla.startTime} + and DATE_SUB(CURDATE(), INTERVAL #{cla.month} month ) <= date(stop_time) + + UPDATE tms_experimental_teaching + SET surplus_time = TIMEDIFF( stop_time, NOW( ) ) + WHERE + now( ) >= start_time + AND stop_time >= now( ) + AND is_del=0 + + + UPDATE tms_experimental_teaching + SET surplus_time = 0 + WHERE + now( ) >= stop_time + AND is_del=0 + + \ No newline at end of file diff --git a/src/main/resources/mapper/tms/ProjectRecordDao.xml b/src/main/resources/mapper/tms/ProjectRecordDao.xml index 685f02c..ca93d17 100644 --- a/src/main/resources/mapper/tms/ProjectRecordDao.xml +++ b/src/main/resources/mapper/tms/ProjectRecordDao.xml @@ -69,9 +69,14 @@ tms_project_record tpr LEFT JOIN tms_project tp ON tpr.projectId = tp.projectId WHERE - tpr.userId = #{userid} + tpr.userId = #{pro.userid} AND - tpr.isdel = #{isdel} + tpr.isdel = #{pro.isdel} + AND tpr.projectId IN + + #{projectId} + +