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

import com.sw.mes.yb.accessory.dto.*;
import com.sw.mes.yb.accessory.entity.EquipmentAccessory;
import com.sw.mes.core.base.BaseService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

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

    void saveOrUpdate(@Valid AccessoryChangeDto equipmentAccessoryDto) throws RuntimeException;

    void saveOrUpdate(@Valid EquipmentAccessoryDto equipmentAccessoryDto) throws RuntimeException;

    /**
     * 根据设备ID
     * @param equipmentId
     * @return
     */
    List<EquipmentAccessory> getByEquipment_id(Long equipmentId);

    /**
     * 修改监控模型寿命
     * @param materialId
     * @param useLife
     */
    void updateUseLife(Long materialId, Double useLife);

    EquipmentAccessory saveOrUpdate(EquipAccessCreateDto dto) throws RuntimeException;

    void update(EquipAccessUpdateDto dto) throws RuntimeException;

    void change(EquipAccessChangeDto dto) throws RuntimeException;

    EquipmentAccessory getByEquipment_idAndMaterial_id(Long equipmentId, Long materialId);

    EquipmentAccessory getChangeInfo(EquipAccessChangeDto dto);

    void batchChange(EquipAccessBatchChangeDto dto);

    EquipmentAccessory getUseTimeByCode(String code);

    List<EquipmentAccessory> findByGoodCodes(String uniqueCode);

    /**
     * 查出对应设备编号的热场监控
     * @param deviceNo
     * @return
     */
    List<EquipmentAccessory> findByDeviceCode(String deviceNo);

    Page<Map<String, Object>> newListByPage(EquipmentAccessoryParmDto dto, Pageable pageable);

    /**
     * 获取当前设备监控已使用寿命
     */
    BigDecimal getUseTime(Long equipmentAccessoryId);

    List<EquipmentAccessory> findByGoodCodesWithBind(String uniqueCode);

    void collectForExportAndSaveWithAsync(EquipAccessCreateDto dto, List<EquipmentAccessory> copyOnWriteArrayList);

    EquipmentAccessoryListByPageDto getDetail(Long id);

    Integer countNewListByPage(EquipmentAccessoryParmDto dto);

    void newChange(List<EquipAccessNewChangeDto> dtos);
}
