package com.sw.mes.agv.service;

import com.sw.mes.agv.dto.MonitorRechargeDto;
import com.sw.mes.agv.entity.MonitorEquipmentRecharge;
import com.sw.mes.core.base.BaseService;
import com.sw.mes.core.utils.RequestPage;
import org.springframework.data.jpa.domain.Specification;

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

public interface MonitorEquipmentRechargeService extends BaseService<MonitorEquipmentRecharge> {
	
	List<MonitorEquipmentRecharge> findAll(RequestPage page);
	
	List<MonitorEquipmentRecharge> findAll(Specification<MonitorEquipmentRecharge> specification);
	
	List<MonitorEquipmentRecharge> findByExample(Specification<MonitorEquipmentRecharge> specification, RequestPage page);

	/**
	 * 根据设备名称查询复投看板信息
	 * @param deviceNo
	 * @return
	 */
	MonitorEquipmentRecharge getByName(String deviceNo);

    List<MonitorEquipmentRecharge> findBySlingStateNot(String state);

    List<MonitorEquipmentRecharge> findByEquipmentsAndSlingStateNotEqual(List<String> equipmentList, String state);

	List<MonitorEquipmentRecharge> findByEquipmentsAndSlingState(List<String> equipmentList, String state);

	List<MonitorEquipmentRecharge> findByEquipmentsAndSlingStateNotEqualAndStoreCode(List<String> equipmentList, String futouzhong, Boolean isHave);

	List<MonitorEquipmentRecharge> findByStateAndArea(Integer state, String area);

    void updateRechargeStartTime(Date rechargeStartTime, String deviceNo);

	void updateRechargeEndTime(Date rechargeEndTime, String deviceNo);

    List<MonitorEquipmentRecharge> findRechargeEndTimeIsNull(String userIp);

    List<MonitorEquipmentRecharge> findRechargeChangeWeight(String userIp);

	/**
	 * 灌料桶数小于呼叫桶数的列表信息
	 * @param userIp
	 * @return
	 */
	List<MonitorEquipmentRecharge> findRechargeCall(String userIp, String deviceCode);

//	/**
//	 * 查找满料入库送走列表
//	 * @param userIp
//	 * @param deviceCode
//	 * @return
//	 */
//	List<RechargeInfoDto> findPadSend(String userIp, String deviceCode);

	/**
	 * 查找初始重量为0且预计复投时间小于等于当前时间
	 * @return
	 */
    List<MonitorEquipmentRecharge> findByInitWeightAndPreSlingTime();

	void handleTaskLog();

	// 处理 远程拉晶端 发送复投重量
    void initRechargeWeight(String deviceNo, BigDecimal weight) throws Exception;

    // 更新物料搭配方案
    void saveOrUpdateArtBag(MonitorRechargeDto dto) throws Exception;

    // 查找 待复投 列表
	// 已操作物料搭配方案
    List<MonitorEquipmentRecharge> findRechargeInfoByMixTime(String userIp, String deviceCode);

//	/**
//	 * 新增 复投重量
//	 * @param dto
//	 */
//	void initRechargeWeight(RechargeWeightDto dto) throws Exception;

}
