diff --git a/src/main/java/com/subsidy/common/configure/RenSheConfig.java b/src/main/java/com/subsidy/common/configure/RenSheConfig.java
new file mode 100644
index 0000000..3d260ec
--- /dev/null
+++ b/src/main/java/com/subsidy/common/configure/RenSheConfig.java
@@ -0,0 +1,18 @@
+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;
+
+}
diff --git a/src/main/java/com/subsidy/controller/ActivityDetectionController.java b/src/main/java/com/subsidy/controller/ActivityDetectionController.java
index 1f763eb..e693da3 100644
--- a/src/main/java/com/subsidy/controller/ActivityDetectionController.java
+++ b/src/main/java/com/subsidy/controller/ActivityDetectionController.java
@@ -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));
diff --git a/src/main/java/com/subsidy/controller/ClassDictController.java b/src/main/java/com/subsidy/controller/ClassDictController.java
index 766314e..c9b8cf4 100644
--- a/src/main/java/com/subsidy/controller/ClassDictController.java
+++ b/src/main/java/com/subsidy/controller/ClassDictController.java
@@ -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));
diff --git a/src/main/java/com/subsidy/controller/ExerciseDictController.java b/src/main/java/com/subsidy/controller/ExerciseDictController.java
index 4222a2b..c1b23cd 100644
--- a/src/main/java/com/subsidy/controller/ExerciseDictController.java
+++ b/src/main/java/com/subsidy/controller/ExerciseDictController.java
@@ -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()")
diff --git a/src/main/java/com/subsidy/controller/ImageCheckRecordController.java b/src/main/java/com/subsidy/controller/ImageCheckRecordController.java
index 2a48c37..3061f87 100644
--- a/src/main/java/com/subsidy/controller/ImageCheckRecordController.java
+++ b/src/main/java/com/subsidy/controller/ImageCheckRecordController.java
@@ -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));
+// }
+
}
diff --git a/src/main/java/com/subsidy/controller/MemberController.java b/src/main/java/com/subsidy/controller/MemberController.java
index 50ce829..4e24d4d 100644
--- a/src/main/java/com/subsidy/controller/MemberController.java
+++ b/src/main/java/com/subsidy/controller/MemberController.java
@@ -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;
+
/**
*
* 学生表 前端控制器
@@ -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")
diff --git a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java
index 2732de5..ff5f4b6 100644
--- a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java
+++ b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java
@@ -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);
diff --git a/src/main/java/com/subsidy/model/ActivityDetectionDO.java b/src/main/java/com/subsidy/model/ActivityDetectionDO.java
index 73e9319..fbfd709 100644
--- a/src/main/java/com/subsidy/model/ActivityDetectionDO.java
+++ b/src/main/java/com/subsidy/model/ActivityDetectionDO.java
@@ -36,6 +36,16 @@ public class ActivityDetectionDO extends BaseModel {
private Long memberId;
/**
+ * 检测类型:0:滑块 1:人脸
+ */
+ private Integer checkType;
+
+ /**
+ * 人脸识别id
+ */
+ private Long faceCheckId;
+
+ /**
* 成功/失败
*/
private Integer status;
diff --git a/src/main/java/com/subsidy/model/ClassDictDO.java b/src/main/java/com/subsidy/model/ClassDictDO.java
index 52c4aef..77c4ae3 100644
--- a/src/main/java/com/subsidy/model/ClassDictDO.java
+++ b/src/main/java/com/subsidy/model/ClassDictDO.java
@@ -34,6 +34,11 @@ public class ClassDictDO extends BaseModel {
private Long companyId;
/**
+ * 班级编码
+ */
+ private String classCode;
+
+ /**
* 班级名称
*/
private String className;
diff --git a/src/main/java/com/subsidy/model/ClassMemberMappingDO.java b/src/main/java/com/subsidy/model/ClassMemberMappingDO.java
index 0d7bef0..ae1f3f2 100644
--- a/src/main/java/com/subsidy/model/ClassMemberMappingDO.java
+++ b/src/main/java/com/subsidy/model/ClassMemberMappingDO.java
@@ -45,4 +45,9 @@ public class ClassMemberMappingDO extends BaseModel {
*/
private Integer emailStatus;
+ /**
+ * 照片
+ */
+ private String photo;
+
}
diff --git a/src/main/java/com/subsidy/model/CompanyDictDO.java b/src/main/java/com/subsidy/model/CompanyDictDO.java
index 3ce3917..76af168 100644
--- a/src/main/java/com/subsidy/model/CompanyDictDO.java
+++ b/src/main/java/com/subsidy/model/CompanyDictDO.java
@@ -36,6 +36,11 @@ public class CompanyDictDO extends BaseModel {
private String companyName;
/**
+ * 公司编码
+ */
+ private String companyCode;
+
+ /**
* 简称
*/
private String shortName;
diff --git a/src/main/java/com/subsidy/model/OprMemDictDO.java b/src/main/java/com/subsidy/model/OprMemDictDO.java
index 6cc856f..5b28136 100644
--- a/src/main/java/com/subsidy/model/OprMemDictDO.java
+++ b/src/main/java/com/subsidy/model/OprMemDictDO.java
@@ -39,8 +39,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/model/VodPlayHistoryDO.java b/src/main/java/com/subsidy/model/VodPlayHistoryDO.java
index d5fc850..2086fba 100644
--- a/src/main/java/com/subsidy/model/VodPlayHistoryDO.java
+++ b/src/main/java/com/subsidy/model/VodPlayHistoryDO.java
@@ -59,5 +59,4 @@ public class VodPlayHistoryDO extends BaseModel {
private LocalDateTime playDate;
-
}
diff --git a/src/main/java/com/subsidy/service/ImageCheckRecordService.java b/src/main/java/com/subsidy/service/ImageCheckRecordService.java
index 29de678..08d8a9b 100644
--- a/src/main/java/com/subsidy/service/ImageCheckRecordService.java
+++ b/src/main/java/com/subsidy/service/ImageCheckRecordService.java
@@ -30,4 +30,5 @@ public interface ImageCheckRecordService extends IService {
ImageCheckRecordDO checkResult(CheckResultDTO checkResultDTO)throws Exception;
+// int imageProcess(ImageCheckRecordDO imageCheckRecordDO);
}
diff --git a/src/main/java/com/subsidy/service/MemberService.java b/src/main/java/com/subsidy/service/MemberService.java
index 712375b..b73d0c1 100644
--- a/src/main/java/com/subsidy/service/MemberService.java
+++ b/src/main/java/com/subsidy/service/MemberService.java
@@ -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 {
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 {
QxyVO qxy(MemberDO memberDO);
- UserRoleVO register(RegisterDTO registerDTO);
+ UserRoleVO register(RegisterDTO registerDTO, HttpServletRequest request);
List memberLives(MemberDO memberDO);
diff --git a/src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java b/src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java
index 8670f59..e2f1f6e 100644
--- a/src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java
+++ b/src/main/java/com/subsidy/service/impl/ActivityDetectionServiceImpl.java
@@ -37,6 +37,7 @@ public class ActivityDetectionServiceImpl extends ServiceImpl signList1 =new ArrayList<>();
+ List 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 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 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 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()
+ .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 imple
@Autowired
private LiveDictMapper liveDictMapper;
+ @Autowired
+ private ActivityDetectionMapper activityDetectionMapper;
+
public IPage getAll(GetAllDTO getAllDTO) {
Page pager = new Page(getAllDTO.getPageNum(), getAllDTO.getPageSize());
@@ -281,7 +285,7 @@ public class MemberServiceImpl extends ServiceImpl imple
}
@Transactional(rollbackFor = Exception.class)
- public UserRoleVO login(VerifyCodeDTO verifyCodeDTO) {
+ public UserRoleVO login(VerifyCodeDTO verifyCodeDTO, HttpServletRequest request) {
UserRoleVO userRoleVO = new UserRoleVO();
//先从redis里拿 还得从数据库先查公司。。还是直接查人快
@@ -305,6 +309,7 @@ public class MemberServiceImpl extends ServiceImpl imple
//oprMemDictDO.setCompanyId(companyDictDO.getId());
//oprMemDictDO.setCompanyName(companyDictDO.getCompanyName());
//mongoTemplate.insert(oprMemDictDO);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
//redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + memberDO.getUserName() + ":" + companyDictDO.getCompanyName() + ":" + LocalDateTime.now(), oprMemDictDO);
throw new HttpException(10013);
@@ -330,12 +335,7 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
- //oprMemDictDO.setUserName(memberDO.getUserName());
- //oprMemDictDO.setCreateDate(System.currentTimeMillis() + "");
- //oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
- //oprMemDictDO.setCompanyId(companyDictDO.getId());
- //oprMemDictDO.setCompanyName(companyDictDO.getCompanyName());
- //mongoTemplate.insert(oprMemDictDO);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(70010);
}
@@ -343,12 +343,8 @@ public class MemberServiceImpl extends ServiceImpl imple
OprMemDictDO oprMemDictDO = new OprMemDictDO();
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
- //oprMemDictDO.setUserName(memberDO.getUserName());
oprMemDictDO.setResult(1);
- //oprMemDictDO.setCreateDate(System.currentTimeMillis() + "");
- //oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
- //oprMemDictDO.setCompanyId(companyDictDO.getId());
- //oprMemDictDO.setCompanyName(companyDictDO.getCompanyName());
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
//mongoTemplate.insert(oprMemDictDO);
userRoleVO.setCompanyId(companyDictDO.getId());
@@ -368,7 +364,7 @@ public class MemberServiceImpl extends ServiceImpl imple
return userRoleVO;
}
- public MemberVO passwordLogin(PasswordLoginDTO passwordLoginDTO) {
+ public MemberVO passwordLogin(PasswordLoginDTO passwordLoginDTO, HttpServletRequest request) {
/**
* 先从redis里查
*/
@@ -394,17 +390,12 @@ public class MemberServiceImpl extends ServiceImpl imple
memberVO.setCompanyId(companyDictDO.getId());
memberVO.setCompanyName(companyDictDO.getCompanyName());
memberVO.setQxyStatus(companyDictDO.getQxyStatus());
- OprMemDictDO oprMemDictDO = new OprMemDictDO();
- oprMemDictDO.setUserId(memberDO.getId());
- oprMemDictDO.setOprType("登录");
- oprMemDictDO.setResult(1);
- //oprMemDictDO.setUserName(memberDO.getUserName());
- //oprMemDictDO.setCreateDate(System.currentTimeMillis() + "");
- //oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
- //oprMemDictDO.setCompanyId(companyDictDO.getId());
- //oprMemDictDO.setCompanyName(companyDictDO.getCompanyName());
- //mongoTemplate.insert(oprMemDictDO);
- oprMemDictMapper.insert(oprMemDictDO);
+// OprMemDictDO oprMemDictDO = new OprMemDictDO();
+// oprMemDictDO.setUserId(memberDO.getId());
+// oprMemDictDO.setOprType("登录");
+// oprMemDictDO.setResult(1);
+// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
+// oprMemDictMapper.insert(oprMemDictDO);
memberVO.setCompanyId(companyDictDO.getId());
memberVO.setSuperviseName(companyDictDO.getSuperviseName());
memberVO.setCompanyName(companyDictDO.getCompanyName());
@@ -413,11 +404,8 @@ public class MemberServiceImpl extends ServiceImpl imple
.lambda()
.eq(RotationImgDictDO::getCompanyId, companyDictDO.getId()));
memberVO.setRotationImgDictDOS(rotationImgDictDOS);
- //redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + passwordLoginDTO.getCompanyId() + ":" + passwordLoginDTO.getAccountName(), memberDO);
- //redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + System.currentTimeMillis(), 1);
String token = JwtUtil.generateToken(memberDO.getId(), ConstantUtils.MOBILE_TERMINATE);
- //redisUtil.set(ConstantUtils.MOBILE_TERMINATE + "_" + memberDO.getId(), token);
Localstorage.setUser(memberDO);
memberVO.setToken(token);
return memberVO;
@@ -433,6 +421,7 @@ public class MemberServiceImpl extends ServiceImpl imple
//oprMemDictDO.setCompanyName(companyDictDO.getCompanyName());
//oprMemDictDO.setCompanyId(companyDictDO.getId());
//mongoTemplate.insert(oprMemDictDO);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
//redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + System.currentTimeMillis(), oprMemDictDO);
throw new HttpException(10016);
@@ -449,6 +438,7 @@ public class MemberServiceImpl extends ServiceImpl imple
//oprMemDictDO.setCompanyName(companyDictDO.getCompanyName());
//oprMemDictDO.setCompanyId(companyDictDO.getId());
//mongoTemplate.insert(oprMemDictDO);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
//redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + System.currentTimeMillis(), 0);
throw new HttpException(10015);
@@ -468,7 +458,7 @@ public class MemberServiceImpl extends ServiceImpl imple
System.out.println(uuid);
}
- public UserRoleVO qingxuetangLogin(QingxuetangLoginDTO qingxuetangLoginDTO) {
+ public UserRoleVO qingxuetangLogin(QingxuetangLoginDTO qingxuetangLoginDTO, HttpServletRequest request) {
UserRoleVO userRoleVO = new UserRoleVO();
@@ -493,6 +483,7 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(14002);
}
@@ -523,6 +514,7 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(14001);
}
@@ -534,6 +526,7 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(10013);
}
@@ -554,6 +547,7 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(1);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
userRoleVO.setCompanyId(companyDictDO.getId());
userRoleVO.setSuperviseName(companyDictDO.getSuperviseName());
@@ -570,7 +564,7 @@ public class MemberServiceImpl extends ServiceImpl imple
return userRoleVO;
}
- public UserRoleVO kunchiLogin(QingxuetangLoginDTO qingxuetangLoginDTO) {
+ public UserRoleVO kunchiLogin(QingxuetangLoginDTO qingxuetangLoginDTO, HttpServletRequest request) {
UserRoleVO userRoleVO = new UserRoleVO();
@@ -592,6 +586,7 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(14002);
}
@@ -610,6 +605,7 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(14001);
}
@@ -621,6 +617,7 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(0);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
throw new HttpException(10013);
}
@@ -641,6 +638,7 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setOprType("登录");
oprMemDictDO.setResult(1);
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
userRoleVO.setCompanyId(companyDictDO.getId());
userRoleVO.setSuperviseName(companyDictDO.getSuperviseName());
@@ -700,18 +698,17 @@ 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()
+ int count = activityDetectionMapper.selectCount(new QueryWrapper()
.lambda()
- .eq(ImageCheckRecordDO::getMemberId, myCoursesDTO.getMemberId())
- .eq(ImageCheckRecordDO::getClassId, myCoursesVO.getClassId())
- .isNull(ImageCheckRecordDO::getPaperId)
- .eq(ImageCheckRecordDO::getCheckPlace, 0)
- .eq(ImageCheckRecordDO::getResult, 1));
+ .eq(ActivityDetectionDO::getClassId, myCoursesVO.getClassId())
+ .eq(ActivityDetectionDO::getMemberId, myCoursesDTO.getMemberId())
+ .eq(ActivityDetectionDO::getCheckType, 1)
+ .eq(ActivityDetectionDO::getStatus, 1));
int checkCnt = imageCheckRecordMapper.checkDailyCount(myCoursesDTO.getMemberId(), myCoursesVO.getClassId(), 1, null);
myCoursesVO.setCheckCnt(checkCnt);
- if (count > 0) {
+ if (count > 1) {
myCoursesVO.setResult(1);
} else {
myCoursesVO.setResult(0);
@@ -1043,7 +1040,7 @@ public class MemberServiceImpl extends ServiceImpl imple
}
@Transactional(rollbackFor = Exception.class)
- public UserRoleVO register(RegisterDTO registerDTO) {
+ public UserRoleVO register(RegisterDTO registerDTO, HttpServletRequest request) {
UserRoleVO userRoleVO = new UserRoleVO();
@@ -1067,7 +1064,7 @@ public class MemberServiceImpl extends ServiceImpl imple
//赋值
MemberDO memberDO = new MemberDO();
- BeanUtils.copyProperties(registerDTO,memberDO);
+ BeanUtils.copyProperties(registerDTO, memberDO);
memberDO.setFirstLogin(1);
memberDO.setStatus("启用");
HanyuPinyinOutputFormat format = new HanyuPinyinOutputFormat();
@@ -1079,7 +1076,7 @@ public class MemberServiceImpl extends ServiceImpl imple
String accountName = PinyinHelper.toHanYuPinyinString(registerDTO.getUserName(), format, "", true);
memberDO.setAccountName(accountName);
memberDO.setPassword("123456");
- }catch (Exception e){
+ } catch (Exception e) {
e.printStackTrace();
}
this.baseMapper.insert(memberDO);
@@ -1090,14 +1087,11 @@ public class MemberServiceImpl extends ServiceImpl imple
oprMemDictDO.setOprType("登录");
//oprMemDictDO.setUserName(memberDO.getUserName());
oprMemDictDO.setResult(1);
- //oprMemDictDO.setCreateDate(System.currentTimeMillis() + "");
- //oprMemDictDO.setLoginDateFormat(DateFormatUtil.format(new Date(), "yyyyMMdd"));
- //oprMemDictDO.setCompanyId(companyDictDO.getId());
- //oprMemDictDO.setCompanyName(companyDictDO.getCompanyName());
+ oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request));
oprMemDictMapper.insert(oprMemDictDO);
CompanyDictDO companyDictDO = companyDictMapper.selectById(registerDTO.getCompanyId());
- BeanUtils.copyProperties(memberDO,userRoleVO);
+ BeanUtils.copyProperties(memberDO, userRoleVO);
userRoleVO.setCompanyId(companyDictDO.getId());
userRoleVO.setSuperviseName(companyDictDO.getSuperviseName());
userRoleVO.setCompanyName(companyDictDO.getCompanyName());
@@ -1115,18 +1109,18 @@ public class MemberServiceImpl extends ServiceImpl imple
return userRoleVO;
}
- public List memberLives(MemberDO memberDO){
+ public List memberLives(MemberDO memberDO) {
List memberLivesVOS = this.baseMapper.memberLives(memberDO.getId());
//工具类生成某个学生的直播地址
- for (MemberLivesVO mlv : memberLivesVOS){
- mlv.setLiveUrl(PolyvUtils.liveSign(memberDO.getId().toString(),mlv.getChannel()));
+ for (MemberLivesVO mlv : memberLivesVOS) {
+ mlv.setLiveUrl(PolyvUtils.liveSign(memberDO.getId().toString(), mlv.getChannel()));
}
return memberLivesVOS;
}
- public PolyvInfoVO polyvInfo(String userid,String channelId,String ts,String token){
+ public PolyvInfoVO polyvInfo(String userid, String channelId, String ts, String token) {
PolyvInfoVO polyvInfoVO = new PolyvInfoVO();
MemberDO memberDO = this.baseMapper.selectById(userid);
diff --git a/src/main/java/com/subsidy/util/Base64Util.java b/src/main/java/com/subsidy/util/Base64Util.java
new file mode 100644
index 0000000..b473446
--- /dev/null
+++ b/src/main/java/com/subsidy/util/Base64Util.java
@@ -0,0 +1,83 @@
+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
diff --git a/src/main/java/com/subsidy/util/ConstantUtils.java b/src/main/java/com/subsidy/util/ConstantUtils.java
index 6feaccb..0e3c58e 100644
--- a/src/main/java/com/subsidy/util/ConstantUtils.java
+++ b/src/main/java/com/subsidy/util/ConstantUtils.java
@@ -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";
+
}
diff --git a/src/main/java/com/subsidy/util/OSSUtils.java b/src/main/java/com/subsidy/util/OSSUtils.java
new file mode 100644
index 0000000..4cf7668
--- /dev/null
+++ b/src/main/java/com/subsidy/util/OSSUtils.java
@@ -0,0 +1,120 @@
+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"));
+ }
+}
diff --git a/src/main/java/com/subsidy/util/TestMain.java b/src/main/java/com/subsidy/util/TestMain.java
index 83c4e2b..50f955c 100644
--- a/src/main/java/com/subsidy/util/TestMain.java
+++ b/src/main/java/com/subsidy/util/TestMain.java
@@ -1,31 +1,77 @@
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 {
- 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();
}
diff --git a/src/main/java/com/subsidy/util/websocket/ReConnectWebSocketClient.java b/src/main/java/com/subsidy/util/websocket/ReConnectWebSocketClient.java
new file mode 100644
index 0000000..edf8b03
--- /dev/null
+++ b/src/main/java/com/subsidy/util/websocket/ReConnectWebSocketClient.java
@@ -0,0 +1,272 @@
+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 msgStr;
+ /** 字节流消息回调 */
+ private Consumer msgByte;
+ /** 异常回调 */
+ private Consumer 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 endConsumer;
+
+ public ReConnectWebSocketClient(
+ URI serverUri,
+ String key,
+ Consumer msgStr,
+ Consumer msgByte,
+ Consumer 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
diff --git a/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java b/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java
index 2f51640..93af665 100644
--- a/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java
+++ b/src/main/java/com/subsidy/util/websocket/WebSocketUtil.java
@@ -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
@@ -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 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 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;
}
diff --git a/src/main/java/com/subsidy/vo/administer/OperatorsVO.java b/src/main/java/com/subsidy/vo/administer/OperatorsVO.java
index e2fda11..e866734 100644
--- a/src/main/java/com/subsidy/vo/administer/OperatorsVO.java
+++ b/src/main/java/com/subsidy/vo/administer/OperatorsVO.java
@@ -33,4 +33,6 @@ public class OperatorsVO {
private String logo;
private String superviseName;
+
+ private String companyCode;
}
diff --git a/src/main/java/com/subsidy/vo/classdict/GetAllClassesVO.java b/src/main/java/com/subsidy/vo/classdict/GetAllClassesVO.java
index ed22a59..ee40953 100644
--- a/src/main/java/com/subsidy/vo/classdict/GetAllClassesVO.java
+++ b/src/main/java/com/subsidy/vo/classdict/GetAllClassesVO.java
@@ -11,6 +11,8 @@ public class GetAllClassesVO {
private String className;
+ private String classCode;
+
private String courseName;
private String startDate;
diff --git a/src/main/java/com/subsidy/vo/classdict/GetClassBaseInfoVO.java b/src/main/java/com/subsidy/vo/classdict/GetClassBaseInfoVO.java
index b325aa5..2fa496a 100644
--- a/src/main/java/com/subsidy/vo/classdict/GetClassBaseInfoVO.java
+++ b/src/main/java/com/subsidy/vo/classdict/GetClassBaseInfoVO.java
@@ -9,6 +9,8 @@ public class GetClassBaseInfoVO {
private String courseName;
+ private String classCode;
+
private Integer count;
private String className;
diff --git a/src/main/java/com/subsidy/vo/token/ResultVO.java b/src/main/java/com/subsidy/vo/token/ResultVO.java
index 22bfade..d382b4a 100644
--- a/src/main/java/com/subsidy/vo/token/ResultVO.java
+++ b/src/main/java/com/subsidy/vo/token/ResultVO.java
@@ -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 photoList;
}
diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties
index cbbe544..c07a6e3 100644
--- a/src/main/resources/application-dev.properties
+++ b/src/main/resources/application-dev.properties
@@ -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
diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties
index 602d9bb..1e00c44 100644
--- a/src/main/resources/application-prod.properties
+++ b/src/main/resources/application-prod.properties
@@ -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
diff --git a/src/main/resources/mapper/ClassDictMapper.xml b/src/main/resources/mapper/ClassDictMapper.xml
index b0b4eec..b18c881 100644
--- a/src/main/resources/mapper/ClassDictMapper.xml
+++ b/src/main/resources/mapper/ClassDictMapper.xml
@@ -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
diff --git a/src/main/resources/mapper/CompanyDictMapper.xml b/src/main/resources/mapper/CompanyDictMapper.xml
index 49308d1..6844115 100644
--- a/src/main/resources/mapper/CompanyDictMapper.xml
+++ b/src/main/resources/mapper/CompanyDictMapper.xml
@@ -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