package com.njcn.csdevice.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.param.*;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
import com.njcn.csdevice.pojo.vo.DevVersionVO;
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2023/3/30  16:23【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
public interface CsEquipmentDeliveryService extends IService<CsEquipmentDeliveryPO>{

    /**
     * 初始化缓存设备池
     */
    void refreshDeviceDataCache();

    /**
    * @Description: save
    * @Param: [csEquipmentDeliveryAddParm]
    * @return: java.lang.Boolean
    * @Author: clam
    * @Date: 2023/3/31
    */
    CsEquipmentDeliveryPO save(CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm);
    /**
    * @Description: AuditEquipmentDelivery
    * @Param: [id]
    * @return: java.lang.Boolean
    * @Author: clam
    * @Date: 2023/3/31
    */
    Boolean AuditEquipmentDelivery(String id);
    /**
    * @Description: queryEquipmentByndid
    * @Param: [ndid]
    * @return: com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO
    * @Author: clam
    * @Date: 2023/3/31
    */
    CsEquipmentDeliveryVO queryEquipmentByndid(String ndid);
    /** 
    * @Description: queryEquipmentByProject 
    * @Param: [projectEquipmentQueryParm] 
    * @return: com.njcn.algorithm.pojo.vo.CsEquipmentDeliveryVO 
    * @Author: clam
    * @Date: 2023/4/3 
    */
    IPage<ProjectEquipmentVO> queryEquipmentByProject(ProjectEquipmentQueryParm projectEquipmentQueryParm);

    Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm);

    /**
     * 根据网关id修改装置的状态
     * @param nDid 网关id
     */
    void updateStatusBynDid(String nDid,Integer status);

    /**
     * 设备出厂列表
     * @param param
     * @return
     */
    Page<CsEquipmentDeliveryVO> list(CsEquipmentDeliveryQueryParm param);

    /**
     * 获取装置基础数据和模板数据
     * @return
     */
    DeviceManagerVO getDeviceData(String deviceId,String type,String lineId);

    /**
     * 根据网关id修改软件信息
     * @param nDid 网关id
     */
    void updateSoftInfoBynDid(String nDid,String id,Integer module);

    /**
     * 通过nDid查询设备信息
     * @param nDid
     * @return
     */
    CsEquipmentDeliveryPO findDevByNDid(String nDid);

    List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response);

    void delete(String devId);

    void testCompletion(String deviceId,Integer type,String remark);

    void deleteTest(String deviceId, Integer type,String remark);

    /**
     * 更新设备软件信息
     * @param nDid
     * @param id
     */
    void updateSoftInfo(String nDid, String id);

    /**
     * 更新设备模块个数
     * @param nDid
     * @param number
     */
    void updateModuleNumber(String nDid, Integer number);

    boolean rebootDevice(String nDid);

    /**
     * 获取所有装置信息
     * @return
     */
    List<CsEquipmentDeliveryPO> getAll();

    /**
     * 获取所有装置信息(投运且在线)
     * @return
     */
    List<CsEquipmentDeliveryPO> getAllOnline();

    /**
     * 判断设备型号
     */
    boolean judgeDevModel(String nDid);

    CsEquipmentDeliveryPO getDevByLineId(String lineId);

    /**
     * 新增云前置设备
     * @param param
     * @return
     */
    CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param);

    /**
     * 删除云前置设备
     * @param id
     * @return
     */
    Boolean delCldDev(String id);

    /**
     * 更新云前置设备
     * @param param
     * @return
     */
    Boolean updateCldDev(CsEquipmentDeliveryAuditParm param);

    /**
     * 根据前置ip和运行状态获取装置数据
     * @param id
     * @param runFlag
     * @return
     */
    List<CsEquipmentDeliveryPO> getCldDevByIp(String id, List<Integer> runFlag);

    /**
     * 根据前置id和进程号修改设备状态；同时修改设备下的监测点的状态
     */
    void updateCldDevStatus(String nodeId, Integer processNo);

    /**
     * 根据设备id和状态来修改设备运行状态；同时修改设备下的监测点的状态
     * @param date
     * @param devId
     * @param status
     */
    void flipCldDevStatus(String date, String devId, Integer status);

    /**
     * 根据项目id获取设备列表
     */
    List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId);

    List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(String nodeId, Integer processNo);

    List<CsEquipmentDeliveryPO> getListByIds(List<String> devList);

    List<CsEquipmentDeliveryPO> getRunPortableDev(String userId);

    IPage<DevVersionVO> versionPage(CsEquipmentDeliveryQueryParm baseParam);
}
