package com.fjhx.sale.controller.sample;

import com.fjhx.account.entity.account.vo.AccountRunningWaterVo;
import com.fjhx.sale.entity.contract.dto.ContractDto;
import com.fjhx.sale.entity.purchase.po.EhsdPurchase;
import com.fjhx.sale.entity.sample.vo.SamplePdfInfoVo;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.sale.entity.sample.vo.SampleVo;
import com.fjhx.sale.entity.sample.dto.SampleSelectDto;
import com.fjhx.sale.entity.sample.dto.SampleDto;
import com.ruoyi.common.core.domain.BaseSelectDto;
import com.fjhx.sale.service.sample.SampleService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


/**
 * <p>
 * 样品单表 前端控制器
 * </p>
 *
 * @author
 * @since 2023-05-05
 */
@RestController
@RequestMapping("/sample")
public class SampleController {

    @Autowired
    private SampleService sampleService;

    /**
     * 样品单表分页
     */
    @PostMapping("/page")
    public Page<SampleVo> page(@RequestBody SampleSelectDto dto) {
        return sampleService.getPage(dto);
    }

    /**
     * 样品单表明细
     */
    @PostMapping("/detail")
    public SampleVo detail(@RequestBody BaseSelectDto dto) {
        return sampleService.detail(dto.getId());
    }

    /**
     * 样品单表新增
     */
    @PostMapping("/add")
    public void add(@RequestBody SampleDto sampleDto) {
        sampleService.add(sampleDto);
    }

    /**
     * 样品单表编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody SampleDto sampleDto) {
        sampleService.edit(sampleDto);
    }

    /**
     * 样品单表删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        sampleService.delete(dto.getId());
    }

    /**
     * 样品交接单添加
     */
    @PostMapping("/sampleHandover")
    public void sampleHandover(@RequestBody SampleDto dto) {
        sampleService.sampleHandover(dto);
    }


    /**
     * 样品单pdf
     */
    @PostMapping("/getSamplePdfInfo")
    public SamplePdfInfoVo getSamplePdfInfo(@RequestBody ContractDto dto) {
        return sampleService.getSamplePdfInfo(dto.getId());
    }

    /**
     * 获取合同相关的所有版本列表
     */
    @PostMapping("/getVersionList")
    public List<SampleVo> getVersionList(@RequestBody ContractDto dto) {
        return sampleService.getVersionList(dto.getId());
    }

    /**
     * 获取样品单id获取所有采购id
     */
    @PostMapping("/getPurchaseListBySampleId")
    public List<EhsdPurchase> getPurchaseListBySampleId(@RequestBody ContractDto dto) {
        return sampleService.getPurchaseListBySampleId(dto.getId());
    }

    /**
     * 根据样品单id获取合同的资金流水信息
     */
    @PostMapping("/getAccountRunningWaterBySampleId")
    public List<AccountRunningWaterVo> getAccountRunningWaterBySampleId(@RequestBody ContractDto dto) {
        return sampleService.getAccountRunningWaterBySampleId(dto.getId());
    }

}
