package cn.superdesk.uniorder.controller.invoice.supplier;

import cn.hutool.json.JSONUtil;
import cn.superdesk.uniorder.common.rest.response.R;
import cn.superdesk.uniorder.controller.base.BaseController;
import cn.superdesk.uniorder.dto.param.invoice.supplier.InvoiceApplySupplierPageVoListQueryCriteria;
import cn.superdesk.uniorder.dubbo.consumer.accounting.supplier.AccountingUnifiedSupplierDubboConsumerService;
import cn.superdesk.uniorder.dubbo.consumer.invoice.supplier.InvoiceApplySupplierDubboConsumerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;


@Api(value = "[开票发票]-供应商结算-开票申请(发票申请管理)-Excel导出", tags = {"[开票发票]-供应商结算-开票申请(发票申请管理)-Excel导出"})
@Slf4j
@RestController
@RequestMapping("/invoice/apply/supplier/export")
public class InvoiceApplySupplierExportExcelController extends BaseController {


	@Autowired
	private InvoiceApplySupplierDubboConsumerService      invoiceApplySupplierDubboConsumerService;
	@Autowired
	private AccountingUnifiedSupplierDubboConsumerService accountingUnifiedSupplierDubboConsumerService;

	@ApiOperation(value = "供应商结算-发票申请管理-opt 导出报表 TODO mode 有逻辑 侨城汇 - 供应商结算2.0 已适配\n" +
			"\t|---- 1. 搜索框 条件 结算集 op 导出报表\n" +
			"\t|---- 2. 搜索框 条件 结算集 后 界面上 勾选 要以 开票申请编号 分 sheet 分合并前 合并后 op 勾选导出报表\n" +
			"\t|---- 3. 搜索框 条件 结算集 后 界面上 勾选 要以 开票申请编号 分 sheet 财务专用 op 导出开票数据")
	@RequestMapping(value = "/exportExcelInvoiceApplySupplierFocusScoreDimGoods", method = RequestMethod.POST)
	public R<String> exportExcelInvoiceApplySupplierFocusScoreDimGoods(@RequestBody InvoiceApplySupplierPageVoListQueryCriteria queryCriteria) throws IOException {

		log.info("{}", JSONUtil.toJsonStr(queryCriteria));

		return new R<>(invoiceApplySupplierDubboConsumerService.exportExcelInvoiceApplySupplierFocusScoreDimGoods(getToken(), queryCriteria));
	}
}
