package com.jwipc.order.logic;

import cn.hutool.core.date.DateTime;
import com.jwipc.order.dto.ShortagePlanReleaseDTO;
import com.jwipc.order.dto.ShortagePlanReplyDTO;
import com.jwipc.order.entity.ShortageData;
import com.jwipc.order.entity.ShortagePlan;
import com.jwipc.order.model.query.BasicForeignQuotaQuery;
import com.jwipc.order.model.query.BasicPlanQuery;
import com.jwipc.page.PageView;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

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

/**
 * @Author: swq
 * @Date: 2024/4/29 14:24
 */
public interface ShortagePlanLogic {

    /**
     * 欠料计划，回复页面， 点击导入时，先缓存excel导入的数据，方便页面点击同意时，在从缓存中取出推送至sap
     * @param result
     */
    void pushReplyImportToCash(List<ShortagePlanReplyDTO> result);

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

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


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

    /**
     * 查询预测计划信息列表：过滤新建状态
     * @return
     */
    List<ShortagePlan> selectPlanList();
    /**
     * 明细查看
     *
     * @param planId 计划ID
     * @return 明细查看数据
     */
    List<ShortageData> selectDataList(long planId);

    /**
     * 供应商回复 查看汇总列表
     */
    PageView getReplyData(BasicForeignQuotaQuery 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);

    void remove(String id);

    PageView getToPublishedData(BasicPlanQuery basicPlanQuery);


    void exportToPublishedData(HttpServletResponse response, String exportFiled, BasicPlanQuery basicPlanQuery);


    List<ShortagePlanReleaseDTO> fildToPublishedData(BasicPlanQuery basicPlanQuery);

    void savePublished(List<ShortagePlanReleaseDTO> list);

    void published(List<ShortagePlanReleaseDTO> list, Integer deployToSupplier);

    void getExportReplyData(HttpServletResponse response, String exportFiled, BasicForeignQuotaQuery basicPlanQuery);

    void saveReply(List<ShortagePlanReplyDTO> list);
    void confirmReply(BasicForeignQuotaQuery basicPlanQuery);

    void confirmReply();

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

    String genSerialNumber(DateTime now, String serialNumber);

    /**
     * 补充供应商数据
     * @param result
     */
    void fillSupplier(List<ShortagePlanReleaseDTO> result);

//  此方法废除
//    void fillLaunchDate(List<ShortagePlanReleaseDTO> result);

    void importForPublished(List<ShortagePlanReleaseDTO> result);
}
