提交修改
This commit is contained in:
parent
d98df1b43b
commit
206f836bc3
@ -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) {
|
||||
|
||||
@ -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) {
|
||||
|
||||
@ -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服务启动完成!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user