feat: 删除冗余接口

This commit is contained in:
JR
2025-08-02 16:40:16 +08:00
parent bac9fbd1fb
commit 9f89ef9fcb
14 changed files with 106 additions and 646 deletions

View File

@@ -301,3 +301,30 @@ flowable:
tesseract:
data-path: D:/tessdata # Windows开发环境
# datapath: /opt/tessdata # Linux生产环境
# 图片识别配置
image:
recognition:
# AI API配置
api-url: https://api.siliconflow.cn/v1/chat/completions
model-name: Qwen/Qwen2.5-VL-32B-Instruct
api-key: sk-sbmuklhrcxqlsucufqebiibauflxqfdafqjxaedtwirurtrc
max-retries: 3
temperature: 0.0
max-tokens: 4096
# 图片处理配置
max-image-dimension: 512
image-quality: 60
# 销售话术生成器配置
sales:
script:
ai:
# DeepSeek API配置
api-key: sk-5eb55d2fb2cc4fe58a0150919a1f0d70
base-url: https://api.deepseek.com/v1
model-name: deepseek-chat
max-retries: 3
temperature: 1.0

View File

@@ -0,0 +1,21 @@
package com.klp.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "sales.script.ai")
public class DeepseekConfig {
private String apiKey;
private String baseUrl;
private String modelName;
private Integer maxRetries;
private Double temperature;
}

View File

@@ -0,0 +1,27 @@
package com.klp.common.config;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@Data
@Component
@ConfigurationProperties(prefix = "image.recognition")
public class ImageRecognitionConfig {
/**
* AI API配置
*/
private String apiUrl;
private String modelName;
private String apiKey;
private Integer maxRetries = 3;
private Double temperature = 0.0;
private Integer maxTokens = 4096;
/**
* 图片处理配置
*/
private Integer maxImageDimension = 512;
private Integer imageQuality = 60;
}

View File

@@ -1,4 +1,4 @@
package com.klp.config;
package com.klp.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -11,13 +11,13 @@ import org.springframework.web.client.RestTemplate;
*/
@Configuration
public class RestTemplateConfig {
@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
factory.setConnectTimeout(30000); // 30秒连接超时
factory.setReadTimeout(60000); // 60秒读取超时
return new RestTemplate(factory);
}
}
}

View File

@@ -1,4 +1,4 @@
package com.klp.config;
package com.klp.common.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -24,4 +24,4 @@ public class SalesScriptConfig {
factory.setReadTimeout(60000); // 60秒读取超时
return new RestTemplate(factory);
}
}
}

View File

