提交修改

This commit is contained in:
quyixiao 2026-06-03 23:59:07 +08:00
parent d98df1b43b
commit 206f836bc3
4 changed files with 64 additions and 8 deletions

View File

@ -11,6 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 购物小票识别控制器
* 提供购物小票OCR识别功能基于百度AI票据识别服务
*/
@RestController
@RequestMapping("/shopping/receipt")
@NotIntercept
@ -19,6 +23,11 @@ public class ShoppingReceiptController extends BaseController {
@Autowired
private BShoppingReceiptHandle bShoppingReceiptHandle;
/**
* 购物小票识别接口
* @param request 识别请求参数图片URL或Base64
* @return 识别结果包含商品名称价格日期等信息
*/
@RequestMapping("/recognize")
@CacheResult
public R recognize(BShoppingReceiptRequest request) {

View File

@ -11,6 +11,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 出租车票识别控制器
* 提供出租车发票OCR识别功能基于百度AI票据识别服务
*/
@RestController
@RequestMapping("/taxi/receipt")
@NotIntercept
@ -19,6 +23,11 @@ public class TaxiReceiptController extends BaseController {
@Autowired
private BTaxiReceiptHandle bTaxiReceiptHandle;
/**
* 出租车票识别接口
* @param request 识别请求参数图片URL或Base64
* @return 识别结果包含发票号码日期金额上车/下车时间等信息
*/
@RequestMapping("/recognize")
@CacheResult
public R recognize(BTaxiReceiptRequest request) {

View File

@ -2,19 +2,26 @@ package com.heyu.api.job.api;
//import com.tuya.connector.spring.annotations.ConnectorScan;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
/**
* API Job服务启动类
* 负责定时任务和消息队列监听处理
*/
@Slf4j
@SpringBootApplication(scanBasePackages = {"com.heyu.api.*"})
@EnableAspectJAutoProxy
@EnableDiscoveryClient
public class ApiJobApiApplication {
public static void main(String[] args) {
log.info("ApiJob服务开始启动...");
SpringApplication.run(ApiJobApiApplication.class, args);
log.info("ApiJob服务启动完成!");
}
}

View File

@ -17,8 +17,13 @@ import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import java.io.IOException;
/**
* 账户日志队列监听器
* 消费accountLogNameQueue队列处理账户变动日志记录
*/
@Component
@Slf4j
public class LogQueueSimpleRabbitListener {
@ -26,29 +31,55 @@ public class LogQueueSimpleRabbitListener {
@Value("${eb.config.rabbitQueue.accountLogName}")
private String accountLogNameQueue;
@Autowired
private CalcaAccountLogService calcaAccountLogService;
/**
* 监听器初始化日志
*/
@PostConstruct
public void init() {
log.info("LogQueueSimpleRabbitListener初始化完成监听队列: {}", accountLogNameQueue);
}
/**
* 消费账户日志消息
* @param message 消息内容CalcaAccountLogDTO JSON格式
* @param delivertTag RabbitMQ投递标签
* @param channel RabbitMQ通道
*/
@RabbitHandler
@RabbitListener(queues = "#{accountLogNameQueue.name}", containerFactory = "accountLogNameQueueSimpleRabbitListenerContainerFactory")
public void consumeMessage(@Payload String message, @Header(AmqpHeaders.DELIVERY_TAG) long delivertTag, Channel channel) {
String userName = "";
long startTime = System.currentTimeMillis();
String traceId = "";
try {
log.info("accountLogNameQueue请求参数是message :{}", message);
log.info("[账户日志队列] 接收到消息, message: {}", message);
CalcaAccountLogDTO calcaAccountLogDTO = JSON.parseObject(message, CalcaAccountLogDTO.class);
String newTraceId = calcaAccountLogDTO.getTraceId() + "_" + OrderUtil.getUserPoolOrder("on");
traceId = calcaAccountLogDTO.getTraceId();
// 生成新的traceId并放入MDC
String newTraceId = traceId + "_" + OrderUtil.getUserPoolOrder("on");
MDC.put(ApiConstants.TRACE_ID, newTraceId);
// 插入账户日志
calcaAccountLogService.insertCalcaAccountLog(calcaAccountLogDTO.getCalcaAccountLogEntity());
long costTime = System.currentTimeMillis() - startTime;
log.info("[账户日志队列] 消息处理成功, traceId: {}, costTime: {}ms", traceId, costTime);
} catch (Exception e) {
log.error("accountLogNameQueue handle", e);
long costTime = System.currentTimeMillis() - startTime;
log.error("[账户日志队列] 消息处理失败, traceId: {}, costTime: {}ms", traceId, costTime, e);
} finally {
try {
log.info("accountLogNameQueue消息{},消息确认完成", message + ",username : " + userName);
channel.basicAck(delivertTag, true);
log.debug("[账户日志队列] 消息ACK确认完成, traceId: {}", traceId);
} catch (IOException e) {
log.error("accountLogNameQueue消息确认异常", e);
log.error("[账户日志队列] 消息ACK确认异常, traceId: {}", traceId, e);
} finally {
MDC.remove(ApiConstants.TRACE_ID);
}
}
}