|
|
|
|
package com.ibeetl.jlw.service;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.lang.Assert;
|
|
|
|
|
import cn.hutool.core.util.BooleanUtil;
|
|
|
|
|
import cn.hutool.extra.validation.BeanValidationResult;
|
|
|
|
|
import cn.hutool.extra.validation.ValidationUtil;
|
|
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
import cn.jlw.util.ToolUtils;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ibeetl.admin.core.service.CoreBaseService;
|
|
|
|
|
import com.ibeetl.admin.core.util.PlatformException;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonResult;
|
|
|
|
|
import com.ibeetl.admin.core.web.JsonReturnCode;
|
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseStudentSigninLogDao;
|
|
|
|
|
import com.ibeetl.jlw.dao.TeacherOpenCourseStudentSigninSettingDao;
|
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourseStudentSigninLog;
|
|
|
|
|
import com.ibeetl.jlw.entity.TeacherOpenCourseStudentSigninSetting;
|
|
|
|
|
import com.ibeetl.jlw.entity.dto.TeacherOpenCourseStudentSigninLogSigninDTO;
|
|
|
|
|
import com.ibeetl.jlw.web.query.TeacherOpenCourseStudentSigninLogQuery;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.beetl.sql.core.SqlId;
|
|
|
|
|
import org.beetl.sql.core.engine.PageQuery;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
import static cn.jlw.util.IpUtils.getIpAddr;
|
|
|
|
|
import static com.ibeetl.admin.core.util.servlet.ServletUtils.getRequest;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 学生签到记录 Service
|
|
|
|
|
* 当分布式ID开启后请勿使用insert(*,true)
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
@Transactional
|
|
|
|
|
@Validated
|
|
|
|
|
public class TeacherOpenCourseStudentSigninLogService extends CoreBaseService<TeacherOpenCourseStudentSigninLog>{
|
|
|
|
|
|
|
|
|
|
@Resource private TeacherOpenCourseStudentSigninLogDao teacherOpenCourseStudentSigninLogDao;
|
|
|
|
|
@Resource private TeacherOpenCourseStudentSigninSettingDao teacherOpenCourseStudentSigninSettingDao;
|
|
|
|
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseStudentSigninLog>queryByCondition(PageQuery query){
|
|
|
|
|
PageQuery ret = teacherOpenCourseStudentSigninLogDao.queryByCondition(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PageQuery<TeacherOpenCourseStudentSigninLog>queryByConditionQuery(PageQuery query){
|
|
|
|
|
PageQuery ret = teacherOpenCourseStudentSigninLogDao.queryByConditionQuery(query);
|
|
|
|
|
queryListAfter(ret.getList());
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteByList(List list){
|
|
|
|
|
String ids = "";
|
|
|
|
|
ToolUtils.deleteNullList(list);
|
|
|
|
|
for(int i=0;null != list && i<list.size();i++){
|
|
|
|
|
ids += list.get(i).toString()+(i==list.size()-1?"":",");
|
|
|
|
|
}
|
|
|
|
|
if(StringUtils.isNotBlank(ids)){
|
|
|
|
|
teacherOpenCourseStudentSigninLogDao.deleteTeacherOpenCourseStudentSigninLogByIds(ids);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void deleteTeacherOpenCourseStudentSigninLog(String ids){
|
|
|
|
|
try {
|
|
|
|
|
teacherOpenCourseStudentSigninLogDao.deleteTeacherOpenCourseStudentSigninLogByIds(ids);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new PlatformException("批量删除学生签到记录失败", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String addAll(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> teacherOpenCourseStudentSigninLogList = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
teacherOpenCourseStudentSigninLogList = JSON.parseArray(teacherOpenCourseStudentSigninLogQuery.getTeacherOpenCourseStudentSigninLogJsonStr(), TeacherOpenCourseStudentSigninLog.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
try {
|
|
|
|
|
teacherOpenCourseStudentSigninLogList.add(JSONObject.parseObject(teacherOpenCourseStudentSigninLogQuery.getTeacherOpenCourseStudentSigninLogJsonStr(), TeacherOpenCourseStudentSigninLog.class));
|
|
|
|
|
} catch (Exception e1) {}
|
|
|
|
|
}
|
|
|
|
|
ToolUtils.deleteNullList(teacherOpenCourseStudentSigninLogList);
|
|
|
|
|
if(null != teacherOpenCourseStudentSigninLogList && teacherOpenCourseStudentSigninLogList.size()>0){
|
|
|
|
|
for(int i=0;i<teacherOpenCourseStudentSigninLogList.size();i++){
|
|
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = teacherOpenCourseStudentSigninLogList.get(i);
|
|
|
|
|
teacherOpenCourseStudentSigninLog.setUserId(teacherOpenCourseStudentSigninLogQuery.getUserId());
|
|
|
|
|
teacherOpenCourseStudentSigninLog.setOrgId(teacherOpenCourseStudentSigninLogQuery.getOrgId());
|
|
|
|
|
}
|
|
|
|
|
insertBatch(teacherOpenCourseStudentSigninLogList);
|
|
|
|
|
}
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JsonResult add(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = teacherOpenCourseStudentSigninLogQuery.pojo();
|
|
|
|
|
teacherOpenCourseStudentSigninLog.setTeacherOpenCourseStudentSigninLogAddTime(new Date());
|
|
|
|
|
teacherOpenCourseStudentSigninLogDao.insert(teacherOpenCourseStudentSigninLog);
|
|
|
|
|
teacherOpenCourseStudentSigninLogQuery.setTeacherOpenCourseStudentSigninLogId(teacherOpenCourseStudentSigninLog.getTeacherOpenCourseStudentSigninLogId());
|
|
|
|
|
JsonResult jsonResult = new JsonResult();
|
|
|
|
|
jsonResult.setData(teacherOpenCourseStudentSigninLog.getTeacherOpenCourseStudentSigninLogId());//自增的ID丢进去
|
|
|
|
|
jsonResult.setCode(JsonReturnCode.SUCCESS.getCode());
|
|
|
|
|
jsonResult.setMsg(msg);
|
|
|
|
|
return jsonResult;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String edit(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
TeacherOpenCourseStudentSigninLog teacherOpenCourseStudentSigninLog = teacherOpenCourseStudentSigninLogQuery.pojo();
|
|
|
|
|
teacherOpenCourseStudentSigninLogDao.updateTemplateById(teacherOpenCourseStudentSigninLog);
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String updateGivenByIds(TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
String msg = "";
|
|
|
|
|
if(StringUtils.isNotBlank(teacherOpenCourseStudentSigninLogQuery.get_given())){
|
|
|
|
|
boolean flag = teacherOpenCourseStudentSigninLogDao.updateGivenByIds(teacherOpenCourseStudentSigninLogQuery) > 0;
|
|
|
|
|
if(!flag){
|
|
|
|
|
msg = "更新指定参数失败";
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
msg = "指定参数为空";
|
|
|
|
|
}
|
|
|
|
|
return msg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TeacherOpenCourseStudentSigninLog> getValues (Object paras){
|
|
|
|
|
return sqlManager.select(SqlId.of("jlw.teacherOpenCourseStudentSigninLog.getTeacherOpenCourseStudentSigninLogValues"), TeacherOpenCourseStudentSigninLog.class, paras);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TeacherOpenCourseStudentSigninLog> getValuesByQuery (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
return teacherOpenCourseStudentSigninLogDao.getValuesByQuery(teacherOpenCourseStudentSigninLogQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<TeacherOpenCourseStudentSigninLog> getValuesByQueryNotWithPermission (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
return teacherOpenCourseStudentSigninLogDao.getValuesByQueryNotWithPermission(teacherOpenCourseStudentSigninLogQuery);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TeacherOpenCourseStudentSigninLog getInfo (Long teacherOpenCourseStudentSigninLogId){
|
|
|
|
|
TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
|
|
teacherOpenCourseStudentSigninLogQuery.setTeacherOpenCourseStudentSigninLogId(teacherOpenCourseStudentSigninLogId);
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> list = teacherOpenCourseStudentSigninLogDao.getValuesByQuery(teacherOpenCourseStudentSigninLogQuery);
|
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
|
return list.get(0);
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TeacherOpenCourseStudentSigninLog getInfo (TeacherOpenCourseStudentSigninLogQuery teacherOpenCourseStudentSigninLogQuery){
|
|
|
|
|
List<TeacherOpenCourseStudentSigninLog> list = teacherOpenCourseStudentSigninLogDao.getValuesByQuery(teacherOpenCourseStudentSigninLogQuery);
|
|
|
|
|
if(null != list && list.size()>0){
|
|
|
|
|
return list.get(0);
|
|
|
|
|
}else{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 学生端-签到
|
|
|
|
|
* @param signinDTO
|
|
|
|
|
*/
|
|
|
|
|
public void signin(@Validated TeacherOpenCourseStudentSigninLogSigninDTO signinDTO) {
|
|
|
|
|
|
|
|
|
|
// 根据type类型 验证Bean
|
|
|
|
|
BeanValidationResult beanValidationResult = ValidationUtil.warpValidate(signinDTO, signinDTO.getTeacherOpenCourseStudentSigninLogType().getClazz());
|
|
|
|
|
Assert.isTrue(beanValidationResult.isSuccess(), JSONUtil.toJsonStr(beanValidationResult.getErrorMessages()));
|
|
|
|
|
|
|
|
|
|
List<TeacherOpenCourseStudentSigninSetting> settingList =
|
|
|
|
|
teacherOpenCourseStudentSigninSettingDao.getByIds(signinDTO.getTeacherOpenCourseStudentSigninSettingId());
|
|
|
|
|
Assert.notEmpty(settingList, "签到配置ID无效!");
|
|
|
|
|
|
|
|
|
|
// 构建实体
|
|
|
|
|
TeacherOpenCourseStudentSigninLogQuery signinLogQuery = new TeacherOpenCourseStudentSigninLogQuery();
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseId(settingList.get(0).getTeacherOpenCourseId());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogType(signinDTO.getTeacherOpenCourseStudentSigninLogType().name());
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogIp(getIpAddr(getRequest()));
|
|
|
|
|
|
|
|
|
|
// 是否缺席
|
|
|
|
|
if(BooleanUtil.isTrue(signinDTO.getIsAbsent())) {
|
|
|
|
|
BeanValidationResult isAbsentValidationResult = ValidationUtil.warpValidate(signinDTO, TeacherOpenCourseStudentSigninLogSigninDTO.ManualClass.class);
|
|
|
|
|
Assert.isTrue(isAbsentValidationResult.isSuccess(), JSONUtil.toJsonStr(isAbsentValidationResult.getErrorMessages()));
|
|
|
|
|
signinLogQuery.setTeacherOpenCourseStudentSigninLogRemark(signinDTO.getTeacherOpenCourseStudentSigninLogRemark());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 学生签到记录添加
|
|
|
|
|
add(signinLogQuery);
|
|
|
|
|
}
|
|
|
|
|
}
|