! 上报结果更新不使用事件总线
This commit is contained in:
parent
cc9cd8b00f
commit
8ee4bbcf1a
|
|
@ -44,6 +44,7 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
_cahce = distributedCache;
|
_cahce = distributedCache;
|
||||||
_resultService = resultService;
|
_resultService = resultService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新上报状态
|
/// 更新上报状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -51,9 +52,34 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ResultInfo> UpdateStatusAsync(UpdateStatusDto data)
|
public async Task<ResultInfo> UpdateStatusAsync(UpdateStatusDto data)
|
||||||
{
|
{
|
||||||
await _capBus.PublishAsync("result.service.update", data);
|
//await _capBus.PublishAsync("result.service.update", data);
|
||||||
return new ResultInfo(ResultState.SUCCESS, "success");
|
//return new ResultInfo(ResultState.SUCCESS, "success");
|
||||||
|
Guid resultid = Guid.Empty;
|
||||||
|
if (!string.IsNullOrEmpty(data.ResultId) && Guid.TryParse(data.ResultId, out resultid))
|
||||||
|
{
|
||||||
|
if (await dbClient.Queryable<W_ResultExt>().AnyAsync(x => x.ResultId == resultid))
|
||||||
|
{
|
||||||
|
await dbClient.Updateable<W_ResultExt>().SetColumns(x => new W_ResultExt
|
||||||
|
{
|
||||||
|
Status = data.status
|
||||||
|
}).Where(x => x.ResultId == resultid).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var insertdata = new W_ResultExt
|
||||||
|
{
|
||||||
|
Id = IDGen.NextID(),
|
||||||
|
Status = data.status,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
ResultId = resultid
|
||||||
|
};
|
||||||
|
await dbClient.Insertable(insertdata).ExecuteCommandAsync();
|
||||||
|
}
|
||||||
|
return new ResultInfo(ResultState.SUCCESS, "success");
|
||||||
|
}
|
||||||
|
return new ResultInfo(ResultState.SUCCESS, "记录id未找到");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取设备上报相关信息
|
/// 获取设备上报相关信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -61,7 +87,6 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<ResultInfo> GetDevInfoAsync(GetDevInfoRequestDto data)
|
public async Task<ResultInfo> GetDevInfoAsync(GetDevInfoRequestDto data)
|
||||||
{
|
{
|
||||||
|
|
||||||
//更新上报记录结果
|
//更新上报记录结果
|
||||||
Guid resultid = Guid.Empty;
|
Guid resultid = Guid.Empty;
|
||||||
//这里进行去重处理
|
//这里进行去重处理
|
||||||
|
|
@ -211,6 +236,7 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
|
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 16进制转汉字
|
/// 16进制转汉字
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -242,6 +268,7 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
Encoding chs = Encoding.GetEncoding("gb2312");
|
Encoding chs = Encoding.GetEncoding("gb2312");
|
||||||
return chs.GetString(bytes);
|
return chs.GetString(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 16进制转10进制
|
/// 16进制转10进制
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -261,28 +288,33 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
case "A":
|
case "A":
|
||||||
strNum = "10";
|
strNum = "10";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "B":
|
case "B":
|
||||||
strNum = "11";
|
strNum = "11";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "C":
|
case "C":
|
||||||
strNum = "12";
|
strNum = "12";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "D":
|
case "D":
|
||||||
strNum = "13";
|
strNum = "13";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "E":
|
case "E":
|
||||||
strNum = "14";
|
strNum = "14";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "F":
|
case "F":
|
||||||
strNum = "15";
|
strNum = "15";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
double power = Math.Pow(16, Convert.ToDouble(nums.Length - i - 1));
|
double power = Math.Pow(16, Convert.ToDouble(nums.Length - i - 1));
|
||||||
total += Convert.ToInt64(strNum) * Convert.ToInt64(power);
|
total += Convert.ToInt64(strNum) * Convert.ToInt64(power);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (System.Exception ex)
|
catch (System.Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -290,9 +322,9 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 心跳数据上报
|
/// 心跳数据上报
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -307,6 +339,7 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
await _capBus.PublishAsync("device.service.postheart", data);
|
await _capBus.PublishAsync("device.service.postheart", data);
|
||||||
return new ResultInfo(ResultState.SUCCESS, "success");
|
return new ResultInfo(ResultState.SUCCESS, "success");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取设备注册信息,第一次开机使用
|
/// 获取设备注册信息,第一次开机使用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -342,6 +375,7 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
}
|
}
|
||||||
return new ResultInfo(ResultState.SUCCESS, "success", data);
|
return new ResultInfo(ResultState.SUCCESS, "success", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int TrashType(string type)
|
private int TrashType(string type)
|
||||||
{
|
{
|
||||||
if (type == "厨余垃圾") return 1;
|
if (type == "厨余垃圾") return 1;
|
||||||
|
|
@ -350,12 +384,14 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
else if (type == "其他垃圾") return 4;
|
else if (type == "其他垃圾") return 4;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetTimestamp(DateTime time)
|
private int GetTimestamp(DateTime time)
|
||||||
{
|
{
|
||||||
DateTime dateTimeStart = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1, 8, 0, 0));
|
DateTime dateTimeStart = TimeZoneInfo.ConvertTimeToUtc(new DateTime(1970, 1, 1, 8, 0, 0));
|
||||||
int timestamp = Convert.ToInt32((time - dateTimeStart).TotalSeconds);
|
int timestamp = Convert.ToInt32((time - dateTimeStart).TotalSeconds);
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 字节数组转16进制
|
/// 字节数组转16进制
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -373,6 +409,7 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
}
|
}
|
||||||
return returnStr;
|
return returnStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新设备版本信息
|
/// 更新设备版本信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -382,6 +419,7 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
{
|
{
|
||||||
await _capBus.PublishAsync("device.service.updatever", data);
|
await _capBus.PublishAsync("device.service.updatever", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 通过ailink wifi模式发送的数据
|
/// 通过ailink wifi模式发送的数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -457,6 +495,7 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
}
|
}
|
||||||
return returndata;
|
return returndata;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// wifi数据解析
|
/// wifi数据解析
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -528,4 +567,4 @@ namespace Waste.Application.ThirdApiInfo
|
||||||
return ((int)bt).ToString("X2");
|
return ((int)bt).ToString("X2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -13,9 +13,9 @@ namespace WasteConsoleTest
|
||||||
private ClientWebSocket ws = null;
|
private ClientWebSocket ws = null;
|
||||||
private Uri uri = null;
|
private Uri uri = null;
|
||||||
private bool isUserClose = false;//是否最后由用户手动关闭
|
private bool isUserClose = false;//是否最后由用户手动关闭
|
||||||
public static string Secret = "ai5ak2Q5TpkOLO4T";
|
public static string Secret = "xsbem33eCm3eCYfP";
|
||||||
public static string SecretHash = "6c29321e21e9c202";
|
public static string SecretHash = "MULpdMXWuiECHK1kngvNgeA/s5DZT3pRsD371nj5EkA=";
|
||||||
public static string deviceid = "08d99b6b-a16f-4a5a-81ad-ffeaa9fdc94e";
|
public static string deviceid = "08d9f5fc-e4d7-44e1-84fd-cd8aac2d7c2d";
|
||||||
|
|
||||||
// <summary>
|
// <summary>
|
||||||
/// WebSocket状态
|
/// WebSocket状态
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue