package com.yeejoin.amos.fas.business.service.intfc;


import com.yeejoin.amos.fas.business.action.model.FireEquimentDataRo;
import com.yeejoin.amos.fas.business.action.model.ProtalDataRo;
import com.yeejoin.amos.fas.business.bo.BindRegionBo;
import com.yeejoin.amos.fas.business.bo.DangerResultBo;
import com.yeejoin.amos.fas.business.bo.JpushMsgBo;
import com.yeejoin.amos.fas.business.bo.RiskSourceSynBo;
import com.yeejoin.amos.fas.business.param.AlarmParam;
import com.yeejoin.amos.fas.business.param.CommonPageInfoParam;
import com.yeejoin.amos.fas.business.param.FmeaBindParam;
import com.yeejoin.amos.fas.business.service.model.ContingencyDeviceStatus;
import com.yeejoin.amos.fas.core.common.request.CommonPageable;
import com.yeejoin.amos.fas.core.common.response.RegionTreeResponse;
import com.yeejoin.amos.fas.core.common.response.RiskSourceTreeResponse;
import com.yeejoin.amos.fas.core.enums.ReserveEnum;
import com.yeejoin.amos.fas.dao.entity.FmeaEquipmentPoint;
import com.yeejoin.amos.fas.dao.entity.FmeaPointInputitem;
import com.yeejoin.amos.fas.dao.entity.RiskSource;
import org.springframework.data.domain.Page;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface IRiskSourceService {

    /**
     * 新增及维护风险点
     */
    RiskSource editRiskSource(HashMap<String, Object> map) throws Exception;

    /**
     * 风险模型新增及维护时远程同步
     *
     * @param appKey
     * @param product
     * @param token
     * @param success contoler中的系统通用failed标识和这里返回前台的不一样。
     * @param id
     * @param code
     * @param name
     * @param parentId
     * @return CommonResponse
     * @throws <br>
     * @author 张展弋
     * @date 2020-9-8 17:39:32
     */
//    String saveToEquipManage(String appKey, String product, String token, String success, long id,
//            String code, String name, Long parentId);

    /**
     * 将本地 风险模型推送到远程同步
     *
     * @param appKey
     * @param product
     * @param token
     * @param success
     * @param riskSourcesTree
     * @return String
     * @throws <br>
     * @author 张展弋
     * @date 2020-9-9 15:40:18
     */
//    String synToEquipManage(String appKey, String product, String token, String success, List<RiskSourceTreeResponse> riskSourcesTree);

    /**
     *
     * 是否同步到对站系统
     *
     * @return boolean
     * @throws <br>
     * @author 张展弋
     * @date 2020-9-8 15:45:34
     */
//    boolean isSynEquipManage();
    /**
     * 删除风险点
     */
    void deleteRiskSource(String appKey,String product,String token,String failed,Long[] riskSourceId) throws Exception;

    /**
     * 根据参数分页查询风险点信息
     */
    Page<HashMap<String, Object>> queryRiskSourceByPage(CommonPageInfoParam param);

    List<Map> queryForRegion();

    List<Map> queryRPNReport();

    /**
     * 上升率
     */
    Map queryForRiseUp() throws Exception;

    List<Map> queryForMatrix();

    /**
     * 获取所有风险点
     */
    List<RiskSourceTreeResponse> findRiskSourceTrees(String compCode);

    List<FmeaEquipmentPoint> bindFireEquiment(FmeaBindParam fmeaBindParam);

    List<FmeaPointInputitem> bindPointInputitem(FmeaBindParam fmeaBindParam);

    /**
     * 查询指定风险点和设备之间的关系，包含绑定和未绑定
     */
    Page queryEquimentRelation(CommonPageable commonPageable, String equipmentId, String fname);

    List<Map<String, Object>> listEquipmentPointById(Long fmeaId, Long importantEquipId, Long equipmentId, String equipmentPointName);

    Page<Map<String, Object>> listFmeaPointInputitem(String toke,String product,String appKey,Long fmeaId, Integer pageNumber, Integer pageSize);

    Page<Map<String, Object>> listFeamEquipmentPoint(Long fmeaId, Integer pageNumber, Integer pageSize);

    /**
     * 处理巡检数据和设备数据
     */
    String processFireEqumtData(FireEquimentDataRo deviceData) throws Exception;

    boolean processTaskData(ProtalDataRo taskData) throws Exception;

    void processProtalData(String toke,String product,String appKey,ProtalDataRo protalData, String orgCode) throws Exception;

    RiskSourceTreeResponse queryRiskSourceDetailById(Long id);

    /**
     * 三维图统计
     */
    Map queryFor3DStatistics();

    Map earlyWarning(Long riskSourceId);

    List<HashMap<String, Object>> queryRiskAreaRpn();

    String processFireEqumtData(AlarmParam deviceData) throws Exception;

//    void saveData(List<AlarmParam> deviceDatas, String type);

    List<HashMap<String, Object>> queryRiskSourceSecondLevel(String compCode);

    List<RiskSourceTreeResponse> findRiskSourceEquipStatistics();

    List<RiskSourceTreeResponse> findRiskSourceEquipStatistics(String[] type);

    List<RiskSourceTreeResponse> getCheckPointRiskSources();

    void queryContingencyDeviceStatus(ContingencyDeviceStatus contingencyDeviceStatus);

    List<Map> queryContingencyWater();

    List<Map> queryFmeaByPointId(Long pointId);

    Integer getChildTypeByPid(Long riskSourceId);

    void notifyFmeaFromAbnormal(String toke,String product,String appKey,Long fmeaId, String notifyType,String userName, String relationName,String checkStatus);

    void notifyFmeaFromUpdate(String toke,String product,String appKey,Long fmeaId, String nofityType,String userName);

    /**
     * 按照机构重新区域树
     * @param orgCode 机构
     * @return 树
     */
	List<RegionTreeResponse> findRegionTree(String channelType,String orgCode);

    /**
     * 区域详情重新
     * @param id 主键
     * @param orgCode 机构
     * @return map
     */
	HashMap<String, Object> findRegionById(Long id,String orgCode,String channelType);

    /**
     * 批量保存区域信息
     * @param regionBoList 参数数组
     */
	void batchSaveRegionUe4(List<BindRegionBo> regionBoList,String orgCode);

    void notifyRiskSource(String orgCode, Long fmeaId, Long riskSourceId, String notifyType, JpushMsgBo jpushMsgBo);

    void notifyFmeaFromDelete(Long handId, String from);

    void notifyRiskSourceDelete(Long handId);

    /**
     *
     * 不做任何不能删校验，直接删除，慎用
     *
     * @param id void
     * @throws <br>
     * @author 张展弋
     * @date 2020-9-9 11:53:36
     */
    void deleteById(Long id);

    /**
     * 同步创建/更新区域
     * @param code userId
     * @param compCode 公司编号
     * @param synBo 同步数据支持树结构同步
     * @return RiskSource
     */
    RiskSource synRegion(String code, String compCode, RiskSourceSynBo synBo);

    /**
     * 解除绑定关系
     * @param instanceId 解除者id
     * @return Boolean
     */
    Boolean removeBind(Long instanceId);

    ReserveEnum startEquipReserve(Long id, String typeCode);

    void processProtalDataFromDanger(DangerResultBo dangerResultBo) throws Exception;

    RiskSource updateAreaSyn(String code, String compCode, RiskSourceSynBo synBo);
}
