Compare commits
3 Commits
1a42ca6a55
...
d123811617
| Author | SHA1 | Date |
|---|---|---|
|
|
d123811617 | |
|
|
9f48a4db76 | |
|
|
bf080e393d |
|
|
@ -12,8 +12,8 @@
|
|||
<artifactId>electrmangnetic-backup</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
|
@ -37,6 +37,17 @@
|
|||
<version>1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<!-- 可选:添加 JAXB 实现库(如 jaxb-impl) -->
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ import com.electromagnetic.industry.software.backup.service.FileService;
|
|||
import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
|
|
@ -17,7 +18,6 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
@RestController
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import cn.hutool.crypto.SecureUtil;
|
|||
import com.electromagnetic.industry.software.backup.pojo.BackupPro;
|
||||
import com.electromagnetic.industry.software.backup.service.FileService;
|
||||
import com.electromagnetic.industry.software.common.util.EleCommonUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.MediaType;
|
||||
|
|
@ -13,7 +14,6 @@ import org.springframework.http.ResponseEntity;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,11 @@
|
|||
<artifactId>electrmangnetic</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mapstruct.version>1.4.1.Final</mapstruct.version>
|
||||
<hutool.version>5.8.22</hutool.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
@ -32,16 +33,17 @@
|
|||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.8.22</version>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.3.1</version>
|
||||
<artifactId>mybatis-plus-spring-boot3-starter</artifactId>
|
||||
<version>3.5.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.31</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
|
@ -99,6 +101,37 @@
|
|||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.9.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-elasticsearch-store-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>co.elastic.clients</groupId>
|
||||
<artifactId>elasticsearch-java</artifactId>
|
||||
<version>8.13.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-pdf-document-reader</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
@ -107,7 +140,6 @@
|
|||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>2.6.12</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<configuration>
|
||||
|
|
@ -119,6 +151,17 @@
|
|||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version> <!-- 确保版本 >=3.6.2 -->
|
||||
<configuration>
|
||||
<parameters>true</parameters> <!-- 关键配置 -->
|
||||
<compilerArgs>
|
||||
<arg>-parameters</arg>
|
||||
</compilerArgs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.electromagnetic.industry.software.manage;
|
||||
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableScheduling
|
||||
@MapperScan("com.electromagnetic.industry.software.manage.mapper")
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
package com.electromagnetic.industry.software.manage.aop;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import jakarta.servlet.ServletRequest;
|
||||
import jakarta.servlet.ServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,13 +9,13 @@ import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
||||
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import org.aspectj.lang.reflect.MethodSignature;
|
|||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StopWatch;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
|
|
@ -26,7 +28,7 @@ public class ServiceAspect {
|
|||
*/
|
||||
@Around("execution(* com.electromagnetic.industry.software.manage.controller..*.*(..)))")
|
||||
public Object process(ProceedingJoinPoint jp) throws Throwable {
|
||||
String methodInfo = jp.getTarget().getClass().getSimpleName() + "."
|
||||
String methodInfo = jp.getTarget().getClass().getSimpleName() + "."
|
||||
+ jp.getSignature().getName();
|
||||
Object[] args = jp.getArgs();
|
||||
String[] argNames = ((MethodSignature) jp.getSignature()).getParameterNames();
|
||||
|
|
@ -41,12 +43,13 @@ public class ServiceAspect {
|
|||
}
|
||||
UserThreadLocal.setReqArgs(paramInfo);
|
||||
Object rvt = jp.proceed();
|
||||
if (rvt instanceof ResponseEntity) {
|
||||
String returnInfo = "";
|
||||
if (rvt instanceof ResponseEntity || rvt instanceof Flux) {
|
||||
UserThreadLocal.setRes(ElectromagneticResultUtil.success(""));
|
||||
return rvt;
|
||||
} else {
|
||||
UserThreadLocal.setRes((ElectromagneticResult) rvt);
|
||||
returnInfo = JSONUtil.toJsonStr(rvt);
|
||||
}
|
||||
UserThreadLocal.setRes((ElectromagneticResult) rvt);
|
||||
String returnInfo = JSONUtil.toJsonStr(rvt);
|
||||
log.info("请求接口结束:{},返回参数:{},接口耗时:{}", methodInfo, returnInfo, (System.currentTimeMillis() - startTime) + "毫秒");
|
||||
stopwatch.stop();
|
||||
log.debug(stopwatch.prettyPrint());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.electromagnetic.industry.software.manage.config;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
|
||||
import org.springframework.ai.chat.client.advisor.QuestionAnswerAdvisor;
|
||||
import org.springframework.ai.chat.memory.InMemoryChatMemory;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class AiAdvisor {
|
||||
|
||||
@Resource
|
||||
private VectorStore vectorStore;
|
||||
|
||||
@Bean
|
||||
public QuestionAnswerAdvisor questionAnswerAdvisor() {
|
||||
return new QuestionAnswerAdvisor(vectorStore);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public MessageChatMemoryAdvisor messageChatMemoryAdvisor() {
|
||||
return new MessageChatMemoryAdvisor(new InMemoryChatMemory());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -62,14 +62,6 @@ public class ElePropertyConfig {
|
|||
@Value("${backup.mysql.path}")
|
||||
private String sqlDirs;
|
||||
|
||||
@Getter
|
||||
@Value("${ai.remote.host}")
|
||||
private String aiRemoteHost;
|
||||
|
||||
@Getter
|
||||
@Value("${ai.remote.port}")
|
||||
private String aiRemotePort;
|
||||
|
||||
public String getEleTmpPath() {
|
||||
if (EleCommonUtil.isWinOs()) {
|
||||
return winPrefix + eleTmpPath;
|
||||
|
|
|
|||
|
|
@ -18,15 +18,16 @@ import com.electromagnetic.industry.software.manage.mapper.UserAccessLogMapper;
|
|||
import com.electromagnetic.industry.software.manage.pojo.models.Token;
|
||||
import com.electromagnetic.industry.software.manage.pojo.models.UserAccessLog;
|
||||
import io.jsonwebtoken.Claims;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.method.HandlerMethod;
|
||||
import org.springframework.web.servlet.HandlerInterceptor;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
package com.electromagnetic.industry.software.manage.config;
|
||||
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @version $Id: d.java, v 0.1 2021-01-05 19:33 Exp $$
|
||||
|
|
|
|||
|
|
@ -8,12 +8,11 @@ import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
|||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.AccessLogQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.UserAccessLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/log/")
|
||||
public class AccessLogController {
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.ChatQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.AiChatService;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/ai/")
|
||||
public class AiChatController {
|
||||
|
||||
@Resource
|
||||
private AiChatService aiChatService;
|
||||
|
||||
@RequestMapping(value = "chat")
|
||||
public ElectromagneticResult<?> chat(@RequestBody ChatQueryDTO chatQueryDTO) {
|
||||
return aiChatService.chat(chatQueryDTO.getQuestion());
|
||||
}
|
||||
|
||||
@RequestMapping(value = "addKnowledge")
|
||||
public ElectromagneticResult<?> addKnowledge(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
String fileType = FileUtil.extName(file.getOriginalFilename());
|
||||
if (!StrUtil.equals(fileType, "pdf")) {
|
||||
return ElectromagneticResultUtil.fail("-1", "当前仅支持pdf格式文件");
|
||||
}
|
||||
return aiChatService.addKnowledge(file);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
package com.electromagnetic.industry.software.manage.controller;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.QueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.ChatService;
|
||||
import com.electromagnetic.industry.software.manage.tasks.ChatTaskThread1;
|
||||
import com.electromagnetic.industry.software.manage.tasks.ChatTaskThread2;
|
||||
import com.electromagnetic.industry.software.manage.tasks.ChatTaskThread3;
|
||||
import com.electromagnetic.industry.software.manage.tasks.ThreadUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/ai")
|
||||
public class AiController {
|
||||
|
||||
@Resource
|
||||
private ChatService chatService;
|
||||
|
||||
@RequestMapping("/upload")
|
||||
public ElectromagneticResult<?> upload(@RequestParam("file") MultipartFile file) throws Exception {
|
||||
return chatService.addFromUpload(file);
|
||||
}
|
||||
|
||||
@PostMapping("/chat")
|
||||
public ElectromagneticResult<String> chat(@RequestBody QueryDTO queryDTO) throws Exception {
|
||||
log.info("question is --->" + queryDTO.getMsg());
|
||||
ChatTaskThread1 chatTaskThread = new ChatTaskThread1(chatService, queryDTO);
|
||||
Future<String> future = ThreadUtil.getThreadPool().submit(chatTaskThread);
|
||||
String res = future.get();
|
||||
log.info("answer is --->" + res);
|
||||
return ElectromagneticResultUtil.success(res);
|
||||
}
|
||||
|
||||
@PostMapping(path = "/chatStreamStr", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public Flux<String> chatStreamStr(@RequestBody QueryDTO queryDTO) throws ExecutionException, InterruptedException {
|
||||
ChatTaskThread2 chatTaskThread = new ChatTaskThread2(chatService, queryDTO);
|
||||
Future<Flux<String>> future = ThreadUtil.getThreadPool().submit(chatTaskThread);
|
||||
return future.get();
|
||||
}
|
||||
|
||||
@PostMapping(path = "/chatStreamResp", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public Flux<ChatResponse> chatStreamResp(@RequestBody QueryDTO queryDTO) throws ExecutionException, InterruptedException {
|
||||
ChatTaskThread3 chatTaskThread = new ChatTaskThread3(chatService, queryDTO);
|
||||
Future<Flux<ChatResponse>> future = ThreadUtil.getThreadPool().submit(chatTaskThread);
|
||||
return future.get();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,9 +8,9 @@ import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.TagCreateDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdTagLibraryService;
|
||||
import com.electromagnetic.industry.software.manage.service.FileTagRelationService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
|
|
|||
|
|
@ -5,13 +5,12 @@ import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnu
|
|||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.service.FileBackLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/backup/")
|
||||
public class FileBackupLogController {
|
||||
|
|
|
|||
|
|
@ -5,13 +5,12 @@ import com.electromagnetic.industry.software.common.enums.UserOperationModuleEnu
|
|||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.service.FileFormatService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/file/format")
|
||||
public class FileFormatController {
|
||||
|
|
|
|||
|
|
@ -8,13 +8,12 @@ import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
|||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.RecycleFileQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.FileRecycleService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/recycle/file")
|
||||
public class FileRecycleController {
|
||||
|
|
|
|||
|
|
@ -6,13 +6,12 @@ import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
|||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/permission")
|
||||
public class PermissionController {
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.EdFileRelationServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
|
|
|
|||
|
|
@ -11,11 +11,10 @@ import com.electromagnetic.industry.software.manage.pojo.models.EdFileRelation;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.CheckNameUniqueRequest;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateRelationDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.EdFileRelationServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/repo/relation")
|
||||
public class RepoEdFileRelationController {
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.QueryPublishStatus;
|
||||
import com.electromagnetic.industry.software.manage.service.EdPrjService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import com.electromagnetic.industry.software.common.util.ElectromagneticResultUt
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.RoleDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.RolePageDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.RoleService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/role")
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
|
|
|
|||
|
|
@ -11,11 +11,10 @@ import com.electromagnetic.industry.software.manage.pojo.models.EdFileRelation;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.CheckNameUniqueRequest;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateRelationDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.EdFileRelationServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/relation")
|
||||
public class SysEdFileRelationController {
|
||||
|
|
|
|||
|
|
@ -10,12 +10,12 @@ import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.QueryPublishStatus;
|
||||
import com.electromagnetic.industry.software.manage.service.EdPrjService;
|
||||
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ import com.electromagnetic.industry.software.common.util.ElectromagneticResultUt
|
|||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.*;
|
||||
import com.electromagnetic.industry.software.manage.service.UserService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
|
|
|||
|
|
@ -13,13 +13,14 @@ import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileFavoriteService;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileInfoService;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
|
|
@ -28,8 +29,6 @@ public class UserEdFileInfoController {
|
|||
|
||||
@Resource
|
||||
private EdFileInfoService edFileInfoService;
|
||||
@Resource
|
||||
private EdFileFavoriteService edFileFavoriteService;
|
||||
|
||||
@UserOperation(value = "查看工程树", modelName = UserOperationModuleEnum.USER_PRJ)
|
||||
@RequestMapping("tree")
|
||||
|
|
|
|||
|
|
@ -11,11 +11,10 @@ import com.electromagnetic.industry.software.manage.pojo.models.EdFileRelation;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.CheckNameUniqueRequest;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateRelationDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.EdFileRelationServiceImpl;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/user/relation")
|
||||
public class UserEdFileRelationController {
|
||||
|
|
|
|||
|
|
@ -7,13 +7,12 @@ import com.electromagnetic.industry.software.common.util.ElectromagneticResultUt
|
|||
import com.electromagnetic.industry.software.common.util.UserThreadLocal;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.TagCreateDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.FileTagRelationService;
|
||||
import jakarta.annotation.Resource;
|
||||
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 javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/data/ed/user/tag")
|
||||
public class UserEdFileTagController {
|
||||
|
|
|
|||
|
|
@ -8,12 +8,12 @@ import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.FolderResortDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.QueryPublishStatus;
|
||||
import com.electromagnetic.industry.software.manage.service.EdPrjService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class QueryDTO {
|
||||
|
||||
private String msg;
|
||||
|
||||
// private String userId;
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.electromagnetic.industry.software.manage.pojo.req;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UploadDTO {
|
||||
|
||||
private String content;
|
||||
|
||||
}
|
||||
|
|
@ -9,11 +9,11 @@ import com.electromagnetic.industry.software.manage.pojo.req.CreateFolderDTO;
|
|||
import com.electromagnetic.industry.software.manage.pojo.req.FileChunkDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.FileInfoQueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.UpdateFileInfoDTO;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,41 +0,0 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.StrFormatter;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.electromagnetic.industry.software.common.parse.PdfParse;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class AiChatService {
|
||||
|
||||
@Resource
|
||||
private ElePropertyConfig elePropertyConfig;
|
||||
|
||||
public ElectromagneticResult<?> chat(String message) {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
String url = StrFormatter.format("http://{}:{}/data/ed/ai/chat", elePropertyConfig.getAiRemoteHost(), elePropertyConfig.getAiRemotePort());
|
||||
String res = HttpUtil.post(url, JSONUtil.toJsonStr(map), 5 * 60 * 1000);
|
||||
ElectromagneticResult<?> result = JSONUtil.toBean(res, ElectromagneticResult.class);
|
||||
return result;
|
||||
}
|
||||
|
||||
public ElectromagneticResult<?> addKnowledge(MultipartFile file) throws IOException {
|
||||
String content = new PdfParse().parseAllText(file.getInputStream(), "pdf");
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("content", content);
|
||||
String url = StrFormatter.format("http://{}:{}/data/ed/ai/upload", elePropertyConfig.getAiRemoteHost(), elePropertyConfig.getAiRemotePort());
|
||||
String res = HttpUtil.post(url, JSONUtil.toJsonStr(map));
|
||||
return JSONUtil.toBean(res, ElectromagneticResult.class);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
package com.electromagnetic.industry.software.manage.service.serviceimpl;
|
||||
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.crypto.digest.DigestUtil;
|
||||
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.common.util.ElectromagneticResultUtil;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.QueryDTO;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.ai.chat.client.ChatClient;
|
||||
import org.springframework.ai.chat.client.advisor.*;
|
||||
import org.springframework.ai.chat.messages.UserMessage;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import org.springframework.ai.chat.prompt.Prompt;
|
||||
import org.springframework.ai.document.Document;
|
||||
import org.springframework.ai.ollama.OllamaChatModel;
|
||||
import org.springframework.ai.reader.pdf.PagePdfDocumentReader;
|
||||
import org.springframework.ai.vectorstore.VectorStore;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.codec.ServerSentEvent;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ChatService {
|
||||
|
||||
@Resource
|
||||
private VectorStore vectorStore;
|
||||
|
||||
@Resource
|
||||
private OllamaChatModel model;
|
||||
|
||||
@Resource
|
||||
private MessageChatMemoryAdvisor messageChatMemoryAdvisor;
|
||||
|
||||
@Resource
|
||||
private QuestionAnswerAdvisor questionAnswerAdvisor;
|
||||
|
||||
@Value("file.md5RecordPath")
|
||||
private String uploadFileMd5RecordPath;
|
||||
|
||||
@PostMapping
|
||||
public void init() {
|
||||
if (!FileUtil.exist(uploadFileMd5RecordPath)) {
|
||||
FileUtil.touch(uploadFileMd5RecordPath);
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String content) {
|
||||
List<Document> documents = Stream.of(content).map(Document::new).collect(Collectors.toList());
|
||||
vectorStore.write(documents);
|
||||
}
|
||||
|
||||
public ElectromagneticResult<?> addFromUpload(MultipartFile file) throws Exception{
|
||||
String fileType = FileUtil.extName(file.getOriginalFilename());
|
||||
if (!StrUtil.equals(fileType, "pdf")) {
|
||||
return ElectromagneticResultUtil.fail("-1", "当前仅支持pdf格式文件");
|
||||
}
|
||||
String fileMd5 = DigestUtil.md5Hex(file.getInputStream());
|
||||
List<String> lines = FileUtil.readLines(uploadFileMd5RecordPath, Charset.defaultCharset());
|
||||
if (lines.contains(fileMd5)) {
|
||||
return ElectromagneticResultUtil.success(fileMd5);
|
||||
}
|
||||
String pdfTmpPath = FileUtil.getParent(uploadFileMd5RecordPath, 1) + File.separator + IdUtil.fastSimpleUUID() + "." + fileType;
|
||||
FileUtil.writeFromStream(file.getInputStream(), pdfTmpPath);
|
||||
|
||||
PagePdfDocumentReader pagePdfDocumentReader = new PagePdfDocumentReader(pdfTmpPath);
|
||||
List<Document> documents = pagePdfDocumentReader.read();
|
||||
vectorStore.write(documents);
|
||||
lines.add(fileMd5);
|
||||
FileUtil.writeLines(lines, uploadFileMd5RecordPath, Charset.defaultCharset());
|
||||
FileUtil.del(pdfTmpPath);
|
||||
return ElectromagneticResultUtil.success(fileMd5);
|
||||
}
|
||||
|
||||
public String chat(QueryDTO queryDTO) {
|
||||
|
||||
log.info("Start call model to answer");
|
||||
|
||||
return ChatClient.builder(model).defaultAdvisors(messageChatMemoryAdvisor, questionAnswerAdvisor).build().prompt()
|
||||
.user(queryDTO.getMsg())
|
||||
.advisors(advisorSpec -> advisorSpec
|
||||
// .param(CHAT_MEMORY_CONVERSATION_ID_KEY, queryDTO.getUserId())
|
||||
.param(AbstractChatMemoryAdvisor.CHAT_MEMORY_RETRIEVE_SIZE_KEY, 100))
|
||||
.call()
|
||||
.content();
|
||||
}
|
||||
|
||||
public Flux<String> chatStreamStr(String msg) {
|
||||
return ChatClient.builder(model).defaultAdvisors(messageChatMemoryAdvisor, questionAnswerAdvisor).build().prompt(msg).stream().content();
|
||||
}
|
||||
|
||||
public Flux<ChatResponse> chatStreamResponse(String msg) {
|
||||
ChatClient.StreamResponseSpec stream = ChatClient.builder(model).defaultAdvisors(messageChatMemoryAdvisor, questionAnswerAdvisor).build().prompt(new Prompt(new UserMessage(msg))).stream();
|
||||
return stream.chatResponse();
|
||||
}
|
||||
}
|
||||
|
|
@ -27,12 +27,12 @@ import com.electromagnetic.industry.software.manage.pojo.resp.FileProjectVO;
|
|||
import com.electromagnetic.industry.software.manage.pojo.resp.ProjectVO;
|
||||
import com.electromagnetic.industry.software.manage.service.FileFormatService;
|
||||
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ import com.electromagnetic.industry.software.manage.pojo.resp.FileProjectVO;
|
|||
import com.electromagnetic.industry.software.manage.pojo.resp.FileVersionViewVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.UploadRecordVO;
|
||||
import com.electromagnetic.industry.software.manage.service.*;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.InputStreamResource;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
|
@ -50,8 +52,6 @@ import org.springframework.transaction.annotation.Propagation;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ import com.electromagnetic.industry.software.manage.pojo.req.CheckNameUniqueRequ
|
|||
import com.electromagnetic.industry.software.manage.pojo.resp.FileRelationViewVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileSimpleInfoVO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdFileRelationService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static com.electromagnetic.industry.software.common.cons.ElectromagneticConstants.*;
|
||||
|
|
|
|||
|
|
@ -25,11 +25,11 @@ import com.electromagnetic.industry.software.manage.pojo.req.QueryPublishStatus;
|
|||
import com.electromagnetic.industry.software.manage.pojo.resp.ProjectVO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdPrjService;
|
||||
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
|
|||
|
|
@ -19,11 +19,11 @@ import com.electromagnetic.industry.software.manage.pojo.models.FileTagRelation;
|
|||
import com.electromagnetic.industry.software.manage.pojo.resp.FileTagInfo;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.TagListVO;
|
||||
import com.electromagnetic.industry.software.manage.service.EdTagLibraryService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@ import com.electromagnetic.industry.software.manage.pojo.models.FileBackupLog;
|
|||
import com.electromagnetic.industry.software.manage.pojo.resp.FileBackLogVO;
|
||||
import com.electromagnetic.industry.software.manage.service.FileBackLogService;
|
||||
import com.electromagnetic.industry.software.manage.tasks.BackupHandler;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ import com.electromagnetic.industry.software.manage.service.FileRecycleService;
|
|||
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
||||
import com.electromagnetic.industry.software.manage.tasks.BackupHandler;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ import com.electromagnetic.industry.software.manage.pojo.models.EdTagLibrary;
|
|||
import com.electromagnetic.industry.software.manage.pojo.models.FileTagRelation;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.FileTagInfo;
|
||||
import com.electromagnetic.industry.software.manage.service.FileTagRelationService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ import com.electromagnetic.industry.software.manage.pojo.models.RolePermission;
|
|||
import com.electromagnetic.industry.software.manage.pojo.models.UserRole;
|
||||
import com.electromagnetic.industry.software.manage.service.PermissionService;
|
||||
import com.electromagnetic.industry.software.manage.service.RolePermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
|
|||
|
|
@ -7,11 +7,11 @@ import com.electromagnetic.industry.software.manage.pojo.models.EdFileInfo;
|
|||
import com.electromagnetic.industry.software.manage.pojo.models.RolePermission;
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.PublishedFileDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.RolePermissionService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
|
|
|||
|
|
@ -26,10 +26,10 @@ import com.electromagnetic.industry.software.manage.service.PermissionService;
|
|||
import com.electromagnetic.industry.software.manage.service.RolePermissionService;
|
||||
import com.electromagnetic.industry.software.manage.service.RoleService;
|
||||
import com.electromagnetic.industry.software.manage.service.UserRoleService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@ import com.electromagnetic.industry.software.manage.pojo.req.AccessLogQueryDTO;
|
|||
import com.electromagnetic.industry.software.manage.pojo.resp.AccessLogQueryVO;
|
||||
import com.electromagnetic.industry.software.manage.pojo.resp.OperationModuleVO;
|
||||
import com.electromagnetic.industry.software.manage.service.UserAccessLogService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ import com.electromagnetic.industry.software.manage.pojo.resp.UserSearchResponse
|
|||
import com.electromagnetic.industry.software.manage.service.UserService;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
import static cn.hutool.core.date.DateTime.now;
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ import cn.hutool.json.JSONUtil;
|
|||
import com.electromagnetic.industry.software.common.pojo.BackupFileResLog;
|
||||
import com.electromagnetic.industry.software.common.resp.ElectromagneticResult;
|
||||
import com.electromagnetic.industry.software.manage.config.ElePropertyConfig;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
|
|
|||
|
|
@ -26,11 +26,11 @@ import com.electromagnetic.industry.software.manage.pojo.models.FileBackupLog;
|
|||
import com.electromagnetic.industry.software.manage.pojo.models.UserAccessLog;
|
||||
import com.electromagnetic.industry.software.manage.service.FileSystemService;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.CommonService;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.Arrays;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,21 @@
|
|||
package com.electromagnetic.industry.software.manage.tasks;
|
||||
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.QueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.ChatService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ChatTaskThread1 implements Callable<String> {
|
||||
|
||||
private ChatService chatService;
|
||||
private QueryDTO queryDTO;
|
||||
|
||||
@Override
|
||||
public String call() throws Exception {
|
||||
return chatService.chat(queryDTO);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.electromagnetic.industry.software.manage.tasks;
|
||||
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.QueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.ChatService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatTaskThread2 implements Callable<Flux<String>> {
|
||||
private ChatService chatService;
|
||||
private QueryDTO queryDTO;
|
||||
|
||||
@Override
|
||||
public Flux<String> call() throws Exception {
|
||||
return chatService.chatStreamStr(queryDTO.getMsg());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.electromagnetic.industry.software.manage.tasks;
|
||||
|
||||
import com.electromagnetic.industry.software.manage.pojo.req.QueryDTO;
|
||||
import com.electromagnetic.industry.software.manage.service.serviceimpl.ChatService;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.ai.chat.model.ChatResponse;
|
||||
import reactor.core.publisher.Flux;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ChatTaskThread3 implements Callable<Flux<ChatResponse>> {
|
||||
|
||||
private ChatService chatService;
|
||||
private QueryDTO queryDTO;
|
||||
|
||||
@Override
|
||||
public Flux<ChatResponse> call() throws Exception {
|
||||
return chatService.chatStreamResponse(queryDTO.getMsg());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.electromagnetic.industry.software.manage.tasks;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
public final class ThreadUtil {
|
||||
|
||||
private static final ExecutorService THREAD_POOL = new ThreadPoolExecutor(1, 1, 3, TimeUnit.SECONDS, new LinkedBlockingDeque<>(100), Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardOldestPolicy());
|
||||
|
||||
public static ExecutorService getThreadPool() {
|
||||
return THREAD_POOL;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -9,6 +9,21 @@ spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
|||
spring.jackson.time-zone=GMT+8
|
||||
spring.servlet.multipart.max-file-size=500MB
|
||||
spring.servlet.multipart.max-request-size=500MB
|
||||
spring.mvc.async.request-timeout=3600000
|
||||
# es
|
||||
spring.elasticsearch.password=_oO*of_l-b+4mrzXo6B0
|
||||
spring.elasticsearch.username=elastic
|
||||
spring.elasticsearch.uris=http://139.196.179.195:9200
|
||||
#ai
|
||||
spring.ai.ollama.base-url=http://localhost:11434
|
||||
spring.ai.ollama.chat.options.model=gemma3:latest
|
||||
spring.ai.ollama.chat.options.num-g-p-u=1
|
||||
spring.ai.ollama.embedding.enabled=true
|
||||
spring.ai.ollama.embedding.model=nomic-embed-text
|
||||
spring.ai.vectorstore.elasticsearch.initialize-schema=true
|
||||
spring.ai.vectorstore.elasticsearch.index-name=rag
|
||||
spring.ai.vectorstore.elasticsearch.dimensions=768
|
||||
spring.ai.vectorstore.elasticsearch.similarity=cosine
|
||||
# mybatis
|
||||
mybatis-plus.mapper-locations=classpath:sqlmapper/*.xml
|
||||
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
|
@ -36,8 +51,4 @@ tmp.file.store.hour=48
|
|||
backup.remote.host=127.0.0.1
|
||||
backup.remote.port=1111
|
||||
backup.mysql.path=/workspace/mysqlbak/test
|
||||
backup.mysql.script.path=/workspace/mysqlbak/back_dev.sh
|
||||
|
||||
# ai options
|
||||
ai.remote.host=127.0.0.1
|
||||
ai.remote.port=8186
|
||||
backup.mysql.script.path=/workspace/mysqlbak/back_dev.sh
|
||||
|
|
@ -12,8 +12,8 @@
|
|||
<artifactId>electromagnetic-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<jwt.version>0.9.0</jwt.version>
|
||||
</properties>
|
||||
|
|
@ -91,7 +91,16 @@
|
|||
<artifactId>pdfbox</artifactId>
|
||||
<version>2.0.24</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sun.xml.bind</groupId>
|
||||
<artifactId>jaxb-impl</artifactId>
|
||||
<version>2.3.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
40
pom.xml
40
pom.xml
|
|
@ -15,15 +15,25 @@
|
|||
</modules>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<java.version>17</java.version>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<spring.boot.version>2.6.3</spring.boot.version>
|
||||
<spring.boot.version>3.3.8</spring.boot.version>
|
||||
<spring.ai.version>1.0.0-M5</spring.ai.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.ai</groupId>
|
||||
<artifactId>spring-ai-bom</artifactId>
|
||||
<version>${spring.ai.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
|
|
@ -34,4 +44,26 @@
|
|||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spring-snapshots</id>
|
||||
<name>Spring Snapshots</name>
|
||||
<url>https://repo.spring.io/snapshot</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<name>Central Portal Snapshots</name>
|
||||
<id>central-portal-snapshots</id>
|
||||
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
</project>
|
||||
Loading…
Reference in New Issue