From 7944d5cea8d86325b161c3ea76ef531df29468be Mon Sep 17 00:00:00 2001 From: tuyp Date: Thu, 1 Jun 2023 17:04:00 +0800 Subject: [PATCH] 补贴培训第一次上课 --- src/main/java/com/subsidy/MeishuApplication.java | 2 ++ src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java | 13 +++++-------- src/main/java/com/subsidy/controller/AdministerController.java | 11 +---------- src/main/java/com/subsidy/controller/DuDaoController.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/subsidy/controller/ExerciseDictController.java | 2 +- src/main/java/com/subsidy/controller/MemberController.java | 16 ++++++++-------- src/main/java/com/subsidy/controller/OssController.java | 196 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------- src/main/java/com/subsidy/controller/VodPlayHistoryController.java | 3 ++- src/main/java/com/subsidy/jobs/DudaoJob.java | 45 +++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/subsidy/jobs/RenSheJuJob.java | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------ src/main/java/com/subsidy/jobs/ShehuihuaJob.java | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- src/main/java/com/subsidy/mapper/DudaoMapper.java | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/subsidy/mapper/OprMemDictMapper.java | 33 ++++++++++++++++++++++----------- src/main/java/com/subsidy/mapper/RenSheJuMapper.java | 26 ++++++++++++++++++++++---- src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java | 6 ++++++ src/main/java/com/subsidy/service/DudaoService.java | 20 ++++++++++++++++++++ src/main/java/com/subsidy/service/MemberService.java | 2 +- src/main/java/com/subsidy/service/RenSheJuService.java | 1 - src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java | 2 +- src/main/java/com/subsidy/service/impl/DudaoServiceImpl.java | 575 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/subsidy/service/impl/ExerciseDictServiceImpl.java | 28 +++++++++++++++++++++------- src/main/java/com/subsidy/service/impl/MemberServiceImpl.java | 318 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------- src/main/java/com/subsidy/service/impl/ShehuihuaServiceImpl.java | 26 ++++++++++++-------------- src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java | 41 +++++++++++++++++------------------------ src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java | 63 ++++++++++++++++++++++++++++++++++++++------------------------- src/main/java/com/subsidy/util/DudaoConstant.java | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ src/main/java/com/subsidy/util/OSSUtils.java | 4 ++-- src/main/java/com/subsidy/util/SMSUtils.java | 1 + src/main/java/com/subsidy/vo/opr/InsertLastStudyRecordVO.java | 20 ++++++++++++++++++++ src/main/resources/application-prod.properties | 6 ++---- src/main/resources/application.properties | 6 ++++-- src/main/resources/code.properties | 4 +++- src/main/resources/mapper/AdministerMapper.xml | 29 +++++++++++++++++++++++++---- src/main/resources/mapper/ClassDictMapper.xml | 2 +- src/main/resources/mapper/DudaoMapper.xml | 227 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main/resources/mapper/MemberMapper.xml | 1 + src/main/resources/mapper/OprAdmDictMapper.xml | 2 +- src/main/resources/mapper/OprMemDictMapper.xml | 197 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------- src/main/resources/mapper/RenSheJuMapper.xml | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------- src/main/resources/mapper/SignInRecordMapper.xml | 2 +- src/main/resources/mapper/VodDictMapper.xml | 4 ++-- src/main/resources/mapper/VodPlayHistoryMapper.xml | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 43 files changed, 2121 insertions(+), 555 deletions(-) create mode 100644 src/main/java/com/subsidy/controller/DuDaoController.java create mode 100644 src/main/java/com/subsidy/jobs/DudaoJob.java create mode 100644 src/main/java/com/subsidy/mapper/DudaoMapper.java create mode 100644 src/main/java/com/subsidy/service/DudaoService.java create mode 100644 src/main/java/com/subsidy/service/impl/DudaoServiceImpl.java create mode 100644 src/main/java/com/subsidy/util/DudaoConstant.java create mode 100644 src/main/java/com/subsidy/vo/opr/InsertLastStudyRecordVO.java create mode 100644 src/main/resources/mapper/DudaoMapper.xml diff --git a/src/main/java/com/subsidy/MeishuApplication.java b/src/main/java/com/subsidy/MeishuApplication.java index 491dbf6..b984c32 100644 --- a/src/main/java/com/subsidy/MeishuApplication.java +++ b/src/main/java/com/subsidy/MeishuApplication.java @@ -6,6 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cache.annotation.EnableCaching; import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableScheduling; +import org.springframework.transaction.annotation.EnableTransactionManagement; import org.springframework.web.bind.annotation.RestController; @RestController @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; @EnableScheduling //@EnableCaching @EnableAsync +@EnableTransactionManagement public class MeishuApplication { public static void main(String[] args) { diff --git a/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java b/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java index d69dbc5..a51f550 100644 --- a/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java +++ b/src/main/java/com/subsidy/common/interceptor/AuthenticationInterceptor.java @@ -57,9 +57,6 @@ public class AuthenticationInterceptor implements HandlerInterceptor { @Autowired private MemberTokensMapper memberTokensMapper; - @Autowired - private OprMemDictMapper oprMemDictMapper; - @Override @CrossOrigin() public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { @@ -102,11 +99,11 @@ public class AuthenticationInterceptor implements HandlerInterceptor { 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); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登出"); +// oprMemDictDO.setResult(1); +// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(17001); } } diff --git a/src/main/java/com/subsidy/controller/AdministerController.java b/src/main/java/com/subsidy/controller/AdministerController.java index df1229f..1fe2380 100644 --- a/src/main/java/com/subsidy/controller/AdministerController.java +++ b/src/main/java/com/subsidy/controller/AdministerController.java @@ -7,22 +7,13 @@ import com.subsidy.common.interceptor.LoginRequired; import com.subsidy.dto.administer.*; import com.subsidy.model.*; import com.subsidy.service.AdministerService; -import com.subsidy.util.ConstantUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; -import java.net.InetAddress; - /** *

