package com.usky.fire.service.config;

import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
import com.usky.common.security.utils.SecurityUtils;
import com.usky.system.RemoteDictService;
import com.usky.system.RemoteMceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;

@Configuration
public class SyncPatrolInspectionEvent {

    @Autowired
    private RemoteMceService remoteMceService;
    @Autowired
    private RemoteDictService remoteDictService;

    @Async("asyncServiceExecutor")
    public void sendAsyncMessage(Integer tenantId,Integer eventId,String eventName,Integer eventType){
        String eventTypeName = remoteDictService.selectNameById("patrol_event_type",
                eventType.toString());
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("infoTitle", eventName);
        jsonObject.addProperty("infoContent",eventTypeName);
        jsonObject.addProperty("infoType",2);
        jsonObject.addProperty("userName", SecurityUtils.getUsername());
        jsonObject.addProperty("id",eventId);
        jsonObject.addProperty("tenantId",tenantId);
        remoteMceService.addMce(jsonObject.toString());
    }
}