@@ -1,96 +0,0 @@
package com.klp.config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* 图片识别配置类
*
* @author klp
* @date 2025-01-27
*/
@Configuration
@ConfigurationProperties(prefix = "image.recognition")
public class ImageRecognitionConfig {
/**
* AI API配置
*/
private String apiUrl = "https://api.siliconflow.cn/v1/chat/completions";
private String modelName = "Qwen/Qwen2.5-VL-72B-Instruct";
private String apiKey = "sk-sbmuklhrcxqlsucufqebiibauflxqfdafqjxaedtwirurtrc";
private Integer maxRetries = 3;
private Double temperature = 0.0;
private Integer maxTokens = 4096;
/**
* 图片处理配置
*/
private Integer maxImageDimension = 512;
private Integer imageQuality = 60;
// Getters and Setters
public String getApiUrl() {
return apiUrl;
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public String getModelName() {
return modelName;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public Integer getMaxRetries() {
return maxRetries;
}
public void setMaxRetries(Integer maxRetries) {
this.maxRetries = maxRetries;
}
public Double getTemperature() {
return temperature;
}
public void setTemperature(Double temperature) {
this.temperature = temperature;
}
public Integer getMaxTokens() {
return maxTokens;
}
public void setMaxTokens(Integer maxTokens) {
this.maxTokens = maxTokens;
}
public Integer getMaxImageDimension() {
return maxImageDimension;
}
public void setMaxImageDimension(Integer maxImageDimension) {
this.maxImageDimension = maxImageDimension;
}
public Integer getImageQuality() {
return imageQuality;
}
public void setImageQuality(Integer imageQuality) {
this.imageQuality = imageQuality;
}
}

View File

@@ -63,95 +63,5 @@ public class WmsSalesScriptGeneratorController extends BaseController {
return R.ok(result);
}
/**
* 测试AI连接
*/
@GetMapping("/testConnection")
public R<Map<String, Object>> testConnection() {
Map<String, Object> result = iWmsSalesScriptGeneratorService.testAiConnection();
return R.ok(result);
}
/**
* 获取生成配置
*/
@GetMapping("/config")
public R<Map<String, Object>> getConfig() {
Map<String, Object> config = iWmsSalesScriptGeneratorService.getGenerationConfig();
return R.ok(config);
}
/**
* 更新生成配置
*/
@Log(title = "更新话术生成配置", businessType = BusinessType.UPDATE)
@PostMapping("/config")
public R<Void> updateConfig(@RequestBody Map<String, Object> config) {
iWmsSalesScriptGeneratorService.updateGenerationConfig(config);
return R.ok();
}
/**
* 获取可用的产品列表
*/
@GetMapping("/availableProducts")
public R<List<Map<String, Object>>> getAvailableProducts() {
List<Map<String, Object>> products = iWmsSalesScriptGeneratorService.getAvailableProducts();
return R.ok(products);
}
/**
* 获取生成历史
*/
@GetMapping("/history")
public TableDataInfo<Map<String, Object>> getGenerationHistory(PageQuery pageQuery) {
return iWmsSalesScriptGeneratorService.getGenerationHistory(pageQuery);
}
/**
* 重新生成指定话术
*/
@Log(title = "重新生成话术", businessType = BusinessType.UPDATE)
@PostMapping("/regenerate/{scriptId}")
public R<WmsProductSalesScriptVo> regenerateScript(@NotNull(message = "话术ID不能为空")
@PathVariable Long scriptId) {
WmsProductSalesScriptVo script = iWmsSalesScriptGeneratorService.regenerateScript(scriptId);
return R.ok(script);
}
/**
* 预览话术生成(不保存到数据库)
*/
@PostMapping("/preview")
public R<List<Map<String, Object>>> previewScripts(@RequestBody WmsSalesScriptGeneratorBo bo) {
List<Map<String, Object>> previews = iWmsSalesScriptGeneratorService.previewScripts(bo);
return R.ok(previews);
}
/**
* 获取客户类型列表
*/
@GetMapping("/customerTypes")
public R<List<Map<String, Object>>> getCustomerTypes() {
List<Map<String, Object>> customerTypes = iWmsSalesScriptGeneratorService.getCustomerTypes();
return R.ok(customerTypes);
}
/**
* 获取产品特性关键词
*/
@GetMapping("/featureKeywords")
public R<List<String>> getFeatureKeywords() {
List<String> keywords = iWmsSalesScriptGeneratorService.getFeatureKeywords();
return R.ok(keywords);
}
/**
* 分析产品信息并生成话术建议
*/
@PostMapping("/analyzeProduct")
public R<Map<String, Object>> analyzeProduct(@RequestBody WmsSalesScriptGeneratorBo bo) {
Map<String, Object> analysis = iWmsSalesScriptGeneratorService.analyzeProduct(bo);
return R.ok(analysis);
}
}
}

View File

@@ -35,7 +35,7 @@ public class WmsSalesScriptGeneratorBo extends BaseEntity {
*/
@Min(value = 1, message = "话术数量最少为1")
@Max(value = 10, message = "话术数量最多为10")
private Integer scriptCount = 5;
private Integer scriptCount = 1;
/**
* 客户类型列表
@@ -45,7 +45,7 @@ public class WmsSalesScriptGeneratorBo extends BaseEntity {
/**
* 是否保存到数据库
*/
private Boolean saveToDatabase = true;
private Boolean saveToDatabase = false;
/**
* 生成模式single(单个产品), batch(批量产品), preview(预览模式)
@@ -120,4 +120,4 @@ public class WmsSalesScriptGeneratorBo extends BaseEntity {
* 备注
*/
private String remark;
}
}