* 管理平台用户 前端控制器 diff --git a/src/main/java/com/subsidy/controller/DuDaoController.java b/src/main/java/com/subsidy/controller/DuDaoController.java new file mode 100644 index 0000000..b559a76 --- /dev/null +++ b/src/main/java/com/subsidy/controller/DuDaoController.java @@ -0,0 +1,56 @@ +package com.subsidy.controller; + +import com.subsidy.dto.renshe.*; +import com.subsidy.service.DudaoService; +import com.subsidy.service.RenSheJuService; +import com.subsidy.vo.renshe.RensheResponseVO; +import com.subsidy.vo.renshe.RensheStringVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.io.IOException; +import java.util.List; + +@RestController +@Api(tags = "普陀区人社督导") +@RequestMapping("/dudao") +public class DuDaoController { + + @Autowired + private DudaoService dudaoService; + + @PostMapping("classBaseInfo") + @ApiOperation("POST-1:班级基本信息信息采集接口") + public RensheResponseVO classBaseInfo() throws IOException { + return dudaoService.classBaseInfo(); + } + + @PostMapping("classHourBehavior") + @ApiOperation("POST-2:学时信息采集接口") + public RensheResponseVO classHourBehavior() throws IOException { + return dudaoService.classHourBehavior(); + } + + @PostMapping("uploadChapterBehavior") + @ApiOperation("POST-3:考试信息采集接口") + public RensheResponseVO uploadChapterBehavior() throws IOException { + return dudaoService.uploadChapterBehavior(); + } + + @PostMapping("uploadClassAnswerQuestionBehavior") + @ApiOperation("POST-4:答疑辅导采集接口") + public RensheResponseVO uploadClassAnswerQuestionBehavior() throws IOException { + return dudaoService.uploadClassAnswerQuestionBehavior(); + } + + @PostMapping("uploadClassCode") + @ApiOperation("POST-5: 上下游班级数据绑定接口") + public RensheResponseVO uploadClassCode()throws IOException { + return dudaoService.uploadClassCode(); + } + +} diff --git a/src/main/java/com/subsidy/controller/ExerciseDictController.java b/src/main/java/com/subsidy/controller/ExerciseDictController.java index c1b23cd..bbf5b36 100644 --- a/src/main/java/com/subsidy/controller/ExerciseDictController.java +++ b/src/main/java/com/subsidy/controller/ExerciseDictController.java @@ -60,7 +60,7 @@ public class ExerciseDictController { @PostMapping("submit") @ApiOperation("提交答案 {paperId 卷子id l length memberId 成员id classId课程 courseId 课程id memberExerciseVOS [ id selectAnswer ] startDate:做题时长} ") - @LoginRequired +// @LoginRequired @TimeRequired @CachePut(value = "ResultData" ,key = "'classId_'+#submitDTO.getClassId()") public ResponseVO submit(@RequestBody SubmitDTO submitDTO){ diff --git a/src/main/java/com/subsidy/controller/MemberController.java b/src/main/java/com/subsidy/controller/MemberController.java index a2b841d..68b86bc 100644 --- a/src/main/java/com/subsidy/controller/MemberController.java +++ b/src/main/java/com/subsidy/controller/MemberController.java @@ -122,7 +122,7 @@ public class MemberController { @PostMapping("myCertCourses") @ApiOperation("手机端:我的学习--证书课程 memberId 学员id status 状态 0:全部 1:进行中 2:待开始 3:已完成 ") -// @LoginRequired + @LoginRequired @TimeRequired public ResponseVO myCertCourses(@RequestBody MyCoursesDTO myCoursesDTO){ return ResponseData.generateCreatedResponse(0,memberService.myCertCourses(myCoursesDTO)); @@ -223,13 +223,13 @@ public class MemberController { return memberService.polyvInfo(userid,channelId,ts,token); } - @RequestMapping("logout") - @ApiOperation("登出 学生id") - @TimeRequired - public ResponseVO logout(@RequestBody String param){ - MemberDO memberDO = JSON.parseObject(param, MemberDO.class); - return ResponseData.generateCreatedResponse(0,memberService.logout(memberDO)); - } +// @RequestMapping("logout") +// @ApiOperation("登出 学生id") +// @TimeRequired +// public ResponseVO logout(@RequestBody String param){ +// MemberDO memberDO = JSON.parseObject(param, MemberDO.class); +// return ResponseData.generateCreatedResponse(0,memberService.logout(memberDO)); +// } diff --git a/src/main/java/com/subsidy/controller/OssController.java b/src/main/java/com/subsidy/controller/OssController.java index 8d49441..f37729b 100644 --- a/src/main/java/com/subsidy/controller/OssController.java +++ b/src/main/java/com/subsidy/controller/OssController.java @@ -1,9 +1,10 @@ package com.subsidy.controller; +import com.aliyun.oss.ClientException; import com.aliyun.oss.OSS; import com.aliyun.oss.OSSClientBuilder; -import com.aliyun.oss.model.PutObjectRequest; -import com.aliyun.oss.model.PutObjectResult; +import com.aliyun.oss.OSSException; +import com.aliyun.oss.model.*; import com.subsidy.common.ResponseData; import com.subsidy.common.ResponseVO; import com.subsidy.vo.oss.GetSecretVO; @@ -17,6 +18,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + @Api(tags = "oss") @RestController @RequestMapping("/oss") @@ -40,40 +47,183 @@ public class OssController { return ResponseData.generateCreatedResponse(0, getSecretVO); } +// @PostMapping("uploadFile") +// @ApiOperation("上传文件 file") +// public ResponseVO uploadFile(@RequestParam("file") MultipartFile file) { +// // 创建OSSClient实例。 +// OSS ossClient = new OSSClientBuilder().build("http://oss-cn-shanghai.aliyuncs.com", keyId, secret); +// UploadFileVO uploadFileVO = new UploadFileVO(); +// try { +// +// if (env.equals("test")) { +// env = "ykhl-bigger-test"; +// } +// if (env.equals("prod")) { +// env = "ykhl-bigger"; +// } +// +// +// // 创建PutObjectRequest对象。 +// PutObjectRequest putObjectRequest = new PutObjectRequest(env, System.currentTimeMillis() + "_" + file.getOriginalFilename(), file.getInputStream()); +// // 设置该属性可以返回response。如果不设置,则返回的response为空。 +// putObjectRequest.setProcess("true"); +// // 创建PutObject请求。 +// PutObjectResult result = ossClient.putObject(putObjectRequest); +// // 如果上传成功,则返回200。 +//// System.out.println(result.getResponse().getUri()); +// uploadFileVO.setUrl(result.getResponse().getUri()); +// } catch (Exception oe) { +// oe.printStackTrace(); +// } finally { +// if (ossClient != null) { +// ossClient.shutdown(); +// } +// } +// return ResponseData.generateCreatedResponse(0, uploadFileVO); +// } + @PostMapping("uploadFile") - @ApiOperation("上传文件 file") - public ResponseVO uploadFile(@RequestParam("file") MultipartFile file) { - // 创建OSSClient实例。 - OSS ossClient = new OSSClientBuilder().build("http://oss-cn-shanghai.aliyuncs.com", keyId, secret); + @ApiOperation("分片上传") + public ResponseVO fenpian(@RequestParam("file") MultipartFile file) { + UploadFileVO uploadFileVO = new UploadFileVO(); + + // Endpoint以华东1(杭州)为例,其它Region请按实际情况填写。 + String endpoint = "http://oss-cn-beijing.aliyuncs.com"; + // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。 + String accessKeyId = keyId; + String accessKeySecret = secret; + // 填写Bucket名称,例如examplebucket。 +// String bucketName = "zhongzhi-cms"; + // 填写Object完整路径,例如exampledir/exampleobject.txt。Object完整路径中不能包含Bucket名称。 + String objectName = System.currentTimeMillis() + "_" + file.getOriginalFilename(); + + // 创建OSSClient实例。 + OSS ossClient = new OSSClientBuilder().build(endpoint, accessKeyId, accessKeySecret); + + if (env.equals("dev")) { + env = "ykhl-bigger-test"; + } + if (env.equals("prod")) { + env = "ykhl-bigger"; + } + + try { + // 创建InitiateMultipartUploadRequest对象。 + InitiateMultipartUploadRequest request = new InitiateMultipartUploadRequest(env, objectName); + + // 如果需要在初始化分片时设置请求头,请参考以下示例代码。 + // ObjectMetadata metadata = new ObjectMetadata(); + // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard.toString()); + // 指定该Object的网页缓存行为。 + // metadata.setCacheControl("no-cache"); + // 指定该Object被下载时的名称。 + // metadata.setContentDisposition("attachment;filename=oss_MultipartUpload.txt"); + // 指定该Object的内容编码格式。 + // metadata.setContentEncoding(OSSConstants.DEFAULT_CHARSET_NAME); + // 指定初始化分片上传时是否覆盖同名Object。此处设置为true,表示禁止覆盖同名Object。 + // metadata.setHeader("x-oss-forbid-overwrite", "true"); + // 指定上传该Object的每个part时使用的服务器端加密方式。 + // metadata.setHeader(OSSHeaders.OSS_SERVER_SIDE_ENCRYPTION, ObjectMetadata.KMS_SERVER_SIDE_ENCRYPTION); + // 指定Object的加密算法。如果未指定此选项,表明Object使用AES256加密算法。 + // metadata.setHeader(OSSHeaders.OSS_SERVER_SIDE_DATA_ENCRYPTION, ObjectMetadata.KMS_SERVER_SIDE_ENCRYPTION); + // 指定KMS托管的用户主密钥。 + // metadata.setHeader(OSSHeaders.OSS_SERVER_SIDE_ENCRYPTION_KEY_ID, "9468da86-3509-4f8d-a61e-6eab1eac****"); + // 指定Object的存储类型。 + // metadata.setHeader(OSSHeaders.OSS_STORAGE_CLASS, StorageClass.Standard); + // 指定Object的对象标签,可同时设置多个标签。 + // metadata.setHeader(OSSHeaders.OSS_TAGGING, "a:1"); + // request.setObjectMetadata(metadata); + + // 初始化分片。 + InitiateMultipartUploadResult upresult = ossClient.initiateMultipartUpload(request); + // 返回uploadId,它是分片上传事件的唯一标识。您可以根据该uploadId发起相关的操作,例如取消分片上传、查询分片上传等。 + String uploadId = upresult.getUploadId(); - if (env.equals("test")) { - env = "ykhl-bigger-test"; + // partETags是PartETag的集合。PartETag由分片的ETag和分片号组成。 + List partETags = new ArrayList(); + // 每个分片的大小,用于计算文件有多少个分片。单位为字节。 + final long partSize = 1 * 1024 * 1024L; //1 MB。 + + // 根据上传的数据大小计算分片数。以本地文件为例,说明如何通过File.length()获取上传数据的大小。 +// final File sampleFile = new File("D:\\localpath\\examplefile.txt"); +// long fileLength = sampleFile.length(); +// int partCount = (int) (fileLength / partSize); +// if (fileLength % partSize != 0) { +// partCount++; +// } + + long fileLength = file.getSize(); + int partCount = (int) (fileLength / partSize); + if (fileLength % partSize != 0) { + partCount++; } - if (env.equals("prod")) { - env = "ykhl-bigger"; + + // 遍历分片上传。 + for (int i = 0; i < partCount; i++) { + long startPos = i * partSize; + long curPartSize = (i + 1 == partCount) ? (fileLength - startPos) : partSize; + UploadPartRequest uploadPartRequest = new UploadPartRequest(); + uploadPartRequest.setBucketName(env); + uploadPartRequest.setKey(objectName); + uploadPartRequest.setUploadId(uploadId); + // 设置上传的分片流。 + // 以本地文件为例说明如何创建FIleInputstream,并通过InputStream.skip()方法跳过指定数据。 + InputStream instream = file.getInputStream(); + instream.skip(startPos); + uploadPartRequest.setInputStream(instream); + // 设置分片大小。除了最后一个分片没有大小限制,其他的分片最小为100 KB。 + uploadPartRequest.setPartSize(curPartSize); + // 设置分片号。每一个上传的分片都有一个分片号,取值范围是1~10000,如果超出此范围,OSS将返回InvalidArgument错误码。 + uploadPartRequest.setPartNumber(i + 1); + // 每个分片不需要按顺序上传,甚至可以在不同客户端上传,OSS会按照分片号排序组成完整的文件。 + UploadPartResult uploadPartResult = ossClient.uploadPart(uploadPartRequest); + // 每次上传分片之后,OSS的返回结果包含PartETag。PartETag将被保存在partETags中。 + partETags.add(uploadPartResult.getPartETag()); } - // 创建PutObjectRequest对象。 - PutObjectRequest putObjectRequest = new PutObjectRequest(env, System.currentTimeMillis() + "_" + file.getOriginalFilename(), file.getInputStream()); - // 设置该属性可以返回response。如果不设置,则返回的response为空。 - putObjectRequest.setProcess("true"); - // 创建PutObject请求。 - PutObjectResult result = ossClient.putObject(putObjectRequest); - // 如果上传成功,则返回200。 -// System.out.println(result.getResponse().getUri()); - uploadFileVO.setUrl(result.getResponse().getUri()); - } catch (Exception oe) { - oe.printStackTrace(); + // 创建CompleteMultipartUploadRequest对象。 + // 在执行完成分片上传操作时,需要提供所有有效的partETags。OSS收到提交的partETags后,会逐一验证每个分片的有效性。当所有的数据分片验证通过后,OSS将把这些分片组合成一个完整的文件。 + CompleteMultipartUploadRequest completeMultipartUploadRequest = + new CompleteMultipartUploadRequest(env, objectName, uploadId, partETags); + + // 如果需要在完成分片上传的同时设置文件访问权限,请参考以下示例代码。 + // completeMultipartUploadRequest.setObjectACL(CannedAccessControlList.Private); + // 指定是否列举当前UploadId已上传的所有Part。仅在Java SDK为3.14.0及以上版本时,支持通过服务端List分片数据来合并完整文件时,将CompleteMultipartUploadRequest中的partETags设置为null。 + // Map headers = new HashMap(); + // 如果指定了x-oss-complete-all:yes,则OSS会列举当前UploadId已上传的所有Part,然后按照PartNumber的序号排序并执行CompleteMultipartUpload操作。 + // 如果指定了x-oss-complete-all:yes,则不允许继续指定body,否则报错。 + // headers.put("x-oss-complete-all","yes"); + // completeMultipartUploadRequest.setHeaders(headers); + + // 完成分片上传。 + CompleteMultipartUploadResult completeMultipartUploadResult = ossClient.completeMultipartUpload(completeMultipartUploadRequest); + uploadFileVO.setUrl(completeMultipartUploadResult.getLocation()); + System.out.println(completeMultipartUploadResult.getLocation()); + } catch (OSSException oe) { + System.out.println("Caught an OSSException, which means your request made it to OSS, " + + "but was rejected with an error response for some reason."); + System.out.println("Error Message:" + oe.getErrorMessage()); + System.out.println("Error Code:" + oe.getErrorCode()); + System.out.println("Request ID:" + oe.getRequestId()); + System.out.println("Host ID:" + oe.getHostId()); + } catch (ClientException ce) { + System.out.println("Caught an ClientException, which means the client encountered " + + "a serious internal problem while trying to communicate with OSS, " + + "such as not being able to access the network."); + System.out.println("Error Message:" + ce.getMessage()); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); } finally { if (ossClient != null) { ossClient.shutdown(); } } + return ResponseData.generateCreatedResponse(0, uploadFileVO); } - - } diff --git a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java index 724c142..40f6584 100644 --- a/src/main/java/com/subsidy/controller/VodPlayHistoryController.java +++ b/src/main/java/com/subsidy/controller/VodPlayHistoryController.java @@ -48,6 +48,7 @@ public class VodPlayHistoryController { @ApiOperation("记录学生看视频位置 classId班级id vodId 视频id memberId 成员id " + "playLength 播放时长 playRecord 位点 suspendLength") @TimeRequired +// @LoginRequired public ResponseVO insertHistoryNew(@RequestBody String param){ InsertHistoryNewDTO insertHistoryNewDTO = JSON.parseObject(param, InsertHistoryNewDTO.class); return ResponseData.generateCreatedResponse(0,vodPlayHistoryService.insertHistoryNew(insertHistoryNewDTO)); @@ -55,7 +56,7 @@ public class VodPlayHistoryController { @PostMapping("dataFix") @ApiOperation("每个视频都看一次") -// @LoginRequired + @LoginRequired public void dadaFix(@RequestBody SignDatePlaysDTO dataFixDTO){ vodPlayHistoryService.dataFix(dataFixDTO); } diff --git a/src/main/java/com/subsidy/jobs/DudaoJob.java b/src/main/java/com/subsidy/jobs/DudaoJob.java new file mode 100644 index 0000000..bfb0a59 --- /dev/null +++ b/src/main/java/com/subsidy/jobs/DudaoJob.java @@ -0,0 +1,45 @@ +//package com.subsidy.jobs; +// +//import com.subsidy.service.DudaoService; +//import org.springframework.beans.factory.annotation.Autowired; +//import org.springframework.scheduling.annotation.Scheduled; +//import org.springframework.stereotype.Component; +// +//import java.io.IOException; +// +///** +// * 企业职工线上培训 +// */ +//@Component +//public class DudaoJob { +// +// +// @Autowired +// private DudaoService dudaoService; +// +// @Scheduled(cron = "0 0 2 * * ?") +// public void classBaseInfo() throws IOException { +// dudaoService.classBaseInfo(); +// } +// +// @Scheduled(cron = "0 5 2 * * ?") +// public void classHourBehavior() throws IOException { +// dudaoService.classHourBehavior(); +// } +// +// @Scheduled(cron = "0 10 2 * * ?") +// public void uploadChapterBehavior() throws IOException { +// dudaoService.uploadChapterBehavior(); +// } +// +// @Scheduled(cron = "0 15 2 * * ?") +// public void uploadClassAnswerQuestionBehavior() throws IOException { +// dudaoService.uploadClassAnswerQuestionBehavior(); +// } +// +// @Scheduled(cron = "0 20 2 * * ?") +// public void uploadClassCode()throws IOException { +// dudaoService.uploadClassCode(); +// } +// +//} diff --git a/src/main/java/com/subsidy/jobs/RenSheJuJob.java b/src/main/java/com/subsidy/jobs/RenSheJuJob.java index 800699f..4c7041b 100644 --- a/src/main/java/com/subsidy/jobs/RenSheJuJob.java +++ b/src/main/java/com/subsidy/jobs/RenSheJuJob.java @@ -5,19 +5,25 @@ import com.subsidy.common.ResponseData; import com.subsidy.mapper.OprMemDictMapper; import com.subsidy.model.OprMemDictDO; import com.subsidy.service.RenSheJuService; +import com.subsidy.util.IpAddressUtil; import com.subsidy.util.websocket.WebSocketUtil; +import com.subsidy.vo.opr.InsertLastStudyRecordVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.socket.TextMessage; import org.springframework.web.socket.WebSocketSession; import java.io.IOException; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; import java.util.List; import java.util.concurrent.ConcurrentHashMap; /** - * 企业职工线上培训 + * 企业职工线上培训 */ @Component public class RenSheJuJob { @@ -30,10 +36,10 @@ public class RenSheJuJob { private OprMemDictMapper oprMemDictMapper; /** - * POST-2:班级基本信息信息采集接口 + * POST-2:班级基本信息信息采集接口 */ @Scheduled(cron = "0 0 1 * * ?") - public void classBaseInfo()throws IOException { + public void classBaseInfo() throws IOException { renSheJuService.classBaseInfo(); } @@ -65,7 +71,7 @@ public class RenSheJuJob { * POST-6 班级活跃度/实名认证照片信息采集接口 */ @Scheduled(cron = "0 20 1 * * ?") - public void uploadImage()throws IOException { + public void uploadImage() throws IOException { renSheJuService.uploadImage(); } @@ -73,7 +79,7 @@ public class RenSheJuJob { * POST-7 获取培训待绑定的(班级编号,项目编号)列表 */ @Scheduled(cron = "0 25 1 * * ?") - public void getClassCodeByPrivateKey()throws IOException { + public void getClassCodeByPrivateKey() throws IOException { renSheJuService.getClassCodeByPrivateKey(); } @@ -81,7 +87,7 @@ public class RenSheJuJob { * POST-8 上下游班级数据绑定接口 */ @Scheduled(cron = "0 30 1 * * ?") - public void uploadClassCode()throws IOException { + public void uploadClassCode() throws IOException { renSheJuService.uploadClassCode(); } @@ -93,26 +99,72 @@ public class RenSheJuJob { // renSheJuService.getErrorClass(); // } - @Scheduled(cron = "00 58 23 * * ?") - public void cancelLogin(){ + @Scheduled(cron = "00 50 23 * * ?") + @Transactional(rollbackFor = Exception.class) + public void logout(){ + //让当前用户下线 ConcurrentHashMap webSocketMap = WebSocketUtil.webSocketMap; - List onLineUsers = oprMemDictMapper.onlineUsers(); + //查看当天登录过的人最后一次活跃数据 + List insertLastStudyRecordVOS = oprMemDictMapper.insertLastStudyRecord(); + + for (InsertLastStudyRecordVO ilsr : insertLastStudyRecordVOS) { - for (Long key : onLineUsers){ try { - if (null != webSocketMap.get(key)){ - webSocketMap.get(key).sendMessage(new TextMessage(JSONObject.toJSONString(ResponseData.generateCreatedResponse(17001)))); + if (null != webSocketMap.get(ilsr.getMemberId())) { + webSocketMap.get(ilsr.getMemberId()).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){ + } catch (Exception e) { e.printStackTrace(); } } } + + @Scheduled(cron = "00 55 23 * * ?") + @Transactional(rollbackFor = Exception.class) + public void cancelLogin() { + + //让当前用户下线 +// ConcurrentHashMap webSocketMap = WebSocketUtil.webSocketMap; + + //查看当天登录过的人最后一次活跃数据 + List insertLastStudyRecordVOS = oprMemDictMapper.insertLastStudyRecord(); + for (InsertLastStudyRecordVO ilsr : insertLastStudyRecordVOS) { + + oprMemDictMapper.insertOrUpdate(ilsr.getMemberId(),"登录",1, ilsr.getIpAddress(),ilsr.getSignInDate()); + + if (null == ilsr.getMt()) { + //补23:58的数据 + oprMemDictMapper.insertOrUpdate(ilsr.getMemberId(),"登出",1,null,new Date()); + } else { + //最后一次学习的数据 + oprMemDictMapper.insertOrUpdate(ilsr.getMemberId(), "登出", 1, null, ilsr.getMt()); + } + } + + +// List shutdownUsers = oprMemDictMapper.shutdownUser(); +// for (Long key : shutdownUsers) { +// try { +// if (!onLineUsers.contains(key)) { +// OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(key); +// if (null != oprMemDictDO) { +// if (oprMemDictDO.getResult() == 1 && "登出".equals(oprMemDictDO.getOprType())) { +// oprMemDictMapper.deleteById(oprMemDictDO.getId()); +// } +// } +// DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); +// LocalDateTime time = LocalDateTime.now(); +// String localDateTime = df.format(time); +// LocalDateTime ldt = LocalDateTime.parse(localDateTime, df); +// oprMemDictDO.setCreateDate(ldt); +// oprMemDictMapper.insertOrUpdate(key, "登出", 1, null, ldt); +// } +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } + } + } diff --git a/src/main/java/com/subsidy/jobs/ShehuihuaJob.java b/src/main/java/com/subsidy/jobs/ShehuihuaJob.java index 0130a67..7c850e1 100644 --- a/src/main/java/com/subsidy/jobs/ShehuihuaJob.java +++ b/src/main/java/com/subsidy/jobs/ShehuihuaJob.java @@ -14,55 +14,55 @@ import java.io.IOException; public class ShehuihuaJob { - @Autowired - private ShehuihuaService shehuihuaService; - - /** - * POST-2 获取培训待绑定的(班级编号,项目编号)列表 - */ - @Scheduled(cron = "0 0 2 * * ?") - public void getClassCodeByPrivateKey()throws IOException { - shehuihuaService.getClassCodeByPrivateKey(); - } - - /** - * POST-3:班级基本信息信息采集接口 - */ - @Scheduled(cron = "0 5 2 * * ?") - public void uploadClass() throws IOException { - shehuihuaService.uploadClass(); - } - - /** - * POST-4:考试信息采集接口 - */ - @Scheduled(cron = "0 10 2 * * ?") - public void classHourBehavior() throws IOException { - shehuihuaService.classHourBehavior(); - } - - /** - * POST-5:答疑辅导采集接口 - */ - @Scheduled(cron = "0 15 2 * * ?") - public void uploadChapterBehavior() throws IOException { - shehuihuaService.uploadChapterBehavior(); - } - - /** - * POST-6 班级活跃度/实名认证照片信息采集接口 - */ - @Scheduled(cron = "0 20 2 * * ?") - public void uploadClassAnswerQuestionBehavior()throws IOException { - shehuihuaService.uploadClassAnswerQuestionBehavior(); - } - - /** - * POST-7 获取培训待绑定的(班级编号,项目编号)列表 - */ - @Scheduled(cron = "0 25 2 * * ?") - public void uploadImage()throws IOException { - shehuihuaService.uploadImage(); - } +// @Autowired +// private ShehuihuaService shehuihuaService; +// +// /** +// * POST-2 获取培训待绑定的(班级编号,项目编号)列表 +// */ +// @Scheduled(cron = "0 0 2 * * ?") +// public void getClassCodeByPrivateKey()throws IOException { +// shehuihuaService.getClassCodeByPrivateKey(); +// } +// +// /** +// * POST-3:班级基本信息信息采集接口 +// */ +// @Scheduled(cron = "0 5 2 * * ?") +// public void uploadClass() throws IOException { +// shehuihuaService.uploadClass(); +// } +// +// /** +// * POST-4:考试信息采集接口 +// */ +// @Scheduled(cron = "0 10 2 * * ?") +// public void classHourBehavior() throws IOException { +// shehuihuaService.classHourBehavior(); +// } +// +// /** +// * POST-5:答疑辅导采集接口 +// */ +// @Scheduled(cron = "0 15 2 * * ?") +// public void uploadChapterBehavior() throws IOException { +// shehuihuaService.uploadChapterBehavior(); +// } +// +// /** +// * POST-6 班级活跃度/实名认证照片信息采集接口 +// */ +// @Scheduled(cron = "0 20 2 * * ?") +// public void uploadClassAnswerQuestionBehavior()throws IOException { +// shehuihuaService.uploadClassAnswerQuestionBehavior(); +// } +// +// /** +// * POST-7 获取培训待绑定的(班级编号,项目编号)列表 +// */ +// @Scheduled(cron = "0 25 2 * * ?") +// public void uploadImage()throws IOException { +// shehuihuaService.uploadImage(); +// } } diff --git a/src/main/java/com/subsidy/mapper/DudaoMapper.java b/src/main/java/com/subsidy/mapper/DudaoMapper.java new file mode 100644 index 0000000..84c3c0b --- /dev/null +++ b/src/main/java/com/subsidy/mapper/DudaoMapper.java @@ -0,0 +1,56 @@ +package com.subsidy.mapper; + +import com.subsidy.vo.renshe.DailyAnswerVO; +import com.subsidy.vo.renshe.DailyStudyInfoVO; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface DudaoMapper { + + /** + * 产生视频数据的班级 + */ + List vodClassIds(String classType); + + /** + * 产生考试数据的班级 + */ + List examClassIds(String classType); + + /** + * 答疑数据的班级 + */ + List answerClassIds(String classType); + + /** + * 产生人脸识别的班级 + */ + List imageClassIds(String classType); + + /** + * 前一天新增视频学习数据 + */ + List dailyStudyInfo(String classType); + + /** + * 前一天考试通过数据 + */ + List dailyExamBasic(String classType); + + /** + * 找到某人当天答疑的记录 + */ + List dailyAnswer(String classType); + + /** + * 新增班级 + */ + List newClasses(String classType); + + + + +} + diff --git a/src/main/java/com/subsidy/mapper/OprMemDictMapper.java b/src/main/java/com/subsidy/mapper/OprMemDictMapper.java index c0ea6ed..11d849d 100644 --- a/src/main/java/com/subsidy/mapper/OprMemDictMapper.java +++ b/src/main/java/com/subsidy/mapper/OprMemDictMapper.java @@ -4,8 +4,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.subsidy.model.OprMemDictDO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.subsidy.vo.opr.GetHistoryVO; +import com.subsidy.vo.opr.InsertLastStudyRecordVO; import org.springframework.stereotype.Repository; +import java.time.LocalDateTime; +import java.util.Date; import java.util.List; /** @@ -28,22 +31,30 @@ public interface OprMemDictMapper extends BaseMapper { */ OprMemDictDO getLatestLoginInfo(Long userId); - -// /** -// * 当天最后一次登录 -// */ -// OprMemDictDO getLatestLogoutInfo(Long userId); - -// void deleteData(OprMemDictDO oprMemDictDO); + /** + * 当天最后一次登出 + */ + OprMemDictDO getLatestLogoutInfo(Long userId); /** * 查看当天还在线的用户 */ List onlineUsers(); -// /** -// * 根据最后一次看视频时间随机去写几秒登出 -// */ -// void insertLastStudyRecord(); + /** + * 根据最后一次看视频时间随机去写几秒登出 + */ + List insertLastStudyRecord(); + + /** + * 查看视频记录晚于最后一次登出的人,补一次11:58登出的记录 + */ + List shutdownUser(); + + /** + * 防止相同两条数据的插入 + */ + void insertOrUpdate(Long userId, String oprType, Integer result, String ipAddress, Date createDate); + } diff --git a/src/main/java/com/subsidy/mapper/RenSheJuMapper.java b/src/main/java/com/subsidy/mapper/RenSheJuMapper.java index 02e77b9..580a493 100644 --- a/src/main/java/com/subsidy/mapper/RenSheJuMapper.java +++ b/src/main/java/com/subsidy/mapper/RenSheJuMapper.java @@ -49,8 +49,6 @@ public interface RenSheJuMapper { */ List examActivities(Long classId,Long memberId); - - /** * 某人某天累计在线时长 */ @@ -74,7 +72,7 @@ public interface RenSheJuMapper { /** * 前一天考试通过数据 */ - List dailyExamBasic(); + List dailyExamBasic(String classType); /** * 前一天做过考试通过数据 @@ -100,7 +98,7 @@ public interface RenSheJuMapper { /** * 找到某人当天答疑的记录 */ - List dailyAnswer(); + List dailyAnswer(String classType); /** * 查找前一天做过人脸识别的班级 @@ -127,4 +125,24 @@ public interface RenSheJuMapper { */ List examCheck(Long classId); + /** + * 产生视频数据的班级 + */ + List vodClassIds(String classType); + + /** + * 产生考试数据的班级 + */ + List examClassIds(String classType); + + /** + * 答疑数据的班级 + */ + List answerClassIds(String classType); + + /** + * 产生人脸识别的班级 + */ + List imageClassIds(String classType); + } diff --git a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java index 93e34cd..9331a52 100644 --- a/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java +++ b/src/main/java/com/subsidy/mapper/VodPlayHistoryMapper.java @@ -101,6 +101,12 @@ public interface VodPlayHistoryMapper extends BaseMapper { */ // Long memberLatestRecord(Long memberId); + /** + * 插入一条学习数据 + */ + void insertPlayRecord(Long classId,Long vodId,Long memberId,Integer playLength,Integer suspendLength,Integer playRecord,Integer playCount,Date createDate); + + double getStudyTotal(); double getSubsidyStudyTotal(); diff --git a/src/main/java/com/subsidy/service/DudaoService.java b/src/main/java/com/subsidy/service/DudaoService.java new file mode 100644 index 0000000..1514e01 --- /dev/null +++ b/src/main/java/com/subsidy/service/DudaoService.java @@ -0,0 +1,20 @@ +package com.subsidy.service; + +import com.subsidy.dto.renshe.*; +import com.subsidy.vo.renshe.RensheResponseVO; + +import java.io.IOException; + +public interface DudaoService { + + RensheResponseVO classBaseInfo() throws IOException; + + RensheResponseVO classHourBehavior() throws IOException; + + RensheResponseVO uploadChapterBehavior() throws IOException; + + RensheResponseVO uploadClassAnswerQuestionBehavior()throws IOException; + + RensheResponseVO uploadClassCode()throws IOException; + +} diff --git a/src/main/java/com/subsidy/service/MemberService.java b/src/main/java/com/subsidy/service/MemberService.java index a7c5a17..1d634dd 100644 --- a/src/main/java/com/subsidy/service/MemberService.java +++ b/src/main/java/com/subsidy/service/MemberService.java @@ -79,5 +79,5 @@ public interface MemberService extends IService { PolyvInfoVO polyvInfo(String userid,String channelId,String ts,String token); - String logout(MemberDO memberDO); +// String logout(MemberDO memberDO); } diff --git a/src/main/java/com/subsidy/service/RenSheJuService.java b/src/main/java/com/subsidy/service/RenSheJuService.java index 99a89bd..8e00e96 100644 --- a/src/main/java/com/subsidy/service/RenSheJuService.java +++ b/src/main/java/com/subsidy/service/RenSheJuService.java @@ -1,6 +1,5 @@ package com.subsidy.service; -import com.subsidy.dto.renshe.*; import com.subsidy.vo.renshe.RensheResponseVO; import com.subsidy.vo.renshe.RensheStringVO; diff --git a/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java b/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java index a5f4f87..9143af3 100644 --- a/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/CompanyDictServiceImpl.java @@ -170,7 +170,7 @@ public class CompanyDictServiceImpl extends ServiceImpl epidemicSituationClassBasics = new ArrayList<>(); + + //查找前一天产生数据的班级 + + //看视频 + List vodClassIds = dudaoMapper.vodClassIds("0"); + + //考试 + List examClassIds = dudaoMapper.examClassIds("0"); + + //答疑 + List answerClassIds = dudaoMapper.answerClassIds("0"); + + //人脸识别 + List imageClassIds = dudaoMapper.imageClassIds("0"); + + + Set classIds = new HashSet<>(); + + vodClassIds.stream().forEach(x->classIds.add(x)); + examClassIds.stream().forEach(x->classIds.add(x)); + answerClassIds.stream().forEach(x->classIds.add(x)); + imageClassIds.stream().forEach(x->classIds.add(x)); + + 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(PREFIX_URL + "/classbasicinformation/insertClassBasicInformation") + .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(DudaoConstant.POST_1); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classBaseInfoDTO).toString()); + if (200 == response.code()) { + if (null != rensheResponseVO.getCtt()){ + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + }else { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getMsg()); + } + } else { + renshejuHistoryDO.setOutputParam(DudaoConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + return rensheResponseVO; + } else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(DudaoConstant.POST_1); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classBaseInfoDTO).toString()); + renshejuHistoryDO.setOutputParam(DudaoConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + return null; + } + + } catch (Exception e) { + e.printStackTrace(); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(DudaoConstant.POST_1); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classBaseInfoDTO).toString()); + renshejuHistoryDO.setOutputParam(DudaoConstant.PUSH_FAIL); + renshejuHistoryMapper.insert(renshejuHistoryDO); + } + return null; + } + + public RensheResponseVO classHourBehavior() throws IOException { + + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + MediaType mediaType = MediaType.parse("application/json"); + + ClassHourBehaviorDTO classHourBehaviorDTO = new ClassHourBehaviorDTO(); + + classHourBehaviorDTO.setPrivateKey(getSecret()); + + List classHourBasics = new ArrayList<>(); + try { + //前一天新增视频学习数据的班级并且是普陀的 + List dailyStudyInfoVOS = dudaoMapper.dailyStudyInfo("0"); + 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(i).getCreateDate().toString().replace("T", " "), loginOutRecords.get(i).getCreateDate().toString().replace("T", " ")); + if (chapterList3s.size() > 0) { + 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 (null == dailyActivitiesVO.getAccess() || 0 == dailyActivitiesVO.getAccess()) { + activityList.setAccess(1); + activityList.setErrorInfo(2); + } else { + activityList.setAccess(0); + } + + if (0 == dailyActivitiesVO.getCheckType()) { + activityList.setActivityDetection(2); + } else if (1 == dailyActivitiesVO.getCheckType()) { + activityList.setActivityDetection(1); + } + + activityList.setActivityTime(dailyActivitiesVO.getActivityTime()); + activityLists.add(activityList); + } + classHourBasic.setActivityList(activityLists); + + classHourBasics.add(classHourBasic); + } + classHourBehaviorDTO.setClassHourBasic(classHourBasics); + + System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(classHourBehaviorDTO)); + + if (classHourBasics.size()>0){ + RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(classHourBehaviorDTO).toString()); + + Request request = new Request.Builder() + .url(PREFIX_URL + "/learnduration/insertLearnDuration") + .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(DudaoConstant.POST_2); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + if (200 == response.code()) { + if (null != rensheResponseVO.getCtt()){ + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + }else { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getMsg()); + } + } else { + renshejuHistoryDO.setOutputParam(DudaoConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + return rensheResponseVO; + }else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(DudaoConstant.POST_2); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(DudaoConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + return null; + } +// return null; + } catch (Exception e) { + e.printStackTrace(); + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(DudaoConstant.POST_2); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(DudaoConstant.PUSH_FAIL); + renshejuHistoryMapper.insert(renshejuHistoryDO); + } + return null; + } + + public RensheResponseVO uploadChapterBehavior() throws IOException { + + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + MediaType mediaType = MediaType.parse("application/json"); + + UploadChapterBehaviorDTO uploadChapterBehaviorDTO = new UploadChapterBehaviorDTO(); + + uploadChapterBehaviorDTO.setPrivateKey(getSecret()); + + List chapterExamBasics = new ArrayList<>(); + + //找出前一天产生考试数据的班级 + List classIds = dudaoMapper.dailyExamBasic("0"); + + try { + if (classIds.size() > 0) { + for (Long classId : classIds) { + + //具体哪些人做了 + List 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 activityLists = new ArrayList<>(); + List 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(1); + activityList.setActivityTime(dailyActivitiesVO.getActivityTime()); + activityLists.add(activityList); + } + chapterExamBasic.setActivityList(activityLists); + + + List examLists = new ArrayList<>(); + //上线时间 + List loginRecords = renSheJuMapper.loginRecords(memberDO.getId()); + //下线时间 + List loginOutRecords = renSheJuMapper.loginOutRecords(memberDO.getId()); + + boolean flag = false; + + for (int i = 0; i < loginRecords.size(); i++) { + //找到该时间段内的测评 + List 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); + } + } + + 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(PREFIX_URL + "/examinformation/insertExamInformation") + .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(DudaoConstant.POST_3); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadChapterBehaviorDTO).toString()); + if (200 == response.code()) { + if (null != rensheResponseVO.getCtt()){ + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + }else { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getMsg()); + } + } else { + renshejuHistoryDO.setOutputParam(DudaoConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + } + return rensheResponseVO; + } else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(DudaoConstant.POST_3); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadChapterBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(DudaoConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + return null; + } + } catch (Exception e) { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(DudaoConstant.POST_3); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadChapterBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(DudaoConstant.PUSH_FAIL); + renshejuHistoryMapper.insert(renshejuHistoryDO); + } + return null; + } + + public RensheResponseVO uploadClassAnswerQuestionBehavior() throws IOException { + + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + MediaType mediaType = MediaType.parse("application/json"); + + UploadClassAnswerQuestionBehaviorDTO uploadClassAnswerQuestionBehaviorDTO = new UploadClassAnswerQuestionBehaviorDTO(); + + //秘钥 + uploadClassAnswerQuestionBehaviorDTO.setPrivateKey(getSecret()); + + List dailyAnswerVOS = dudaoMapper.dailyAnswer("0"); + + 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); + } + } + + 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); + } + + 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(PREFIX_URL + "/answertutor/insertAnswerTutor") + .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(DudaoConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassAnswerQuestionBehaviorDTO).toString()); + if (200 == response.code()) { + if (null != rensheResponseVO.getCtt()){ + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + }else { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getMsg()); + } + } else { + renshejuHistoryDO.setOutputParam(DudaoConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + + return rensheResponseVO; + } else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(DudaoConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassAnswerQuestionBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(DudaoConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + return null; + } + } catch (Exception e) { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(DudaoConstant.POST_4); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassAnswerQuestionBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(DudaoConstant.PUSH_FAIL); + renshejuHistoryMapper.insert(renshejuHistoryDO); + } + return null; + } + + public RensheResponseVO uploadClassCode() throws IOException { + + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); + MediaType mediaType = MediaType.parse("application/json"); + + UploadClassCodeDTO uploadClassCodeDTO = new UploadClassCodeDTO(); + + uploadClassCodeDTO.setPrivateKey(getSecret()); + + //所有班级 + List classIds = dudaoMapper.newClasses("0"); + + List classCodeBasics = new ArrayList(); + for (Long classId : classIds) { + ClassCodeBasic classCodeBasic = new ClassCodeBasic(); + ClassDictDO classDictDO = classDictMapper.selectById(classId); + classCodeBasic.setDownCode(String.valueOf(classDictDO.getId())); + classCodeBasic.setClassCode(classDictDO.getClassCode()); + classCodeBasics.add(classCodeBasic); + } + 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(PREFIX_URL + "/bindclass/insertBindClass") + .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(DudaoConstant.POST_5); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassCodeDTO).toString()); + if (200 == response.code()) { + if (null != rensheResponseVO.getCtt()){ + renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); + }else { + renshejuHistoryDO.setOutputParam(rensheResponseVO.getMsg()); + } + } else { + renshejuHistoryDO.setOutputParam(DudaoConstant.API_ERROR); + } + renshejuHistoryMapper.insert(renshejuHistoryDO); + return rensheResponseVO; +// return null; + } catch (Exception e) { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(DudaoConstant.POST_5); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(uploadClassCodeDTO).toString()); + renshejuHistoryDO.setOutputParam(DudaoConstant.PUSH_FAIL); + renshejuHistoryMapper.insert(renshejuHistoryDO); + } + return null; + } + + public String getSecret() throws IOException { + OkHttpClient client = new OkHttpClient().newBuilder() + .build(); +// MediaType mediaType = MediaType.parse("text/plain"); +// RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) +// .addFormDataPart("publicKey", "ykhl65032260") +// .build(); +// Request request = new Request.Builder() +// .url(renSheConfig.getUrl() + "/token/accessPrivateKey") +// .method("POST", body) +// .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") +// .build(); +// Response response = client.newCall(request).execute(); +// GetSecretVO getSecretVO = JSON.parseObject(response.body().string(), GetSecretVO.class); + return "ykhl65032260"; + } + +} diff --git a/src/main/java/com/subsidy/service/impl/ExerciseDictServiceImpl.java b/src/main/java/com/subsidy/service/impl/ExerciseDictServiceImpl.java index 6431213..4452c5a 100644 --- a/src/main/java/com/subsidy/service/impl/ExerciseDictServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/ExerciseDictServiceImpl.java @@ -3,6 +3,7 @@ package com.subsidy.service.impl; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.subsidy.common.exception.HttpException; import com.subsidy.dto.exercise.GetPaperExerciseDTO; import com.subsidy.dto.exercise.SubmitDTO; import com.subsidy.mapper.ExerciseDictMapper; @@ -20,6 +21,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; import java.util.List; /** @@ -39,13 +43,13 @@ public class ExerciseDictServiceImpl extends ServiceImpl memberExerciseVOS = submitDTO.getMemberExerciseVOS(); + SimpleDateFormat startDateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + Date startDate = startDateFormat1.parse(submitDTO.getStartDate()); + + if (new Date().getTime() - startDate.getTime() < 180 * 1000L) { + throw new HttpException(20003); + } + } catch (ParseException e) { + + } + int rightCounts = 0; for (MemberExerciseVO exerciseVO : memberExerciseVOS) { @@ -77,13 +92,12 @@ public class ExerciseDictServiceImpl extends ServiceImpl=60?"合格":"不合格"); + exerciseDoneResultDO.setResult(score >= 60 ? "合格" : "不合格"); exerciseDoneResultMapper.insert(exerciseDoneResultDO); - for (MemberExerciseVO memberExerciseVO : memberExerciseVOS){ + for (MemberExerciseVO memberExerciseVO : memberExerciseVOS) { ExerciseDoneHistoryDO exerciseDoneHistoryDO = new ExerciseDoneHistoryDO(); exerciseDoneHistoryDO.setPaperId(submitDTO.getPaperId()); @@ -116,7 +130,7 @@ public class ExerciseDictServiceImpl extends ServiceImpl getPaperExercise(GetPaperExerciseDTO getPaperExerciseDTO) { Page pager = new Page(getPaperExerciseDTO.getPageNum(), getPaperExerciseDTO.getPageSize()); - return this.baseMapper.getPaperExercise(pager,getPaperExerciseDTO.getPaperId(),getPaperExerciseDTO.getDifficulty(),getPaperExerciseDTO.getExerciseType(),getPaperExerciseDTO.getTitle()); + return this.baseMapper.getPaperExercise(pager, getPaperExerciseDTO.getPaperId(), getPaperExerciseDTO.getDifficulty(), getPaperExerciseDTO.getExerciseType(), getPaperExerciseDTO.getTitle()); } } diff --git a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java index c56674c..e6afec1 100644 --- a/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/MemberServiceImpl.java @@ -41,6 +41,7 @@ import javax.servlet.http.HttpServletRequest; import java.text.SimpleDateFormat; import java.time.Duration; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -92,8 +93,8 @@ public class MemberServiceImpl extends ServiceImpl imple @Autowired private CompanyDictMapper companyDictMapper; - @Autowired - private OprMemDictMapper oprMemDictMapper; +// @Autowired +// private OprMemDictMapper oprMemDictMapper; @Autowired private JobDictMapper jobDictMapper; @@ -128,6 +129,7 @@ public class MemberServiceImpl extends ServiceImpl imple @Autowired private MemberTokensMapper memberTokensMapper; + public IPage getAll(GetAllDTO getAllDTO) { Page pager = new Page(getAllDTO.getPageNum(), getAllDTO.getPageSize()); @@ -302,19 +304,12 @@ public class MemberServiceImpl extends ServiceImpl imple CompanyDictDO companyDictDO = companyDictMapper.selectById(memberDO.getCompanyId()); if ("冻结".equals(memberDO.getStatus())) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - 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); - //redisUtil.set(RedisPrefixConstant.SUBSIDY_MEMBER_LOGIN_PREFIX + memberDO.getId() + ":" + memberDO.getUserName() + ":" + companyDictDO.getCompanyName() + ":" + LocalDateTime.now(), oprMemDictDO); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(10013); } @@ -322,11 +317,9 @@ public class MemberServiceImpl extends ServiceImpl imple if (0 == memberDO.getFirstLogin()) { memberDO.setFirstLogin(1); this.baseMapper.updateById(memberDO); - //redisUtil.set(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + memberDO.getCompanyId() + ":" + memberDO.getAccountName(), memberDO); } BeanUtils.copyProperties(memberDO, userRoleVO); - //String code = redisUtil.get(RedisPrefixConstant.SUBSIDY_TELEPHONE_PREFIX + verifyCodeDTO.getTelephone()).toString(); SmsVerifyCodeDO smsCodeDO = smsVerifyCodeMapper.selectOne(new QueryWrapper() .lambda() .eq(SmsVerifyCodeDO::getTelephone, verifyCodeDTO.getTelephone()) @@ -334,24 +327,24 @@ public class MemberServiceImpl extends ServiceImpl imple .gt(SmsVerifyCodeDO::getCreateDate, LocalDateTime.now().minusMinutes(30L))); if (null == smsCodeDO || !verifyCodeDTO.getVerifyCode().equals(smsCodeDO.getVerifyCode())) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(0); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(70010); } //审计日志 - OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); - if (null == oprMemDictDO || !(oprMemDictDO.getResult() == 1 && "登录".equals(oprMemDictDO.getOprType()))) { - oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(1); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); - } +// OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); +// if (null == oprMemDictDO || !(oprMemDictDO.getResult() == 1 && "登录".equals(oprMemDictDO.getOprType()))) { +// oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(1); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); +// } //mongoTemplate.insert(oprMemDictDO); userRoleVO.setCompanyId(companyDictDO.getId()); userRoleVO.setSuperviseName(companyDictDO.getSuperviseName()); @@ -364,21 +357,17 @@ public class MemberServiceImpl extends ServiceImpl imple userRoleVO.setRotationImgDictDOS(rotationImgDictDOS); String token = JwtUtil.generateToken(memberDO.getId(), ConstantUtils.MOBILE_TERMINATE); - //redisUtil.set(ConstantUtils.MOBILE_TERMINATE + "_" + memberDO.getId(), token); Localstorage.setUser(memberDO); userRoleVO.setToken(token); return userRoleVO; } public MemberVO passwordLogin(PasswordLoginDTO passwordLoginDTO, HttpServletRequest request) { - /** - * 先从redis里查 - */ - //MemberDO memberDO = (MemberDO) redisUtil.get(RedisPrefixConstant.SUBSIDY_COMPANY_MEMBER_PREFIX + passwordLoginDTO.getCompanyId() + ":" + passwordLoginDTO.getAccountName()); + MemberDO memberDO = null; if (null == memberDO) { /** - * redis里没有,从数据库里查 + * 从数据库里查 */ memberDO = this.baseMapper.selectOne(new QueryWrapper() .lambda() @@ -396,15 +385,15 @@ public class MemberServiceImpl extends ServiceImpl imple memberVO.setCompanyId(companyDictDO.getId()); memberVO.setCompanyName(companyDictDO.getCompanyName()); memberVO.setQxyStatus(companyDictDO.getQxyStatus()); - OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); - if (null == oprMemDictDO || !(oprMemDictDO.getResult() == 1 && "登录".equals(oprMemDictDO.getOprType()))) { - oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(1); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); - } +// OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); +// if (null == oprMemDictDO || !(oprMemDictDO.getResult() == 1 && "登录".equals(oprMemDictDO.getOprType()))) { +// 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()); @@ -434,36 +423,22 @@ public class MemberServiceImpl extends ServiceImpl imple return memberVO; } else { if (!memberDO.getPassword().equals(passwordLoginDTO.getPassword())) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - 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.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); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(10016); } if (0 == memberDO.getFirstLogin()) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - 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.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); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(10015); } @@ -495,12 +470,12 @@ public class MemberServiceImpl extends ServiceImpl imple * 时间戳有没有过期 */ if (qingxuetangLoginDTO.getTimestamp() - System.currentTimeMillis() >= 5 * 60 * 1000 || System.currentTimeMillis() - qingxuetangLoginDTO.getTimestamp() >= 5 * 60 * 1000) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(0); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(14002); } @@ -526,48 +501,40 @@ public class MemberServiceImpl extends ServiceImpl imple String result = SecretUtils.getMD5String(preAuthen); if (!qingxuetangLoginDTO.getSign().equals(result)) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(0); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(14001); } CompanyDictDO companyDictDO = companyDictMapper.selectById(memberDO.getCompanyId()); if ("冻结".equals(memberDO.getStatus())) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(0); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); - throw new HttpException(10013); - } - -// //是否登陆过 1:是 0:否 -// if (0 == memberDO.getFirstLogin()) { // OprMemDictDO oprMemDictDO = new OprMemDictDO(); // oprMemDictDO.setUserId(memberDO.getId()); // oprMemDictDO.setOprType("登录"); // oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); // oprMemDictMapper.insert(oprMemDictDO); -// throw new HttpException(10015); -// } + throw new HttpException(10013); + } + + BeanUtils.copyProperties(memberDO, userRoleVO); //审计日志 - OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); - if (null == oprMemDictDO || !(oprMemDictDO.getResult() == 1 && "登录".equals(oprMemDictDO.getOprType()))) { - oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(1); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); - } +// OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); +// if (null == oprMemDictDO || !(oprMemDictDO.getResult() == 1 && "登录".equals(oprMemDictDO.getOprType()))) { +// oprMemDictDO = new OprMemDictDO(); +// 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()); userRoleVO.setCompanyName(companyDictDO.getCompanyName()); @@ -578,7 +545,6 @@ public class MemberServiceImpl extends ServiceImpl imple .eq(RotationImgDictDO::getCompanyId, companyDictDO.getId())); userRoleVO.setRotationImgDictDOS(rotationImgDictDOS); String token = JwtUtil.generateToken(memberDO.getId(), ConstantUtils.MOBILE_TERMINATE); -// redisUtil.set(ConstantUtils.MOBILE_TERMINATE + "_" + memberDO.getId(), token); userRoleVO.setToken(token); return userRoleVO; } @@ -601,12 +567,12 @@ public class MemberServiceImpl extends ServiceImpl imple * 时间戳有没有过期 */ if (qingxuetangLoginDTO.getTimestamp() - System.currentTimeMillis() >= 5 * 60 * 1000 || System.currentTimeMillis() - qingxuetangLoginDTO.getTimestamp() >= 5 * 60 * 1000) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(0); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(14002); } @@ -620,48 +586,39 @@ public class MemberServiceImpl extends ServiceImpl imple String result = SecretUtils.getMD5String(preAuthen); if (!qingxuetangLoginDTO.getSign().equals(result)) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(0); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); throw new HttpException(14001); } CompanyDictDO companyDictDO = companyDictMapper.selectById(memberDO.getCompanyId()); if ("冻结".equals(memberDO.getStatus())) { - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(0); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); - throw new HttpException(10013); - } - -// //是否登陆过 1:是 0:否 -// if (0 == memberDO.getFirstLogin()) { // OprMemDictDO oprMemDictDO = new OprMemDictDO(); // oprMemDictDO.setUserId(memberDO.getId()); // oprMemDictDO.setOprType("登录"); // oprMemDictDO.setResult(0); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); // oprMemDictMapper.insert(oprMemDictDO); -// throw new HttpException(10015); -// } + throw new HttpException(10013); + } + BeanUtils.copyProperties(memberDO, userRoleVO); //审计日志 - OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); - if (null == oprMemDictDO || !(oprMemDictDO.getResult() == 1 && "登录".equals(oprMemDictDO.getOprType()))) { - oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - oprMemDictDO.setResult(1); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); - } +// OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); +// if (null == oprMemDictDO || !(oprMemDictDO.getResult() == 1 && "登录".equals(oprMemDictDO.getOprType()))) { +// oprMemDictDO = new OprMemDictDO(); +// 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()); userRoleVO.setCompanyName(companyDictDO.getCompanyName()); @@ -672,7 +629,6 @@ public class MemberServiceImpl extends ServiceImpl imple .eq(RotationImgDictDO::getCompanyId, companyDictDO.getId())); userRoleVO.setRotationImgDictDOS(rotationImgDictDOS); String token = JwtUtil.generateToken(memberDO.getId(), ConstantUtils.MOBILE_TERMINATE); -// redisUtil.set(ConstantUtils.MOBILE_TERMINATE + "_" + memberDO.getId(), token); userRoleVO.setToken(token); return userRoleVO; } @@ -682,22 +638,22 @@ public class MemberServiceImpl extends ServiceImpl imple CheckStatusVO checkStatusVO = new CheckStatusVO(); MemberDO memberDO1 = this.baseMapper.selectById(memberDO.getId()); - if (StringUtils.isEmpty(memberDO1.getCheckImage())) { - checkStatusVO.setImageStatus(false); - } else { - checkStatusVO.setImageStatus(true); - } - if (memberDO1.getFirstLogin() == 1) { checkStatusVO.setSMSStatus(true); } else { checkStatusVO.setSMSStatus(false); } - if (StringUtils.isEmpty(memberDO1.getIdCardPhoto())) { - checkStatusVO.setIdCardStatus(false); - } else { + Integer count = imageCheckRecordMapper.selectCount(new QueryWrapper() + .lambda() + .eq(ImageCheckRecordDO::getMemberId, memberDO.getId())); + + if (count >0){ checkStatusVO.setIdCardStatus(true); + checkStatusVO.setImageStatus(true); + }else { + checkStatusVO.setImageStatus(false); + checkStatusVO.setIdCardStatus(false); } return checkStatusVO; @@ -1108,13 +1064,13 @@ public class MemberServiceImpl extends ServiceImpl imple this.baseMapper.insert(memberDO); //审计日志 - OprMemDictDO oprMemDictDO = new OprMemDictDO(); - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setOprType("登录"); - //oprMemDictDO.setUserName(memberDO.getUserName()); - oprMemDictDO.setResult(1); - oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); - oprMemDictMapper.insert(oprMemDictDO); +// OprMemDictDO oprMemDictDO = new OprMemDictDO(); +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setOprType("登录"); +// //oprMemDictDO.setUserName(memberDO.getUserName()); +// oprMemDictDO.setResult(1); +// oprMemDictDO.setIpAddress(IpAddressUtil.getIpAddress(request)); +// oprMemDictMapper.insert(oprMemDictDO); CompanyDictDO companyDictDO = companyDictMapper.selectById(registerDTO.getCompanyId()); BeanUtils.copyProperties(memberDO, userRoleVO); @@ -1157,24 +1113,32 @@ public class MemberServiceImpl extends ServiceImpl imple return polyvInfoVO; } - @Transactional(rollbackFor = Exception.class) - public String logout(MemberDO memberDO) { - memberTokensMapper.delete(new QueryWrapper() - .lambda() - .eq(MemberTokensDO::getMemberId, memberDO.getId())); - OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); +// @Transactional(rollbackFor = Exception.class) +// public String logout(MemberDO memberDO) { +// memberTokensMapper.delete(new QueryWrapper() +// .lambda() +// .eq(MemberTokensDO::getMemberId, memberDO.getId())); +// OprMemDictDO oprMemDictDO = oprMemDictMapper.getLatestLoginInfo(memberDO.getId()); +// +// if (null != oprMemDictDO){ +// if (oprMemDictDO.getResult() == 1 && "登出".equals(oprMemDictDO.getOprType())) { +// oprMemDictMapper.deleteById(oprMemDictDO.getId()); +//// oprMemDictMapper.deleteData(oprMemDictDO); +// } +// } +// oprMemDictDO.setUserId(memberDO.getId()); +// oprMemDictDO.setResult(1); +// oprMemDictDO.setOprType("登出"); +// +// DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); +// LocalDateTime time = LocalDateTime.now(); +// String localDateTime = df.format(time); +// LocalDateTime ldt = LocalDateTime.parse(localDateTime, df); +// oprMemDictMapper.insertOrUpdate(oprMemDictDO.getUserId(),oprMemDictDO.getOprType(),oprMemDictDO.getResult(),oprMemDictDO.getIpAddress(),ldt); +// return ConstantUtils.ADD_SUCCESS; +// } + + - if (null != oprMemDictDO){ - if (oprMemDictDO.getResult() == 1 && "登出".equals(oprMemDictDO.getOprType())) { - oprMemDictMapper.deleteById(oprMemDictDO.getId()); -// oprMemDictMapper.deleteData(oprMemDictDO); - } - } - oprMemDictDO.setUserId(memberDO.getId()); - oprMemDictDO.setResult(1); - oprMemDictDO.setOprType("登出"); - oprMemDictMapper.insert(oprMemDictDO); - return ConstantUtils.ADD_SUCCESS; - } } diff --git a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java index f0c4c17..09bbeab 100644 --- a/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/RenSheJuServiceImpl.java @@ -23,9 +23,7 @@ import org.springframework.transaction.annotation.Transactional; import java.io.IOException; import java.sql.Timestamp; import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; +import java.util.*; @Service public class RenSheJuServiceImpl implements RenSheJuService { @@ -59,7 +57,25 @@ public class RenSheJuServiceImpl implements RenSheJuService { List epidemicSituationClassBasics = new ArrayList<>(); //查找前一天产生数据的班级 - List classIds = renSheJuMapper.newClasses("0"); + + //看视频 + List vodClassIds = renSheJuMapper.vodClassIds("0"); + + //考试 + List examClassIds = renSheJuMapper.examClassIds("0"); + + //答疑 + List answerClassIds = renSheJuMapper.answerClassIds("0"); + + //人脸识别 + List imageClassIds = renSheJuMapper.imageClassIds("0"); + + Set classIds = new HashSet<>(); + + vodClassIds.stream().forEach(x->classIds.add(x)); + examClassIds.stream().forEach(x->classIds.add(x)); + answerClassIds.stream().forEach(x->classIds.add(x)); + imageClassIds.stream().forEach(x->classIds.add(x)); try { if (classIds.size() > 0) { @@ -87,26 +103,25 @@ public class RenSheJuServiceImpl implements RenSheJuService { 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; - return null; + 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); @@ -175,11 +190,11 @@ public class RenSheJuServiceImpl implements RenSheJuService { for (DailyActivitiesVO dailyActivitiesVO : activityDetectionDOS) { ActivityList activityList = new ActivityList(); - if (dailyActivitiesVO.getAccess() == 1) { - activityList.setAccess(0); - } else { + if (null == dailyActivitiesVO.getAccess() || 0 == dailyActivitiesVO.getAccess()) { activityList.setAccess(1); activityList.setErrorInfo(2); + } else { + activityList.setAccess(0); } if (0 == dailyActivitiesVO.getCheckType()) { @@ -199,27 +214,36 @@ public class RenSheJuServiceImpl implements RenSheJuService { System.out.println(com.alibaba.fastjson.JSONObject.toJSONString(classHourBehaviorDTO)); - RequestBody body = RequestBody.create(mediaType, JSONObject.fromObject(classHourBehaviorDTO).toString()); + if (classHourBasics.size()>0){ + 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); - 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); + 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; + }else { + RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); + renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_3); + renshejuHistoryDO.setInputParam(JSONObject.fromObject(classHourBehaviorDTO).toString()); + renshejuHistoryDO.setOutputParam(RenSheJuConstant.NO_DATA); + renshejuHistoryMapper.insert(renshejuHistoryDO); + return null; } - renshejuHistoryMapper.insert(renshejuHistoryDO); - return rensheResponseVO; // return null; } catch (Exception e) { e.printStackTrace(); @@ -245,7 +269,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { List chapterExamBasics = new ArrayList<>(); //找出前一天产生考试数据的班级 - List classIds = renSheJuMapper.dailyExamBasic(); + List classIds = renSheJuMapper.dailyExamBasic("0"); try { if (classIds.size() > 0) { @@ -349,7 +373,6 @@ public class RenSheJuServiceImpl implements RenSheJuService { renshejuHistoryMapper.insert(renshejuHistoryDO); } return rensheResponseVO; -// return null; } else { RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_4); @@ -379,7 +402,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { //秘钥 uploadClassAnswerQuestionBehaviorDTO.setPrivateKey(getSecret()); - List dailyAnswerVOS = renSheJuMapper.dailyAnswer(); + List dailyAnswerVOS = renSheJuMapper.dailyAnswer("0"); try { if (dailyAnswerVOS.size() > 0) { @@ -426,7 +449,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { .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()); @@ -438,7 +461,6 @@ public class RenSheJuServiceImpl implements RenSheJuService { renshejuHistoryMapper.insert(renshejuHistoryDO); return rensheResponseVO; -// return null; } else { RenshejuHistoryDO renshejuHistoryDO = new RenshejuHistoryDO(); renshejuHistoryDO.setInterfaceName(RenSheJuConstant.POST_5); @@ -503,7 +525,6 @@ public class RenSheJuServiceImpl implements RenSheJuService { } imageDetailLists.add(imageDetailList); } - } /** @@ -543,7 +564,6 @@ public class RenSheJuServiceImpl implements RenSheJuService { renshejuHistoryDO.setOutputParam(rensheResponseVO.getCtt().toString()); renshejuHistoryMapper.insert(renshejuHistoryDO); rensheResponseVOS.add(rensheResponseVO); - System.out.println(111); } else { RenshejuHistoryDO renshejuHistoryDO1 = new RenshejuHistoryDO(); renshejuHistoryDO1.setInterfaceName(RenSheJuConstant.POST_6); @@ -569,14 +589,14 @@ public class RenSheJuServiceImpl implements RenSheJuService { OkHttpClient client = new OkHttpClient().newBuilder() .build(); - MediaType mediaType = MediaType.parse("text/plain"); - RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) - .addFormDataPart("privateKey", getSecret()) - .build(); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType,"{\"privateKey\":\""+getSecret()+"\"}"); + Request request = new Request.Builder() .url(renSheConfig.getUrl() + "/import/downstream/enterprise/getClassCodeByPrivateKey") .method("POST", body) .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") .build(); try { Response response = client.newCall(request).execute(); @@ -615,9 +635,7 @@ public class RenSheJuServiceImpl implements RenSheJuService { uploadClassCodeDTO.setPrivateKey(getSecret()); //所有班级 -// List classIds = renSheJuMapper.newClasses("0"); - List classIds = new ArrayList(); - classIds.add(404L); + List classIds = renSheJuMapper.newClasses("0"); List classCodeBasics = new ArrayList(); for (Long classId : classIds) { @@ -667,14 +685,13 @@ public class RenSheJuServiceImpl implements RenSheJuService { OkHttpClient client = new OkHttpClient().newBuilder() .build(); - MediaType mediaType = MediaType.parse("text/plain"); - RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) - .addFormDataPart("privateKey", getSecret()) - .build(); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType,"{\"privateKey\":\""+getSecret()+"\"}"); Request request = new Request.Builder() .url(renSheConfig.getUrl() + "/import/downstream/enterprise/getErrorClass") .method("POST", body) .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") .build(); try { Response response = client.newCall(request).execute(); @@ -704,14 +721,14 @@ public class RenSheJuServiceImpl implements RenSheJuService { OkHttpClient client = new OkHttpClient().newBuilder() .build(); -// MediaType mediaType = MediaType.parse("text/plain"); - RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) - .addFormDataPart("privateKey", getSecret()) - .build(); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType,"{\"privateKey\":\""+getSecret()+"\"}"); + Request request = new Request.Builder() .url(renSheConfig.getUrl() + "/import/downstream/enterprise/clear") .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(); RensheStringVO rensheStringVO = JSON.parseObject(response.body().string(), RensheStringVO.class); diff --git a/src/main/java/com/subsidy/service/impl/ShehuihuaServiceImpl.java b/src/main/java/com/subsidy/service/impl/ShehuihuaServiceImpl.java index c1b8ab7..477a9cd 100644 --- a/src/main/java/com/subsidy/service/impl/ShehuihuaServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/ShehuihuaServiceImpl.java @@ -47,14 +47,14 @@ public class ShehuihuaServiceImpl implements ShehuihuaService { OkHttpClient client = new OkHttpClient().newBuilder() .build(); - MediaType mediaType = MediaType.parse("text/plain"); - RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) - .addFormDataPart("privateKey", getSecret()) - .build(); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType,"{\"privateKey\":\""+getSecret()+"\"}"); + Request request = new Request.Builder() .url(renSheConfig.getUrl() + "/import/downstream/social/getClassCodeByPrivateKey") .method("POST", body) .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") .build(); try { Response response = client.newCall(request).execute(); @@ -285,7 +285,7 @@ public class ShehuihuaServiceImpl implements ShehuihuaService { List chapterExamBasics = new ArrayList<>(); //找出前一天产生考试数据的班级 - List classIds = renSheJuMapper.dailyExamBasic(); + List classIds = renSheJuMapper.dailyExamBasic("1"); try { if (classIds.size() > 0) { @@ -419,7 +419,7 @@ public class ShehuihuaServiceImpl implements ShehuihuaService { //秘钥 uploadClassAnswerQuestionBehaviorDTO.setPrivateKey(getSecret()); - List dailyAnswerVOS = renSheJuMapper.dailyAnswer(); + List dailyAnswerVOS = renSheJuMapper.dailyAnswer("1"); try { if (dailyAnswerVOS.size() > 0) { @@ -609,14 +609,13 @@ public class ShehuihuaServiceImpl implements ShehuihuaService { OkHttpClient client = new OkHttpClient().newBuilder() .build(); - MediaType mediaType = MediaType.parse("text/plain"); - RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) - .addFormDataPart("privateKey", getSecret()) - .build(); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType,"{\"privateKey\":\""+getSecret()+"\"}"); Request request = new Request.Builder() .url(renSheConfig.getUrl() + "/import/downstream/social/getErrorClass") .method("POST", body) .addHeader("User-Agent", "Apifox/1.0.0 (https://www.apifox.cn)") + .addHeader("Content-Type", "application/json") .build(); try { Response response = client.newCall(request).execute(); @@ -646,14 +645,13 @@ public class ShehuihuaServiceImpl implements ShehuihuaService { OkHttpClient client = new OkHttpClient().newBuilder() .build(); -// MediaType mediaType = MediaType.parse("text/plain"); - RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM) - .addFormDataPart("privateKey", getSecret()) - .build(); + MediaType mediaType = MediaType.parse("application/json"); + RequestBody body = RequestBody.create(mediaType,"{\"privateKey\":\""+getSecret()+"\"}"); Request request = new Request.Builder() .url(renSheConfig.getUrl() + "/import/downstream/social/clear") .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(); RensheStringVO rensheStringVO = JSON.parseObject(response.body().string(), RensheStringVO.class); diff --git a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java index ae04da0..a62b22a 100644 --- a/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/SignInRecordServiceImpl.java @@ -6,22 +6,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.subsidy.dto.member.GetMemberSignInfoDTO; import com.subsidy.dto.sign.DataViewDTO; -import com.subsidy.mapper.AnsweringQuestionMapper; -import com.subsidy.mapper.ClassDictMapper; -import com.subsidy.mapper.ClassMemberMappingMapper; -import com.subsidy.mapper.ExerciseDoneResultMapper; -import com.subsidy.mapper.SignInRecordMapper; -import com.subsidy.mapper.VodPlayHistoryMapper; -import com.subsidy.model.AnsweringQuestionDO; -import com.subsidy.model.ClassDictDO; -import com.subsidy.model.ClassMemberMappingDO; -import com.subsidy.model.ExerciseDoneResultDO; -import com.subsidy.model.SignInRecordDO; -import com.subsidy.model.VodDictDO; +import com.subsidy.mapper.*; +import com.subsidy.model.*; import com.subsidy.service.SignInRecordService; import com.subsidy.util.ConstantUtils; import com.subsidy.util.DateFormatUtil; import com.subsidy.util.IpAddressUtil; +import com.subsidy.util.RedisUtil; import com.subsidy.vo.member.GetMemberSignInfoVO; import com.subsidy.vo.sign.DataViewVO; import com.subsidy.vo.sign.SignInStatusVO; @@ -54,8 +45,8 @@ public class SignInRecordServiceImpl extends ServiceImpl() .lambda() .eq(SignInRecordDO::getMemberId, getMemberSignInfoDTO.getId()) - .eq(SignInRecordDO::getClassId,getMemberSignInfoDTO.getClassId()) + .eq(SignInRecordDO::getClassId, getMemberSignInfoDTO.getClassId()) .orderByDesc(SignInRecordDO::getCreateDate)); } @Transactional(rollbackFor = Exception.class) public String signIn(SignInRecordDO signInRecordDO, HttpServletRequest request) { - //查看学生所有在读班级 + //查看学生所有在读班级 List classDictDOS = classMemberMappingMapper.getMemberClass(signInRecordDO.getMemberId()); for (ClassDictDO classDictDO : classDictDOS) { - //Set set = redisUtil.scan(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + signInRecordDO.getMemberId() + ":classId:" + signInRecordDO.getClassId() + ":" + DateFormatUtil.format(signInRecordDO.getSignInDate(), "yyyy-MM-dd")+":*"); - //if(set != null && set.size() > 0) { - // redisUtil.del(set); - //} - //redisUtil.set(RedisPrefixConstant.SUBSIDY_SIGN_INFO_PREFIX + signInRecordDO.getMemberId() + ":classId:" + classDictDO.getId() + ":" + DateFormatUtil.format(new Date(), "yyyy-MM-dd") + ":" + System.currentTimeMillis(), null); - // 存储到缓存到同时保存到数据库 SignInRecordDO sign = this.baseMapper.selectOne(new QueryWrapper() .lambda() .eq(SignInRecordDO::getMemberId, signInRecordDO.getMemberId()) .eq(SignInRecordDO::getClassId, classDictDO.getId()) .like(SignInRecordDO::getSignInDate, DateFormatUtil.format(new Date(), "yyyy-MM-dd"))); - if(sign != null) { + if (sign != null) { this.baseMapper.deleteById(sign.getId()); } @@ -109,6 +94,14 @@ public class SignInRecordServiceImpl extends ServiceImpl= vodDictDO.getVodLength()) { i++; } diff --git a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java index bacaf3b..cbb7da3 100644 --- a/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java +++ b/src/main/java/com/subsidy/service/impl/VodPlayHistoryServiceImpl.java @@ -18,6 +18,7 @@ import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -56,11 +57,10 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 8) { //查看系统设定的时长 ClassDictDO classDictDO = classDictMapper.selectOne(new QueryWrapper() @@ -79,22 +79,29 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 5) { - this.baseMapper.insert(vodPlayHistoryDO); + vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() + , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); +// this.baseMapper.insert(vodPlayHistoryDO); } } else { vodPlayHistoryDO.setPlayCount(1); - this.baseMapper.insert(vodPlayHistoryDO); +// this.baseMapper.insert(vodPlayHistoryDO); + vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() + , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); } } else if (classDictDO.getLimitHour() == 0) { vodPlayHistoryDO.setPlayCount(1); - this.baseMapper.insert(vodPlayHistoryDO); + vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() + , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); +// this.baseMapper.insert(vodPlayHistoryDO); } } return ConstantUtils.ADD_SUCCESS; } + @Transactional(rollbackFor = Exception.class) public String insertHistoryNew(InsertHistoryNewDTO insertHistoryNewDTO) { - + Date date = new Date(); if (insertHistoryNewDTO.getPlayLength() > 8) { VodPlayHistoryDO vodPlayHistoryDO = new VodPlayHistoryDO(); BeanUtils.copyProperties(insertHistoryNewDTO, vodPlayHistoryDO); @@ -114,15 +121,21 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl 5) { - this.baseMapper.insert(vodPlayHistoryDO); + vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() + , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); +// this.baseMapper.insert(vodPlayHistoryDO); } } else { vodPlayHistoryDO.setPlayCount(1); - this.baseMapper.insert(vodPlayHistoryDO); + vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() + , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); +// this.baseMapper.insert(vodPlayHistoryDO); } } else if (classDictDO.getLimitHour() == 0) { vodPlayHistoryDO.setPlayCount(1); - this.baseMapper.insert(vodPlayHistoryDO); + vodPlayHistoryMapper.insertPlayRecord(vodPlayHistoryDO.getClassId(), vodPlayHistoryDO.getVodId(), vodPlayHistoryDO.getMemberId(), vodPlayHistoryDO.getPlayLength() + , vodPlayHistoryDO.getSuspendLength(), vodPlayHistoryDO.getPlayRecord(), vodPlayHistoryDO.getPlayCount(), date); +// this.baseMapper.insert(vodPlayHistoryDO); } } return ConstantUtils.ADD_SUCCESS; @@ -620,7 +633,7 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl testPlays(VodPlayHistoryDO vodPlayHistoryDO) { - String classIds = "374,375,376,377,378,379,382,383,384,385,386,387,388,389,390,391,392,393,394,395"; + String classIds = "400"; String[] classIdArr = classIds.split(","); @@ -634,22 +647,22 @@ public class VodPlayHistoryServiceImpl extends ServiceImpl vodPlayStateVO.getStartDate().getTime() && vodPlayStateVO.getPlayLength() >= 3) { + if (vodPlayStateVO1.getEndDate().getTime() > vodPlayStateVO.getStartDate().getTime()) { //这一条数据有问题 -// System.out.println("111111111111111111111" + vodPlayStateVO); + System.out.println("111111111111111111111" + vodPlayStateVO); //查看这个人 这个课程 当天的全部数据 按照createDate升序排序 - List vodPlayHistoryDOS = this.baseMapper.getVodPlayDay(Long.valueOf(classId), classMemberMappingDO.getMemberId(), vodPlayStateVO.getStartDate()); - //从第一条开始看,顺延减去第二条的playlength得到第二条的create_date 以此类推 - for (int l = 0; l < vodPlayHistoryDOS.size() - 1; l++) { - VodPlayHistoryDO vph1 = vodPlayHistoryDOS.get(l); //第一条 - if (l == 0) { - vph1.setPlayDate(vph1.getCreateDate()); - } - VodPlayHistoryDO vph2 = vodPlayHistoryDOS.get(l + 1); //第二条 - LocalDateTime dateTmp = vph1.getPlayDate().plusSeconds(vph2.getPlayLength() + getRandom1_2()); - vph2.setPlayDate(dateTmp); - this.baseMapper.updateById(vph2); - } +// List vodPlayHistoryDOS = this.baseMapper.getVodPlayDay(Long.valueOf(classId), classMemberMappingDO.getMemberId(), vodPlayStateVO.getStartDate()); +// //从第一条开始看,顺延减去第二条的playlength得到第二条的create_date 以此类推 +// for (int l = 0; l < vodPlayHistoryDOS.size() - 1; l++) { +// VodPlayHistoryDO vph1 = vodPlayHistoryDOS.get(l); //第一条 +// if (l == 0) { +// vph1.setPlayDate(vph1.getCreateDate()); +// } +// VodPlayHistoryDO vph2 = vodPlayHistoryDOS.get(l + 1); //第二条 +// LocalDateTime dateTmp = vph1.getPlayDate().plusSeconds(vph2.getPlayLength() + getRandom1_2()); +// vph2.setPlayDate(dateTmp); +// this.baseMapper.updateById(vph2); +// } result.add(vodPlayStateVO.getId()); // break; } diff --git a/src/main/java/com/subsidy/util/DudaoConstant.java b/src/main/java/com/subsidy/util/DudaoConstant.java new file mode 100644 index 0000000..22b77e2 --- /dev/null +++ b/src/main/java/com/subsidy/util/DudaoConstant.java @@ -0,0 +1,49 @@ +package com.subsidy.util; + +public class DudaoConstant { + + /** + * POST-1:班级基本信息信息采集接口 + */ + public static final String POST_1 = "DUDAO_POST_1_insertClassBasicInformation"; + + /** + * POST-2:学时信息采集接口 + */ + public static final String POST_2 = "DUDAO_POST_2_insertLearnDuration"; + + /** + * POST-3:考试信息采集接口 + */ + public static final String POST_3 = "DUDAO_POST_3_insertExamInformation"; + + /** + * POST-4:答疑辅导采集接口 + */ + public static final String POST_4 = "DUDAO_POST_4_insertAnswerTutor"; + + /** + * POST-5 上下游班级数据绑定接口 + */ + public static final String POST_5 = "DUDAO_POST_5_insertBindClass"; + + /** + * 调取失败 + */ + 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/OSSUtils.java b/src/main/java/com/subsidy/util/OSSUtils.java index 1bc6a26..d42c59f 100644 --- a/src/main/java/com/subsidy/util/OSSUtils.java +++ b/src/main/java/com/subsidy/util/OSSUtils.java @@ -17,10 +17,10 @@ import java.util.UUID; public class OSSUtils { // @Value("${aliyun.oss.accessKeyId}") - private static String accessKeyId = "LTAIOrpFKrDqsQ2c"; + private static String accessKeyId = "LTAI5tPAH7P7WQVeowo517BE"; // @Value("${aliyun.oss.accessKeySecret}") - private static String secretAccessKey = "1Qp8huLETbWiBBJvHXJ7MOIhtKuA1G"; + private static String secretAccessKey = "0ueqhIfdAZyw5lWlBVSLpAxTtx37RY"; // @Value("${aliyun.oss.endpoint}") private static String endPoint = "oss-cn-beijing.aliyuncs.com"; diff --git a/src/main/java/com/subsidy/util/SMSUtils.java b/src/main/java/com/subsidy/util/SMSUtils.java index 6a8c408..ccb28ba 100644 --- a/src/main/java/com/subsidy/util/SMSUtils.java +++ b/src/main/java/com/subsidy/util/SMSUtils.java @@ -64,6 +64,7 @@ public class SMSUtils { throw new Exception(sendSmsResponse.getMessage()); } catch (Exception e) { + e.printStackTrace(); throw new HttpException(70011); } } diff --git a/src/main/java/com/subsidy/vo/opr/InsertLastStudyRecordVO.java b/src/main/java/com/subsidy/vo/opr/InsertLastStudyRecordVO.java new file mode 100644 index 0000000..eafdcf9 --- /dev/null +++ b/src/main/java/com/subsidy/vo/opr/InsertLastStudyRecordVO.java @@ -0,0 +1,20 @@ +package com.subsidy.vo.opr; + +import lombok.Data; + +import java.util.Date; + +@Data +public class InsertLastStudyRecordVO { + + private Long id; + + private Long memberId; + + private Date signInDate; + + private String ipAddress; + + private Date mt; + +} diff --git a/src/main/resources/application-prod.properties b/src/main/resources/application-prod.properties index 1e00c44..6f6a815 100644 --- a/src/main/resources/application-prod.properties +++ b/src/main/resources/application-prod.properties @@ -25,9 +25,6 @@ spring.datasource.druid.useGlobalDataSourceStat=true # 控制台日志打印 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl -spring.servlet.multipart.max-file-size=2048KB -spring.servlet.multipart.max-request-size=4098KB - #wechat.appId= wx7785293ff5e31f14 #wechat.appSecret= 25d57cad61fc1b45b3afa46d4c35e8f6 #wechat.msgUrl= https://teachai.youkehulian.com/login @@ -51,4 +48,5 @@ qxueyou.securityKey=44420Tlu-P463-9041-2h1q-29Z59qxy qxueyou.url=https://www.qxueyou.com/auth/user/token renshe.url = https://api.shzypxy.com -renshe.secretKey = 111 \ No newline at end of file +#renshe.url = http://trial.shzypxy.com/api +renshe.secretKey = ad927f0b-6a39-43a7-bac7-163baef1fff7 \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 3287aa3..71c7dba 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -14,6 +14,8 @@ spring.server.compression=on #文件请求大小 spring.server.MaxFileSize=300MB spring.server.MaxRequestSize=500MB +spring.servlet.multipart.max-file-size=100MB +spring.servlet.multipart.max-request-size=50MB # 文件编码 UTF8 spring.mandatory-file-encoding=UTF-8 spring.jackson.time-zone=GMT+8 @@ -40,8 +42,8 @@ spring.cache.ehcache.config=classpath:ehcache.xml # 阿里云短信 sms.product=Dysmsapi sms.domain=dysmsapi.aliyuncs.com -sms.accessKeyId=LTAIOrpFKrDqsQ2c -sms.accessKeySecret=1Qp8huLETbWiBBJvHXJ7MOIhtKuA1G +sms.accessKeyId=LTAI5tPAH7P7WQVeowo517BE +sms.accessKeySecret=0ueqhIfdAZyw5lWlBVSLpAxTtx37RY #wechat.app-id=wx7785293ff5e31f14 #wechat.app-secret=25d57cad61fc1b45b3afa46d4c35e8f6 #wechat.agentId=1000008 diff --git a/src/main/resources/code.properties b/src/main/resources/code.properties index 54021c1..ab9016c 100644 --- a/src/main/resources/code.properties +++ b/src/main/resources/code.properties @@ -73,4 +73,6 @@ meishu.code-message[17001]=系统不支持00:00:00~06:00:00学习 meishu.code-message[18001]=已超过当日验证次数上线 -meishu.code-message[19001]=验证失败 \ No newline at end of file +meishu.code-message[19001]=验证失败 + +meishu.code-message[20003]=提交时间过短,请稍后尝试 \ No newline at end of file diff --git a/src/main/resources/mapper/AdministerMapper.xml b/src/main/resources/mapper/AdministerMapper.xml index 7db7079..fbb939d 100644 --- a/src/main/resources/mapper/AdministerMapper.xml +++ b/src/main/resources/mapper/AdministerMapper.xml @@ -146,6 +146,7 @@ left join company_dict t4 on t2.company_id = t4.id where t.delete_date IS NULL AND t2.delete_date IS NULL + and t3.delete_date IS NULL AND t.class_id = #{classId} and t2.user_name like concat('%',#{userName} ,'%') @@ -184,6 +185,7 @@ WHERE t.delete_date IS NULL AND t2.delete_date IS NULL + and t3.delete_date IS NULL and t2.user_name like concat('%',#{userName} ,'%') @@ -224,10 +226,10 @@ diff --git a/src/main/resources/mapper/DudaoMapper.xml b/src/main/resources/mapper/DudaoMapper.xml new file mode 100644 index 0000000..7125819 --- /dev/null +++ b/src/main/resources/mapper/DudaoMapper.xml @@ -0,0 +1,227 @@ + + + + + + + create_date, + update_date, + delete_date, + id, company_id, cert_id + + + + + + + + + + + + + + + + + + + diff --git a/src/main/resources/mapper/MemberMapper.xml b/src/main/resources/mapper/MemberMapper.xml index 464d2bb..abb2194 100644 --- a/src/main/resources/mapper/MemberMapper.xml +++ b/src/main/resources/mapper/MemberMapper.xml @@ -309,6 +309,7 @@ WHERE t.delete_date IS NULL AND t2.delete_date IS NULL + AND t2.id IS NOT NULL and t.department_id = #{departmentId} and t2.user_name like concat('%',#{userName} ,'%') diff --git a/src/main/resources/mapper/OprAdmDictMapper.xml b/src/main/resources/mapper/OprAdmDictMapper.xml index 1fde4e8..4c8bc7b 100644 --- a/src/main/resources/mapper/OprAdmDictMapper.xml +++ b/src/main/resources/mapper/OprAdmDictMapper.xml @@ -70,7 +70,7 @@ FROM opr_adm_dict WHERE - create_date < (NOW() - INTERVAL 2 DAY) + create_date < (NOW() -interval 1 day) diff --git a/src/main/resources/mapper/OprMemDictMapper.xml b/src/main/resources/mapper/OprMemDictMapper.xml index 5ff33bf..92e8ffd 100644 --- a/src/main/resources/mapper/OprMemDictMapper.xml +++ b/src/main/resources/mapper/OprMemDictMapper.xml @@ -4,12 +4,12 @@ - - - - - - + + + + + + @@ -23,27 +23,27 @@ + - - - - - - - - + + + + + + + + - - - + + + + + + insert into opr_mem_dict(user_id,opr_type,result,ip_address,create_date) + values (#{userId},#{oprType},#{result},#{ipAddress},#{createDate}) + on duplicate key update + user_id=values(user_id), + opr_type=values(opr_type), + result=values(result), + ip_address=values(ip_address), + create_date=values(create_date) + + diff --git a/src/main/resources/mapper/RenSheJuMapper.xml b/src/main/resources/mapper/RenSheJuMapper.xml index 3367358..d336105 100644 --- a/src/main/resources/mapper/RenSheJuMapper.xml +++ b/src/main/resources/mapper/RenSheJuMapper.xml @@ -95,7 +95,7 @@ FROM class_dict t1 WHERE - DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + DATE_FORMAT( DATE_ADD( t1.create_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) AND t1.delete_date IS NULL and t1.class_code is not NULL @@ -123,7 +123,7 @@ FROM vod_play_history t1 WHERE - DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + DATE_FORMAT( DATE_ADD( t1.create_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) AND t1.delete_date IS NULL GROUP BY t1.class_id, @@ -144,7 +144,7 @@ FROM opr_mem_dict t1 WHERE - DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + DATE_FORMAT( DATE_ADD( t1.create_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) AND t1.delete_date IS NULL AND opr_type = "登出" AND result = 1 @@ -158,7 +158,7 @@ FROM opr_mem_dict t1 WHERE - DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + DATE_FORMAT( DATE_ADD( t1.create_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) AND t1.delete_date IS NULL AND opr_type = "登录" AND result = 1 @@ -179,8 +179,9 @@ FROM activity_detection t1 WHERE - DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) - AND t1.delete_date IS NULL + DATE_FORMAT( DATE_ADD( t1.create_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + AND + t1.delete_date IS NULL AND t1.member_id = #{memberId} AND t1.class_id = #{classId} @@ -193,7 +194,7 @@ image_check_record t1 WHERE class_id =#{classId} - AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + 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} @@ -211,7 +212,7 @@ FROM opr_mem_dict t1 WHERE - DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + DATE_FORMAT( DATE_ADD( t1.create_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) AND t1.delete_date IS NULL AND t1.user_id = #{memberId} AND opr_type = "登出" @@ -225,7 +226,7 @@ FROM opr_mem_dict t1 WHERE - DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + DATE_FORMAT( DATE_ADD( t1.create_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) AND t1.delete_date IS NULL AND t1.user_id = #{memberId} AND opr_type = "登录" @@ -235,7 +236,7 @@ SELECT DISTINCT - class_id - FROM - exercise_done_result t1 - WHERE - t1.delete_date IS NULL - AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( - NOW(), - '%Y-%m-%d' - ) + class_id + FROM + exercise_done_result t1 + LEFT JOIN class_dict t2 ON t1.class_id = t2.id + WHERE + t1.delete_date IS NULL + AND t2.class_type = #{classType} + AND DATE_FORMAT( DATE_ADD( t1.create_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( + NOW(), + '%Y-%m-%d' + ) @@ -372,10 +377,11 @@ LEFT JOIN class_dict t2 ON t1.class_id = t2.id LEFT JOIN member t3 ON t1.ask_id = t3.id WHERE - DATE_FORMAT( DATE_ADD( t1.update_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + DATE_FORMAT( DATE_ADD( t1.update_date,interval 1 day), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) AND t1.delete_date IS NULL AND t2.delete_date IS NULL AND t3.delete_date IS NULL + and t2.class_type = #{classType} @@ -451,7 +457,7 @@ WHERE t1.delete_date is null and class_id = #{classId} - AND DATE_FORMAT( DATE_ADD( t1.create_date, INTERVAL 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + 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 and t1.member_id @@ -474,7 +480,7 @@ 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 2 DAY ), '%Y-%m-%d' ) = DATE_FORMAT( NOW(), '%Y-%m-%d' ) + 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 @@ -483,4 +489,82 @@ ORDER BY t1.create_date desc + + + + + + + + diff --git a/src/main/resources/mapper/SignInRecordMapper.xml b/src/main/resources/mapper/SignInRecordMapper.xml index bfa5aa6..99f6940 100644 --- a/src/main/resources/mapper/SignInRecordMapper.xml +++ b/src/main/resources/mapper/SignInRecordMapper.xml @@ -55,7 +55,7 @@ delete_date IS NULL AND date(sign_in_date) = date_sub( curdate(), - INTERVAL 2 DAY) + interval 1 day) diff --git a/src/main/resources/mapper/VodDictMapper.xml b/src/main/resources/mapper/VodDictMapper.xml index 9268fac..3a8574b 100644 --- a/src/main/resources/mapper/VodDictMapper.xml +++ b/src/main/resources/mapper/VodDictMapper.xml @@ -58,7 +58,7 @@ SELECT - DATE_SUB( t1.create_date, INTERVAL t1.play_length SECOND ) AS startDate, + DATE_SUB( t1.create_date, INTERVAL (t1.play_length+t1.suspend_length) SECOND ) AS startDate, t1.create_date AS endDate, - t1.vod_name, + t3.vodName, '视频学习' AS studyType, t1.play_length, IF @@ -262,7 +262,8 @@ t.create_date, t2.vod_name, t.play_length, - t2.vod_length + t2.vod_length, + t.suspend_length FROM vod_play_history t LEFT JOIN vod_dict t2 ON t.vod_id = t2.id @@ -285,6 +286,24 @@ GROUP BY t.vod_id ) t2 ON t1.vod_id = t2.vod_id + LEFT JOIN ( + SELECT + t5.id, + IFNULL( t4.vod_alias_name, t5.vod_name ) AS vodName + FROM + class_dict t1 + LEFT JOIN course_dict t2 ON t1.course_id = t2.id + LEFT JOIN course_content t3 ON t2.id = t3.course_id + LEFT JOIN content_vod_mapping t4 ON t3.id = t4.content_id + LEFT JOIN vod_dict t5 ON t5.id = t4.vod_id + WHERE + t1.id = #{classId} + AND t1.delete_date IS NULL + AND t2.delete_date IS NULL + AND t3.delete_date IS NULL + AND t4.delete_date IS NULL + AND t5.delete_date IS NULL + ) t3 on t2.vod_id = t3.id ORDER BY t1.create_date DESC @@ -293,7 +312,7 @@ SELECT DATE_SUB( t1.create_date, INTERVAL t1.play_length SECOND ) AS startDate, t1.create_date AS endDate, - t1.vod_name, + t3.vodName, '视频学习' AS studyType, t1.play_length, IF @@ -310,7 +329,8 @@ vod_play_history t LEFT JOIN vod_dict t2 ON t.vod_id = t2.id WHERE - t.class_id = #{classId} + t.delete_date is null + and t.class_id = #{classId} AND t.member_id = #{memberId} ) t1 LEFT JOIN ( @@ -321,11 +341,30 @@ vod_play_history t LEFT JOIN vod_dict t2 ON t.vod_id = t2.id WHERE - t.class_id = #{classId} + t.delete_date is null + and t.class_id = #{classId} AND t.member_id = #{memberId} GROUP BY t.vod_id ) t2 ON t1.vod_id = t2.vod_id + LEFT JOIN ( + SELECT + t5.id, + IFNULL( t4.vod_alias_name, t5.vod_name ) AS vodName + FROM + class_dict t1 + LEFT JOIN course_dict t2 ON t1.course_id = t2.id + LEFT JOIN course_content t3 ON t2.id = t3.course_id + LEFT JOIN content_vod_mapping t4 ON t3.id = t4.content_id + LEFT JOIN vod_dict t5 ON t5.id = t4.vod_id + WHERE + t1.id = #{classId} + AND t1.delete_date IS NULL + AND t2.delete_date IS NULL + AND t3.delete_date IS NULL + AND t4.delete_date IS NULL + AND t5.delete_date IS NULL + ) t3 on t2.vod_id = t3.id ORDER BY t1.create_date DESC @@ -366,15 +405,33 @@ SELECT sum( play_length ) -- libgit2 0.25.0