1
This commit is contained in:
+111
@@ -0,0 +1,111 @@
|
||||
package com.ruoyi.web.controller.jarvis;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.jarvis.domain.dto.OrderProfitAnalyzeRequest;
|
||||
import com.ruoyi.jarvis.service.IOrderProfitAnalysisService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 慢单订单/利润 AI 分析
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jarvis/order-profit-analysis")
|
||||
public class OrderProfitAnalysisController extends BaseController {
|
||||
|
||||
private final IOrderProfitAnalysisService orderProfitAnalysisService;
|
||||
|
||||
public OrderProfitAnalysisController(IOrderProfitAnalysisService orderProfitAnalysisService) {
|
||||
this.orderProfitAnalysisService = orderProfitAnalysisService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览统计 JSON(本期 / 上期 / 对比),不调用大模型。
|
||||
*/
|
||||
@GetMapping("/stats")
|
||||
public AjaxResult stats(@RequestParam(value = "periodType", required = false) String periodType,
|
||||
@RequestParam(value = "date", required = false) String date) {
|
||||
try {
|
||||
return AjaxResult.success(orderProfitAnalysisService.buildStats(periodType, date));
|
||||
} catch (Exception e) {
|
||||
logger.error("预览利润统计失败", e);
|
||||
return AjaxResult.error("预览失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 套固定提示词调用已配置大模型;push=true 时推企微。
|
||||
*/
|
||||
@Log(title = "慢单利润AI分析", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/analyze")
|
||||
public AjaxResult analyze(@RequestBody(required = false) OrderProfitAnalyzeRequest request) {
|
||||
try {
|
||||
if (request == null) {
|
||||
request = new OrderProfitAnalyzeRequest();
|
||||
}
|
||||
boolean push = Boolean.TRUE.equals(request.getPush());
|
||||
String trigger = request.getTrigger();
|
||||
Map<String, Object> data = orderProfitAnalysisService.analyze(
|
||||
request.getPeriodType(), request.getDate(), push, request.getProfileId(), trigger);
|
||||
return AjaxResult.success(data);
|
||||
} catch (Exception e) {
|
||||
logger.error("利润 AI 分析失败", e);
|
||||
return AjaxResult.error("分析失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试推送:按所选周期分析并立即推企微,记入发送记录(trigger=test)。
|
||||
*/
|
||||
@Log(title = "慢单利润AI分析测试推送", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/test")
|
||||
public AjaxResult test(@RequestBody(required = false) OrderProfitAnalyzeRequest request) {
|
||||
try {
|
||||
if (request == null) {
|
||||
request = new OrderProfitAnalyzeRequest();
|
||||
}
|
||||
Map<String, Object> data = orderProfitAnalysisService.analyze(
|
||||
request.getPeriodType(), request.getDate(), true, request.getProfileId(), "test");
|
||||
return AjaxResult.success(data);
|
||||
} catch (Exception e) {
|
||||
logger.error("利润分析测试推送失败", e);
|
||||
return AjaxResult.error("测试失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送记录(新的在前)。
|
||||
*/
|
||||
@GetMapping("/send-logs")
|
||||
public AjaxResult sendLogs(@RequestParam(value = "limit", required = false) Integer limit) {
|
||||
try {
|
||||
int n = limit == null ? 30 : limit;
|
||||
return AjaxResult.success(orderProfitAnalysisService.listSendLogs(n));
|
||||
} catch (Exception e) {
|
||||
logger.error("读取利润分析发送记录失败", e);
|
||||
return AjaxResult.error("读取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 最近一次分析结果(按周期)。
|
||||
*/
|
||||
@GetMapping("/latest")
|
||||
public AjaxResult latest(@RequestParam(value = "periodType", required = false) String periodType) {
|
||||
try {
|
||||
return AjaxResult.success(orderProfitAnalysisService.latest(periodType));
|
||||
} catch (Exception e) {
|
||||
logger.error("读取最近利润分析失败", e);
|
||||
return AjaxResult.error("读取失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,6 +222,14 @@ jarvis:
|
||||
# 获取评论接口服务地址(后端转发,避免前端跨域)
|
||||
fetch-comments:
|
||||
base-url: http://192.168.8.60:5008
|
||||
# 慢单利润/订单 AI 分析:聚合成 JSON → 固定提示词 → 已激活大模型 → 企微推送
|
||||
order-profit-analysis:
|
||||
enabled: true
|
||||
# 接收人 UserID,多个逗号或 |;留空则回退 goofish-notify-touser
|
||||
touser: ""
|
||||
daily-cron: "0 0 21 * * ?"
|
||||
weekly-cron: "0 20 8 ? * MON"
|
||||
monthly-cron: "0 30 8 1 * ?"
|
||||
# 企微经 wxSend 调用本接口时校验(须与 wxSend 配置一致)
|
||||
wecom:
|
||||
inbound-secret: jarvis_wecom_bridge_change_me
|
||||
|
||||
@@ -219,6 +219,12 @@ jarvis:
|
||||
# 获取评论接口服务地址(后端转发)
|
||||
fetch-comments:
|
||||
base-url: http://192.168.8.60:5008
|
||||
order-profit-analysis:
|
||||
enabled: true
|
||||
touser: ""
|
||||
daily-cron: "0 0 23 * * ?"
|
||||
weekly-cron: "0 20 8 ? * MON"
|
||||
monthly-cron: "0 30 8 1 * ?"
|
||||
wecom:
|
||||
inbound-secret: jarvis_wecom_bridge_change_me
|
||||
wxsend-base-url: https://wxts.van333.cn
|
||||
|
||||
Reference in New Issue
Block a user