diff --git a/src/main/java/com/subsidy/common/configure/WebSocketConfig.java b/src/main/java/com/subsidy/common/configure/WebSocketConfig.java index 3fd2091..696db4b 100644 --- a/src/main/java/com/subsidy/common/configure/WebSocketConfig.java +++ b/src/main/java/com/subsidy/common/configure/WebSocketConfig.java @@ -16,7 +16,6 @@ import org.springframework.web.socket.config.annotation.WebSocketHandlerRegistry * @author DengMin * @since 2022/7/13 */ - @Configuration @EnableWebSocket public class WebSocketConfig implements WebSocketConfigurer { diff --git a/src/main/java/com/subsidy/common/interceptor/WebSocketInterceptor.java b/src/main/java/com/subsidy/common/interceptor/WebSocketInterceptor.java index ac7b36b..3e0bd6c 100644 --- a/src/main/java/com/subsidy/common/interceptor/WebSocketInterceptor.java +++ b/src/main/java/com/subsidy/common/interceptor/WebSocketInterceptor.java @@ -28,12 +28,6 @@ public class WebSocketInterceptor implements HandshakeInterceptor { /** * 自定义验证规则, 如果该用户不存在数据表中,拒绝此次连接 - * @param request - * @param serverHttpResponse - * @param webSocketHandler - * @param map - * @return - * @throws Exception */ @Override public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse serverHttpResponse, WebSocketHandler webSocketHandler, Map map) throws Exception { diff --git a/src/main/java/com/subsidy/controller/CompanyDictController.java b/src/main/java/com/subsidy/controller/CompanyDictController.java index 91dff13..d580780 100644 --- a/src/main/java/com/subsidy/controller/CompanyDictController.java +++ b/src/main/java/com/subsidy/controller/CompanyDictController.java @@ -43,7 +43,8 @@ public class CompanyDictController { } @PostMapping("addCompany") - @ApiOperation("添加企业 {accountName:账号 superviseName 第三方监管名称 companyName:企业名称 address 企业所在地 shortName 简称 banner:标语 field[]:领域 role 1:超级管理员 2:普通成员}") + @ApiOperation("添加企业 {accountName:账号 superviseName 第三方监管名称 companyName:企业名称 address 企业所在地 shortName " + + "简称 banner:标语 field[]:领域 role 1:超级管理员 2:普通成员}") @LoginRequired public ResponseVO addOperator(@RequestBody AddCompanyDTO addCompanyDTO){ return ResponseData.generateCreatedResponse(0,companyDictService.addOperator(addCompanyDTO)); @@ -81,7 +82,7 @@ public class CompanyDictController { @PostMapping("getAllCompany") @ApiOperation("获取全部企业 {companyName}") - @LoginRequired +// @LoginRequired public ResponseVO getAllCompany(@RequestBody CompanyDictDO companyDictDO){ return ResponseData.generateCreatedResponse(0,companyDictService.getAllCompany(companyDictDO)); } diff --git a/src/main/java/com/subsidy/controller/SignInRecordController.java b/src/main/java/com/subsidy/controller/SignInRecordController.java index 1e0418a..bd4cc92 100644 --- a/src/main/java/com/subsidy/controller/SignInRecordController.java +++ b/src/main/java/com/subsidy/controller/SignInRecordController.java @@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import javax.servlet.http.HttpServletRequest; + /** *

* 学生签到表 前端控制器 @@ -47,8 +49,8 @@ public class SignInRecordController { // @LoginRequired @TimeRequired @CachePut(value = "ResultData" ,key = "'classId_'+#signInRecordDO.getClassId()") - public ResponseVO signIn(@RequestBody SignInRecordDO signInRecordDO) { - return ResponseData.generateCreatedResponse(0, signInRecordService.signIn(signInRecordDO)); + public ResponseVO signIn(@RequestBody SignInRecordDO signInRecordDO, HttpServletRequest request) { + return ResponseData.generateCreatedResponse(0, signInRecordService.signIn(signInRecordDO,request)); } @PostMapping("dataView") diff --git a/src/main/java/com/subsidy/service/SignInRecordService.java b/src/main/java/com/subsidy/service/SignInRecordService.java index ab8071e..d9e673a 100644 --- a/src/main/java/com/subsidy/service/SignInRecordService.java +++ b/src/main/java/com/subsidy/service/SignInRecordService.java @@ -8,6 +8,8 @@ import com.subsidy.model.SignInRecordDO; import com.subsidy.vo.member.GetMemberSignInfoVO; import com.subsidy.vo.sign.SignInStatusVO; +import javax.servlet.http.HttpServletRequest; + /** *

* 学生签到表 服务类 @@ -20,7 +22,7 @@ public interface SignInRecordService extends IService { IPage getMemberSignInfo(GetMemberSignInfoDTO getMemberSignInfoDTO); - String signIn(SignInRecordDO signInRecordDO); + String signIn(SignInRecordDO signInRecordDO, HttpServletRequest request); IPage dataView(DataViewDTO classSignInfoDTO); diff --git a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java index 91c5d0f..443277c 100644 --- a/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java @@ -1004,7 +1004,7 @@ public class AdministerServiceImpl extends ServiceImpl memberCheckDetail = imageCheckRecordMapper.getMemberCheckDetail(imageCheckRecordDO.getMemberId(), imageCheckRecordDO.getClassId()); for (GetMemberCheckDetailVO gcdv : memberCheckDetail) { - if (gcdv.getSimilarity() > 60.0) { + if (null != gcdv.getSimilarity() && gcdv.getSimilarity() > 60.0) { gcdv.setResult("通过"); } else { gcdv.setResult("不通过"); diff --git a/src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java b/src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java index 77d7e76..a564dfd 100644 --- a/src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java @@ -188,19 +188,28 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl signList1 = new ArrayList(Arrays.asList(WBAPPID, imageCheckRecordDO.getId() + "", memberDO.getUserName(), memberDO.getIdCard(), memberDO.getId() + "", "1.0.0")); - String sign = sign(signList1, idCardTicketsVO.getValue()); + List signList1 = new ArrayList<>(); + signList1.add(WBAPPID); + signList1.add(imageCheckRecordDO.getId()+""); + signList1.add(memberDO.getId()+""); + signList1.add("1.0.0"); + String sign = ""; //合作方后台上送身份信息 // 查看之前是否有验证过,没有的话就调取权威库,有的话就进行两个图片对比 SendIdCardInfoVO sendIdCardInfoVO = null; if (StringUtils.isEmpty(memberDO.getCheckImage())) { + signList1.add(memberDO.getUserName()); + signList1.add(memberDO.getIdCard()); + sign = sign(signList1, idCardTicketsVO.getValue()); sendIdCardInfoVO = this.sendIdCardInfo(imageCheckRecordDO.getId() + "", memberDO, sign); }else { + sign = sign(signList1, idCardTicketsVO.getValue()); sendIdCardInfoVO = this.sendIdCardInfoCompare(imageCheckRecordDO.getId()+"",memberDO,sign); } if (!"0".equals(sendIdCardInfoVO.getCode())) { + //删除这个订单 imageCheckRecordMapper.deleteById(imageCheckRecordDO.getId()); throw new HttpException(10026); } @@ -238,27 +247,27 @@ 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); + if (!StringUtils.isEmpty(resultVO.getSimilarity())){ + BeanUtils.copyProperties(resultVO, imageCheckRecordDO); + try { + if ((Double.valueOf(imageCheckRecordDO.getSimilarity()) > 50)) { + 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); } - } else { + }catch (Exception e){ imageCheckRecordDO.setResult(0); } - }catch (Exception e){ - imageCheckRecordDO.setResult(0); - } - - imageCheckRecordMapper.updateById(imageCheckRecordDO); + imageCheckRecordMapper.updateById(imageCheckRecordDO); + } 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 c2f4f12..1c1672d 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -13,7 +13,6 @@ import com.subsidy.mapper.*; import com.subsidy.model.*; import com.subsidy.service.MemberService; import com.subsidy.util.*; -//import com.subsidy.util.RedisUtil; import com.subsidy.vo.administer.UserRoleVO; import com.subsidy.vo.member.*; import com.subsidy.vo.paper.QueryPapersVO; @@ -28,7 +27,6 @@ import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.AsyncResult; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -37,9 +35,8 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.Future; + +//import com.subsidy.util.RedisUtil; /** *

@@ -689,7 +686,8 @@ public class MemberServiceImpl extends ServiceImpl imple .lambda() .eq(ImageCheckRecordDO::getMemberId, myCoursesDTO.getMemberId()) .eq(ImageCheckRecordDO::getClassId, myCoursesVO.getClassId()) - .eq(ImageCheckRecordDO::getCheckPlace, 1) + .isNull(ImageCheckRecordDO::getPaperId) + .eq(ImageCheckRecordDO::getCheckPlace, 0) .eq(ImageCheckRecordDO::getResult, 1)); int checkCnt = imageCheckRecordMapper.checkDailyCount(myCoursesDTO.getMemberId(), myCoursesVO.getClassId(), 1,null); diff --git a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java index cdab567..ae04da0 100644 --- a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java @@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletRequest; import java.time.LocalDate; import java.time.LocalDateTime; import java.util.Date; @@ -79,7 +80,7 @@ public class SignInRecordServiceImpl extends ServiceImpl classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId()); @@ -101,10 +102,11 @@ public class SignInRecordServiceImpl extends ServiceImpl")); + System.err.println(ipsString3);*/ + + // 返回公网IP值 + return ipsString2; + + } catch (Exception e) { + System.out.println("获取公网IP连接超时"); + return "连接超时"; + } + } } diff --git a/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java b/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java index 60d141d..2f51640 100644 --- a/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java +++ b/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java @@ -2,45 +2,30 @@ package com.subsidy.util.websocket; import com.alibaba.fastjson.JSONObject; 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; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import org.springframework.web.socket.CloseStatus; -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 org.springframework.web.socket.*; +import org.springframework.web.socket.handler.AbstractWebSocketHandler; import java.io.IOException; -import java.util.Calendar; -import java.util.Date; import java.util.List; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; +import java.util.concurrent.*; /** *

* WebSocket *

- * + * https://zhuanlan.zhihu.com/p/531474864 * @author DengMin * @since 2022/7/13 */ @@ -127,7 +112,18 @@ public class WebSocketUtil implements WebSocketHandler { } /** - * 处理WebSocket transport error + * 接收WebSocket客户端Message + */ + @Override + public void handleMessage(WebSocketSession session, WebSocketMessage message) throws Exception { +// if (message instanceof TextMessage) { +// System.out.println(message.getPayload()); +// } + this.handleMessage(session,message); + } + + /** + * 链接发生错误:处理WebSocket transport error */ @Override public void handleTransportError(WebSocketSession session, Throwable throwable) throws Exception { @@ -143,7 +139,7 @@ public class WebSocketUtil implements WebSocketHandler { } /** - * 在两端WebSocket connection都关闭或transport error发生后执行 + * 关闭链接 :在两端WebSocket connection都关闭或transport error发生后执行 */ @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus closeStatus) throws Exception { @@ -159,12 +155,20 @@ public class WebSocketUtil implements WebSocketHandler { } /** + * 支持分片消息 + */ + @Override + public boolean supportsPartialMessages() { + return false; + } + + /** * 断开连接后进行三次心跳验证判断是否重新连接了,如果没有连接成功则判断为下线 */ public void heartbeat(WebSocketSession session) { ScheduledExecutorService service = Executors.newScheduledThreadPool(1); ScheduledFuture scheduledFuture = service.scheduleAtFixedRate(new Runnable() { - int beatsNum = heartbeatMin; + int beatsNum = heartbeatMin; //至少一次 @SneakyThrows @Override @@ -185,6 +189,7 @@ public class WebSocketUtil implements WebSocketHandler { beatsNum++; } else if (null != session && session.isOpen()) { /* 时间段内重新连接了结束验证 */ + beatsNum = heartbeatMin; taskMap.get(session.getId()).cancel(true); } } @@ -192,18 +197,4 @@ public class WebSocketUtil implements WebSocketHandler { taskMap.put(session.getId(), scheduledFuture); } - /** - * 接收WebSocket客户端Message - */ - @Override - public void handleMessage(WebSocketSession session, WebSocketMessage message) throws Exception { - if (message instanceof TextMessage) { -// System.out.println(message.getPayload()); - } - } - - @Override - public boolean supportsPartialMessages() { - return false; - } } \ No newline at end of file diff --git a/src/main/java/com/subsidy/vo/classdict/SystemSettings.java b/src/main/java/com/subsidy/vo/classdict/SystemSettings.java index f79689f..e84caaa 100644 --- a/src/main/java/com/subsidy/vo/classdict/SystemSettings.java +++ b/src/main/java/com/subsidy/vo/classdict/SystemSettings.java @@ -7,6 +7,8 @@ import java.util.List; @Data public class SystemSettings { + private Long id; + /** * 上课时间不晚于23:30,不早于6:30 */ diff --git a/src/main/resources/mapper/MemberMapper.xml b/src/main/resources/mapper/MemberMapper.xml index 677781b..96a4f06 100644 --- a/src/main/resources/mapper/MemberMapper.xml +++ b/src/main/resources/mapper/MemberMapper.xml @@ -333,6 +333,7 @@