package com.tuoheng.admin.service.accident.forward;

import com.tuoheng.admin.entity.Inspection;
import com.tuoheng.admin.entity.User;
import com.tuoheng.admin.enums.InspectionTypeEnum;
import com.tuoheng.admin.request.accident.AccidentForwardRequest;
import com.tuoheng.common.core.utils.DateUtils;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public final class CreateEmergencyInspection {

    /**
     * 创建应急任务
     *
     * @param user
     * @param request
     * @return
     */
    public static Inspection create(User user, AccidentForwardRequest request, Integer inspectionStatus) {
        Inspection inspection = new Inspection();
        String code = DateUtils.generateCode("XJRW");
        inspection.setCode(code);
        inspection.setName("应急任务" + code);
        inspection.setDeptId(user.getDeptId());
        inspection.setTenantId(user.getTenantId());
        inspection.setType(2);
        inspection.setAirportId(request.getAirportId());
        inspection.setAirportName(request.getAirportName());
        inspection.setDroneId(request.getDroneId());
        inspection.setDspServiceInstId(request.getDspServiceInstId());
        inspection.setEmergencyDataInspectionId(request.getEmergencyDataInspectionId());
        inspection.setStatus(inspectionStatus);
        inspection.setInspectionType(InspectionTypeEnum.AIRPORT.getCode());
        inspection.setInspectionLine(0);
        inspection.setInspectionLineName("");
        inspection.setExecutionStartTime(DateUtils.now());
        inspection.setChannelId("");
        inspection.setChannelName("");
        inspection.setLegId("");
        inspection.setLegName("");
        inspection.setIsLive(1);
        inspection.setCreateUser(user.getId());
        inspection.setCreateTime(DateUtils.now());
        return inspection;
    }

}
