diff --git a/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java b/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java index f07d107..d69dbc5 100644 --- a/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java +++ b/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java @@ -11,9 +11,11 @@ import com.subsidy.common.exception.HttpException; import com.subsidy.mapper.AdministerMapper; import com.subsidy.mapper.MemberMapper; import com.subsidy.mapper.MemberTokensMapper; +import com.subsidy.mapper.OprMemDictMapper; import com.subsidy.model.AdministerDO; import com.subsidy.model.MemberDO; import com.subsidy.model.MemberTokensDO; +import com.subsidy.model.OprMemDictDO; import com.subsidy.util.ConstantUtils; import com.subsidy.util.JwtUtil; import com.subsidy.util.Localstorage; @@ -55,6 +57,9 @@ public class AuthenticationInterceptor implements HandlerInterceptor { @Autowired private MemberTokensMapper memberTokensMapper; + @Autowired + private OprMemDictMapper oprMemDictMapper; + @Override @CrossOrigin() public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { @@ -67,13 +72,6 @@ public class AuthenticationInterceptor implements HandlerInterceptor { Method method = handlerMethod.getMethod(); TimeRequired timeRequired = method.getAnnotation(TimeRequired.class); - if (timeRequired !=null){ - Calendar calendar = Calendar.getInstance(); - int hour = calendar.get(Calendar.HOUR_OF_DAY); - if (hour<6){ - throw new HttpException(17001); - } - } LoginRequired methodAnnotation = method.getAnnotation(LoginRequired.class); if (methodAnnotation != null) { @@ -100,6 +98,19 @@ public class AuthenticationInterceptor implements HandlerInterceptor { } } else if(ConstantUtils.MOBILE_TERMINATE.equals(type)) { MemberDO memberDO = memberMapper.selectById(claimMap.get("id").asLong()); + if (timeRequired !=null){ + Calendar calendar = Calendar.getInstance(); + int hour = calendar.get(Calendar.HOUR_OF_DAY); + if (hour<6){ + OprMemDictDO oprMemDictDO = new OprMemDictDO(); + oprMemDictDO.setUserId(memberDO.getId()); + oprMemDictDO.setOprType("登出"); + oprMemDictDO.setResult(1); + oprMemDictMapper.insert(oprMemDictDO); + throw new HttpException(17001); + } + } + if(memberDO != null) { Localstorage.setUser(memberDO); return true; diff --git a/src/main/java/com/subsidy/jobs/RenSheJuJob.java b/src/main/java/com/subsidy/jobs/RenSheJuJob.java index f318f49..5527ba3 100644 --- a/src/main/java/com/subsidy/jobs/RenSheJuJob.java +++ b/src/main/java/com/subsidy/jobs/RenSheJuJob.java @@ -1,13 +1,19 @@ package com.subsidy.jobs; +import com.alibaba.fastjson.JSONObject; +import com.subsidy.common.ResponseData; import com.subsidy.service.RenSheJuService; import com.subsidy.service.RenshejuHistoryService; import com.subsidy.service.impl.RenshejuHistoryServiceImpl; +import com.subsidy.util.websocket.WebSocketUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import org.springframework.web.socket.TextMessage; +import org.springframework.web.socket.WebSocketSession; import java.io.IOException; +import java.util.concurrent.ConcurrentHashMap; /** * 人社局数据对接 @@ -83,5 +89,12 @@ public class RenSheJuJob { // renSheJuService.getErrorClass(); // } + @Scheduled(cron = "00 58 23 * * ?") + public void cancelLogin()throws IOException{ + ConcurrentHashMap webSocketMap = WebSocketUtil.webSocketMap; + for (Long key : webSocketMap.keySet()){ + webSocketMap.get(key).sendMessage(new TextMessage(JSONObject.toJSONString(ResponseData.generateCreatedResponse(17001)))); + } + } } diff --git a/src/main/java/com/subsidy/mapper/RenSheJuMapper.java b/src/main/java/com/subsidy/mapper/RenSheJuMapper.java index b375587..ba995b4 100644 --- a/src/main/java/com/subsidy/mapper/RenSheJuMapper.java +++ b/src/main/java/com/subsidy/mapper/RenSheJuMapper.java @@ -98,7 +98,7 @@ public interface RenSheJuMapper { List checkClassIds(); /** - * 查看某个班级的成员做过的人脸识别记录 + * 查看某个班级的成员做过的人脸识别记录 弃用 */ List classImageChecks(Long classId); @@ -107,5 +107,9 @@ public interface RenSheJuMapper { */ List passExamCheck(Long classId); + /** + * 进入到课程第二次做人脸识别 + */ + List studyCheck(Long classId); } diff --git a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java index 59fb9ff..6873eee 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -1157,6 +1157,7 @@ public class MemberServiceImpl extends ServiceImpl imple return polyvInfoVO; } + @Transactional(rollbackFor = Exception.class) public String logout(MemberDO memberDO) { memberTokensMapper.delete(new QueryWrapper() .lambda() diff --git a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java index 25dd12e..173b700 100644 --- a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java @@ -1,15 +1,14 @@ package com.subsidy.service.impl; import com.alibaba.fastjson.JSON; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.subsidy.common.configure.RenSheConfig; import com.subsidy.dto.renshe.*; import com.subsidy.mapper.ClassDictMapper; +import com.subsidy.mapper.ImageCheckRecordMapper; import com.subsidy.mapper.RenSheJuMapper; import com.subsidy.mapper.RenshejuHistoryMapper; -import com.subsidy.model.ClassDictDO; -import com.subsidy.model.ExerciseDoneResultDO; -import com.subsidy.model.OprMemDictDO; -import com.subsidy.model.RenshejuHistoryDO; +import com.subsidy.model.*; import com.subsidy.service.RenSheJuService; import com.subsidy.util.OSSUtils; import com.subsidy.util.RenSheJuConstant; @@ -43,6 +42,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { RenshejuHistoryMapper renshejuHistoryMapper; public RensheResponseVO classBaseInfo() throws IOException { + OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -55,50 +55,72 @@ public class RenSheJuServiceImpl implements RenSheJuService { //查找前一天产生数据的班级 List classIds = renSheJuMapper.newClasses(); - for (Long classId : classIds) { - EpidemicSituationClassBasic epidemicSituationClassBasic = new EpidemicSituationClassBasic(); - //班级基本信息 - ClassBaseInfoVO classBaseInfoVO = renSheJuMapper.classBaseInfo(classId); - BeanUtils.copyProperties(classBaseInfoVO, epidemicSituationClassBasic); - epidemicSituationClassBasic.setDownCode(classBaseInfoVO.getDownCode()); - - //章节 - List chapterLists = renSheJuMapper.classChapters(classId); - ChapterList2 chapterList2 = chapterLists.get(chapterLists.size() - 1); - chapterList2.setIsExam(1); - epidemicSituationClassBasic.setChapterList(chapterLists); - - //学员列表 - List memberVOS = renSheJuMapper.classMembers(classId); - epidemicSituationClassBasic.setStudentList(memberVOS); - - epidemicSituationClassBasics.add(epidemicSituationClassBasic); + try { + if (classIds.size() > 0) { + for (Long classId : classIds) { + EpidemicSituationClassBasic epidemicSituationClassBasic = new EpidemicSituationClassBasic(); + //班级基本信息 + ClassBaseInfoVO classBaseInfoVO = renSheJuMapper.classBaseInfo(classId); + BeanUtils.copyProperties(classBaseInfoVO, epidemicSituationClassBasic); + epidemicSituationClassBasic.setDownCode(classBaseInfoVO.getDownCode()); + + //章节 + List chapterLists = renSheJuMapper.classChapters(classId); + ChapterList2 chapterList2 = chapterLists.get(chapterLists.size() - 1); + chapterList2.setIsExam(1); + epidemicSituationClassBasic.setChapterList(chapterLists); + + //学员列表 + List memberVOS = renSheJuMapper.classMembers(classId); + epidemicSituationClassBasic.setStudentList(memberVOS); + + epidemicSituationClassBasics.add(epidemicSituationClassBasic); + } + classBaseInfoDTO.setEpidemicSituationClassBasic(epidemicSituationClassBasics); + + System.out.println(JSONObject.fromObject(classBaseInfoDTO).toString()); + + RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(classBaseInfoDTO).toString()); + Request request = new Request.Builder() + .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClass") + .method("POST", body) + .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_2); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classBaseInfoDTO).toString()); + if (200 == response.code()) { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + } else { + renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + return rensheResponseVO; + } else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_2); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classBaseInfoDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + return null; + } + + } catch (Exception e) { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_2); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classBaseInfoDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); + renshejuHistoryMapper.insert(renshejuHistoryDO); } - classBaseInfoDTO.setEpidemicSituationClassBasic(epidemicSituationClassBasics); - - System.out.println(JSONObject.fromObject(classBaseInfoDTO).toString()); - - RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(classBaseInfoDTO).toString()); -// Request request = new Request.Builder() -// .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClass") -// .method("POST", body) -// .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") -// .addHeader("Content-Type", "application/json") -// .build(); -// Response response = client.newCall(request).execute(); -// RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); -// RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); -// renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_2); -// renshejuHistoryDO.setInputParam(JSONObject.fromObject(classBaseInfoDTO).toString()); -// renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); -// renshejuHistoryMapper.insert(renshejuHistoryDO); -// System.out.println(rensheResponseVO); -// return rensheResponseVO; return null; - } public RensheResponseVO classHourBehavior() throws IOException { + OkHttpClient client = new OkHttpClient().newBuilder() .build(); MediaType mediaType = MediaType.parse("application/json"); @@ -108,78 +130,95 @@ public class RenSheJuServiceImpl implements RenSheJuService { classHourBehaviorDTO.setPrivateKey(getSecret()); List classHourBasics = new ArrayList<>(); - - //前一天新增视频学习数据的班级 - List dailyStudyInfoVOS = renSheJuMapper.dailyStudyInfo(); - for (DailyStudyInfoVO dailyStudyInfoVO : dailyStudyInfoVOS) { - ClassHourBasic classHourBasic = new ClassHourBasic(); - BeanUtils.copyProperties(dailyStudyInfoVO, classHourBasic); - classHourBasic.setDownCode(dailyStudyInfoVO.getDownCode()); - - //上线时间列表 - //找到当天每次上线下线时间 - //上线时间 - List loginRecords = renSheJuMapper.loginRecords(dailyStudyInfoVO.getMemberId()); - //下线时间 - List loginOutRecords = renSheJuMapper.loginOutRecords(dailyStudyInfoVO.getMemberId()); - - List loginLists = new ArrayList<>(); - for (int i = 0; i < loginRecords.size(); i++) { - LoginList loginList = new LoginList(); - loginList.setIp(loginRecords.get(i).getIpAddress()); - loginList.setStartTime(Timestamp.valueOf(loginRecords.get(i).getCreateDate()).getTime()); - loginList.setEndTime(Timestamp.valueOf(loginOutRecords.get(i).getCreateDate()).getTime()); - - //查看这个人该时间段的学习记录 - List chapterList3s = renSheJuMapper.dailyStudyRecords(dailyStudyInfoVO.getMemberId(), dailyStudyInfoVO.getDownCode(), loginRecords.get(0).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " ")); - loginList.setChapterList(chapterList3s); - loginLists.add(loginList); - } - classHourBasic.setLoginList(loginLists); - - //活跃度列表 - List activityLists = new ArrayList<>(); - List activityDetectionDOS = renSheJuMapper.dailyActivities(dailyStudyInfoVO.getDownCode(), dailyStudyInfoVO.getMemberId()); - for (DailyActivitiesVO dailyActivitiesVO : activityDetectionDOS) { - - ActivityList activityList = new ActivityList(); - if (dailyActivitiesVO.getAccess() == 1) { - activityList.setAccess(0); - } else { - activityList.setAccess(1); - activityList.setErrorInfo(2); + try { + //前一天新增视频学习数据的班级 + List dailyStudyInfoVOS = renSheJuMapper.dailyStudyInfo(); + for (DailyStudyInfoVO dailyStudyInfoVO : dailyStudyInfoVOS) { + ClassHourBasic classHourBasic = new ClassHourBasic(); + BeanUtils.copyProperties(dailyStudyInfoVO, classHourBasic); + classHourBasic.setDownCode(dailyStudyInfoVO.getDownCode()); + + //上线时间列表 + //找到当天每次上线下线时间 + //上线时间 + List loginRecords = renSheJuMapper.loginRecords(dailyStudyInfoVO.getMemberId()); + //下线时间 + List loginOutRecords = renSheJuMapper.loginOutRecords(dailyStudyInfoVO.getMemberId()); + + List loginLists = new ArrayList<>(); + for (int i = 0; i < loginRecords.size(); i++) { + LoginList loginList = new LoginList(); + loginList.setIp(loginRecords.get(i).getIpAddress()); + loginList.setStartTime(Timestamp.valueOf(loginRecords.get(i).getCreateDate()).getTime()); + loginList.setEndTime(Timestamp.valueOf(loginOutRecords.get(i).getCreateDate()).getTime()); + + //查看这个人该时间段的学习记录 + List chapterList3s = renSheJuMapper.dailyStudyRecords(dailyStudyInfoVO.getMemberId(), dailyStudyInfoVO.getDownCode(), loginRecords.get(0).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " ")); + if (chapterList3s.size() > 0) { + loginList.setChapterList(chapterList3s); + loginLists.add(loginList); + } } - activityList.setActivityDetection(2); - activityList.setActivityTime(dailyActivitiesVO.getActivityTime()); - activityLists.add(activityList); + classHourBasic.setLoginList(loginLists); + + //活跃度列表 + List activityLists = new ArrayList<>(); + List activityDetectionDOS = renSheJuMapper.dailyActivities(dailyStudyInfoVO.getDownCode(), dailyStudyInfoVO.getMemberId()); + for (DailyActivitiesVO dailyActivitiesVO : activityDetectionDOS) { + + ActivityList activityList = new ActivityList(); + if (dailyActivitiesVO.getAccess() == 1) { + activityList.setAccess(0); + } else { + activityList.setAccess(1); + activityList.setErrorInfo(2); + } + if (0 == dailyActivitiesVO.getCheckType()) { + activityList.setActivityDetection(2); + } else { + activityList.setActivityDetection(1); + } + activityList.setActivityTime(dailyActivitiesVO.getActivityTime()); + activityLists.add(activityList); + } + classHourBasic.setActivityList(activityLists); + + classHourBasics.add(classHourBasic); } - classHourBasic.setActivityList(activityLists); + classHourBehaviorDTO.setClassHourBasic(classHourBasics); - classHourBasics.add(classHourBasic); - } - classHourBehaviorDTO.setClassHourBasic(classHourBasics); + System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(classHourBehaviorDTO)); - System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(classHourBehaviorDTO)); + RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(classHourBehaviorDTO).toString()); - RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(classHourBehaviorDTO).toString()); + Request request = new Request.Builder() + .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClassHourBehavior") + .method("POST", body) + .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); - Request request = new Request.Builder() - .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClassHourBehavior") - .method("POST", body) - .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") - .addHeader("Content-Type", "application/json") - .build(); - Response response = client.newCall(request).execute(); - RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); - if (null!=rensheResponseVO.getCtt()){ + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_3); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + if (200 == response.code()) { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + } else { + renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + return rensheResponseVO; + } catch (Exception e) { + e.printStackTrace(); RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_3); renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); - renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); } - System.out.println(rensheResponseVO); - return rensheResponseVO; + return null; } public RensheResponseVO uploadChapterBehavior() throws IOException { @@ -196,80 +235,102 @@ public class RenSheJuServiceImpl implements RenSheJuService { List dailyExamBasicVOS = renSheJuMapper.dailyExamBasic(); - for (DailyExamBasicVO dailyExamBasicVO : dailyExamBasicVOS) { - - //章节课程考试时间列表 - ChapterExamBasic chapterExamBasic = new ChapterExamBasic(); - BeanUtils.copyProperties(dailyExamBasicVO, chapterExamBasic); - chapterExamBasic.setDownCode(dailyExamBasicVO.getDownCode()); - - //最后一节课作为chapterCode - String vodId = renSheJuMapper.classVodName(dailyExamBasicVO.getDownCode()); - chapterExamBasic.setChapterCode(vodId); - - //考试活跃度列表 - List activityLists = new ArrayList<>(); - List activityDetectionDOS = renSheJuMapper.examActivities(dailyExamBasicVO.getDownCode(), dailyExamBasicVO.getMemberId()); - for (ExamActivitiesVO dailyActivitiesVO : activityDetectionDOS) { + try { + if (dailyExamBasicVOS.size() > 0) { + for (DailyExamBasicVO dailyExamBasicVO : dailyExamBasicVOS) { + + //章节课程考试时间列表 + ChapterExamBasic chapterExamBasic = new ChapterExamBasic(); + BeanUtils.copyProperties(dailyExamBasicVO, chapterExamBasic); + chapterExamBasic.setDownCode(dailyExamBasicVO.getDownCode()); + + //最后一节课作为chapterCode + String vodId = renSheJuMapper.classVodName(dailyExamBasicVO.getDownCode()); + chapterExamBasic.setChapterCode(vodId); + + //考试活跃度列表 + List activityLists = new ArrayList<>(); + List activityDetectionDOS = renSheJuMapper.examActivities(dailyExamBasicVO.getDownCode(), dailyExamBasicVO.getMemberId()); + for (ExamActivitiesVO dailyActivitiesVO : activityDetectionDOS) { + + ActivityList activityList = new ActivityList(); + if (null == dailyActivitiesVO.getAccess() || 0 == dailyActivitiesVO.getAccess()) { + activityList.setAccess(1); + activityList.setErrorInfo(1); + } else { + activityList.setAccess(0); + } + activityList.setActivityDetection(1); + activityList.setActivityTime(dailyActivitiesVO.getActivityTime()); + activityLists.add(activityList); + } + chapterExamBasic.setActivityList(activityLists); + + //考试时间列表 + //上线时间 + List loginRecords = renSheJuMapper.loginRecords(dailyExamBasicVO.getMemberId()); + //下线时间 + List loginOutRecords = renSheJuMapper.loginOutRecords(dailyExamBasicVO.getMemberId()); + + List examLists = new ArrayList(); + + for (int i = 0; i < loginRecords.size(); i++) { + //找到该时间段内的测评 + List exerciseDoneResultDOS = renSheJuMapper.dailyExerciseDone(dailyExamBasicVO.getMemberId(), loginRecords.get(i).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " ")); + for (ExerciseDoneResultDO exerciseDoneResultDO : exerciseDoneResultDOS) { + ExamList examList = new ExamList(); + examList.setStartTime(Timestamp.valueOf(exerciseDoneResultDO.getStartDate()).getTime()); + examList.setEndTime(Timestamp.valueOf(exerciseDoneResultDO.getCreateDate()).getTime()); + examList.setIp(loginRecords.get(i).getIpAddress()); + examLists.add(examList); + } + } + chapterExamBasic.setExamList(examLists); + chapterExamBasics.add(chapterExamBasic); + } - ActivityList activityList = new ActivityList(); - if (null == dailyActivitiesVO.getAccess() || 0 == dailyActivitiesVO.getAccess()) { - activityList.setAccess(1); - activityList.setErrorInfo(1); + uploadChapterBehaviorDTO.setChapterExamBasic(chapterExamBasics); + + System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(uploadChapterBehaviorDTO)); + + RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(uploadChapterBehaviorDTO).toString()); + Request request = new Request.Builder() + .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadChapterBehavior") + .method("POST", body) + .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); + System.out.println(rensheResponseVO); +// if (200==response.code()) { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadChapterBehaviorDTO).toString()); + if (200 == response.code()) { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); } else { - activityList.setAccess(0); - } - activityList.setActivityDetection(1); - activityList.setActivityTime(dailyActivitiesVO.getActivityTime()); - activityLists.add(activityList); - } - chapterExamBasic.setActivityList(activityLists); - - //考试时间列表 - //上线时间 - List loginRecords = renSheJuMapper.loginRecords(dailyExamBasicVO.getMemberId()); - //下线时间 - List loginOutRecords = renSheJuMapper.loginOutRecords(dailyExamBasicVO.getMemberId()); - - List examLists = new ArrayList(); - - for (int i = 0; i < loginRecords.size(); i++) { - //找到该时间段内的测评 - List exerciseDoneResultDOS = renSheJuMapper.dailyExerciseDone(dailyExamBasicVO.getMemberId(), loginRecords.get(i).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " ")); - for (ExerciseDoneResultDO exerciseDoneResultDO : exerciseDoneResultDOS) { - ExamList examList = new ExamList(); - examList.setStartTime(Timestamp.valueOf(exerciseDoneResultDO.getStartDate()).getTime()); - examList.setEndTime(Timestamp.valueOf(exerciseDoneResultDO.getCreateDate()).getTime()); - examList.setIp(loginRecords.get(i).getIpAddress()); - examLists.add(examList); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); } + renshejuHistoryMapper.insert(renshejuHistoryDO); +// } + return rensheResponseVO; + } else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadChapterBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + return null; } - chapterExamBasic.setExamList(examLists); - chapterExamBasics.add(chapterExamBasic); - } - - uploadChapterBehaviorDTO.setChapterExamBasic(chapterExamBasics); - - System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(uploadChapterBehaviorDTO)); - - RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(uploadChapterBehaviorDTO).toString()); - Request request = new Request.Builder() - .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadChapterBehavior") - .method("POST", body) - .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") - .addHeader("Content-Type", "application/json") - .build(); - Response response = client.newCall(request).execute(); - RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); - System.out.println(rensheResponseVO); - if (null!=rensheResponseVO.getCtt()){ + } catch (Exception e) { RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadChapterBehaviorDTO).toString()); - renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); } - return rensheResponseVO; + return null; } public RensheResponseVO uploadClassAnswerQuestionBehavior() throws IOException { @@ -285,59 +346,79 @@ public class RenSheJuServiceImpl implements RenSheJuService { List dailyAnswerVOS = renSheJuMapper.dailyAnswer(); - HashMap> hashMap = new HashMap<>(); - for (DailyAnswerVO dailyAnswerVO : dailyAnswerVOS) { + try { + if (dailyAnswerVOS.size() > 0) { + HashMap> hashMap = new HashMap<>(); + for (DailyAnswerVO dailyAnswerVO : dailyAnswerVOS) { + + if (!hashMap.containsKey(dailyAnswerVO.getDownCode() + ":" + dailyAnswerVO.getIdentity())) { + List answerAndQuestionLists = new ArrayList<>(); + AnswerAndQuestionList answerAndQuestionList = new AnswerAndQuestionList(); + answerAndQuestionList.setAnswer(dailyAnswerVO.getAnswer()); + answerAndQuestionList.setQuestion(dailyAnswerVO.getQuestion()); + answerAndQuestionLists.add(answerAndQuestionList); + hashMap.put(dailyAnswerVO.getDownCode() + ":" + dailyAnswerVO.getIdentity(), answerAndQuestionLists); + } else { + List answerAndQuestionLists = hashMap.get(dailyAnswerVO.getDownCode() + ":" + dailyAnswerVO.getIdentity()); + AnswerAndQuestionList answerAndQuestionList = new AnswerAndQuestionList(); + answerAndQuestionList.setAnswer(dailyAnswerVO.getAnswer()); + answerAndQuestionList.setQuestion(dailyAnswerVO.getQuestion()); + answerAndQuestionLists.add(answerAndQuestionList); + hashMap.put(dailyAnswerVO.getDownCode() + ":" + dailyAnswerVO.getIdentity(), answerAndQuestionLists); + } + } - if (!hashMap.containsKey(dailyAnswerVO.getDownCode() + ":" + dailyAnswerVO.getIdentity())) { - List answerAndQuestionLists = new ArrayList<>(); - AnswerAndQuestionList answerAndQuestionList = new AnswerAndQuestionList(); - answerAndQuestionList.setAnswer(dailyAnswerVO.getAnswer()); - answerAndQuestionList.setQuestion(dailyAnswerVO.getQuestion()); - answerAndQuestionLists.add(answerAndQuestionList); - hashMap.put(dailyAnswerVO.getDownCode() + ":" + dailyAnswerVO.getIdentity(), answerAndQuestionLists); - } else { - List answerAndQuestionLists = hashMap.get(dailyAnswerVO.getDownCode() + ":" + dailyAnswerVO.getIdentity()); - AnswerAndQuestionList answerAndQuestionList = new AnswerAndQuestionList(); - answerAndQuestionList.setAnswer(dailyAnswerVO.getAnswer()); - answerAndQuestionList.setQuestion(dailyAnswerVO.getQuestion()); - answerAndQuestionLists.add(answerAndQuestionList); - hashMap.put(dailyAnswerVO.getDownCode() + ":" + dailyAnswerVO.getIdentity(), answerAndQuestionLists); - } - } + List answerBasics = new ArrayList<>(); - List answerBasics = new ArrayList<>(); + for (String key : hashMap.keySet()) { + AnswerBasic answerBasic = new AnswerBasic(); + String downCode = key.split(":")[0]; + String identity = key.split(":")[1]; + answerBasic.setDownCode(downCode); + answerBasic.setIdentity(identity); + answerBasic.setAnswerAndQuestionList(hashMap.get(key)); + answerBasics.add(answerBasic); + } - for (String key : hashMap.keySet()) { - AnswerBasic answerBasic = new AnswerBasic(); - String downCode = key.split(":")[0]; - String identity = key.split(":")[1]; - answerBasic.setDownCode(downCode); - answerBasic.setIdentity(identity); - answerBasic.setAnswerAndQuestionList(hashMap.get(key)); - answerBasics.add(answerBasic); - } + uploadClassAnswerQuestionBehaviorDTO.setAnswerBasic(answerBasics); + System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(uploadClassAnswerQuestionBehaviorDTO)); + RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(uploadClassAnswerQuestionBehaviorDTO).toString()); + Request request = new Request.Builder() + .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClassAnswerQuestionBehavior") + .method("POST", body) + .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); + System.out.println(rensheResponseVO); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_5); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassAnswerQuestionBehaviorDTO).toString()); + if (200 == response.code()) { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + } else { + renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); - uploadClassAnswerQuestionBehaviorDTO.setAnswerBasic(answerBasics); - System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(uploadClassAnswerQuestionBehaviorDTO)); - RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(uploadClassAnswerQuestionBehaviorDTO).toString()); - Request request = new Request.Builder() - .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClassAnswerQuestionBehavior") - .method("POST", body) - .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") - .addHeader("Content-Type", "application/json") - .build(); - Response response = client.newCall(request).execute(); - RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); - System.out.println(rensheResponseVO); - if (null!=rensheResponseVO.getCtt()){ + return rensheResponseVO; + } else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_5); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassAnswerQuestionBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + return null; + } + } catch (Exception e) { RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_5); renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassAnswerQuestionBehaviorDTO).toString()); - renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); } - - return rensheResponseVO; + return null; } public List uploadImage() throws IOException { @@ -357,52 +438,59 @@ public class RenSheJuServiceImpl implements RenSheJuService { uploadImage.setPrivateKey(getSecret()); uploadImage.setDownCode(String.valueOf(classId)); // //查找班级下所有人做过的实名认证记录 - List classImageChecksVOS = renSheJuMapper.classImageChecks(classId); +// List classImageChecksVOS = renSheJuMapper.classImageChecks(classId); List imageDetailLists = new ArrayList(); - // - for (ClassImageChecksVO classImageChecksVO : classImageChecksVOS) { - ImageDetailList imageDetailList = new ImageDetailList(); - BeanUtils.copyProperties(classImageChecksVO, imageDetailList); - imageDetailList.setImageBase64(OSSUtils.image2Base64(classImageChecksVO.getImage())); - imageDetailList.setProcessType(0L); - imageDetailList.setDetectionType(0L); - imageDetailLists.add(imageDetailList); - } - - //查找前一天做过考试验证的记录 - List classImageChecksVOS1 = renSheJuMapper.passExamCheck(classId); - - for (ClassImageChecksVO cic : classImageChecksVOS1) { - ImageDetailList imageDetailList = new ImageDetailList(); - BeanUtils.copyProperties(cic, imageDetailList); - imageDetailList.setImageBase64(OSSUtils.image2Base64(cic.getImage())); - imageDetailList.setProcessType(2L); - imageDetailList.setDetectionType(1L); - imageDetailLists.add(imageDetailList); - } - - uploadImage.setImageDetailList(imageDetailLists); - System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(uploadImage)); - RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(uploadImage).toString()); - Request request = new Request.Builder() - .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadImage") - .method("POST", body) - .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") - .addHeader("Content-Type", "application/json") - .build(); - Response response = client.newCall(request).execute(); - RensheResponseVO rensheResponseVO= JSON.parseObject(response.body().string(), RensheResponseVO.class); - - if (null!=rensheResponseVO.getCtt()){ + try { + /** + * 第二次人脸识别 + */ + List classImageChecksVOS2 = renSheJuMapper.studyCheck(classId); + + if (classImageChecksVOS2.size() > 0) { + for (ClassImageChecksVO cicon : classImageChecksVOS2) { + ImageDetailList imageDetailList = new ImageDetailList(); + BeanUtils.copyProperties(cicon, imageDetailList); + imageDetailList.setImageBase64("data:image/jpeg;base64," + OSSUtils.image2Base64(cicon.getImage())); + imageDetailList.setProcessType(0L); + imageDetailList.setDetectionType(0L); + imageDetailLists.add(imageDetailList); + } + + uploadImage.setImageDetailList(imageDetailLists); + System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(uploadImage)); + RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(uploadImage).toString()); + Request request = new Request.Builder() + .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadImage") + .method("POST", body) + .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); + + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_6); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadImage).toString()); + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + renshejuHistoryMapper.insert(renshejuHistoryDO); + rensheResponseVOS.add(rensheResponseVO); + } else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_6); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadImage).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + } + } catch (Exception e) { + e.printStackTrace(); RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_6); renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadImage).toString()); - renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); } - System.out.println(rensheResponseVO); - rensheResponseVOS.add(rensheResponseVO); +// System.out.println(rensheResponseVO); } return rensheResponseVOS; @@ -421,19 +509,30 @@ public class RenSheJuServiceImpl implements RenSheJuService { .method("POST", body) .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") .build(); - Response response = client.newCall(request).execute(); - System.out.println(response); - RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); - System.out.println(rensheResponseVO); + try { + Response response = client.newCall(request).execute(); + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); - if (null!=rensheResponseVO.getCtt()){ RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_7); renshejuHistoryDO.setInputParam(getSecret()); - renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + if (200 == response.code()) { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + } else { + renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + return rensheResponseVO; + + } catch (Exception e) { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_7); + renshejuHistoryDO.setInputParam(getSecret()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); } - return rensheResponseVO; + return null; + } public RensheResponseVO uploadClassCode() throws IOException { @@ -460,26 +559,36 @@ public class RenSheJuServiceImpl implements RenSheJuService { uploadClassCodeDTO.setClassCodeBasic(classCodeBasics); System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(uploadClassCodeDTO)); + try { + RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(uploadClassCodeDTO).toString()); + Request request = new Request.Builder() + .url(renSheConfig.getUrl() + "/import/downstream/enterprise/uploadClassCode") + .method("POST", body) + .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") + .build(); + Response response = client.newCall(request).execute(); + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); + System.out.println(rensheResponseVO); - RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(uploadClassCodeDTO).toString()); - Request request = new Request.Builder() - .url(renSheConfig.getUrl()+"/import/downstream/enterprise/uploadClassCode") - .method("POST", body) - .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") - .addHeader("Content-Type", "application/json") - .build(); - Response response = client.newCall(request).execute(); - RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); - System.out.println(rensheResponseVO); - - if (null!=rensheResponseVO.getCtt()){ RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_8); renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassCodeDTO).toString()); - renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + if (200 == response.code()) { + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_SUCCESS); + } else { + renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + return rensheResponseVO; + } catch (Exception e) { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_8); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassCodeDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); } - return rensheResponseVO; + return null; } public RensheResponseVO getErrorClass() throws IOException { @@ -495,17 +604,28 @@ public class RenSheJuServiceImpl implements RenSheJuService { .method("POST", body) .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") .build(); - Response response = client.newCall(request).execute(); - RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); - System.out.println(rensheResponseVO); - if (null!=rensheResponseVO.getCtt()){ + try { + Response response = client.newCall(request).execute(); + RensheResponseVO rensheResponseVO = JSON.parseObject(response.body().string(), RensheResponseVO.class); + System.out.println(rensheResponseVO); RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_9); renshejuHistoryDO.setInputParam(getSecret()); - renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + if (200 == response.code()) { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + } else { + renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + return rensheResponseVO; + } catch (Exception e) { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_9); + renshejuHistoryDO.setInputParam(getSecret()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL); renshejuHistoryMapper.insert(renshejuHistoryDO); } - return rensheResponseVO; + return null; } public RensheStringVO clear() throws IOException { @@ -543,7 +663,6 @@ public class RenSheJuServiceImpl implements RenSheJuService { .build(); Response response = client.newCall(request).execute(); GetSecretVO getSecretVO = JSON.parseObject(response.body().string(), GetSecretVO.class); - System.out.println(getSecretVO); return getSecretVO.getCtt().getPrivateKey(); } @@ -565,7 +684,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { } - public void test(){ + public void test() { System.out.println("132222222222222222222222222222"); } diff --git a/src/main/java/com/subsidy/util/RenSheJuConstant.java b/src/main/java/com/subsidy/util/RenSheJuConstant.java index a79e493..6ad1e17 100644 --- a/src/main/java/com/subsidy/util/RenSheJuConstant.java +++ b/src/main/java/com/subsidy/util/RenSheJuConstant.java @@ -47,5 +47,23 @@ public class RenSheJuConstant { */ public static final String POST_10 = "POST_10_clear"; + /** + * 调取失败 + */ + public static final String API_ERROR = "调取失败"; + + /** + * 当天没数据 + */ + public static final String NO_DATA = "NO_DATA"; + /** + * 推送失败 + */ + public static final String PUSH_FAIL = "推送失败"; + + /** + * 推送成功 + */ + public static final String PUSH_SUCCESS = "推送成功"; } diff --git a/src/main/java/com/subsidy/util/websocket/ReConnectWebSocketClient.java b/src/main/java/com/subsidy/util/websocket/ReConnectWebSocketClient.java deleted file mode 100644 index edf8b03..0000000 --- a/src/main/java/com/subsidy/util/websocket/ReConnectWebSocketClient.java +++ /dev/null @@ -1,272 +0,0 @@ -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/vo/renshe/ClassImageChecksVO.java b/src/main/java/com/subsidy/vo/renshe/ClassImageChecksVO.java index 3a5b265..4ea9f28 100644 --- a/src/main/java/com/subsidy/vo/renshe/ClassImageChecksVO.java +++ b/src/main/java/com/subsidy/vo/renshe/ClassImageChecksVO.java @@ -5,6 +5,10 @@ import lombok.Data; @Data public class ClassImageChecksVO { + Long classId; + + Long memberId; + /** * 检测时间,【13位时间戳】【精确到毫秒】如检测类型为活跃度检测则与【学时信息采集接口】、【考试信息采集接口】activityTime时间保持一致 */ diff --git a/src/main/java/com/subsidy/vo/renshe/DailyActivitiesVO.java b/src/main/java/com/subsidy/vo/renshe/DailyActivitiesVO.java index 5bb512d..2704171 100644 --- a/src/main/java/com/subsidy/vo/renshe/DailyActivitiesVO.java +++ b/src/main/java/com/subsidy/vo/renshe/DailyActivitiesVO.java @@ -9,5 +9,6 @@ public class DailyActivitiesVO { private Long activityTime; + private Integer checkType; } diff --git a/src/main/resources/mapper/RenSheJuMapper.xml b/src/main/resources/mapper/RenSheJuMapper.xml index 7545a9c..f308393 100644 --- a/src/main/resources/mapper/RenSheJuMapper.xml +++ b/src/main/resources/mapper/RenSheJuMapper.xml @@ -168,7 +168,8 @@ + + +