package com.sw.mes.yb.alloy.dao;

import com.sw.mes.core.base.BaseDao;
import com.sw.mes.yb.alloy.entity.AlloyMasterAlloy;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;


/**
 * @Author
 * @Description：
 * @Date:
 * @Modified By:
 */
public interface AlloyMasterAlloyDao extends BaseDao<AlloyMasterAlloy, Integer> {

    /**
     * @param lastWeight：上一棒重量
     * @param inCruWeight：留锅量
     * @param lastResivity：上一棒电阻
     * @param polysiliconResivity：多晶硅电阻
     * @param polysiliconWeight：多晶硅重量
     * @param loop1Resivity：循环料1电阻
     * @param loop1Weight：循环料1重量
     * @param loop2Resivity：循环料2电阻
     * @param loop2Weight：循环料2重量
     * @param loop3Resivity：循环料3电阻
     * @param loop3Weight：循环料3重量
     * @param loop4Resivity：循环料4电阻
     * @param loop4Weight：循环料4重量
     * @param loop5Resivity：循环料5电阻
     * @param loop5Weight：循环料5重量
     * @param loop6Resivity：循环料6电阻
     * @param loop6Weight：循环料6重量
     * @param loop7Resivity：循环料7电阻
     * @param loop7Weight：循环料7重量
     * @param curResivity：本棒电阻
     * @param motherAlloyGear：母合金档位
     * @return 母合金重量
     */
    @Query(value = "SELECT Jinko_GetComputeMotherAlloyWeight(:lastWeight, :inCruWeight, :lastResivity, :polysiliconResivity, :polysiliconWeight, :loop1Resivity, :loop1Weight, :loop2Resivity, :loop2Weight, :loop3Resivity, :loop3Weight, :loop4Resivity, :loop4Weight, :loop5Resivity, :loop5Weight, :loop6Resivity, :loop6Weight, :loop7Resivity, :loop7Weight, :curResivity, :motherAlloyGear) FROM DUAL", nativeQuery = true)
    Float getComputedMotherAlloyWeight(@Param("lastWeight") Float lastWeight,
                                       @Param("inCruWeight") Float inCruWeight,
                                       @Param("lastResivity") Float lastResivity,
                                       @Param("polysiliconResivity") Float polysiliconResivity,
                                       @Param("polysiliconWeight") Float polysiliconWeight,
                                       @Param("loop1Resivity") Float loop1Resivity,
                                       @Param("loop1Weight") Float loop1Weight,
                                       @Param("loop2Resivity") Float loop2Resivity,
                                       @Param("loop2Weight") Float loop2Weight,
                                       @Param("loop3Resivity") Float loop3Resivity,
                                       @Param("loop3Weight") Float loop3Weight,
                                       @Param("loop4Resivity") Float loop4Resivity,
                                       @Param("loop4Weight") Float loop4Weight,
                                       @Param("loop5Resivity") Float loop5Resivity,
                                       @Param("loop5Weight") Float loop5Weight,
                                       @Param("loop6Resivity") Float loop6Resivity,
                                       @Param("loop6Weight") Float loop6Weight,
                                       @Param("loop7Resivity") Float loop7Resivity,
                                       @Param("loop7Weight") Float loop7Weight,
                                       @Param("curResivity") Float curResivity,
                                       @Param("motherAlloyGear") Float motherAlloyGear);

    @Query(value = "select * from alloy_master_alloy where lot_no = ?1 and add_time = ?2 limit 1", nativeQuery = true)
    AlloyMasterAlloy findByLotNoAndAddTime(String lotNo, String addTime);
}
