package com.sw.mes.sap.service;

import com.sw.mes.core.annotation.Jinko;
import com.sw.mes.core.base.BaseService;
import com.sw.mes.core.response.Result;
import com.sw.mes.sap.dto.statistics.StatisticsDto;
import com.sw.mes.sap.dto.statistics.StatisticsLjDto;
import com.sw.mes.sap.entity.ReportSapGoodsmvt;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.web.multipart.MultipartFile;

/**
 * MES报工SAP货物移动接口Service接口
 *
 * @author liru
 * @date 2024-01-06
 */
@Jinko(value = "MES报工SAP货物移动接口Service接口", author = "liru")
public interface ReportSapGoodsmvtService extends BaseService<ReportSapGoodsmvt> {

	List<Result> sendReportWord(Long[] id,String sendType);

    /**
     * 物料编码和移动类型获取MES报工
     *
     * @param crystalNo
     * @param bwart
     * @return
     */
    ReportSapGoodsmvt findByCrystalNoAndBwart(String crystalNo, String bwart);

    List<ReportSapGoodsmvt> findByProcNameAndOrderNoAndBwart(String procName, String orderNo, List<String> bwart);

    List<ReportSapGoodsmvt> findByProcNameAndOrderNoAndBwartAndLotNo(String procName, String orderNo, List<String> bwart, String lotNo);

    /**
     * 获取物料的消耗报工数据
     *
     * @return
     */
    List<ReportSapGoodsmvt> groupMaterialCostAtSap();

    /**
     * 根据晶编号查询报工记录 正序
     * @param crystalNo
     * @return
     */
	List<ReportSapGoodsmvt> findByCrystalNo(String crystalNo);

    /**
     * 物料编码和移动类型和工序获取MES报工
     *
     * @param crystalNo
     * @param bwart
     * @return
     */
    ReportSapGoodsmvt findByCrystalNoAndBwartAndProcName(String crystalNo, String bwart,String procName);

    ReportSapGoodsmvt findByCrystalNoAndBwartAndProcName1(String crystalNo, String procName);

    /**
     * 调拨统计
     */
	List statisticYbcshdb(StatisticsDto dto);



    /**
     * 修改SAP订单号
     */
    Integer modifyAufnrByCrystalNo(String procName, List<String> crystalNoList,Integer status) ;

    /**
     * 导入
     * @param file
     * @return
     */
	String importExcel(MultipartFile file);

	List<Map<Object,Object>> ljStatistics();

	List<Map<Object, Object>> djshStatistics(StatisticsDto dto);

	List<Map<Object, Object>> jdxhStatistics(StatisticsDto dto);

	List<Map<Object, Object>> jdshStatistics(StatisticsDto dto);

	List<Map<Object, Object>> dpxhStatistics(StatisticsDto dto);
	
	/**
	 * 检查未自动报工记录再次发送至SAP
	 */
	void checkNotAutoSendSap();

    BigDecimal findSumWeightByProcNameAndBwartAndOrderNo(String procName, String bwart, String orderNo);

	ReportSapGoodsmvt findByZuuidOrMblnr(String mBLNR);

	void superSaveOrUpdate(ReportSapGoodsmvt reportSapGoodsmvt);

	String importSAPExcel(MultipartFile file);

	Double getSumNoSendSapLog(String aufnr);

	/**
	 * 查询库位 物料 批次 总数量 记录
	 * @param AUFNR 工单号
	 */
	List<ReportSapGoodsmvt> findAllOrderMatnrChargLgort(String AUFNR);

	Long getChargLengthCount(String aUFNR);

	Long getChargeOffMengeCount(String aUFNR);

	Long getRsnumNullCount(String aUFNR);

	ReportSapGoodsmvt getByMblnr(String mblnr);

	List<ReportSapGoodsmvt> findByBwartAndLgortAndMatnrAndChargAndMengeAndStatus(String bwart, String lgort,String matnr, String charg, String menge, boolean status);
}
