Commit 70bfd420 by 涂亚平

人社局测试

1 parent c7dc8010
......@@ -51,7 +51,7 @@ public class AdministerController {
return ResponseData.generateCreatedResponse(0,administerService.login(administerDO));
}
@PostMapping("/getPermissions")
@PostMapping("/getPermissions")
@ApiOperation("权限查询")
@LoginRequired
public ResponseVO getPermissions() {
......
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;
/**
* 人社局数据对接
*/
@Component
public class RenSheJuJob {
@Autowired
private RenSheJuService renSheJuService;
/**
* POST-2:班级基本信息信息采集接口
*/
@Scheduled(cron = "0 0 1 * * ?")
public void classBaseInfo()throws IOException {
renSheJuService.classBaseInfo();
}
/**
* POST-3:学时信息采集接口
*/
@Scheduled(cron = "0 5 1 * * ?")
public void classHourBehavior() throws IOException {
renSheJuService.classHourBehavior();
}
/**
* POST-4:考试信息采集接口
*/
@Scheduled(cron = "0 10 1 * * ?")
public void uploadChapterBehavior() throws IOException {
renSheJuService.uploadChapterBehavior();
}
/**
* POST-5:答疑辅导采集接口
*/
@Scheduled(cron = "0 15 1 * * ?")
public void uploadClassAnswerQuestionBehavior() throws IOException {
renSheJuService.uploadClassAnswerQuestionBehavior();
}
/**
* POST-6 班级活跃度/实名认证照片信息采集接口
*/
@Scheduled(cron = "0 20 1 * * ?")
public void uploadImage()throws IOException {
renSheJuService.uploadImage();
}
/**
* POST-7 获取培训待绑定的(班级编号,项目编号)列表
*/
@Scheduled(cron = "0 25 1 * * ?")
public void getClassCodeByPrivateKey()throws IOException {
renSheJuService.getClassCodeByPrivateKey();
}
/**
* POST-8 上下游班级数据绑定接口
*/
@Scheduled(cron = "0 30 1 * * ?")
public void uploadClassCode()throws IOException {
renSheJuService.uploadClassCode();
}
//package com.subsidy.jobs;
//
//import com.alibaba.fastjson.JSONObject;
//import com.subsidy.common.ResponseData;
//import com.subsidy.mapper.OprMemDictMapper;
//import com.subsidy.model.OprMemDictDO;
//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.List;
//import java.util.concurrent.ConcurrentHashMap;
//
///**
// * 人社局数据对接
// */
//@Component
//public class RenSheJuJob {
//
//
// @Autowired
// private RenSheJuService renSheJuService;
//
// @Autowired
// private OprMemDictMapper oprMemDictMapper;
//
// /**
// * POST-9 获取推送失败班级列表
// * POST-2:班级基本信息信息采集接口
// */
// @Scheduled(cron = "0 35 1 * * ?")
// public void getErrorClass()throws IOException{
// renSheJuService.getErrorClass();
// @Scheduled(cron = "0 0 1 * * ?")
// public void classBaseInfo()throws IOException {
// renSheJuService.classBaseInfo();
// }
@Scheduled(cron = "00 58 23 * * ?")
public void cancelLogin()throws IOException{
ConcurrentHashMap<Long, WebSocketSession> webSocketMap = WebSocketUtil.webSocketMap;
for (Long key : webSocketMap.keySet()){
webSocketMap.get(key).sendMessage(new TextMessage(JSONObject.toJSONString(ResponseData.generateCreatedResponse(17001))));
}
}
}
//
// /**
// * POST-3:学时信息采集接口
// */
// @Scheduled(cron = "0 5 1 * * ?")
// public void classHourBehavior() throws IOException {
// renSheJuService.classHourBehavior();
// }
//
// /**
// * POST-4:考试信息采集接口
// */
// @Scheduled(cron = "0 10 1 * * ?")
// public void uploadChapterBehavior() throws IOException {
// renSheJuService.uploadChapterBehavior();
// }
//
// /**
// * POST-5:答疑辅导采集接口
// */
// @Scheduled(cron = "0 15 1 * * ?")
// public void uploadClassAnswerQuestionBehavior() throws IOException {
// renSheJuService.uploadClassAnswerQuestionBehavior();
// }
//
// /**
// * POST-6 班级活跃度/实名认证照片信息采集接口
// */
// @Scheduled(cron = "0 20 1 * * ?")
// public void uploadImage()throws IOException {
// renSheJuService.uploadImage();
// }
//
// /**
// * POST-7 获取培训待绑定的(班级编号,项目编号)列表
// */
// @Scheduled(cron = "0 25 1 * * ?")
// public void getClassCodeByPrivateKey()throws IOException {
// renSheJuService.getClassCodeByPrivateKey();
// }
//
// /**
// * POST-8 上下游班级数据绑定接口
// */
// @Scheduled(cron = "0 30 1 * * ?")
// public void uploadClassCode()throws IOException {
// renSheJuService.uploadClassCode();
// }
//
//// /**
//// * POST-9 获取推送失败班级列表
//// */
//// @Scheduled(cron = "0 35 1 * * ?")
//// public void getErrorClass()throws IOException{
//// renSheJuService.getErrorClass();
//// }
//
// @Scheduled(cron = "00 58 23 * * ?")
// public void cancelLogin(){
// ConcurrentHashMap<Long, WebSocketSession> webSocketMap = WebSocketUtil.webSocketMap;
//
// List<Long> onLineUsers = oprMemDictMapper.onlineUsers();
//
// for (Long key : onLineUsers){
// try {
// if (null != webSocketMap.get(key)){
// webSocketMap.get(key).sendMessage(new TextMessage(JSONObject.toJSONString(ResponseData.generateCreatedResponse(17001))));
// }
// OprMemDictDO oprMemDictDO = new OprMemDictDO();
// oprMemDictDO.setResult(1);
// oprMemDictDO.setOprType("登出");
// oprMemDictDO.setUserId(key);
// oprMemDictMapper.insert(oprMemDictDO);
// }catch (Exception e){
// e.printStackTrace();
// }
// }
// }
//
//}
......@@ -23,8 +23,27 @@ public interface OprMemDictMapper extends BaseMapper<OprMemDictDO> {
List<OprMemDictDO> getRecordByDate();
/**
* 当天最后一次登录记录
*/
OprMemDictDO getLatestLoginInfo(Long userId);
void deleteData(OprMemDictDO oprMemDictDO);
// /**
// * 当天最后一次登录
// */
// OprMemDictDO getLatestLogoutInfo(Long userId);
// void deleteData(OprMemDictDO oprMemDictDO);
/**
* 查看当天还在线的用户
*/
List<Long> onlineUsers();
// /**
// * 根据最后一次看视频时间随机去写几秒登出
// */
// void insertLastStudyRecord();
}
......@@ -4,10 +4,7 @@ import com.subsidy.dto.renshe.ChapterExamBasic;
import com.subsidy.dto.renshe.ChapterList2;
import com.subsidy.dto.renshe.ChapterList3;
import com.subsidy.dto.renshe.ClassHourBasic;
import com.subsidy.model.ActivityDetectionDO;
import com.subsidy.model.ClassMemberMappingDO;
import com.subsidy.model.ExerciseDoneResultDO;
import com.subsidy.model.OprMemDictDO;
import com.subsidy.model.*;
import com.subsidy.vo.renshe.*;
import org.springframework.stereotype.Repository;
......@@ -50,7 +47,9 @@ public interface RenSheJuMapper {
/**
* 考试活跃度检测--人脸
*/
List<ExamActivitiesVO> examActivities(String classId,Long memberId);
List<ExamActivitiesVO> examActivities(Long classId,Long memberId);
/**
* 某人某天累计在线时长
......@@ -75,17 +74,28 @@ public interface RenSheJuMapper {
/**
* 前一天考试通过数据
*/
List<DailyExamBasicVO> dailyExamBasic();
List<Long> dailyExamBasic();
/**
* 前一天做过考试通过数据
*/
List<MemberDO> memberIds(Long classId);
/**
* 查找课程最后一个视频
*/
String classVodName(String classId);
String classVodName(Long classId);
/**
* 查出考试时间
*/
Long examLength(Long memberId,Long classId);
/**
* 找到某人某个时间段内的测评记录
*/
List<ExerciseDoneResultDO> dailyExerciseDone(Long memberId, String startDate, String endDate);
List<ExerciseDoneResultDO> dailyExerciseDone(Long memberId, String startDate, String endDate,Long classId);
/**
* 找到某人当天答疑的记录
......@@ -108,8 +118,13 @@ public interface RenSheJuMapper {
List<ClassImageChecksVO> passExamCheck(Long classId);
/**
* 进入到课程第二次做人脸识别
* 进入到课程第二次做人脸识别 弃用
*/
List<ClassImageChecksVO> studyCheck(Long classId);
/**
* 考试数据
*/
List<ClassImageChecksVO> examCheck(Long classId);
}
......@@ -133,12 +133,17 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
signList1.add(NONCE);
String sign = sign(signList1, idCardTicketsVO.getValue());
ClassMemberMappingDO classMemberMappingDO = classMemberMappingMapper.selectOne(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getMemberId, memberDO.getId())
.eq(ClassMemberMappingDO::getClassId, classId));
//合作方后台上送身份信息
SendIdCardInfoVO sendIdCardInfoVO = null;
if (StringUtils.isEmpty(memberDO.getCheckImage())) {
if (StringUtils.isEmpty(classMemberMappingDO.getPhoto())) {
sendIdCardInfoVO = this.h5SendIdCardInfo(imageCheckRecordDO.getBizSeqNo(), memberDO, sign);
} else {
sendIdCardInfoVO = this.h5SendIdCardInfoCompare(imageCheckRecordDO.getBizSeqNo(), memberDO, sign);
sendIdCardInfoVO = this.h5SendIdCardInfoCompare(imageCheckRecordDO.getBizSeqNo(), memberDO, sign, OSSUtils.image2Base64(classMemberMappingDO.getPhoto()));
}
if (!"0".equals(sendIdCardInfoVO.getCode())) {
......@@ -205,14 +210,21 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
//合作方后台上送身份信息
// 查看之前是否有验证过,没有的话就调取权威库,有的话就进行两个图片对比
SendIdCardInfoVO sendIdCardInfoVO = null;
if (StringUtils.isEmpty(memberDO.getCheckImage())) {
ClassMemberMappingDO classMemberMappingDO = classMemberMappingMapper.selectOne(new QueryWrapper<ClassMemberMappingDO>()
.lambda()
.eq(ClassMemberMappingDO::getMemberId, memberDO.getId())
.eq(ClassMemberMappingDO::getClassId, classId));
if (StringUtils.isEmpty(classMemberMappingDO.getPhoto())) {
signList1.add(memberDO.getUserName());
signList1.add(memberDO.getIdCard());
sign = sign(signList1, idCardTicketsVO.getValue());
sendIdCardInfoVO = this.sendIdCardInfo(imageCheckRecordDO.getBizSeqNo(), memberDO, sign);
} else {
sign = sign(signList1, idCardTicketsVO.getValue());
sendIdCardInfoVO = this.sendIdCardInfoCompare(imageCheckRecordDO.getBizSeqNo(), memberDO, sign);
sendIdCardInfoVO = this.sendIdCardInfoCompare(imageCheckRecordDO.getBizSeqNo(), memberDO, sign, OSSUtils.image2Base64(classMemberMappingDO.getPhoto()));
}
if (!"0".equals(sendIdCardInfoVO.getCode())) {
......@@ -255,8 +267,8 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
//存数据库
ImageCheckRecordDO imageCheckRecordDO = imageCheckRecordMapper.selectOne(new QueryWrapper<ImageCheckRecordDO>()
.lambda()
.eq(ImageCheckRecordDO::getBizSeqNo,checkResultDTO.getId()));
.lambda()
.eq(ImageCheckRecordDO::getBizSeqNo, checkResultDTO.getId()));
if (!StringUtils.isEmpty(resultVO.getSimilarity())) {
BeanUtils.copyProperties(resultVO, imageCheckRecordDO);
ActivityDetectionDO activityDetectionDO = new ActivityDetectionDO();
......@@ -265,7 +277,7 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
activityDetectionDO.setCheckType(1);
activityDetectionDO.setFaceCheckId(imageCheckRecordDO.getId());
try {
imageCheckRecordDO.setPhoto(OSSUtils.uploadOneFile(resultVO.getPhotoList().get(resultVO.getPhotoList().size()-1)));
imageCheckRecordDO.setPhoto(OSSUtils.uploadOneFile(resultVO.getPhotoList().get(resultVO.getPhotoList().size() - 1)));
if ((Double.valueOf(imageCheckRecordDO.getSimilarity()) > 50)) {
imageCheckRecordDO.setResult(1);
activityDetectionDO.setStatus(1);
......@@ -276,7 +288,7 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
.lambda()
.eq(ClassMemberMappingDO::getMemberId, imageCheckRecordDO.getMemberId())
.eq(ClassMemberMappingDO::getClassId, imageCheckRecordDO.getClassId()));
if (StringUtils.isEmpty(classMemberMappingDO.getPhoto())){
if (StringUtils.isEmpty(classMemberMappingDO.getPhoto())) {
classMemberMappingDO.setPhoto(imageCheckRecordDO.getPhoto());
classMemberMappingMapper.updateById(classMemberMappingDO);
}
......@@ -291,6 +303,10 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
activityDetectionDO.setStatus(0);
e.printStackTrace();
}
if (null != imageCheckRecordDO.getPaperId()) {
activityDetectionDO.setCheckType(2);
}
activityDetectionMapper.insert(activityDetectionDO);
imageCheckRecordMapper.updateById(imageCheckRecordDO);
}
......@@ -374,13 +390,13 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
/**
* PC端 合作方后台上送身份信息 POST请求 图片对比
*/
public SendIdCardInfoVO sendIdCardInfoCompare(String orderNo, MemberDO memberDO, String sign) {
public SendIdCardInfoVO sendIdCardInfoCompare(String orderNo, MemberDO memberDO, String sign, String sourceImg) {
String url = "https://miniprogram-kyc.tencentcloudapi.com/api/server/h5/geth5faceid?orderNo=" + orderNo;
String input = "{\n" +
" \"webankAppId\":\"" + WBAPPID + "\",\n" +
" \"orderNo\":\"" + orderNo + "\",\n" +
" \"sourcePhotoStr\":\"" + memberDO.getCheckImage() + "\"," +
" \"sourcePhotoStr\":\"" + sourceImg + "\"," +
" \"sourcePhotoType\":\"" + 2 + "\"," +
" \"userId\":\"" + memberDO.getId() + "\"," +
" \"version\":\"1.0.0\"," +
......@@ -421,13 +437,13 @@ public class ImageCheckRecordServiceImpl extends ServiceImpl<ImageCheckRecordMap
/**
* H5端 合作方后台上送身份信息 POST请求 图片对比
*/
public SendIdCardInfoVO h5SendIdCardInfoCompare(String orderNo, MemberDO memberDO, String sign) {
public SendIdCardInfoVO h5SendIdCardInfoCompare(String orderNo, MemberDO memberDO, String sign, String sourceImg) {
String url = "https://kyc.qcloud.com/api/server/getAdvFaceId?orderNo=" + orderNo;
String input = "{\n" +
" \"appId\":\"" + WBAPPID + "\",\n" +
" \"orderNo\":\"" + orderNo + "\",\n" +
" \"sourcePhotoStr\":\"" + memberDO.getCheckImage() + "\"," +
" \"sourcePhotoStr\":\"" + sourceImg + "\"," +
" \"sourcePhotoType\":\"" + 2 + "\"," +
" \"userId\":\"" + memberDO.getId() + "\"," +
" \"version\":\"1.0.0\"," +
......
......@@ -1164,8 +1164,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, MemberDO> imple
.eq(MemberTokensDO::getMemberId, memberDO.getId()));
OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId());
if (oprMemDictDO.getResult() == 1 && "登出".equals(oprMemDictDO.getOprType())) {
oprMemDictMapper.deleteData(oprMemDictDO);
if (null != oprMemDictDO){
if (oprMemDictDO.getResult() == 1 && "登出".equals(oprMemDictDO.getOprType())) {
oprMemDictMapper.deleteById(oprMemDictDO.getId());
// oprMemDictMapper.deleteData(oprMemDictDO);
}
}
oprMemDictDO.setUserId(memberDO.getId());
oprMemDictDO.setResult(1);
......
......@@ -44,6 +44,7 @@ public class RenSheJuServiceImpl implements RenSheJuService {
@Autowired
private ImageCheckRecordMapper imageCheckRecordMapper;
public RensheResponseVO classBaseInfo() throws IOException {
OkHttpClient client = new OkHttpClient().newBuilder()
......@@ -176,11 +177,26 @@ public class RenSheJuServiceImpl implements RenSheJuService {
activityList.setAccess(1);
activityList.setErrorInfo(2);
}
int count = imageCheckRecordMapper.selectCount(new QueryWrapper<ImageCheckRecordDO>()
.lambda()
.eq(ImageCheckRecordDO::getResult, 1)
.isNull(ImageCheckRecordDO::getPaperId)
.eq(ImageCheckRecordDO::getMemberId, dailyStudyInfoVO.getMemberId())
.eq(ImageCheckRecordDO::getClassId, dailyStudyInfoVO.getDownCode()));
if (0 == dailyActivitiesVO.getCheckType()) {
activityList.setActivityDetection(2);
} else {
} else if (1 == dailyActivitiesVO.getCheckType()) {
activityList.setActivityDetection(1);
} else {
activityList.setActivityDetection(3);
}
if (count >= 2 && dailyActivitiesVO.getCheckType() == 1) {
activityList.setActivityDetection(4);
}
activityList.setActivityTime(dailyActivitiesVO.getActivityTime());
activityLists.add(activityList);
}
......@@ -236,60 +252,86 @@ public class RenSheJuServiceImpl implements RenSheJuService {
List<ChapterExamBasic> chapterExamBasics = new ArrayList<>();
List<DailyExamBasicVO> dailyExamBasicVOS = renSheJuMapper.dailyExamBasic();
//找出前一天产生考试数据的班级
// List<Long> classIds = renSheJuMapper.dailyExamBasic();
List<Long> classIds = new ArrayList<>();
classIds.add(404L);
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<ActivityList> activityLists = new ArrayList<>();
List<ExamActivitiesVO> 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);
if (classIds.size() > 0) {
for (Long classId : classIds) {
//具体哪些人做了
List<MemberDO> memberDOList = renSheJuMapper.memberIds(classId);
for (MemberDO memberDO : memberDOList) {
//章节课程考试时间列表
ChapterExamBasic chapterExamBasic = new ChapterExamBasic();
chapterExamBasic.setDownCode(String.valueOf(classId));
//最后一节课作为chapterCode
String vodId = renSheJuMapper.classVodName(classId);
chapterExamBasic.setChapterCode(vodId);
chapterExamBasic.setStudentName(memberDO.getUserName());
chapterExamBasic.setPhone(memberDO.getTelephone());
chapterExamBasic.setIdentity(memberDO.getIdCard());
//考试花了多长时间
Long examLength = renSheJuMapper.examLength(memberDO.getId(), classId);
chapterExamBasic.setExamTime(examLength);
//考试活跃度列表
List<ActivityList> activityLists = new ArrayList<>();
List<ExamActivitiesVO> activityDetectionDOS = renSheJuMapper.examActivities(classId, memberDO.getId());
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(3);
activityList.setActivityTime(dailyActivitiesVO.getActivityTime());
activityLists.add(activityList);
}
activityList.setActivityDetection(1);
activityList.setActivityTime(dailyActivitiesVO.getActivityTime());
activityLists.add(activityList);
}
chapterExamBasic.setActivityList(activityLists);
//考试时间列表
//上线时间
List<OprMemDictDO> loginRecords = renSheJuMapper.loginRecords(dailyExamBasicVO.getMemberId());
//下线时间
List<OprMemDictDO> loginOutRecords = renSheJuMapper.loginOutRecords(dailyExamBasicVO.getMemberId());
List<ExamList> examLists = new ArrayList<ExamList>();
for (int i = 0; i < loginRecords.size(); i++) {
//找到该时间段内的测评
List<ExerciseDoneResultDO> 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.setActivityList(activityLists);
List<ExamList> examLists = new ArrayList<ExamList>();
//上线时间
List<OprMemDictDO> loginRecords = renSheJuMapper.loginRecords(memberDO.getId());
//下线时间
List<OprMemDictDO> loginOutRecords = renSheJuMapper.loginOutRecords(memberDO.getId());
boolean flag = false;
for (int i = 0; i < loginRecords.size(); i++) {
//找到该时间段内的测评
List<ExerciseDoneResultDO> exerciseDoneResultDOS = renSheJuMapper.dailyExerciseDone(memberDO.getId(), loginRecords.get(i).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " "), classId);
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());
if ("合格".equals(exerciseDoneResultDO.getResult())) {
flag = true;
}
examLists.add(examList);
}
}
if (flag == true) {
chapterExamBasic.setAccess(0L);
} else {
chapterExamBasic.setAccess(1L);
}
chapterExamBasic.setExamList(examLists);
chapterExamBasics.add(chapterExamBasic);
}
chapterExamBasic.setExamList(examLists);
chapterExamBasics.add(chapterExamBasic);
}
uploadChapterBehaviorDTO.setChapterExamBasic(chapterExamBasics);
......@@ -306,18 +348,19 @@ public class RenSheJuServiceImpl implements RenSheJuService {
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 {
renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR);
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 {
renshejuHistoryDO.setOutputParam(RenSheJuConstant.API_ERROR);
}
renshejuHistoryMapper.insert(renshejuHistoryDO);
}
renshejuHistoryMapper.insert(renshejuHistoryDO);
// }
return rensheResponseVO;
// return null;
} else {
RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO();
renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4);
......@@ -434,14 +477,15 @@ public class RenSheJuServiceImpl implements RenSheJuService {
//找到昨天做过人脸识别的班级
List<Long> classIds = renSheJuMapper.checkClassIds();
// List<Long> classIds = renSheJuMapper.checkClassIds();
List<Long> classIds = new ArrayList<>();
classIds.add(404L);
for (Long classId : classIds) {
UploadImageDTO uploadImage = new UploadImageDTO();
uploadImage.setPrivateKey(getSecret());
uploadImage.setDownCode(String.valueOf(classId));
// //查找班级下所有人做过的实名认证记录
// List<ClassImageChecksVO> classImageChecksVOS = renSheJuMapper.classImageChecks(classId);
List<ImageDetailList> imageDetailLists = new ArrayList<ImageDetailList>();
try {
......@@ -465,16 +509,35 @@ public class RenSheJuServiceImpl implements RenSheJuService {
if (count == 1) {
imageDetailList.setProcessType(0L);
imageDetailList.setDetectionType(0L);
imageDetailLists.add(imageDetailList);
} else if (count == 2) {
imageDetailList.setProcessType(1L);
imageDetailList.setDetectionType(1L);
imageDetailLists.add(imageDetailList);
}
imageDetailLists.add(imageDetailList);
}
uploadImage.setImageDetailList(imageDetailLists);
}
/**
* 考试检测数据
*/
List<ClassImageChecksVO> examChecks = renSheJuMapper.examCheck(classId);
if (examChecks.size() > 0) {
for (ClassImageChecksVO cicon : examChecks) {
ImageDetailList imageDetailList = new ImageDetailList();
BeanUtils.copyProperties(cicon, imageDetailList);
imageDetailList.setImageBase64("data:image/jpeg;base64," + OSSUtils.image2Base64(cicon.getImage()));
imageDetailList.setProcessType(2L);
imageDetailList.setDetectionType(1L);
imageDetailLists.add(imageDetailList);
}
}
uploadImage.setImageDetailList(imageDetailLists);
if (imageDetailLists.size() > 0) {
System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(uploadImage));
RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(uploadImage).toString());
Request request = new Request.Builder()
......@@ -492,13 +555,15 @@ public class RenSheJuServiceImpl implements RenSheJuService {
renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString());
renshejuHistoryMapper.insert(renshejuHistoryDO);
rensheResponseVOS.add(rensheResponseVO);
System.out.println(111);
} else {
RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO();
renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_6);
renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadImage).toString());
renshejuHistoryDO.setOutputParam(RenSheJuConstant.NO_DATA);
renshejuHistoryMapper.insert(renshejuHistoryDO);
RenshejuHistoryDO renshejuHistoryDO1 = new RenshejuHistoryDO();
renshejuHistoryDO1.setInterfaceName(RenSheJuConstant.POST_6);
renshejuHistoryDO1.setInputParam(JSONObject.fromObject(uploadImage).toString());
renshejuHistoryDO1.setOutputParam(RenSheJuConstant.NO_DATA);
renshejuHistoryMapper.insert(renshejuHistoryDO1);
}
} catch (Exception e) {
e.printStackTrace();
RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO();
......@@ -507,7 +572,6 @@ public class RenSheJuServiceImpl implements RenSheJuService {
renshejuHistoryDO.setOutputParam(RenSheJuConstant.PUSH_FAIL);
renshejuHistoryMapper.insert(renshejuHistoryDO);
}
// System.out.println(rensheResponseVO);
}
return rensheResponseVOS;
......
......@@ -36,7 +36,11 @@ class Base64Util {
BASE64Encoder decoder = new BASE64Encoder();
return replaceEnter(decoder.encode(image));
}
public static void main(String[] args) {
System.out.println(encode("http://ykhl-bigger.oss-cn-beijing.aliyuncs.com/2023-02-1618cb936b-4825-429c-9fdd-dd9d0de97ed7.jpg?x-oss-process=image/auto-orient,1/resize,m_pad,w_500,h_500/quality,Q_100/format,jpg"));
}
public static String encode(String uri){
BASE64Encoder encoder = new BASE64Encoder();
return replaceEnter(encoder.encode(uri.getBytes()));
......
......@@ -37,7 +37,7 @@ public class MathUtil {
//习题/视频 ==> 秒钟向下取整
public static String floorSecond(int length) {
return String.valueOf((int) Math.ceil((double) length / 60));
return String.valueOf((int) Math.floor((double) length / 60));
}
//视频秒数处理
......
......@@ -115,6 +115,7 @@ public class OSSUtils {
}
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"));
// 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"));
System.out.println(image2Base64("http://ykhl-bigger.oss-cn-beijing.aliyuncs.com/2023-02-1618cb936b-4825-429c-9fdd-dd9d0de97ed7.jpg?x-oss-process=image/auto-orient,1/resize,m_pad,w_500,h_500/quality,Q_100/format,jpg"));
}
}
......@@ -68,16 +68,66 @@
t.delete_date IS NULL
AND t.result = 1
AND t.user_id =#{userId}
order by t.create_date desc
and DATE_FORMAT( create_date, '%Y-%m-%d' ) = DATE_FORMAT( now(), '%Y-%m-%d' )
order by t.id desc
limit 1
</select>
<delete id="deleteData" parameterType="com.subsidy.model.OprMemDictDO">
DELETE
<!-- <update id="deleteData" parameterType="com.subsidy.model.OprMemDictDO">-->
<!-- DELETE-->
<!-- FROM-->
<!-- opr_mem_dict-->
<!-- WHERE-->
<!-- delete_date IS NULL-->
<!-- AND id = #{id}-->
<!-- </update>-->
<select id="onlineUsers" resultType="long">
SELECT
t1.user_id
FROM
opr_mem_dict
(
SELECT
id,
user_id,
opr_type,
max( create_date ) AS time1
FROM
opr_mem_dict
WHERE
delete_date IS NULL
AND id = #{id}
</delete>
DATE_FORMAT( create_date, '%Y-%m-%d ' ) = DATE_FORMAT( now(), '%Y-%m-%d ' )
AND result = 1
AND opr_type = "登录"
GROUP BY
user_id
ORDER BY
create_date DESC
) t1
LEFT JOIN (
SELECT
id,
user_id,
opr_type,
max( create_date ) AS time2
FROM
opr_mem_dict
WHERE
DATE_FORMAT( create_date, '%Y-%m-%d ' ) = DATE_FORMAT( now(), '%Y-%m-%d ' )
AND result = 1
AND opr_type = "登出"
GROUP BY
user_id
ORDER BY
create_date DESC
) t2 ON t1.user_id = t2.user_id
WHERE
t2.id IS NULL
OR t2.time2 &lt; t1.time1
</select>
<!-- <update id="insertLastStudyRecord">-->
<!-- -->
<!-- </update>-->
</mapper>
......@@ -182,13 +182,14 @@
<select id="examActivities" resultType="com.subsidy.vo.renshe.ExamActivitiesVO">
SELECT
t1.result AS access,
UNIX_TIMESTAMP( t1.create_date )* 1000 AS activityTime
UNIX_TIMESTAMP( t1.update_date )* 1000 AS activityTime
FROM
image_check_record t1
WHERE
class_id =#{classId}
AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
AND t1.paper_id IS NOT NULL
and t1.result =1
AND t1.member_id=#{memberId}
</select>
......@@ -276,26 +277,35 @@
and t.class_id = #{classId}
</select>
<select id="dailyExamBasic" resultType="com.subsidy.vo.renshe.DailyExamBasicVO">
SELECT
t3.id as downCode,
t2.id as memberId,
t3.class_code,
t2.user_name AS studentName,
t2.telephone AS phone,
t2.id_card AS identity,
IF
( t1.result = "合格", 0, 1 ) AS access,
unix_timestamp( t1.create_date )- unix_timestamp( t1.start_date ) AS examTime
FROM
exercise_done_result t1
LEFT JOIN member t2 ON t1.member_id = t2.id
LEFT JOIN class_dict t3 ON t1.class_id = t3.id
WHERE
DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
<select id="dailyExamBasic" resultType="long">
SELECT DISTINCT
class_id
FROM
exercise_done_result t1
WHERE
t1.delete_date IS NULL
AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT(
NOW(),
'%Y-%m-%d'
)
</select>
<select id="classVodName" parameterType="string" resultType="string">
<select id="memberIds" parameterType="long" resultType="com.subsidy.model.MemberDO">
SELECT DISTINCT
member_id as id,
t2.id_card,
t2.telephone,
t2.user_name
FROM
exercise_done_result t1
LEFT JOIN member t2 ON t1.member_id = t2.id
WHERE
t1.delete_date IS NULL
AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
And class_id = #{classId}
</select>
<select id="classVodName" parameterType="long" resultType="string">
SELECT
t7.id AS chapterCode
FROM
......@@ -318,6 +328,18 @@
limit 1
</select>
<select id="examLength" resultType="long">
SELECT
SUM(unix_timestamp( t1.create_date )- unix_timestamp( t1.start_date ) ) AS examTime
FROM
exercise_done_result t1
WHERE
t1.delete_date IS NULL
AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
AND class_id = #{classId}
AND member_id = #{memberId}
</select>
<select id="dailyExerciseDone" resultType="com.subsidy.model.ExerciseDoneResultDO">
SELECT
*
......@@ -328,6 +350,7 @@
AND t.member_id = #{memberId}
AND t.create_date BETWEEN DATE_FORMAT(#{startDate}, '%Y-%m-%d %H:%i:%s' )
AND DATE_FORMAT(#{endDate}, '%Y-%m-%d %H:%i:%s' )
and t.class_id = #{classId}
</select>
<select id="dailyAnswer" resultType="com.subsidy.vo.renshe.DailyAnswerVO">
......@@ -360,6 +383,7 @@
NOW(),
'%Y-%m-%d'
)
and class_id is not null
</select>
<select id="classImageChecks" parameterType="long" resultType="com.subsidy.vo.renshe.ClassImageChecksVO">
......@@ -414,7 +438,8 @@
image_check_record t1
LEFT JOIN member t2 ON t1.member_id = t2.id
WHERE
class_id = #{classId}
t1.delete_date is null
and class_id = #{classId}
AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
AND t1.paper_id IS NULL
AND t1.result = 1
......@@ -424,4 +449,27 @@
</select>
<select id="examCheck" parameterType="long" resultType="com.subsidy.vo.renshe.ClassImageChecksVO">
SELECT
t1.class_id,
t1.member_id,
t1.photo AS image,
t2.user_name AS studentName,
t2.id_card AS identity,
t2.telephone AS phone,
UNIX_TIMESTAMP( t1.update_date )* 1000 AS activityTime
FROM
image_check_record t1
LEFT JOIN member t2 ON t1.member_id = t2.id
WHERE
t1.delete_date is null
AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 1 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' )
and class_id = #{classId}
AND t1.paper_id IS not NULL
AND t1.result = 1
and t1.member_id
GROUP BY t1.class_id,t1.member_id
ORDER BY t1.create_date desc
</select>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!