diff --git a/src/main/java/com/subsidy/controller/ImageCheckRecordController.java b/src/main/java/com/subsidy/controller/ImageCheckRecordController.java index 954f047..2a48c37 100644 --- a/src/main/java/com/subsidy/controller/ImageCheckRecordController.java +++ b/src/main/java/com/subsidy/controller/ImageCheckRecordController.java @@ -43,14 +43,14 @@ public class ImageCheckRecordController { } @PostMapping("imageCheck") - @ApiOperation("课程/测评人身核验(权威库:身份证) PC端 id 用户id classId 班级id ") + @ApiOperation("课程/测评人身核验(权威库:身份证) PC端 id 用户id classId 班级id classPlace 1:视频的时候检测 2:测评的时候检测 paperId") @TimeRequired public ResponseVO imageCheck(@RequestBody ImageCheckDTO imageCheckDTO) throws Exception { return ResponseData.generateCreatedResponse(0, imageCheckRecordService.imageCheck(imageCheckDTO)); } @PostMapping("h5ImageCheck") - @ApiOperation("课程/测评人脸核验(权威库:身份证) 微信浮层H5 id 用户id classId 班级id") + @ApiOperation("课程/测评人脸核验(权威库:身份证) 微信浮层H5 id 用户id classId 班级id classPlace 1:视频的时候检测 2:测评的时候检测 paperId") @TimeRequired public ResponseVO h5CheckResult(@RequestBody ImageCheckDTO imageCheckDTO)throws Exception{ return ResponseData.generateCreatedResponse(0,imageCheckRecordService.h5CheckResult(imageCheckDTO)); @@ -64,7 +64,7 @@ public class ImageCheckRecordController { } @PostMapping("h5LoginCheck") - @ApiOperation("签到页做人脸核验 (权威库:身份证) PC端 id 用户id") + @ApiOperation("签到页做人脸核验 (权威库:身份证) id 用户id") @TimeRequired public ResponseVO h5LoginCheck(@RequestBody ImageCheckDTO imageCheckDTO)throws Exception{ return ResponseData.generateCreatedResponse(0,imageCheckRecordService.h5LoginCheck(imageCheckDTO)); diff --git a/src/main/java/com/subsidy/dto/image/ImageCheckDTO.java b/src/main/java/com/subsidy/dto/image/ImageCheckDTO.java index 256868b..711c0bb 100644 --- a/src/main/java/com/subsidy/dto/image/ImageCheckDTO.java +++ b/src/main/java/com/subsidy/dto/image/ImageCheckDTO.java @@ -15,4 +15,14 @@ public class ImageCheckDTO { */ private Long classId; + /** + * 试卷id + */ + private Long paperId; + + /** + * 1:视频的时候检测 2:测评的时候检测 + */ + private Integer classPlace; + } diff --git a/src/main/java/com/subsidy/mapper/ClassDictMapper.java b/src/main/java/com/subsidy/mapper/ClassDictMapper.java index 2c0a764..227d62a 100644 --- a/src/main/java/com/subsidy/mapper/ClassDictMapper.java +++ b/src/main/java/com/subsidy/mapper/ClassDictMapper.java @@ -5,10 +5,7 @@ import com.subsidy.dto.classDict.GetSpareMembersDTO; import com.subsidy.model.ClassDictDO; import com.subsidy.model.MemberDO; import com.subsidy.model.VodDictDO; -import com.subsidy.vo.classdict.ClassAndCompanyInfoVO; -import com.subsidy.vo.classdict.ClassSettingsVO; -import com.subsidy.vo.classdict.GetAllClassesVO; -import com.subsidy.vo.classdict.GetClassBaseInfoVO; +import com.subsidy.vo.classdict.*; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @@ -59,4 +56,9 @@ public interface ClassDictMapper extends BaseMapper { Integer getClassCount(); List getClassSettings(@Param("userId") Long userId); + + /** + * 通过班级id查看公司配置 + */ + SystemSettings getCompanySettings(Long classId); } diff --git a/src/main/java/com/subsidy/mapper/ImageCheckRecordMapper.java b/src/main/java/com/subsidy/mapper/ImageCheckRecordMapper.java index 40e8f5a..2572608 100644 --- a/src/main/java/com/subsidy/mapper/ImageCheckRecordMapper.java +++ b/src/main/java/com/subsidy/mapper/ImageCheckRecordMapper.java @@ -24,4 +24,9 @@ public interface ImageCheckRecordMapper extends BaseMapper { */ List getMemberCheckDetail(Long memberId, Long classId); + /** + * 查看某个人某个课程当天做了几次人脸识别 + */ + int checkDailyCount(Long memberId,Long classId,Integer checkPlace,Long paperId); + } diff --git a/src/main/java/com/subsidy/mapper/MemberMapper.java b/src/main/java/com/subsidy/mapper/MemberMapper.java index 2a7a8e2..ff3eac7 100644 --- a/src/main/java/com/subsidy/mapper/MemberMapper.java +++ b/src/main/java/com/subsidy/mapper/MemberMapper.java @@ -7,6 +7,7 @@ import com.subsidy.model.DepartmentDictDO; import com.subsidy.model.MemberDO; import com.subsidy.vo.administer.ManageMemberVO; import com.subsidy.vo.administer.UserRoleVO; +import com.subsidy.vo.classdict.SystemSettings; import com.subsidy.vo.member.GetAllVO; import com.subsidy.vo.member.MyCoursesVO; import com.subsidy.vo.member.StudyPageVO; @@ -76,5 +77,10 @@ public interface MemberMapper extends BaseMapper { */ void removeCheckImage(Long id); + /** + * 通过人员id查询公司配置 + */ + SystemSettings companySettings(Long memberId); + } diff --git a/src/main/java/com/subsidy/mapper/OprMemDictMapper.java b/src/main/java/com/subsidy/mapper/OprMemDictMapper.java index d05379c..9a11aeb 100644 --- a/src/main/java/com/subsidy/mapper/OprMemDictMapper.java +++ b/src/main/java/com/subsidy/mapper/OprMemDictMapper.java @@ -23,4 +23,6 @@ public interface OprMemDictMapper extends BaseMapper { List getRecordByDate(); + OprMemDictDO getLatestLoginInfo(Long userId); + } diff --git a/src/main/java/com/subsidy/model/ImageCheckRecordDO.java b/src/main/java/com/subsidy/model/ImageCheckRecordDO.java index 617a728..e1b865d 100644 --- a/src/main/java/com/subsidy/model/ImageCheckRecordDO.java +++ b/src/main/java/com/subsidy/model/ImageCheckRecordDO.java @@ -31,6 +31,11 @@ public class ImageCheckRecordDO extends BaseModel { private Long classId; /** + * 试卷id + */ + private Long paperId; + + /** * 成员id */ private Long memberId; @@ -70,5 +75,15 @@ public class ImageCheckRecordDO extends BaseModel { */ private Integer checkPlace; + /** + * 1:视频的时候检测 2:测评的时候检测 + */ + private Integer classPlace; + + /** + * 1 核对通过 0 核对不通过 + */ + private Integer result; + } diff --git a/src/main/java/com/subsidy/model/OprMemDictDO.java b/src/main/java/com/subsidy/model/OprMemDictDO.java index a62aa80..0ade304 100644 --- a/src/main/java/com/subsidy/model/OprMemDictDO.java +++ b/src/main/java/com/subsidy/model/OprMemDictDO.java @@ -38,8 +38,8 @@ public class OprMemDictDO extends BaseModel { private Integer result; /** - * 登录ip + * 登录ip ==弃用字段 */ - private String ipAddress; +// private String ipAddress; } diff --git a/src/main/java/com/subsidy/service/impl/ClassDictServiceImpl.java b/src/main/java/com/subsidy/service/impl/ClassDictServiceImpl.java index ff0750c..05e54ef 100644 --- a/src/main/java/com/subsidy/service/impl/ClassDictServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/ClassDictServiceImpl.java @@ -40,6 +40,7 @@ import com.subsidy.util.websocket.WebSocketUtil; import com.subsidy.vo.classdict.ClassSettingsVO; import com.subsidy.vo.classdict.GetAllClassesVO; import com.subsidy.vo.classdict.GetClassBaseInfoVO; +import com.subsidy.vo.classdict.SystemSettings; import org.apache.commons.collections.CollectionUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -163,6 +164,9 @@ public class ClassDictServiceImpl extends ServiceImpl list = classMemberMappingMapper.selectList(new QueryWrapper() .lambda() .eq(ClassMemberMappingDO::getClassId, classDictDO.getId())); @@ -171,8 +175,10 @@ public class ClassDictServiceImpl extends ServiceImpl classSettings = this.baseMapper.getClassSettings(classMemberMappingDO.getMemberId()); - String data = JSONObject.toJSONString(ResponseData.generateCreatedResponse(0, classSettings), SerializerFeature.WriteMapNullValue); + systemSettings.setClassSettingsVOS(classSettings); + String data = JSONObject.toJSONString(ResponseData.generateCreatedResponse(0, systemSettings), SerializerFeature.WriteMapNullValue); webSocketSession.sendMessage(new TextMessage(data)); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java b/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java index 866c3f6..839dd22 100644 --- a/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java @@ -39,6 +39,7 @@ import com.subsidy.util.VodUtil; import com.subsidy.util.websocket.WebSocketUtil; import com.subsidy.vo.administer.OperatorsVO; import com.subsidy.vo.classdict.ClassSettingsVO; +import com.subsidy.vo.classdict.SystemSettings; import com.subsidy.vo.company.CDNStatDetailsVO; import com.subsidy.vo.company.DataOverviewVO; import com.subsidy.vo.company.GetAllCompanyVO; @@ -293,6 +294,10 @@ public class CompanyDictServiceImpl extends ServiceImpl list = classMemberMappingMapper.getCLassMemberByCompanyId(companyDictDO.getId()); if(CollectionUtils.isNotEmpty(list)) { for (ClassMemberMappingDO classMemberMappingDO : list) { @@ -300,7 +305,8 @@ public class CompanyDictServiceImpl extends ServiceImpl classSettings = classDictMapper.getClassSettings(classMemberMappingDO.getMemberId()); - String data = JSONObject.toJSONString(ResponseData.generateCreatedResponse(0, classSettings), SerializerFeature.WriteMapNullValue); + systemSettings.setClassSettingsVOS(classSettings); + String data = JSONObject.toJSONString(ResponseData.generateCreatedResponse(0, systemSettings), SerializerFeature.WriteMapNullValue); webSocketSession.sendMessage(new TextMessage(data)); } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java b/src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java index b8447bc..77d7e76 100644 --- a/src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java @@ -14,9 +14,7 @@ import com.subsidy.model.AccessTokenDO; import com.subsidy.model.ImageCheckRecordDO; import com.subsidy.model.MemberDO; import com.subsidy.service.ImageCheckRecordService; -import com.subsidy.util.ConstantUtils; import com.subsidy.util.DateFormatUtil; -import com.subsidy.vo.image.CheckImageResultVO; import com.subsidy.vo.token.*; import org.apache.commons.codec.Charsets; import org.apache.commons.lang3.StringUtils; @@ -24,15 +22,11 @@ import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.*; import org.springframework.stereotype.Service; -import sun.misc.BASE64Decoder; -import sun.security.krb5.internal.crypto.Nonce; -//import org.apache.commons.codec.binary.Base64; -import java.io.*; import java.time.LocalDateTime; import java.util.*; -import java.util.regex.Matcher; -import java.util.regex.Pattern; + +//import org.apache.commons.codec.binary.Base64; /** *

@@ -72,19 +66,19 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl signList2 = new ArrayList(Arrays.asList(WBAPPID, memberDO.getId() + "", NONCE, "1.0.0", sendIdCardInfoVO.getResult().getFaceId(), sendIdCardInfoVO.getResult().getOrderNo())); + //签名2 faceId ===>H5FaceId + List signList2 = new ArrayList(Arrays.asList(WBAPPID, memberDO.getId() + "", NONCE, "1.0.0", sendIdCardInfoVO.getResult().getH5faceId(), sendIdCardInfoVO.getResult().getOrderNo())); String sign2 = sign(signList2, nonceTicket.getValue()); sendIdCardInfoVO.getResult().setWbAppId(WBAPPID); @@ -223,7 +221,6 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl 60)) { + imageCheckRecordDO.setResult(1); + //如果是签到页的认证,则把图片写到member表里 + if (imageCheckRecordDO.getCheckPlace()==1){ + MemberDO memberDO = memberMapper.selectById(imageCheckRecordDO.getMemberId()); + memberDO.setCheckImage(imageCheckRecordDO.getPhoto()); + memberDO.setCheckTime(DateFormatUtil.format(new Date(), DateFormatUtil.FMT_sdf14_L)); + memberMapper.updateById(memberDO); + } + } else { + imageCheckRecordDO.setResult(0); + } + }catch (Exception e){ + imageCheckRecordDO.setResult(0); + } - //如果是签到页的认证,则把图片写到member表里 - MemberDO memberDO = memberMapper.selectById(imageCheckRecordDO.getMemberId()); - memberDO.setImage(checkImageResultVO.getPhoto()); - memberDO.setCheckTime(DateFormatUtil.format(new Date(), DateFormatUtil.FMT_sdf14_L)); - memberMapper.updateById(memberDO); + imageCheckRecordMapper.updateById(imageCheckRecordDO); - if ((Double.valueOf(imageCheckRecordDO.getSimilarity()) > 60)) { - checkImageResultVO.setResult(true); - } else { - checkImageResultVO.setResult(false); - } return imageCheckRecordDO; } diff --git a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java index 1cb92d1..c2f4f12 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -9,42 +9,8 @@ import com.subsidy.common.configure.QXueYouConfig; import com.subsidy.common.exception.HttpException; import com.subsidy.dto.administer.VerifyCodeDTO; import com.subsidy.dto.member.*; -import com.subsidy.mapper.ClassDictMapper; -import com.subsidy.mapper.ClassHourDictMapper; -import com.subsidy.mapper.ClassMemberMappingMapper; -import com.subsidy.mapper.CompanyDictMapper; -import com.subsidy.mapper.CourseContentMapper; -import com.subsidy.mapper.CourseFieldMappingMapper; -import com.subsidy.mapper.DepartmentDictMapper; -import com.subsidy.mapper.ExerciseDoneResultMapper; -import com.subsidy.mapper.FileDictMapper; -import com.subsidy.mapper.JobDictMapper; -import com.subsidy.mapper.JobMemberMappingMapper; -import com.subsidy.mapper.MemberDepartmentMappingMapper; -import com.subsidy.mapper.MemberMapper; -import com.subsidy.mapper.OprMemDictMapper; -import com.subsidy.mapper.PaperDictMapper; -import com.subsidy.mapper.RotationImgDictMapper; -import com.subsidy.mapper.SmsVerifyCodeMapper; -import com.subsidy.mapper.VodDictMapper; -import com.subsidy.mapper.VodPlayHistoryMapper; -import com.subsidy.model.ClassDictDO; -import com.subsidy.model.ClassHourDictDO; -import com.subsidy.model.ClassMemberMappingDO; -import com.subsidy.model.CompanyDictDO; -import com.subsidy.model.CourseContentDO; -import com.subsidy.model.DepartmentDictDO; -import com.subsidy.model.ExerciseDoneResultDO; -import com.subsidy.model.FieldDictDO; -import com.subsidy.model.FileDictDO; -import com.subsidy.model.JobDictDO; -import com.subsidy.model.JobMemberMappingDO; -import com.subsidy.model.MemberDO; -import com.subsidy.model.MemberDepartmentMappingDO; -import com.subsidy.model.OprMemDictDO; -import com.subsidy.model.RotationImgDictDO; -import com.subsidy.model.SmsVerifyCodeDO; -import com.subsidy.model.VodDictDO; +import com.subsidy.mapper.*; +import com.subsidy.model.*; import com.subsidy.service.MemberService; import com.subsidy.util.*; //import com.subsidy.util.RedisUtil; @@ -135,7 +101,7 @@ public class MemberServiceImpl extends ServiceImpl imple private RotationImgDictMapper rotationImgDictMapper; @Autowired - private VodDictMapper vodDictMapper; + private ImageCheckRecordMapper imageCheckRecordMapper; @Autowired private SmsVerifyCodeMapper smsVerifyCodeMapper; @@ -719,6 +685,21 @@ public class MemberServiceImpl extends ServiceImpl imple for (MyCoursesVO myCoursesVO : myCoursesVOS) { List fieldDictDOS = courseFieldMappingMapper.courseFields(myCoursesVO.getCourseId()); myCoursesVO.setFieldDictDOS(fieldDictDOS); + int count = imageCheckRecordMapper.selectCount(new QueryWrapper() + .lambda() + .eq(ImageCheckRecordDO::getMemberId, myCoursesDTO.getMemberId()) + .eq(ImageCheckRecordDO::getClassId, myCoursesVO.getClassId()) + .eq(ImageCheckRecordDO::getCheckPlace, 1) + .eq(ImageCheckRecordDO::getResult, 1)); + + int checkCnt = imageCheckRecordMapper.checkDailyCount(myCoursesDTO.getMemberId(), myCoursesVO.getClassId(), 1,null); + myCoursesVO.setCheckCnt(checkCnt); + + if (count > 0) { + myCoursesVO.setResult(1); + } else { + myCoursesVO.setResult(0); + } } return myCoursesVOS; } @@ -855,6 +836,23 @@ public class MemberServiceImpl extends ServiceImpl imple } else { queryPapersVO.setResult("待完成"); } + + int count = imageCheckRecordMapper.selectCount(new QueryWrapper() + .lambda() + .eq(ImageCheckRecordDO::getMemberId, contentMemberDTO.getMemberId()) + .eq(ImageCheckRecordDO::getClassId, contentMemberDTO.getClassId()) + .eq(ImageCheckRecordDO::getPaperId,queryPapersVO.getId()) + .eq(ImageCheckRecordDO::getClassPlace, 2) + .eq(ImageCheckRecordDO::getResult, 1)); + + int checkCnt = imageCheckRecordMapper.checkDailyCount(contentMemberDTO.getMemberId(), contentMemberDTO.getClassId(), 2,queryPapersVO.getId()); + queryPapersVO.setCheckCnt(checkCnt); + + if (count > 0) { + queryPapersVO.setCheckResult(1); + } else { + queryPapersVO.setCheckResult(0); + } //截止时间 queryPapersVO.setEndDate(classDictDO.getEndDate()); } diff --git a/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java b/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java index 9e0239d..60d141d 100644 --- a/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java +++ b/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java @@ -5,10 +5,16 @@ import com.alibaba.fastjson.serializer.SerializerFeature; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.subsidy.common.ResponseData; import com.subsidy.mapper.ClassDictMapper; +import com.subsidy.mapper.CompanyDictMapper; +import com.subsidy.mapper.MemberMapper; import com.subsidy.mapper.OprMemDictMapper; +import com.subsidy.model.CompanyDictDO; +import com.subsidy.model.MemberDO; import com.subsidy.model.OprMemDictDO; import com.subsidy.util.DateFormatUtil; import com.subsidy.vo.classdict.ClassSettingsVO; +import com.subsidy.vo.classdict.SystemSettings; +import io.swagger.annotations.ApiOperation; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.CollectionUtils; @@ -19,6 +25,7 @@ import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketHandler; import org.springframework.web.socket.WebSocketMessage; import org.springframework.web.socket.WebSocketSession; + import java.io.IOException; import java.util.Calendar; import java.util.Date; @@ -31,7 +38,7 @@ import java.util.concurrent.TimeUnit; /** *

- * WebSocket + * WebSocket *

* * @author DengMin @@ -47,12 +54,15 @@ public class WebSocketUtil implements WebSocketHandler { @Autowired private ClassDictMapper classDictMapper; + @Autowired + private MemberMapper memberMapper; + private int heartbeatMin = 1; // 断连最小心跳次数 private int heartbeatMax = 2; // 断连最大心跳次数 private int reconnectionSeconds = 60; //每次断连间隔重新连接秒 /** - * 存放建立连接webSocket对象 + * 存放建立连接webSocket对象 Map */ public static ConcurrentHashMap webSocketMap = new ConcurrentHashMap(); @@ -60,124 +70,117 @@ public class WebSocketUtil implements WebSocketHandler { /** * 处理成功连接WebSocket 建立直接后调用 - * @param session */ @Override public void afterConnectionEstablished(WebSocketSession session) throws IOException { - if(null != session) { + if (null != session) { String params = session.getUri().getQuery(); Long id = Long.valueOf(params.split("=")[1]); - if(null != webSocketMap && webSocketMap.get(id) != null) { - if(webSocketMap.get(id).isOpen()) { + + //webSocketMap的操作 + if (null != webSocketMap && webSocketMap.get(id) != null) { + if (webSocketMap.get(id).isOpen()) { /* 相同账户进行挤号,发送消息给WebSocket通知账户已在其他地方登录 */ webSocketMap.get(id).sendMessage(new TextMessage(JSONObject.toJSONString(ResponseData.generateCreatedResponse(1011)))); webSocketMap.get(id).close(); } else { /* - * 如果上次连接的WebSocket状态是关闭, + * 上次连接的WebSocket状态是关闭, * 并且上一次记录时间大于 { heartbeatMax * reconnectionSeconds } 秒(心跳检测机制),则判断为这次登陆是免密码登陆的重新记录上线时间 */ - List list = oprMemDictMapper.selectList(new QueryWrapper() - .lambda() - .eq(OprMemDictDO::getUserId, id) - .orderByDesc(OprMemDictDO::getCreateDate)); - - Calendar calendar = Calendar.getInstance(); - calendar.setTime(DateFormatUtil.localDateTimeToDate(list.get(0).getCreateDate())); - calendar.add(Calendar.SECOND,heartbeatMax * reconnectionSeconds); - if(calendar.getTime().after(DateFormatUtil.localDateTimeToDate(list.get(0).getCreateDate()))) { - if(list.get(0).getOprType().equals("登出")) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(id); - oprMemDictDO.setResult(1); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setIpAddress(session.getRemoteAddress().getHostName()); - oprMemDictMapper.insert(oprMemDictDO); - } + OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(id); //最近一次登录 + +// Calendar calendar = Calendar.getInstance(); +// calendar.setTime(DateFormatUtil.localDateTimeToDate(oprMemDictDO.getCreateDate())); +// calendar.add(Calendar.SECOND,heartbeatMax * reconnectionSeconds); //当前时间+最大链接次数,判定为超时 +// if(calendar.getTime().after(DateFormatUtil.localDateTimeToDate(oprMemDictDO.getCreateDate()))) { + if (oprMemDictDO.getOprType().equals("登出")) { + //登出过的话就写记录,否则不写 + oprMemDictDO.setUserId(id); + oprMemDictDO.setResult(1); + oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setIpAddress(session.getRemoteAddress().getHostName()); + oprMemDictMapper.insert(oprMemDictDO); } +// } } webSocketMap.remove(id); } webSocketMap.put(id, session); - /* 班级配置信息 */ //查人的班级 + // 数据操作 + SystemSettings systemSettings = memberMapper.companySettings(id); //公司配置 List classSettings = classDictMapper.getClassSettings(id); - if(CollectionUtils.isNotEmpty(classSettings)) { - String data = JSONObject.toJSONString(ResponseData.generateCreatedResponse(0, classSettings), SerializerFeature.WriteMapNullValue); + systemSettings.setClassSettingsVOS(classSettings); + if (CollectionUtils.isNotEmpty(classSettings)) { + String data = JSONObject.toJSONString(ResponseData.generateCreatedResponse(0, systemSettings), SerializerFeature.WriteMapNullValue); webSocketMap.get(id).sendMessage(new TextMessage(data)); } - String httpSessionId = session.getId(); - String host = session.getUri().getHost(); - String query = session.getUri().getQuery(); - log.info("----> webSocket connection success"); - log.info("parameter:[ httpSessionId: {}, host: {}, {} ]", httpSessionId, host, query); - log.info("connection time: {}", DateFormatUtil.format(new Date(), DateFormatUtil.FMT_sdf14_L)); +// String httpSessionId = session.getId(); +// String host = session.getUri().getHost(); +// String query = session.getUri().getQuery(); +// log.info("----> webSocket connection success"); +// log.info("parameter:[ httpSessionId: {}, host: {}, {} ]", httpSessionId, host, query); +// log.info("connection time: {}", DateFormatUtil.format(new Date(), DateFormatUtil.FMT_sdf14_L)); } } /** * 处理WebSocket transport error - * @param session - * @param throwable - * @throws Exception */ @Override public void handleTransportError(WebSocketSession session, Throwable throwable) throws Exception { - if(session.isOpen()) { + if (session.isOpen()) { session.close(); } String params = session.getUri().getQuery(); Long id = Long.valueOf(params.split("=")[1]); webSocketMap.remove(id); - log.error("<---- webSocket transport error"); - log.error("error message: {}", throwable.getMessage()); +// log.error("<---- webSocket transport error"); +// log.error("error message: {}", throwable.getMessage()); } /** * 在两端WebSocket connection都关闭或transport error发生后执行 - * @param session - * @param closeStatus - * @throws Exception */ @Override - public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception{ - if(null != session) { - if(null != webSocketMap) { + public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception { + if (null != session) { + if (null != webSocketMap) { String params = session.getUri().getQuery(); Long id = Long.valueOf(params.split("=")[1]); heartbeat(webSocketMap.get(id)); } - log.info("<---- webSocket is close"); - log.info("session {} close, status: {}", session.getId(), closeStatus); +// log.info("<---- webSocket is close"); +// log.info("session {} close, status: {}", session.getId(), closeStatus); } } /** * 断开连接后进行三次心跳验证判断是否重新连接了,如果没有连接成功则判断为下线 - * - * @param session */ public void heartbeat(WebSocketSession session) { ScheduledExecutorService service = Executors.newScheduledThreadPool(1); ScheduledFuture scheduledFuture = service.scheduleAtFixedRate(new Runnable() { int beatsNum = heartbeatMin; + @SneakyThrows @Override public void run() { - if(null != session && !session.isOpen()) { - while (beatsNum > heartbeatMax) { + if (null != session && !session.isOpen()) { + if (beatsNum > heartbeatMax) { //heartbeatMa:2 String params = session.getUri().getQuery(); Long id = Long.valueOf(params.split("=")[1]); OprMemDictDO oprMemDictDO = new OprMemDictDO(); oprMemDictDO.setUserId(id); oprMemDictDO.setResult(1); oprMemDictDO.setOprType("登出"); - oprMemDictDO.setIpAddress(session.getRemoteAddress().getHostName()); +// oprMemDictDO.setIpAddress(session.getRemoteAddress().getHostName()); oprMemDictMapper.insert(oprMemDictDO); taskMap.get(session.getId()).cancel(true); - +// break; } beatsNum++; } else if (null != session && session.isOpen()) { @@ -191,14 +194,11 @@ public class WebSocketUtil implements WebSocketHandler { /** * 接收WebSocket客户端Message - * @param session - * @param message - * @throws Exception */ @Override public void handleMessage(WebSocketSession session, WebSocketMessage message) throws Exception { - if(message instanceof TextMessage) { - System.out.println(message.getPayload()); + if (message instanceof TextMessage) { +// System.out.println(message.getPayload()); } } diff --git a/src/main/java/com/subsidy/vo/classdict/SystemSettings.java b/src/main/java/com/subsidy/vo/classdict/SystemSettings.java new file mode 100644 index 0000000..f79689f --- /dev/null +++ b/src/main/java/com/subsidy/vo/classdict/SystemSettings.java @@ -0,0 +1,31 @@ +package com.subsidy.vo.classdict; + +import lombok.Data; + +import java.util.List; + +@Data +public class SystemSettings { + + /** + * 上课时间不晚于23:30,不早于6:30 + */ + private Integer timeLimit; + + /** + * 签到时记录IP地址 + */ + private Integer ipAddressRecord; + + /** + * 签到时记录设备型号 + */ + private Integer deviceNoRecord; + + /** + * 班级配置 + */ + private List classSettingsVOS; + + +} diff --git a/src/main/java/com/subsidy/vo/image/CheckImageResultVO.java b/src/main/java/com/subsidy/vo/image/CheckImageResultVO.java deleted file mode 100644 index d78a5ad..0000000 --- a/src/main/java/com/subsidy/vo/image/CheckImageResultVO.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.subsidy.vo.image; - -import com.subsidy.model.ImageCheckRecordDO; -import lombok.Data; - -@Data -public class CheckImageResultVO extends ImageCheckRecordDO { - - private Boolean result; - -} diff --git a/src/main/java/com/subsidy/vo/member/MyCoursesVO.java b/src/main/java/com/subsidy/vo/member/MyCoursesVO.java index 79cad1d..7c7562c 100644 --- a/src/main/java/com/subsidy/vo/member/MyCoursesVO.java +++ b/src/main/java/com/subsidy/vo/member/MyCoursesVO.java @@ -32,5 +32,9 @@ public class MyCoursesVO { private Integer isFastPlay; + private Integer result; + + private Integer checkCnt; + private List fieldDictDOS; } diff --git a/src/main/java/com/subsidy/vo/paper/QueryPapersVO.java b/src/main/java/com/subsidy/vo/paper/QueryPapersVO.java index 00a303f..8c5457c 100644 --- a/src/main/java/com/subsidy/vo/paper/QueryPapersVO.java +++ b/src/main/java/com/subsidy/vo/paper/QueryPapersVO.java @@ -21,4 +21,8 @@ public class QueryPapersVO { private String endDate; + private Integer checkCnt; + + private Integer checkResult; + } diff --git a/src/main/resources/mapper/ClassDictMapper.xml b/src/main/resources/mapper/ClassDictMapper.xml index 6b4b8e8..eb8b15c 100644 --- a/src/main/resources/mapper/ClassDictMapper.xml +++ b/src/main/resources/mapper/ClassDictMapper.xml @@ -197,4 +197,19 @@ AND t2.delete_date IS NULL AND t3.delete_date IS NULL + + + diff --git a/src/main/resources/mapper/ImageCheckRecordMapper.xml b/src/main/resources/mapper/ImageCheckRecordMapper.xml index 77185e7..ec50cf2 100644 --- a/src/main/resources/mapper/ImageCheckRecordMapper.xml +++ b/src/main/resources/mapper/ImageCheckRecordMapper.xml @@ -33,4 +33,26 @@ AND t.member_id = #{memberId} + + diff --git a/src/main/resources/mapper/MemberMapper.xml b/src/main/resources/mapper/MemberMapper.xml index ae0a93d..677781b 100644 --- a/src/main/resources/mapper/MemberMapper.xml +++ b/src/main/resources/mapper/MemberMapper.xml @@ -330,4 +330,18 @@ update member set check_image = null,check_time = null where id = #{id} + + diff --git a/src/main/resources/mapper/OprMemDictMapper.xml b/src/main/resources/mapper/OprMemDictMapper.xml index 5312914..b6b7b44 100644 --- a/src/main/resources/mapper/OprMemDictMapper.xml +++ b/src/main/resources/mapper/OprMemDictMapper.xml @@ -54,4 +54,18 @@ WHERE create_date < (NOW() - INTERVAL 10 DAY) + +