package com.jwipc.finance.controller.rest;


import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson2.JSON;
import com.jwipc.dto.ExportDataDTO;
import com.jwipc.finance.logic.AccountStatementApproveLogic;
import com.jwipc.finance.logic.AccountStatementDetailLogic;
import com.jwipc.finance.logic.CostAccountStatementApproveLogic;
import com.jwipc.finance.logic.CostAccountStatementDetailLogic;
import com.jwipc.finance.model.query.AccountStatementDetailQuery;
import com.jwipc.finance.model.query.AsApproveQuery;
import com.jwipc.finance.model.query.CreateInvoicedApplyQuery;
import com.jwipc.page.PageView;
import com.jwipc.security.LoginUtil;
import com.jwipc.util.EasyExcelUtils;
import lombok.RequiredArgsConstructor;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import static com.jwipc.finance.constant.ModuleConst.MODULE_ROOT;

/**
 * <p>
 *     对账模块-对账单 前端控制器
 * </p>
 *
 * @author JT
 * @since 2020-07-31
 */
@RestController
@RequestMapping(MODULE_ROOT + "/cost/account/statement/detail/rest")
@RequiredArgsConstructor
public class CostAccountStatementDetailRestController {
    private final CostAccountStatementDetailLogic costAccountStatementDetailLogic;
    private final CostAccountStatementApproveLogic costAccountStatementApproveLogic;

    /**
     * 根据对账单ID获取对账单明细数据
     *
     * @param asId 对账单ID
     * @return 结果
     */
    @PostMapping("/find/by/statement/id")
    public ResponseEntity findByStatementId(Long asId){
        return ResponseEntity.ok(costAccountStatementDetailLogic.findByStatementIdPage(asId));
    }

    /**
     * 获取对账单审批确认备注
     *
     * @param query 查询参数
     * @return 结果
     */
    @PostMapping("/find/as/approve/log")
    public PageView findStatementApproveLog(AsApproveQuery query){
        return costAccountStatementApproveLogic.findByPage(query);
    }
}
