1
This commit is contained in:
+32
-5
@@ -214,10 +214,13 @@ public class OrderProfitAnalysisServiceImpl implements IOrderProfitAnalysisServi
|
|||||||
|
|
||||||
boolean pushed = false;
|
boolean pushed = false;
|
||||||
String pushError = null;
|
String pushError = null;
|
||||||
|
int chunkCount = 0;
|
||||||
String toUser = resolveTouser();
|
String toUser = resolveTouser();
|
||||||
if (push) {
|
if (push) {
|
||||||
try {
|
try {
|
||||||
pushed = pushReport(current.titlePrefix, report, toUser);
|
List<String> chunks = buildPushChunks(current.titlePrefix, report);
|
||||||
|
chunkCount = chunks.size();
|
||||||
|
pushed = pushChunks(chunks, toUser);
|
||||||
if (!pushed) {
|
if (!pushed) {
|
||||||
pushError = StringUtils.isEmpty(toUser)
|
pushError = StringUtils.isEmpty(toUser)
|
||||||
? "未配置接收人(touser / goofish-notify-touser)"
|
? "未配置接收人(touser / goofish-notify-touser)"
|
||||||
@@ -240,6 +243,7 @@ public class OrderProfitAnalysisServiceImpl implements IOrderProfitAnalysisServi
|
|||||||
result.put("pushed", pushed);
|
result.put("pushed", pushed);
|
||||||
result.put("pushError", pushError);
|
result.put("pushError", pushError);
|
||||||
result.put("toUser", toUser);
|
result.put("toUser", toUser);
|
||||||
|
result.put("chunkCount", chunkCount);
|
||||||
cacheLatest(normalizePeriod(periodType), result);
|
cacheLatest(normalizePeriod(periodType), result);
|
||||||
if (push) {
|
if (push) {
|
||||||
appendSendLog(result, stats);
|
appendSendLog(result, stats);
|
||||||
@@ -423,7 +427,13 @@ public class OrderProfitAnalysisServiceImpl implements IOrderProfitAnalysisServi
|
|||||||
return data.getString("reply");
|
return data.getString("reply");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean pushReport(String title, String report, String toUser) {
|
private List<String> buildPushChunks(String title, String report) {
|
||||||
|
String body = stripThinkTags(report);
|
||||||
|
String full = (title == null ? "" : title) + "\n" + (body == null ? "" : body);
|
||||||
|
return labelChunks(splitUtf8Chunks(full, WECOM_CHUNK_BYTES));
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean pushChunks(List<String> chunks, String toUser) {
|
||||||
if (phoneForwardActivePush == null) {
|
if (phoneForwardActivePush == null) {
|
||||||
log.warn("利润分析推送跳过:IPhoneForwardActivePush 不可用");
|
log.warn("利润分析推送跳过:IPhoneForwardActivePush 不可用");
|
||||||
return false;
|
return false;
|
||||||
@@ -432,12 +442,28 @@ public class OrderProfitAnalysisServiceImpl implements IOrderProfitAnalysisServi
|
|||||||
log.warn("利润分析推送跳过:未配置 jarvis.order-profit-analysis.touser 或 jarvis.wecom.goofish-notify-touser");
|
log.warn("利润分析推送跳过:未配置 jarvis.order-profit-analysis.touser 或 jarvis.wecom.goofish-notify-touser");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String body = stripThinkTags(report);
|
if (chunks == null || chunks.isEmpty()) {
|
||||||
String full = (title == null ? "" : title) + "\n" + (body == null ? "" : body);
|
return false;
|
||||||
List<String> chunks = splitUtf8Chunks(full, WECOM_CHUNK_BYTES);
|
}
|
||||||
|
log.info("利润分析推送拆成 {} 条 toUser={}", chunks.size(), toUser);
|
||||||
return phoneForwardActivePush.schedulePushChunks(toUser, null, chunks);
|
return phoneForwardActivePush.schedulePushChunks(toUser, null, chunks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<String> labelChunks(List<String> chunks) {
|
||||||
|
if (chunks == null || chunks.isEmpty()) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
if (chunks.size() == 1) {
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
int n = chunks.size();
|
||||||
|
List<String> out = new ArrayList<>(n);
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
out.add("(" + (i + 1) + "/" + n + ")\n" + chunks.get(i));
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 去掉模型思考标签及其内容,避免推到企微。
|
* 去掉模型思考标签及其内容,避免推到企微。
|
||||||
* 兼容成对 {@code <think>...</think>},以及残留的开闭标签。
|
* 兼容成对 {@code <think>...</think>},以及残留的开闭标签。
|
||||||
@@ -490,6 +516,7 @@ public class OrderProfitAnalysisServiceImpl implements IOrderProfitAnalysisServi
|
|||||||
}
|
}
|
||||||
String report = result.get("report") == null ? "" : String.valueOf(result.get("report"));
|
String report = result.get("report") == null ? "" : String.valueOf(result.get("report"));
|
||||||
row.put("report", report);
|
row.put("report", report);
|
||||||
|
row.put("chunkCount", result.get("chunkCount"));
|
||||||
redisTemplate.opsForList().leftPush(REDIS_SEND_LOG, JSON.toJSONString(row));
|
redisTemplate.opsForList().leftPush(REDIS_SEND_LOG, JSON.toJSONString(row));
|
||||||
redisTemplate.opsForList().trim(REDIS_SEND_LOG, 0, SEND_LOG_MAX - 1);
|
redisTemplate.opsForList().trim(REDIS_SEND_LOG, 0, SEND_LOG_MAX - 1);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user