package com.jwipc.order.logic;

import com.jwipc.order.entity.BasicForcaseData;
import com.jwipc.order.entity.BasicForcaseQuota;
import com.jwipc.order.entity.BasicPlan;
import com.jwipc.order.model.po.BasicForecastPlanReleasePO;
import com.jwipc.order.model.query.BasicForeignQuotaQuery;
import com.jwipc.order.model.query.BasicPlanQuery;
import com.jwipc.page.PageView;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

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


/**
 * @Author: swq
 * @Date: 2024/3/12 15:01
 */
public interface BasicPlanLogic {

    /**
     * 查询列表数据
     * @param query
     * @return
     */
    PageView selectListByPage(BasicPlanQuery query);

    /**
     * 导入预测数据
     *
     * @param file 文件信息
     * @param startDate 开始时间
     * @param userId 操作人
     * @return 是否导入成功
     */
    boolean impAppraiseScore(MultipartFile file, String startDate, Long userId);

    /**
     * 查询预测计划信息
     * @param id 计划主键
     * @return
     */
    BasicPlan selectById(Long id);

    /**
     * 查询预测计划信息列表：过滤新建状态
     * @return
     */
    List<BasicPlan> selectPlanList();

    /**
     * 根据计划ID获取回复数据
     * @param planId 计划ID
     * @return 回复数据
     */
    List<BasicForcaseQuota> selectQuotaList(long planId);
    /**
     * 明细查看
     *
     * @param planId 计划ID
     * @return 明细查看数据
     */
    List<BasicForcaseData> selectDataList(long planId);

    ResponseEntity getDateData(long planId, Integer page, Integer limit, String q);
    /**
     * 供应商回复 查看汇总列表
     */
    ResponseEntity getSupplierReply(BasicForeignQuotaQuery query);
    /**
     * 保存供应商回复数据
     *
     * @param data 回复数据
     * @return 是否成功
     */
    ResponseEntity saveSupplierReply(String data, boolean isPurchaseReplace,String detail_remark,Long userId);
    /**
     * 根据详情ID获取计划详情时间数据
     *
     * @param detailId 详情ID
     * @return 详情时间数据
     */
    ResponseEntity byDetailIdGetPlanData(Long detailId, String supplierCode);

    /**
     * 回复导出
     *
     * @param planId   计划ID
     * @param status   第一次回复的状态
     * @param response 响应
     */
    void getReplyExport(HttpServletRequest request, HttpServletResponse response, Long planId,
                   Integer status, String isRiskMaterial, String supplier, String purchaseGroup);
    /**
     * 回复导入
     *
     * @param planId 计划ID
     */
     ResponseEntity replyImport(@RequestPart("file") MultipartFile file, Long planId);

    /**
     * 检查标准预测计划发布或回复情况
     *
     * @param planId 标准预测计划ID
     * @param checkType 检查类型 1:发布情况 2:回复情况
     * @return 结果
     */
     ResponseEntity checkPlanReleaseReplySituation(Long planId, Integer checkType);
    /**
     * 采购员确认 [确定OR拒绝]
     * @param isBatch 是否批量操作
     * @param detailId 明细ID
     * @param supplierCode 供应商编码
     * @param replyIds 回复IDS
     * @param refusalReason 拒绝原因
     * @return 是否确认成功
     */
     ResponseEntity getConfirmData(
            Boolean isBatch, Long detailId, String supplierCode, String replyIds, String refusalReason, String confirmType
    );

    BasicForecastPlanReleasePO findPlanSituation(BasicPlanQuery query);
    /**
     * 获取待发布数据
     *
     * @param page 当前页码
     * @param rows 每页显示行数
     * @param query 查询条件
     * @return 结果
     */
    ResponseEntity findWaitReleaseData(Integer page, Integer rows, BasicPlanQuery query);

    /**
     * 根据计划类型和计划ID下载计划文件
     *
     * @param planId   计划ID
     * @param type     计划类型 要货计划、标准预测、外协预测 外包物料到货需求
     * @param request  请求
     * @param response 响应
     * @return 文件
     */
    String downloadPlanFileByTypeAndPlanId(Long planId,
                                           @RequestParam(value = "type", defaultValue = "") String type,
                                           HttpServletRequest request,
                                           HttpServletResponse response,
                                           @RequestParam(value = "downFileName", defaultValue = "") String downFileName,
                                           @RequestParam(value = "downFilePath", defaultValue = "") String downFilePath);

    /**
     * 保存发布数据
     *
     * @param planId 计划ID
     * @param data 待保存数据
     * @return 结果
     */
    ResponseEntity saveReleaseData(Long planId, String data);

    void downLoadPcn(HttpServletRequest request,
                     HttpServletResponse response,
                     @RequestParam(value = "planId") Long planId,
                     @RequestParam(value = "purchaseGroup") String purchaseGroup
    );

    void downLoadRisk(HttpServletRequest request,
                      HttpServletResponse response,String product,String supplier,String isRisk,String serialNumber);
    Map<String,Object> impXunJiaMaterial(@RequestPart("file") MultipartFile file);


    ResponseEntity saveSupplierReplys(String data, boolean isPurchaseReplace);

    /**
     * 获取供应商回复进度
     */
    ResponseEntity getSupplierReply(Integer page, Integer rows, Long planId);

    /**
     * 删除
     * @param id
     */
    void remove(Long id);

    void downloadSapData(Long planId, HttpServletRequest request, HttpServletResponse response);
}
