package com.tuoheng.admin.service.accident;

import com.tuoheng.admin.entity.Accident;
import com.tuoheng.admin.mapper.AccidentMapper;
import com.tuoheng.admin.query.AccidentQuery;
import com.tuoheng.admin.request.accident.*;
import com.tuoheng.admin.service.accident.accidentNotice.AccidentNoticeService;
import com.tuoheng.admin.service.accident.add.AddAccidentService;
import com.tuoheng.admin.service.accident.continuee.ContinueToInspectService;
import com.tuoheng.admin.service.accident.forward.AccidentForwardFactory;
import com.tuoheng.admin.service.accident.handle.HandleAccidentService;
import com.tuoheng.admin.service.accident.ignore.AccidentIgnoreService;
import com.tuoheng.admin.service.accident.index.QueryAccidentIndexService;
import com.tuoheng.admin.service.accident.index.QueryAccidentInfoService;
import com.tuoheng.admin.service.accident.query.QueryAccidentByIdService;
import com.tuoheng.admin.service.accident.query.QueryAccidentListService;
import com.tuoheng.admin.service.accident.query.QueryEmergencyListService;
import com.tuoheng.admin.service.accident.record.RecordAccidentService;
import com.tuoheng.admin.service.accident.update.UpdateAccidentStatusCompletedService;
import com.tuoheng.common.core.common.BaseServiceImpl;
import com.tuoheng.common.core.utils.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Author ChengWang
 * @Date 2023/3/2
 */
@Service
@Slf4j
public class AccidentServiceImpl extends BaseServiceImpl<AccidentMapper, Accident> implements IAccidentService {
    @Autowired
    private QueryAccidentIndexService queryAccidentIndexService;
    @Autowired
    private QueryAccidentInfoService queryAccidentInfoService;

    @Autowired
    private QueryAccidentListService queryAccidentListService;

    @Autowired
    private QueryAccidentByIdService queryAccidentByIdService;

    @Autowired
    private AddAccidentService addAccidentService;

    @Autowired
    private AccidentForwardFactory accidentForwardFactory;

    @Autowired
    private ContinueToInspectService continueToInspectService;

    @Autowired
    private RecordAccidentService recordAccidentService;

    @Autowired
    private AccidentNoticeService accidentNoticeService;

    @Autowired
    private HandleAccidentService handleAccidentService;
    @Autowired
    private QueryEmergencyListService queryEmergencyListService;

    @Autowired
    private AccidentIgnoreService accidentIgnoreService;

    @Autowired
    private UpdateAccidentStatusCompletedService updateAccidentStatusCompletedService;

    @Override
    public JsonResult getAccidentCardList(QueryAccidentListRequest request) {
        return queryAccidentListService.getList(request);
    }

    @Override
    public JsonResult getAccidentInfo(String id) {
        return queryAccidentByIdService.getInfoById(id);
    }

    /**
     * 添加应急事故信息
     *
     * @param request
     * @return
     */
    @Override
    public JsonResult create(AddAccidentRequest request) {
        return addAccidentService.add(request);
    }

    /**
     * 查询应急事故记录
     *
     * @param query
     * @return
     */
    @Override
    public JsonResult index(AccidentQuery query) {
        return queryAccidentIndexService.index(query);
    }

    /**
     * 前往
     *
     * @param request
     * @return
     */
    @Override
    public JsonResult forward(AccidentForwardRequest request) {
        return accidentForwardFactory.forward(request);
    }

    /**
     * 继续巡检
     *
     * @param request
     * @return
     */
    @Override
    public JsonResult continueToInspect(ContinueToInspectRequest request) {
        return continueToInspectService.continueToInspect(request);
    }

    /**
     * 应急事故记录
     *
     * @param request
     * @return
     */
    @Override
    public JsonResult record(AccidentRecordRequest request) {
        return recordAccidentService.record(request);
    }

    /**
     * 查询应急事故记录详情
     *
     * @param accidentId 事故id
     * @return
     */
    @Override
    public JsonResult getInfoByAccident(String accidentId) {
        return queryAccidentInfoService.getInfoByAccidentId(accidentId);
    }

    /**
     * 告警弹窗通知下发
     *
     * @return
     */
    @Override
    public JsonResult notice() {
        return accidentNoticeService.notice();
    }

    /**
     * 应急事故处理完成
     *
     * @param request
     * @return
     */
    @Override
    public JsonResult handle(AccidentHandleRequest request) {
        return handleAccidentService.handle(request);
    }

    /**
     * 查询应急任务状态 页面滑动展示
     *
     * @param request
     * @return
     */
    @Override
    public JsonResult getAccList(QueryEmergencyListRequest request) {
        return queryEmergencyListService.getList(request);
    }

    /**
     * 忽略
     *
     * @param id
     * @return
     */
    @Override
    public JsonResult ignore(String id) {
        return accidentIgnoreService.ignore(id);
    }

    /**
     * 修改任务状态为已完成
     * @param id
     * @return
     */
    @Override
    public JsonResult updateStatus(String id) {
        return updateAccidentStatusCompletedService.updateStatus(id);
    }
}

