调用大模型自动解析订单信息

This commit is contained in:
2026-05-14 22:03:03 +08:00
parent 97b9048ee7
commit c539363eaf
3 changed files with 162 additions and 0 deletions

View File

@@ -4,7 +4,11 @@ import com.rj.entity.LbPurchaseApply;
import com.rj.service.ILbPurchaseApplyService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
@@ -21,6 +25,30 @@ public class LbPurchaseApplyController {
@Autowired
private ILbPurchaseApplyService lbPurchaseApplyService;
@Data
@Schema(description = "大模型解析订货信息请求体")
public static class ParseOrderInfoRequest {
@Schema(description = "订货信息原文", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "订货信息不能为空")
private String orderInfo;
@Schema(description = "当前登录人租户ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotBlank(message = "tenantId不能为空")
private String tenantId;
}
@PostMapping("/parseFromOrderInfo")
@Operation(summary = "大模型解析订货信息为进货申请实体", description = "根据自然语言订货信息调用大模型抽取字段,返回 LbPurchaseApply不落库")
public ResponseEntity<Map<String, Object>> parseFromOrderInfo(
@Parameter(description = "订货信息与租户ID", required = true) @Valid @RequestBody ParseOrderInfoRequest body) {
Map<String, Object> result = lbPurchaseApplyService.parseFromOrderInfoByLlm(body.getOrderInfo(), body.getTenantId());
Boolean success = (Boolean) result.get("success");
if (success != null && success) {
return ResponseEntity.ok(result);
}
return ResponseEntity.badRequest().body(result);
}
@PostMapping("/add")
@Operation(summary = "新增")
public ResponseEntity<Map<String, Object>> add(