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 4897185f
authored
Dec 21, 2022
by
涂亚平
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
人社局跑数据准备中
1 parent
c55137bd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
34 changed files
with
767 additions
and
112 deletions
pom.xml
src/main/java/com/subsidy/common/configure/RenSheConfig.java
src/main/java/com/subsidy/controller/ActivityDetectionController.java
src/main/java/com/subsidy/controller/ClassDictController.java
src/main/java/com/subsidy/controller/ExerciseDictController.java
src/main/java/com/subsidy/controller/ImageCheckRecordController.java
src/main/java/com/subsidy/controller/MemberController.java
src/main/java/com/subsidy/controller/VodPlayHistoryController.java
src/main/java/com/subsidy/model/ActivityDetectionDO.java
src/main/java/com/subsidy/model/ClassDictDO.java
src/main/java/com/subsidy/model/ClassMemberMappingDO.java
src/main/java/com/subsidy/model/CompanyDictDO.java
src/main/java/com/subsidy/model/OprMemDictDO.java
src/main/java/com/subsidy/model/VodPlayHistoryDO.java
src/main/java/com/subsidy/service/ImageCheckRecordService.java
src/main/java/com/subsidy/service/MemberService.java
src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java
src/main/java/com/subsidy/service/impl/ExerciseDictServiceImpl.java
src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java
src/main/java/com/subsidy/service/impl/MemberServiceImpl.java
src/main/java/com/subsidy/util/Base64Util.java
src/main/java/com/subsidy/util/ConstantUtils.java
src/main/java/com/subsidy/util/OSSUtils.java
src/main/java/com/subsidy/util/TestMain.java
src/main/java/com/subsidy/util/websocket/ReConnectWebSocketClient.java
src/main/java/com/subsidy/util/websocket/WebSocketUtil.java
src/main/java/com/subsidy/vo/administer/OperatorsVO.java
src/main/java/com/subsidy/vo/classdict/GetAllClassesVO.java
src/main/java/com/subsidy/vo/classdict/GetClassBaseInfoVO.java
src/main/java/com/subsidy/vo/token/ResultVO.java
src/main/resources/application-dev.properties
src/main/resources/application-prod.properties
src/main/resources/mapper/ClassDictMapper.xml
src/main/resources/mapper/CompanyDictMapper.xml
pom.xml
View file @
4897185
...
...
@@ -222,6 +222,18 @@
</dependency>
<dependency>
<groupId>
org.java-websocket
</groupId>
<artifactId>
Java-WebSocket
</artifactId>
<version>
1.5.1
</version>
</dependency>
<dependency>
<groupId>
cn.hutool
</groupId>
<artifactId>
hutool-all
</artifactId>
<version>
5.5.2
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-cache
</artifactId>
</dependency>
...
...
@@ -242,6 +254,19 @@
<!-- <artifactId>spring-boot-starter-data-mongodb</artifactId>-->
<!-- </dependency>-->
<!-- 阿里云 对象存储oss -->
<dependency>
<groupId>
com.aliyun.oss
</groupId>
<artifactId>
aliyun-sdk-oss
</artifactId>
<version>
3.15.0
</version>
</dependency>
<!-- 图片压缩 -->
<dependency>
<groupId>
net.coobird
</groupId>
<artifactId>
thumbnailator
</artifactId>
<version>
0.4.8
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/com/subsidy/common/configure/RenSheConfig.java
0 → 100644
View file @
4897185
package
com
.
subsidy
.
common
.
configure
;
import
lombok.Data
;
import
org.springframework.boot.context.properties.ConfigurationProperties
;
import
org.springframework.stereotype.Component
;
@Component
@Data
@ConfigurationProperties
(
prefix
=
"renshe"
)
public
class
RenSheConfig
{
//接口地址
private
String
url
;
//私钥
private
String
secretKey
;
}
src/main/java/com/subsidy/controller/ActivityDetectionController.java
View file @
4897185
...
...
@@ -35,7 +35,7 @@ public class ActivityDetectionController {
private
ActivityDetectionService
activityDetectionService
;
@PostMapping
(
"verify"
)
@ApiOperation
(
"验证滑块 ticket randStr memberId classId"
)
@ApiOperation
(
"验证滑块 ticket randStr memberId classId
checkType:检测类型:0:滑块 1:人脸
"
)
@TimeRequired
public
ResponseVO
verify
(
@RequestBody
VerifyDTO
verifyDTO
,
HttpServletRequest
request
){
return
ResponseData
.
generateCreatedResponse
(
0
,
activityDetectionService
.
verify
(
verifyDTO
,
request
));
...
...
src/main/java/com/subsidy/controller/ClassDictController.java
View file @
4897185
...
...
@@ -63,7 +63,7 @@ public class ClassDictController {
@ApiOperation
(
"修改班级 id className classTypeId startDate endDate isOrder 是否按顺序播放 isFastPlay 是否允许快进 "
+
"testRule:测试规则 limitHour 学习上限时长 imageClassCheck:首次进入班级时人脸验证 imageTestCheck:测试前人脸识别验证"
+
"activityDetection:活跃度检测开启/关闭 activityDetectionMethod:活跃度检测方式 firstDragAllowed:首次播放允许拖曳"
+
"firstSpeedAllowed:首次播放允许倍速 playSnap 课程抓拍 "
)
"firstSpeedAllowed:首次播放允许倍速 playSnap 课程抓拍
classCode
"
)
@LoginRequired
public
ResponseVO
updateClass
(
@RequestBody
ClassDictDO
classDictDO
){
return
ResponseData
.
generateCreatedResponse
(
0
,
classDictService
.
updateClass
(
classDictDO
));
...
...
src/main/java/com/subsidy/controller/ExerciseDictController.java
View file @
4897185
...
...
@@ -59,7 +59,7 @@ public class ExerciseDictController {
}
@PostMapping
(
"submit"
)
@ApiOperation
(
"提交答案 {paperId 卷子id memberId 成员id classId课程 courseId 课程id memberExerciseVOS [ id selectAnswer ] startDate:做题时长} "
)
@ApiOperation
(
"提交答案 {paperId 卷子id
l length
memberId 成员id classId课程 courseId 课程id memberExerciseVOS [ id selectAnswer ] startDate:做题时长} "
)
@LoginRequired
@TimeRequired
@CachePut
(
value
=
"ResultData"
,
key
=
"'classId_'+#submitDTO.getClassId()"
)
...
...
src/main/java/com/subsidy/controller/ImageCheckRecordController.java
View file @
4897185
...
...
@@ -76,4 +76,9 @@ public class ImageCheckRecordController {
return
ResponseData
.
generateCreatedResponse
(
0
,
imageCheckRecordService
.
checkResult
(
checkResultDTO
));
}
// @PostMapping("imageProcess")
// public ResponseVO imageProcess(@RequestBody ImageCheckRecordDO imageCheckRecordDO){
// return ResponseData.generateCreatedResponse(0,imageCheckRecordService.imageProcess(imageCheckRecordDO));
// }
}
src/main/java/com/subsidy/controller/MemberController.java
View file @
4897185
...
...
@@ -17,6 +17,8 @@ import io.swagger.annotations.ApiOperation;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletRequest
;
/**
* <p>
* 学生表 前端控制器
...
...
@@ -63,28 +65,28 @@ public class MemberController {
@PostMapping
(
value
=
"/login"
)
@ApiOperation
(
"手机端:登录:telephone/手机号, verifyCode/验证码"
)
public
ResponseVO
login
(
@RequestBody
VerifyCodeDTO
verifyCodeDTO
)
{
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
login
(
verifyCodeDTO
));
public
ResponseVO
login
(
@RequestBody
VerifyCodeDTO
verifyCodeDTO
,
HttpServletRequest
request
)
{
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
login
(
verifyCodeDTO
,
request
));
}
@PostMapping
(
"passwordLogin"
)
@ApiOperation
(
"手机端:密码登录 { companyId accountName password}"
)
public
ResponseVO
passwordLogin
(
@RequestBody
PasswordLoginDTO
passwordLoginDTO
){
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
passwordLogin
(
passwordLoginDTO
));
public
ResponseVO
passwordLogin
(
@RequestBody
PasswordLoginDTO
passwordLoginDTO
,
HttpServletRequest
request
){
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
passwordLogin
(
passwordLoginDTO
,
request
));
}
@PostMapping
(
"qingxuetangLogin"
)
@ApiOperation
(
"轻学堂登录 手机号mobile"
)
@TimeRequired
public
ResponseVO
qingxuetangLogin
(
@RequestBody
QingxuetangLoginDTO
qingxuetangLoginDTO
){
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
qingxuetangLogin
(
qingxuetangLoginDTO
));
public
ResponseVO
qingxuetangLogin
(
@RequestBody
QingxuetangLoginDTO
qingxuetangLoginDTO
,
HttpServletRequest
request
){
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
qingxuetangLogin
(
qingxuetangLoginDTO
,
request
));
}
@PostMapping
(
"kunchiLogin"
)
@ApiOperation
(
"鲲驰登陆 authCorpName 手机号mobile nickname timestamp sign"
)
@TimeRequired
public
ResponseVO
kunchiLogin
(
@RequestBody
QingxuetangLoginDTO
qingxuetangLoginDTO
){
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
kunchiLogin
(
qingxuetangLoginDTO
));
public
ResponseVO
kunchiLogin
(
@RequestBody
QingxuetangLoginDTO
qingxuetangLoginDTO
,
HttpServletRequest
request
){
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
kunchiLogin
(
qingxuetangLoginDTO
,
request
));
}
@PostMapping
(
"checkStatus"
)
...
...
@@ -202,8 +204,8 @@ public class MemberController {
@PostMapping
(
"register"
)
@ApiOperation
(
"注册 companyId userName idCard telephone smsCode "
)
// @LoginRequired
public
ResponseVO
register
(
@RequestBody
RegisterDTO
registerDTO
){
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
register
(
registerDTO
));
public
ResponseVO
register
(
@RequestBody
RegisterDTO
registerDTO
,
HttpServletRequest
request
){
return
ResponseData
.
generateCreatedResponse
(
0
,
memberService
.
register
(
registerDTO
,
request
));
}
@PostMapping
(
"memberLives"
)
...
...
src/main/java/com/subsidy/controller/VodPlayHistoryController.java
View file @
4897185
...
...
@@ -36,7 +36,8 @@ public class VodPlayHistoryController {
private
VodPlayHistoryService
vodPlayHistoryService
;
@PostMapping
(
"insertHistory"
)
@ApiOperation
(
"记录学生看视频位置 ajax请求 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点"
)
@ApiOperation
(
"记录学生看视频位置 ajax请求 classId班级id vodId 视频id "
+
"memberId 成员id playLength 播放时长 playRecord 位点 "
)
@LoginRequired
@TimeRequired
public
ResponseVO
insertHistory
(
@RequestBody
VodPlayHistoryDO
vodPlayHistoryDO
){
...
...
@@ -44,7 +45,8 @@ public class VodPlayHistoryController {
}
@RequestMapping
(
"insertHistoryNew"
)
@ApiOperation
(
"记录学生看视频位置 classId班级id vodId 视频id memberId 成员id playLength 播放时长 playRecord 位点"
)
@ApiOperation
(
"记录学生看视频位置 classId班级id vodId 视频id memberId 成员id "
+
"playLength 播放时长 playRecord 位点 "
)
@TimeRequired
public
ResponseVO
insertHistoryNew
(
@RequestBody
String
param
){
InsertHistoryNewDTO
insertHistoryNewDTO
=
JSON
.
parseObject
(
param
,
InsertHistoryNewDTO
.
class
);
...
...
src/main/java/com/subsidy/model/ActivityDetectionDO.java
View file @
4897185
...
...
@@ -36,6 +36,16 @@ public class ActivityDetectionDO extends BaseModel {
private
Long
memberId
;
/**
* 检测类型:0:滑块 1:人脸
*/
private
Integer
checkType
;
/**
* 人脸识别id
*/
private
Long
faceCheckId
;
/**
* 成功/失败
*/
private
Integer
status
;
...
...
src/main/java/com/subsidy/model/ClassDictDO.java
View file @
4897185
...
...
@@ -34,6 +34,11 @@ public class ClassDictDO extends BaseModel {
private
Long
companyId
;
/**
* 班级编码
*/
private
String
classCode
;
/**
* 班级名称
*/
private
String
className
;
...
...
src/main/java/com/subsidy/model/ClassMemberMappingDO.java
View file @
4897185
...
...
@@ -45,4 +45,9 @@ public class ClassMemberMappingDO extends BaseModel {
*/
private
Integer
emailStatus
;
/**
* 照片
*/
private
String
photo
;
}
src/main/java/com/subsidy/model/CompanyDictDO.java
View file @
4897185
...
...
@@ -36,6 +36,11 @@ public class CompanyDictDO extends BaseModel {
private
String
companyName
;
/**
* 公司编码
*/
private
String
companyCode
;
/**
* 简称
*/
private
String
shortName
;
...
...
src/main/java/com/subsidy/model/OprMemDictDO.java
View file @
4897185
...
...
@@ -39,8 +39,8 @@ public class OprMemDictDO extends BaseModel {
private
Integer
result
;
/**
* 登录ip
==弃用字段
* 登录ip
*/
//
private String ipAddress;
private
String
ipAddress
;
}
src/main/java/com/subsidy/model/VodPlayHistoryDO.java
View file @
4897185
...
...
@@ -59,5 +59,4 @@ public class VodPlayHistoryDO extends BaseModel {
private
LocalDateTime
playDate
;
}
src/main/java/com/subsidy/service/ImageCheckRecordService.java
View file @
4897185
...
...
@@ -30,4 +30,5 @@ public interface ImageCheckRecordService extends IService<ImageCheckRecordDO> {
ImageCheckRecordDO
checkResult
(
CheckResultDTO
checkResultDTO
)
throws
Exception
;
// int imageProcess(ImageCheckRecordDO imageCheckRecordDO);
}
src/main/java/com/subsidy/service/MemberService.java
View file @
4897185
...
...
@@ -14,6 +14,7 @@ import com.subsidy.vo.live.PolyvInfoVO;
import
com.subsidy.vo.member.*
;
import
com.subsidy.vo.paper.QueryPapersVO
;
import
javax.servlet.http.HttpServletRequest
;
import
java.util.List
;
/**
...
...
@@ -34,13 +35,13 @@ public interface MemberService extends IService<MemberDO> {
String
updateMember
(
AddMemberDTO
addMemberDTO
);
UserRoleVO
login
(
VerifyCodeDTO
verifyCodeDTO
);
UserRoleVO
login
(
VerifyCodeDTO
verifyCodeDTO
,
HttpServletRequest
request
);
MemberVO
passwordLogin
(
PasswordLoginDTO
passwordLoginDTO
);
MemberVO
passwordLogin
(
PasswordLoginDTO
passwordLoginDTO
,
HttpServletRequest
request
);
UserRoleVO
qingxuetangLogin
(
QingxuetangLoginDTO
qingxuetangLoginDTO
);
UserRoleVO
qingxuetangLogin
(
QingxuetangLoginDTO
qingxuetangLoginDTO
,
HttpServletRequest
request
);
UserRoleVO
kunchiLogin
(
QingxuetangLoginDTO
qingxuetangLoginDTO
);
UserRoleVO
kunchiLogin
(
QingxuetangLoginDTO
qingxuetangLoginDTO
,
HttpServletRequest
request
);
CheckStatusVO
checkStatus
(
MemberDO
memberDO
);
...
...
@@ -72,7 +73,7 @@ public interface MemberService extends IService<MemberDO> {
QxyVO
qxy
(
MemberDO
memberDO
);
UserRoleVO
register
(
RegisterDTO
registerDTO
);
UserRoleVO
register
(
RegisterDTO
registerDTO
,
HttpServletRequest
request
);
List
<
MemberLivesVO
>
memberLives
(
MemberDO
memberDO
);
...
...
src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java
View file @
4897185
...
...
@@ -37,6 +37,7 @@ public class ActivityDetectionServiceImpl extends ServiceImpl<ActivityDetectionM
activityDetectionDO
.
setClassId
(
verifyDTO
.
getClassId
());
activityDetectionDO
.
setMemberId
(
verifyDTO
.
getMemberId
());
activityDetectionDO
.
setRequestId
(
resp
.
getRequestId
());
activityDetectionDO
.
setCheckType
(
0
);
if
(
resp
.
getCaptchaCode
()==
1
){
//成功
activityDetectionDO
.
setStatus
(
1
);
...
...
src/main/java/com/subsidy/service/impl/ExerciseDictServiceImpl.java
View file @
4897185
...
...
@@ -82,6 +82,8 @@ public class ExerciseDictServiceImpl extends ServiceImpl<ExerciseDictMapper, Exe
}
}
exerciseDoneResultDO
.
setClassId
(
submitDTO
.
getClassId
());
exerciseDoneResultDO
.
setRightCounts
(
rightCounts
);
exerciseDoneResultDO
.
setTotalCounts
(
memberExerciseVOS
.
size
());
...
...
src/main/java/com/subsidy/service/impl/ImageCheckRecordServiceImpl.java
View file @
4897185
...
...
@@ -7,14 +7,11 @@ import com.subsidy.common.configure.RestTemplateConfig;
import
com.subsidy.common.exception.HttpException
;
import
com.subsidy.dto.image.CheckResultDTO
;
import
com.subsidy.dto.image.ImageCheckDTO
;
import
com.subsidy.mapper.AccessTokenMapper
;
import
com.subsidy.mapper.ImageCheckRecordMapper
;
import
com.subsidy.mapper.MemberMapper
;
import
com.subsidy.model.AccessTokenDO
;
import
com.subsidy.model.ImageCheckRecordDO
;
import
com.subsidy.model.MemberDO
;
import
com.subsidy.mapper.*
;
import
com.subsidy.model.*
;
import
com.subsidy.service.ImageCheckRecordService
;
import
com.subsidy.util.DateFormatUtil
;
import
com.subsidy.util.OSSUtils
;
import
com.subsidy.vo.token.*
;
import
org.apache.commons.codec.Charsets
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -22,6 +19,7 @@ import org.springframework.beans.BeanUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.*
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
java.time.LocalDateTime
;
import
java.util.*
;
...
...
@@ -51,10 +49,16 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
@Autowired
private
ImageCheckRecordMapper
imageCheckRecordMapper
;
@Autowired
private
ClassMemberMappingMapper
classMemberMappingMapper
;
@Autowired
private
ActivityDetectionMapper
activityDetectionMapper
;
public
static
final
String
WBAPPID
=
"IDAaOibN"
;
public
static
final
String
SECRET
=
"GD6Z55rHXSlBZB4oxEEowwI5h4IgwUdh0xOOHi6fambXYMFcHuDaBRxtnMx5FVhk"
;
public
static
final
String
SECRET
=
"GD6Z55rHXSlBZB4oxEEowwI5h4IgwUdh0xOOHi6fambXYMFcHuDaBRxtnMx5FVhk"
;
// public static final String WBAPPID = "TIDAbX8x";
// public static final String WBAPPID = "TIDAbX8x";
// public static final String SECRET = "cWAMlQ8Aq7aOad0wrtfJcSpcgksCLFT62qHC4uDHFCGx0SPKqtpt1PungiAKya2M";
public
static
final
String
NONCE
=
"08f1209ee37b4ba29e61e51f3643a24e"
;
...
...
@@ -66,19 +70,19 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
}
public
SendIdCardInfoVO
imageCheck
(
ImageCheckDTO
imageCheckDTO
)
throws
Exception
{
return
PCCheckIdCard
(
imageCheckDTO
.
getId
(),
imageCheckDTO
.
getClassId
(),
0
,
imageCheckDTO
.
getClassPlace
(),
imageCheckDTO
.
getPaperId
());
return
PCCheckIdCard
(
imageCheckDTO
.
getId
(),
imageCheckDTO
.
getClassId
(),
0
,
imageCheckDTO
.
getClassPlace
(),
imageCheckDTO
.
getPaperId
());
}
public
SendIdCardInfoVO
h5CheckResult
(
ImageCheckDTO
imageCheckDTO
)
throws
Exception
{
return
H5IdCheckCard
(
imageCheckDTO
.
getId
(),
imageCheckDTO
.
getClassId
(),
0
,
imageCheckDTO
.
getClassPlace
(),
imageCheckDTO
.
getPaperId
());
return
H5IdCheckCard
(
imageCheckDTO
.
getId
(),
imageCheckDTO
.
getClassId
(),
0
,
imageCheckDTO
.
getClassPlace
(),
imageCheckDTO
.
getPaperId
());
}
public
SendIdCardInfoVO
loginCheck
(
ImageCheckDTO
imageCheckDTO
)
throws
Exception
{
return
PCCheckIdCard
(
imageCheckDTO
.
getId
(),
null
,
1
,
null
,
null
);
return
PCCheckIdCard
(
imageCheckDTO
.
getId
(),
null
,
1
,
null
,
null
);
}
public
SendIdCardInfoVO
h5LoginCheck
(
ImageCheckDTO
imageCheckDTO
)
throws
Exception
{
return
H5IdCheckCard
(
imageCheckDTO
.
getId
(),
null
,
1
,
null
,
null
);
return
H5IdCheckCard
(
imageCheckDTO
.
getId
(),
null
,
1
,
null
,
null
);
}
/**
...
...
@@ -98,7 +102,7 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
* H5端调取权威库(身份证)验证 权威库
* 1,签到页 0 班级内
*/
public
SendIdCardInfoVO
H5IdCheckCard
(
Long
id
,
Long
classId
,
Integer
checkPlace
,
Integer
classPlace
,
Long
paperId
)
{
public
SendIdCardInfoVO
H5IdCheckCard
(
Long
id
,
Long
classId
,
Integer
checkPlace
,
Integer
classPlace
,
Long
paperId
)
{
getDailyCheckCnt
(
id
);
//获取这个学生的基本信息
MemberDO
memberDO
=
memberMapper
.
selectById
(
id
);
...
...
@@ -120,19 +124,19 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
//获取signTicket
IdCardTicketsVO
idCardTicketsVO
=
this
.
signTickets
(
getLatestAccessToken
());
//生成签名
List
<
String
>
signList1
=
new
ArrayList
<>();
List
<
String
>
signList1
=
new
ArrayList
<>();
signList1
.
add
(
WBAPPID
);
signList1
.
add
(
memberDO
.
getId
()
+
""
);
signList1
.
add
(
memberDO
.
getId
()
+
""
);
signList1
.
add
(
"1.0.0"
);
signList1
.
add
(
NONCE
);
String
sign
=
sign
(
signList1
,
idCardTicketsVO
.
getValue
());
//合作方后台上送身份信息
SendIdCardInfoVO
sendIdCardInfoVO
=
null
;
if
(
StringUtils
.
isEmpty
(
memberDO
.
getCheckImage
())){
if
(
StringUtils
.
isEmpty
(
memberDO
.
getCheckImage
()))
{
sendIdCardInfoVO
=
this
.
h5SendIdCardInfo
(
imageCheckRecordDO
.
getId
()
+
""
,
memberDO
,
sign
);
}
else
{
sendIdCardInfoVO
=
this
.
h5SendIdCardInfoCompare
(
imageCheckRecordDO
.
getId
()
+
""
,
memberDO
,
sign
);
}
else
{
sendIdCardInfoVO
=
this
.
h5SendIdCardInfoCompare
(
imageCheckRecordDO
.
getId
()
+
""
,
memberDO
,
sign
);
}
if
(!
"0"
.
equals
(
sendIdCardInfoVO
.
getCode
()))
{
...
...
@@ -146,8 +150,8 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
//签名2
List
<
String
>
signList2
=
new
ArrayList
<>();
signList2
.
add
(
WBAPPID
);
signList2
.
add
(
imageCheckRecordDO
.
getId
()
+
""
);
signList2
.
add
(
memberDO
.
getId
()
+
""
);
signList2
.
add
(
imageCheckRecordDO
.
getId
()
+
""
);
signList2
.
add
(
memberDO
.
getId
()
+
""
);
signList2
.
add
(
"1.0.0"
);
signList2
.
add
(
sendIdCardInfoVO
.
getResult
().
getFaceId
());
signList2
.
add
(
NONCE
);
...
...
@@ -165,7 +169,7 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
* PC端调取权威库(身份证)验证 权威库
* 1,签到页 0 班级内
*/
public
SendIdCardInfoVO
PCCheckIdCard
(
Long
id
,
Long
classId
,
Integer
checkPlace
,
Integer
classPlace
,
Long
paperId
)
{
public
SendIdCardInfoVO
PCCheckIdCard
(
Long
id
,
Long
classId
,
Integer
checkPlace
,
Integer
classPlace
,
Long
paperId
)
{
getDailyCheckCnt
(
id
);
//获取这个学生的基本信息
...
...
@@ -190,8 +194,8 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
//生成签名
List
<
String
>
signList1
=
new
ArrayList
<>();
signList1
.
add
(
WBAPPID
);
signList1
.
add
(
imageCheckRecordDO
.
getId
()
+
""
);
signList1
.
add
(
memberDO
.
getId
()
+
""
);
signList1
.
add
(
imageCheckRecordDO
.
getId
()
+
""
);
signList1
.
add
(
memberDO
.
getId
()
+
""
);
signList1
.
add
(
"1.0.0"
);
String
sign
=
""
;
...
...
@@ -203,9 +207,9 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
signList1
.
add
(
memberDO
.
getIdCard
());
sign
=
sign
(
signList1
,
idCardTicketsVO
.
getValue
());
sendIdCardInfoVO
=
this
.
sendIdCardInfo
(
imageCheckRecordDO
.
getId
()
+
""
,
memberDO
,
sign
);
}
else
{
}
else
{
sign
=
sign
(
signList1
,
idCardTicketsVO
.
getValue
());
sendIdCardInfoVO
=
this
.
sendIdCardInfoCompare
(
imageCheckRecordDO
.
getId
()
+
""
,
memberDO
,
sign
);
sendIdCardInfoVO
=
this
.
sendIdCardInfoCompare
(
imageCheckRecordDO
.
getId
()
+
""
,
memberDO
,
sign
);
}
if
(!
"0"
.
equals
(
sendIdCardInfoVO
.
getCode
()))
{
...
...
@@ -228,6 +232,7 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
return
sendIdCardInfoVO
;
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
ImageCheckRecordDO
checkResult
(
CheckResultDTO
checkResultDTO
)
throws
Exception
{
//获取signTicket
...
...
@@ -247,30 +252,55 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
//存数据库
ImageCheckRecordDO
imageCheckRecordDO
=
imageCheckRecordMapper
.
selectById
(
checkResultDTO
.
getId
());
if
(!
StringUtils
.
isEmpty
(
resultVO
.
getSimilarity
())){
if
(!
StringUtils
.
isEmpty
(
resultVO
.
getSimilarity
()))
{
BeanUtils
.
copyProperties
(
resultVO
,
imageCheckRecordDO
);
ActivityDetectionDO
activityDetectionDO
=
new
ActivityDetectionDO
();
activityDetectionDO
.
setClassId
(
imageCheckRecordDO
.
getClassId
());
activityDetectionDO
.
setMemberId
(
imageCheckRecordDO
.
getMemberId
());
activityDetectionDO
.
setCheckType
(
1
);
activityDetectionDO
.
setFaceCheckId
(
imageCheckRecordDO
.
getId
());
try
{
imageCheckRecordDO
.
setPhoto
(
OSSUtils
.
uploadOneFile
(
resultVO
.
getPhotoList
().
get
(
resultVO
.
getPhotoList
().
size
()-
1
)));
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
);
if
(
imageCheckRecordDO
.
getCheckPlace
()
==
1
)
{
//写到学生班级映射表里去
ClassMemberMappingDO
classMemberMappingDO
=
classMemberMappingMapper
.
selectOne
(
new
QueryWrapper
<
ClassMemberMappingDO
>()
.
lambda
()
.
eq
(
ClassMemberMappingDO:
:
getMemberId
,
imageCheckRecordDO
.
getMemberId
())
.
eq
(
ClassMemberMappingDO:
:
getClassId
,
imageCheckRecordDO
.
getClassId
()));
classMemberMappingDO
.
setPhoto
(
imageCheckRecordDO
.
getPhoto
());
classMemberMappingMapper
.
updateById
(
classMemberMappingDO
);
activityDetectionDO
.
setStatus
(
1
);
}
}
else
{
activityDetectionDO
.
setStatus
(
1
);
imageCheckRecordDO
.
setResult
(
0
);
}
}
catch
(
Exception
e
){
}
catch
(
Exception
e
)
{
imageCheckRecordDO
.
setResult
(
0
);
imageCheckRecordDO
.
setResult
(
0
);
}
activityDetectionMapper
.
insert
(
activityDetectionDO
);
imageCheckRecordMapper
.
updateById
(
imageCheckRecordDO
);
}
return
imageCheckRecordDO
;
}
// public int imageProcess(ImageCheckRecordDO imageCheckRecordDO) {
//
// ImageCheckRecordDO imageCheckRecordDO1 = this.baseMapper.selectById(479);
// try {
// OSSUtils.uploadOneFile(imageCheckRecordDO1.getPhoto());
// }catch (Exception e){
// e.printStackTrace();
// }
// return 0;
// }
/**
* 获取accessToken
*/
...
...
@@ -432,6 +462,7 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
" \"nonce\":\""
+
NONCE
+
"\","
+
" \"orderNo\":\""
+
orderNo
+
"\","
+
" \"sign\":\""
+
sign
+
"\","
+
" \"getPhotos\":\""
+
1
+
"\","
+
" \"getFile\":\"2\","
+
" \"queryVersion\":\"\""
+
"}"
;
...
...
src/main/java/com/subsidy/service/impl/MemberServiceImpl.java
View file @
4897185
This diff is collapsed.
Click to expand it.
src/main/java/com/subsidy/util/Base64Util.java
0 → 100644
View file @
4897185
package
com
.
subsidy
.
util
;
import
sun.misc.BASE64Decoder
;
import
sun.misc.BASE64Encoder
;
import
javax.imageio.stream.FileImageInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
class
Base64Util
{
/**
* 字符串转图片
* @param base64Str
* @return
*/
public
static
byte
[]
decode
(
String
base64Str
){
byte
[]
b
=
null
;
BASE64Decoder
decoder
=
new
BASE64Decoder
();
try
{
b
=
decoder
.
decodeBuffer
(
replaceEnter
(
base64Str
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
b
;
}
/**
* 图片转字符串
* @param image
* @return
*/
public
static
String
encode
(
byte
[]
image
){
BASE64Encoder
decoder
=
new
BASE64Encoder
();
return
replaceEnter
(
decoder
.
encode
(
image
));
}
public
static
String
encode
(
String
uri
){
BASE64Encoder
encoder
=
new
BASE64Encoder
();
return
replaceEnter
(
encoder
.
encode
(
uri
.
getBytes
()));
}
/**
*
* @path 图片路径
* @return
*/
public
static
byte
[]
imageTobyte
(
String
path
){
byte
[]
data
=
null
;
FileImageInputStream
input
=
null
;
try
{
input
=
new
FileImageInputStream
(
new
File
(
path
));
ByteArrayOutputStream
output
=
new
ByteArrayOutputStream
();
byte
[]
buf
=
new
byte
[
1024
];
int
numBytesRead
=
0
;
while
((
numBytesRead
=
input
.
read
(
buf
))
!=
-
1
){
output
.
write
(
buf
,
0
,
numBytesRead
);
}
data
=
output
.
toByteArray
();
output
.
close
();
input
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
data
;
}
public
static
String
replaceEnter
(
String
str
){
String
reg
=
"[\n-\r]"
;
Pattern
p
=
Pattern
.
compile
(
reg
);
Matcher
m
=
p
.
matcher
(
str
);
return
m
.
replaceAll
(
""
);
}
}
\ No newline at end of file
src/main/java/com/subsidy/util/ConstantUtils.java
View file @
4897185
...
...
@@ -48,8 +48,6 @@ public class ConstantUtils {
public
static
final
String
PUBLISH_SUCCESS
=
"发布成功"
;
public
static
final
String
LOGIN_OUT
=
"登出成功"
;
public
static
final
String
COMPRESS_SUCCESS
=
"压缩成功"
;
public
static
final
String
CHECK_STATUS
=
"审核通过"
;
...
...
@@ -110,4 +108,9 @@ public class ConstantUtils {
*/
public
static
final
String
POLYV_VIEWLOG_2
=
"http://api.polyv.net/live/v1/statistics/{channelId}/viewlog"
;
/**
* 推送人社局图片格式
*/
public
static
final
String
IMAGE_FORMAT
=
"?x-oss-process=image/auto-orient,1/resize,m_pad,w_500,h_500/quality,Q_100/format,jpg"
;
}
src/main/java/com/subsidy/util/OSSUtils.java
0 → 100644
View file @
4897185
package
com
.
subsidy
.
util
;
import
cn.hutool.core.codec.Base64
;
import
cn.hutool.core.date.DateTime
;
import
com.aliyun.oss.ClientException
;
import
com.aliyun.oss.OSS
;
import
com.aliyun.oss.OSSClientBuilder
;
import
com.aliyun.oss.OSSException
;
import
com.aliyun.oss.model.PutObjectRequest
;
import
com.aliyun.oss.model.PutObjectResult
;
import
java.io.*
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
import
java.util.UUID
;
public
class
OSSUtils
{
// @Value("${aliyun.oss.accessKeyId}")
private
static
String
accessKeyId
=
"LTAIOrpFKrDqsQ2c"
;
// @Value("${aliyun.oss.accessKeySecret}")
private
static
String
secretAccessKey
=
"1Qp8huLETbWiBBJvHXJ7MOIhtKuA1G"
;
// @Value("${aliyun.oss.endpoint}")
private
static
String
endPoint
=
"oss-cn-beijing.aliyuncs.com"
;
// @Value("${aliyun.oss.bucketName}")
// private static String bucketName = "shixischool";
private
static
String
bucketName
=
"ykhl-bigger"
;
public
static
String
uploadOneFile
(
String
file
)
throws
IOException
{
// 创建OSSClient实例。
OSS
ossClient
=
new
OSSClientBuilder
().
build
(
endPoint
,
accessKeyId
,
secretAccessKey
);
// 设置文件名
String
fileName
=
new
DateTime
().
toString
(
"yyyy-MM-dd"
)
+
UUID
.
randomUUID
().
toString
()
+
".jpg"
;
// 获取文件后缀名
// int originalFilenameStartIndex = file.indexOf('/');
// int originalFilenameEndIndex = file.indexOf(';');
// String originalFilename = file.substring(originalFilenameStartIndex+1,originalFilenameEndIndex);
// 获取base64的文件
// file = file.split(",")[1];
byte
[]
bytesFile
=
Base64
.
decode
(
file
);
try
{
// 创建PutObject请求。
InputStream
inputStream
=
new
ByteArrayInputStream
(
bytesFile
);
ossClient
.
putObject
(
bucketName
,
fileName
,
inputStream
);
String
url
=
"http://"
+
bucketName
+
"."
+
endPoint
+
"/"
+
fileName
;
// System.out.println(url);
return
url
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
finally
{
if
(
ossClient
!=
null
)
{
ossClient
.
shutdown
();
}
}
}
public
static
String
image2Base64
(
String
imgUrl
)
{
URL
url
=
null
;
InputStream
is
=
null
;
ByteArrayOutputStream
outStream
=
null
;
HttpURLConnection
httpUrl
=
null
;
try
{
url
=
new
URL
(
imgUrl
);
httpUrl
=
(
HttpURLConnection
)
url
.
openConnection
();
httpUrl
.
connect
();
httpUrl
.
getInputStream
();
is
=
httpUrl
.
getInputStream
();
outStream
=
new
ByteArrayOutputStream
();
// 创建一个Buffer字符串
byte
[]
buffer
=
new
byte
[
1024
];
// 每次读取的字符串长度,如果为-1,代表全部读取完毕
int
len
=
0
;
// 使用一个输入流从buffer里把数据读取出来
while
((
len
=
is
.
read
(
buffer
))
!=
-
1
)
{
// 用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度
outStream
.
write
(
buffer
,
0
,
len
);
}
// 对字节数组Base64编码
return
Base64Util
.
encode
(
outStream
.
toByteArray
());
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
is
!=
null
)
{
try
{
is
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
outStream
!=
null
)
{
try
{
outStream
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
if
(
httpUrl
!=
null
)
{
httpUrl
.
disconnect
();
}
}
return
imgUrl
;
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
image2Base64
(
"https://shixischool.oss-cn-beijing.aliyuncs.com/2022-12-219df5b721-99b7-48c4-916e-e474a4eca946.jpg?x-oss-process=image/auto-orient,1/resize,m_pad,w_500,h_500/quality,Q_100/format,jpg"
));
}
}
src/main/java/com/subsidy/util/TestMain.java
View file @
4897185
package
com
.
subsidy
.
util
;
import
org.apache.commons.codec.binary.Base64
;
import
java.io.FileOutputStream
;
import
java.io.OutputStream
;
import
java.security.MessageDigest
;
import
java.util.Random
;
public
class
TestMain
{
/**
* 对字节数组字符串进行Base64解码并生成图片
* @param imgStr 图片数据
* @param imgFilePath 保存图片全路径地址
* @return
*/
public
static
boolean
generateImage
(
String
imgStr
,
String
imgFilePath
){
//
if
(
imgStr
==
null
)
//图像数据为空
{
return
false
;
}
try
{
//Base64解码
byte
[]
b
=
Base64
.
decodeBase64
(
imgStr
);
for
(
int
i
=
0
;
i
<
b
.
length
;++
i
)
{
if
(
b
[
i
]<
0
)
{
//调整异常数据
b
[
i
]+=
256
;
}
}
//生成jpeg图片
OutputStream
out
=
new
FileOutputStream
(
imgFilePath
);
out
.
write
(
b
);
out
.
flush
();
out
.
close
();
return
true
;
}
catch
(
Exception
e
)
{
return
false
;
}
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// String password = "123456";
// String saltCode = getRandomCharAndNumr(5);
// String encryptString = encrypt("91ebn" + password);
// System.out.println(encryptString);
Thread
thread1
=
new
Thread
(()
->
{
System
.
out
.
println
(
"thread1"
);
});
Thread
thread2
=
new
Thread
(()
->
{
System
.
out
.
println
(
"thread2"
);
});
Thread
thread3
=
new
Thread
(()
->
{
System
.
out
.
println
(
"thread3"
);
});
thread1
.
start
();
thread1
.
join
();
thread2
.
start
();
thread2
.
join
();
thread3
.
start
();
thread3
.
join
();
//
Thread thread1 = new Thread(() -> {
//
System.out.println("thread1");
//
});
//
Thread thread2 = new Thread(() -> {
//
System.out.println("thread2");
//
});
//
Thread thread3 = new Thread(() -> {
//
System.out.println("thread3");
//
});
//
thread1.start();
//
thread1.join();
//
thread2.start();
//
thread2.join();
//
thread3.start();
//
thread3.join();
}
...
...
src/main/java/com/subsidy/util/websocket/ReConnectWebSocketClient.java
0 → 100644
View file @
4897185
package
com
.
subsidy
.
util
.
websocket
;
import
cn.hutool.core.thread.ThreadUtil
;
import
cn.hutool.core.util.StrUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
org.java_websocket.WebSocket
;
import
org.java_websocket.client.WebSocketClient
;
import
org.java_websocket.framing.Framedata
;
import
org.java_websocket.handshake.ServerHandshake
;
import
javax.net.ssl.*
;
import
java.net.Socket
;
import
java.net.URI
;
import
java.nio.ByteBuffer
;
import
java.security.cert.CertificateException
;
import
java.security.cert.X509Certificate
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.atomic.AtomicBoolean
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.function.Consumer
;
/** @Author huyi @Date 2021/10/15 20:03 @Description: 重连websocket客户端 */
@Slf4j
public
class
ReConnectWebSocketClient
{
/** 字符串消息回调 */
private
Consumer
<
String
>
msgStr
;
/** 字节流消息回调 */
private
Consumer
<
ByteBuffer
>
msgByte
;
/** 异常回调 */
private
Consumer
<
Exception
>
error
;
/** 连接标识 */
private
String
key
;
/** ws服务端连接 */
private
URI
serverUri
;
/** 尝试重连标识 */
private
AtomicBoolean
tryReconnect
;
/** 需要ping标识 */
private
AtomicBoolean
needPing
;
/** websocket连接实体 */
private
WebSocketClient
webSocketClient
;
/** 重连次数 */
private
AtomicInteger
reConnectTimes
;
/** 连接结束标识 */
private
AtomicBoolean
end
;
/** 连接后初始发送报文,这里也可以不需要,如果服务端主动断开连接,重连后可以继续推送报文的话。 */
private
String
initReConnectReq
;
/** 结束回调 */
private
Consumer
<
String
>
endConsumer
;
public
ReConnectWebSocketClient
(
URI
serverUri
,
String
key
,
Consumer
<
String
>
msgStr
,
Consumer
<
ByteBuffer
>
msgByte
,
Consumer
<
Exception
>
error
)
{
this
.
msgStr
=
msgStr
;
this
.
msgByte
=
msgByte
;
this
.
error
=
error
;
this
.
key
=
key
;
this
.
serverUri
=
serverUri
;
this
.
tryReconnect
=
new
AtomicBoolean
(
false
);
this
.
needPing
=
new
AtomicBoolean
(
true
);
this
.
reConnectTimes
=
new
AtomicInteger
(
0
);
this
.
end
=
new
AtomicBoolean
(
false
);
this
.
endConsumer
=
this
::
close
;
init
();
}
/** 初始化连接 */
public
void
init
()
{
// 创建连接
createWebSocketClient
();
// ping线程
circlePing
();
}
private
void
needReconnect
()
throws
Exception
{
ThreadUtil
.
sleep
(
10
,
TimeUnit
.
SECONDS
);
int
cul
=
reConnectTimes
.
incrementAndGet
();
if
(
cul
>
3
)
{
close
(
"real stop"
);
throw
new
Exception
(
"服务端断连,3次重连均失败"
);
}
log
.
warn
(
"[{}]第[{}]次断开重连"
,
key
,
cul
);
if
(
tryReconnect
.
get
())
{
log
.
error
(
"[{}]第[{}]次断开重连结果 -> 连接正在重连,本次重连请求放弃"
,
key
,
cul
);
needReconnect
();
return
;
}
try
{
tryReconnect
.
set
(
true
);
if
(
webSocketClient
.
isOpen
())
{
log
.
warn
(
"[{}]第[{}]次断开重连,关闭旧连接"
,
key
,
cul
);
webSocketClient
.
closeConnection
(
2
,
"reconnect stop"
);
}
webSocketClient
=
null
;
createWebSocketClient
();
connect
();
if
(!
StrUtil
.
hasBlank
(
initReConnectReq
))
{
send
(
initReConnectReq
);
}
}
catch
(
Exception
exception
)
{
log
.
error
(
"[{}]第[{}]次断开重连结果 -> 连接正在重连,重连异常:[{}]"
,
key
,
cul
,
exception
.
getMessage
());
needReconnect
();
}
finally
{
tryReconnect
.
set
(
false
);
}
}
private
void
createWebSocketClient
()
{
webSocketClient
=
new
WebSocketClient
(
serverUri
)
{
@Override
public
void
onOpen
(
ServerHandshake
serverHandshake
)
{
log
.
info
(
"[{}]ReConnectWebSocketClient [onOpen]连接成功{}"
,
key
,
getRemoteSocketAddress
());
tryReconnect
.
set
(
false
);
}
@Override
public
void
onMessage
(
String
text
)
{
log
.
info
(
"[{}]ReConnectWebSocketClient [onMessage]接收到服务端数据:text={}"
,
key
,
text
);
msgStr
.
accept
(
text
);
}
@Override
public
void
onMessage
(
ByteBuffer
bytes
)
{
log
.
info
(
"[{}]ReConnectWebSocketClient [onMessage]接收到服务端数据:bytes={}"
,
key
,
bytes
);
msgByte
.
accept
(
bytes
);
}
@Override
public
void
onWebsocketPong
(
WebSocket
conn
,
Framedata
f
)
{
log
.
info
(
"[{}]ReConnectWebSocketClient [onWebsocketPong]接收到服务端数据:opcode={}"
,
key
,
f
.
getOpcode
());
}
@Override
public
void
onClose
(
int
i
,
String
s
,
boolean
b
)
{
log
.
info
(
"[{}]ReConnectWebSocketClient [onClose]关闭,s={},b={}"
,
key
,
s
,
b
);
if
(
StrUtil
.
hasBlank
(
s
)
||
s
.
contains
(
"https"
))
{
if
(
end
.
get
())
{
return
;
}
try
{
needReconnect
();
}
catch
(
Exception
exception
)
{
endConsumer
.
accept
(
"reconnect error"
);
error
.
accept
(
exception
);
}
}
}
@Override
public
void
onError
(
Exception
e
)
{
log
.
info
(
"[{}]ReConnectWebSocketClient [onError]异常,e={}"
,
key
,
e
);
endConsumer
.
accept
(
"error close"
);
error
.
accept
(
e
);
}
};
if
(
serverUri
.
toString
().
contains
(
"wss://"
))
{
trustAllHosts
(
webSocketClient
);
}
}
public
void
circlePing
()
{
new
Thread
(
()
->
{
while
(
needPing
.
get
())
{
if
(
webSocketClient
.
isOpen
())
{
webSocketClient
.
sendPing
();
}
ThreadUtil
.
sleep
(
5
,
TimeUnit
.
SECONDS
);
}
log
.
warn
(
"[{}]Ping循环关闭"
,
key
);
})
.
start
();
}
/**
* 连接
*
* @throws Exception 异常
*/
public
void
connect
()
throws
Exception
{
webSocketClient
.
connectBlocking
(
10
,
TimeUnit
.
SECONDS
);
}
/**
* 发送
*
* @param msg 消息
* @throws Exception 异常
*/
public
void
send
(
String
msg
)
throws
Exception
{
this
.
initReConnectReq
=
msg
;
if
(
webSocketClient
.
isOpen
())
{
webSocketClient
.
send
(
msg
);
}
}
/**
* 关闭
*
* @param msg 关闭消息
*/
public
void
close
(
String
msg
)
{
needPing
.
set
(
false
);
end
.
set
(
true
);
if
(
webSocketClient
!=
null
)
{
webSocketClient
.
closeConnection
(
3
,
msg
);
}
}
/**
* 忽略证书
*
* @param client
*/
public
void
trustAllHosts
(
WebSocketClient
client
)
{
TrustManager
[]
trustAllCerts
=
new
TrustManager
[]
{
new
X509ExtendedTrustManager
()
{
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
,
Socket
socket
)
throws
CertificateException
{}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
,
Socket
socket
)
throws
CertificateException
{}
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
,
SSLEngine
sslEngine
)
throws
CertificateException
{}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
,
SSLEngine
sslEngine
)
throws
CertificateException
{}
@Override
public
void
checkClientTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
)
throws
CertificateException
{}
@Override
public
void
checkServerTrusted
(
X509Certificate
[]
x509Certificates
,
String
s
)
throws
CertificateException
{}
@Override
public
X509Certificate
[]
getAcceptedIssuers
()
{
return
null
;
}
}
};
try
{
SSLContext
ssl
=
SSLContext
.
getInstance
(
"SSL"
);
ssl
.
init
(
null
,
trustAllCerts
,
new
java
.
security
.
SecureRandom
());
SSLSocketFactory
socketFactory
=
ssl
.
getSocketFactory
();
client
.
setSocketFactory
(
socketFactory
);
}
catch
(
Exception
e
)
{
log
.
error
(
"ReConnectWebSocketClient trustAllHosts 异常,e={0}"
,
e
);
}
}
}
\ No newline at end of file
src/main/java/com/subsidy/util/websocket/WebSocketUtil.java
View file @
4897185
...
...
@@ -43,8 +43,8 @@ public class WebSocketUtil implements WebSocketHandler {
private
MemberMapper
memberMapper
;
private
int
heartbeatMin
=
1
;
// 断连最小心跳次数
private
int
heartbeatMax
=
2
;
// 断连最大心跳次数
private
int
reconnectionSeconds
=
60
;
//每次断连间隔重新连接秒
private
int
heartbeatMax
=
4
;
// 断连最大心跳次数
private
int
reconnectionSeconds
=
3
;
//每次断连间隔重新连接秒
/**
* 存放建立连接webSocket对象 Map<memberId,session>
...
...
@@ -74,40 +74,35 @@ public class WebSocketUtil implements WebSocketHandler {
* 并且上一次记录时间大于 { heartbeatMax * reconnectionSeconds } 秒(心跳检测机制),则判断为这次登陆是免密码登陆的重新记录上线时间
*/
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
(
"登出"
))
{
if
(
null
!=
oprMemDictDO
)
{
//登出过的话就写记录,否则不写
oprMemDictDO
.
setUserId
(
id
);
oprMemDictDO
.
setResult
(
1
);
oprMemDictDO
.
setOprType
(
"登录"
);
// oprMemDictDO.setIpAddress(session.getRemoteAddress().getHostName
());
oprMemDictDO
.
setIpAddress
(
session
.
getRemoteAddress
().
getAddress
().
getHostAddress
());
oprMemDictMapper
.
insert
(
oprMemDictDO
);
}
// }
}
}
webSocketMap
.
remove
(
id
);
}
else
{
webSocketMap
.
put
(
id
,
session
);
OprMemDictDO
oprMemDictDO
=
new
OprMemDictDO
();
oprMemDictDO
.
setUserId
(
id
);
oprMemDictDO
.
setResult
(
1
);
oprMemDictDO
.
setOprType
(
"登录"
);
oprMemDictDO
.
setIpAddress
(
session
.
getRemoteAddress
().
getAddress
().
getHostAddress
());
oprMemDictMapper
.
insert
(
oprMemDictDO
);
// 数据操作
SystemSettings
systemSettings
=
memberMapper
.
companySettings
(
id
);
//公司配置
List
<
ClassSettingsVO
>
classSettings
=
classDictMapper
.
getClassSettings
(
id
);
systemSettings
.
setClassSettingsVOS
(
classSettings
);
if
(
CollectionUtils
.
isNotEmpty
(
classSettings
))
{
String
data
=
JSONObject
.
toJSONString
(
ResponseData
.
generateCreatedResponse
(
0
,
systemSettings
),
SerializerFeature
.
WriteMapNullValue
);
webSocketMap
.
get
(
id
).
sendMessage
(
new
TextMessage
(
data
));
}
}
webSocketMap
.
put
(
id
,
session
);
// 数据操作
SystemSettings
systemSettings
=
memberMapper
.
companySettings
(
id
);
//公司配置
List
<
ClassSettingsVO
>
classSettings
=
classDictMapper
.
getClassSettings
(
id
);
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));
}
}
...
...
@@ -134,19 +129,22 @@ public class WebSocketUtil implements WebSocketHandler {
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());
}
/**
* 关闭链接 :在两端WebSocket connection都关闭或transport error发生后执行
*/
@Override
public
void
afterConnectionClosed
(
WebSocketSession
session
,
CloseStatus
closeStatus
)
throws
Exception
{
public
void
afterConnectionClosed
(
WebSocketSession
session
,
CloseStatus
closeStatus
)
{
if
(
null
!=
session
)
{
if
(
null
!=
webSocketMap
)
{
String
params
=
session
.
getUri
().
getQuery
();
Long
id
=
Long
.
valueOf
(
params
.
split
(
"="
)[
1
]);
// //下线
// OprMemDictDO oprMemDictDO = new OprMemDictDO();
// oprMemDictDO.setUserId(id);
// oprMemDictDO.setOprType("登出");
// oprMemDictMapper.insert(oprMemDictDO);
heartbeat
(
webSocketMap
.
get
(
id
));
}
// log.info("<---- webSocket is close");
...
...
@@ -174,15 +172,16 @@ public class WebSocketUtil implements WebSocketHandler {
@Override
public
void
run
()
{
if
(
null
!=
session
&&
!
session
.
isOpen
())
{
if
(
beatsNum
>
heartbeatMax
)
{
//heartbeatMa:2
if
(
beatsNum
>
heartbeatMax
)
{
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
().
getAddress
().
getHostAddress
());
oprMemDictMapper
.
insert
(
oprMemDictDO
);
beatsNum
=
heartbeatMin
;
taskMap
.
get
(
session
.
getId
()).
cancel
(
true
);
// break;
}
...
...
src/main/java/com/subsidy/vo/administer/OperatorsVO.java
View file @
4897185
...
...
@@ -33,4 +33,6 @@ public class OperatorsVO {
private
String
logo
;
private
String
superviseName
;
private
String
companyCode
;
}
src/main/java/com/subsidy/vo/classdict/GetAllClassesVO.java
View file @
4897185
...
...
@@ -11,6 +11,8 @@ public class GetAllClassesVO {
private
String
className
;
private
String
classCode
;
private
String
courseName
;
private
String
startDate
;
...
...
src/main/java/com/subsidy/vo/classdict/GetClassBaseInfoVO.java
View file @
4897185
...
...
@@ -9,6 +9,8 @@ public class GetClassBaseInfoVO {
private
String
courseName
;
private
String
classCode
;
private
Integer
count
;
private
String
className
;
...
...
src/main/java/com/subsidy/vo/token/ResultVO.java
View file @
4897185
...
...
@@ -2,6 +2,8 @@ package com.subsidy.vo.token;
import
lombok.Data
;
import
java.util.List
;
@Data
public
class
ResultVO
{
...
...
@@ -25,4 +27,5 @@ public class ResultVO {
private
String
trtcFlag
;
private
List
<
String
>
photoList
;
}
src/main/resources/application-dev.properties
View file @
4897185
...
...
@@ -54,4 +54,7 @@ spring.redis.lettuce.pool.min-idle=8
qxueyou.appId
=
qxywz5nnWMI77CM3Tx
qxueyou.securityKey
=
626737T1-65K0-5xC2-0Y0V-2Aq95qxy
qxueyou.url
=
https://dev.qxueyou.com/auth/user/token
\ No newline at end of file
qxueyou.url
=
https://dev.qxueyou.com/auth/user/token
renshe.url
=
https://test.shzypxy.com
renshe.secretKey
=
111
\ No newline at end of file
src/main/resources/application-prod.properties
View file @
4897185
...
...
@@ -48,4 +48,7 @@ spring.redis.lettuce.pool.min-idle=8
qxueyou.appId
=
qxy1a2n6h16012nJ6x
qxueyou.securityKey
=
44420Tlu-P463-9041-2h1q-29Z59qxy
qxueyou.url
=
https://www.qxueyou.com/auth/user/token
\ No newline at end of file
qxueyou.url
=
https://www.qxueyou.com/auth/user/token
renshe.url
=
https://api.shzypxy.com
renshe.secretKey
=
111
\ No newline at end of file
src/main/resources/mapper/ClassDictMapper.xml
View file @
4897185
...
...
@@ -32,7 +32,8 @@
t.end_date,
t4.cnt,
t5.class_type,
t5.id as class_type_id
t5.id as class_type_id,
t.class_code
FROM
class_dict t
left join class_type_dict t5 on t.class_type_id = t5.id
...
...
@@ -142,7 +143,8 @@
t.is_order,
t.is_fast_play,
t.test_rule,
t2.cover_page
t2.cover_page,
t.class_code
FROM
class_dict t
LEFT JOIN course_dict t2 ON t.course_id = t2.id
...
...
src/main/resources/mapper/CompanyDictMapper.xml
View file @
4897185
...
...
@@ -32,7 +32,8 @@
t2.company_name,
t2.logo,
t2.address,
t2.supervise_name
t2.supervise_name,
t2.company_code
FROM
administer t
left join role_administer_mapping t4 on t.id = t4.administer_id
...
...
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