Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
涂亚平
/
subsidy
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7fb594bb
authored
Sep 06, 2022
by
涂亚平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
人脸识别版本备个份
1 parent
421d9309
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
130 additions
and
77 deletions
src/main/java/com/subsidy/common/configure/WebSocketConfig.java
src/main/java/com/subsidy/common/interceptor/WebSocketInterceptor.java
src/main/java/com/subsidy/controller/CompanyDictController.java
src/main/java/com/subsidy/controller/SignInRecordController.java
src/main/java/com/subsidy/service/SignInRecordService.java
src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java
src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java
src/main/java/com/subsidy/service/impl/MemberServiceImpl.java
src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java
src/main/java/com/subsidy/util/IpAddressUtil.java
src/main/java/com/subsidy/util/websocket/WebSocketUtil.java
src/main/java/com/subsidy/vo/classdict/SystemSettings.java
src/main/resources/mapper/MemberMapper.xml
src/main/java/com/subsidy/common/configure/WebSocketConfig.java
View file @
7fb594b
...
...
@@ -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
{
...
...
src/main/java/com/subsidy/common/interceptor/WebSocketInterceptor.java
View file @
7fb594b
...
...
@@ -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
<
String
,
Object
>
map
)
throws
Exception
{
...
...
src/main/java/com/subsidy/controller/CompanyDictController.java
View file @
7fb594b
...
...
@@ -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
));
}
...
...
src/main/java/com/subsidy/controller/SignInRecordController.java
View file @
7fb594b
...
...
@@ -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
;
/**
* <p>
* 学生签到表 前端控制器
...
...
@@ -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"
)
...
...
src/main/java/com/subsidy/service/SignInRecordService.java
View file @
7fb594b
...
...
@@ -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
;
/**
* <p>
* 学生签到表 服务类
...
...
@@ -20,7 +22,7 @@ public interface SignInRecordService extends IService<SignInRecordDO> {
IPage
<
GetMemberSignInfoVO
>
getMemberSignInfo
(
GetMemberSignInfoDTO
getMemberSignInfoDTO
);
String
signIn
(
SignInRecordDO
signInRecordDO
);
String
signIn
(
SignInRecordDO
signInRecordDO
,
HttpServletRequest
request
);
IPage
dataView
(
DataViewDTO
classSignInfoDTO
);
...
...
src/main/java/com/subsidy/service/impl/AdministerServiceImpl.java
View file @
7fb594b
...
...
@@ -1004,7 +1004,7 @@ public class AdministerServiceImpl extends ServiceImpl<AdministerMapper, Adminis
List
<
GetMemberCheckDetailVO
>
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
(
"不通过"
);
...
...
src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java
View file @
7fb594b
...
...
@@ -188,19 +188,28 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
IdCardTicketsVO
idCardTicketsVO
=
this
.
signTickets
(
getLatestAccessToken
());
//生成签名
List
<
String
>
signList1
=
new
ArrayList
(
Arrays
.
asList
(
WBAPPID
,
imageCheckRecordDO
.
getId
()
+
""
,
memberDO
.
getUserName
(),
memberDO
.
getIdCard
(),
memberDO
.
getId
()
+
""
,
"1.0.0"
));
String
sign
=
sign
(
signList1
,
idCardTicketsVO
.
getValue
());
List
<
String
>
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<ImageCheckRecordMap
//存数据库
ImageCheckRecordDO
imageCheckRecordDO
=
imageCheckRecordMapper
.
selectById
(
checkResultDTO
.
getId
());
BeanUtils
.
copyProperties
(
resultVO
,
imageCheckRecordDO
);
try
{
if
((
Double
.
valueOf
(
imageCheckRecordDO
.
getSimilarity
())
>
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
;
}
...
...
src/main/java/com/subsidy/service/impl/MemberServiceImpl.java
View file @
7fb594b
...
...
@@ -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;
/**
* <p>
...
...
@@ -689,7 +686,8 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> 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
);
...
...
src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java
View file @
7fb594b
...
...
@@ -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<SignInRecordMapper, Sig
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
String
signIn
(
SignInRecordDO
signInRecordDO
)
{
public
String
signIn
(
SignInRecordDO
signInRecordDO
,
HttpServletRequest
request
)
{
//查看学生所有在读班级
List
<
ClassDictDO
>
classDictDOS
=
classMemberMappingMapper
.
getMemberClass
(
signInRecordDO
.
getMemberId
());
...
...
@@ -101,10 +102,11 @@ public class SignInRecordServiceImpl extends ServiceImpl<SignInRecordMapper, Sig
this
.
baseMapper
.
deleteById
(
sign
.
getId
());
}
// signInRecordDO.setIpAddress(IpAddressUtil.getIpAddress(
));
signInRecordDO
.
setIpAddress
(
IpAddressUtil
.
getIpAddress
(
request
));
signInRecordDO
.
setClassId
(
classDictDO
.
getId
());
signInRecordDO
.
setSignInDate
(
LocalDateTime
.
now
());
signInRecordDO
.
setCreateDate
(
LocalDateTime
.
now
());
signInRecordDO
.
setDeviceNo
(
signInRecordDO
.
getDeviceNo
());
this
.
baseMapper
.
insert
(
signInRecordDO
);
}
return
ConstantUtils
.
ADD_SUCCESS
;
...
...
src/main/java/com/subsidy/util/IpAddressUtil.java
View file @
7fb594b
package
com
.
subsidy
.
util
;
import
javax.servlet.http.HttpServletRequest
;
import
java.io.BufferedReader
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.net.HttpURLConnection
;
import
java.net.InetAddress
;
import
java.net.URL
;
import
java.net.UnknownHostException
;
public
class
IpAddressUtil
{
...
...
@@ -36,4 +41,52 @@ public class IpAddressUtil {
}
return
ipAddress
;
}
/**
* @Description:获取客户端外网ip
* @Author:zrt
* @Date:2019/6/13 11:23
**/
public
static
String
getPublicIp
()
{
try
{
String
path
=
"http://subsidy.youkehulian.cn/"
;
// 要获得html页面内容的地址
URL
url
=
new
URL
(
path
);
// 创建url对象
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
// 打开连接
conn
.
setRequestProperty
(
"contentType"
,
"GBK"
);
// 设置url中文参数编码
conn
.
setConnectTimeout
(
5
*
1000
);
// 请求的时间
conn
.
setRequestMethod
(
"GET"
);
// 请求方式
InputStream
inStream
=
conn
.
getInputStream
();
// readLesoSysXML(inStream);
BufferedReader
in
=
new
BufferedReader
(
new
InputStreamReader
(
inStream
,
"GBK"
));
StringBuffer
buffer
=
new
StringBuffer
();
String
line
=
""
;
// 读取获取到内容的最后一行,写入
while
((
line
=
in
.
readLine
())
!=
null
)
{
buffer
.
append
(
line
);
}
String
str
=
buffer
.
toString
();
String
ipString1
=
str
.
substring
(
str
.
indexOf
(
"["
));
// 获取你的IP是中间的[182.149.82.50]内容
String
ipsString2
=
ipString1
.
substring
(
ipString1
.
indexOf
(
"["
)
+
1
,
ipString1
.
lastIndexOf
(
"]"
));
//获取当前IP地址所在地址
/* String ipsString3=ipString1.substring(ipString1.indexOf(": "),ipString1.lastIndexOf("</center>"));
System.err.println(ipsString3);*/
// 返回公网IP值
return
ipsString2
;
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"获取公网IP连接超时"
);
return
"连接超时"
;
}
}
}
src/main/java/com/subsidy/util/websocket/WebSocketUtil.java
View file @
7fb594b
...
...
@@ -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.*
;
/**
* <p>
* WebSocket
* </p>
*
*
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
src/main/java/com/subsidy/vo/classdict/SystemSettings.java
View file @
7fb594b
...
...
@@ -7,6 +7,8 @@ import java.util.List;
@Data
public
class
SystemSettings
{
private
Long
id
;
/**
* 上课时间不晚于23:30,不早于6:30
*/
...
...
src/main/resources/mapper/MemberMapper.xml
View file @
7fb594b
...
...
@@ -333,6 +333,7 @@
<select
id=
"companySettings"
parameterType=
"long"
resultType=
"com.subsidy.vo.classdict.SystemSettings"
>
SELECT
t2.id,
t2.time_limit,
t2.ip_address_record,
t2.device_no_record
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment