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