package com.heyu.api.controller.car;


import com.aliyun.ocr20191230.models.RecognizeTaxiInvoiceResponse;
import com.aliyun.ocr20191230.models.RecognizeTaxiInvoiceResponseBody;
import com.heyu.api.alibaba.handle.common.text.ARecognizeTaxiInvoiceHandle;
import com.heyu.api.alibaba.request.common.text.ARecognizeTaxiInvoiceRequest;
import com.heyu.api.baidu.handle.financial.BTaxiReceiptHandle;
import com.heyu.api.controller.BaseController;
import com.heyu.api.data.annotation.NotIntercept;
import com.heyu.api.data.utils.ApiR;
import com.heyu.api.data.utils.R;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/***
 * https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeTaxiInvoice?tab=DEMO&lang=JAVA
 *
 *出租车发票识别 RecognizeTaxiInvoice
 *出租车发票识别能力可以准确识别出全国各大城市出租车发票在图像中的位置，支持出租车发票结构化识别，输出发票号码、代码、车号、日期、时间、金额，共 6 个关键字段信息。
 *
 *
 *
 * https://console.bce.baidu.com/support/?_=1740575657628&timestamp=1740577722254#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E8%B4%A2%E5%8A%A1%E7%A5%A8%E6%8D%AEOCR&api=rest%2F2.0%2Focr%2Fv1%2Ftaxi_receipt&method=post
 *
 */
@Slf4j
@RestController
@RequestMapping("/taxi/invoice")
@NotIntercept
public class RecognizeTaxiInvoiceController extends BaseController {


    @Autowired
    private ARecognizeTaxiInvoiceHandle arRecognizeTaxiInvoiceHandle;

    @Autowired
    private BTaxiReceiptHandle bTaxiReceiptHandle;


    @RequestMapping("/recognize")
    public R recognize(ARecognizeTaxiInvoiceRequest request) {
        ApiR<RecognizeTaxiInvoiceResponse> aR = arRecognizeTaxiInvoiceHandle.handle(request);

        if(aR.isSuccess() && isSuccessStatusCode(aR.getData().getStatusCode()) ){
            RecognizeTaxiInvoiceResponse recognizeTaxiInvoiceResponse = aR.getData();

            RecognizeTaxiInvoiceResponseBody responseBody  = recognizeTaxiInvoiceResponse.getBody();
            RecognizeTaxiInvoiceResponseBody.RecognizeTaxiInvoiceResponseBodyData responseBodyData = responseBody.getData();
            

        }

        return R.error();
    }

}
