package com.prolog.cs.biz.outbound.controller.print;


import com.prolog.cs.biz.outbound.model.vo.BillDPrePositionVO;
import com.prolog.cs.biz.outbound.service.DoPringService;
import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.log.aop.annotation.UserLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Api(tags = "出库订单打印")
@RestController
@RequestMapping("/do/print")
public class DoPringController {

    @Autowired
    private DoPringService service;


/*    @UserLog
    @ApiOperation(value = "打印出库清单")
    @GetMapping("/out-detailed-print")
    @ApiImplicitParams({
    @ApiImplicitParam(name = "warehouseId", value = "仓", required = true),
    @ApiImplicitParam(name = "cargoOwnerId", value = "货主", required = true),
    @ApiImplicitParam(name = "billId", value = "出库单ID", required = true),
    @ApiImplicitParam(name = "printBillCode", value = "打印模板code", required = true)
    })
    public RestMessage<String> outDetailedPrint(String warehouseId, String consignorId, String billId,String printBillCode) {
        return RestMessage.newInstance(true, "outDetailedPrintSuccess", service.outDetailedPrint(warehouseId, consignorId, billId, printBillCode));
    }*/

    @UserLog
    @ApiOperation(value = "打印出库清单")
    @GetMapping("/out-detailed-print")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "warehouseId", value = "仓", required = true),
            @ApiImplicitParam(name = "cargoOwnerId", value = "货主", required = true),
            @ApiImplicitParam(name = "billId", value = "出库单ID", required = true),
            @ApiImplicitParam(name = "printBillCode", value = "打印模板code", required = true)
    })
    public RestMessage<Object> outDetailedPrint(String warehouseId, String consignorId, String billId,String printBillCode) {
        return RestMessage.newInstance(true, "outDetailedPrintSuccess", service.outDetailedPrint(warehouseId, consignorId, billId, printBillCode));
    }

    @UserLog
    @ApiOperation(value = "下载出库清单")
    @GetMapping("/out-detailed-download")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "warehouseId", value = "仓", required = true),
            @ApiImplicitParam(name = "cargoOwnerId", value = "货主", required = true),
            @ApiImplicitParam(name = "billId", value = "出库单ID", required = true),
            @ApiImplicitParam(name = "printBillCode", value = "打印模板code", required = true)
    })
    public RestMessage<Object> outDetailedDownload(String warehouseId, String consignorId, String billId, String printBillCode, HttpServletResponse response, HttpServletRequest request) {
        service.outDetailedDownload(warehouseId, consignorId, billId, printBillCode,response,request);
        return RestMessage.newInstance(true, "导出成功");
    }

    @UserLog
    @ApiOperation(value = "下载出库清单-无用户权限")
    @GetMapping("/out-detailed-download-extends")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型", required = true),
            @ApiImplicitParam(name = "warehouseId", value = "仓", required = true),
            @ApiImplicitParam(name = "cargoOwnerId", value = "货主", required = true),
            @ApiImplicitParam(name = "billId", value = "出库单ID", required = true),
            @ApiImplicitParam(name = "printBillCode", value = "打印模板code", required = true)
    })
    public RestMessage<Object> outDetailedDownload(String type, String warehouseId, String consignorId, String billId, String printBillCode, HttpServletResponse response, HttpServletRequest request) {
        String url = service.outDetailedDownloadExtends(type, warehouseId, consignorId, billId, printBillCode, response, request);
        return RestMessage.newInstance(true, "导出成功", url);
    }



    @UserLog
    @ApiOperation(value = "打印发票")
    @GetMapping("/out-receipt-print")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "warehouseId", value = "仓", required = true),
            @ApiImplicitParam(name = "cargoOwnerId", value = "货主", required = true),
            @ApiImplicitParam(name = "billId", value = "出库单ID", required = true)
    })
    public RestMessage<String> receiptPrint(String warehouseId, String cargoOwnerId, String billId) {
        service.receiptPrint(warehouseId, cargoOwnerId, billId);
        return RestMessage.success("打印成功", null);
    }

    @UserLog
    @ApiOperation(value = "打印出库清单-空模板")
    @GetMapping("/out-detailed-print-null")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "warehouseId", value = "仓", required = true),
            @ApiImplicitParam(name = "cargoOwnerId", value = "货主", required = true),
            @ApiImplicitParam(name = "billId", value = "出库单ID", required = true),
            @ApiImplicitParam(name = "printBillCode", value = "打印模板code", required = true)
    })
    public RestMessage<Object> printNull(String warehouseId, String consignorId, String billId,String printBillCode) {
        return RestMessage.newInstance(true, "outDetailedPrintSuccess", service.printNull(warehouseId, consignorId, billId, printBillCode));
    }

}
