package com.sw.mes.yb.check.service;

import com.sw.mes.core.base.BaseService;
import com.sw.mes.core.dto.PieceCheckDto1;
import com.sw.mes.core.utils.RequestPage;
import com.sw.mes.yb.check.entity.PieceCheck;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.web.multipart.MultipartFile;

import java.util.Date;
import java.util.List;

public interface PieceCheckService extends BaseService<PieceCheck> {

    List<PieceCheck> findByExample(Specification<PieceCheck> specification, RequestPage page);

    PieceCheck getByPieceNo(String pieceNo);

    void saveOrUpdateInBatch(List<PieceCheck> pieceChecks, String type);

    List<PieceCheck> findAll(Specification<PieceCheck> specification);

    int findCountByPieceNo(List<String> samples);

    List<PieceCheck> findByMotherCrystalNo(String motherCrystalNo);

    List<PieceCheck> findPieceNosByPieceNo(List<String> samples);

    // 评级
    //List<InspectData> grandInspect(List<PieceCheck> list);

    /**
     * 根据导入excel的内容，封装成PieceCheck结果集返回
     * @param file
     * @return
     */
    void readExcelFile(MultipartFile file) throws Exception;

    Integer countByPieceNo(String pieceNo);

    List<PieceCheck> findByTime(Date beginTime, Date endTime);

    List<String> findPieceCheckLotNoList(Date beginTime, Date endTime);

    List<PieceCheck> findByLotNo(String lotNo);

    /**
     * 保存位错、微缺陷数据
     * @param pieceChecks
     */
    void saveOrUpdateLineData(List<PieceCheck> pieceChecks);

    List<PieceCheck> getpieceCheck(String param, String series, String deviceNo, String lotNo, String motherCrystalNo, String startTime, String endTime, Sort sort);

    void saveAll(List<PieceCheck> pieceChecks);

    void createPieceCheck(List<String> samples, String batchNo, String receiveUser, String workshop);

    // 通过样片编号更新检验数据库晶段信息
    void saveInspectDataBaseInfo(String pieceNo);

    // 防止异步落库导致不更新样片数据
    void saveInspectDataBaseInfoNew(PieceCheck pieceCheck);

    void savePieceCheck(List<PieceCheck> pieceChecks);

    /**
     * 同步圆棒检验数据，以及方棒检验数据库
     * @param pieceChecks 样片检验数据
     */
    void synchronizationPieceCheck(List<PieceCheck> pieceChecks);
}