View File

@@ -27,21 +27,6 @@ public class ImageRecognitionVo implements Serializable {
*/
private String recognitionType;
/**
* 识别结果
*/
private String recognizedText;
/**
* 结构化识别结果JSON格式
*/
private Map<String, Object> structuredResult;
/**
* BOM信息列表
*/
private List<BomItemVo> bomItems;
/**
* 识别结果属性列表
*/

View File

@@ -40,77 +40,4 @@ public interface IWmsSalesScriptGeneratorService {
*/
Map<String, Object> generateScriptsForProductIds(WmsSalesScriptGeneratorBo bo);
/**
* 测试AI连接
*
* @return 测试结果
*/
Map<String, Object> testAiConnection();
/**
* 获取生成配置
*
* @return 配置信息
*/
Map<String, Object> getGenerationConfig();
/**
* 更新生成配置
*
* @param config 配置信息
*/
void updateGenerationConfig(Map<String, Object> config);
/**
* 获取可用的产品列表
*
* @return 产品列表
*/
List<Map<String, Object>> getAvailableProducts();
/**
* 获取生成历史
*
* @param pageQuery 分页查询
* @return 历史记录
*/
TableDataInfo<Map<String, Object>> getGenerationHistory(PageQuery pageQuery);
/**
* 重新生成指定话术
*
* @param scriptId 话术ID
* @return 重新生成的话术
*/
WmsProductSalesScriptVo regenerateScript(Long scriptId);
/**
* 预览话术生成(不保存到数据库)
*
* @param bo 生成参数
* @return 预览话术列表
*/
List<Map<String, Object>> previewScripts(WmsSalesScriptGeneratorBo bo);
/**
* 获取客户类型列表
*
* @return 客户类型列表
*/
List<Map<String, Object>> getCustomerTypes();
/**
* 获取产品特性关键词
*
* @return 关键词列表
*/
List<String> getFeatureKeywords();
/**
* 分析产品信息并生成话术建议
*
* @param bo 分析参数
* @return 分析结果
*/
Map<String, Object> analyzeProduct(WmsSalesScriptGeneratorBo bo);
}
}

View File

@@ -2,7 +2,7 @@ package com.klp.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.klp.config.ImageRecognitionConfig;
import com.klp.common.config.ImageRecognitionConfig;
import com.klp.domain.bo.ImageRecognitionBo;
import com.klp.domain.vo.AttributeVo;
import com.klp.domain.vo.ImageRecognitionVo;
@@ -87,28 +87,18 @@ public class ImageRecognitionServiceImpl implements IImageRecognitionService {
ImageRecognitionVo result = new ImageRecognitionVo();
result.setImageUrl(bo.getImageUrl());
result.setRecognitionType("bom");
result.setRecognizedText(aiResponse);
// 解析识别结果
try {
// 直接解析属性数组
List<AttributeVo> attributes = parseAttributesResponse(aiResponse);
result.setAttributes(attributes);
// 直接解析属性数组
List<AttributeVo> attributes = parseAttributesResponse(aiResponse);
result.setAttributes(attributes);
// 构建结构化结果
Map<String, Object> structuredResult = new HashMap<>();
structuredResult.put("attributes", attributes);
structuredResult.put("summary", "材料质保单识别结果");
structuredResult.put("totalItems", attributes.size());
result.setStructuredResult(structuredResult);
// 构建结构化结果
Map<String, Object> structuredResult = new HashMap<>();
structuredResult.put("attributes", attributes);
structuredResult.put("summary", "材料质保单识别结果");
structuredResult.put("totalItems", attributes.size());
// BOM项目为空因为这是质保单识别
result.setBomItems(new ArrayList<>());
} catch (Exception e) {
log.warn("解析识别响应失败: {}", e.getMessage());
result.setRecognizedText(aiResponse);
}
return result;
}
@@ -120,7 +110,6 @@ public class ImageRecognitionServiceImpl implements IImageRecognitionService {
ImageRecognitionVo result = new ImageRecognitionVo();
result.setImageUrl(bo.getImageUrl());
result.setRecognitionType("text");
result.setRecognizedText(aiResponse);
return result;
}
@@ -136,8 +125,6 @@ public class ImageRecognitionServiceImpl implements IImageRecognitionService {
ImageRecognitionVo result = new ImageRecognitionVo();
result.setImageUrl(bo.getImageUrl());
result.setRecognitionType("general");
result.setRecognizedText(aiResponse);
return result;
}

