You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
4.7 KiB

using System.Text.Json;
using HybirdFrameworkCore.Entity;
using HybirdFrameworkCore.AutoTask;
using Microsoft.AspNetCore.Mvc;
using Service.Cloud.Client;
using Service.Cloud.Msg.Host.Req;
using Newtonsoft.Json;
using Service.Init;
using Service.Cloud.Common;
using Org.BouncyCastle.Asn1.X509;
using Org.BouncyCastle.Crypto.Tls;
namespace WebStarter.Controllers.System;
[Produces("application/json")]
[ApiController]
[Route("api/[controller]")]
public class TestController1
{
/// <summary>
/// 云端上传
/// </summary>
/// <param name="topic"></param>
/// <param name="payload"></param>
/// <returns></returns>
[HttpGet("/Cloud/CloudStart")]
public Result<bool> CloudStart(string topic, string payload)
{
CloudClientMgr.Send(topic, payload);
return Result<bool>.Success();
}
/// <summary>
/// 上传云端车辆就绪
/// </summary>
/// <returns></returns>
[HttpGet("/Cloud/UploadCloudReady")]
public Result<bool> UploadCloudReady(ReadyTopic readyTopic)
{
string jsonString = JsonConvert.SerializeObject(readyTopic, Formatting.Indented);
CloudClientMgr.Send("truck_topic_command_sub_find", jsonString);
return Result<bool>.Success();
}
/// <summary>
/// 上传云端换电完成
/// </summary>
/// <returns></returns>
[HttpGet("/Cloud/UploadCloudSwapFinish")]
public Result<bool> UploadCloudSwapFinish()
{
SwapFinish swapFinish = new SwapFinish()
{
stationSn = StaticStationInfo.StationSn,
type = "2",
carNumber = "沪AD84996",
status = "2",
alarmCode = "",
sn = "",
after_sn = "",
orderID = "123132123123",
stationStatus = "1",
before_soc = "45",
after_soc = "96",
};
string jsonString = JsonConvert.SerializeObject(swapFinish, Formatting.Indented);
CloudClientMgr.Send("truck_topic_command_sub_find_2", jsonString);
return Result<bool>.Success();
}
/// <summary>
/// 上传云端机器人状态
/// </summary>
/// <returns></returns>
[HttpGet("/Cloud/UploadCloudRobotInfo")]
public Result<bool> UploadCloudRobotInfo()
{
RobotInfo swapFinish = new RobotInfo()
{
stationSn = StaticStationInfo.StationSn,
type = "2",
sn="001",
status ="1",
network_status = "1",
startTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
alarm_code = "",
soc = "100",
spare = "",
};
string jsonString = JsonConvert.SerializeObject(swapFinish, Formatting.Indented);
CloudClientMgr.Send(CloudConst.robotInfo, jsonString);
return Result<bool>.Success();
}
/// <summary>
/// 上传云端告警信息
/// </summary>
/// <returns></returns>
[HttpGet("/Cloud/UploadCloudAlarm")]
public Result<bool> UploadCloudAlarm()
{
Alarm swapFinish = new Alarm()
{
stationSn = StaticStationInfo.StationSn,
type = "4",
carNumber = "",
status = "1",
alarmCode="18",
title= "充电机告警",
sn = "C2001",
alarmLevel="3",
alarmSuggestions="",
startTime=DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
endTime="",
deviceType="4",
content= "BMS通信故障",
deviceName="充电机01",
stationName= "城南换电站",
};
string jsonString = JsonConvert.SerializeObject(swapFinish, Formatting.Indented);
CloudClientMgr.Send(CloudConst.stationAlarm, jsonString);
return Result<bool>.Success();
}
/// <summary>
/// 上传云端告警信息
/// </summary>
/// <returns></returns>
[HttpGet("/Cloud/UploadCloudBatteryStatus")]
public Result<bool> UploadCloudBatteryStatus()
{
BatteryStatus batteryStatus = new BatteryStatus()
{
sn = "001",
soc = "23",
soh="",
energy = "56",
temperature = "23",
voltage_min = "20",
voltage_max = "220",
network_status = "1",
alarmCode = "",
status = "1",
isVehicle = "2",
longitude = "121.231321",
latitude = "29.2334",
battery_no = "1242203B1964",
};
string jsonString = JsonConvert.SerializeObject(batteryStatus, Formatting.Indented);
CloudClientMgr.Send(CloudConst.stationAlarm, jsonString);
return Result<bool>.Success();
}
}