Commit c83d0168 authored by zhangqingle's avatar zhangqingle

增加签到开始时间字段,增加签到接口

parent 19bb1fc5
...@@ -279,12 +279,12 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -279,12 +279,12 @@ public class BLessonController extends PaginationController<BLesson> {
@ApiOperation(value = "614 退出课程", notes = "根据ID停用一条记录") @ApiOperation(value = "614 退出课程", notes = "根据ID停用一条记录")
@ApiImplicitParam(name = "businessId", value = "退出课程的选课id", required = true, dataType = "varchar") @ApiImplicitParam(name = "businessId", value = "退出课程的选课id", required = true, dataType = "varchar")
@PostMapping(value = "/quit") @PostMapping(value = "/quit")
public Result quit(CurUser curUser, @Valid QuitLessonDTO quitLessonDTO, BindingResult bindingResult) { public Result quit(CurUser curUser, @Valid QuitAndSignDTO quitAndSignDTO, BindingResult bindingResult) {
PersistModel data = bLessonPersonService.quit(quitLessonDTO, curUser); PersistModel data = bLessonPersonService.quit(quitAndSignDTO, curUser);
return Result.builder(data, return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR, MessageConstant.MESSAGE_ALERT_ERROR,
quitLessonDTO); quitAndSignDTO);
} }
/** /**
...@@ -713,4 +713,20 @@ public class BLessonController extends PaginationController<BLesson> { ...@@ -713,4 +713,20 @@ public class BLessonController extends PaginationController<BLesson> {
gridModel); gridModel);
} }
/**
* @param
* @return
* @author: zhangqingle
*/
@ApiOperation(value = "642 培训签到", notes = "培训签到")
@PostMapping(value = "/signIn")
public Result signIn(CurUser curUser, @Valid QuitAndSignDTO quitAndSignDTO, BindingResult bindingResult) {
PersistModel data = bLessonPersonService.signIn(quitAndSignDTO);
return Result.builder(data,
MessageConstant.MESSAGE_ALERT_SUCCESS,
MessageConstant.MESSAGE_ALERT_ERROR,
quitAndSignDTO);
}
} }
...@@ -7,18 +7,15 @@ import org.hibernate.validator.constraints.Length; ...@@ -7,18 +7,15 @@ import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
@Data @Data
public class QuitLessonDTO { public class QuitAndSignDTO {
@Length(min = 1,max = 64,message = "长度最小为1,最大为50") @ApiModelProperty(value = "选课主键id", required = false)
@ApiModelProperty(value = "选课主键id")
@NotNull
private String businessId; private String businessId;
@Length(min = 1,max = 64,message = "长度最小为1,最大为50") @ApiModelProperty(value = "课程id", required = false)
@ApiModelProperty(value = "课程id")
@NotNull
private String lessonId; private String lessonId;
private String cropId; private String corpId;
private String userId;
} }
...@@ -262,6 +262,12 @@ public class BLesson extends IdEntity<BLesson> { ...@@ -262,6 +262,12 @@ public class BLesson extends IdEntity<BLesson> {
@Transient @Transient
private String lessonPersonId; private String lessonPersonId;
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8",pattern = "yyyy/MM/dd HH:mm:ss")
@ApiModelProperty(value = "签到时间")
@Transient
private Date signStartDate;
public void initModel(){ public void initModel(){
// this.setDefaultUrl(global.getDEFAULT_COURSE_LOCATION()); // this.setDefaultUrl(global.getDEFAULT_COURSE_LOCATION());
......
...@@ -13,10 +13,10 @@ public interface BLessonPersonService { ...@@ -13,10 +13,10 @@ public interface BLessonPersonService {
/** /**
* 退出课程 * 退出课程
* @param quitLessonDTO * @param quitAndSignDTO
* @return * @return
*/ */
PersistModel quit(QuitLessonDTO quitLessonDTO,CurUser curUser); PersistModel quit(QuitAndSignDTO quitAndSignDTO, CurUser curUser);
/** /**
...@@ -57,4 +57,12 @@ public interface BLessonPersonService { ...@@ -57,4 +57,12 @@ public interface BLessonPersonService {
* @return * @return
*/ */
PersistModel addMyLearnLesson(AddMyLearnLessonDTO addMyLearnLessonDTO, CurUser curUser); PersistModel addMyLearnLesson(AddMyLearnLessonDTO addMyLearnLessonDTO, CurUser curUser);
/**
* 培训签到
* @param quitAndSignDTO
* @return
*/
PersistModel signIn(QuitAndSignDTO quitAndSignDTO);
} }
...@@ -11,16 +11,13 @@ import org.rcisoft.business.blesson.entity.BLesson; ...@@ -11,16 +11,13 @@ import org.rcisoft.business.blesson.entity.BLesson;
import org.rcisoft.business.blesson.dao.BLessonPersonRepository; import org.rcisoft.business.blesson.dao.BLessonPersonRepository;
import org.rcisoft.business.blesson.entity.BLessonPerson; import org.rcisoft.business.blesson.entity.BLessonPerson;
import org.rcisoft.business.blesson.service.BLessonPersonService; import org.rcisoft.business.blesson.service.BLessonPersonService;
import org.rcisoft.business.blesson.service.BLessonService;
import org.rcisoft.business.bpersonvalue.dao.BPersonValueRepository; import org.rcisoft.business.bpersonvalue.dao.BPersonValueRepository;
import org.rcisoft.business.bpersonvalue.entity.BPersonValue; import org.rcisoft.business.bpersonvalue.entity.BPersonValue;
import org.rcisoft.common.util.feignDto.*; import org.rcisoft.common.util.feignDto.*;
import org.rcisoft.common.util.outClient.MTCotactApiRequestClient; import org.rcisoft.common.util.outClient.MTCotactApiRequestClient;
import org.rcisoft.core.aop.PageUtil; import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.core.exception.ServiceException; import org.rcisoft.core.exception.ServiceException;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.result.ResultExceptionEnum;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.util.IdGen; import org.rcisoft.core.util.IdGen;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
...@@ -70,20 +67,11 @@ public class BLessonPersonServiceImpl implements BLessonPersonService { ...@@ -70,20 +67,11 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
@Transactional(propagation = Propagation.REQUIRED, readOnly = false) @Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override @Override
public PersistModel quit(QuitLessonDTO quitLessonDTO,CurUser curUser) { public PersistModel quit(QuitAndSignDTO quitAndSignDTO, CurUser curUser) {
BLessonPerson bLessonPerson = new BLessonPerson(); BLessonPerson bLessonPerson = getLessonPersonByDto(quitAndSignDTO);
if (StringUtils.isNotEmpty(quitLessonDTO.getBusinessId())){
bLessonPerson = bLessonPersonRepository.selectById(quitLessonDTO.getBusinessId());
}else {
AddMyLearnLessonDTO addMyLearnLessonDTO = new AddMyLearnLessonDTO(quitLessonDTO.getLessonId(),curUser.getCorpId(),curUser.getUserId());
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByPersonAndLesson(addMyLearnLessonDTO);
if (bLessonPersonList != null && bLessonPersonList.get(0) != null){
bLessonPerson = bLessonPersonList.get(0);
}
}
BLesson bLesson = new BLesson(); BLesson bLesson = new BLesson();
bLesson.setBusinessId(quitLessonDTO.getLessonId()); bLesson.setBusinessId(quitAndSignDTO.getLessonId());
bLesson = bLessonRepository.selectByPrimaryKey(bLesson); bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
if (bLesson == null){ if (bLesson == null){
throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR); throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR);
...@@ -104,23 +92,26 @@ public class BLessonPersonServiceImpl implements BLessonPersonService { ...@@ -104,23 +92,26 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
bLessonPerson.setApplyDate(null); bLessonPerson.setApplyDate(null);
UserUtil.setCurrentMergeOperation(bLessonPerson); UserUtil.setCurrentMergeOperation(bLessonPerson);
// int line = bLessonPersonRepository.quit(quitLessonDTO.getBusinessId()); // int line = bLessonPersonRepository.quit(quitAndSignDTO.getBusinessId());
int line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson); int line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
//重新统计在学人数 //重新统计在学人数
bLessonRepository.personNumberReCount(quitLessonDTO.getLessonId(),bLesson.getLessonType()); bLessonRepository.personNumberReCount(quitAndSignDTO.getLessonId(),bLesson.getLessonType());
return new PersistModel(line); return new PersistModel(line);
} }
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override @Override
public List<BLesson> queryLearnBLessonsByPagination(PageUtil pageUtil, ILearnLessonDTO model) { public List<BLesson> queryLearnBLessonsByPagination(PageUtil pageUtil, ILearnLessonDTO model) {
return bLessonPersonRepository.queryLearnBLessons(model); return bLessonPersonRepository.queryLearnBLessons(model);
} }
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override @Override
public StudentTrackingChartRspDTO studentTrackingChart(StudentTrackingChartDTO studentTrackingChartDTO) { public StudentTrackingChartRspDTO studentTrackingChart(StudentTrackingChartDTO studentTrackingChartDTO) {
return bLessonPersonRepository.studentTrackingChart(studentTrackingChartDTO); return bLessonPersonRepository.studentTrackingChart(studentTrackingChartDTO);
} }
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override @Override
public List<StudentTrackingRspDTO> studentTrackingByPagination(PageUtil pageUtil, StudentTrackingDTO studentTrackingDTO) { public List<StudentTrackingRspDTO> studentTrackingByPagination(PageUtil pageUtil, StudentTrackingDTO studentTrackingDTO) {
// List<Long> deptIds = new ArrayList<>(); // List<Long> deptIds = new ArrayList<>();
...@@ -239,6 +230,7 @@ public class BLessonPersonServiceImpl implements BLessonPersonService { ...@@ -239,6 +230,7 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
return new PersistModel(1,result); return new PersistModel(1,result);
} }
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override @Override
public PersistModel addMyLearnLesson(AddMyLearnLessonDTO addMyLearnLessonDTO, CurUser curUser) { public PersistModel addMyLearnLesson(AddMyLearnLessonDTO addMyLearnLessonDTO, CurUser curUser) {
...@@ -329,4 +321,57 @@ public class BLessonPersonServiceImpl implements BLessonPersonService { ...@@ -329,4 +321,57 @@ public class BLessonPersonServiceImpl implements BLessonPersonService {
return new PersistModel(1); return new PersistModel(1);
} }
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
@Override
public PersistModel signIn(QuitAndSignDTO quitAndSignDTO) {
BLessonPerson bLessonPerson = getLessonPersonByDto(quitAndSignDTO);
BLesson bLesson = new BLesson();
bLesson.setBusinessId(quitAndSignDTO.getLessonId());
bLesson = bLessonRepository.selectByPrimaryKey(bLesson);
if (bLesson == null){
throw new ServiceException(ResultServiceEnums.NOT_LESSON_ERROR);
}
if (bLessonPerson == null && "0".equals(bLesson.getLessonType())){
throw new ServiceException(ResultServiceEnums.APPOINT_NOT_CLOSE);
}
if (bLessonPerson == null && "1".equals(bLesson.getLessonType())){
throw new ServiceException(ResultServiceEnums.LEARN_LESSON_NOT_EXISTS);
}
Date now = new Date();
Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time);
//时间不在签到范围内
if (now.before(signStart) || bLesson.getTrainOverDate().before(now)){
throw new ServiceException(ResultServiceEnums.NOT_SIGN_DATE);
}
//TODO 判断 曾经是否学完过 奖励积分
if ( "2".equals(bLessonPerson.getIsFinish()) && !"1".equals(bLessonPerson.getEverFinished())){
//查询课程信息
BPersonValue bPersonValue = new BPersonValue(bLessonPerson.getPersonId(),"学完课程",bLesson.getValueGain(),"0");
bLessonServiceImpl.addValueEvent(bLessonPerson.getPersonId(),bPersonValue,null);
}
bLessonPerson.setEverFinished("1");
bLessonPerson.setSignDate(new Date());
bLessonPerson.setTrainIsSign("2");
int line = bLessonPersonRepository.updateByPrimaryKeySelective(bLessonPerson);
return new PersistModel(line);
}
@Transactional(propagation = Propagation.REQUIRED, readOnly = false,rollbackFor= Exception.class)
BLessonPerson getLessonPersonByDto(QuitAndSignDTO quitAndSignDTO){
BLessonPerson bLessonPerson = new BLessonPerson();
if (StringUtils.isNotEmpty(quitAndSignDTO.getBusinessId())){
bLessonPerson = bLessonPersonRepository.selectById(quitAndSignDTO.getBusinessId());
}else {
AddMyLearnLessonDTO addMyLearnLessonDTO = new AddMyLearnLessonDTO(quitAndSignDTO.getLessonId(), quitAndSignDTO.getCorpId(), quitAndSignDTO.getUserId());
List<BLessonPerson> bLessonPersonList = bLessonPersonRepository.selectByPersonAndLesson(addMyLearnLessonDTO);
if (bLessonPersonList != null && bLessonPersonList.get(0) != null){
bLessonPerson = bLessonPersonList.get(0);
}
}
return bLessonPerson;
}
} }
...@@ -1290,6 +1290,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1290,6 +1290,7 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<SysUser> findAppointPerson(CurUser curUser, String lessonId) { public List<SysUser> findAppointPerson(CurUser curUser, String lessonId) {
List<BAppoint> bAppoints = bAppointRepository.selectByLessonId(lessonId); List<BAppoint> bAppoints = bAppointRepository.selectByLessonId(lessonId);
if (bAppoints == null || bAppoints.size()<1){ if (bAppoints == null || bAppoints.size()<1){
...@@ -1304,11 +1305,13 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1304,11 +1305,13 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<BLesson> queryCollectByPagination(PageUtil pageUtil, String lessonType, CurUser curUser) { public List<BLesson> queryCollectByPagination(PageUtil pageUtil, String lessonType, CurUser curUser) {
return bLessonRepository.selectMyCollect(lessonType, curUser); return bLessonRepository.selectMyCollect(lessonType, curUser);
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public Map<String,Object> judgeVisibleAuthority(CurUser curUser, String lessonId) { public Map<String,Object> judgeVisibleAuthority(CurUser curUser, String lessonId) {
BLesson bLesson = bLessonRepository.selectInfoById(lessonId,curUser); BLesson bLesson = bLessonRepository.selectInfoById(lessonId,curUser);
if (bLesson == null){ if (bLesson == null){
...@@ -1349,6 +1352,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1349,6 +1352,7 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<StudentTrackingRspDTO> userManageLessonByPagination(PageUtil pageUtil, UserLessonDTO userLessonDTO) { public List<StudentTrackingRspDTO> userManageLessonByPagination(PageUtil pageUtil, UserLessonDTO userLessonDTO) {
String trainTypeSelStr = ""; String trainTypeSelStr = "";
if ("0".equals(userLessonDTO.getTrainType())){ if ("0".equals(userLessonDTO.getTrainType())){
...@@ -1365,6 +1369,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1365,6 +1369,7 @@ public class BLessonServiceImpl implements BLessonService {
} }
@Override @Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public List<ExamDto> userManageExamByPagination(PageUtil pageUtil, ExamQueryDto dto) { public List<ExamDto> userManageExamByPagination(PageUtil pageUtil, ExamQueryDto dto) {
List<ExamDto> list = bLessonPersonRepository.userManageExam(dto); List<ExamDto> list = bLessonPersonRepository.userManageExam(dto);
if(list.size()>0){ if(list.size()>0){
...@@ -1466,6 +1471,7 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1466,6 +1471,7 @@ public class BLessonServiceImpl implements BLessonService {
if (bLesson.getTrainStartDate() != null && bLesson.getTrainOverDate() !=null && StringUtils.isNotEmpty(bLesson.getTrainSignTime())){ if (bLesson.getTrainStartDate() != null && bLesson.getTrainOverDate() !=null && StringUtils.isNotEmpty(bLesson.getTrainSignTime())){
Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000; Long time = Long.parseLong(bLesson.getTrainSignTime()) * 60 * 1000;
Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time); Date signStart = new Date(bLesson.getTrainStartDate().getTime() - time);
bLesson.setSignStartDate(signStart);
if (signStart.before(nowDate) && nowDate.before(bLesson.getTrainOverDate())){ if (signStart.before(nowDate) && nowDate.before(bLesson.getTrainOverDate())){
bLesson.setTrainDateState("1"); bLesson.setTrainDateState("1");
} }
...@@ -1527,7 +1533,8 @@ public class BLessonServiceImpl implements BLessonService { ...@@ -1527,7 +1533,8 @@ public class BLessonServiceImpl implements BLessonService {
UserUtil.setCurrentPersistOperation(bPersonValue); UserUtil.setCurrentPersistOperation(bPersonValue);
bPersonValueRepository.add(bPersonValue); bPersonValueRepository.add(bPersonValue);
//积分变化后 s_user表中value字段重新统计 //积分变化后 s_user表中value字段重新统计
bPersonValueRepository.updateUserValue(personId, lockNum); int line = bPersonValueRepository.updateUserValue(personId, lockNum);
//TODO 判断返回值 抛异常
} }
} }
......
...@@ -247,6 +247,7 @@ public enum ResultServiceEnums { ...@@ -247,6 +247,7 @@ public enum ResultServiceEnums {
MANAGE_NOT_STOP(147,"不能停用主管理员"), MANAGE_NOT_STOP(147,"不能停用主管理员"),
APPLY_TRAIN_NOT_EXISTS(148,"未报名该培训"), APPLY_TRAIN_NOT_EXISTS(148,"未报名该培训"),
LEARN_LESSON_NOT_EXISTS(149,"未学习该课程"), LEARN_LESSON_NOT_EXISTS(149,"未学习该课程"),
NOT_SIGN_DATE(150,"当前时间不在签到时间范围内"),
; ;
private Integer code; private Integer code;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment