档案统计

This commit is contained in:
cjw 2024-08-08 09:35:45 +08:00
parent 7d50fa7103
commit d91f1eeaa4
17 changed files with 192 additions and 274 deletions

View File

@ -20,35 +20,35 @@ spring:
driverClassName: com.mysql.cj.jdbc.Driver driverClassName: com.mysql.cj.jdbc.Driver
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562 # jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题) # rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true url: jdbc:mysql://172.25.23.150:16338/mental_health_vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: root username: root
password: root password: Mz!@#123
# 从库数据源 # 从库数据源
slave: slave:
lazy: true lazy: true
type: ${spring.datasource.type} type: ${spring.datasource.type}
driverClassName: com.mysql.cj.jdbc.Driver driverClassName: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true url: jdbc:mysql://172.25.23.150:16338/mental_health_vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&allowMultiQueries=true
username: username:
password: password:
# oracle: # oracle:
# type: ${spring.datasource.type} # type: ${spring.datasource.type}
# driverClassName: oracle.jdbc.OracleDriver # driverClassName: oracle.jdbc.OracleDriver
# url: jdbc:oracle:thin:@//localhost:1521/XE # url: jdbc:oracle:thin:@//localhost:1521/XE
# username: ROOT # username: ROOT
# password: root # password: root
# postgres: # postgres:
# type: ${spring.datasource.type} # type: ${spring.datasource.type}
# driverClassName: org.postgresql.Driver # driverClassName: org.postgresql.Driver
# url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true # url: jdbc:postgresql://localhost:5432/postgres?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
# username: root # username: root
# password: root # password: root
# sqlserver: # sqlserver:
# type: ${spring.datasource.type} # type: ${spring.datasource.type}
# driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver # driverClassName: com.microsoft.sqlserver.jdbc.SQLServerDriver
# url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true # url: jdbc:sqlserver://localhost:1433;DatabaseName=tempdb;SelectMethod=cursor;encrypt=false;rewriteBatchedStatements=true
# username: SA # username: SA
# password: root # password: root
hikari: hikari:
# 最大连接池数量 # 最大连接池数量
maxPoolSize: 20 maxPoolSize: 20
@ -69,16 +69,16 @@ spring:
spring.data: spring.data:
redis: redis:
# 地址 # 地址
host: localhost host: 172.25.23.150
# 端口默认为6379 # 端口默认为6379
port: 6379 port: 16237
# 数据库索引 # 数据库索引
database: 0 database: 1
# 密码(如没有密码请注释掉) # 密码(如没有密码请注释掉)
# password: # password:
# 连接超时时间 # 连接超时时间
timeout: 10s timeout: 10s
# 是否开启ssl # 是否开启sslkeys
ssl.enabled: false ssl.enabled: false
redisson: redisson:

View File

@ -22,7 +22,7 @@ captcha:
# 开发环境配置 # 开发环境配置
server: server:
# 服务器的HTTP端口默认为8080 # 服务器的HTTP端口默认为8080
port: 8080 port: 8070
servlet: servlet:
# 应用的访问路径 # 应用的访问路径
context-path: / context-path: /

View File

@ -1,45 +0,0 @@
package org.dromara.test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
/**
* 断言单元测试案例
*
* @author Lion Li
*/
@DisplayName("断言单元测试案例")
public class AssertUnitTest {
@DisplayName("测试 assertEquals 方法")
@Test
public void testAssertEquals() {
Assertions.assertEquals("666", new String("666"));
Assertions.assertNotEquals("666", new String("666"));
}
@DisplayName("测试 assertSame 方法")
@Test
public void testAssertSame() {
Object obj = new Object();
Object obj1 = obj;
Assertions.assertSame(obj, obj1);
Assertions.assertNotSame(obj, obj1);
}
@DisplayName("测试 assertTrue 方法")
@Test
public void testAssertTrue() {
Assertions.assertTrue(true);
Assertions.assertFalse(true);
}
@DisplayName("测试 assertNull 方法")
@Test
public void testAssertNull() {
Assertions.assertNull(null);
Assertions.assertNotNull(null);
}
}

View File

@ -1,70 +0,0 @@
package org.dromara.test;
import org.dromara.common.core.config.RuoYiConfig;
import org.junit.jupiter.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.concurrent.TimeUnit;
/**
* 单元测试案例
*
* @author Lion Li
*/
@SpringBootTest // 此注解只能在 springboot 主包下使用 需包含 main 方法与 yml 配置文件
@DisplayName("单元测试案例")
public class DemoUnitTest {
@Autowired
private RuoYiConfig ruoYiConfig;
@DisplayName("测试 @SpringBootTest @Test @DisplayName 注解")
@Test
public void testTest() {
System.out.println(ruoYiConfig);
}
@Disabled
@DisplayName("测试 @Disabled 注解")
@Test
public void testDisabled() {
System.out.println(ruoYiConfig);
}
@Timeout(value = 2L, unit = TimeUnit.SECONDS)
@DisplayName("测试 @Timeout 注解")
@Test
public void testTimeout() throws InterruptedException {
Thread.sleep(3000);
System.out.println(ruoYiConfig);
}
@DisplayName("测试 @RepeatedTest 注解")
@RepeatedTest(3)
public void testRepeatedTest() {
System.out.println(666);
}
@BeforeAll
public static void testBeforeAll() {
System.out.println("@BeforeAll ==================");
}
@BeforeEach
public void testBeforeEach() {
System.out.println("@BeforeEach ==================");
}
@AfterEach
public void testAfterEach() {
System.out.println("@AfterEach ==================");
}
@AfterAll
public static void testAfterAll() {
System.out.println("@AfterAll ==================");
}
}

View File

@ -1,72 +0,0 @@
package org.dromara.test;
import org.dromara.common.core.enums.UserType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.EnumSource;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.NullSource;
import org.junit.jupiter.params.provider.ValueSource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
/**
* 带参数单元测试案例
*
* @author Lion Li
*/
@DisplayName("带参数单元测试案例")
public class ParamUnitTest {
@DisplayName("测试 @ValueSource 注解")
@ParameterizedTest
@ValueSource(strings = {"t1", "t2", "t3"})
public void testValueSource(String str) {
System.out.println(str);
}
@DisplayName("测试 @NullSource 注解")
@ParameterizedTest
@NullSource
public void testNullSource(String str) {
System.out.println(str);
}
@DisplayName("测试 @EnumSource 注解")
@ParameterizedTest
@EnumSource(UserType.class)
public void testEnumSource(UserType type) {
System.out.println(type.getUserType());
}
@DisplayName("测试 @MethodSource 注解")
@ParameterizedTest
@MethodSource("getParam")
public void testMethodSource(String str) {
System.out.println(str);
}
public static Stream<String> getParam() {
List<String> list = new ArrayList<>();
list.add("t1");
list.add("t2");
list.add("t3");
return list.stream();
}
@BeforeEach
public void testBeforeEach() {
System.out.println("@BeforeEach ==================");
}
@AfterEach
public void testAfterEach() {
System.out.println("@AfterEach ==================");
}
}

View File

@ -1,54 +0,0 @@
package org.dromara.test;
import org.junit.jupiter.api.*;
import org.springframework.boot.test.context.SpringBootTest;
/**
* 标签单元测试案例
*
* @author Lion Li
*/
@SpringBootTest
@DisplayName("标签单元测试案例")
public class TagUnitTest {
@Tag("dev")
@DisplayName("测试 @Tag dev")
@Test
public void testTagDev() {
System.out.println("dev");
}
@Tag("prod")
@DisplayName("测试 @Tag prod")
@Test
public void testTagProd() {
System.out.println("prod");
}
@Tag("local")
@DisplayName("测试 @Tag local")
@Test
public void testTagLocal() {
System.out.println("local");
}
@Tag("exclude")
@DisplayName("测试 @Tag exclude")
@Test
public void testTagExclude() {
System.out.println("exclude");
}
@BeforeEach
public void testBeforeEach() {
System.out.println("@BeforeEach ==================");
}
@AfterEach
public void testAfterEach() {
System.out.println("@AfterEach ==================");
}
}

View File

@ -182,6 +182,7 @@ public class OssClient {
return header + domain + "/" + properties.getBucketName(); return header + domain + "/" + properties.getBucketName();
} }
return header + endpoint + "/" + properties.getBucketName(); return header + endpoint + "/" + properties.getBucketName();
//return "https://wx.ysmental.com/oss/" + properties.getBucketName();
} }
public String getPath(String prefix, String suffix) { public String getPath(String prefix, String suffix) {
@ -249,8 +250,10 @@ public class OssClient {
} }
builder.append("{\n\"Action\": "); builder.append("{\n\"Action\": ");
builder.append(switch (policyType) { builder.append(switch (policyType) {
case WRITE -> "[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n"; case WRITE ->
case READ_WRITE -> "[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:GetObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n"; "[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n";
case READ_WRITE ->
"[\n\"s3:AbortMultipartUpload\",\n\"s3:DeleteObject\",\n\"s3:GetObject\",\n\"s3:ListMultipartUploadParts\",\n\"s3:PutObject\"\n],\n";
default -> "\"s3:GetObject\",\n"; default -> "\"s3:GetObject\",\n";
}); });
builder.append("\"Effect\": \"Allow\",\n\"Principal\": \"*\",\n\"Resource\": \"arn:aws:s3:::"); builder.append("\"Effect\": \"Allow\",\n\"Principal\": \"*\",\n\"Resource\": \"arn:aws:s3:::");

View File

@ -2,15 +2,20 @@ package org.dromara.scale.controller;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.scale.domain.vo.ArchiveStatisticVo; import org.dromara.scale.domain.vo.ArchiveStatisticVo;
import org.dromara.scale.domain.vo.ArchiveVo; import org.dromara.scale.domain.vo.ArchiveVo;
import org.dromara.scale.domain.vo.StatisticScaleVo;
import org.dromara.scale.domain.vo.StatisticWarnVo;
import org.dromara.scale.service.IArchiveService; import org.dromara.scale.service.IArchiveService;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* <p>TODO<p> * <p>TODO<p>
* *
@ -34,6 +39,7 @@ public class ArchiveController {
public TableDataInfo<ArchiveVo> pageList(ArchiveVo vo, PageQuery pageQuery) { public TableDataInfo<ArchiveVo> pageList(ArchiveVo vo, PageQuery pageQuery) {
return archiveService.queryPageList(vo, pageQuery); return archiveService.queryPageList(vo, pageQuery);
} }
/** /**
* 获取档案静态列表 * 获取档案静态列表
*/ */
@ -43,4 +49,22 @@ public class ArchiveController {
return archiveService.queryStatisticPageList(userId, pageQuery); return archiveService.queryStatisticPageList(userId, pageQuery);
} }
/**
* 获取档案静态列表
*/
@SaCheckPermission("scale:archive:statistic")
@GetMapping("/statistic/scale")
public R<List<StatisticScaleVo>> statisticScale() {
return R.ok(archiveService.queryStatisticScale());
}
/**
* 获取档案静态列表
*/
@SaCheckPermission("scale:archive:statistic")
@GetMapping("/statistic/warn")
public R<StatisticWarnVo> statisticWarn() {
return R.ok(archiveService.queryStatisticWarn());
}
} }

View File

@ -5,6 +5,7 @@ import io.github.linpeilie.annotations.AutoMapping;
import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.dromara.common.core.validate.AddGroup; import org.dromara.common.core.validate.AddGroup;
@ -41,6 +42,7 @@ public class SysScaleBo extends BaseEntity {
* 量表编码 * 量表编码
*/ */
@NotBlank(message = "量表编码不能为空", groups = {AddGroup.class, EditGroup.class}) @NotBlank(message = "量表编码不能为空", groups = {AddGroup.class, EditGroup.class})
@Size()
private String scaleCode; private String scaleCode;
/** /**

View File

@ -0,0 +1,26 @@
package org.dromara.scale.domain.vo;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
/**
* <p>量表统计<p>
*
* @author cjw
* @version V1.0.0
* @date 2024/8/7 17:06
*/
@Data
public class StatisticScaleVo implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private String name;
private String times;
private int value;
}

View File

@ -8,7 +8,7 @@ import org.dromara.scale.domain.SysEvaluationRecord;
import java.io.Serial; import java.io.Serial;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
@ -61,6 +61,9 @@ public class SysEvaluationRecordVo implements Serializable {
*/ */
private Integer status; private Integer status;
private Date createTime;

View File

@ -7,6 +7,10 @@ import org.dromara.common.mybatis.annotation.DataColumn;
import org.dromara.common.mybatis.annotation.DataPermission; import org.dromara.common.mybatis.annotation.DataPermission;
import org.dromara.scale.domain.vo.ArchiveStatisticVo; import org.dromara.scale.domain.vo.ArchiveStatisticVo;
import org.dromara.scale.domain.vo.ArchiveVo; import org.dromara.scale.domain.vo.ArchiveVo;
import org.dromara.scale.domain.vo.StatisticWarnVo;
import org.dromara.scale.domain.vo.SysEvaluationRecordVo;
import java.util.List;
@Mapper @Mapper
public interface ArchiveMapper { public interface ArchiveMapper {
@ -18,5 +22,8 @@ public interface ArchiveMapper {
Page<ArchiveStatisticVo> selectStatisticVoPage(@Param("page") Page<ArchiveStatisticVo> page, @Param("userId") Long userId); Page<ArchiveStatisticVo> selectStatisticVoPage(@Param("page") Page<ArchiveStatisticVo> page, @Param("userId") Long userId);
List<SysEvaluationRecordVo> selectScaleRecordByUserId(@Param("userId") Long userId);
StatisticWarnVo selectWarnByUserId(@Param("userId") Long userId);
} }

View File

@ -4,9 +4,18 @@ import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.scale.domain.vo.ArchiveStatisticVo; import org.dromara.scale.domain.vo.ArchiveStatisticVo;
import org.dromara.scale.domain.vo.ArchiveVo; import org.dromara.scale.domain.vo.ArchiveVo;
import org.dromara.scale.domain.vo.StatisticScaleVo;
import org.dromara.scale.domain.vo.StatisticWarnVo;
import java.util.List;
public interface IArchiveService { public interface IArchiveService {
TableDataInfo<ArchiveVo> queryPageList(ArchiveVo vo, PageQuery pageQuery); TableDataInfo<ArchiveVo> queryPageList(ArchiveVo vo, PageQuery pageQuery);
TableDataInfo<ArchiveStatisticVo> queryStatisticPageList(Long usetId, PageQuery pageQuery); TableDataInfo<ArchiveStatisticVo> queryStatisticPageList(Long usetId, PageQuery pageQuery);
List<StatisticScaleVo> queryStatisticScale();
StatisticWarnVo queryStatisticWarn();
} }

View File

@ -1,15 +1,21 @@
package org.dromara.scale.service.impl; package org.dromara.scale.service.impl;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.scale.domain.vo.ArchiveStatisticVo; import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.scale.domain.vo.ArchiveVo; import org.dromara.scale.domain.vo.*;
import org.dromara.scale.mapper.ArchiveMapper; import org.dromara.scale.mapper.ArchiveMapper;
import org.dromara.scale.service.IArchiveService; import org.dromara.scale.service.IArchiveService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
import java.util.stream.Collectors;
/** /**
* <p>TODO<p> * <p>TODO<p>
* *
@ -38,4 +44,45 @@ public class ArchiveServiceImpl implements IArchiveService {
Page<ArchiveStatisticVo> result = archiveMapper.selectStatisticVoPage(pageQuery.build(), userId); Page<ArchiveStatisticVo> result = archiveMapper.selectStatisticVoPage(pageQuery.build(), userId);
return TableDataInfo.build(result); return TableDataInfo.build(result);
} }
@Override
public List<StatisticScaleVo> queryStatisticScale() {
Long userId = LoginHelper.getUserId();
List<SysEvaluationRecordVo> list = archiveMapper.selectScaleRecordByUserId(userId);
Map<String, List<Instant>> groupedTimes = list.stream()
.sorted(Comparator.comparing(e -> e.getCreateTime().toInstant())) // 先排序
.collect(Collectors.groupingBy(
SysEvaluationRecordVo::getScaleName,
Collectors.mapping(e -> e.getCreateTime().toInstant(), Collectors.toList())
));
Map<String, String> result = groupedTimes.entrySet().stream()
.collect(Collectors.toMap(
Map.Entry::getKey,
entry -> formatTimes(entry.getValue())
));
List<StatisticScaleVo> data = new ArrayList<>(result.keySet().size());
result.forEach((name, times) ->
{
StatisticScaleVo one = new StatisticScaleVo();
one.setName(name);
one.setTimes(times);
List<String> split = StrUtil.split(times, ",");
one.setValue(split.size());
data.add(one);
});
return data;
}
private String formatTimes(List<Instant> instants) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return instants.stream()
.map(instant -> sdf.format(Date.from(instant)))
.collect(Collectors.joining(", "));
}
@Override
public StatisticWarnVo queryStatisticWarn() {
Long userId = LoginHelper.getUserId();
return archiveMapper.selectWarnByUserId(userId);
}
} }

View File

@ -17,6 +17,7 @@ import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.scale.domain.SysEvaluationRecord; import org.dromara.scale.domain.SysEvaluationRecord;
import org.dromara.scale.domain.SysScale;
import org.dromara.scale.domain.bo.BaseQueryBo; import org.dromara.scale.domain.bo.BaseQueryBo;
import org.dromara.scale.domain.bo.SysEvaluationRecordBo; import org.dromara.scale.domain.bo.SysEvaluationRecordBo;
import org.dromara.scale.domain.vo.SysEvaluationRecordVo; import org.dromara.scale.domain.vo.SysEvaluationRecordVo;
@ -113,6 +114,11 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
if (scaleId == null) { if (scaleId == null) {
throw new ServerException("量表ID不能为空"); throw new ServerException("量表ID不能为空");
} }
SysScale sysScale = scaleMapper.selectById(scaleId);
boolean mbtiFlag = false;
if (sysScale.getScaleName().contains("MBTI")) {
mbtiFlag = true;
}
EvaluationRecordWordData wordData = new EvaluationRecordWordData(); EvaluationRecordWordData wordData = new EvaluationRecordWordData();
String name = configService.selectConfigByKey("sys.school.name"); String name = configService.selectConfigByKey("sys.school.name");
@ -217,8 +223,12 @@ public class SysEvaluationRecordServiceImpl implements ISysEvaluationRecordServi
wordData.setRadar(radar); wordData.setRadar(radar);
} }
wordData.setPropose(stringBuilder.toString()); wordData.setPropose(stringBuilder.toString());
File path = new File("/usr/local/mental/word/personalTemplate.docx"); File path = null;
if(mbtiFlag){
path = new File("/usr/local/mental/word/MBTITemplate.docx");
}else{
path = new File("/usr/local/mental/word/personalTemplate.docx");
}
File docx = FileUtil.createTempFile(".docx", true); File docx = FileUtil.createTempFile(".docx", true);
String wordPath = docx.getPath(); String wordPath = docx.getPath();
try (FileInputStream fileInputStream = new FileInputStream(path)) { try (FileInputStream fileInputStream = new FileInputStream(path)) {

View File

@ -1,6 +1,7 @@
package org.dromara.scale.starter; package org.dromara.scale.starter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.redis.utils.QueueUtils; import org.dromara.common.redis.utils.QueueUtils;
import org.dromara.scale.constant.StatusEnum; import org.dromara.scale.constant.StatusEnum;
import org.dromara.scale.domain.SysScalePublish; import org.dromara.scale.domain.SysScalePublish;
@ -16,6 +17,7 @@ import org.springframework.stereotype.Component;
* @version V1.0.0 * @version V1.0.0
* @date 2024/4/15 15:08 * @date 2024/4/15 15:08
*/ */
@Slf4j
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
@Order(value = 99) @Order(value = 99)
@ -29,14 +31,17 @@ public class ApplicationStarter implements CommandLineRunner {
} }
private void subscribeRedisDelayedQueue(){ private void subscribeRedisDelayedQueue(){
log.info("=======================延迟队列回调开始===============");
// 项目初始化设置一次即可 // 项目初始化设置一次即可
QueueUtils.subscribeBlockingQueue("endPublish-delay-queue", (Long batchNo) -> { QueueUtils.subscribeBlockingQueue("endPublish-delay-queue", (Long batchNo) -> {
log.info("=======================结束发布回调开始 批次号:{}===============",batchNo);
SysScalePublish publish = new SysScalePublish(); SysScalePublish publish = new SysScalePublish();
publish.setBatchNo(batchNo); publish.setBatchNo(batchNo);
publish.setStatus(StatusEnum.DISABLED.getValue()); publish.setStatus(StatusEnum.DISABLED.getValue());
publishMapper.updateById(publish); publishMapper.updateById(publish);
}, true); }, true);
QueueUtils.subscribeBlockingQueue("startPublish-delay-queue", (Long batchNo) -> { QueueUtils.subscribeBlockingQueue("startPublish-delay-queue", (Long batchNo) -> {
log.info("=======================预约发布回调开始 批次号:{}===============",batchNo);
//SysScalePublish scalePublish = publishMapper.selectById(batchNo); //SysScalePublish scalePublish = publishMapper.selectById(batchNo);
SysScalePublish publish = new SysScalePublish(); SysScalePublish publish = new SysScalePublish();
publish.setBatchNo(batchNo); publish.setBatchNo(batchNo);

View File

@ -40,5 +40,28 @@
where er.user_id = #{userId} where er.user_id = #{userId}
and er.status = 1 and er.status = 1
group by er.record_id group by er.record_id
order by er.create_time desc
</select>
<select id="selectScaleRecordByUserId" resultType="org.dromara.scale.domain.vo.SysEvaluationRecordVo">
select er.create_time, s.scale_name
from sys_evaluation_record er
left join sys_scale s on s.scale_id = er.scale_id
where er.status = 1
and er.user_id = #{userId}
</select>
<select id="selectWarnByUserId" resultType="org.dromara.scale.domain.vo.StatisticWarnVo">
select count(if(ec.situation = 1, 1, null)) as `noneNum`,
count(if(ec.situation = 2, 1, null)) as `lowNum`,
count(if(ec.situation = 3, 1, null)) as `middleNum`,
count(if(ec.situation = 4, 1, null)) as `highNum`,
count(if(ec.situation = 5, 1, null)) as `majorNum`
from sys_evaluation_record er
left join sys_evaluation_conclusion ec
on ec.record_id = er.record_id
where er.status = 1
and ec.status = 1
and er.user_id = #{userId}
</select> </select>
</mapper> </mapper>