diff --git a/emis-ai-web/pom.xml b/emis-ai-web/pom.xml deleted file mode 100644 index c1c3b5de6..000000000 --- a/emis-ai-web/pom.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - 4.0.0 - - com.xdadan - emis - 1.0.2 - ../pom.xml - - - jar - - emis-ai-web - 1.0.2 - - ai web服务入口 - - - 8 - pub - - - - - - com.xdadan - emis-ai - 1.0.2 - - - - - - \ No newline at end of file diff --git a/emis-ai-web/src/main/java/com/xdadan/erp/web/ai/AICommonController.java b/emis-ai-web/src/main/java/com/xdadan/erp/web/ai/AICommonController.java deleted file mode 100644 index d1be39783..000000000 --- a/emis-ai-web/src/main/java/com/xdadan/erp/web/ai/AICommonController.java +++ /dev/null @@ -1,170 +0,0 @@ - -package com.xdadan.erp.web.ai; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.xdadan.erp.ai.service.OCRService; -import com.xdadan.erp.common.config.PayConfig; -import com.xdadan.erp.common.core.controller.BaseController; -import com.xdadan.erp.common.core.domain.AjaxResult; -import com.xdadan.erp.common.core.redis.RedissonService; -import com.xdadan.erp.common.utils.file.FileUploadUtils; -import com.xdadan.erp.common.utils.file.FileUtils; -import lombok.extern.slf4j.Slf4j; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; -import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.nio.charset.StandardCharsets; -import java.util.Collections; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -/** - * AI 公共 Controller - * - * @author linfso - * @date 2023-12-14 13:02:48 - */ -@Slf4j -@RestController -@RequestMapping("/ai/common") -public class AICommonController extends BaseController -{ - - @Autowired - RedissonService redissonService; - - @Autowired - OCRService ocrService; - - - private static final String API_URL = "https://chat.deepseek.com"; - private static final String API_KEY = "sk-408990000f9c4c349c4d69df7630bc75"; - - private final ExecutorService executorService = Executors.newCachedThreadPool(); - private final ObjectMapper objectMapper = new ObjectMapper(); - - @PostMapping(value = "/aiChat", produces = MediaType.TEXT_EVENT_STREAM_VALUE) - public SseEmitter aiChat(@RequestBody String question) { - SseEmitter emitter = new SseEmitter(-1L); - executorService.execute(() -> { - try { - log.info("流式回答开始,问题:{}", question); - try (CloseableHttpClient client = HttpClients.createDefault()) { - HttpPost request = new HttpPost(API_URL); - request.setHeader("Content-Type", "application/json"); - request.setHeader("Authorization", "Bearer " + API_KEY); - - Map message = new HashMap<>(); - message.put("role", "user"); - message.put("content", question); - - Map requestMap = new HashMap<>(); - requestMap.put("model", "deepseek-chat"); - requestMap.put("messages", Collections.singletonList(message)); - requestMap.put("stream", true); - - String requestBody = objectMapper.writeValueAsString(requestMap); - request.setEntity(new StringEntity(requestBody, StandardCharsets.UTF_8)); - - try (CloseableHttpResponse response = client.execute(request); - BufferedReader reader = new BufferedReader( - new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8))) { - String line; - while ((line = reader.readLine()) != null) { - if (line.startsWith("data: ")) { - String jsonData = line.substring(6); - if ("[DONE]".equals(jsonData)) { - break; - } - JsonNode node = objectMapper.readTree(jsonData); - String content = node.path("choices") - .path(0) - .path("delta") - .path("content") - .asText(""); - if (!content.isEmpty()) { - emitter.send(content); - } - } - } - log.info("流式回答结束,{}",question); - emitter.complete(); - } - } catch (Exception e) { - log.error("处理 Deepseek 请求时发生错误", e); - emitter.completeWithError(e); - } - } catch (Exception e) { - log.error("处理 Deepseek 请求时发生错误", e); - emitter.completeWithError(e); - } - }); - return emitter; - } - - - /** - * 通用上传请求(单个) - */ - @PostMapping("/ocrRecognizeByUpload") - public AjaxResult ocrRecognizeByUpload(MultipartFile file) throws Exception - { - try - { - // 上传文件路径 - String filePath = PayConfig.getUploadPath(); - // 上传并返回新文件名称 - String fileName = FileUploadUtils.upload(filePath, file); - AjaxResult rst=ocrService.recognize(fileName); - return rst; - } - catch (Exception e) - { - return AjaxResult.error(e.getMessage()); - } - } - - /** - * ocr识别 - * @param appId - * @param sign - * @return - */ - @PostMapping("/ocrRecognizeByBase64") - public AjaxResult ocrRecognizeByBase64(String appId, String base64Data, String sign) - { - if(StringUtils.isAnyEmpty(base64Data,appId,sign)){ - return AjaxResult.error("appId,sign,mainNo required!"); - } - - if(!"xdadan20240614".equals(appId)){ - return AjaxResult.error("appId error!"); - } - - // base64写入文件 - String filePath=""; - - AjaxResult rst=ocrService.recognize(filePath); - return rst; - } - - - -} diff --git a/emis-ai/lib/aspose-words-19.1-jdk16.jar b/emis-ai/lib/aspose-words-19.1-jdk16.jar deleted file mode 100644 index d78e0fb31..000000000 Binary files a/emis-ai/lib/aspose-words-19.1-jdk16.jar and /dev/null differ diff --git a/emis-ai/lib/masmgc.sdk.sms-1.0.3-SNAPSHOT.jar b/emis-ai/lib/masmgc.sdk.sms-1.0.3-SNAPSHOT.jar deleted file mode 100644 index dbb93adcb..000000000 Binary files a/emis-ai/lib/masmgc.sdk.sms-1.0.3-SNAPSHOT.jar and /dev/null differ diff --git a/emis-ai/lib/mvn_install.sh b/emis-ai/lib/mvn_install.sh deleted file mode 100644 index 6d2a92924..000000000 --- a/emis-ai/lib/mvn_install.sh +++ /dev/null @@ -1,2 +0,0 @@ -mvn install:install-file -DgroupId=com.aspose -DartifactId=aspose-words -Dversion=19.1.0 -Dpackaging=jar -Dfile=./aspose-words-19.1-jdk16.jar -#mvn install:install-file -DgroupId=com.mascloud -DartifactId=massdk -Dversion=1.0.3 -Dpackaging=jar -Dfile=./masmgc.sdk.sms-1.0.3-SNAPSHOT.jar diff --git a/emis-ai/pom.xml b/emis-ai/pom.xml deleted file mode 100644 index ed9c8e645..000000000 --- a/emis-ai/pom.xml +++ /dev/null @@ -1,169 +0,0 @@ - - - 4.0.0 - - com.xdadan - emis - 1.0.2 - ../pom.xml - - - emis-ai - 1.0.2 - AI模块 - - - - - - com.xdadan - emis-common - 1.0.4 - - - - - com.xdadan - emis-framework - 1.0.4 - - - - com.xdadan - emis-system - 1.0.4 - compile - - - - - com.googlecode.aviator - aviator - 5.2.4 - - - - - com.itextpdf - itextpdf - 5.5.6 - - - com.itextpdf - itext-asian - 5.2.0 - - - - com.itextpdf.tool - xmlworker - 5.5.6 - - - - org.apache.pdfbox - pdfbox - 2.0.9 - - - org.apache.pdfbox - fontbox - 2.0.9 - - - - net.coobird - thumbnailator - 0.4.11 - - - - - - com.aliyun - dysmsapi20170525 - 2.0.22 - - - com.aliyun - tea-openapi - 0.2.6 - - - com.aliyun - tea-console - 0.0.1 - - - com.aliyun - tea-util - 0.2.14 - - - com.aliyun - tea - 1.1.14 - - - - - - - - - - - org.apache.poi - poi - 4.1.2 - - - - org.apache.poi - poi-scratchpad - 4.1.2 - - - - org.apache.poi - ooxml-schemas - 1.4 - - - - - com.alibaba - easyexcel - 3.3.2 - - - - com.deepoove - poi-tl - 1.10.6 - - - - - com.aspose - aspose-words - 19.1.0 - - - - - org.apache.commons - commons-text - 1.10.0 - - - org.aspectj - aspectjweaver - - - - - - \ No newline at end of file diff --git a/emis-ai/src/main/java/com/xdadan/erp/ai/service/OCRService.java b/emis-ai/src/main/java/com/xdadan/erp/ai/service/OCRService.java deleted file mode 100644 index e93bb1d83..000000000 --- a/emis-ai/src/main/java/com/xdadan/erp/ai/service/OCRService.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.xdadan.erp.ai.service; - -import com.xdadan.erp.common.core.domain.AjaxResult; -import lombok.extern.slf4j.Slf4j; -import org.springframework.stereotype.Service; - -@Service -@Slf4j -public class OCRService { - - public AjaxResult recognize(String filePath){ -// ParamConfig paramConfig = ParamConfig.getDefaultConfig(); -// paramConfig.setDoAngle(true); -// paramConfig.setMostAngle(true); -// InferenceEngine engine = InferenceEngine.getInstance(Model.ONNX_PPOCR_V4); -// // 开始识别 -// OcrResult ocrResult = engine.runOcr(filePath, paramConfig); - return AjaxResult.success("成功"); - } - - public static void main(String[] args) { -// String temPath = "/Users/alan/Downloads/工作台1.png"; -// ParamConfig paramConfig = ParamConfig.getDefaultConfig(); -// paramConfig.setDoAngle(true); -// paramConfig.setMostAngle(true); -// InferenceEngine engine = InferenceEngine.getInstance(Model.ONNX_PPOCR_V4); -// // 开始识别 -// OcrResult ocrResult = engine.runOcr(temPath, paramConfig); -// System.out.println("识别内容"+ocrResult.getStrRes().replace("\n", " ")); - } -} diff --git a/pom.xml b/pom.xml index 12e7ca543..24f2b5f85 100644 --- a/pom.xml +++ b/pom.xml @@ -41,9 +41,6 @@ emis-biz emis-biz-web - emis-ai - emis-ai-web - pom