从抢货接口读取货物包

This commit is contained in:
2026-05-27 08:13:30 +08:00
parent 947bb21c8b
commit 0258079d49
12 changed files with 281 additions and 19 deletions

View File

@@ -52,6 +52,8 @@ public class LbDeductionAmountServiceImpl
/** 优先匹配「申请…抵扣…金额数字」,避免误用「已提现金额」。 */
private static final Pattern DIKOU_AMT_PATTERN =
Pattern.compile("申请[^\\n]*?抵扣[^\\n]*?金额\\s*(\\d+(?:\\.\\d+)?)", Pattern.CASE_INSENSITIVE);
private static final Pattern TIXIAN_AMT_PATTERN =
Pattern.compile("已提现金额\\s*(\\d+(?:\\.\\d+)?)", Pattern.CASE_INSENSITIVE);
private static final String PARSE_SYSTEM_PROMPT = """
你是信息抽取助手。用户会提供「抵扣金记录」自然语言,常见为多行固定格式,例如:
@@ -64,11 +66,12 @@ public class LbDeductionAmountServiceImpl
1. 首行或文中「M月d日」如 5月21日仅作业务日期参考不要写入 JSON服务端会从原文补 createTime
2. 「姓名 + 空格 + 11位手机号」同一行userName 为姓名userPhone 为手机号。
3. dikouAmt 取含「申请」且含「抵扣」且含「金额」那一行中的数字(如上例 2678不要用「已提现金额」作为 dikouAmt。
4. FXJ、SJF 等字母为业务代号,忽略即可
5. 金额只输出数字,不要带「元」等单位
4. tixianAmt 取含「已提现金额」那一行中的数字(如上例 2678若无该行可省略
5. FXJ、SJF 等字母为业务代号,忽略即可
6. 金额只输出数字,不要带「元」等单位。
请只输出一个 JSON 对象,不要 markdown 代码块,不要解释性文字。
字段名必须完全一致userName、userPhone、dikouAmt。
字段名必须完全一致userName、userPhone、dikouAmt、tixianAmt
createTime 若填写,格式 yyyy-MM-dd HH:mm:ss服务端仅将非当前年的年份校正为系统当前年月日不变。
不要输出 id、tenantId、originalText、updateTime。
""";
@@ -132,10 +135,11 @@ public class LbDeductionAmountServiceImpl
enrichFromDeductionText(entity, trimmedText);
log.debug(
"parseFromTextByLlmAndSaveuserName={} userPhone={} dikouAmt={} createTime={}",
"parseFromTextByLlmAndSaveuserName={} userPhone={} dikouAmt={} tixianAmt={} createTime={}",
entity.getUserName(),
entity.getUserPhone(),
entity.getDikouAmt(),
entity.getTixianAmt(),
entity.getCreateTime());
return add(entity);
@@ -185,6 +189,7 @@ public class LbDeductionAmountServiceImpl
fillCreateTimeFromText(entity, text);
// 含「申请…抵扣…金额」时以该行为准,避免模型误用「已提现金额」
fillDikouAmtFromText(entity, text);
fillTixianAmtFromText(entity, text);
if (entity.getUserPhone() == null || entity.getUserPhone().isBlank()) {
fillPhoneFromText(entity, text);
}
@@ -221,6 +226,13 @@ public class LbDeductionAmountServiceImpl
}
}
private void fillTixianAmtFromText(LbDeductionAmount entity, String text) {
Matcher matcher = TIXIAN_AMT_PATTERN.matcher(text);
if (matcher.find()) {
entity.setTixianAmt(new BigDecimal(matcher.group(1)));
}
}
private void fillPhoneFromText(LbDeductionAmount entity, String text) {
Matcher matcher = MOBILE_PHONE_PATTERN.matcher(text);
if (matcher.find()) {
@@ -283,6 +295,9 @@ public class LbDeductionAmountServiceImpl
if (entity.getDikouAmt() == null) {
entity.setDikouAmt(BigDecimal.ZERO);
}
if (entity.getTixianAmt() == null) {
entity.setTixianAmt(BigDecimal.ZERO);
}
if (entity.getId() == null || entity.getId().trim().isEmpty()) {
entity.setId(UUID.randomUUID().toString());

View File

@@ -262,7 +262,7 @@ public class LbGoodsServiceImpl extends ServiceImpl<LbGoodsMapper, LbGoods> impl
if (opt.isEmpty()) {
if (page == 1) {
result.put("success", false);
result.put("message", "未拉取到货品(请检查 hxr.admin.goods-api-token、网络或第三方返回");
result.put("message", "未拉取到货品(请检查 hxr.admin.goods-api-token、goods-api-app-str 或网络)");
result.put("synced", 0);
return result;
}