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

import com.sw.mes.core.base.BaseService;
import com.sw.mes.core.response.Result;
import com.sw.mes.yb.production.dto.*;
import com.sw.mes.yb.production.entity.LongCrystal;

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

/**
 * @Author
 * @Description：
 * @Date:
 * @Modified By:
 */
public interface LongCrystalService extends BaseService<LongCrystal> {

    LongCrystal getLastCrystalNo(String equipmentCode);

    List<LongCrystalExcelDto> giveSomeValues(List<LongCrystalDto> longCrystalDto);

    List<LongCrystal> findByLotNo(String lotNo);

    List<LongCrystal> findByEquipmentCode(String equipmentCode);

    List<String> findByLotNoAndClosureIdentification(List<String> lotNoList, String closureIdentification);

    LongCrystal findByCrystalNo(String toString);

    List<LongCrystal> findLongCrystal();

    List<LongCrystal> findByCrystalNoAndNotId(String crystalNo, Long id);

    List<LongCrystal> findAllByCrystalNo(List<String> toString);

    LongCrystal findByCrystalNo2(String toString);

    List<LongCrystal> findByAgvTaskCode(String taskCode);

    List<LongCrystal> findByConfirmCrystals(String equipmentCode);

    LongCrystal findTopByLotId(Long id);

    List<LongCrystal> findByIds(List<Integer> ids);

    List<String> findTop3LotNo( );

    List<String> findTop3LotNoByEquipmentCode(String equipmentCode);

    LongCrystal findByLotIdAndAgainNumAndCrystalNumAndCrystalStatusNotAndIdNot(Long lotId, Integer againNum, Integer crystalNum, int crystalStatus,Long id);

    Result updateCrystalNo(LongCrystalInfoDto dto);

    //更新单晶状态
    Result updateCrystalStatus(LongCrystalDto dto);

    List<LongCrystal> findByLotIdAndCrystalStatusNot(Long lotId, Integer crystalStatus);

    Result<Integer> updateYbWorkOrder(String crystalNo, String ybWorkOrder);

    void completionLongCrystalOrder(String lotNo, String crystalNo, Date startTime, BigDecimal maxDiam, BigDecimal minDiam, Boolean flag);


    LongCrystal findBLotNoAndClosureIdentification(String crystalNo, String closureIdentification);

    LongCrystal findTopByLotIdAndCrystalStatus(Long lotId, Integer crystalStatus);

    Result updateLastLongCrstalWeight(LongCrystalVO longCrystalVO);

    Result updateWeightAndHeight(LongCrystalInfoDto dto);

    List<LongCrystal> findByGmtCreate(String startTime, String endTime);

    List<String> findByGmtCreate1(String startTime, String endTime, String area, String s);

    List<LongCrystal> findByGmtCreate2(List<String> lotNoList, String area, String s);

    BigDecimal findByGmtCreateAndAreaAndarea(String startTime, String endTime, String area);

    BigDecimal findByGmtCreateAndAreaAndarea1(String startTime, String endTime, String area);

    List<Map<String, Object>> pullOutPutData();

    List<Map<String, Object>> pullOutPutDataCut();

    void updatePulledState(List<Long> idList2);

    void updateSquarePulledState(List<Long> idList2);

    /**
     * 获取当前炉台，当前长晶棒上一根棒子
     * @param equipmentCode
     * @param id
     * @return
     */
    LongCrystal getLastId(String equipmentCode, Long id);

    /**
     * 根据炉次号和复投次数查询晶棒
     * @param lotNo
     * @param againNum
     * @return
     */
    List<LongCrystal> findByLotNoAndAgainNum(String lotNo, Integer againNum);

    /**
     * 获取设备时间节点之前产出
     * @param deviceNo
     * @param createTime
     * @return
     */
    LongCrystal findDeviceNoAndCreateTime(String deviceNo, Date createTime,Integer crystalStatus);


    BigDecimal findSumWeightByOrderNo(String orderNo);

    /**
     * 根据设备号查询最新的晶棒
     * @param equipmentCode
     * @return
     */
    LongCrystal findLastByEquipmentCode(String equipmentCode);

    List<LongCrystalWorkHourDto> getCrystalWorkHour(List<String> orderList);

    /**
     * 根据炉次号和复投次数查询最新的正常晶棒
     * @param lotNo
     * @param againNum
     * @return
     */
    LongCrystal findLastRightByLotNoAndAgainNum(String lotNo, Integer againNum, Long id);


    /**
     * 根据炉次号查询未确认晶棒
     * @param lotNo
     * @return
     */
    List<LongCrystal> findUnconfirmedByLotNo(String lotNo);

    List<LongCrystal> findByTakeCrystalAgvTaskCode(String takeCrystalAgvTaskCode);
}
