package com.securitycontrol.screen.service.impl;

import com.securitycontrol.common.core.domain.Result;
import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.common.security.utils.SecurityUtils;
import com.securitycontrol.entity.background.vo.DutyPlanVo;
import com.securitycontrol.entity.screen.dto.AlarmMgeDto;
import com.securitycontrol.entity.screen.dto.ScreenParamDto;
import com.securitycontrol.entity.screen.vo.AlarmMgeVo;
import com.securitycontrol.entity.system.SystemGlobal;
import com.securitycontrol.entity.system.base.vo.ProVo;
import com.securitycontrol.screen.mapper.AlarmMgeMapper;
import com.securitycontrol.screen.service.AlarmMgeService;
import com.securitycontrol.system.api.model.LoginUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Future;

/**
 * 告警管理
 * @author lsun
 */
@Slf4j
@Service(value = "AlarmMgeService")
public class AlarmMgeServiceImpl implements AlarmMgeService {

    @Resource(name = "AlarmMgeMapper")
    private AlarmMgeMapper mapper;

    @Override
    public List<AlarmMgeVo> getAlarmMgeList(AlarmMgeDto dto) {
        List<AlarmMgeVo> list = new ArrayList<>();
        try {
            list = mapper.getAlarmMgeList(dto);
        } catch (Exception e) {
            log.error(e.toString(),e);
        }
        return list;
    }

    /**
     * 告警处置接口
     * @param dto
     * @return
     */
    @Override
    public Result<String> warnProcess(AlarmMgeDto dto) {
        try{
            LoginUser user= SecurityUtils.getLoginUser();
            dto.setUserId(user.getUserid()+"");
            dto.setUserName(user.getUsername());
            int  num= mapper.warnProcess(dto);
            if(num==SystemGlobal.SUCCESS_NUM){
                return  Result.ok("操作成功","操作成功");
            }
            return  Result.fail("操作失败");
        }catch (Exception e){
            log.error(e.toString(),e);
        }
        return  Result.fail("操作失败");
    }
}
