更新学生考试记录和签到时同步培训用户时间信息
parent
c024d8000b
commit
6d1d4ad1de
|
|
@ -58,7 +58,6 @@ public class ClassUpdateExe {
|
||||||
public void executePostpone(ClassPostponeCmd classPostponeCmd){
|
public void executePostpone(ClassPostponeCmd classPostponeCmd){
|
||||||
ClassE classE = new ClassE();
|
ClassE classE = new ClassE();
|
||||||
BeanUtils.copyProperties(classPostponeCmd, classE);
|
BeanUtils.copyProperties(classPostponeCmd, classE);
|
||||||
classE.postpone();
|
|
||||||
classGateway.update(classE);
|
classGateway.update(classE);
|
||||||
studentRepository.postponeUpdateStudent(classPostponeCmd.getClassId());
|
studentRepository.postponeUpdateStudent(classPostponeCmd.getClassId());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,13 @@ import com.zcloud.edu.domain.gateway.study.StudentExamRecordGateway;
|
||||||
import com.zcloud.edu.domain.model.study.ClassExamPaperE;
|
import com.zcloud.edu.domain.model.study.ClassExamPaperE;
|
||||||
import com.zcloud.edu.domain.model.study.StudentExamRecordE;
|
import com.zcloud.edu.domain.model.study.StudentExamRecordE;
|
||||||
import com.zcloud.edu.domain.model.study.StudentExamRecordItemE;
|
import com.zcloud.edu.domain.model.study.StudentExamRecordItemE;
|
||||||
|
import com.zcloud.edu.domain.model.training.TrainingUserE;
|
||||||
import com.zcloud.edu.dto.clientobject.study.StudentExamRecordCO;
|
import com.zcloud.edu.dto.clientobject.study.StudentExamRecordCO;
|
||||||
import com.zcloud.edu.dto.study.StudentExamRecordAddCmd;
|
import com.zcloud.edu.dto.study.StudentExamRecordAddCmd;
|
||||||
import com.zcloud.edu.dto.study.StudentExamRecordItemAddCmd;
|
import com.zcloud.edu.dto.study.StudentExamRecordItemAddCmd;
|
||||||
import com.zcloud.edu.persistence.dataobject.study.ClassDO;
|
import com.zcloud.edu.persistence.dataobject.study.*;
|
||||||
import com.zcloud.edu.persistence.dataobject.study.ClassExamPaperDO;
|
|
||||||
import com.zcloud.edu.persistence.dataobject.study.StudentExamRecordDO;
|
|
||||||
import com.zcloud.edu.persistence.dataobject.study.StudentExamRecordItemDO;
|
|
||||||
import com.zcloud.edu.persistence.repository.study.*;
|
import com.zcloud.edu.persistence.repository.study.*;
|
||||||
|
import com.zcloud.edu.persistence.repository.training.TrainingUserRepository;
|
||||||
import io.swagger.models.auth.In;
|
import io.swagger.models.auth.In;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
|
|
@ -43,6 +42,7 @@ public class StudentExamRecordAddExe {
|
||||||
private final StudentExamRecordRepository studentExamRecordRepository;
|
private final StudentExamRecordRepository studentExamRecordRepository;
|
||||||
private final ClassRepository classRepository;
|
private final ClassRepository classRepository;
|
||||||
private final StudentRepository studentRepository;
|
private final StudentRepository studentRepository;
|
||||||
|
private final TrainingUserRepository trainingUserRepository;
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public SingleResponse<StudentExamRecordCO> execute(StudentExamRecordAddCmd cmd) {
|
public SingleResponse<StudentExamRecordCO> execute(StudentExamRecordAddCmd cmd) {
|
||||||
ClassDO classDO = classRepository.getByClassId(cmd.getClassId());
|
ClassDO classDO = classRepository.getByClassId(cmd.getClassId());
|
||||||
|
|
@ -68,6 +68,10 @@ public class StudentExamRecordAddExe {
|
||||||
params.put("state",1);
|
params.put("state",1);
|
||||||
params.put("studentId", studentExamRecordE.getStudentId());
|
params.put("studentId", studentExamRecordE.getStudentId());
|
||||||
studentRepository.updateStudent(params);
|
studentRepository.updateStudent(params);
|
||||||
|
StudentDO studentDO = studentRepository.findInfoByStudentId(studentExamRecordE.getStudentId());
|
||||||
|
TrainingUserE trainingUserE = new TrainingUserE();
|
||||||
|
trainingUserE.initTrainingUser(studentDO.getPhone(), classDO.getValidStartTime(), classDO.getValidEndTime());
|
||||||
|
trainingUserRepository.updateTime(trainingUserE);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,13 @@ package com.zcloud.edu.command.study;
|
||||||
import com.alibaba.cola.exception.BizException;
|
import com.alibaba.cola.exception.BizException;
|
||||||
import com.zcloud.edu.domain.gateway.study.StudentSignGateway;
|
import com.zcloud.edu.domain.gateway.study.StudentSignGateway;
|
||||||
import com.zcloud.edu.domain.model.study.StudentSignE;
|
import com.zcloud.edu.domain.model.study.StudentSignE;
|
||||||
|
import com.zcloud.edu.domain.model.training.TrainingUserE;
|
||||||
import com.zcloud.edu.dto.study.StudentSignUpdateCmd;
|
import com.zcloud.edu.dto.study.StudentSignUpdateCmd;
|
||||||
|
import com.zcloud.edu.persistence.dataobject.study.ClassDO;
|
||||||
import com.zcloud.edu.persistence.dataobject.study.StudentDO;
|
import com.zcloud.edu.persistence.dataobject.study.StudentDO;
|
||||||
|
import com.zcloud.edu.persistence.repository.study.ClassRepository;
|
||||||
import com.zcloud.edu.persistence.repository.study.StudentRepository;
|
import com.zcloud.edu.persistence.repository.study.StudentRepository;
|
||||||
|
import com.zcloud.edu.persistence.repository.training.TrainingUserRepository;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
@ -26,6 +30,8 @@ import java.util.Map;
|
||||||
public class StudentSignUpdateExe {
|
public class StudentSignUpdateExe {
|
||||||
private final StudentSignGateway studentSignGateway;
|
private final StudentSignGateway studentSignGateway;
|
||||||
private final StudentRepository studentRepository;
|
private final StudentRepository studentRepository;
|
||||||
|
private final ClassRepository classRepository;
|
||||||
|
private final TrainingUserRepository trainingUserRepository;
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void execute(StudentSignUpdateCmd studentSignUpdateCmd) {
|
public void execute(StudentSignUpdateCmd studentSignUpdateCmd) {
|
||||||
|
|
@ -33,6 +39,7 @@ public class StudentSignUpdateExe {
|
||||||
BeanUtils.copyProperties(studentSignUpdateCmd, studentSignE);
|
BeanUtils.copyProperties(studentSignUpdateCmd, studentSignE);
|
||||||
boolean res = studentSignGateway.update(studentSignE);
|
boolean res = studentSignGateway.update(studentSignE);
|
||||||
|
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
if (studentSignUpdateCmd.getType() == 1){
|
if (studentSignUpdateCmd.getType() == 1){
|
||||||
params.put("signFlag",1);
|
params.put("signFlag",1);
|
||||||
|
|
@ -40,6 +47,16 @@ public class StudentSignUpdateExe {
|
||||||
params.put("examSignFlag",1);
|
params.put("examSignFlag",1);
|
||||||
}
|
}
|
||||||
params.put("studentId", studentSignUpdateCmd.getStudentId());
|
params.put("studentId", studentSignUpdateCmd.getStudentId());
|
||||||
|
|
||||||
|
ClassDO classDO = classRepository.getByClassId(studentSignUpdateCmd.getClassId());
|
||||||
|
if (classDO != null && classDO.getExamination() == 0){
|
||||||
|
StudentDO studentDO = studentRepository.findInfoByStudentId(studentSignUpdateCmd.getStudentId());
|
||||||
|
params.put("state", 1);
|
||||||
|
TrainingUserE trainingUserE = new TrainingUserE();
|
||||||
|
trainingUserE.initTrainingUser(studentDO.getPhone(), classDO.getStartTime(), classDO.getEndTime());
|
||||||
|
trainingUserRepository.updateTime(trainingUserE);
|
||||||
|
}
|
||||||
|
|
||||||
studentRepository.updateStudent(params);
|
studentRepository.updateStudent(params);
|
||||||
if (!res) {
|
if (!res) {
|
||||||
throw new BizException("修改失败");
|
throw new BizException("修改失败");
|
||||||
|
|
|
||||||
|
|
@ -85,23 +85,10 @@ public class ClassE extends BaseE {
|
||||||
}
|
}
|
||||||
public void initUpdate(){
|
public void initUpdate(){
|
||||||
if(this.updateType == 2){
|
if(this.updateType == 2){
|
||||||
if(DateUtil.isBeforeThan(this.startTime)){
|
this.state = 2;
|
||||||
this.state = 2;
|
|
||||||
} else if(DateUtil.isBeforeThan(this.endTime)){
|
|
||||||
this.state = 3;
|
|
||||||
} else {
|
|
||||||
this.state = 4;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void postpone(){
|
|
||||||
if(DateUtil.isBeforeThan(this.endTime)){
|
|
||||||
this.state = 3;
|
|
||||||
} else {
|
|
||||||
this.state = 4;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断班级是否开班
|
* 判断班级是否开班
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.zcloud.edu.domain.enums.ExamineStatusEnum;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web-domain
|
* web-domain
|
||||||
|
|
@ -42,5 +43,12 @@ public class TrainingUserE extends BaseE {
|
||||||
trainingUser.setEndTime(LocalDateTime.now().plusYears(1));
|
trainingUser.setEndTime(LocalDateTime.now().plusYears(1));
|
||||||
return trainingUser;
|
return trainingUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initTrainingUser(String phone, String startTime, String endTime) {
|
||||||
|
this.setPhone(phone);
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||||
|
this.setStartTime(LocalDateTime.parse(startTime, formatter));
|
||||||
|
this.setEndTime(LocalDateTime.parse(endTime, formatter));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,9 @@ package com.zcloud.edu.persistence.mapper;
|
||||||
import com.zcloud.edu.persistence.dataobject.TrainingUserDO;
|
import com.zcloud.edu.persistence.dataobject.TrainingUserDO;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web-infrastructure
|
* web-infrastructure
|
||||||
|
|
@ -11,6 +14,7 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface TrainingUserMapper extends BaseMapper<TrainingUserDO> {
|
public interface TrainingUserMapper extends BaseMapper<TrainingUserDO> {
|
||||||
|
void updateTime(@Param("params") Map<String, Object> params);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.zcloud.edu.persistence.repository.impl;
|
package com.zcloud.edu.persistence.repository.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.jjb.saas.framework.repository.common.PageHelper;
|
import com.jjb.saas.framework.repository.common.PageHelper;
|
||||||
import com.zcloud.edu.domain.model.training.TrainingUserE;
|
import com.zcloud.edu.domain.model.training.TrainingUserE;
|
||||||
import com.zcloud.edu.persistence.dataobject.TrainingUserDO;
|
import com.zcloud.edu.persistence.dataobject.TrainingUserDO;
|
||||||
|
|
@ -36,5 +37,11 @@ public class TrainingUserRepositoryImpl extends BaseRepositoryImpl<TrainingUserM
|
||||||
IPage<TrainingUserDO> result = trainingUserMapper.selectPage(iPage, queryWrapper);
|
IPage<TrainingUserDO> result = trainingUserMapper.selectPage(iPage, queryWrapper);
|
||||||
return PageHelper.pageToResponse(result, result.getRecords());
|
return PageHelper.pageToResponse(result, result.getRecords());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTime(TrainingUserE trainingUserE) {
|
||||||
|
Map<String, Object> params = PageQueryHelper.toHashMap(trainingUserE);
|
||||||
|
trainingUserMapper.updateTime(params);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,5 +15,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public interface TrainingUserRepository extends BaseRepository<TrainingUserDO> {
|
public interface TrainingUserRepository extends BaseRepository<TrainingUserDO> {
|
||||||
PageResponse<TrainingUserDO> listPage(Map<String,Object> params);
|
PageResponse<TrainingUserDO> listPage(Map<String,Object> params);
|
||||||
|
|
||||||
|
void updateTime(TrainingUserE trainingUserE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,17 @@
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
<mapper namespace="com.zcloud.edu.persistence.mapper.TrainingUserMapper">
|
<mapper namespace="com.zcloud.edu.persistence.mapper.TrainingUserMapper">
|
||||||
|
<update id="updateTime">
|
||||||
|
update training_user
|
||||||
|
<set>
|
||||||
|
start_time = #{params.startTime},
|
||||||
|
end_time = #{params.endTime}
|
||||||
|
</set>
|
||||||
|
<where>
|
||||||
|
phone = #{params.phone}
|
||||||
|
and ( end_time is null or end_time < #{params.endTime})
|
||||||
|
</where>
|
||||||
|
where phone = #{phone}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,14 @@
|
||||||
c.training_location,
|
c.training_location,
|
||||||
c.corpinfo_id,
|
c.corpinfo_id,
|
||||||
ci.corp_name,
|
ci.corp_name,
|
||||||
c.state,
|
CASE
|
||||||
|
WHEN state = 1 THEN 1
|
||||||
|
<![CDATA[
|
||||||
|
WHEN NOW() < c.start_time THEN 2
|
||||||
|
WHEN NOW() < c.end_time THEN 3
|
||||||
|
WHEN NOW() > c.end_time THEN 4
|
||||||
|
]]>
|
||||||
|
END AS state,
|
||||||
c.valid_start_time,
|
c.valid_start_time,
|
||||||
c.valid_end_time,
|
c.valid_end_time,
|
||||||
c.examination,
|
c.examination,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue