Compare commits

..

3 Commits

48 changed files with 571 additions and 2260 deletions

View File

@@ -20,7 +20,7 @@ import com.xboe.common.utils.StringUtil;
public class ElasticsearchConfig {
@Value("${xboe.elasticsearch.server.ip}")
private String esIp="10.251.88.214";
private String esIp="127.0.0.1";
@Value("${xboe.elasticsearch.server.port}")
private int esPort=9200;

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
@@ -16,38 +16,38 @@
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>2021.0.5</spring-cloud.version>
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
<nacos-client.version>2.2.0</nacos-client.version>
<spring-cloud-alibaba.version>2021.0.5.0</spring-cloud-alibaba.version>
<nacos-client.version>2.2.0</nacos-client.version>
</properties>
<dependencies>
<!-- 引入Cloud -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<exclusions>
<exclusion>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos-client.version}</version>
</dependency>
<!-- end -->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<exclusions>
<exclusion>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>${nacos-client.version}</version>
</dependency>
<!-- end -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.16</version>
</dependency>
<dependency>
<groupId>com.xboe</groupId>
<artifactId>xboe-api</artifactId>
@@ -58,7 +58,7 @@
<artifactId>xboe-module-scorm</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<dependency>
<groupId>com.xboe</groupId>
<artifactId>xboe-core</artifactId>
<version>1.0.0</version>
@@ -84,6 +84,7 @@
<artifactId>xboe-module-es</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>it.sauronsoftware</groupId>
<artifactId>jave</artifactId>
@@ -92,9 +93,9 @@
<systemPath>${project.basedir}/src/main/resources/libs/jave-1.0.2.jar</systemPath>
</dependency>
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.18.3</version>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>3.18.3</version>
</dependency>
<!--
<dependency>
@@ -109,8 +110,8 @@
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
</dependency>
<dependency>
@@ -129,10 +130,10 @@
<groupId>org.springframework.session</groupId>
<artifactId>spring-session-data-redis</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
@@ -184,13 +185,13 @@
</dependency>
<!-- aspose -->
<dependency>
<groupId>com.aspose</groupId>
<artifactId>slides</artifactId>
<version>15.9.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/aspose/aspose.slides-15.9.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>slides</artifactId>
<version>15.9.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/aspose/aspose.slides-15.9.0.jar</systemPath>
</dependency>
<dependency>
<groupId>com.aspose</groupId>
<artifactId>words</artifactId>
@@ -213,20 +214,20 @@
<version>3.0.3</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.9.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.9.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.9.0</version>
</dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-high-level-client</artifactId>
<version>7.9.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>7.9.0</version>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>7.9.0</version>
</dependency>
<dependency>
<groupId>org.springframework.retry</groupId>
<artifactId>spring-retry</artifactId>
@@ -235,32 +236,32 @@
</dependencies>
<build>
<resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>application-${profileActive}.properties</include>
<include>application.properties</include>
</includes>
</resource>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.properties</exclude>
</excludes>
</resource>
</resources>
<resource>
<filtering>true</filtering>
<directory>src/main/resources</directory>
<includes>
<include>application-${profileActive}.properties</include>
<include>application.properties</include>
</includes>
</resource>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.properties</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- <version>3.8.0</version> -->
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<!-- <version>3.8.0</version> -->
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
@@ -271,8 +272,8 @@
<artifactId>lombok</artifactId>
</exclude>
</excludes>
<includeSystemScope>true</includeSystemScope>
</configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
</plugins>
</build>
@@ -295,12 +296,12 @@
<profileActive>test</profileActive>
</properties>
</profile>
<profile>
<id>test135</id>
<properties>
<profileActive>test135</profileActive>
</properties>
</profile>
<profile>
<id>test135</id>
<properties>
<profileActive>test135</profileActive>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>

View File

@@ -12,14 +12,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.system.ApplicationPid;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
@Configuration
@SpringBootApplication
@EnableCaching
@EnableAsync
@EnableRetry
@EnableScheduling
public class BoeServerAllApplication {
public static void main(String[] args) {

View File

@@ -13,14 +13,9 @@ 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 javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
@@ -68,10 +63,6 @@ public class ThirdApi {
@Value("${manageApi.editExam}")
private String editExam;
@Value("${userBasic.getUserBasicInfo}")
private String getUserBasicInfo;
//获取例外人员的id
public List<String> getUserId(){
String responseBody = Optional.ofNullable(HttpRequest.get(infarasApiUrl+"?pid=316&type=1").execute() //prod 316
@@ -240,66 +231,5 @@ public class ThirdApi {
}
/**
* 获取案例浏览记录
*/
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();
}
/**
* 虽然当前已存在接口查询用户基本信息目前仅仅包括用户名、工号、用户ID
*/
public List<UserBasicInfo> getUserBasicInfoByUserId(List<String> userIds, HttpServletRequest request) {
String token = request.getHeader("Xboe-Access-Token");
if (StringUtils.isEmpty(token)) {
token = request.getHeader("token");
}
if (StringUtils.isEmpty(token)) {
token = request.getHeader("x-access-token");
}
// 将userIds列表转换为逗号分隔的字符串
String userIdsStr = userIds.stream()
.collect(Collectors.joining(","));
String url = getUserBasicInfo +"?userIds=" + userIdsStr;
String respStr = Optional.ofNullable(HttpRequest
.get(url)
.header("token", token)
.execute().body()).orElseThrow(() -> new RuntimeException("用户中心用户数据获取失败"));
UserBasicInfoResult userBasicInfoResult = JSONUtil.parseObj(respStr).toBean(UserBasicInfoResult.class);
List<UserBasicInfo> basicInfos = userBasicInfoResult.getResult();
return basicInfos;
}
}

View File

@@ -1,23 +0,0 @@
package com.xboe.api.vo;
import lombok.Data;
@Data
public class UserBasicInfo {
/**
* 用户ID
*/
private String userId;
/**
* 用户名。
*/
private String userName;
/**
* 工号。
*/
private String workNum;
}

View File

@@ -1,35 +0,0 @@
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.List;
@Data
@Slf4j
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserBasicInfoResult {
private String error;
private String message;
private String permissions;
private List<UserBasicInfo> result;
private int status;
private Date timestamp;
public UserBasicInfoResult success() {
if (this.status != 200) {
log.error("获取用户基本信息失败----{}", JSONUtil.toJsonPrettyStr(this));
return null;
}
return this;
}
}

View File

@@ -133,26 +133,4 @@ public interface CacheName {
* 字典缓存key
* */
String KEY_DICT="dict";
String STUDY_KEY = "StudyKey:";
/**
* 季度观看量排行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";
}

View File

@@ -1,26 +0,0 @@
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;
}

View File

@@ -1,32 +0,0 @@
package com.xboe.module.boecase.api;
import com.xboe.module.boecase.service.ICasesService;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
@Component
public class CaseScheduledTasks {
@Resource
private ICasesService casesService;
/**
* 每月的第一天的1:00执行
*/
@Scheduled(cron = "0 0 1 1 * ?")
public void refreshViewsRankOfMajor() {
casesService.refreshViewsRankOfMajor();
}
/**
* 季初第一天两点执行cron表达式设置为每个季度的第一个月的第一天的特定时间。每个季度的第一个月是1月、4月、7月和10月
*/
@Scheduled(cron = "0 0 2 1 1,4,7,10 ?")
public void refreshLastQuarterStatistics() {
casesService.refreshLastQuarterStatistics();
}
}

View File

@@ -11,14 +11,18 @@ 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.*;
import com.xboe.module.boecase.vo.CaseExportVo;
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.*;
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 cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
@@ -35,7 +39,6 @@ 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;
@@ -124,12 +127,25 @@ public class CasesApi extends ApiBaseController {
@PostMapping("/queryListV2")
public JsonResponse<PageList<Cases>> queryCaseBreV2(@Validated @RequestBody CasePageVo req) {
String type = req.getType();
req.setUserId(getCurrent().getAccountId());
PageList<Cases> subViews1;
PageList<Cases> subViews2;
PageList<Cases> views = null;
if (type.equals("recommend")) {
views = casesService.queryRecommendPageCasesV2(req);
req.setUserId(getCurrent().getAccountId());
if (StringUtils.isNotEmpty(type)) {
if ("recommend".equals(type)) {
views = casesService.queryRecommendPageCasesV2(req);
} else {
views = casesService.queryPageCasesV2(req);
}
} else {
views = casesService.queryPageCasesV2(req);
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);
}
if (views != null) {
@@ -159,6 +175,24 @@ 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();
@@ -612,8 +646,7 @@ public class CasesApi extends ApiBaseController {
if (ids.isEmpty()) {
return badRequest("参数异常");
}
String accountId = getCurrent().getAccountId();
List<Cases> cases = casesService.ids(ids,accountId);
List<Cases> cases = casesService.ids(ids);
return success(cases);
}
@@ -621,7 +654,7 @@ public class CasesApi extends ApiBaseController {
* 设置/取消优秀案例
*/
@PostMapping("/excellent")
public JsonResponse<Boolean> excellent(String id, Boolean excellent,String excellentReason) {
public JsonResponse<Boolean> excellent(String id, Boolean excellent) {
if (StringUtil.isBlank(id)) {
return badRequest("参数异常");
}
@@ -629,145 +662,12 @@ public class CasesApi extends ApiBaseController {
excellent = false;//默认设置取消
}
try {
casesService.excellent(id, excellent,excellentReason);
casesService.excellent(id, excellent);
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 String 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<String, List<String>>> queryAllTimePopularityOfMajor() {
Map<String, 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);
}
}

View File

@@ -1,24 +1,18 @@
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.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.*;
import com.xboe.core.orm.FieldFilters;
import com.xboe.module.boecase.dto.CaseVo;
@Repository
@Slf4j
public class CasesDao extends BaseDao<Cases> {
/**
@@ -41,106 +35,4 @@ 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;
}
}

View File

@@ -1,88 +0,0 @@
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 bdmt.code = bcvr.major_id \n" +
"WHERE bcvr.case_id = ?1 AND bcvr.deleted=0 AND bdmt.deleted=0\n" +
"ORDER BY bcvr.rise_rank_time DESC;";
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(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, String 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;
}
}

View File

@@ -21,79 +21,50 @@ import java.util.List;
*/
@Repository
public interface CasesRecordDao extends JpaRepository<Cases, String>, JpaSpecificationExecutor<Cases> {
@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"
)
@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")
Page<Cases> queryList(Pageable pageable, @Param("condition") CasePageVo casePage);

View File

@@ -3,7 +3,6 @@ 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;
@@ -249,7 +248,16 @@ 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;
/**
* 最佳案例标识
@@ -264,48 +272,6 @@ 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 种类
* 区分 案例/推荐案例
@@ -313,6 +279,11 @@ public class Cases extends BaseEntity {
@Transient
private String type;
/**
* id
*/
@Transient
private List<String> majorIds;
@@ -325,15 +296,6 @@ 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;
}
@@ -418,7 +380,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;
@@ -436,6 +398,7 @@ public class Cases extends BaseEntity {
this.favorites=favorites;
super.setDeleted(deleted);
}
public Cases(String title) {
this.title = title;
}
@@ -452,29 +415,4 @@ 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);
}
}

View File

@@ -1,61 +0,0 @@
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 String 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(String majorId, LocalDateTime riseRankTime) {
this.majorId = majorId;
this.riseRankTime = riseRankTime;
}
}

View File

@@ -54,15 +54,8 @@ 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;
}
}

View File

@@ -1,22 +1,14 @@
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{
/**
* 案例分页搜索,是否被推荐
@@ -99,7 +91,7 @@ public interface ICasesService{
/**
* 用于二次查询
* */
List<Cases> ids(List<String> ids, String accountId);
List<Cases> ids(List<String> ids);
/**
*二期 首页的推荐案例
@@ -109,7 +101,7 @@ public interface ICasesService{
/**
* 设置或者取消优秀案例
* */
void excellent(String id, Boolean excellent, String excellentReason);
void excellent(String id,Boolean excellent);
PageList<Cases> queryRecommendPageCasesV2(CasePageVo req);
@@ -118,27 +110,5 @@ 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, String 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<String, List<String>> queryAllTimePopularityOfMajor();
}

View File

@@ -2,14 +2,8 @@ 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;
@@ -17,40 +11,29 @@ 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.*;
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.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.servlet.http.HttpServletRequest;
import java.lang.reflect.Array;
import javax.transaction.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
@Slf4j
@Service
@@ -78,15 +61,6 @@ public class CasesServiceImpl implements ICasesService {
@Autowired
private CasesRecommendDao casesRecommendDao;
@Resource
private CasesRankDao casesRankDao;
@Resource
private StringRedisTemplate stringRedisTemplate;
@Resource
private ThirdApi thirdApi;
/**
* 案例分页查询,用于门户的查询
*/
@@ -204,6 +178,12 @@ 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;
@@ -316,16 +296,18 @@ public class CasesServiceImpl implements ICasesService {
filters.add(FieldFilters.eq("excellent", caseVo.getExcellent()));
}
OrderCondition order = null;
if (StringUtils.isNotBlank(caseVo.getOrderField()) && caseVo.getOrderAsc() != null && ("sysCreateTime".equals(caseVo.getOrderField()) || "views".equals(caseVo.getOrderField()))) {
if (caseVo.getOrderAsc()) {
if (StringUtils.isNotBlank(caseVo.getOrderField())) {
if (caseVo.getOrderAsc() == null || caseVo.getOrderAsc()) {
order = OrderCondition.asc(caseVo.getOrderField());
} else {
order = OrderCondition.desc(caseVo.getOrderField());
}
} else {
order = OrderCondition.desc("sysCreateTime");
}
if (StrUtil.equals(type,"new")) {
order = OrderCondition.desc("sysCreateTime");
} else if (StrUtil.equals(type,"hot")) {
order = OrderCondition.desc("views");
}
if(Objects.nonNull(order)) {
query.addOrder(order);
}
@@ -333,18 +315,53 @@ public class CasesServiceImpl implements ICasesService {
query.setPageIndex(caseVo.getPageIndex());
query.setPageSize(caseVo.getPageSize());
page = casesDao.findPage(query.builder());
List<Cases> casesList = page.getList();
casesList.forEach(it->{
List<Cases> list = page.getList();
list.forEach(it->{
it.setBreCommend(0);
});
casesList = caseListCommonHandle(casesList, caseVo.getUserId());
page.setList(casesList);
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);
}
});
}
}
}
return page;
}
@Override
public PageList<Cases> queryRecommendPageCasesV2(CasePageVo caseVo) {
@@ -391,90 +408,37 @@ 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));
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);
//3.案例类型处理
// majorTypeHandle(casesList);
return casesList;
}
private void majorTypeHandle(List<Cases> casesList) {
if (CollUtil.isNotEmpty(casesList)) {
for (Cases c : casesList) {
StringBuffer stringBuffer = new StringBuffer();
List<CasesMajorType> caseId = casesMajorTypeDao.findList(FieldFilters.eq("caseId", c.getId()));
if (caseId != null && !caseId.isEmpty()) {
for (CasesMajorType cm : caseId) {
stringBuffer.append(cm.getMajorId());
stringBuffer.append(",");
}
}
if (stringBuffer.length() > 0) {
stringBuffer.deleteCharAt(stringBuffer.length() - 1);
c.setMajorType(stringBuffer.toString());
}
}
}
}
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)
))
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)
.addField("new CasesRecommend(id,recommendOrgName,recommendTime)")
.addFilters(Arrays.asList(
FieldFilters.eq("deleted", Boolean.FALSE),
FieldFilters.in("id", rIds)
));
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);
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));
casesList.forEach(it -> {
Map<String, CasesRecommend> collect = recommands.stream().collect(Collectors.toMap(k -> k.getId(), item->item));
content.forEach(it -> {
CasesRecommendPushRecord one = CollUtil.findOne(pushRecords, (a) -> StrUtil.equals(a.getCaseId(), it.getId()));
if (Objects.nonNull(one)) {
CasesRecommend recommend = collect.get(one.getRecommendId());
@@ -482,76 +446,13 @@ public class CasesServiceImpl implements ICasesService {
it.setRefId(one.getId());
it.setRecommendOrgName(recommend.getRecommendOrgName());
it.setSysCreateTime(recommend.getRecommendTime());
} else {
it.setBreCommend(0);
}
});
}
}
}
}
/**
* 添加案例标签、作者标签最佳案例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()) {
if (e.getDraftingTime()!=null){
e.setExcellentTag(e.getDraftingTime().format(DateTimeFormatter.ofPattern("yy年"))+"度最佳");
} else {
e.setExcellentTag(e.getSysCreateTime().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);
});
pageList.setList(content);
return pageList;
}
public static void main(String[] args) {
@@ -1044,12 +945,11 @@ public class CasesServiceImpl implements ICasesService {
}
@Override
public List<Cases> ids(List<String> ids, String accountId) {
public List<Cases> ids(List<String> ids) {
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,keyword1,keyword2,keyword3,keyword4,keyword5)");
builder.addFields("new Cases(id,title,summary,coverUrl,authorId,authorName,sysCreateTime,breCommend,views,comments,praises,shares,favorites,deleted,sysCreateBy,sysCreateAid)");
List<Cases> cases = casesDao.findList(builder.builder());
cases = caseListCommonHandle(cases, accountId);
return cases;
}
@@ -1178,385 +1078,15 @@ public class CasesServiceImpl implements ICasesService {
}
@Override
public void excellent(String id, Boolean excellent, String excellentReason) {
public void excellent(String id, Boolean excellent) {
//取消时,把时间清空
if (excellent) {
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", LocalDateTime.now()), UpdateBuilder.create("excellentReason", excellentReason));
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", LocalDateTime.now()));
} else {
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", null), UpdateBuilder.create("excellentReason", null));
casesDao.updateMultiFieldById(id, UpdateBuilder.create("excellent", excellent), UpdateBuilder.create("excellentTime", null));
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void refreshViewsRankOfMajor(){
log.info("开始执行每月案例浏览量相关定时任务");
// 获取上个月的第一天的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";
String sql =
"SELECT bc.id,bcmt.major_id,bc.views 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 !=0 and bc.views is not null";
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(Array.get(o, 1).toString());
casesRank.setMonthlyIncrement(Integer.parseInt(Array.get(o, 2).toString()));
casesRank.setRiseRankTime(lastDayOfLastMonth);
return casesRank;
}).collect(Collectors.toList());
// 根据专业分类进行分组
Map<String, 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
int i = casesDao.sqlUpdate("update boe_cases set last_month_views=views where deleted=0");
log.info("每月案例浏览量相关定时任务执行完成boe_cases更新数据量为条数为"+i);
log.info("每月案例浏览量相关定时任务执行完成boe_cases_rank添加数据量为条数为"+lastMonthRank.size());
}
@Override
public void refreshLastQuarterStatistics() {
log.info("开始执行每季案例相关定时任务");
int i = casesDao.sqlUpdate("update boe_cases set last_quarter_views=views,last_quarter_praises=praises where deleted=0");
log.info("每季案例相关定时任务执行完成boe_cases更新数据量为条数为"+i);
}
@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, String 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());
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);
//获取案例与排名的映射关系
Map<Object, Integer> collect = popularityOfMajor.stream().collect(Collectors.toMap(map -> map.get("caseId").toString(), map -> Integer.valueOf(map.get("rank").toString())));
//排序榜单案例顺序
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);
}
});
casesList.forEach(cases -> {
List<CaseViewRankingItemVo> viewRankTags = cases.getViewRankTags();
// 使用 Stream API 进行排序,保持其余元素的原始顺序
List<CaseViewRankingItemVo> sortedList = viewRankTags.stream()
.sorted((o1, o2) -> {
// majorId 相等时放前面
boolean o1Matches = o1.getMajorId().equals(majorId);
boolean o2Matches = o2.getMajorId().equals(majorId);
if (o1Matches && !o2Matches) return -1; // o1是majorId, o2不是o1排前
if (!o1Matches && o2Matches) return 1; // o2是majorId, o1不是o2排前
return 0; // 如果两者都是或都不是majorId, 保持原有顺序
})
.collect(Collectors.toList());
// 更新原列表
cases.setViewRankTags(sortedList);
});
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())){
// 重名属性如IDcopy会出现覆盖。
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<String, 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<String, List<String>> collect = list.stream().collect(Collectors.groupingBy
(CasesRank::getMajorId, Collectors.mapping(casesRank -> casesRank.getRiseRankTime().format(formatter), Collectors.toList())));
return collect;
}
}

View File

@@ -1,17 +0,0 @@
package com.xboe.module.boecase.vo;
import lombok.Data;
@Data
public class CaseRankingVo {
/**
* 案例id
*/
private String caseId;
/**
* 案例标题
*/
private String caseTitle;
}

View File

@@ -1,29 +0,0 @@
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;
}

View File

@@ -1,31 +0,0 @@
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;
/**
* 事件时间查看案例时有定时接口触发名为sendeventTime为该时间
* */
private LocalDateTime eventTime;
/**
* 案例ID
* */
private String contentId;
}

View File

@@ -1,37 +0,0 @@
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;
}

View File

@@ -1,23 +0,0 @@
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;
}

View File

@@ -4,10 +4,13 @@ import java.util.List;
import javax.annotation.Resource;
import com.xboe.common.utils.StringUtil;
import com.xboe.core.log.AutoLog;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PathVariable;
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 com.xboe.core.JsonResponse;
import com.xboe.core.api.ApiBaseController;
@@ -74,22 +77,7 @@ public class CourseContentApi extends ApiBaseController{
}
return success(obj);
}
@GetMapping("/exam/paper-content")
@AutoLog(module = "试卷",action = "查看试卷试题",info = "查看当前试题内容")
public JsonResponse<Object> paperContent(String courseExamId){
if(StringUtil.isBlank(courseExamId)){
return badRequest("缺少必要参数");
}
try {
Object paperContentOfOnline = ccontentService.getPaperContentOfOnline(courseExamId);
return success(paperContentOfOnline);
} catch (Exception e) {
log.error("查询试卷内容json错误",e);
return error("查询失败",e.getMessage());
}
}
/**
* 获取评估信息
* @param ccid

View File

@@ -1,50 +1,57 @@
package com.xboe.module.course.api;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.xboe.api.ThirdApi;
import com.xboe.api.vo.UserBasicInfo;
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.module.course.vo.TeacherVo;
import com.xboe.module.usergroup.entity.UserGroupItem;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
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 com.xboe.common.PageList;
import com.xboe.common.Pagination;
import com.xboe.common.utils.StringUtil;
import com.xboe.core.JsonResponse;
import com.xboe.core.api.ApiBaseController;
import com.xboe.core.orm.FieldFilters;
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.*;
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;
import com.xboe.module.course.service.ICourseTeacherService;
import com.xboe.module.course.vo.CourseStudyVo;
import com.xboe.module.course.vo.TeacherVo;
import com.xboe.module.teacher.entity.Teacher;
import com.xboe.module.teacher.service.ITeacherService;
import com.xboe.module.usergroup.service.IUserGroupService;
import com.xboe.school.study.dao.StudyCourseDao;
import com.xboe.school.study.entity.StudyCourse;
import com.xboe.school.study.entity.StudyCourseItem;
import com.xboe.school.study.entity.StudyHomeWork;
import com.xboe.school.study.service.IStudyCourseService;
import com.xboe.school.study.service.IStudyHomeWorkService;
import com.xboe.school.study.service.IStudyService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import lombok.extern.slf4j.Slf4j;
/**
@@ -60,19 +67,19 @@ public class CoursePortalApi extends ApiBaseController{
@Resource
private ICourseService courseService;
@Resource
private ITeacherService teacherService;
@Resource
private ICourseContentService contentService;
@Resource
private ICourseSectionService sectionService;
@Resource
private ICourseTeacherService courseTeacherService;
@Autowired
private IUserGroupService userGroupService;
@@ -82,15 +89,6 @@ public class CoursePortalApi extends ApiBaseController{
@Resource
private ThirdApi thirdApi;
@Autowired
IStudyHomeWorkService shomeworkService;
@Autowired
IStudyService studyService;
@Autowired
StudyCourseDao studyCourseDao;
@Autowired
StringRedisTemplate redisTemplate;
@@ -110,9 +108,9 @@ public class CoursePortalApi extends ApiBaseController{
Map<String,Object> list=courseService.findImages(cids);
return success(list);
}
/**
* 人气榜
* 人气榜
* */
@PostMapping("/ranking")
public JsonResponse<List<RankingDto>> Ranking(Integer type,Integer time){
@@ -138,7 +136,7 @@ public class CoursePortalApi extends ApiBaseController{
return success(rankingDtos);
}
/**
* 查询列表,数量,类型,最新,最热
* @param num
@@ -164,7 +162,7 @@ public class CoursePortalApi extends ApiBaseController{
}
dto.setDevice(device);
try {
List<Course> list=courseService.findList(num, dto);
return success(list);
}catch(Exception e) {
@@ -172,10 +170,10 @@ public class CoursePortalApi extends ApiBaseController{
return error("查询课程列表失败",e.getMessage());
}
}
@PostMapping("/pagelist-new")
public JsonResponse<PageList<Course>> findNewPage(Pagination pager,CourseQueryDto dto){
//只是查询已发布的
dto.setPublish(true);
@@ -197,9 +195,9 @@ public class CoursePortalApi extends ApiBaseController{
}
}
}
return success(coursePageList);
}
/**
@@ -210,7 +208,7 @@ public class CoursePortalApi extends ApiBaseController{
*/
@PostMapping("/pagelist")
public JsonResponse<PageList<Course>> findPage(Pagination pager,CourseQueryDto dto){
//只是查询已发布的
dto.setPublish(true);
@@ -231,11 +229,11 @@ public class CoursePortalApi extends ApiBaseController{
}
}
}
return success(coursePageList);
}
/**
* 获取详细信息
* @param id
@@ -246,19 +244,19 @@ public class CoursePortalApi extends ApiBaseController{
if(StringUtils.isBlank(id)) {
return badRequest("参数错误,未指定课程");
}
//当前对于课程不增加浏览量,课程的意义并不是看过
// if(addView==null) {
// addView=false;
// }
Map<String,Object> rs=new HashMap<String,Object>();
Course course=courseService.getAddView(id);
if(course==null || course.getDeleted()){
return badRequest("课程不存在或已被删除");
}
rs.put("course",course);
List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(id);
if(crowd!=null && crowd) {
rs.put("crowds",courseCrowdList);
@@ -301,7 +299,7 @@ public class CoursePortalApi extends ApiBaseController{
List<CourseContent> cclist=contentService.getByCourseId(id);
List<CourseSection> sectionlist=sectionService.getByCourseId(id);
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(id);
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
for(CourseTeacher ct : teachers) {
@@ -321,7 +319,7 @@ public class CoursePortalApi extends ApiBaseController{
}
}
}
}
rs.put("isCrowd",pass);
@@ -330,7 +328,7 @@ public class CoursePortalApi extends ApiBaseController{
rs.put("teachers",teachers);
//查询课程
return success(rs);
}
private void getTeacherInfo(String token, List<String> teacherIds) {
List<TeacherVo> teacherInfo = thirdApi.getTeacherInfo(teacherIds, token);
@@ -349,80 +347,7 @@ public class CoursePortalApi extends ApiBaseController{
}
}
//作业导出
@GetMapping("/export")
public JsonResponse<String> export(String courseId,String courseName,String contentId,String name,Integer status,HttpServletRequest request) 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 <UserBasicInfo> userBasicInfoList =thirdApi.getUserBasicInfoByUserId(userIds,request);
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->{
userBasicInfoList.forEach(u->{
if(u.getUserId().equals(s.getAid())){
//取后缀
int dotIndex = e.getFilePath().lastIndexOf('.'); // 查找最后一个'.'的位置
String extension = e.getFilePath().substring(dotIndex);
map.put(u.getUserName()+"-"+u.getWorkNum()+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);
}
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)){
@@ -467,7 +392,7 @@ public class CoursePortalApi extends ApiBaseController{
cv.setStatus(9);
}
}
//音视频
//音视频
}else{
cv.setStatus(study.getStatus());

View File

@@ -83,13 +83,8 @@ public class CourseContent extends BaseEntity {
* */
@Column(name = "duration")
private Integer duration;
/**
* 视频播放进度
* */
@Column(name = "progress_video")
private Float progressVideo;
/**用于学习时的状态显示,非存储字段*/
@Transient
private Integer status;

View File

@@ -82,9 +82,4 @@ public interface ICourseContentService{
* @return
*/
CourseAssess getAssess(String ccid);
void updateProcessVideo(String contentId, String courseId, Float processVideo);
Object getPaperContentOfOnline(String courseExamId);
}

View File

@@ -1,17 +1,21 @@
package com.xboe.module.course.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.util.List;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.xboe.common.OrderCondition;
import com.xboe.core.cache.IXaskCache;
import com.xboe.core.cache.XaskCacheProvider;
import com.xboe.core.orm.FieldFilters;
import com.xboe.core.orm.UpdateBuilder;
import com.xboe.module.course.dao.*;
import com.xboe.module.course.dao.CourseAssessDao;
import com.xboe.module.course.dao.CourseContentDao;
import com.xboe.module.course.dao.CourseExamDao;
import com.xboe.module.course.dao.CourseHomeWorkDao;
import com.xboe.module.course.dao.CourseSectionDao;
import com.xboe.module.course.dto.CourseContentDto;
import com.xboe.module.course.dto.SortItem;
import com.xboe.module.course.entity.CourseAssess;
@@ -19,21 +23,8 @@ import com.xboe.module.course.entity.CourseContent;
import com.xboe.module.course.entity.CourseExam;
import com.xboe.module.course.entity.CourseHomeWork;
import com.xboe.module.course.service.ICourseContentService;
import com.xboe.module.exam.dao.ExamPaperDao;
import com.xboe.module.exam.vo.TestQuestionVo;
import com.xboe.standard.enums.BoedxContentType;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.TimeUnit;
@Slf4j
@Service
public class CourseContentServiceImpl implements ICourseContentService {
@@ -51,13 +42,7 @@ public class CourseContentServiceImpl implements ICourseContentService {
@Resource
private CourseHomeWorkDao homeworkDao;
@Resource
private CourseExamDao courseExamDao;
@Resource
private ExamPaperDao examPaperDao;
@Override
@Transactional
@@ -91,9 +76,6 @@ public class CourseContentServiceImpl implements ICourseContentService {
assessDao.saveOrUpdate(assess);
}
if(exam!=null) {
if ((exam.getRandomMode() && !(exam.getQnum() > 0)) || (!exam.getRandomMode() && exam.getQnum() > 0)) {
throw new RuntimeException("随机选题处参数错误");
}
exam.setCourseId(cc.getCourseId());
exam.setContentId(cc.getId());
if(exam.getPercentScore()==null) {
@@ -159,17 +141,6 @@ public class CourseContentServiceImpl implements ICourseContentService {
return assess;
}
@Override
@Transactional
public void updateProcessVideo(String id, String courseId, Float progressVideo) {
// 处理 processVideo 为 null 的情况
if (progressVideo == null) {
progressVideo = 0.00f;
}
String sql = "UPDATE boe_course_content SET progress_video = "+ progressVideo+" WHERE id = "+ id+" AND course_id = "+ courseId+" ";
ccDao.sqlUpdate(sql);
}
@Override
@Transactional
public void updateName(String id, String name) {
@@ -204,68 +175,4 @@ public class CourseContentServiceImpl implements ICourseContentService {
return ccDao.sumDurationByCourseId(courseId);
}
@Override
public Object getPaperContentOfOnline(String courseExamId) {
CourseExam courseExam = courseExamDao.findOne(FieldFilters.eq("id", courseExamId));
if (courseExam == null) {
throw new RuntimeException("课程考试不存在");
}
String paperId = courseExam.getPaperId();
Integer qnum = courseExam.getQnum();
Boolean randomMode = courseExam.getRandomMode();
String paperJson = "";
ObjectMapper objectMapper = new ObjectMapper();
try {
// 判断试卷类型
if (courseExam.getPaperType() == 1 && StringUtils.isNotBlank(courseExam.getPaperContent())) {
paperJson = courseExam.getPaperContent();
JsonNode rootNode = objectMapper.readTree(paperJson);
JsonNode itemsNode = rootNode.path("items");
List<JsonNode> itemsNodes = new ArrayList<>();
itemsNode.forEach(itemsNodes::add);
if (randomMode && qnum != null && qnum > 0 && randomMode && qnum != null && qnum > 0 && itemsNodes.size() > qnum) {
Collections.shuffle(itemsNodes);
itemsNodes = itemsNodes.subList(0, qnum);
}
return itemsNodes;
} else if (courseExam.getPaperType() == 2) {
IXaskCache cache = XaskCacheProvider.getCache();
String cacheKey = "course:exam:" + courseExamId + ":" + paperId;
String cacheData = cache.getCacheObject(cacheKey);
if (StringUtils.isBlank(cacheData)) {
paperJson = (String) examPaperDao.findField("paperContent", FieldFilters.eq("id", paperId));
cache.setCacheObject(cacheKey, paperJson, 5, TimeUnit.HOURS);
} else {
paperJson = cacheData;
}
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
List<TestQuestionVo> eqVoList = objectMapper.readValue(paperJson, new TypeReference<List<TestQuestionVo>>() {
});
if (randomMode && qnum != null && qnum > 0 && eqVoList.size() > qnum) {
Collections.shuffle(eqVoList);
eqVoList = eqVoList.subList(0, qnum);
}
return eqVoList;
}
} catch (JsonProcessingException e) {
log.error("JSON处理错误", e);
throw new RuntimeException(e);
}
if (StringUtils.isBlank(paperJson)) {
throw new RuntimeException("此考试无试卷内容,考试已经过期或试卷已被删除");
}
return null;
}
}

View File

@@ -166,253 +166,118 @@ public class ExamQuestionApi extends ApiBaseController {
return badRequest("请上传正确的试题文件");
}
//获取表头
Row row ;
Row row = sheetAt.getRow(1);
//从第二行开始获取数据
List<ExamQuestion> examQuestions1 = new ArrayList<>();
QuestionDto questionDto = new QuestionDto();
if(sheetAt.getRow(1).getCell(0).getStringCellValue().equals("标题(*)") && !sheetAt.getRow(1).getCell(0).getStringCellValue().equals("")){
row = sheetAt.getRow(1);
for (int i = 2;i<sheetAt.getPhysicalNumberOfRows();i++) {
//获取每一行
Row row1 = sheetAt.getRow(i);
if(row1==null || row1.getCell(0)==null){
break;
}
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
break;
}
ExamQuestion examQuestion = new ExamQuestion();
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
if(row1.getCell(1).getStringCellValue().equals("单选题")){
examQuestion.setType(1);
}
if(row1.getCell(1).getStringCellValue().equals("多选题")){
examQuestion.setType(2);
}
if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(2f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
} else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(1f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(null);
}
Cell cell = row1.getCell(3);
cell.setCellType(CellType.STRING);
for (int i=2;i<sheetAt.getPhysicalNumberOfRows();i++) {
//获取每一行
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
//单选
if (!cell.getStringCellValue().contains(",")){
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
if (row1.getCell(3).getStringCellValue().isEmpty()){
examQuestion.setDefaultScore(null);
}else {
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
for (int j=6;j<=12;j++) {
if(row1.getCell(j)!=null) {
ExamOption examOption = new ExamOption();
// 截取表头
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
if (row1.getCell(5).getStringCellValue().contains(substring)) {
examOption.setIsAnswer(true);
if (row1.getCell(3).getStringCellValue().isEmpty()){
examOption.setScore(null);
}else {
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
} else {
examOption.setIsAnswer(false);
}
if (examOption.getIsAnswer()) {
if (row1.getCell(3).getStringCellValue().isEmpty()){
examOption.setScore(null);
}else {
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
}
examOption.setOptions(row.getCell(j).getStringCellValue());
Cell cell2 = row1.getCell(j);
cell2.setCellType(CellType.STRING);
examOption.setContent(cell2.getStringCellValue());
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
//多选 多选的默认分存的是最大分
else{
String stringCellValue = row1.getCell(4).getStringCellValue();
String[] strings = stringCellValue.split(",");
// String[] strings = new String[stringCellValue.length()];
String max=strings[0];
for (int j=0;j<strings.length;j++) {
if(Float.valueOf(max)<Float.valueOf(strings[j])){
max=strings[j];
}
}
examQuestion.setDefaultScore(Float.valueOf(max));
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//A
for (int j=6;j<=12;j++){
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-6]));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
Row row1 = sheetAt.getRow(i);
if(row1==null || row1.getCell(0)==null){
break;
}
}else {
row = sheetAt.getRow(2);
for (int i = 3;i<sheetAt.getPhysicalNumberOfRows();i++) {
//获取每一行
Row row1 = sheetAt.getRow(i);
if(row1==null || row1.getCell(0)==null){
break;
}
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
break;
}
ExamQuestion examQuestion = new ExamQuestion();
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
if(row1.getCell(1).getStringCellValue().equals("单选题")){
examQuestion.setType(1);
}
if(row1.getCell(1).getStringCellValue().equals("多选题")){
examQuestion.setType(2);
}
if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(2f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
} else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(1f);
}else if(row1.getCell(2).getStringCellValue().equals("")){
examQuestion.setDifficulty(null);
}
Cell cell = row1.getCell(3);
cell.setCellType(CellType.STRING);
if(StringUtil.isBlank(row1.getCell(0).getStringCellValue())){
break;
}
ExamQuestion examQuestion = new ExamQuestion();
examQuestion.setTitle(row1.getCell(0).getStringCellValue());
if(row1.getCell(1).getStringCellValue().equals("单选题")){
examQuestion.setType(1);
}
if(row1.getCell(1).getStringCellValue().equals("多选题")){
examQuestion.setType(2);
}
examQuestion.setKnowledge(row1.getCell(2).getStringCellValue());
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(2f);
}
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(3f);
}
if(row1.getCell(3).getStringCellValue().equals("")){
examQuestion.setDifficulty(1f);
}
Cell cell = row1.getCell(4);
cell.setCellType(CellType.STRING);
// examQuestion.setDefaultScore(Float.valueOf(cell.getStringCellValue()));
//单选
if (!cell.getStringCellValue().contains(",")){
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
if (row1.getCell(3).getStringCellValue().isEmpty()){
examQuestion.setDefaultScore(null);
}else {
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
//单选
if (!cell.getStringCellValue().contains(",")){
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
examQuestion.setDefaultScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
for (int j=6;j<=12;j++) {
List<ExamOption> examOptions = new ArrayList<>();
for (int j=7;j<=13;j++) {
if(row1.getCell(j)!=null) {
ExamOption examOption = new ExamOption();
if(row1.getCell(j)!=null) {
ExamOption examOption = new ExamOption();
// 截取表头
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
if (row1.getCell(5).getStringCellValue().contains(substring)) {
String substring = row.getCell(j).getStringCellValue().substring(3, 4);
if (row1.getCell(6).getStringCellValue().contains(substring)) {
examOption.setIsAnswer(true);
if (row1.getCell(3).getStringCellValue().isEmpty()){
examOption.setScore(null);
}else {
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
} else {
examOption.setIsAnswer(false);
}
if (examOption.getIsAnswer()) {
if (row1.getCell(3).getStringCellValue().isEmpty()){
examOption.setScore(null);
}else {
examOption.setScore(Float.valueOf(row1.getCell(3).getStringCellValue()));
}
}
examOption.setOptions(row.getCell(j).getStringCellValue());
Cell cell2 = row1.getCell(j);
cell2.setCellType(CellType.STRING);
examOption.setContent(cell2.getStringCellValue());
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
//多选 多选的默认分存的是最大分
else{
String stringCellValue = row1.getCell(4).getStringCellValue();
String[] strings = stringCellValue.split(",");
// String[] strings = new String[stringCellValue.length()];
String max=strings[0];
for (int j=0;j<strings.length;j++) {
if(Float.valueOf(max)<Float.valueOf(strings[j])){
max=strings[j];
}
}
examQuestion.setDefaultScore(Float.valueOf(max));
Cell cell1 = row1.getCell(4, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(5).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//A
for (int j=6;j<=13;j++){
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-6]));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
examOptions.add(examOption);
}
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
} else {
examOption.setIsAnswer(false);
}
if (examOption.getIsAnswer()) {
examOption.setScore(Float.valueOf(row1.getCell(4).getStringCellValue()));
}
examOption.setOptions(row.getCell(j).getStringCellValue());
Cell cell2 = row1.getCell(j);
cell2.setCellType(CellType.STRING);
examOption.setContent(cell2.getStringCellValue());
if (examOption != null && StringUtil.isNotBlank(examOption.getContent())) {
examOptions.add(examOption);
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
//多选 多选的默认分存的是最大分
else{
String stringCellValue = row1.getCell(4).getStringCellValue();
String[] strings = stringCellValue.split(",");
// String[] strings = new String[stringCellValue.length()];
String max=strings[0];
for (int j=0;j<strings.length;j++) {
if(Float.valueOf(max)<Float.valueOf(strings[j])){
max=strings[j];
}
}
examQuestion.setDefaultScore(Float.valueOf(max));
Cell cell1 = row1.getCell(5, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
cell1.setCellType(CellType.STRING);
examQuestion.setAnalysis(cell1.getStringCellValue());
examQuestion.setAnswer(row1.getCell(6).getStringCellValue());
List<ExamOption> examOptions = new ArrayList<>();
//A
for (int j=7;j<=13;j++){
if(row1.getCell(j)!=null && StringUtil.isNotBlank(row1.getCell(j).getStringCellValue())){
ExamOption examOption=new ExamOption();
examOption.setOptions(row.getCell(j).getStringCellValue());
examOption.setContent(row1.getCell(j).getStringCellValue());
examOption.setIsAnswer(true);
examOption.setScore(Float.valueOf(strings[j-7]));
if(examOption!=null && StringUtil.isNotBlank(examOption.getContent())){
examOptions.add(examOption);
}
}
}
examQuestion.setOptionList(examOptions);
examQuestions1.add(examQuestion);
}
}
//判断题 只存在试题表中
@@ -435,30 +300,27 @@ public class ExamQuestionApi extends ApiBaseController {
ExamQuestion examQuestion1 = new ExamQuestion();
examQuestion1.setTitle(row2.getCell(0).getStringCellValue());
examQuestion1.setType(3);
System.out.println("1+++++++"+row2.getCell(1));
if(row2.getCell(1).getStringCellValue().equals("")){
examQuestion1.setKnowledge(row2.getCell(1).getStringCellValue());
if(row2.getCell(2).getStringCellValue().equals("")){
examQuestion1.setDifficulty(2f);
}else if(row2.getCell(1).getStringCellValue().equals("")){
}
if(row2.getCell(2).getStringCellValue().equals("")){
examQuestion1.setDifficulty(3f);
} else if(row2.getCell(1).getStringCellValue().equals("")){
}
if(row2.getCell(2).getStringCellValue().equals("")){
examQuestion1.setDifficulty(1f);
}else if(row2.getCell(1).getStringCellValue().equals("")){
examQuestion1.setDifficulty(null);
}
Cell cell1 = row2.getCell(2);
Cell cell1 = row2.getCell(3);
cell1.setCellType(CellType.STRING);
if (row2.getCell(2).getStringCellValue().isEmpty()){
examQuestion1.setDefaultScore(null);
}else {
examQuestion1.setDefaultScore(Float.valueOf(row2.getCell(2).getStringCellValue()));
}
if(row2.getCell(3)!=null) {
examQuestion1.setAnalysis(row2.getCell(3).getStringCellValue());
examQuestion1.setDefaultScore(Float.valueOf(cell1.getStringCellValue()));
if(row2.getCell(4)!=null) {
examQuestion1.setAnalysis(row2.getCell(4).getStringCellValue());
}else {
examQuestion1.setAnalysis("");
}
String cvalue=row2.getCell(4).getStringCellValue();
String cvalue=row2.getCell(5).getStringCellValue();
examQuestion1.setAnswer(cvalue.equals("正确")? "true":"false");
if(examQuestion1!=null){
examQuestions2.add(examQuestion1);

View File

@@ -28,7 +28,7 @@ public class ExamTest extends BaseEntity {
/**
* 考试名称
* */
@Column(name = "test_name",length = 50)
@Column(name = "test_name",nullable = false,length = 50)
private String testName;
/**
@@ -46,7 +46,7 @@ public class ExamTest extends BaseEntity {
/**
* 考试时长 分钟
* */
@Column(name = "test_duration")
@Column(name = "test_duration",nullable = false)
private Integer testDuration;
/**
* 显示解析
@@ -107,13 +107,13 @@ public class ExamTest extends BaseEntity {
/**
* 考试的类型
* */
@Column(name = "test_type")
@Column(name = "test_type",nullable = false)
private Integer testType;
/**
* 发布状态 ,是否已发布
*/
@Column(name = "published",length = 1)
@Column(name = "published",length = 1,nullable = false)
private Boolean published;
/**
* 发布时间
@@ -154,7 +154,7 @@ public class ExamTest extends BaseEntity {
/**
* 范围1表独立使用2表课程内部
* */
@Column(name = "range_type")
@Column(name = "range_type",nullable = false)
private Integer rangeType;
/**
@@ -178,4 +178,5 @@ public class ExamTest extends BaseEntity {
@Transient
private String paperName;
}

View File

@@ -12,7 +12,6 @@ public class FavoriteCaseDto {
private String id;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime time;
/**

View File

@@ -3,13 +3,14 @@ package com.xboe.school.study.api;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
import cn.hutool.core.util.ArrayUtil;
import com.xboe.api.ThirdApi;
import com.xboe.constants.CacheName;
import com.xboe.api.vo.*;
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;
@@ -323,32 +324,17 @@ public class StudyCourseApi extends ApiBaseController{
//检查是否已存在
StudyCourseItem item = studyService.checkHas(sci.getStudyId(),sci.getContentId());
if(item!=null) {
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);
}
//如果记录存在但是进度不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("无课程信息");
}
@@ -543,7 +529,7 @@ public class StudyCourseApi extends ApiBaseController{
* @return
*/
@PostMapping("/study-video-time")
public JsonResponse<Boolean> study(String itemId,Integer videoTime,String contentId , String courseId,Float progressVideo){
public JsonResponse<Boolean> study(String studyId,String itemId,Integer videoTime){
if(StringUtils.isBlank(itemId)){
return error("参数错误");
@@ -553,10 +539,7 @@ public class StudyCourseApi extends ApiBaseController{
}
//检查是否已存在
try {
studyService.updateLastTime(itemId,videoTime, getCurrent().getAccountId());
if (contentId != null && courseId != null && progressVideo != null){
contentService.updateProcessVideo(contentId, courseId, progressVideo);
}
studyService.updateLastTime(itemId,videoTime,getCurrent().getAccountId());
return success(true);
}catch(Exception e) {
log.error("记录最后学习时间错误",e);

View File

@@ -7,7 +7,6 @@ import java.util.Map;
import java.util.concurrent.TimeUnit;
import com.xboe.api.ThirdApi;
import com.xboe.school.study.dao.StudyCourseDao;
import com.xboe.school.study.entity.StudyCourse;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -33,8 +32,6 @@ import javax.servlet.http.HttpServletRequest;
@RestController
@RequestMapping(value="/xboe/school/study/exam")
public class StudyExamApi extends ApiBaseController{
@Autowired
StudyCourseDao scDao;
@Autowired
IStudyExamService sexamService;

View File

@@ -117,7 +117,7 @@ public class StudyExam extends IdEntity {
/*
* 开始时间
* */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy--MM-dd HH:mm:ss")
@Column(name = "start_time")
private LocalDateTime startTime;
/*

View File

@@ -1,6 +1,5 @@
package com.xboe.school.study.service;
import java.util.Collection;
import java.util.List;
import com.xboe.school.study.entity.StudyHomeWork;
@@ -30,6 +29,4 @@ public interface IStudyHomeWorkService {
* @return
*/
List<StudyHomeWork> getByStudyIdAndContentId(String studyId,String contentId);
List<StudyHomeWork>getByStudnetNameAndContentId(List<String> studentName, String contentId);
}

View File

@@ -7,7 +7,6 @@ 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;
/**
* 学习情况处理,比较综合一个处理类
@@ -96,7 +95,4 @@ 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);
}

View File

@@ -1,9 +1,24 @@
package com.xboe.school.study.service.impl;
import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import com.xboe.api.ThirdApi;
import com.xboe.core.orm.QueryBuilder;
import com.xboe.school.study.entity.StudyCourse;
import com.xboe.system.user.entity.Message;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import com.xboe.common.OrderCondition;
import com.xboe.core.orm.FieldFilters;
import com.xboe.core.orm.QueryBuilder;
import com.xboe.core.orm.UpdateBuilder;
import com.xboe.module.course.dao.CourseContentDao;
import com.xboe.module.course.dao.CourseExamDao;
import com.xboe.module.course.entity.CourseExam;
@@ -13,17 +28,6 @@ import com.xboe.school.study.dao.StudyExamDao;
import com.xboe.school.study.entity.StudyCourseItem;
import com.xboe.school.study.entity.StudyExam;
import com.xboe.school.study.service.IStudyExamService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.transaction.Transactional;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.List;
@Slf4j
@Service
@@ -69,31 +73,29 @@ public class StudyExamServiceImpl implements IStudyExamService{
exam.setPassLine(0);
}
int prog=exam.getScore().intValue()>=exam.getPassLine()?100:exam.getScore().intValue();
//完成处理,判断是否已存在
Object obj=scItemDao.findField("id", FieldFilters.eq("studyId", exam.getStudyId()), FieldFilters.eq("contentId", exam.getContentId()));
//获取本次考试提交,学习状态与学习进度
int status=exam.getScore()>=exam.getPassLine()?StudyCourseItem.STATUS_FINISH:StudyCourseItem.STATUS_STUDYING;
int progress = exam.getScore().intValue() >= exam.getPassLine() ? 100 : 0;
//计算时长
LocalDateTime ldt=LocalDateTime.now();
if(obj==null) {
StudyCourseItem sci=new StudyCourseItem();
LocalDateTime ldt=LocalDateTime.now();
sci.setStudyId(exam.getStudyId());
sci.setContentId(exam.getContentId());
sci.setContentName("考试");
sci.setCourseId(exam.getCourseId());
//sci.setCsectionId(homework.getCsectionId());
sci.setProgress(progress);//直接设置为学习完成
sci.setProgress(prog);//直接设置为学习完成
sci.setStatus(status);//状态直接更新为已完成
sci.setStartTime(exam.getStartTime());
sci.setStartTime(ldt);
sci.setAid(exam.getStudentId());
sci.setAname(exam.getStudentName());
sci.setFinishTime(ldt);
sci.setFinishTime(LocalDateTime.now());
sci.setLastStudyTime(0);//此项用户记录视频内容当前学习的时间点
sci.setLastTime(ldt);
sci.setScore(exam.getScore());
sci.setStudyDuration(exam.getTestDuration());
if(cexam.getScoringType()==CourseExam.SCORINGTYPE_LAST) {
sci.setScore(exam.getScore());
}
scItemDao.save(sci);
exam.setStudyItemId(sci.getId());
dao.save(exam);
@@ -106,34 +108,35 @@ public class StudyExamServiceImpl implements IStudyExamService{
}else {
exam.setStudyItemId(obj.toString());//此项就是学习条目的id
Float maxScore = (Float) dao.findField("max(score)", FieldFilters.eq("contentId", exam.getContentId()), FieldFilters.eq("courseId", exam.getCourseId()), FieldFilters.eq("studyId", exam.getStudyId()));
dao.save(exam);
//最新考试分值
if (cexam.getScoringType() == CourseExam.SCORINGTYPE_LAST) {
scItemDao.updateMultiFieldById(exam.getStudyItemId(),
UpdateBuilder.create("startTime", exam.getStartTime()),
UpdateBuilder.create("finishTime", ldt),
UpdateBuilder.create("score", exam.getScore()),
UpdateBuilder.create("progress", progress),
UpdateBuilder.create("status", status),
UpdateBuilder.create("studyDuration", exam.getTestDuration())
);
}
//最高分
if (cexam.getScoringType() == CourseExam.SCORINGTYPE_MAX) {
if (exam.getScore() > maxScore) {
scItemDao.updateMultiFieldById(exam.getStudyItemId(),
UpdateBuilder.create("startTime", exam.getStartTime()),
UpdateBuilder.create("finishTime", LocalDateTime.now()),
UpdateBuilder.create("score", exam.getScore()),
UpdateBuilder.create("progress", progress),
UpdateBuilder.create("status", status)
);
if(cexam.getScoringType()==CourseExam.SCORINGTYPE_LAST){
scItemDao.updateFieldById(exam.getStudyItemId(), "score",exam.getScore());
scItemDao.updateFieldById(exam.getStudyItemId(), "progress",prog);
if(exam.getScore()>=exam.getPassLine()){
scItemDao.updateFieldById(exam.getStudyId(), "progress",100);
scItemDao.updateFieldById(exam.getStudyId(), "finish_time",LocalDateTime.now());
scItemDao.updateFieldById(exam.getStudyId(), "status",StudyCourseItem.STATUS_FINISH);
scItemDao.updateFieldById(exam.getStudyId(), "score",exam.getScore());
//scDao.updateFieldById(exam.getStudyId(), "last_score",100.0f);
}
}
}
//1最高一次,用于最高一次的计算
if(cexam.getScoringType()==CourseExam.SCORINGTYPE_MAX) {
Float f=(Float)dao.findField("max(score)", FieldFilters.eq("contentId", exam.getContentId()), FieldFilters.eq("courseId", exam.getCourseId()), FieldFilters.eq("studyId", exam.getStudyId()));
scItemDao.updateFieldById(exam.getStudyItemId(), "score", f);
scItemDao.updateFieldById(exam.getStudyItemId(), "status", f>=exam.getPassLine()?StudyCourseItem.STATUS_FINISH:StudyCourseItem.STATUS_STUDYING);
scItemDao.updateFieldById(exam.getStudyItemId(), "progress",f>=exam.getPassLine()?100:f.intValue());
if(f>=exam.getPassLine()){
scItemDao.updateFieldById(exam.getStudyId(), "progress",100);
scItemDao.updateFieldById(exam.getStudyId(), "finish_time",LocalDateTime.now());
scItemDao.updateFieldById(exam.getStudyId(), "status",StudyCourseItem.STATUS_FINISH);
scItemDao.updateFieldById(exam.getStudyId(), "score",exam.getScore());
//scDao.updateFieldById(exam.getStudyId(), "last_score",100.0f);
}
}
int totalContent = courseContentDao.getCount(exam.getCourseId());
scDao.finishCheck(exam.getStudyId(),exam.getCourseId(),totalContent,token);
scDao.updateFieldById(exam.getStudyId(), "last_score",exam.getScore());

View File

@@ -64,7 +64,6 @@ public class StudyHomeWorkServiceImpl implements IStudyHomeWorkService{
int totalContent=courseContentDao.count(FieldFilters.eq("courseId", homework.getCourseId()),FieldFilters.eq("deleted",false));
scDao.finishCheck(homework.getStudyId(),homework.getCourseId(),totalContent,token);
}else {
scItemDao.updateFieldById(obj.toString(), "finishTime", LocalDateTime.now());
//只是保留一条作业记录,不再保存多条记录了
//dao.save(homework);
//设置id。然后进行悠
@@ -90,9 +89,4 @@ 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));
}
}

View File

@@ -1,5 +1,6 @@
package com.xboe.school.study.service.impl;
import java.math.BigInteger;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
@@ -7,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;
@@ -97,12 +98,8 @@ public class StudyServiceImpl implements IStudyService{
//sci.setProgress(100);//直接设置为学习完成
sci.setLastTime(ldt);
scItemDao.saveOrUpdate(sci);
if (sci.getId() != null){
dto.setStudyItemId(sci.getId());
}else {
log.info("学习记录插入失败"+sci.getId());
throw new IllegalArgumentException("学习记录插入失败");
}
dto.setStudyItemId(sci.getId());
//检查是否全部学习完成
scDao.finishCheck(dto.getStudyId(),dto.getCourseId(),dto.getContentTotal(),token);
@@ -183,15 +180,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;
int pageIndex2 = pageIndex-1;
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 " +
@@ -271,34 +270,6 @@ 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.like("aname", name));
}
return scItemDao.findList(query.builder());
}
@Override
@Transactional
public void updateProcess(String studyContentId,String studyId, String courseId,Integer total, Integer progress,String token) {

View File

@@ -1,9 +1,9 @@
# cloud nacos config
spring.cloud.nacos.discovery.server-addr=10.251.113.100:8848
spring.cloud.nacos.discovery.server-addr=10.251.129.51:8848
## redis
spring.redis.database=1
spring.redis.host=10.251.88.213
spring.redis.host=10.251.129.122
spring.redis.password=qwert!W588
spring.redis.port=6379
@@ -16,7 +16,7 @@ spring.datasource.driverClassName=com.mysql.jdbc.Driver
#spring.datasource.url=jdbc:mysql://10.251.129.129:8066/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
#spring.datasource.username=admin
#spring.datasource.password=ocYMC>!{8G
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=admin
spring.datasource.password=boeRds01
@@ -53,7 +53,6 @@ xboe.externalinterface.url.system=http://127.0.0.1:9091
## ?????????????
xboe.old.base.url=https://u.boe.com
## ???????api??
xboe.stat.base.url=http://127.0.0.1:9080
xboe.server.userbasic.url=https://u.boe.com/userbasic
@@ -64,7 +63,7 @@ jasypt.encryptor.algorithm=PBEWithMD5AndDES
jasypt.encryptor.iv-generator-classname=org.jasypt.iv.NoIvGenerator
# elasticsearch config
xboe.elasticsearch.server.ip=10.251.88.218
xboe.elasticsearch.server.ip=10.251.129.21
xboe.elasticsearch.server.port=9200
xboe.elasticsearch.server.user=
xboe.elasticsearch.server.password=

View File

@@ -56,7 +56,7 @@ logging.config=classpath:log/logback-@profileActive@.xml
# config.id.generator.datacenter.num=1
#boe.domain=https://pretest.zcwytd.com
boe.domain=http://127.0.0.1
boe.domain=https://u.boe.com
#boe.domain=http://localhost:30001
orgTree.orgTreeList=${boe.domain}/userbasic/org/list
# ????id????????????
@@ -74,5 +74,4 @@ manageApi.stu.offcourse=${boe.domain}/manageApi/stu/offcourse/getOffCourseId
manageApi.editExam=${boe.domain}/manageApi/admin/project/editExam
#获取离职教师id
userBasic.getTeacherIds=${boe.domain}/userbasic/user/getTeacherInfo
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus
userBasic.getUserBasicInfo=${boe.domain}/userbasic/user/getUserBasicInfo
coursesuilt.getStudyStatus=${boe.domain}/manageApi/stu/project/completeStatus

View File

@@ -1,6 +1,6 @@
## redis
spring.redis.database=3
spring.redis.host=10.251.88.213
spring.redis.host=10.251.129.122
spring.redis.password=qwert!W588
spring.redis.port=6379
@@ -14,7 +14,7 @@ spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
# 当前数据库 basic 对应的数据库
spring.datasource.db1.driverClassName=com.mysql.jdbc.Driver
spring.datasource.db1.jdbc-url=jdbc:mysql://10.251.88.216:3306/boe_basic?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db1.jdbc-url=jdbc:mysql://10.251.129.126:3306/boe_basic?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db1.username=admin
spring.datasource.db1.password=boeRds01
@@ -23,7 +23,7 @@ spring.datasource.db1.password=boeRds01
# 主数据库 all 对应的数据库
spring.datasource.db2.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.db2.jdbc-url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db2.jdbc-url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db2.username=admin
spring.datasource.db2.password=boeRds01
@@ -48,7 +48,6 @@ xboe.upload.file.http_path=https://u.boe.com/upload
## 新系统的内部地址可以不通过nginx调用
xboe.inner.data.sync.baseurl=http://127.0.0.1:9090
#加密盐
#jasypt.encryptor.password=jasypt
jasypt.encryptor.algorithm=PBEWithMD5AndDES

View File

@@ -1,15 +1,15 @@
## redis
spring.redis.database=2
spring.redis.host=10.251.88.214
spring.redis.password=qwert!W588
spring.redis.host=127.0.0.1
spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
spring.redis.port=6379
## datasource config
spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql:/10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=admin
spring.datasource.password=boeRds01
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=root
spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)
logging.level.org.hibernate.SQL=ERROR
# logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE

View File

@@ -1,6 +1,6 @@
## redis
spring.redis.database=2
spring.redis.host=10.251.88.214
spring.redis.host=127.0.0.1
spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
spring.redis.port=6379
@@ -8,7 +8,7 @@ spring.redis.port=6379
spring.jpa.hibernate.ddl-auto=none
spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=root
spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)

View File

@@ -1,16 +1,16 @@
## redis
spring.redis.database=2
spring.redis.host=10.251.88.214
spring.redis.host=127.0.0.1
spring.redis.password=ENC(zA5LNV8xw3yEx6LMwdGGBGgNsOaD3Cg+)
spring.redis.port=6379
# cloud nacos config
spring.cloud.nacos.discovery.server-addr=10.251.113.100:8848
spring.cloud.nacos.discovery.server-addr=10.251.181.11:8848
## datasource config
spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=root
spring.datasource.password=ENC(lAoFOYuc8CAypPtigTNLYg==)
@@ -33,6 +33,7 @@ xboe.upload.file.http_path=http://localhost:9090/cdn/upload
## 外部接口调用地址 旧系统机构及用户数据接口
xboe.externalinterface.url.system=http://localhost:9091
#加密盐
#jasypt.encryptor.password=jasypt
jasypt.encryptor.algorithm=PBEWithMD5AndDES

View File

@@ -7,7 +7,7 @@ spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
# 当前数据库 basic 对应的数据库
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=admin
spring.datasource.password=boeRds01

View File

@@ -7,7 +7,7 @@ spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
# 当前数据库 basic 对应的数据库
spring.datasource.url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.username=admin
spring.datasource.password=boeRds01

View File

@@ -1,3 +1,4 @@
# datasource config
# basic数据库
spring.jpa.hibernate.ddl-auto=none
@@ -8,7 +9,7 @@ spring.datasource.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
# 原数据库 old 对应的数据库
spring.datasource.db1.driverClassName=com.mysql.jdbc.Driver
spring.datasource.db1.jdbc-url=jdbc:mysql://10.251.88.216:3306/elearninglms?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db1.jdbc-url=jdbc:mysql://10.251.129.126:3306/elearninglms?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db1.username=admin
spring.datasource.db1.password=boeRds01
@@ -17,7 +18,7 @@ spring.datasource.db1.password=boeRds01
# 新主数据库 all 对应的数据库
spring.datasource.db2.driverClassName=com.mysql.jdbc.Driver
# spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver
spring.datasource.db2.jdbc-url=jdbc:mysql://10.251.88.216:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db2.jdbc-url=jdbc:mysql://10.251.129.126:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
spring.datasource.db2.username=admin
spring.datasource.db2.password=boeRds01