View File

@@ -1,5 +1,6 @@
package com.klp.service.impl;
import com.klp.common.config.DeepseekConfig;
import com.klp.common.core.page.TableDataInfo;
import com.klp.common.core.domain.PageQuery;
import com.klp.common.utils.StringUtils;
@@ -23,6 +24,7 @@ import org.springframework.web.client.RestTemplate;
import org.springframework.http.*;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import javax.annotation.Resource;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
@@ -43,31 +45,11 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
private final IWmsProductService iWmsProductService;
private final IWmsProductBomService iWmsProductBomService;
private final IWmsProductSalesScriptService iWmsProductSalesScriptService;
// private final RedisUtils redisUtils;
@Qualifier("salesScriptRestTemplate")
private final RestTemplate restTemplate;
// AI配置
@Value("${sales.script.ai.api-key:sk-5eb55d2fb2cc4fe58a0150919a1f0d70}")
private String apiKey;
@Value("${sales.script.ai.base-url:https://api.deepseek.com/v1}")
private String baseUrl;
@Value("${sales.script.ai.model-name:deepseek-chat}")
private String modelName;
@Value("${sales.script.ai.max-retries:3}")
private Integer maxRetries;
@Value("${sales.script.ai.temperature:1.0}")
private Double temperature;
// 客户类型配置
private static final List<String> CUSTOMER_TYPES = Arrays.asList(
"技术型客户", "价格敏感型客户", "质量优先型客户", "批量采购客户", "定制化需求客户"
);
@Resource
private DeepseekConfig deepseekConfig;
// 产品特性关键词
private static final List<String> FEATURE_KEYWORDS = Arrays.asList(
@@ -211,168 +193,6 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
return result;
}
@Override
public Map<String, Object> testAiConnection() {
Map<String, Object> result = new HashMap<>();
try {
// 构建测试请求
Map<String, Object> requestBody = new HashMap<>();
requestBody.put("model", modelName);
Map<String, String> message = new HashMap<>();
message.put("role", "user");
message.put("content", "你好");
requestBody.put("messages", Arrays.asList(message));
requestBody.put("max_tokens", 10);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setBearerAuth(apiKey);
HttpEntity<Map<String, Object>> entity = new HttpEntity<>(requestBody, headers);
ResponseEntity<Map> response = restTemplate.postForEntity(
baseUrl + "/chat/completions", entity, Map.class);
result.put("success", true);
result.put("message", "AI连接测试成功");
result.put("response", response.getBody());
} catch (Exception e) {
log.error("AI连接测试失败", e);
result.put("success", false);
result.put("message", "AI连接测试失败: " + e.getMessage());
}
return result;
}
@Override
public Map<String, Object> getGenerationConfig() {
Map<String, Object> config = new HashMap<>();
config.put("apiKey", StringUtils.isNotEmpty(apiKey) ? apiKey.substring(0, 10) + "..." : "");
config.put("baseUrl", baseUrl);
config.put("modelName", modelName);
config.put("maxRetries", maxRetries);
config.put("temperature", temperature);
config.put("customerTypes", CUSTOMER_TYPES);
config.put("featureKeywords", FEATURE_KEYWORDS);
return config;
}
@Override
public void updateGenerationConfig(Map<String, Object> config) {
// 这里可以实现配置更新逻辑
// 可以将配置保存到数据库或配置文件中
log.info("更新生成配置: {}", config);
}
@Override
public List<Map<String, Object>> getAvailableProducts() {
List<Map<String, Object>> products = new ArrayList<>();
try {
List<WmsProductVo> productList = iWmsProductService.queryList(new com.klp.domain.bo.WmsProductBo());
for (WmsProductVo product : productList) {
if (product.getIsEnabled() != null && product.getIsEnabled() == 1) {
Map<String, Object> productMap = new HashMap<>();
productMap.put("productId", product.getProductId());
productMap.put("productName", product.getProductName());
productMap.put("productCode", product.getProductCode());
productMap.put("owner", product.getOwner());
products.add(productMap);
}
}
} catch (Exception e) {
log.error("获取可用产品列表失败", e);
}
return products;
}
@Override
public TableDataInfo<Map<String, Object>> getGenerationHistory(PageQuery pageQuery) {
// 这里可以实现生成历史查询逻辑
// 可以创建一个专门的表来记录生成历史
TableDataInfo<Map<String, Object>> result = new TableDataInfo<>();
result.setRows(new ArrayList<>());
result.setTotal(0L);
return result;
}
@Override
public WmsProductSalesScriptVo regenerateScript(Long scriptId) {
// 获取原话术信息
WmsProductSalesScriptVo originalScript = iWmsProductSalesScriptService.queryById(scriptId);
if (originalScript == null) {
throw new RuntimeException("话术不存在");
}
// 重新生成话术
WmsSalesScriptGeneratorBo bo = new WmsSalesScriptGeneratorBo();
bo.setProductId(originalScript.getProductId());
bo.setScriptCount(1);
bo.setSaveToDatabase(false);
List<WmsProductSalesScriptVo> newScripts = generateScriptsForProduct(bo);
if (!newScripts.isEmpty()) {
return newScripts.get(0);
}
throw new RuntimeException("重新生成话术失败");
}
@Override
public List<Map<String, Object>> previewScripts(WmsSalesScriptGeneratorBo bo) {
bo.setSaveToDatabase(false);
List<WmsProductSalesScriptVo> scripts = generateScriptsForProduct(bo);
List<Map<String, Object>> previews = new ArrayList<>();
for (WmsProductSalesScriptVo script : scripts) {
Map<String, Object> preview = new HashMap<>();
preview.put("title", script.getScriptTitle());
preview.put("content", script.getScriptContent());
preview.put("featurePoint", script.getFeaturePoint());
previews.add(preview);
}
return previews;
}
@Override
public List<Map<String, Object>> getCustomerTypes() {
List<Map<String, Object>> customerTypes = new ArrayList<>();
for (String type : CUSTOMER_TYPES) {
Map<String, Object> customerType = new HashMap<>();
customerType.put("type", type);
customerType.put("description", getCustomerTypeDescription(type));
customerTypes.add(customerType);
}
return customerTypes;
}
@Override
public List<String> getFeatureKeywords() {
return new ArrayList<>(FEATURE_KEYWORDS);
}
@Override
public Map<String, Object> analyzeProduct(WmsSalesScriptGeneratorBo bo) {
Map<String, Object> analysis = new HashMap<>();
try {
WmsProductVo product = iWmsProductService.queryById(bo.getProductId());
if (product == null) {
throw new RuntimeException("产品不存在");
}
List<WmsProductBom> bomList = iWmsProductBomService.listByProductId(bo.getProductId());
// 分析产品特性
analysis.put("productInfo", product);
analysis.put("bomInfo", bomList);
analysis.put("suggestedCustomerTypes", suggestCustomerTypes(product, bomList));
analysis.put("suggestedFeatures", extractFeatures(product, bomList));
analysis.put("suggestedScriptCount", 5);
} catch (Exception e) {
log.error("分析产品失败", e);
analysis.put("error", e.getMessage());
}
return analysis;
}
/**
* 调用AI API
@@ -381,7 +201,7 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
String prompt = buildPrompt(product, bomList, bo);
Map<String, Object> requestBody = new HashMap<>();
requestBody.put("model", modelName);
requestBody.put("model", deepseekConfig.getModelName());
Map<String, String> systemMessage = new HashMap<>();
systemMessage.put("role", "system");
systemMessage.put("content", "你是一名专业的销售话术专家");
@@ -396,14 +216,14 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON);
headers.setBearerAuth(apiKey);
headers.setBearerAuth(deepseekConfig.getApiKey());
HttpEntity<Map<String, Object>> entity = new HttpEntity<>(requestBody, headers);
for (int i = 0; i < bo.getMaxRetries(); i++) {
try {
ResponseEntity<Map> response = restTemplate.postForEntity(
baseUrl + "/chat/completions", entity, Map.class);
deepseekConfig.getBaseUrl() + "/chat/completions", entity, Map.class);
if (response.getStatusCode() == HttpStatus.OK && response.getBody() != null) {
Map<String, Object> body = response.getBody();
@@ -421,7 +241,6 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
}
}
}
throw new RuntimeException("AI API调用失败已达到最大重试次数");
}
@@ -430,8 +249,10 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
*/
private String buildPrompt(WmsProductVo product, List<WmsProductBom> bomList, WmsSalesScriptGeneratorBo bo) {
StringBuilder prompt = new StringBuilder();
prompt.append("请根据以下产品信息和BOM清单生成").append(bo.getScriptCount()).append("条针对不同客户场景的销售话术。\n\n").append("不要给我加称呼\n");
prompt.append("请根据以下产品信息和BOM清单生成")
.append(bo.getScriptCount())
.append("条针对不同客户场景的销售话术。\n\n")
.append("不要给我加称呼\n");
// 产品信息
prompt.append("【产品信息】\n");
prompt.append("产品名称:").append(product.getProductName()).append("\n");
@@ -450,7 +271,6 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
if (StringUtils.isNotEmpty(product.getRemark())) {
prompt.append("备注:").append(product.getRemark()).append("\n");
}
// BOM信息
if (Boolean.TRUE.equals(bo.getIncludeBomInfo()) && bomList != null && !bomList.isEmpty()) {
prompt.append("\n【BOM清单】\n");
@@ -460,7 +280,6 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
.append(" ").append(bom.getUnit()).append("\n");
}
}
// 生成要求
prompt.append("\n【话术生成要求】\n");
prompt.append("1. 每条话术必须包含产品的主要特性和优势\n");
@@ -469,7 +288,6 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
prompt.append("4. 话术要自然、专业、有说服力\n");
prompt.append("5. 包含具体的应用场景和解决方案\n");
prompt.append("6. 突出产品的核心竞争力\n");
// 输出格式
prompt.append("\n【输出格式】\n");
prompt.append("请按以下格式输出:\n\n");
@@ -478,7 +296,6 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
prompt.append("标题:").append(product.getProductName()).append(" - 话术标题\n");
prompt.append("内容:[具体话术内容]\n\n");
}
return prompt.toString();
}
@@ -487,11 +304,9 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
*/
private List<Map<String, Object>> parseAiResponse(String response) {
List<Map<String, Object>> scripts = new ArrayList<>();
// 使用正则表达式解析响应
Pattern pattern = Pattern.compile("【话术(\\d+)】(.*?)\\n标题(.*?)\\n内容(.*?)(?=\\n【话术|\\Z)", Pattern.DOTALL);
Matcher matcher = pattern.matcher(response);
while (matcher.find()) {
Map<String, Object> script = new HashMap<>();
script.put("customerType", matcher.group(2).trim());
@@ -500,7 +315,6 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
script.put("featurePoint", extractFeaturePoints(matcher.group(4)));
scripts.add(script);
}
return scripts;
}
@@ -509,7 +323,6 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
*/
private String extractFeaturePoints(String content) {
List<String> features = new ArrayList<>();
// 提取技术参数
for (String pattern : TECH_PATTERNS) {
Pattern techPattern = Pattern.compile(pattern + "[:]\\s*([\\d.]+)");
@@ -518,7 +331,6 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
features.add("技术参数: " + matcher.group(1));
}
}
// 提取材料优势
for (String keyword : FEATURE_KEYWORDS) {
if (content.contains(keyword)) {
@@ -528,50 +340,4 @@ public class WmsSalesScriptGeneratorServiceImpl implements IWmsSalesScriptGenera
return features.isEmpty() ? "产品特性突出" : String.join("; ", features);
}
/**
* 获取客户类型描述
*/
private String getCustomerTypeDescription(String type) {
Map<String, String> descriptions = new HashMap<>();
descriptions.put("技术型客户", "突出技术参数和性能优势");
descriptions.put("价格敏感型客户", "强调性价比和成本效益");
descriptions.put("质量优先型客户", "重点介绍品质保证和可靠性");
descriptions.put("批量采购客户", "突出批量优惠和供应能力");
descriptions.put("定制化需求客户", "强调定制服务和个性化解决方案");
return descriptions.getOrDefault(type, "");
}
/**
* 建议客户类型
*/
private List<String> suggestCustomerTypes(WmsProductVo product, List<WmsProductBom> bomList) {
List<String> suggestions = new ArrayList<>();
suggestions.add("技术型客户");
suggestions.add("质量优先型客户");
if (bomList != null && bomList.size() > 3) {
suggestions.add("批量采购客户");
}
return suggestions;
}
/**
* 提取特性
*/
private List<String> extractFeatures(WmsProductVo product, List<WmsProductBom> bomList) {
List<String> features = new ArrayList<>();
if (product.getThickness() != null || product.getWidth() != null || product.getInnerDiameter() != null) {
features.add("精密制造");
}
if (bomList != null && !bomList.isEmpty()) {
features.add("优质材料");
}
return features;
}
}

