mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 01:46:47 +08:00
Compare commits
343 Commits
SZX-1293-z
...
dev0525
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2ac3a92618 | ||
|
|
c8f113ed32 | ||
|
|
339ee671a1 | ||
|
|
a790b8622e | ||
|
|
dcb70ab705 | ||
|
|
40eebd7e86 | ||
|
|
cefdee3cfc | ||
|
|
0c7f6f0a8d | ||
|
|
f2d6b0cce9 | ||
|
|
44ffc93310 | ||
|
|
3890ad04b9 | ||
|
|
1039af40db | ||
|
|
efcee67fe1 | ||
|
|
284207fb5b | ||
|
|
20c05afda9 | ||
|
|
1eca154b02 | ||
|
|
3ebd110f1c | ||
|
|
18614bae7a | ||
|
|
e508c546fa | ||
|
|
8bdd69ca60 | ||
|
|
336283dae3 | ||
|
|
0b4cd71cd1 | ||
|
|
cc385f32aa | ||
|
|
c02c9246b3 | ||
|
|
0988145ac3 | ||
|
|
9e3183b93d | ||
|
|
3d6e97cba8 | ||
|
|
f82dfb7402 | ||
|
|
6e6ce7b323 | ||
|
|
ff43f046d0 | ||
|
|
0f5727bc0d | ||
|
|
6a9deb1bac | ||
|
|
4a26209008 | ||
|
|
4ac7acb033 | ||
|
|
350921dbe6 | ||
|
|
2e596e1e9a | ||
|
|
2c967cef0a | ||
|
|
3c674317c3 | ||
|
|
9461c692e2 | ||
|
|
580e5bd100 | ||
|
|
7eda4f8a7c | ||
|
|
8627a72d91 | ||
|
|
a6bcc50f16 | ||
|
|
0d95b756a6 | ||
|
|
f852674994 | ||
|
|
3a5b13dfe8 | ||
|
|
e4adadcdbf | ||
|
|
29a17efd44 | ||
|
|
b40391ba6a | ||
|
|
d1e9b53625 | ||
|
|
24894444f6 | ||
|
|
48ac060ab2 | ||
|
|
0e8f8b1cb7 | ||
|
|
a6336b2bf2 | ||
|
|
323aca88da | ||
|
|
b5b17f9b86 | ||
|
|
44c87232eb | ||
|
|
70d81ebca8 | ||
|
|
aa50cd64fd | ||
|
|
a0976e48a8 | ||
|
|
f049759428 | ||
|
|
1fbf56dec3 | ||
|
|
e60e110ab4 | ||
|
|
f8452e4702 | ||
|
|
d976e37bc5 | ||
|
|
bedc922585 | ||
|
|
2d223c5f1f | ||
|
|
9758ef056c | ||
|
|
bb894c996c | ||
|
|
8db557a8f6 | ||
|
|
f19b24641e | ||
|
|
67d34224e3 | ||
|
|
74f51601d3 | ||
|
|
d24df7e30a | ||
|
|
708eeade22 | ||
|
|
695ec18b04 | ||
|
|
a06a353c68 | ||
|
|
05629b721d | ||
|
|
a8a31d7d86 | ||
|
|
b9bcf02484 | ||
|
|
77e347f8d4 | ||
|
|
3b0435f246 | ||
|
|
93ad2f4693 | ||
|
|
58c05e7e47 | ||
|
|
f8949af69f | ||
|
|
3f0a32de14 | ||
|
|
903a1369f5 | ||
|
|
0fcd4568ec | ||
|
|
45fce7927d | ||
|
|
5070be0620 | ||
|
|
616594af9e | ||
|
|
a1e0918aec | ||
|
|
94c63a8907 | ||
|
|
4ff47085b8 | ||
|
|
b7e8c43b5f | ||
|
|
b5bee5a6a4 | ||
|
|
d467e0974d | ||
|
|
aa5495dbfe | ||
|
|
5ef57add02 | ||
|
|
f6c61534aa | ||
|
|
9d0cf1a988 | ||
|
|
4a187a4c18 | ||
|
|
4c36a29ee7 | ||
|
|
7321f7de6c | ||
|
|
7be0acf350 | ||
|
|
87892fe8ef | ||
|
|
a0c891cd35 | ||
|
|
6e805590b8 | ||
|
|
33ebd209ff | ||
|
|
27b863a6a4 | ||
|
|
7569c95241 | ||
|
|
484a7650dd | ||
|
|
07d0578edc | ||
|
|
5430c149e1 | ||
|
|
42c953f05a | ||
|
|
bcb453b2f4 | ||
|
|
5236f13c14 | ||
|
|
4e7b4e4a51 | ||
|
|
fe1a59359d | ||
|
|
6a3cbf290a | ||
|
|
65e1e752d0 | ||
|
|
389dff8fbe | ||
|
|
ba62bc6403 | ||
|
|
21e780c589 | ||
|
|
89060ad3d9 | ||
|
|
0e7e11b3f1 | ||
|
|
a13ad69e1f | ||
|
|
3973cb1421 | ||
|
|
a9be34631a | ||
|
|
d7d9a3c2c9 | ||
|
|
7e3a3a5838 | ||
|
|
b0321d4f28 | ||
|
|
21e12c815b | ||
|
|
4e7661530c | ||
|
|
cdd6879aee | ||
|
|
7a9859cf9c | ||
|
|
eb70c7a985 | ||
|
|
f79a159e22 | ||
|
|
0556fce863 | ||
|
|
becebadfe0 | ||
|
|
2a78c13abb | ||
|
|
b9c4503aaa | ||
|
|
50745e8398 | ||
|
|
860fb3f27c | ||
|
|
036df70e83 | ||
|
|
294949f4e5 | ||
|
|
55b35db9a9 | ||
|
|
9b8487b0ca | ||
|
|
2f1983d76b | ||
|
|
c607d35281 | ||
|
|
e508551043 | ||
|
|
f6e5d7539d | ||
|
|
3e0a6d4487 | ||
|
|
8dffbfda04 | ||
|
|
5387a90f3a | ||
|
|
da103bde52 | ||
|
|
5116c1ebc5 | ||
|
|
92b302316b | ||
|
|
29ca9d61f9 | ||
|
|
c973bd1573 | ||
|
|
fc34ab91ce | ||
|
|
f901a2897f | ||
|
|
e8b95bcd5a | ||
|
|
914b06bc77 | ||
|
|
450693cdad | ||
|
|
41c1321769 | ||
|
|
653a617912 | ||
|
|
973c6fb9f5 | ||
|
|
c1da0a2d05 | ||
|
|
fc7d3d00b9 | ||
|
|
84ee2fd916 | ||
|
|
d2a7fe07da | ||
|
|
ce6730dd2d | ||
|
|
d71f098e91 | ||
|
|
aa3be9c091 | ||
|
|
08acab350e | ||
|
|
1cd0fd1ba0 | ||
|
|
7887736fb2 | ||
|
|
5d31baa027 | ||
|
|
d0ec40a947 | ||
|
|
8a0d0219a5 | ||
|
|
4620f85eba | ||
|
|
73b198af4c | ||
|
|
68ea50b1f3 | ||
|
|
386afebce4 | ||
|
|
9bec1afacf | ||
|
|
dd68754a1e | ||
|
|
6aae7ac070 | ||
|
|
b81bdc7179 | ||
|
|
de6c405af4 | ||
|
|
275cc76f55 | ||
|
|
dba0386bcd | ||
|
|
290417534c | ||
|
|
db6febcd54 | ||
|
|
16239a68dc | ||
|
|
1be244e483 | ||
|
|
c25fd9c384 | ||
|
|
e0b0516ae0 | ||
|
|
897a44e2c3 | ||
|
|
802130aa75 | ||
|
|
c72f3eb640 | ||
|
|
1df65fce85 | ||
|
|
529fb59167 | ||
|
|
262463bb7f | ||
|
|
a019726181 | ||
|
|
4e08676639 | ||
|
|
3b34cc1bde | ||
|
|
c7f4f9fc01 | ||
|
|
be18e35583 | ||
|
|
ae3a56891c | ||
|
|
bd25fc1d1a | ||
|
|
b049aa81f5 | ||
|
|
91b0b899b0 | ||
|
|
85753b7261 | ||
|
|
983313e845 | ||
|
|
a71b6232cb | ||
|
|
f4c1bd7eed | ||
|
|
ef40c39749 | ||
|
|
0ac6622526 | ||
|
|
6924744c07 | ||
|
|
00fa85add2 | ||
|
|
9a83f64e38 | ||
|
|
aab518b522 | ||
|
|
20484a83da | ||
|
|
3116bed63c | ||
|
|
45d5233448 | ||
|
|
1f2fa21c93 | ||
|
|
26a2a8e709 | ||
|
|
b219a46a74 | ||
|
|
d90f4d883f | ||
|
|
43d99828e6 | ||
|
|
901638dea9 | ||
|
|
532a502cf1 | ||
|
|
170dc45c64 | ||
|
|
5594e07264 | ||
|
|
e868833696 | ||
|
|
13b5e6ab4c | ||
|
|
d0944b05e0 | ||
|
|
e144fde444 | ||
|
|
0cdbdfbb30 | ||
|
|
439737f9a5 | ||
|
|
88158e7ebf | ||
|
|
4e870985a8 | ||
|
|
973afb94b4 | ||
|
|
da566414eb | ||
|
|
e69ab94c8c | ||
|
|
9aa852e56f | ||
|
|
42040f023d | ||
|
|
e7b6d08802 | ||
|
|
ddf846fe2f | ||
|
|
ebaf8e09d3 | ||
|
|
1f2a07efb3 | ||
|
|
cdccb6f0ef | ||
|
|
4c1c19c364 | ||
|
|
f6e167e024 | ||
|
|
7287c6d7b8 | ||
|
|
6749aaa594 | ||
|
|
ac552d5452 | ||
|
|
c9dbc8a622 | ||
|
|
559f525450 | ||
|
|
7e2b3506c6 | ||
|
|
7aa30aff77 | ||
|
|
d2f323bb38 | ||
|
|
e57a02bf87 | ||
|
|
2b63fe1db6 | ||
|
|
49f920e730 | ||
|
|
8d3eed6603 | ||
|
|
2adb039a82 | ||
|
|
5bd71c539b | ||
|
|
332aa68960 | ||
|
|
4fdd7b1352 | ||
|
|
cb7bedf353 | ||
|
|
a4f260b99a | ||
|
|
745e2299e5 | ||
|
|
2ebb945198 | ||
|
|
de7d26f447 | ||
|
|
a6b9fb8da2 | ||
|
|
8868d3771b | ||
|
|
e2e0aeb9cb | ||
|
|
2fb3cf28e6 | ||
|
|
340091b916 | ||
|
|
f1a92fd371 | ||
|
|
b934c71e3a | ||
|
|
7217348ae9 | ||
|
|
3d5c9620f7 | ||
|
|
bcdc784e7d | ||
|
|
21b990898d | ||
|
|
7c4a6feb78 | ||
|
|
77c8991d13 | ||
|
|
aa245e52c6 | ||
|
|
43950ccff3 | ||
|
|
83458c030b | ||
|
|
13af22baea | ||
|
|
f610b0725c | ||
|
|
805f40f6d6 | ||
|
|
e72edb9c77 | ||
|
|
f4d00c7ad4 | ||
|
|
9fb1b432ee | ||
|
|
d47669b3ea | ||
|
|
ec8ffcb947 | ||
|
|
105d29b754 | ||
|
|
a227cb96d2 | ||
|
|
b2ff1a208d | ||
|
|
76aa90a0ce | ||
|
|
7168452b0d | ||
|
|
4b4f3b9620 | ||
|
|
72f033a769 | ||
|
|
9deeed5764 | ||
|
|
1bd4764eee | ||
|
|
7f2c57099b | ||
|
|
16b6c419ab | ||
|
|
726fc2e684 | ||
|
|
cc1900f907 | ||
|
|
61caaa6b12 | ||
|
|
4c1afd1130 | ||
|
|
58e694aaf1 | ||
|
|
eb0184762a | ||
|
|
b595800344 | ||
|
|
85eb11c30a | ||
|
|
5f223d9183 | ||
|
|
b74141a036 | ||
|
|
c7841adcaa | ||
|
|
9f0a926841 | ||
|
|
dc3e47ec15 | ||
|
|
3acf58e8d4 | ||
|
|
2ff595062c | ||
|
|
0b3c6b057e | ||
|
|
56866a51df | ||
|
|
c1e45afbca | ||
|
|
219b406e8a | ||
|
|
06d14582cc | ||
|
|
08763593cd | ||
|
|
5f1f3ebf9f | ||
|
|
c66c6369c6 | ||
|
|
402015f5b1 | ||
|
|
f61c7ed83f | ||
|
|
8e3231b506 | ||
|
|
1c3a70bc12 | ||
|
|
a62c39b13c | ||
|
|
189a47d4d0 | ||
|
|
0c98dbef06 | ||
|
|
bdfb400ad6 | ||
|
|
858704a3d0 |
@@ -84,7 +84,6 @@
|
||||
<artifactId>xboe-module-es</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>it.sauronsoftware</groupId>
|
||||
<artifactId>jave</artifactId>
|
||||
|
||||
@@ -34,6 +34,8 @@ public class UrlSecurityFilterImpl implements IUrlSecurityFilter{
|
||||
noLoginUrls.add("/xboe/m/exam/alone-extend/save");
|
||||
|
||||
noLoginUrls.add("/xboe/m/course/manage/test");
|
||||
// 暂时取消验证 todo by yyk
|
||||
noLoginUrls.add("/xboe/m/course/manage/getCourseCoverUrl");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -4,25 +4,35 @@ import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.GsonBuilder;
|
||||
import com.xboe.api.vo.*;
|
||||
import com.xboe.module.course.vo.StudyCourseVo;
|
||||
import com.xboe.module.course.vo.TeacherInfoVo;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.module.dict.entity.DictDto;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.module.exam.entity.ExamTest;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.system.user.dao.UserDao;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ThirdApi {
|
||||
@@ -63,9 +73,16 @@ public class ThirdApi {
|
||||
|
||||
@Value("${manageApi.editExam}")
|
||||
private String editExam;
|
||||
|
||||
@Value("${userBasic.getUserIdByWorkNum}")
|
||||
private String getUserIdByWorkNum;
|
||||
|
||||
@Value("${coursesuilt.syncExamScoreToCourseSuite}")
|
||||
private String syncExamScoreToCourseSuite;
|
||||
|
||||
//获取例外人员的id
|
||||
public List<String> getUserId(){
|
||||
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=316&type=1").execute() //prod 316
|
||||
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=136&type=1").execute() //prod 316
|
||||
.body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
log.info("正在获取例外人员工号 responseBody = " + responseBody);
|
||||
try {
|
||||
@@ -215,6 +232,7 @@ public class ThirdApi {
|
||||
Opt.ofBlankAble(resp).map(t -> JSONUtil.toBean(t, DynamicBean.class).success());
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
String token = "eyJ0eXBlIjoidG9rZW4iLCJhbGciOiJIUzI1NiJ9.eyJjb21wYW55Q29kZSI6IkMwMDEiLCJ1SWQiOiI5NjUzNDIwMjc0OTc2MDcxNjgiLCJjb21wYW55SWQiOiIxMDQxNjczOTc3Mzc5OTQ2NDk2IiwibG9naW5JZCI6IjE2ODg0NDg5MjIwNzY0OTE3NzgiLCJpc3MiOiJodHRwOi8vdS5ib2UuY29tIiwiR2l2ZW5OYW1lIjoiYm9ldSIsImV4cCI6MTY5MTM5OTc2NzU1OCwidXNlck5hbWUiOiLmnY7njonlhrAiLCJ1c2VySWQiOiI2QjA0OUZBRi1DMzE0LTdDQ0YtMEQyOC0wRDIzRjRDNDI1MzEifQ==.8b52dcf4d48a790ed258b9ca2b279bb269f5301722095382fbd352705b51c893";
|
||||
String resp = Optional.ofNullable(HttpRequest.post("https://u-pre.boe.com/statApi/xboe/m/stat/userdynamic/list").body(JSONUtil.toJsonStr(UserdynamicParam.builder().
|
||||
@@ -226,10 +244,76 @@ public class ThirdApi {
|
||||
List<UserDynamic> list = a.getResult().getList();
|
||||
System.out.println(" list = " +list.size());
|
||||
System.out.println(" list = " +list);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public HashMap<String, String> getUserIdByWorkNum(String token, List<String> workNumList) {
|
||||
// 将workNum列表转换为逗号分隔的字符串
|
||||
String workNums = workNumList.stream()
|
||||
.collect(Collectors.joining(","));
|
||||
// 构建请求URL
|
||||
String url = getUserIdByWorkNum+"?workNums=" + workNums;
|
||||
String respStr = Optional.ofNullable(
|
||||
HttpRequest.get(url)
|
||||
.header("token", token)
|
||||
.execute().body()
|
||||
).orElseThrow(() -> new RuntimeException("Token校验失败"));
|
||||
// 解析JSON字符串为HashMap
|
||||
GetUserIdByWorkNumResult getUserIdByWorkNumResult = JSONUtil.parseObj(respStr).toBean(GetUserIdByWorkNumResult.class);
|
||||
HashMap<String, String> result = getUserIdByWorkNumResult.getResult();
|
||||
return result;
|
||||
}
|
||||
|
||||
public void syncExamScoreToCourseSuite(AloneExam aloneExam,String token) {
|
||||
Gson gson = new GsonBuilder()
|
||||
.registerTypeAdapter(LocalDateTime.class, new LocalDateTimeSerializer())
|
||||
.create();
|
||||
|
||||
String json = gson.toJson(aloneExam);
|
||||
String resp = HttpRequest.post(syncExamScoreToCourseSuite)
|
||||
.body(json)
|
||||
.header("token", token)
|
||||
.execute()
|
||||
.body();
|
||||
|
||||
if (StringUtils.isBlank(resp)){
|
||||
return;
|
||||
}
|
||||
JSONUtil.toBean(resp, SyncExamScoreBean.class).success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取案例浏览记录
|
||||
*/
|
||||
public UserDynamicResult getAllUserdynamicListOfCaseRead(UserdynamicParam userdynamicParam, String token) {
|
||||
String s = buildFormData(userdynamicParam);
|
||||
String resp = Optional.ofNullable(HttpRequest
|
||||
.post(userdynamicListUrl)
|
||||
.header("Content-Type", "application/x-www-form-urlencoded")
|
||||
.body(s)
|
||||
.header("XBOE-Access-Token", token)
|
||||
.execute().body()).orElseThrow(() -> new RuntimeException("token校验失败"));
|
||||
|
||||
DynamicBean dynamicBean = JSONUtil.toBean(resp, DynamicBean.class);
|
||||
UserDynamicResult userdynamicResult = dynamicBean.getResult();
|
||||
return userdynamicResult;
|
||||
}
|
||||
|
||||
private String buildFormData(UserdynamicParam param) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
try {
|
||||
builder.append("pageIndex=").append(URLEncoder.encode(param.getPageIndex().toString(), "UTF-8"));
|
||||
|
||||
builder.append("&pageSize=").append(URLEncoder.encode(param.getPageSize().toString(), "UTF-8"));
|
||||
builder.append("&contentType=").append(URLEncoder.encode(param.getContentType().toString(), "UTF-8"));
|
||||
builder.append("&aid=").append(URLEncoder.encode(param.getAid().toString(), "UTF-8"));
|
||||
builder.append("&eventKey=").append(URLEncoder.encode("ReadCase", "UTF-8"));
|
||||
if (param.getHidden() != null) {
|
||||
builder.append("&hidden=").append(URLEncoder.encode(param.getHidden(), "UTF-8"));
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.xboe.api.vo;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class CheckExamBandingBean {
|
||||
|
||||
private boolean show;
|
||||
private String version;
|
||||
private int code;
|
||||
private String msg;
|
||||
private Object data;
|
||||
private boolean success;
|
||||
|
||||
public CheckExamBandingBean success() {
|
||||
if (this.code!=200) {
|
||||
log.error("获取绑定关系失败----{}", JSONUtil.toJsonPrettyStr(this));
|
||||
return null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.xboe.api.vo;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.module.exam.dto.ExamTestDto;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
public class GetExamSyncResult {
|
||||
private String error;
|
||||
private String message;
|
||||
private String permissions;
|
||||
private List<AloneExam> result;
|
||||
private int status;
|
||||
private Date timestamp;
|
||||
|
||||
public GetExamSyncResult success() {
|
||||
if (this.status != 200) {
|
||||
log.error("同步考试记录失败----{}", JSONUtil.toJsonPrettyStr(this));
|
||||
return null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.xboe.api.vo;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Auto-generated: 2022-12-10 14:3:18
|
||||
*
|
||||
* @author bejson.com (i@bejson.com)
|
||||
* @website http://www.bejson.com/java2pojo/
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class GetUserIdByWorkNumResult {
|
||||
|
||||
private String error;
|
||||
private String message;
|
||||
private String permissions;
|
||||
private HashMap<String,String> result;
|
||||
private int status;
|
||||
private Date timestamp;
|
||||
|
||||
public GetUserIdByWorkNumResult success() {
|
||||
if (this.status != 200) {
|
||||
log.error("获取用户ID列表失败----{}", JSONUtil.toJsonPrettyStr(this));
|
||||
return null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.xboe.api.vo;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonElement;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonPrimitive;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonSerializationContext;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonSerializer;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class LocalDateTimeSerializer implements JsonSerializer<LocalDateTime> {
|
||||
private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public JsonElement serialize(LocalDateTime src, Type typeOfSrc, JsonSerializationContext context) {
|
||||
return new JsonPrimitive(formatter.format(src));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xboe.api.vo;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Data
|
||||
@Slf4j
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SyncExamScoreBean {
|
||||
|
||||
private boolean show;
|
||||
private String version;
|
||||
private int code;
|
||||
private String msg;
|
||||
private Object data;
|
||||
private boolean success;
|
||||
|
||||
public SyncExamScoreBean success() {
|
||||
if (this.code!=200) {
|
||||
log.error("同步考试到boe库失败----{}", JSONUtil.toJsonPrettyStr(this));
|
||||
return null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -133,4 +133,26 @@ public interface CacheName {
|
||||
* 字典缓存key
|
||||
* */
|
||||
String KEY_DICT="dict";
|
||||
|
||||
/**
|
||||
* 季度观看量排行key
|
||||
* */
|
||||
String CASE_RANK_VIEWS_QUARTER="case:rank:views:quarter";
|
||||
|
||||
/**
|
||||
* 总观看排行key
|
||||
* */
|
||||
String CASE_RANK_VIEWS_ALL="case:rank:views:all";
|
||||
|
||||
/**
|
||||
* 季度点赞排行key
|
||||
* */
|
||||
String CASE_RANK_PRAISE_QUARTER ="case:rank:praise:quarter";
|
||||
|
||||
/**
|
||||
* 总点赞排行key
|
||||
* */
|
||||
String CASE_RANK_PRAISE_ALL="case:rank:praise:all";
|
||||
|
||||
String STUDY_KEY = "StudyKey:";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.xboe.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import static com.xboe.constants.CacheName.*;
|
||||
|
||||
/**
|
||||
* 案例排行榜类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum CasesRankEnum {
|
||||
|
||||
QUARTER_VIEWS(1,"季度观看量排行",CASE_RANK_VIEWS_QUARTER),
|
||||
ALL_VIEWS(2,"总观看排行",CASE_RANK_VIEWS_ALL),
|
||||
QUARTER_PRAISES(3,"季度点赞排行",CASE_RANK_PRAISE_QUARTER),
|
||||
ALL_PRAISES(4,"总点赞排行",CASE_RANK_PRAISE_ALL),
|
||||
;
|
||||
|
||||
private Integer type;
|
||||
private String name;
|
||||
private String cacheKey;
|
||||
|
||||
|
||||
}
|
||||
@@ -11,18 +11,14 @@ import com.xboe.module.boecase.dao.CasesMajorTypeDao;
|
||||
import com.xboe.module.boecase.dto.*;
|
||||
import com.xboe.module.boecase.entity.CasesMajorType;
|
||||
import com.xboe.module.boecase.service.ICasesRecommendPushRecordService;
|
||||
import com.xboe.module.boecase.vo.CaseExportVo;
|
||||
import com.xboe.module.boecase.vo.*;
|
||||
import com.xboe.module.dict.entity.DictItem;
|
||||
import com.xboe.module.excel.ExportsExcelSenderUtil;
|
||||
|
||||
import com.xboe.system.user.dao.UserDao;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
@@ -39,6 +35,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -127,25 +124,12 @@ public class CasesApi extends ApiBaseController {
|
||||
@PostMapping("/queryListV2")
|
||||
public JsonResponse<PageList<Cases>> queryCaseBreV2(@Validated @RequestBody CasePageVo req) {
|
||||
String type = req.getType();
|
||||
PageList<Cases> subViews1;
|
||||
PageList<Cases> subViews2;
|
||||
PageList<Cases> views = null;
|
||||
req.setUserId(getCurrent().getAccountId());
|
||||
if (StringUtils.isNotEmpty(type)) {
|
||||
if ("recommend".equals(type)) {
|
||||
views = casesService.queryRecommendPageCasesV2(req);
|
||||
} else {
|
||||
views = casesService.queryPageCasesV2(req);
|
||||
}
|
||||
PageList<Cases> views = null;
|
||||
if (type.equals("recommend")) {
|
||||
views = casesService.queryRecommendPageCasesV2(req);
|
||||
} else {
|
||||
PageDto pageDto = new PageDto();
|
||||
pageDto.setPageIndex(req.getPageIndex());
|
||||
pageDto.setPageSize(req.getPageSize());
|
||||
req.setPageSize(1000000);
|
||||
req.setPageIndex(1);
|
||||
subViews1 = casesService.queryRecommendPageCasesV2(req);
|
||||
subViews2 = casesService.queryPageCasesV2(req);
|
||||
views = merge(subViews1, subViews2, pageDto);
|
||||
views = casesService.queryPageCasesV2(req);
|
||||
}
|
||||
|
||||
if (views != null) {
|
||||
@@ -175,24 +159,6 @@ public class CasesApi extends ApiBaseController {
|
||||
return success(views);
|
||||
}
|
||||
|
||||
public static PageList<Cases> merge(PageList<Cases> pageList1, PageList<Cases> pageList2, PageDto pageDto) {
|
||||
List<Cases> mergedCaseList = new ArrayList<>();
|
||||
mergedCaseList.addAll(pageList1.getList());
|
||||
mergedCaseList.addAll(pageList2.getList());
|
||||
List<Cases> pageCaseList = mergedCaseList.stream()
|
||||
.skip((long) (pageDto.getPageIndex() - 1) * pageDto.getPageSize())
|
||||
.limit(pageDto.getPageSize())
|
||||
.collect(Collectors.toList());
|
||||
int totalCount = pageList1.getCount() + pageList2.getCount();
|
||||
int pageSize = pageDto.getPageSize();
|
||||
|
||||
PageList<Cases> mergePageList = new PageList<>();
|
||||
mergePageList.setList(pageCaseList);
|
||||
mergePageList.setCount(totalCount);
|
||||
mergePageList.setPageSize(pageSize);
|
||||
return mergePageList;
|
||||
}
|
||||
|
||||
@PostMapping("/caseYears")
|
||||
public JsonResponse<List<String>> caseYears() {
|
||||
List<String> result = casesService.getCaseYears();
|
||||
@@ -646,7 +612,8 @@ public class CasesApi extends ApiBaseController {
|
||||
if (ids.isEmpty()) {
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
List<Cases> cases = casesService.ids(ids);
|
||||
String accountId = getCurrent().getAccountId();
|
||||
List<Cases> cases = casesService.ids(ids,accountId);
|
||||
return success(cases);
|
||||
}
|
||||
|
||||
@@ -654,7 +621,7 @@ public class CasesApi extends ApiBaseController {
|
||||
* 设置/取消优秀案例
|
||||
*/
|
||||
@PostMapping("/excellent")
|
||||
public JsonResponse<Boolean> excellent(String id, Boolean excellent) {
|
||||
public JsonResponse<Boolean> excellent(String id, Boolean excellent,String excellentReason) {
|
||||
if (StringUtil.isBlank(id)) {
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
@@ -662,12 +629,145 @@ public class CasesApi extends ApiBaseController {
|
||||
excellent = false;//默认设置取消
|
||||
}
|
||||
try {
|
||||
casesService.excellent(id, excellent);
|
||||
casesService.excellent(id, excellent,excellentReason);
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
return error("设置或者取消失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 不同专业分类下排行榜刷新
|
||||
* 注意!!!定时统计任务是在本月月初执行的,而上榜时间是在上个月最后一天23:59:59
|
||||
*/
|
||||
@PostMapping("/refreshViewsRankOfMajor")
|
||||
public JsonResponse<Boolean> refreshViewsRankOfMajor() {
|
||||
casesService.refreshViewsRankOfMajor();
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@PostMapping("/refreshLastQuarterStatistics")
|
||||
public JsonResponse<Boolean> refreshLastQuarterStatistics() {
|
||||
casesService.refreshLastQuarterStatistics();
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 热度榜(当前季度、总榜) 按观看量排行
|
||||
* @param pageSize
|
||||
* @param rankType 1:当前季度,2:总榜
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@GetMapping("/queryPopularity")
|
||||
public JsonResponse<List<CaseRankingVo>> queryPopularity(@RequestParam(required = false) Integer pageSize,@RequestParam Integer rankType) {
|
||||
List<CaseRankingVo> caseRankingVoList =casesService.queryRank(pageSize,rankType);
|
||||
return success(caseRankingVoList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 好评榜 (当前季度、总榜) 按点赞量排行
|
||||
* @param pageSize
|
||||
* @param rankType
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@GetMapping("/queryHighOpinion")
|
||||
public JsonResponse<List<CaseRankingVo>> queryHighOpinion(@RequestParam(required = false) Integer pageSize,@RequestParam Integer rankType) {
|
||||
List<CaseRankingVo> caseRankingVoList =casesService.queryRank(pageSize,rankType);
|
||||
return success(caseRankingVoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 不同专业月热度榜 按观看量排行
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@GetMapping("/queryPopularityOfMajor")
|
||||
public JsonResponse<List<Cases>> queryPopularityOfMajor(@RequestParam(required = false) Integer pageSize,
|
||||
@RequestParam Long majorId,
|
||||
@RequestParam LocalDateTime rankMonth) {
|
||||
String accountId = getCurrent().getAccountId();
|
||||
List<Cases> caseRankingVoList =casesService.queryPopularityOfMajor(pageSize,majorId,rankMonth,accountId);
|
||||
return success(caseRankingVoList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 所有上榜的的(专业ID-时间), 用于下拉框.优化可将majorName一并查询,返回为List<List<Entity>> todo by anyone
|
||||
*/
|
||||
@GetMapping("/queryAllTimePopularityOfMajor")
|
||||
public JsonResponse<Map<Long, List<String>>> queryAllTimePopularityOfMajor() {
|
||||
Map<Long, List<String>> time = casesService.queryAllTimePopularityOfMajor();
|
||||
return success(time);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询推荐案例榜单
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@GetMapping("/queryRecommendRank")
|
||||
public JsonResponse<List<CasesQueryRecommendRankVo>> queryRecommendRank(@RequestParam(required = false,defaultValue = "3") Integer pageSize) {
|
||||
List<CasesQueryRecommendRankVo> list = casesService.queryRecommendRank(pageSize);
|
||||
return success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 案例上榜
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/riseIntoRank")
|
||||
public JsonResponse<Boolean> riseIntoRank(@RequestParam Long caseId) {
|
||||
casesService.riseIntoRank(caseId,getCurrent());
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 案例下榜
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/cancelRiseIntoRank")
|
||||
public JsonResponse<Boolean> cancelRiseIntoRank(@RequestParam Long caseId) {
|
||||
casesService.cancelRiseIntoRank(caseId);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐案例调整排名
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@PostMapping("/adjustRank")
|
||||
public JsonResponse<Boolean> adjustRank(@RequestParam List<Long> caseIds) {
|
||||
casesService.adjustRank(caseIds);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询收藏
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@GetMapping("/queryFavoriteCaseOfIndex")
|
||||
public JsonResponse<PageList<FavoriteCaseOfIndexVo>> queryFavoriteCaseOfIndex(@RequestParam(required = false,defaultValue = "1") Integer pageIndex,
|
||||
@RequestParam(required = false,defaultValue = "5") Integer pageSize) {
|
||||
String accountId = this.getCurrent().getAccountId();
|
||||
PageList<FavoriteCaseOfIndexVo> casesList = casesService.queryFavoriteCaseOfIndex(pageIndex,pageSize,accountId);
|
||||
return success(casesList);
|
||||
}
|
||||
|
||||
@GetMapping("/browsingHistory")
|
||||
public JsonResponse<PageList<CasesBrowsingHistoryVo>> browsingHistory(@RequestParam(required = false,defaultValue = "1") Integer pageIndex,
|
||||
@RequestParam(required = false,defaultValue = "5") Integer pageSize,
|
||||
HttpServletRequest request) {
|
||||
String accountId = this.getCurrent().getAccountId();
|
||||
PageList<CasesBrowsingHistoryVo> casesList = casesService.browsingHistory(pageIndex,pageSize,accountId,request);
|
||||
return success(casesList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,18 +1,24 @@
|
||||
package com.xboe.module.boecase.dao;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.module.boecase.dto.CaseVo;
|
||||
import com.xboe.module.boecase.vo.CaseRankingVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static com.xboe.enums.CasesRankEnum.*;
|
||||
|
||||
@Repository
|
||||
@Slf4j
|
||||
public class CasesDao extends BaseDao<Cases> {
|
||||
|
||||
/**
|
||||
@@ -35,4 +41,106 @@ public class CasesDao extends BaseDao<Cases> {
|
||||
public Cases getByTitle(String title) {
|
||||
return this.getGenericDao().findOne(Cases.class, FieldFilters.eq("title", title));
|
||||
}
|
||||
|
||||
public HashMap<String, Object> findExcellentCount(List<String> authorIdList) {
|
||||
String sql =
|
||||
"SELECT author_id,COUNT(1) AS excellentCount\n" +
|
||||
"FROM boe_cases \n" +
|
||||
"WHERE excellent = 1 AND author_id IN (?1) AND deleted=0 \n" +
|
||||
"GROUP BY author_id";
|
||||
List<Object[]> list = this.sqlFindList(sql, authorIdList);
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
list.forEach(objects -> {
|
||||
String authorId = objects[0].toString();
|
||||
int excellentCount = Integer.parseInt(objects[1].toString());
|
||||
map.put(authorId, excellentCount);
|
||||
});
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private List<CaseRankingVo> handleCaseRank(List<Object[]> listFields) {
|
||||
List<CaseRankingVo> list = new ArrayList<>();
|
||||
for (Object[] o : listFields) {
|
||||
CaseRankingVo dto = new CaseRankingVo();
|
||||
dto.setCaseId(String.valueOf(o[0]));
|
||||
dto.setCaseTitle((String) o[1]);
|
||||
list.add(dto);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<CaseRankingVo> findPopularityOfAll(Integer pageSize) {
|
||||
|
||||
String sql =
|
||||
"SELECT id,title\n" +
|
||||
"FROM boe_cases \n" +
|
||||
"WHERE deleted=0\n" +
|
||||
"ORDER BY views DESC,sys_create_time DESC\n" +
|
||||
"LIMIT ?1";
|
||||
|
||||
List<Object[]> listFields = this.sqlFindList(sql, pageSize);
|
||||
List<CaseRankingVo> caseRankingVoList = handleCaseRank(listFields);
|
||||
return caseRankingVoList;
|
||||
}
|
||||
|
||||
public List<CaseRankingVo> findPopularityOfQuarter(Integer pageSize) {
|
||||
String sql =
|
||||
"SELECT id,title\n" +
|
||||
"FROM boe_cases \n" +
|
||||
"WHERE deleted=0\n" +
|
||||
"ORDER BY (views-last_quarter_views) DESC,sys_create_time DESC \n" +
|
||||
"LIMIT ?1";
|
||||
|
||||
List<Object[]> listFields = this.sqlFindList(sql, pageSize);
|
||||
|
||||
List<CaseRankingVo> caseRankingVoList = handleCaseRank(listFields);
|
||||
return caseRankingVoList;
|
||||
}
|
||||
|
||||
public List<CaseRankingVo> findHighOpinionOfAll(Integer pageSize) {
|
||||
String sql =
|
||||
"SELECT id,title\n" +
|
||||
"FROM boe_cases \n" +
|
||||
"WHERE deleted=0\n" +
|
||||
"ORDER BY praises DESC,sys_create_time DESC \n" +
|
||||
"LIMIT ?1";
|
||||
List<Object[]> listFields = this.sqlFindList(sql, pageSize);
|
||||
List<CaseRankingVo> caseRankingVoList = handleCaseRank(listFields);
|
||||
return caseRankingVoList;
|
||||
}
|
||||
|
||||
|
||||
public List<CaseRankingVo> findHighOpinionOfQuarter(Integer pageSize) {
|
||||
String sql =
|
||||
"SELECT id,title\n" +
|
||||
"FROM boe_cases \n" +
|
||||
"WHERE deleted=0\n" +
|
||||
"ORDER BY (praises-last_quarter_praises) DESC,sys_create_time DESC \n" +
|
||||
"LIMIT ?1";
|
||||
|
||||
List<Object[]> listFields = this.sqlFindList(sql, pageSize);
|
||||
List<CaseRankingVo> caseRankingVoList = handleCaseRank(listFields);
|
||||
return caseRankingVoList;
|
||||
}
|
||||
|
||||
public List<CaseRankingVo> findRank(Integer pageSize, Integer rankType) {
|
||||
List<CaseRankingVo> popularityOfQuarter = Collections.emptyList();
|
||||
if (rankType == QUARTER_VIEWS.getType()){
|
||||
popularityOfQuarter = findPopularityOfQuarter(pageSize);
|
||||
}
|
||||
if (rankType == ALL_VIEWS.getType()){
|
||||
popularityOfQuarter = findPopularityOfAll(pageSize);
|
||||
}
|
||||
if (rankType == QUARTER_PRAISES.getType()){
|
||||
popularityOfQuarter = findHighOpinionOfQuarter(pageSize);
|
||||
}
|
||||
if (rankType == ALL_PRAISES.getType()){
|
||||
popularityOfQuarter = findHighOpinionOfAll(pageSize);
|
||||
}
|
||||
return popularityOfQuarter;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.xboe.module.boecase.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.boecase.entity.CasesRank;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Repository
|
||||
@Slf4j
|
||||
public class CasesRankDao extends BaseDao<CasesRank> {
|
||||
|
||||
public List<CasesRank> findViewsRankRecordByCaseId(String caseId) {
|
||||
String sql =
|
||||
"SELECT bdmt.name,bcvr.rise_rank_time,bcvr.rank,bcvr.major_id \n" +
|
||||
"FROM\n" +
|
||||
" boe_cases_rank bcvr\n" +
|
||||
"JOIN boe_dict_major_type bdmt \n" +
|
||||
" ON CAST(bdmt.code AS SIGNED) = bcvr.major_id \n" +
|
||||
"WHERE bcvr.case_id = ?1 AND bcvr.deleted=0 AND bdmt.deleted=0\n" +
|
||||
"ORDER BY bcvr.sys_update_time DESC \n" +
|
||||
"LIMIT 2;";
|
||||
|
||||
List<Object[]> list = this.sqlFindList(sql, caseId);
|
||||
|
||||
List<CasesRank> resultList = new ArrayList<>();
|
||||
for (Object[] o : list) {
|
||||
CasesRank casesRank = new CasesRank();
|
||||
casesRank.setMajorName(o[0].toString());
|
||||
casesRank.setRiseRankTime(((Timestamp) o[1]).toLocalDateTime());
|
||||
casesRank.setRank(Integer.valueOf(o[2].toString()));
|
||||
casesRank.setMajorId(Long.valueOf(o[3].toString()));
|
||||
resultList.add(casesRank);
|
||||
}
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public HashMap<String, Object> findViewTopCount(List<String> authorIdList) {
|
||||
String sql=
|
||||
"SELECT author_id,COUNT(1) as viewTopCount\n" +
|
||||
"FROM boe_cases bc JOIN boe_cases_rank bcvr ON bcvr.case_id = bc.id\n" +
|
||||
"WHERE bc.author_id IN (?1) \n" +
|
||||
" AND bcvr.deleted = 0 \n" +
|
||||
" AND bc.deleted = 0\n" +
|
||||
"GROUP BY bc.author_id;";
|
||||
List<Object[]> list = this.sqlFindList(sql, authorIdList);
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
list.forEach(objects -> {
|
||||
String authorId = objects[0].toString();
|
||||
Integer viewTopCount = Integer.parseInt(objects[1].toString());
|
||||
map.put(authorId, viewTopCount);
|
||||
});
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
public List<HashMap<String, Object>> findPopularityOfMajor(Integer pageSize, LocalDateTime startTime, LocalDateTime endTime, Long majorId) {
|
||||
|
||||
String sql =
|
||||
"SELECT bcr.case_id,bcr.rank\n" +
|
||||
"FROM boe_cases_rank bcr\n" +
|
||||
"JOIN boe_cases bc on bcr.case_id = bc.id\n" +
|
||||
"WHERE bcr.deleted=0 AND bc.deleted=0 AND bcr.rise_rank_time BETWEEN ?1 and ?2 AND major_id=?3\n" +
|
||||
"ORDER BY rank\n" +
|
||||
"LIMIT ?4";
|
||||
|
||||
List<Object[]> listFields = this.sqlFindList(sql, startTime, endTime,majorId,pageSize);
|
||||
|
||||
List<HashMap<String, Object>> collect = listFields.stream().map(item -> {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("caseId", item[0].toString());
|
||||
map.put("rank", item[1].toString());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return collect;
|
||||
}
|
||||
}
|
||||
@@ -21,50 +21,79 @@ import java.util.List;
|
||||
*/
|
||||
@Repository
|
||||
public interface CasesRecordDao extends JpaRepository<Cases, String>, JpaSpecificationExecutor<Cases> {
|
||||
@Query(nativeQuery = true, value = "select c.* from ( select b.*" +
|
||||
" from boe_cases_recommend_push_record a left JOIN boe_cases b on a.case_id = b.id" +
|
||||
" where b.deleted=0 and a.push_status = 3 and a.deleted=0 and a.push_user_id= :#{#condition.userId}" +
|
||||
" and if(IFNULL(:#{#condition.keyWord},'')!='',b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.author_name like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword1 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword2 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword3 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword4 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword5 like CONCAT('%',:#{#condition.keyWord},'%'),1=1)" +
|
||||
" and if(:#{#condition.yearsEmpty},1=1, YEAR(b.sys_create_time) in (:#{#condition.years}))" +
|
||||
" and if(:#{#condition.caseIdsEmpty}, 1=1, b.id in (:#{#condition.caseIds}))" +
|
||||
" and ("+
|
||||
" if(:#{#condition.allOrgEmpty}, 1=1, 1=2)" +
|
||||
" or if(:#{#condition.org1Empty}, 1=2, b.org_domain_parent in (:#{#condition.org1}))" +
|
||||
" or if(:#{#condition.org2Empty}, 1=2, b.org_domain_parent2 in (:#{#condition.org2}))" +
|
||||
" or if(:#{#condition.org3Empty}, 1=2, b.org_domain_parent3 in (:#{#condition.org3}))" +
|
||||
")" +
|
||||
" and if(:#{#condition.isSysType1Empty} , 1=1, b.sys_type1 = :#{#condition.sysType1} )"+
|
||||
" and if(:#{#condition.isSysType2Empty} , 1=1, b.sys_type2 = :#{#condition.sysType2} )"+
|
||||
" and if(:#{#condition.isSysType3Empty} , 1=1, b.sys_type3 = :#{#condition.sysType3} )"+
|
||||
" order by a.sys_create_time DESC, a.read_flag ASC) as c group by c.id",
|
||||
countQuery = "select count(*) FROM (select c.* from ( select b.*" +
|
||||
" from boe_cases_recommend_push_record a left JOIN boe_cases b on a.case_id = b.id " +
|
||||
" where b.deleted=0 and a.push_status = 3 and a.deleted=0 and a.push_user_id= :#{#condition.userId}" +
|
||||
" and if(IFNULL(:#{#condition.keyWord},'')!='',b.title like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.author_name like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword1 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword2 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword3 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword4 like CONCAT('%',:#{#condition.keyWord},'%')" +
|
||||
" or b.keyword5 like CONCAT('%',:#{#condition.keyWord},'%'),1=1)" +
|
||||
" and if(:#{#condition.yearsEmpty},1=1, YEAR(b.sys_create_time) in (:#{#condition.years}))" +
|
||||
" and if(:#{#condition.caseIdsEmpty}, 1=1, b.id in (:#{#condition.caseIds}))" +
|
||||
" and ("+
|
||||
" if(:#{#condition.allOrgEmpty}, 1=1, 1=2)" +
|
||||
" or if(:#{#condition.org1Empty}, 1=1, b.org_domain_parent in (:#{#condition.org1}))" +
|
||||
" or if(:#{#condition.org2Empty}, 1=1, b.org_domain_parent2 in (:#{#condition.org2}))" +
|
||||
" or if(:#{#condition.org3Empty}, 1=1, b.org_domain_parent3 in (:#{#condition.org3}))" +
|
||||
")" +
|
||||
" and if(:#{#condition.isSysType1Empty} , 1=1, b.sys_type1 = :#{#condition.sysType1} )"+
|
||||
" and if(:#{#condition.isSysType2Empty} , 1=1, b.sys_type2 = :#{#condition.sysType2} )"+
|
||||
" and if(:#{#condition.isSysType3Empty} , 1=1, b.sys_type3 = :#{#condition.sysType3} )"+
|
||||
" order by a.sys_create_time DESC, a.read_flag ASC ) as c group by c.id) as d")
|
||||
@Query(nativeQuery = true, value =
|
||||
" SELECT c.* FROM ( " +
|
||||
" SELECT b.*,a.sys_create_time as recommendPushTime" +
|
||||
" FROM boe_cases_recommend_push_record a " +
|
||||
" LEFT JOIN boe_cases b ON a.case_id = b.id " +
|
||||
" WHERE b.deleted = 0 " +
|
||||
" AND a.push_status = 3 " +
|
||||
" AND a.deleted = 0 " +
|
||||
" AND a.push_user_id = :#{#condition.userId} " +
|
||||
" AND IF(IFNULL(:#{#condition.keyWord}, '') != '', " +
|
||||
" b.title LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.author_name LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword1 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword2 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword3 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword4 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword5 LIKE CONCAT('%', :#{#condition.keyWord}, '%'), " +
|
||||
" 1 = 1) " +
|
||||
" AND IF(:#{#condition.yearsEmpty}, 1 = 1, YEAR(b.sys_create_time) IN (:#{#condition.years})) " +
|
||||
" AND IF(:#{#condition.caseIdsEmpty}, 1 = 1, b.id IN (:#{#condition.caseIds})) " +
|
||||
" AND ( " +
|
||||
" IF(:#{#condition.allOrgEmpty}, 1 = 1, 1 = 2) " +
|
||||
" OR IF(:#{#condition.org1Empty}, 1 = 2, b.org_domain_parent IN (:#{#condition.org1})) " +
|
||||
" OR IF(:#{#condition.org2Empty}, 1 = 2, b.org_domain_parent2 IN (:#{#condition.org2})) " +
|
||||
" OR IF(:#{#condition.org3Empty}, 1 = 2, b.org_domain_parent3 IN (:#{#condition.org3})) " +
|
||||
" ) " +
|
||||
" AND IF(:#{#condition.isSysType1Empty}, 1 = 1, b.sys_type1 = :#{#condition.sysType1}) " +
|
||||
" AND IF(:#{#condition.isSysType2Empty}, 1 = 1, b.sys_type2 = :#{#condition.sysType2}) " +
|
||||
" AND IF(:#{#condition.isSysType3Empty}, 1 = 1, b.sys_type3 = :#{#condition.sysType3}) " +
|
||||
" ) AS c GROUP BY c.id " +
|
||||
" ORDER BY " +
|
||||
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=true,c.views, null) asc," +
|
||||
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=false,c.views, null) desc," +
|
||||
" IF(:#{#condition.orderField}='sysCreateTime' and :#{#condition.orderAsc}=true ,c.sys_create_time,null) asc," +
|
||||
" IF(:#{#condition.orderField}='sysCreateTime' and :#{#condition.orderAsc}=false , c.sys_create_time,null) desc," +
|
||||
" IF(:#{#condition.orderField}='recommendPushTime', c.recommendPushTime,null) desc",
|
||||
countQuery =
|
||||
" SELECT count(*) FROM ( " +
|
||||
" SELECT b.*,a.sys_create_time as recommendPushTime" +
|
||||
" FROM boe_cases_recommend_push_record a " +
|
||||
" LEFT JOIN boe_cases b ON a.case_id = b.id " +
|
||||
" WHERE b.deleted = 0 " +
|
||||
" AND a.push_status = 3 " +
|
||||
" AND a.deleted = 0 " +
|
||||
" AND a.push_user_id = :#{#condition.userId} " +
|
||||
" AND IF(IFNULL(:#{#condition.keyWord}, '') != '', " +
|
||||
" b.title LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.author_name LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword1 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword2 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword3 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword4 LIKE CONCAT('%', :#{#condition.keyWord}, '%') " +
|
||||
" OR b.keyword5 LIKE CONCAT('%', :#{#condition.keyWord}, '%'), " +
|
||||
" 1 = 1) " +
|
||||
" AND IF(:#{#condition.yearsEmpty}, 1 = 1, YEAR(b.sys_create_time) IN (:#{#condition.years})) " +
|
||||
" AND IF(:#{#condition.caseIdsEmpty}, 1 = 1, b.id IN (:#{#condition.caseIds})) " +
|
||||
" AND ( " +
|
||||
" IF(:#{#condition.allOrgEmpty}, 1 = 1, 1 = 2) " +
|
||||
" OR IF(:#{#condition.org1Empty}, 1 = 2, b.org_domain_parent IN (:#{#condition.org1})) " +
|
||||
" OR IF(:#{#condition.org2Empty}, 1 = 2, b.org_domain_parent2 IN (:#{#condition.org2})) " +
|
||||
" OR IF(:#{#condition.org3Empty}, 1 = 2, b.org_domain_parent3 IN (:#{#condition.org3})) " +
|
||||
" ) " +
|
||||
" AND IF(:#{#condition.isSysType1Empty}, 1 = 1, b.sys_type1 = :#{#condition.sysType1}) " +
|
||||
" AND IF(:#{#condition.isSysType2Empty}, 1 = 1, b.sys_type2 = :#{#condition.sysType2}) " +
|
||||
" AND IF(:#{#condition.isSysType3Empty}, 1 = 1, b.sys_type3 = :#{#condition.sysType3}) " +
|
||||
" ) AS c GROUP BY c.id " +
|
||||
" ORDER BY " +
|
||||
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=true,c.views, null) asc," +
|
||||
" IF(:#{#condition.orderField}='views' and :#{#condition.orderAsc}=false,c.views, null) desc," +
|
||||
" IF(:#{#condition.orderField}='sysCreateTime' and :#{#condition.orderAsc}=true ,c.sys_create_time,null) asc," +
|
||||
" IF(:#{#condition.orderField}='sysCreateTime' and :#{#condition.orderAsc}=false , c.sys_create_time,null) desc," +
|
||||
" IF(:#{#condition.orderField}='recommendPushTime', c.recommendPushTime,null) desc"
|
||||
)
|
||||
Page<Cases> queryList(Pageable pageable, @Param("condition") CasePageVo casePage);
|
||||
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.xboe.module.boecase.entity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import com.xboe.module.boecase.vo.CaseViewRankingItemVo;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@@ -248,16 +249,7 @@ public class Cases extends BaseEntity {
|
||||
@Column(name = "case_value")
|
||||
private String caseValue;
|
||||
|
||||
// 种类字段1
|
||||
// 暂不上线
|
||||
// @Column(name = "sys_type1")
|
||||
// private String sysType1;
|
||||
//种类字段2
|
||||
// @Column(name = "sys_type2")
|
||||
// private String sysType2;
|
||||
//种类字段3
|
||||
// @Column(name = "sys_type3")
|
||||
// private String sysType3;
|
||||
|
||||
|
||||
/**
|
||||
* 最佳案例标识
|
||||
@@ -272,6 +264,48 @@ public class Cases extends BaseEntity {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime excellentTime;
|
||||
|
||||
/**
|
||||
* 最佳时间
|
||||
* */
|
||||
@Column(name = "excellent_reason")
|
||||
private String excellentReason;
|
||||
|
||||
/**
|
||||
* 上月浏览量
|
||||
*/
|
||||
@Column(name = "last_month_views")
|
||||
private Integer lastMonthViews;
|
||||
|
||||
/**
|
||||
* 上季度浏览量
|
||||
*/
|
||||
@Column(name = "last_quarter_views")
|
||||
private Integer lastQuarterViews;
|
||||
|
||||
/**
|
||||
* 上季度点赞量
|
||||
*/
|
||||
@Column(name = "last_quarter_praises")
|
||||
private Integer lastQuarterPraises;
|
||||
|
||||
/**
|
||||
* 推荐榜排序
|
||||
* */
|
||||
@Column(name = "recommend_rank")
|
||||
private Integer recommendRank;
|
||||
|
||||
/**
|
||||
* 推送用户名称
|
||||
*/
|
||||
@Column(name = "recommend_rank_push_user_name")
|
||||
private String recommendRankPushUserName;
|
||||
|
||||
/**
|
||||
* 推送时间
|
||||
*/
|
||||
@Column(name = "recommend_rank_push_time")
|
||||
private LocalDateTime recommendRankPushTime;
|
||||
|
||||
/**
|
||||
* type 种类
|
||||
* 区分 案例/推荐案例
|
||||
@@ -279,11 +313,6 @@ public class Cases extends BaseEntity {
|
||||
@Transient
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
|
||||
|
||||
@Transient
|
||||
private List<String> majorIds;
|
||||
|
||||
@@ -296,6 +325,15 @@ public class Cases extends BaseEntity {
|
||||
@Transient
|
||||
private String refId;
|
||||
|
||||
@Transient
|
||||
private String excellentTag;
|
||||
|
||||
@Transient
|
||||
private List<CaseViewRankingItemVo> viewRankTags;
|
||||
|
||||
@Transient
|
||||
private List<String> authorTags;
|
||||
|
||||
public String getRefId() {
|
||||
return refId;
|
||||
}
|
||||
@@ -380,7 +418,7 @@ public class Cases extends BaseEntity {
|
||||
this.title=title;
|
||||
}
|
||||
public Cases(String id,String title,String summary,String coverUrl,String authorId,String authorName,LocalDateTime sysCreateTime,Integer breCommend,Integer views,Integer comments,Integer praises,Integer shares,Integer favorites,Boolean deleted
|
||||
,String sysCreateBy,String sysCreateAid){
|
||||
,String sysCreateBy,String sysCreateAid){
|
||||
this.title=title;
|
||||
super.setId(id);
|
||||
this.authorId=authorId;
|
||||
@@ -398,7 +436,6 @@ public class Cases extends BaseEntity {
|
||||
this.favorites=favorites;
|
||||
super.setDeleted(deleted);
|
||||
}
|
||||
|
||||
public Cases(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
@@ -415,4 +452,29 @@ public class Cases extends BaseEntity {
|
||||
this.authorName = authorName;
|
||||
this.confidentialityLevel = confidentialityLevel;
|
||||
}
|
||||
|
||||
public Cases(String id,String title,String summary,String coverUrl,String authorId,String authorName,LocalDateTime sysCreateTime,Integer breCommend,Integer views,Integer comments,Integer praises,Integer shares,Integer favorites,Boolean deleted
|
||||
,String sysCreateBy,String sysCreateAid,String keyword1,String keyword2,String keyword3,String keyword4,String keyword5){
|
||||
this.title=title;
|
||||
super.setId(id);
|
||||
this.authorId=authorId;
|
||||
this.authorName=authorName;
|
||||
super.setSysCreateTime(sysCreateTime);
|
||||
super.setSysCreateAid(sysCreateAid);
|
||||
super.setSysCreateBy(sysCreateBy);
|
||||
this.summary=summary;
|
||||
this.coverUrl=coverUrl;
|
||||
this.breCommend=breCommend;
|
||||
this.views=views;
|
||||
this.comments=comments;
|
||||
this.praises=praises;
|
||||
this.shares=shares;
|
||||
this.favorites=favorites;
|
||||
this.keyword1=keyword1;
|
||||
this.keyword2=keyword2;
|
||||
this.keyword3=keyword3;
|
||||
this.keyword4=keyword4;
|
||||
this.keyword5=keyword5;
|
||||
super.setDeleted(deleted);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.xboe.module.boecase.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 案例推荐表
|
||||
* @TableName boe_cases_rank
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = SysConstant.TABLE_PRE+"cases_rank")
|
||||
public class CasesRank extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 案例ID
|
||||
*/
|
||||
@Column(name = "case_id")
|
||||
private Long caseId;
|
||||
|
||||
/**
|
||||
* 专业ID
|
||||
*/
|
||||
@Column(name = "major_id")
|
||||
private Long majorId;
|
||||
|
||||
/**
|
||||
* 排名
|
||||
*/
|
||||
@Column(name = "rank")
|
||||
private Integer rank;
|
||||
|
||||
/**
|
||||
* 浏览量每月增量
|
||||
*/
|
||||
@Column(name = "monthly_increment")
|
||||
private Integer monthlyIncrement;
|
||||
|
||||
|
||||
@Column(name = "rise_rank_time")
|
||||
private LocalDateTime riseRankTime;
|
||||
|
||||
@Transient
|
||||
private String majorName;
|
||||
|
||||
public CasesRank(Long majorId, LocalDateTime riseRankTime) {
|
||||
this.majorId = majorId;
|
||||
this.riseRankTime = riseRankTime;
|
||||
}
|
||||
}
|
||||
@@ -54,8 +54,15 @@ public class CasesRecommend extends BaseEntity {
|
||||
public CasesRecommend() {
|
||||
}
|
||||
|
||||
|
||||
public CasesRecommend(String id, String recommendOrgName) {
|
||||
this.setId(id);
|
||||
this.recommendOrgName = recommendOrgName;
|
||||
}
|
||||
|
||||
public CasesRecommend(String id, String recommendOrgName,LocalDateTime recommendTime) {
|
||||
this.setId(id);
|
||||
this.recommendOrgName = recommendOrgName;
|
||||
this.recommendTime = recommendTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package com.xboe.module.boecase.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.module.boecase.dto.*;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import com.xboe.module.boecase.vo.CasesBrowsingHistoryVo;
|
||||
import com.xboe.module.boecase.vo.CaseRankingVo;
|
||||
import com.xboe.module.boecase.vo.CasesQueryRecommendRankVo;
|
||||
import com.xboe.module.boecase.vo.FavoriteCaseOfIndexVo;
|
||||
import com.xboe.module.dict.entity.DictItem;
|
||||
import com.xboe.school.vo.CasesVo;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.transaction.Transactional;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface ICasesService{
|
||||
/**
|
||||
* 案例分页搜索,是否被推荐
|
||||
@@ -91,7 +99,7 @@ public interface ICasesService{
|
||||
/**
|
||||
* 用于二次查询
|
||||
* */
|
||||
List<Cases> ids(List<String> ids);
|
||||
List<Cases> ids(List<String> ids, String accountId);
|
||||
|
||||
/**
|
||||
*二期 首页的推荐案例
|
||||
@@ -101,7 +109,7 @@ public interface ICasesService{
|
||||
/**
|
||||
* 设置或者取消优秀案例
|
||||
* */
|
||||
void excellent(String id,Boolean excellent);
|
||||
void excellent(String id, Boolean excellent, String excellentReason);
|
||||
|
||||
|
||||
PageList<Cases> queryRecommendPageCasesV2(CasePageVo req);
|
||||
@@ -110,5 +118,27 @@ public interface ICasesService{
|
||||
|
||||
List<String> getCaseYears();
|
||||
|
||||
@Transactional
|
||||
void refreshViewsRankOfMajor();
|
||||
|
||||
void refreshLastQuarterStatistics();
|
||||
|
||||
List<CasesQueryRecommendRankVo> queryRecommendRank(Integer pageSize);
|
||||
|
||||
void riseIntoRank(Long caseId, CurrentUser currentUser);
|
||||
|
||||
void cancelRiseIntoRank(Long caseId);
|
||||
|
||||
void adjustRank(List<Long> caseIdList);
|
||||
|
||||
List<CaseRankingVo> queryRank(Integer pageSize, Integer rankType);
|
||||
|
||||
List<Cases> queryPopularityOfMajor(Integer pageSize, Long majorId, LocalDateTime month, String accountId);
|
||||
|
||||
PageList<FavoriteCaseOfIndexVo> queryFavoriteCaseOfIndex(Integer pageIndex, Integer pageSize, String accountId);
|
||||
|
||||
PageList<CasesBrowsingHistoryVo> browsingHistory(Integer pageIndex, Integer pageSize, String accountId, HttpServletRequest request);
|
||||
|
||||
Map<Long, List<String>> queryAllTimePopularityOfMajor();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,14 @@ package com.xboe.module.boecase.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.api.vo.UserDynamic;
|
||||
import com.xboe.api.vo.UserDynamicResult;
|
||||
import com.xboe.api.vo.UserdynamicParam;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.OrderDirection;
|
||||
import com.xboe.common.PageList;
|
||||
@@ -11,29 +17,39 @@ import com.xboe.common.utils.IDGenerator;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.orm.*;
|
||||
import com.xboe.enums.CasesRankEnum;
|
||||
import com.xboe.module.boecase.dao.*;
|
||||
import com.xboe.module.boecase.dto.*;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import com.xboe.module.boecase.entity.CasesMajorType;
|
||||
import com.xboe.module.boecase.entity.CasesRecommend;
|
||||
import com.xboe.module.boecase.entity.CasesRecommendPushRecord;
|
||||
import com.xboe.module.boecase.entity.*;
|
||||
import com.xboe.module.boecase.service.ICasesService;
|
||||
import com.xboe.module.boecase.vo.*;
|
||||
import com.xboe.module.dict.dao.SysDictionaryDao;
|
||||
import com.xboe.module.dict.entity.DictItem;
|
||||
import com.xboe.module.interaction.entity.Favorites;
|
||||
import com.xboe.orm.CustomFieldInFilter;
|
||||
import com.xboe.school.vo.CasesVo;
|
||||
import com.xboe.standard.enums.BoedxResourceType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.transaction.Transactional;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Array;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.TemporalAdjusters;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -61,6 +77,15 @@ public class CasesServiceImpl implements ICasesService {
|
||||
@Autowired
|
||||
private CasesRecommendDao casesRecommendDao;
|
||||
|
||||
@Resource
|
||||
private CasesRankDao casesRankDao;
|
||||
|
||||
@Resource
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
/**
|
||||
* 案例分页查询,用于门户的查询
|
||||
*/
|
||||
@@ -178,12 +203,6 @@ public class CasesServiceImpl implements ICasesService {
|
||||
@Override
|
||||
public PageList<Cases> queryPageCasesV2(CasePageVo caseVo) {
|
||||
|
||||
String type = caseVo.getType();
|
||||
if (!StrUtil.equals(type,"excellent")) {
|
||||
caseVo.setOrderField("");
|
||||
caseVo.setOrderAsc(null);
|
||||
}
|
||||
|
||||
String keyword = caseVo.getKeyWord();
|
||||
QueryBuilder query = QueryBuilder.from(Cases.class);
|
||||
PageList<Cases> page = null;
|
||||
@@ -296,18 +315,16 @@ public class CasesServiceImpl implements ICasesService {
|
||||
filters.add(FieldFilters.eq("excellent", caseVo.getExcellent()));
|
||||
}
|
||||
OrderCondition order = null;
|
||||
if (StringUtils.isNotBlank(caseVo.getOrderField())) {
|
||||
if (caseVo.getOrderAsc() == null || caseVo.getOrderAsc()) {
|
||||
if (StringUtils.isNotBlank(caseVo.getOrderField()) && caseVo.getOrderAsc() != null && ("sysCreateTime".equals(caseVo.getOrderField()) || "views".equals(caseVo.getOrderField()))) {
|
||||
if (caseVo.getOrderAsc()) {
|
||||
order = OrderCondition.asc(caseVo.getOrderField());
|
||||
} else {
|
||||
order = OrderCondition.desc(caseVo.getOrderField());
|
||||
}
|
||||
}
|
||||
if (StrUtil.equals(type,"new")) {
|
||||
} else {
|
||||
order = OrderCondition.desc("sysCreateTime");
|
||||
} else if (StrUtil.equals(type,"hot")) {
|
||||
order = OrderCondition.desc("views");
|
||||
}
|
||||
|
||||
if(Objects.nonNull(order)) {
|
||||
query.addOrder(order);
|
||||
}
|
||||
@@ -315,53 +332,18 @@ public class CasesServiceImpl implements ICasesService {
|
||||
query.setPageIndex(caseVo.getPageIndex());
|
||||
query.setPageSize(caseVo.getPageSize());
|
||||
page = casesDao.findPage(query.builder());
|
||||
List<Cases> list = page.getList();
|
||||
list.forEach(it->{
|
||||
List<Cases> casesList = page.getList();
|
||||
casesList.forEach(it->{
|
||||
it.setBreCommend(0);
|
||||
});
|
||||
if (CollUtil.isNotEmpty(list) && StrUtil.isNotBlank(caseVo.getUserId())) {
|
||||
List<String> caseIds = list.stream().map(Cases::getId).collect(Collectors.toList());
|
||||
QueryBuilder recommendCasesQuery = QueryBuilder.from(CasesRecommendPushRecord.class);
|
||||
recommendCasesQuery.addField("new CasesRecommendPushRecord(id,recommendId,caseId)");
|
||||
List<IFieldFilter> subFilters = new ArrayList<>();
|
||||
subFilters.add(FieldFilters.eq("pushUserId", caseVo.getUserId()));
|
||||
subFilters.add(FieldFilters.in("caseId", caseIds));
|
||||
subFilters.add(FieldFilters.eq("pushStatus", 3));
|
||||
subFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
|
||||
QueryBuilder queryBuilder = recommendCasesQuery.addFilters(subFilters)
|
||||
.addOrder("sysCreateTime", OrderDirection.DESC)
|
||||
.addGroupBy("caseId");
|
||||
List<CasesRecommendPushRecord> pushRecords = casesRecommendPushRecordDao.findList(queryBuilder.builder());
|
||||
if (CollUtil.isNotEmpty(pushRecords)) {
|
||||
List<String> rIds = pushRecords.stream().map(CasesRecommendPushRecord::getRecommendId).distinct().collect(Collectors.toList());
|
||||
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class);
|
||||
builder.addField("new CasesRecommend(id,recommendOrgName)");
|
||||
List<IFieldFilter> recommendFilters = new ArrayList<>();
|
||||
recommendFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
recommendFilters.add(FieldFilters.in("id", rIds));
|
||||
builder.addFilters(recommendFilters);
|
||||
List<CasesRecommend> recommands = casesRecommendDao.findList(builder.builder());
|
||||
if (CollUtil.isNotEmpty(recommands)) {
|
||||
Map<String, String> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), v -> v.getRecommendOrgName()));
|
||||
list.forEach(it -> {
|
||||
CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId()));
|
||||
if (Objects.nonNull(one)) {
|
||||
String recommendOrgName = collect.get(one.getRecommendId());
|
||||
it.setBreCommend(1);
|
||||
it.setRecommendOrgName(recommendOrgName);
|
||||
} else {
|
||||
it.setBreCommend(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
casesList = caseListCommonHandle(casesList, caseVo.getUserId());
|
||||
page.setList(casesList);
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public PageList<Cases> queryRecommendPageCasesV2(CasePageVo caseVo) {
|
||||
|
||||
@@ -408,37 +390,68 @@ public class CasesServiceImpl implements ICasesService {
|
||||
caseVo.setOrg2(level2);
|
||||
caseVo.setOrg3(level3);
|
||||
|
||||
Set<String> validOrderFields = new HashSet<>();
|
||||
validOrderFields.add("sysCreateTime");
|
||||
validOrderFields.add("views");
|
||||
validOrderFields.add("recommendPushTime");
|
||||
if (StringUtils.isBlank(caseVo.getOrderField()) || caseVo.getOrderAsc() == null || !validOrderFields.contains(caseVo.getOrderField())) {
|
||||
caseVo.setOrderField("recommendPushTime");
|
||||
caseVo.setOrderAsc(false);
|
||||
}
|
||||
|
||||
Page<Cases> cases = casesRecordDao.queryList(pageRequest,caseVo);
|
||||
PageList<Cases> pageList = new PageList<>();
|
||||
pageList.setCount((int) cases.getTotalElements());
|
||||
pageList.setPageSize(cases.getSize());
|
||||
List<Cases> content = cases.getContent();
|
||||
List<String> caseIds = content.stream().map(Cases::getId).collect(Collectors.toList());
|
||||
String userId = caseVo.getUserId();
|
||||
if (CollUtil.isNotEmpty(caseIds)) {
|
||||
QueryBuilder recommendCasesQuery = QueryBuilder.from(CasesRecommendPushRecord.class);
|
||||
recommendCasesQuery.addField("new CasesRecommendPushRecord(id,recommendId,caseId)");
|
||||
List<IFieldFilter> subFilters = new ArrayList<>();
|
||||
subFilters.add(FieldFilters.eq("pushUserId", userId));
|
||||
subFilters.add(FieldFilters.in("caseId", caseIds));
|
||||
subFilters.add(FieldFilters.eq("pushStatus", 3));
|
||||
subFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
|
||||
QueryBuilder queryBuilder = recommendCasesQuery.addFilters(subFilters)
|
||||
caseListCommonHandle(content, caseVo.getUserId());
|
||||
|
||||
pageList.setList(content);
|
||||
return pageList;
|
||||
}
|
||||
|
||||
private List<Cases> caseListCommonHandle(List<Cases> casesList, String accountId) {
|
||||
if (CollUtil.isEmpty(casesList)) {
|
||||
return casesList;
|
||||
}
|
||||
//1.推荐案例数据处理
|
||||
recommendCasesDataHandle(casesList, accountId);
|
||||
//2.标签处理,添加作者标签和新的案例标签
|
||||
addAuthorTagAndCaseNewTag(casesList);
|
||||
|
||||
return casesList;
|
||||
}
|
||||
|
||||
private void recommendCasesDataHandle(List<Cases> casesList, String accountId) {
|
||||
if (StrUtil.isNotBlank(accountId)) {
|
||||
List<String> caseIdList = casesList.stream().map(Cases::getId).collect(Collectors.toList());
|
||||
QueryBuilder queryBuilder = QueryBuilder.from(CasesRecommendPushRecord.class)
|
||||
.addField("new CasesRecommendPushRecord(id,recommendId,caseId)")
|
||||
.addFilters(Arrays.asList(
|
||||
FieldFilters.eq("pushUserId", accountId),
|
||||
FieldFilters.in("caseId", caseIdList),
|
||||
FieldFilters.eq("pushStatus", 3),
|
||||
FieldFilters.eq("deleted", Boolean.FALSE)
|
||||
))
|
||||
.addOrder("sysCreateTime", OrderDirection.DESC)
|
||||
.addGroupBy("caseId");
|
||||
|
||||
List<CasesRecommendPushRecord> pushRecords = casesRecommendPushRecordDao.findList(queryBuilder.builder());
|
||||
|
||||
if (CollUtil.isNotEmpty(pushRecords)) {
|
||||
List<String> rIds = pushRecords.stream().map(CasesRecommendPushRecord::getRecommendId).distinct().collect(Collectors.toList());
|
||||
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class);
|
||||
List<IFieldFilter> recommendFilters = new ArrayList<>();
|
||||
recommendFilters.add(FieldFilters.eq("deleted", Boolean.FALSE));
|
||||
recommendFilters.add(FieldFilters.in("id", rIds));
|
||||
builder.addFilters(recommendFilters);
|
||||
QueryBuilder builder = QueryBuilder.from(CasesRecommend.class)
|
||||
.addField("new CasesRecommend(id,recommendOrgName,recommendTime)")
|
||||
.addFilters(Arrays.asList(
|
||||
FieldFilters.eq("deleted", Boolean.FALSE),
|
||||
FieldFilters.in("id", rIds)
|
||||
));
|
||||
|
||||
List<CasesRecommend> recommands = casesRecommendDao.findList(builder.builder());
|
||||
if (CollUtil.isNotEmpty(recommands)) {
|
||||
Map<String, CasesRecommend> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), item->item));
|
||||
content.forEach(it -> {
|
||||
Map<String, CasesRecommend> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), item -> item));
|
||||
casesList.forEach(it -> {
|
||||
CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId()));
|
||||
if (Objects.nonNull(one)) {
|
||||
CasesRecommend recommend = collect.get(one.getRecommendId());
|
||||
@@ -446,13 +459,72 @@ public class CasesServiceImpl implements ICasesService {
|
||||
it.setRefId(one.getId());
|
||||
it.setRecommendOrgName(recommend.getRecommendOrgName());
|
||||
it.setSysCreateTime(recommend.getRecommendTime());
|
||||
} else {
|
||||
it.setBreCommend(0);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
pageList.setList(content);
|
||||
return pageList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加案例标签、作者标签(最佳案例N篇、上榜浏览量TOP榜单N次)、案例标签(xx分类浏览量TOP、最佳案例)
|
||||
*/
|
||||
private void addAuthorTagAndCaseNewTag(List<Cases> caseList) {
|
||||
if (CollUtil.isEmpty(caseList)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> authorIdList = caseList.stream().map(Cases::getAuthorId).distinct().collect(Collectors.toList());
|
||||
HashMap<String, Object> excellentCountMap = casesDao.findExcellentCount(authorIdList);
|
||||
HashMap<String, Object> viewTopCountMap = casesRankDao.findViewTopCount(authorIdList);
|
||||
|
||||
|
||||
caseList.forEach(e -> {
|
||||
// 获取最新的两个浏览量上榜记录
|
||||
List<CasesRank> viewsRankRecords = casesRankDao.findViewsRankRecordByCaseId(e.getId());
|
||||
if (CollUtil.isNotEmpty(viewsRankRecords)) {
|
||||
// 拼接生成浏览量排行榜的标签
|
||||
List<CaseViewRankingItemVo> viewRankTags = viewsRankRecords.stream().map(casesRank -> {
|
||||
String pattern = casesRank.getRiseRankTime().getMonthValue() < 10 ? "yy年M月" : "yy年MM月";
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
|
||||
String time = casesRank.getRiseRankTime().format(formatter);
|
||||
|
||||
// 2023年6月 经营管理类 浏览量 TOP1
|
||||
String viewRankTag = time + casesRank.getMajorName() + "类浏览量TOP" + (casesRank.getRank() + 1);
|
||||
|
||||
CaseViewRankingItemVo caseViewRankingItemVo = new CaseViewRankingItemVo();
|
||||
caseViewRankingItemVo.setMajorId(String.valueOf(casesRank.getMajorId()));
|
||||
caseViewRankingItemVo.setMajorName(casesRank.getMajorName());
|
||||
caseViewRankingItemVo.setTagName(viewRankTag);
|
||||
caseViewRankingItemVo.setRiseRankTime(casesRank.getRiseRankTime());
|
||||
|
||||
return caseViewRankingItemVo;
|
||||
}).collect(Collectors.toList());
|
||||
e.setViewRankTags(viewRankTags);
|
||||
|
||||
}
|
||||
|
||||
// 拼接生成年度最佳标签
|
||||
if (e.getExcellent()!=null && e.getExcellent()) {
|
||||
e.setExcellentTag(e.getExcellentTime().format(DateTimeFormatter.ofPattern("yy年"))+"度最佳");
|
||||
}
|
||||
|
||||
List<String> authorTags = new ArrayList<>();
|
||||
|
||||
if (excellentCountMap.get(e.getAuthorId())!=null){
|
||||
String authorTagOfExcellent = excellentCountMap.get(e.getAuthorId()) + "篇最佳案例";
|
||||
authorTags.add(authorTagOfExcellent);
|
||||
}
|
||||
|
||||
if (viewTopCountMap.get(e.getAuthorId())!=null){
|
||||
String authorTagOfView = "上榜浏览量TOP榜单" + viewTopCountMap.get(e.getAuthorId()) + "次";
|
||||
authorTags.add(authorTagOfView);
|
||||
}
|
||||
|
||||
e.setAuthorTags(authorTags);
|
||||
});
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
@@ -945,11 +1017,12 @@ public class CasesServiceImpl implements ICasesService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Cases> ids(List<String> ids) {
|
||||
public List<Cases> ids(List<String> ids, String accountId) {
|
||||
QueryBuilder builder = QueryBuilder.from(Cases.class);
|
||||
builder.addFilter(FieldFilters.in("id", ids));
|
||||
builder.addFields("new Cases(id,title,summary,coverUrl,authorId,authorName,sysCreateTime,breCommend,views,comments,praises,shares,favorites,deleted,sysCreateBy,sysCreateAid)");
|
||||
builder.addFields("new Cases(id,title,summary,coverUrl,authorId,authorName,sysCreateTime,breCommend,views,comments,praises,shares,favorites,deleted,sysCreateBy,sysCreateAid,keyword1,keyword2,keyword3,keyword4,keyword5)");
|
||||
List<Cases> cases = casesDao.findList(builder.builder());
|
||||
cases = caseListCommonHandle(cases, accountId);
|
||||
return cases;
|
||||
}
|
||||
|
||||
@@ -1078,15 +1151,352 @@ public class CasesServiceImpl implements ICasesService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excellent(String id, Boolean excellent) {
|
||||
public void excellent(String id, Boolean excellent, String excellentReason) {
|
||||
//取消时,把时间清空
|
||||
if (excellent) {
|
||||
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", LocalDateTime.now()));
|
||||
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", LocalDateTime.now()), UpdateBuilder.create("excellentReason", excellentReason));
|
||||
} else {
|
||||
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", null));
|
||||
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", null), UpdateBuilder.create("excellentReason", null));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refreshViewsRankOfMajor(){
|
||||
// 获取上个月的第一天的00:00
|
||||
// LocalDateTime firstDayOfLastMonth = LocalDateTime.now().minusMonths(1).with(TemporalAdjusters.firstDayOfMonth()).toLocalDate().atStartOfDay();
|
||||
// 获取上个月的最后一天的23:59:59,将其设置为上榜时间。注意,定时统计任务是在本月月初执行的,而上榜时间是在上个月最后一天23:59:59
|
||||
LocalDateTime lastDayOfLastMonth = LocalDateTime.now().minusMonths(1).with(TemporalAdjusters.lastDayOfMonth()).toLocalDate().atTime(23, 59, 59); // 设置为当天的几乎结束时刻
|
||||
|
||||
int count = casesRankDao.sqlCount("SELECT count(1) FROM boe_cases_rank WHERE deleted=0 AND rise_rank_time = ?1" , lastDayOfLastMonth);
|
||||
if (count > 0){
|
||||
log.info("已生成上个月排行榜数据,本次不执行");
|
||||
throw new RuntimeException("已生成上个月排行榜数据,请将上月排行榜数据删除");
|
||||
}
|
||||
|
||||
//获取案例当月排名
|
||||
String sql =
|
||||
"SELECT bc.id,bcmt.major_id,bc.views - COALESCE(bc.last_month_views, 0) AS increment\n" +
|
||||
"FROM boe_cases bc\n" +
|
||||
"JOIN boe_cases_major_type bcmt ON bcmt.case_id = bc.id and bc.deleted=0 and file_path is not null and file_path!='' and bc.views - COALESCE(bc.last_month_views, 0)!=0";
|
||||
List<Object> caseListOfObject = casesDao.sqlFindList(sql);
|
||||
|
||||
// 转为casesRank
|
||||
List<CasesRank> casesRankList = caseListOfObject.stream()
|
||||
.map(o -> {
|
||||
CasesRank casesRank = new CasesRank();
|
||||
casesRank.setCaseId(Long.valueOf(Array.get(o, 0).toString()));
|
||||
casesRank.setMajorId(Long.valueOf(Array.get(o, 1).toString()));
|
||||
casesRank.setMonthlyIncrement(Integer.parseInt(Array.get(o, 2).toString()));
|
||||
casesRank.setRiseRankTime(lastDayOfLastMonth);
|
||||
return casesRank;
|
||||
}).collect(Collectors.toList());
|
||||
// 根据专业分类进行分组
|
||||
Map<Long, List<CasesRank>> casesRankMap = casesRankList.stream().collect(Collectors.groupingBy(CasesRank::getMajorId));
|
||||
|
||||
// 生成当前月不同分类的最新的浏览量排名
|
||||
ArrayList<CasesRank> lastMonthRank = new ArrayList<>();
|
||||
casesRankMap.forEach((majorId, caseList) -> {
|
||||
List<CasesRank> sortedCaseList = caseList.stream()
|
||||
.sorted(Comparator.comparingInt(CasesRank::getMonthlyIncrement).reversed()).limit(10)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
IntStream.range(0, sortedCaseList.size())
|
||||
.forEach(i -> sortedCaseList.get(i).setRank(i));
|
||||
lastMonthRank.addAll(sortedCaseList);
|
||||
});
|
||||
|
||||
|
||||
casesRankDao.saveList(lastMonthRank);
|
||||
// 重置上月观看量:last_month_views
|
||||
casesDao.sqlUpdate("update boe_cases set last_month_views=views where deleted=0");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void refreshLastQuarterStatistics() {
|
||||
casesDao.sqlUpdate("update boe_cases set last_quarter_views=views where deleted=0");
|
||||
casesDao.sqlUpdate("update boe_cases set last_quarter_praise=praise where deleted=0");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CaseRankingVo> queryRank(Integer pageSize, Integer rankType) {
|
||||
if (pageSize == null) {
|
||||
pageSize = 3;
|
||||
}
|
||||
String cacheKey = "";
|
||||
// 获取缓存key
|
||||
for (CasesRankEnum enumValue : CasesRankEnum.values()) {
|
||||
if (rankType == enumValue.getType()) {
|
||||
// 格式如:case:rank:praise:all3
|
||||
cacheKey = enumValue.getCacheKey()+pageSize;
|
||||
}
|
||||
}
|
||||
|
||||
List<String> caseListOfJson = stringRedisTemplate.opsForList().range(cacheKey, 0, -1);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(caseListOfJson)) {
|
||||
// 缓存中存在数据
|
||||
List<CaseRankingVo> casesList = caseListOfJson.stream().map(item -> JSONUtil.toBean(item, CaseRankingVo.class)).collect(Collectors.toList());
|
||||
return casesList;
|
||||
}
|
||||
|
||||
List<CaseRankingVo> casesList = casesDao.findRank(pageSize,rankType);
|
||||
|
||||
if (CollectionUtil.isNotEmpty(casesList)) {
|
||||
// 缓存不存在数据,数据库中不存在数据,重建缓存
|
||||
List<String> serializedCases = casesList.stream().map(item -> JSONUtil.toJsonStr(item)).collect(Collectors.toList());
|
||||
// stringRedisTemplate.opsForList().rightPushAll(cacheKey, serializedCases);
|
||||
// stringRedisTemplate.expire(cacheKey, 600, TimeUnit.SECONDS);
|
||||
return casesList;
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<Cases> queryPopularityOfMajor(Integer pageSize, Long majorId, LocalDateTime month, String accountId) {
|
||||
if (pageSize == null) {
|
||||
pageSize = 10;
|
||||
}
|
||||
|
||||
LocalDateTime startTime = month.withDayOfMonth(1);
|
||||
LocalDateTime endTime = month.plusMonths(1).withDayOfMonth(1).withMinute(0);
|
||||
|
||||
List<HashMap<String, Object>> popularityOfMajor = casesRankDao.findPopularityOfMajor(pageSize, startTime, endTime, majorId);
|
||||
List<String> caseIdList = popularityOfMajor.stream().map(map -> map.get("caseId").toString()).collect(Collectors.toList());
|
||||
|
||||
Map<Object, Integer> collect = popularityOfMajor.stream().collect(Collectors.toMap(map -> map.get("caseId").toString(), map -> Integer.valueOf(map.get("rank").toString())));
|
||||
|
||||
QueryBuilder query = QueryBuilder.from(Cases.class);
|
||||
query.addFilter(FieldFilters.in("id",caseIdList));
|
||||
query.addFilter(FieldFilters.eq("deleted",false));
|
||||
|
||||
List<Cases> casesList = casesDao.findList(query.builder());
|
||||
casesList = caseListCommonHandle(casesList, accountId);
|
||||
|
||||
Collections.sort(casesList, new Comparator<Cases>() {
|
||||
@Override
|
||||
public int compare(Cases c1, Cases c2) {
|
||||
Integer order1 = collect.get(c1.getId());
|
||||
Integer order2 = collect.get(c2.getId());
|
||||
return Integer.compare(order1, order2);
|
||||
}
|
||||
});
|
||||
return casesList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public List<CasesQueryRecommendRankVo> queryRecommendRank(Integer pageSize) {
|
||||
QueryBuilder queryBuilder = QueryBuilder.from(Cases.class);
|
||||
queryBuilder.setPageSize(pageSize);
|
||||
queryBuilder.addFilter(FieldFilters.eq("deleted",false));
|
||||
queryBuilder.addFilter(FieldFilters.isNotNull("recommend_rank"));
|
||||
queryBuilder.addOrder(OrderCondition.asc("recommend_rank"));
|
||||
|
||||
List<Cases> recommendRank = casesDao.findList(queryBuilder.builder());
|
||||
|
||||
List<CasesQueryRecommendRankVo> collect = recommendRank.stream().map(e -> {
|
||||
CasesQueryRecommendRankVo casesQueryRecommendRankVo = new CasesQueryRecommendRankVo();
|
||||
casesQueryRecommendRankVo.setCaseId(e.getId());
|
||||
casesQueryRecommendRankVo.setCaseTitle(e.getTitle());
|
||||
casesQueryRecommendRankVo.setCaseAuthor(e.getAuthorName());
|
||||
casesQueryRecommendRankVo.setRecommendRankPushUserName(e.getRecommendRankPushUserName());
|
||||
casesQueryRecommendRankVo.setRecommendRankPusTime(e.getRecommendRankPushTime());
|
||||
return casesQueryRecommendRankVo;
|
||||
}).collect(Collectors.toList());
|
||||
return collect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void riseIntoRank(Long caseId, CurrentUser currentUser) {
|
||||
Cases caseOfNewRise = casesDao.findOne(FieldFilters.eq("id", String.valueOf(caseId)),FieldFilters.isNull("recommend_rank"),FieldFilters.eq("deleted",false));
|
||||
if (caseOfNewRise == null) {
|
||||
log.error("案例不存在或已经在榜,不可上榜", caseId);
|
||||
return;
|
||||
}
|
||||
|
||||
int count = casesDao.sqlCount("select count(1) from boe_cases where deleted=0 and recommend_rank is not null order by recommend_rank asc limit 10");
|
||||
|
||||
if (count == 10){
|
||||
log.error("已满10条,无法添加");
|
||||
throw new RuntimeException("已满10条,无法添加");
|
||||
}
|
||||
|
||||
caseOfNewRise.setRecommendRank(count);
|
||||
caseOfNewRise.setRecommendRankPushUserName(currentUser.getLoginName());
|
||||
caseOfNewRise.setRecommendRankPushTime(LocalDateTime.now());
|
||||
|
||||
casesDao.update(caseOfNewRise);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void cancelRiseIntoRank(Long caseId) {
|
||||
Cases caseOfCancelRise = casesDao.findOne(FieldFilters.eq("id", String.valueOf(caseId)),FieldFilters.isNotNull("recommend_rank"),FieldFilters.eq("deleted",false));
|
||||
if (caseOfCancelRise == null) {
|
||||
log.error("案例不存在或已经在榜,不可下榜", caseId);
|
||||
return;
|
||||
}
|
||||
QueryBuilder queryBuilder = QueryBuilder.from(Cases.class);
|
||||
queryBuilder.setPageSize(10);
|
||||
queryBuilder.addFilter(FieldFilters.eq("deleted",false));
|
||||
queryBuilder.addOrder(OrderCondition.asc("recommend_rank"));
|
||||
queryBuilder.addFilter(FieldFilters.gt("recommend_rank",caseOfCancelRise.getRecommendRank()));
|
||||
List<Cases> recommendRank = casesDao.findList(queryBuilder.builder());
|
||||
|
||||
if (CollectionUtils.isEmpty(recommendRank)){
|
||||
// 更新排序
|
||||
for (int i = 0; i < recommendRank.size(); i++){
|
||||
Integer currentSort = recommendRank.get(i).getRecommendRank();
|
||||
recommendRank.get(i).setRecommendRank(currentSort - 1);
|
||||
casesDao.update(recommendRank.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
// 取消排序
|
||||
caseOfCancelRise.setRecommendRank(null);
|
||||
caseOfCancelRise.setRecommendRankPushTime(null);
|
||||
caseOfCancelRise.setRecommendRankPushUserName(null);
|
||||
casesDao.update(caseOfCancelRise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void adjustRank(List<Long> caseIdList) {
|
||||
QueryBuilder queryBuilder = QueryBuilder.from(Cases.class);
|
||||
queryBuilder.setPageSize(10);
|
||||
queryBuilder.addFilter(FieldFilters.eq("deleted",false));
|
||||
queryBuilder.addFilter(FieldFilters.isNotNull("recommend_rank"));
|
||||
queryBuilder.addOrder(OrderCondition.asc("recommend_rank"));
|
||||
List<Cases> recommendRank = casesDao.findList(queryBuilder.builder());
|
||||
|
||||
// 遍历排序后的案例列表,并根据 caseIdList 设置或重置 recommendRank
|
||||
recommendRank.forEach(caseItem -> {
|
||||
int index = caseIdList.indexOf(Long.valueOf(caseItem.getId()));
|
||||
// 如果 ID 存在于 caseIdList 中,则设置推荐等级为该 ID 的索引位置,否则设置为 null
|
||||
if (index != -1) {
|
||||
caseItem.setRecommendRank(index);
|
||||
} else {
|
||||
caseItem.setRecommendRank(null);
|
||||
caseItem.setRecommendRankPushTime(null);
|
||||
caseItem.setRecommendRankPushUserName(null);
|
||||
}
|
||||
});
|
||||
|
||||
// 保存对案例排序的更改
|
||||
recommendRank.forEach(casesDao::update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageList<FavoriteCaseOfIndexVo> queryFavoriteCaseOfIndex(Integer pageIndex, Integer pageSize, String accountId) {
|
||||
String from = Favorites.class.getSimpleName()+" f,"+ Cases.class.getSimpleName()+" c";
|
||||
QueryBuilder builder = QueryBuilder.from(from);
|
||||
builder.addFields("f.id","f.sysCreateTime","c");
|
||||
|
||||
builder.addFilter(FieldFilters.eqField("f.objId","c.id"));
|
||||
builder.addFilter(FieldFilters.eq("f.objType", BoedxResourceType.Case.value()));
|
||||
builder.addFilter(FieldFilters.eq("f.sysCreateAid",accountId));
|
||||
builder.addFilter(FieldFilters.eq("c.deleted", false));
|
||||
builder.addOrder(OrderCondition.desc("f.sysCreateTime"));
|
||||
|
||||
builder.setPageIndex(pageIndex);
|
||||
builder.setPageSize(pageSize);
|
||||
|
||||
PageList<Object[]> pageFields=null;
|
||||
try {
|
||||
pageFields = casesDao.findPageFields(builder.builder());
|
||||
} catch (Exception e) {
|
||||
log.error("收藏案例查询错误",e);
|
||||
}
|
||||
|
||||
List<Object[]> list = pageFields.getList();
|
||||
|
||||
// 提取出 Cases 对象,添加标签
|
||||
List<Cases> casesList = list.stream().map(o -> {
|
||||
Cases cases = (Cases) o[2];
|
||||
FavoriteCaseOfIndexVo favoriteCaseOfIndexVo = new FavoriteCaseOfIndexVo();
|
||||
BeanUtils.copyProperties(cases, favoriteCaseOfIndexVo);
|
||||
favoriteCaseOfIndexVo.setFavoriteId(o[0].toString());
|
||||
favoriteCaseOfIndexVo.setFavoriteTime(LocalDateTime.parse(o[1].toString()));
|
||||
return favoriteCaseOfIndexVo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
casesList = caseListCommonHandle(casesList, accountId);
|
||||
|
||||
List<FavoriteCaseOfIndexVo> collect = casesList.stream().map(cases -> (FavoriteCaseOfIndexVo) cases).collect(Collectors.toList());
|
||||
|
||||
PageList<FavoriteCaseOfIndexVo> favoriteCaseOfIndexVoPageList = new PageList<>();
|
||||
favoriteCaseOfIndexVoPageList.setList(collect);
|
||||
favoriteCaseOfIndexVoPageList.setPageSize(pageSize);
|
||||
favoriteCaseOfIndexVoPageList.setCount(pageFields.getCount());
|
||||
|
||||
return favoriteCaseOfIndexVoPageList;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageList<CasesBrowsingHistoryVo> browsingHistory(Integer pageIndex, Integer pageSize, String accountId, HttpServletRequest request) {
|
||||
UserdynamicParam userdynamicParam = new UserdynamicParam();
|
||||
userdynamicParam.setPageIndex(pageIndex);
|
||||
userdynamicParam.setPageSize(pageSize);
|
||||
userdynamicParam.setContentType(3);
|
||||
userdynamicParam.setAid(Long.valueOf(accountId));
|
||||
userdynamicParam.setHidden("");
|
||||
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
// 获取案例浏览记录
|
||||
UserDynamicResult userDynamicResult = thirdApi.getAllUserdynamicListOfCaseRead(userdynamicParam, token);
|
||||
|
||||
List<UserDynamic> allUserdynamicList = userDynamicResult.getList();
|
||||
List<String> collect = allUserdynamicList.stream().map(UserDynamic::getContentId).distinct().collect(Collectors.toList());
|
||||
// 查询案例信息
|
||||
List<Cases> caseList = this.ids(collect, accountId);
|
||||
Map<String, Cases> map = caseList.stream().collect(Collectors.toMap(Cases::getId, cases -> cases));
|
||||
|
||||
// 组合案例信息与浏览记录
|
||||
List<CasesBrowsingHistoryVo> batchHistoryVoList = allUserdynamicList.stream().map(userDynamic -> {
|
||||
CasesBrowsingHistoryVo browsingHistoryVo = new CasesBrowsingHistoryVo();
|
||||
browsingHistoryVo.setBrowsingHistoryId(userDynamic.getId());
|
||||
browsingHistoryVo.setContentInfo(userDynamic.getContentInfo());
|
||||
browsingHistoryVo.setEventTime(userDynamic.getEventTime());
|
||||
browsingHistoryVo.setContentId(userDynamic.getContentId());
|
||||
if (map.containsKey(userDynamic.getContentId())){
|
||||
// 重名属性,如ID,copy会出现覆盖。
|
||||
BeanUtils.copyProperties(map.get(userDynamic.getContentId()),browsingHistoryVo);
|
||||
}
|
||||
return browsingHistoryVo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
PageList<CasesBrowsingHistoryVo> pageList = new PageList<>();
|
||||
pageList.setList(batchHistoryVoList);
|
||||
pageList.setCount(userDynamicResult.getCount());
|
||||
pageList.setPageSize(userDynamicResult.getPageSize());
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Long, List<String>> queryAllTimePopularityOfMajor() {
|
||||
QueryBuilder builder = QueryBuilder.from(CasesRank.class);
|
||||
builder.addField("new CasesRank(majorId,riseRankTime)");
|
||||
builder.addFilter(FieldFilters.eq("deleted",false));
|
||||
builder.addGroupBy("majorId");
|
||||
builder.addGroupBy("riseRankTime");
|
||||
List<CasesRank> list = casesRankDao.findList(builder.builder());
|
||||
// 定义日期时间的格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy-MM");
|
||||
|
||||
Map<Long, List<String>> collect = list.stream().collect(Collectors.groupingBy
|
||||
(CasesRank::getMajorId, Collectors.mapping(casesRank -> casesRank.getRiseRankTime().format(formatter), Collectors.toList())));
|
||||
|
||||
return collect;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CaseRankingVo {
|
||||
/**
|
||||
* 案例id
|
||||
*/
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 案例标题
|
||||
*/
|
||||
private String caseTitle;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CaseViewRankingItemVo {
|
||||
|
||||
/**
|
||||
* 分类id
|
||||
*/
|
||||
private String majorId;
|
||||
|
||||
/**
|
||||
* 分类名称
|
||||
*/
|
||||
private String majorName;
|
||||
|
||||
/**
|
||||
* 上榜时间,目前默认为一月中的最后一天的23:59:59
|
||||
*/
|
||||
private LocalDateTime riseRankTime;
|
||||
|
||||
/**
|
||||
* 标签名称
|
||||
*/
|
||||
private String tagName;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class CasesBrowsingHistoryVo extends Cases{
|
||||
|
||||
/**
|
||||
* 浏览记录id
|
||||
* */
|
||||
private String browsingHistoryId;
|
||||
|
||||
/**
|
||||
* 案例标题
|
||||
* */
|
||||
private String contentInfo;
|
||||
|
||||
/**
|
||||
* 事件时间,查看案例时,有定时接口触发,名为send,eventTime为该时间
|
||||
* */
|
||||
private LocalDateTime eventTime;
|
||||
|
||||
/**
|
||||
* 案例ID
|
||||
* */
|
||||
private String contentId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
||||
@Data
|
||||
public class CasesQueryRecommendRankVo {
|
||||
|
||||
/**
|
||||
* 案例id
|
||||
*/
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 案例标题
|
||||
*/
|
||||
private String caseTitle;
|
||||
|
||||
/**
|
||||
* 案例作者
|
||||
*/
|
||||
private String caseAuthor;
|
||||
|
||||
/**
|
||||
* 推送用户名称
|
||||
*/
|
||||
private String recommendRankPushUserName;
|
||||
|
||||
/**
|
||||
* 推送时间
|
||||
*/
|
||||
private LocalDateTime recommendRankPusTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class FavoriteCaseOfIndexVo extends Cases{
|
||||
|
||||
/**
|
||||
* 收藏id
|
||||
*/
|
||||
private String favoriteId;
|
||||
|
||||
/**
|
||||
* 收藏时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime favoriteTime;
|
||||
|
||||
}
|
||||
@@ -7,9 +7,7 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
@@ -238,22 +236,46 @@ public class CourseFileApi extends ApiBaseController {
|
||||
|
||||
file.setDeleted(false);
|
||||
file.setDown(true);//默认允许下载
|
||||
file.setDuration(0);
|
||||
if (file.getResType() == null) {
|
||||
if ("mp4".indexOf(file.getFileType()) > -1) {
|
||||
file.setResType(10);//以后换成变量
|
||||
} else if ("jpg,png,gif".indexOf(file.getFileType()) > -1) {
|
||||
file.setResType(30);//以后换成变量
|
||||
if (file.getDuration()!=null){
|
||||
file.setDuration(file.getDuration()*60);
|
||||
}
|
||||
} else if ("mp3,wmv".indexOf(file.getFileType()) > -1) {
|
||||
file.setResType(20);//以后换成变量
|
||||
} else if ("doc,xls,ppt,docx,xlsx,pptx".indexOf(file.getFileType()) > -1) {
|
||||
file.setResType(40);//以后换成变量
|
||||
if (file.getDuration()!=null){
|
||||
file.setDuration(file.getDuration()*60);
|
||||
}
|
||||
}else if(file.getFileType().equalsIgnoreCase("zip")) {
|
||||
file.setResType(BoedxCourseFileType.Scrom.getValue());//scorm课件
|
||||
if (file.getDuration()!=null){
|
||||
file.setDuration(file.getDuration()*60);
|
||||
}
|
||||
} else {
|
||||
file.setResType(90);//以后换成变量
|
||||
}
|
||||
}
|
||||
if (file.getResType() != null) {
|
||||
if ("jpg,png,gif".indexOf(file.getFileType()) > -1) {
|
||||
if (file.getDuration() != null) {
|
||||
file.setDuration(file.getDuration() * 60);
|
||||
}
|
||||
}else if ("doc,xls,ppt,docx,xlsx,pptx".indexOf(file.getFileType()) > -1) {
|
||||
if (file.getDuration() != null) {
|
||||
file.setDuration(file.getDuration() * 60);
|
||||
}
|
||||
} else if (file.getFileType().equalsIgnoreCase("zip")) {
|
||||
file.setResType(BoedxCourseFileType.Scrom.getValue());//scorm课件
|
||||
if (file.getDuration() != null) {
|
||||
file.setDuration(file.getDuration() * 60);
|
||||
}
|
||||
}
|
||||
}
|
||||
String fileFullPath = SysConstant.getConfigValue(BaseConstant.CONFIG_UPLOAD_FILES_SAVEPATH) + file.getFilePath();
|
||||
if ("mp3,mp4".indexOf(file.getFileType()) > -1){
|
||||
log.info("上传 "+file.getFileType()+"文件:"+file.getFilePath());
|
||||
@@ -284,12 +306,12 @@ public class CourseFileApi extends ApiBaseController {
|
||||
}
|
||||
|
||||
try {
|
||||
Set<String> officeFileTypes = new HashSet<>(Arrays.asList("doc", "xls", "ppt", "docx", "xlsx", "pptx"));
|
||||
file.setFileType(file.getFileType());
|
||||
|
||||
if(file.getFileType().equalsIgnoreCase("pdf")) {
|
||||
file.setPreviewFilePath(file.getFilePath());
|
||||
file.setConverStatus(0);//代表不需要转化
|
||||
}else if ("doc,xls,ppt,docx,xlsx,pptx".indexOf(file.getFileType().toLowerCase()) > -1) {
|
||||
}else if (officeFileTypes.contains(file.getFileType().toLowerCase())) {
|
||||
file.setConverStatus(1);//转化中
|
||||
}else if(file.getFileType().equalsIgnoreCase("zip")) {
|
||||
//scorm包的内容
|
||||
|
||||
@@ -9,12 +9,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.Pagination;
|
||||
@@ -1164,5 +1159,11 @@ public class CourseManageApi extends ApiBaseController{
|
||||
return success(courses);
|
||||
}
|
||||
|
||||
@GetMapping("/getCourseCoverUrl")
|
||||
public JsonResponse<Map<String, String>> getCourseCoverUrl(@RequestParam String courseIds){
|
||||
Map<String, String> courseUrlMap = courseService.getCourseCoverUrl(courseIds);
|
||||
return success(courseUrlMap);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
package com.xboe.module.course.api;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.api.vo.AuditList;
|
||||
import com.xboe.api.vo.AuditListParam;
|
||||
import com.xboe.api.vo.UserDynamic;
|
||||
import com.xboe.api.vo.UserdynamicParam;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.core.JsonResponseStatus;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.module.usergroup.entity.UserGroupItem;
|
||||
import com.xboe.school.study.dao.StudyCourseDao;
|
||||
import com.xboe.school.study.entity.StudyHomeWork;
|
||||
import com.xboe.school.study.service.IStudyHomeWorkService;
|
||||
import com.xboe.school.study.service.IStudyService;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -34,11 +46,6 @@ import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.module.course.dto.CourseQueryDto;
|
||||
import com.xboe.module.course.dto.CourseTeacherDto;
|
||||
import com.xboe.module.course.dto.RankingDto;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseContent;
|
||||
import com.xboe.module.course.entity.CourseCrowd;
|
||||
import com.xboe.module.course.entity.CourseSection;
|
||||
import com.xboe.module.course.entity.CourseTeacher;
|
||||
import com.xboe.module.course.service.ICourseContentService;
|
||||
import com.xboe.module.course.service.ICourseSectionService;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
@@ -89,6 +96,15 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
@Autowired
|
||||
IStudyHomeWorkService shomeworkService;
|
||||
|
||||
@Autowired
|
||||
IStudyService studyService;
|
||||
|
||||
@Autowired
|
||||
StudyCourseDao studyCourseDao;
|
||||
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
|
||||
@@ -347,7 +363,121 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
}
|
||||
|
||||
}
|
||||
//作业导出
|
||||
@GetMapping("/export")
|
||||
public JsonResponse<String> export(String courseId,String courseName,String contentId,String name,Integer status) throws IOException {
|
||||
Map<String, String>map=new HashMap<>();
|
||||
List<String> userIds = studyCourseDao.findList(FieldFilters.eq("courseId", courseId)).stream().filter(Objects::nonNull).map(StudyCourse::getAid).collect(Collectors.toList());
|
||||
if (userIds.isEmpty()){
|
||||
return error("查询不到用户");
|
||||
}
|
||||
List<User>user=studyService.getUserNo(userIds);
|
||||
try {//筛选出的人员
|
||||
List<StudyCourseItem> list = studyService.getList(courseId, contentId, name, status);
|
||||
if(list.isEmpty()){
|
||||
return success("暂无数据");
|
||||
}
|
||||
for (StudyCourseItem s : list) {
|
||||
List<StudyHomeWork> studyHomeWorks = shomeworkService.getByStudyIdAndContentId(s.getStudyId(), contentId).stream().filter(e-> !Objects.equals(e.getFilePath(), "")).filter(e->e.getFilePath()!=null).collect(Collectors.toList());
|
||||
if(studyHomeWorks.isEmpty()){
|
||||
return success("暂无数据");
|
||||
}
|
||||
studyHomeWorks.forEach(e->{
|
||||
user.forEach(u->{
|
||||
if(u.getId().equals(s.getAid())){
|
||||
//取后缀
|
||||
int dotIndex = e.getFilePath().lastIndexOf('.'); // 查找最后一个'.'的位置
|
||||
String extension = e.getFilePath().substring(dotIndex);
|
||||
map.put(u.getName()+"-"+u.getUserNo()+extension,"/home/www/elearning/upload"+e.getFilePath());
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException("导出异常"+e.getMessage());
|
||||
}
|
||||
long totalFileSize = map.values().stream()
|
||||
.mapToLong(path -> new File(path).length())
|
||||
.sum();
|
||||
// 检查文件总大小是否超过 2GB
|
||||
if (totalFileSize > 2L * 1024 * 1024 * 1024) {
|
||||
return success("您要下载的作业过大,请分批下载或联系管理员!");
|
||||
}
|
||||
// 创建压缩文件
|
||||
String zipFilePath = "/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip";
|
||||
createZipFile(map, zipFilePath);
|
||||
return success(zipFilePath);
|
||||
// 创建一个临时文件用于存储ZIP文件
|
||||
// File tempZipFile = new File("/home/www/elearning/upload/temp.zip");
|
||||
//
|
||||
// try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(tempZipFile))) {
|
||||
// for (Map.Entry<String, String> e : map.entrySet()) {
|
||||
// File fileToZip = new File(e.getValue());
|
||||
// // 添加 ZIP 条目
|
||||
// ZipEntry entry = new ZipEntry(e.getKey());
|
||||
// entry.setSize(fileToZip.length());
|
||||
//
|
||||
// zos.putNextEntry(entry);
|
||||
//
|
||||
// try (FileInputStream fis = new FileInputStream(fileToZip)) {
|
||||
// byte[] buffer = new byte[4096];
|
||||
// int len;
|
||||
// while ((len = fis.read(buffer)) > 0) {
|
||||
// zos.write(buffer, 0, len);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// zos.closeEntry();
|
||||
// }
|
||||
// }
|
||||
// // 将临时文件移动到指定位置
|
||||
// Path source = tempZipFile.toPath();
|
||||
// //生成uuid
|
||||
//// String uuid = UUID.randomUUID().toString();
|
||||
// Path destination = Paths.get("/home/www/elearning/upload/saveZip/" + courseName+"【作业】" + ".zip");
|
||||
//
|
||||
// // 确保目标目录存在
|
||||
// Files.createDirectories(destination.getParent());
|
||||
//
|
||||
// // 删除目标文件如果已存在
|
||||
// if (Files.exists(destination)) {
|
||||
// Files.delete(destination);
|
||||
// }
|
||||
//
|
||||
// // 移动文件
|
||||
// Files.copy(source, destination, StandardCopyOption.REPLACE_EXISTING);
|
||||
//
|
||||
// // 返回文件路径给前端
|
||||
// String filePath = destination.toAbsolutePath().toString();
|
||||
// return success(filePath);
|
||||
}
|
||||
private static void createZipFile(Map<String, String> map, String zipFilePath) throws IOException {
|
||||
try (ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(zipFilePath))) {
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
String value = entry.getValue();
|
||||
|
||||
File file = new File(value);
|
||||
if (!file.exists()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
FileInputStream fis = new FileInputStream(file);
|
||||
ZipEntry zipEntry = new ZipEntry(key);
|
||||
zos.putNextEntry(zipEntry);
|
||||
|
||||
int length;
|
||||
while ((length = fis.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
zos.closeEntry();
|
||||
fis.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@GetMapping("/detail-study")
|
||||
public JsonResponse<List<CourseStudyVo>> detailStudy(String courseId, String aid){
|
||||
if(StringUtil.isBlank(courseId)){
|
||||
|
||||
@@ -85,4 +85,6 @@ public interface ICourseContentService{
|
||||
|
||||
void updateProcessVideo(String contentId, String courseId, Float processVideo);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -340,9 +340,8 @@ public interface ICourseService {
|
||||
* */
|
||||
List<Course> mobiledelList(Integer num,CourseQueryDto courseQueryDto);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取课程封面
|
||||
* */
|
||||
Map<String, String> getCourseCoverUrl(String courseIds);
|
||||
}
|
||||
|
||||
@@ -53,13 +53,17 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
||||
CourseAssess assess=dto.getAssess();
|
||||
CourseExam exam=dto.getExam();
|
||||
CourseHomeWork homework=dto.getHomework();
|
||||
|
||||
if(StringUtils.isBlank(cc.getId())) {
|
||||
//新增的情况
|
||||
cc.setDeleted(false);
|
||||
if(cc.getDuration()==null) {
|
||||
if (cc.getDuration()==null){
|
||||
cc.setDuration(0);
|
||||
}
|
||||
if(exam!=null) {
|
||||
if (exam.getTestDuration()!=null) {
|
||||
cc.setDuration(exam.getTestDuration() * 60);
|
||||
}
|
||||
}
|
||||
//如果是没有目录的,并具是课程内容
|
||||
if(dto.getType()!=null && dto.getType()==10) {
|
||||
if(cc.getSortIndex()==1) {
|
||||
@@ -69,6 +73,11 @@ public class CourseContentServiceImpl implements ICourseContentService {
|
||||
}
|
||||
ccDao.save(cc);
|
||||
}else {
|
||||
if(exam!=null) {
|
||||
if (exam.getTestDuration()!=null) {
|
||||
cc.setDuration(exam.getTestDuration() * 60);
|
||||
}
|
||||
}
|
||||
ccDao.update(cc);
|
||||
cc.setSysVersion(ccDao.getVersion(cc.getId()));
|
||||
}
|
||||
|
||||
@@ -481,7 +481,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
String sql = "SELECT DISTINCT\n" +
|
||||
"rt.course_id\n" +
|
||||
"FROM\n" +
|
||||
"boe_new.student s INNER JOIN boe_new.router_task rt on s.pid=rt.router_id inner join boe_course c on c.id=rt.course_id\n" +
|
||||
"boe.student s INNER JOIN boe.router_task rt on s.pid=rt.router_id inner join boe_course c on c.id=rt.course_id\n" +
|
||||
"\n" +
|
||||
"WHERE\n" +
|
||||
"\n" +
|
||||
@@ -504,7 +504,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
String sql = "SELECT DISTINCT\n" +
|
||||
"pt.course_id\n" +
|
||||
"FROM\n" +
|
||||
"boe_new.student s INNER JOIN boe_new.project_task pt on s.pid=pt.project_id inner join boe_course c on c.id=pt.course_id\n" +
|
||||
"boe.student s INNER JOIN boe.project_task pt on s.pid=pt.project_id inner join boe_course c on c.id=pt.course_id\n" +
|
||||
"\n" +
|
||||
"WHERE\n" +
|
||||
"\n" +
|
||||
@@ -561,8 +561,8 @@ public class CourseServiceImpl implements ICourseService {
|
||||
String sql = "SELECT DISTINCT\n" +
|
||||
"\tc.id \n" +
|
||||
"FROM\n" +
|
||||
"\tboe_new.student s\n" +
|
||||
"\tINNER JOIN boe_new.grow_task gt ON s.pid = gt.grow_id\n" +
|
||||
"\tboe.student s\n" +
|
||||
"\tINNER JOIN boe.grow_task gt ON s.pid = gt.grow_id\n" +
|
||||
"\tINNER JOIN boe_course c ON gt.course_id = c.id \n" +
|
||||
"WHERE\n" +
|
||||
"\ts.type = 14 \n" +
|
||||
@@ -1979,5 +1979,16 @@ public class CourseServiceImpl implements ICourseService {
|
||||
return courseDao.findListByHql("Select new Course(id,studys,score) from Course where id in(?1)", ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getCourseCoverUrl(String courseIds) {
|
||||
List<String> courseIdList = Arrays.asList(courseIds.split(","));
|
||||
List<Course> courseList = courseDao.findList(FieldFilters.in("id", courseIdList));
|
||||
Map<String, String> coverUrlMap = courseList.stream()
|
||||
.filter(course -> StringUtils.isNotBlank(course.getCoverImg()))
|
||||
.collect(Collectors.toMap(Course::getId, Course::getCoverImg));
|
||||
|
||||
return coverUrlMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xboe.module.exam.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
@@ -14,15 +15,12 @@ import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.xboe.module.exam.dto.SaveExamScoreDto;
|
||||
import com.xboe.module.exam.entity.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.dao.DuplicateKeyException;
|
||||
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.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
@@ -41,9 +39,6 @@ import com.xboe.core.cache.IXaskCache;
|
||||
import com.xboe.core.cache.XaskCacheProvider;
|
||||
import com.xboe.core.exception.XaskException;
|
||||
import com.xboe.module.exam.dto.AloneExamExportDto;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.module.exam.entity.AloneExamAnswer;
|
||||
import com.xboe.module.exam.entity.ExamTest;
|
||||
import com.xboe.module.exam.service.IAloneExamService;
|
||||
import com.xboe.module.exam.service.IExamPaperService;
|
||||
import com.xboe.module.exam.service.IExamTestService;
|
||||
@@ -553,6 +548,7 @@ public class AloneExamApi extends ApiBaseController {
|
||||
//转化成百分数
|
||||
//answer.setScore(this.calculateScore(detail));
|
||||
service.submit(answer,scoreType);
|
||||
service.syncExamScoreToCourseSuite(answer, request);
|
||||
return success(map);
|
||||
} catch (Exception e) {
|
||||
log.error("提交答卷错误", e);
|
||||
@@ -707,4 +703,19 @@ public class AloneExamApi extends ApiBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param request
|
||||
* @param saveExamScoreDtoList
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
@PostMapping("/examScoreBatchAdd")
|
||||
public JsonResponse examScoreBatchAdd(HttpServletRequest request, @RequestBody List<SaveExamScoreDto> saveExamScoreDtoList){
|
||||
service.examScoreBatchAdd(request, saveExamScoreDtoList);
|
||||
return success("导入成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@ package com.xboe.module.exam.api;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.hibernate.exception.ConstraintViolationException;
|
||||
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.RestController;
|
||||
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.Pagination;
|
||||
@@ -23,6 +21,8 @@ import com.xboe.module.exam.service.IExamTestService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 考试
|
||||
* */
|
||||
@@ -33,8 +33,10 @@ public class ExamTestApi extends ApiBaseController {
|
||||
|
||||
@Resource
|
||||
private IExamTestService examTestService;
|
||||
|
||||
@Resource
|
||||
ThirdApi thirdApi;
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
/**
|
||||
*查询考试,分页,搜索,资源归属,状态
|
||||
**/
|
||||
@@ -133,10 +135,16 @@ public class ExamTestApi extends ApiBaseController {
|
||||
* */
|
||||
@GetMapping("/delete")
|
||||
@AutoLog(module = "考试",action = "删除考试",info = "删除考试")
|
||||
public JsonResponse<Boolean> delete(String id){
|
||||
public JsonResponse<Boolean> delete(String id, HttpServletRequest request){
|
||||
if(StringUtil.isBlank(id)){
|
||||
return badRequest("缺少必要参数");
|
||||
}
|
||||
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtil.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
|
||||
try {
|
||||
examTestService.delete(id);
|
||||
return success(true);
|
||||
@@ -183,4 +191,21 @@ public class ExamTestApi extends ApiBaseController {
|
||||
return error("上下级失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 引用关系移除
|
||||
* */
|
||||
@PostMapping("/removeRel")
|
||||
public JsonResponse<Boolean> removeRel(@RequestParam List<String> ids){
|
||||
if(CollectionUtil.isEmpty(ids)){
|
||||
return badRequest("参数异常");
|
||||
}
|
||||
try {
|
||||
examTestService.removeRel(ids);
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
log.error("引用关系移除异常",e);
|
||||
return error("引用关系移除异常",e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,122 @@
|
||||
package com.xboe.module.exam.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 单独的考虑答卷信息
|
||||
*/
|
||||
@Data
|
||||
public class SaveExamScoreDto {
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 考试id
|
||||
*/
|
||||
private String testId;
|
||||
|
||||
// /**
|
||||
// * 考试名称
|
||||
// */
|
||||
// private String testName;
|
||||
|
||||
// /**
|
||||
// * 考试时长 分钟
|
||||
// */
|
||||
// private Integer testDuration;
|
||||
|
||||
/**
|
||||
* 试题排列 1试题乱序,2选项乱序,3全部乱序
|
||||
*/
|
||||
private Integer arrange;
|
||||
|
||||
// /**
|
||||
// * 及格线
|
||||
// */
|
||||
// private Integer passLine;
|
||||
|
||||
/**
|
||||
* 账户的代码,用于区别于同姓名的用户
|
||||
*/
|
||||
private String workNum;
|
||||
|
||||
|
||||
/**
|
||||
* 独立考试任务的id
|
||||
*/
|
||||
private String aloneId;
|
||||
|
||||
/**
|
||||
* 试卷总分
|
||||
*/
|
||||
@Column(name = "total_score")
|
||||
private Float totalScore;
|
||||
|
||||
|
||||
// /**
|
||||
// * 答卷内容
|
||||
// */
|
||||
// @Column(name = "answer_json", columnDefinition = "mediumtext")
|
||||
// private String answerJson;
|
||||
|
||||
// todo by yyk 2024-05-17 14:10:32 确定分数
|
||||
/**
|
||||
* 用户的实际得分
|
||||
*/
|
||||
private Float realScore;
|
||||
|
||||
// /**
|
||||
// * 用时秒
|
||||
// */
|
||||
// private Integer useMinute;
|
||||
|
||||
|
||||
/**
|
||||
* 最终成绩,如果是百分制,用户的实际得分会换算为百分制
|
||||
*/
|
||||
private Float score;
|
||||
|
||||
/**
|
||||
* 开始时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 结束时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
|
||||
private LocalDateTime endTime;
|
||||
|
||||
|
||||
// /**
|
||||
// * 完成状态
|
||||
// */
|
||||
// private Integer status;
|
||||
|
||||
// /**
|
||||
// * 考试次数
|
||||
// */
|
||||
// private Integer times;
|
||||
|
||||
|
||||
// /**
|
||||
// * 记录最后的操作时间
|
||||
// */
|
||||
// @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")
|
||||
// private LocalDateTime lastTime;
|
||||
|
||||
|
||||
}
|
||||
@@ -65,6 +65,7 @@ public class AloneExam extends IdBaseEntity {
|
||||
private String ucode;
|
||||
|
||||
/**关联类型*/
|
||||
/**关联类型 新增关联类型14,代表成长路径图*/
|
||||
@Column(name = "ref_type", length = 30)
|
||||
private String refType;
|
||||
|
||||
|
||||
@@ -178,4 +178,14 @@ public class ExamTest extends BaseEntity {
|
||||
|
||||
@Transient
|
||||
private String paperName;
|
||||
|
||||
/** 关联类型,1、项目 2、学习路径图 3、面授课 14、成长路径图 */
|
||||
@Column(name = "ref_type")
|
||||
private Integer refType;
|
||||
|
||||
@Column(name = "ref_id")
|
||||
private String refId;
|
||||
|
||||
@Column(name = "ref_status")
|
||||
private Integer refStatus;
|
||||
}
|
||||
|
||||
@@ -5,11 +5,13 @@ import java.util.Map;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.module.exam.dto.SaveExamScoreDto;
|
||||
import com.xboe.module.exam.dto.TestUserDto;
|
||||
import com.xboe.module.exam.dto.TestUserQuery;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.module.exam.entity.AloneExamAnswer;
|
||||
import com.xboe.module.exam.vo.AloneExamQuery;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 独立考试的处理。此信息无删除操作,更新也只是更新answerJson字段
|
||||
@@ -92,10 +94,18 @@ public interface IAloneExamService {
|
||||
|
||||
/**
|
||||
* 提交考试
|
||||
*
|
||||
* @param aea
|
||||
*/
|
||||
void submit(AloneExamAnswer aea,Integer scoreType);
|
||||
|
||||
void submit(AloneExamAnswer aea, Integer scoreType);
|
||||
|
||||
/**
|
||||
* 同步考试成绩
|
||||
* @param aea
|
||||
* @param request
|
||||
*/
|
||||
void syncExamScoreToCourseSuite(AloneExamAnswer aea, HttpServletRequest request);
|
||||
|
||||
/**
|
||||
* 更新答案
|
||||
* @param id
|
||||
@@ -156,5 +166,7 @@ public interface IAloneExamService {
|
||||
* @throws Exception
|
||||
*/
|
||||
PageList<TestUserDto> findTestUserAnswers(TestUserQuery params) throws Exception;
|
||||
|
||||
|
||||
void examScoreBatchAdd(HttpServletRequest request, List<SaveExamScoreDto> saveExamScoreDtoList);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.xboe.module.exam.service;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.module.exam.entity.ExamTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IExamTestService {
|
||||
/**
|
||||
* 分页查,状态,搜索,资源归属
|
||||
@@ -51,4 +53,5 @@ public interface IExamTestService {
|
||||
* */
|
||||
void enabled(String id,Boolean enabled);
|
||||
|
||||
void removeRel(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -1,15 +1,25 @@
|
||||
package com.xboe.module.exam.service.impl;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.module.exam.dao.ExamTestDao;
|
||||
import com.xboe.module.exam.dto.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
@@ -20,31 +30,40 @@ import com.xboe.core.orm.QueryBuilder;
|
||||
import com.xboe.core.orm.UpdateBuilder;
|
||||
import com.xboe.module.exam.dao.AloneExamAnswerDao;
|
||||
import com.xboe.module.exam.dao.AloneExamDao;
|
||||
import com.xboe.module.exam.dto.TestUserAnswerDto;
|
||||
import com.xboe.module.exam.dto.TestUserDto;
|
||||
import com.xboe.module.exam.dto.TestUserQuery;
|
||||
import com.xboe.module.exam.entity.AloneExam;
|
||||
import com.xboe.module.exam.entity.AloneExamAnswer;
|
||||
import com.xboe.module.exam.entity.ExamTest;
|
||||
import com.xboe.module.exam.service.IAloneExamService;
|
||||
import com.xboe.module.exam.vo.AloneExamQuery;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
@Service
|
||||
public class AloneExamServiceImpl implements IAloneExamService{
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(AloneExamServiceImpl.class);
|
||||
@Resource
|
||||
AloneExamAnswerDao dao;
|
||||
|
||||
@Resource
|
||||
AloneExamDao aeDao;
|
||||
|
||||
@Autowired
|
||||
private ExamTestDao examTestDao;
|
||||
|
||||
@Autowired
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(AloneExamAnswer aea){
|
||||
dao.save(aea);
|
||||
AloneExam ae=aeDao.findOne(FieldFilters.eq("aid", aea.getAid()),FieldFilters.eq("testId", aea.getTestId()));
|
||||
int currentTimes = ae.getTimes() != null ? ae.getTimes() : 0;
|
||||
//更新状态
|
||||
aeDao.update(UpdateBuilder.from(AloneExam.class)
|
||||
.addUpdateField("status", AloneExam.STATUS_NORMAL)
|
||||
.addUpdateField("times", currentTimes+1)
|
||||
.addFilter(FieldFilters.eq("aid", aea.getAid()))
|
||||
.addFilter(FieldFilters.eq("testId", aea.getTestId()))
|
||||
.addFilter(FieldFilters.eq("status",AloneExam.STATUS_NONE))
|
||||
@@ -53,8 +72,8 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void submit(AloneExamAnswer aea,Integer scoreType){
|
||||
@Transactional(propagation = Propagation.REQUIRES_NEW)
|
||||
public void submit(AloneExamAnswer aea, Integer scoreType){
|
||||
//dao.update(aea);
|
||||
aea.setStatus(AloneExamAnswer.STATUS_FINISH);
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
@@ -102,6 +121,27 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
// }
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void syncExamScoreToCourseSuite(AloneExamAnswer aea, HttpServletRequest request) {
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
|
||||
String finalToken = token;
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
AloneExam aloneExam = aeDao.findOne(FieldFilters.eq("aid", aea.getAid()), FieldFilters.eq("testId", aea.getTestId()));
|
||||
if (aloneExam.getRefType().equals("14")){
|
||||
thirdApi.syncExamScoreToCourseSuite(aloneExam, finalToken);
|
||||
}
|
||||
return "完成结果";
|
||||
}).exceptionally(ex -> {
|
||||
log.error("异步操作中发生错误: " + ex.getMessage(), ex);
|
||||
return "发生错误";
|
||||
}).thenAccept(result -> {
|
||||
log.info("同步考试成绩到课程项目完成:" + result);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@@ -142,9 +182,6 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
if(StringUtils.isNotBlank(aea.getTestId())) {
|
||||
query.addFilter(FieldFilters.eq("testId",aea.getTestId()));
|
||||
}
|
||||
if(StringUtils.isNotBlank(aea.getTestName())) {
|
||||
query.addFilter(FieldFilters.eq("testName",aea.getTestName()));
|
||||
}
|
||||
if(StringUtils.isNotBlank(aea.getAid())) {
|
||||
query.addFilter(FieldFilters.eq("aid",aea.getAid()));
|
||||
}
|
||||
@@ -427,4 +464,86 @@ public class AloneExamServiceImpl implements IAloneExamService{
|
||||
rs.setPageSize(params.getPageSize());
|
||||
return rs;
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private PlatformTransactionManager transactionManager;
|
||||
|
||||
|
||||
@Override
|
||||
public void examScoreBatchAdd(HttpServletRequest request, List<SaveExamScoreDto> saveExamScoreDtoList) {
|
||||
List<String> workNumList = saveExamScoreDtoList.stream().map(SaveExamScoreDto::getWorkNum).collect(Collectors.toList());
|
||||
|
||||
String token = request.getHeader("Xboe-Access-Token");
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
HashMap<String, String> userIdAndWorkNumMap = thirdApi.getUserIdByWorkNum(token, workNumList);
|
||||
|
||||
saveExamScoreDtoList.forEach(examScoreDto -> {
|
||||
TransactionStatus status = null; // 事务状态
|
||||
|
||||
try {
|
||||
// 获取事务定义
|
||||
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
||||
// 设置事务隔离级别
|
||||
def.setIsolationLevel(DefaultTransactionDefinition.ISOLATION_READ_COMMITTED);
|
||||
// 设置事务传播行为
|
||||
def.setPropagationBehavior(DefaultTransactionDefinition.PROPAGATION_REQUIRED);
|
||||
// 获取事务状态
|
||||
status = transactionManager.getTransaction(def);
|
||||
|
||||
AloneExamAnswer aloneExamAnswer = new AloneExamAnswer();
|
||||
BeanUtils.copyProperties(examScoreDto, aloneExamAnswer);
|
||||
|
||||
String userId = userIdAndWorkNumMap.get(examScoreDto.getWorkNum());
|
||||
aloneExamAnswer.setAid(userId);
|
||||
aloneExamAnswer.setName(examScoreDto.getUserName());
|
||||
aloneExamAnswer.setUcode(examScoreDto.getWorkNum());
|
||||
aloneExamAnswer.setStatus(AloneExamAnswer.STATUS_FINISH);
|
||||
// aloneExamAnswer.setUseSecond(examScoreDto.getUseMinute()*60);
|
||||
|
||||
ExamTest examTest = examTestDao.get(examScoreDto.getTestId());
|
||||
aloneExamAnswer.setPassLine(examTest.getPassLine());
|
||||
aloneExamAnswer.setArrange(examTest.getArrange());
|
||||
aloneExamAnswer.setTestDuration(examTest.getTestDuration());
|
||||
|
||||
// 获取考试任务ID
|
||||
AloneExam aloneExam=aeDao.findOne(FieldFilters.eq("aid", userId),FieldFilters.eq("testId", examScoreDto.getTestId()));
|
||||
aloneExamAnswer.setAloneId(aloneExam.getId());
|
||||
// 添加答卷
|
||||
dao.save(aloneExamAnswer);
|
||||
|
||||
// 更新状态,状态是未完成的,这里会有问题
|
||||
int currentTimes = aloneExam.getTimes() != null ? aloneExam.getTimes() : 0;
|
||||
if(examTest.getScoringType()!=null && examTest.getScoringType()==2) {
|
||||
//最后一次的分数为准
|
||||
aeDao.update(UpdateBuilder.from(AloneExam.class)
|
||||
.addUpdateField("status", AloneExam.STATUS_FINISH)
|
||||
.addUpdateField("score", examScoreDto.getScore())
|
||||
.addUpdateField("times", currentTimes+1)
|
||||
.addFilter(FieldFilters.eq("aid", userId))
|
||||
.addFilter(FieldFilters.eq("testId", examScoreDto.getTestId()))
|
||||
.builder());
|
||||
} else {
|
||||
if (aloneExam.getStatus() == AloneExam.STATUS_FINISH) {
|
||||
if (aloneExam.getScore() < examScoreDto.getScore()) {
|
||||
aeDao.updateMultiFieldById(aloneExam.getId(), UpdateBuilder.create("score", examScoreDto.getScore()), UpdateBuilder.create("times", currentTimes+1));
|
||||
}
|
||||
} else {
|
||||
aeDao.updateMultiFieldById(aloneExam.getId(), UpdateBuilder.create("status", AloneExam.STATUS_FINISH), UpdateBuilder.create("score", examScoreDto.getScore()), UpdateBuilder.create("times", currentTimes+1));
|
||||
}
|
||||
}
|
||||
|
||||
// 提交事务
|
||||
transactionManager.commit(status);
|
||||
} catch (Exception e) {
|
||||
// 如果发生异常,回滚事务
|
||||
if (status != null && !status.isCompleted()) {
|
||||
transactionManager.rollback(status);
|
||||
}
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -122,4 +122,10 @@ public class ExamTestServiceImpl implements IExamTestService {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeRel(List<String> ids) {
|
||||
String idsStr = String.join(",", ids);
|
||||
examTestDao.sqlUpdate("update boe_exam_test set ref_status=0 where id in (?1)",idsStr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ public class FavoriteCaseDto {
|
||||
|
||||
|
||||
private String id;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime time;
|
||||
/**
|
||||
|
||||
@@ -3,16 +3,12 @@ package com.xboe.school.study.api;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.api.vo.*;
|
||||
import com.xboe.constants.CacheName;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.module.usergroup.entity.UserGroupItem;
|
||||
import com.xboe.module.usergroup.service.IUserGroupService;
|
||||
import com.xboe.school.study.dao.StudyCourseDao;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -66,9 +62,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
@RestController
|
||||
@RequestMapping(value="/xboe/school/study/course")
|
||||
public class StudyCourseApi extends ApiBaseController{
|
||||
|
||||
|
||||
|
||||
|
||||
@Autowired
|
||||
IStudyCourseService service;
|
||||
|
||||
@@ -98,7 +92,6 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
|
||||
/**
|
||||
* 用于查询课程的学习记录
|
||||
* @param pager
|
||||
@@ -324,31 +317,34 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
if (StringUtils.isEmpty(token)) {
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
|
||||
|
||||
//检查是否已存在
|
||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||
|
||||
// 20240815 特训营结营考试 临时代码
|
||||
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
|
||||
// redisTemplate.opsForValue().set(item.getId(),item.getId());
|
||||
// //设置过期时间为1天
|
||||
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
|
||||
// }else{
|
||||
// return success("");
|
||||
// }
|
||||
if(item!=null) {
|
||||
//如果记录存在,但是进度不100无成情况,就更新进度,一期不会有这种情况
|
||||
if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
|
||||
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
|
||||
String studyKey = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + item.getCourseId()+":"+cuser.getAccountId()+":"+item.getContentId();
|
||||
String studyKey2 = CacheName.NAME_AUTH + ":" + CacheName.STUDY_KEY + sci.getCourseId()+":"+cuser.getAccountId()+":"+sci.getContentId();
|
||||
redisTemplate.opsForValue().set(studyKey,
|
||||
String.valueOf(item.getProgress()), 2, TimeUnit.HOURS);
|
||||
String progressStr = redisTemplate.opsForValue().get(studyKey2);
|
||||
if (progressStr != null && !progressStr.isEmpty()) {
|
||||
// 尝试将 Redis 中的字符串转换为整数
|
||||
int redisProgress = Integer.parseInt(progressStr);
|
||||
// 假设 item.getProgress() 返回的是 int 类型
|
||||
int sciProgress = sci.getProgress();
|
||||
|
||||
if (redisProgress < sciProgress && redisProgress < 100) {
|
||||
// 执行一些操作
|
||||
// if(item.getProgress()<100 && sci.getProgress()>item.getProgress()) {
|
||||
// }
|
||||
studyService.updateProcess(item.getId(), sci.getStudyId(), sci.getCourseId(), sci.getContentTotal(), sci.getProgress(),token);
|
||||
}
|
||||
}
|
||||
//追加学习时长
|
||||
studyService.appendStudyDuration(sci.getStudyId(),item.getId(),sci.getContentId(),sci.getDuration());
|
||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(sci.getStudyId() ,sci.getCourseId(), token);
|
||||
log.info("在线课学习记录"+allUserList);
|
||||
return success(item.getId());
|
||||
//如果记录存在,但是进度不100无成情况,就更新进度,一期不会有这种情况
|
||||
}
|
||||
|
||||
|
||||
if(StringUtils.isBlank(sci.getCourseId())){
|
||||
return error("无课程信息");
|
||||
}
|
||||
@@ -421,14 +417,6 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
|
||||
if(item!=null) {
|
||||
//如果记录存在,但是进度不到100,未完成情况,就更新进度,一期不会有这种情况
|
||||
// 20240815 特训营结营考试 临时代码
|
||||
// if(item != null && redisTemplate.opsForValue().get(item.getId())==null){
|
||||
// redisTemplate.opsForValue().set(item.getId(),item.getId());
|
||||
// //设置过期时间为1天
|
||||
// redisTemplate.expire(item.getId(), 60, TimeUnit.SECONDS);
|
||||
// }else{
|
||||
// return success("");
|
||||
// }
|
||||
if(item.getProgress()<100) {
|
||||
studyService.updateProcess(item.getId(),sci.getStudyId(),sci.getCourseId(), sci.getContentTotal(),100,token);
|
||||
}
|
||||
@@ -534,14 +522,6 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
token = request.getHeader("token");
|
||||
}
|
||||
try {
|
||||
// 20240815 特训营结营考试 临时代码
|
||||
// if(itemId != null && redisTemplate.opsForValue().get(itemId)==null){
|
||||
// redisTemplate.opsForValue().set(itemId,itemId);
|
||||
// //设置过期时间为1天
|
||||
// redisTemplate.expire(itemId, 60, TimeUnit.SECONDS);
|
||||
// }else{
|
||||
// return success(true);
|
||||
// }
|
||||
studyService.finishVideoStudyItem(itemId, studyId,courseId,cnum,token);
|
||||
List<StudyCourse> allUserList = thirdApi.getStudyCourseList(studyId ,courseId, token);
|
||||
log.info("在线课学习记录"+allUserList);
|
||||
@@ -723,10 +703,9 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
return error("查询失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping(value="/study-course-content",method = {RequestMethod.GET,RequestMethod.POST})
|
||||
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId, HttpServletRequest request){
|
||||
public JsonResponse<StudyCourseItem> findStudyCourseItem(String studyId,String contentId){
|
||||
if(StringUtils.isBlank(studyId)){
|
||||
return error("无学习信息");
|
||||
}
|
||||
|
||||
@@ -93,8 +93,8 @@ public class StudyExamApi extends ApiBaseController{
|
||||
exam.setEndTime(exam.getLastTime());
|
||||
}
|
||||
log.info( exam.getStudyId() + "_" + exam.getContentId() + ",------------试卷开始提交 " + LocalDateTime.now());
|
||||
String msg = sexamService.save(exam,token);
|
||||
log.info( exam.getStudyId() + "_" + exam.getContentId() + ",------------试卷保存完毕 ,msg = " + msg + " , " + LocalDateTime.now());
|
||||
sexamService.save(exam,token);
|
||||
//log.info( exam.getStudyId() + "_" + exam.getContentId() + ",------------试卷保存完毕 ,msg = " + msg + " , " + LocalDateTime.now());
|
||||
exam.setAnswerJson("");
|
||||
exam.setPaperJson("");
|
||||
|
||||
|
||||
@@ -89,7 +89,6 @@ public class StudyHomeWorkApi extends ApiBaseController{
|
||||
return error("查询课程作业失败",e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/list-study")
|
||||
public JsonResponse<List<StudyHomeWork>> listByStudyIdContentId(String studyId,String contentId){
|
||||
if(StringUtils.isBlank(studyId)) {
|
||||
|
||||
@@ -10,7 +10,7 @@ public interface IStudyExamService {
|
||||
* 保存考试信息
|
||||
* @param exam
|
||||
*/
|
||||
String save(StudyExam exam,String token);
|
||||
void save(StudyExam exam,String token);
|
||||
|
||||
|
||||
StudyExam get(String id);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xboe.school.study.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import com.xboe.school.study.entity.StudyHomeWork;
|
||||
@@ -29,4 +30,6 @@ public interface IStudyHomeWorkService {
|
||||
* @return
|
||||
*/
|
||||
List<StudyHomeWork> getByStudyIdAndContentId(String studyId,String contentId);
|
||||
|
||||
List<StudyHomeWork>getByStudnetNameAndContentId(List<String> studentName, String contentId);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.xboe.common.PageList;
|
||||
import com.xboe.school.study.dto.StudyContentDto;
|
||||
import com.xboe.school.study.entity.StudyCourseItem;
|
||||
import com.xboe.school.study.entity.StudyTime;
|
||||
import com.xboe.system.user.entity.User;
|
||||
|
||||
/**
|
||||
* 学习情况处理,比较综合一个处理类
|
||||
@@ -95,4 +96,8 @@ public interface IStudyService {
|
||||
* @return
|
||||
*/
|
||||
PageList<StudyCourseItem> findItemPage(int pageIndex, int pageSize, String contentId, String courseId, String name, Integer status);
|
||||
|
||||
List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status);
|
||||
|
||||
List<User> getUserNo(List<String> userIds);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@ import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -18,6 +21,7 @@ import com.xboe.school.study.entity.StudyAssess;
|
||||
import com.xboe.school.study.entity.StudyCourseItem;
|
||||
import com.xboe.school.study.service.IStudyAssessService;
|
||||
|
||||
|
||||
@Service
|
||||
public class StudyAssessServiceImpl implements IStudyAssessService{
|
||||
|
||||
@@ -33,6 +37,7 @@ public class StudyAssessServiceImpl implements IStudyAssessService{
|
||||
@Autowired
|
||||
StudyCourseItemDao scItemDao;
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(StudyAssess assess,String token) {
|
||||
@@ -67,7 +72,7 @@ public class StudyAssessServiceImpl implements IStudyAssessService{
|
||||
assess.setStudyItemId(obj.toString());
|
||||
dao.update(assess);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -54,7 +54,7 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public String save(StudyExam exam,String token) {
|
||||
public void save(StudyExam exam,String token) {
|
||||
String key = exam.getStudyId() + "_" + exam.getContentId();
|
||||
// //判断是否存在redis
|
||||
// if(StringUtils.isNotEmpty(redisTemplate.opsForValue().get(key))){
|
||||
@@ -142,7 +142,6 @@ public class StudyExamServiceImpl implements IStudyExamService{
|
||||
scDao.updateFieldById(exam.getStudyId(), "last_score",exam.getScore());
|
||||
//执行完毕 清除redis记录
|
||||
// redisTemplate.delete(key);
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -89,4 +89,9 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
|
||||
return dao.findList(FieldFilters.eq("studyId", studyId),FieldFilters.eq("contentId", contentId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StudyHomeWork> getByStudnetNameAndContentId(List<String> studentName, String contentId) {
|
||||
return dao.findList(FieldFilters.in("student_name", studentName),FieldFilters.eq("contentId", contentId));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,12 +8,12 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.transaction.Transactional;
|
||||
|
||||
import com.xboe.module.article.entity.Article;
|
||||
import com.xboe.module.interaction.entity.Shares;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.system.user.entity.User;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -98,6 +98,8 @@ public class StudyServiceImpl implements IStudyService{
|
||||
//sci.setProgress(100);//直接设置为学习完成
|
||||
sci.setLastTime(ldt);
|
||||
scItemDao.saveOrUpdate(sci);
|
||||
|
||||
dto.setStudyItemId(sci.getId());
|
||||
if (sci.getId() != null){
|
||||
dto.setStudyItemId(sci.getId());
|
||||
}else {
|
||||
@@ -184,15 +186,17 @@ public class StudyServiceImpl implements IStudyService{
|
||||
query.addFilter(FieldFilters.eq("courseId",courseId));
|
||||
}
|
||||
if(StringUtils.isNotBlank(name)) {
|
||||
query.addFilter(FieldFilters.eq("aname", name));
|
||||
query.addFilter(FieldFilters.like("aname", name));
|
||||
}
|
||||
int pageIndex2 = (pageIndex-1)*10;
|
||||
if(status!=null) {
|
||||
if(status==3) {
|
||||
query.addFilter(FieldFilters.eq("status", 2));
|
||||
query.addFilter(FieldFilters.like("aname", name));
|
||||
return scItemDao.findPage(query.builder());
|
||||
}else if(status==2){
|
||||
query.addFilter(FieldFilters.eq("status",9));
|
||||
query.addFilter(FieldFilters.like("aname", name));
|
||||
return scItemDao.findPage(query.builder());
|
||||
}else if (status == 1) {
|
||||
String sql = "select bsc.id,bsc.course_id,bsc.course_name,bsc.aname,item.content_id,0 as progress,1 as status from boe_study_course bsc " +
|
||||
@@ -272,6 +276,39 @@ public class StudyServiceImpl implements IStudyService{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StudyCourseItem> getList(String courseId, String contentId, String name, Integer status) {
|
||||
|
||||
QueryBuilder query=QueryBuilder.from(StudyCourseItem.class);
|
||||
|
||||
OrderCondition oc=OrderCondition.desc("id");
|
||||
query.addOrder(oc);
|
||||
if(StringUtils.isNotBlank(contentId)) {
|
||||
query.addFilter(FieldFilters.eq("contentId",contentId));
|
||||
}
|
||||
if(StringUtils.isNotBlank(courseId)) {
|
||||
query.addFilter(FieldFilters.eq("courseId",courseId));
|
||||
}
|
||||
|
||||
if(status!=null) {
|
||||
if(status==1) {
|
||||
query.addFilter(FieldFilters.eq("progress", 0));
|
||||
}else {
|
||||
query.addFilter(FieldFilters.eq("progress",100));
|
||||
}
|
||||
|
||||
}
|
||||
if(StringUtils.isNotBlank(name)) {
|
||||
query.addFilter(FieldFilters.eq("aname", name));
|
||||
}
|
||||
return scItemDao.findList(query.builder());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<User> getUserNo(List<String> userIds) {
|
||||
return userDao.findList(FieldFilters.in("id", userIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress,String token) {
|
||||
|
||||
@@ -72,6 +72,10 @@ infrasApi.dict=${boe.domain}/infrasApi/dict/list
|
||||
#获取非报名课id
|
||||
manageApi.stu.offcourse=${boe.domain}/manageApi/stu/offcourse/getOffCourseId
|
||||
manageApi.editExam=${boe.domain}/manageApi/admin/project/editExam
|
||||
manageApi.getExamSycn=${boe.domain}/manageApi/stu/grow/getExamSync
|
||||
#获取离职教师id
|
||||
userBasic.getTeacherIds=${boe.domain}/userbasic/user/getTeacherInfo
|
||||
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
|
||||
userBasic.getUserIdByWorkNum=${boe.domain}/userbasic/user/getUserIdByWorkNum
|
||||
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
|
||||
coursesuilt.checkBanding=${boe.domain}/manageApi/stu/task/exam/checkBanding
|
||||
coursesuilt.syncExamScoreToCourseSuite=${boe.domain}/manageApi/stu/task/exam/syncExamScoreToCourseSuite
|
||||
Reference in New Issue
Block a user