View File

@@ -1,38 +0,0 @@
# 图片识别配置
image:
recognition:
# AI API配置
api-url: https://api.siliconflow.cn/v1/chat/completions
model-name: Qwen/Qwen2.5-VL-32B-Instruct
api-key: sk-sbmuklhrcxqlsucufqebiibauflxqfdafqjxaedtwirurtrc
max-retries: 3
temperature: 0.0
max-tokens: 4096
# 图片处理配置
max-image-dimension: 512
image-quality: 60
# 识别配置
default-recognition-type: bom
enable-voting: true
voting-rounds: 3
# 支持的图片格式
supported-formats:
- jpg
- jpeg
- png
- bmp
- gif
# 超时配置
connect-timeout: 30000
read-timeout: 60000
# 缓存配置
enable-cache: true
cache-ttl: 3600
# 日志配置
enable-debug-log: false

View File

@@ -1,56 +0,0 @@
# 销售话术生成器配置
sales:
script:
ai:
# DeepSeek API配置
api-key: sk-5eb55d2fb2cc4fe58a0150919a1f0d70
base-url: https://api.deepseek.com/v1
model-name: deepseek-chat
max-retries: 3
temperature: 1.0
# 生成配置
generation:
# 默认话术数量
default-script-count: 5
# 批量处理大小
batch-size: 5
# 批次间延迟(毫秒)
delay-between-batches: 2000
# 客户类型配置
customer-types:
- 技术型客户
- 价格敏感型客户
- 质量优先型客户
- 批量采购客户
- 定制化需求客户
# 产品特性关键词
feature-keywords:
- 优质
- 高精度
- 耐用
- 稳定
- 可靠
- 先进
- 高效
- 节能
- 环保
- 安全
- 便捷
- 智能
# 技术参数模式
tech-patterns:
- 厚度
- 宽度
- 内径
- 长度
- 重量
- 密度
# 日志配置
logging:
level:
com.klp.service.impl.WmsSalesScriptGeneratorServiceImpl: DEBUG