parent
2c3752fcd4
commit
3ac7466122
|
|
@ -27,3 +27,5 @@
|
|||
/.vs
|
||||
/WasteConsoleTest/WasteConsoleTest/obj
|
||||
/WasteConsoleTest/WasteConsoleTest/bin
|
||||
/Waste.CreateDB/bin/Debug/net5.0
|
||||
/Waste.CreateDB/obj
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Waste.Application.SubscribeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 测量记录
|
||||
/// </summary>
|
||||
public class ResultS2SDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备ID
|
||||
/// </summary>
|
||||
public Guid DeviceId { get; set; }
|
||||
/// <summary>
|
||||
/// 最近使用时间
|
||||
/// </summary>
|
||||
public DateTime? LastHeartTime { get; set; }
|
||||
/// <summary>
|
||||
/// 记录ID
|
||||
/// </summary>
|
||||
public Guid ResultId { get; set; }
|
||||
/// <summary>
|
||||
/// 设备服务商ID
|
||||
/// </summary>
|
||||
public Guid BusinessId { get; set; }
|
||||
/// <summary>
|
||||
/// 设备的IMEI
|
||||
/// </summary>
|
||||
public string imei { get; set; }
|
||||
/// <summary>
|
||||
/// ICCID
|
||||
/// </summary>
|
||||
public string iccid { get; set; }
|
||||
/// <summary>
|
||||
/// IMSI
|
||||
/// </summary>
|
||||
public string imsi { get; set; }
|
||||
/// <summary>
|
||||
/// 纬度
|
||||
/// </summary>
|
||||
public decimal latitude { get; set; }
|
||||
/// <summary>
|
||||
/// 经度
|
||||
/// </summary>
|
||||
public decimal longtitude { get; set; }
|
||||
/// <summary>
|
||||
/// 信号强度
|
||||
/// </summary>
|
||||
public int gslq { get; set; }
|
||||
/// <summary>
|
||||
/// 垃圾类型
|
||||
/// </summary>
|
||||
public string wastetype { get; set; }
|
||||
/// <summary>
|
||||
/// 垃圾桶编号
|
||||
/// </summary>
|
||||
public string trash { get; set; }
|
||||
/// <summary>
|
||||
/// 毛重
|
||||
/// </summary>
|
||||
public string weight { get; set; }
|
||||
/// <summary>
|
||||
/// 皮重
|
||||
/// </summary>
|
||||
public decimal Tare { get; set; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 设备版本信息
|
||||
/// </summary>
|
||||
public class DeviceVerS2SDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备机器码
|
||||
/// </summary>
|
||||
public string ecode { get; set; }
|
||||
/// <summary>
|
||||
/// 版本号
|
||||
/// </summary>
|
||||
public string ver { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Waste.Application.ThirdApiInfo;
|
||||
|
||||
namespace Waste.Application.SubscribeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// CAP订阅相关接口
|
||||
/// </summary>
|
||||
public interface ISubscribeService
|
||||
{
|
||||
/// <summary>
|
||||
/// 添加记录
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
Task InsertResultAsync(ResultS2SDto data);
|
||||
/// <summary>
|
||||
/// 更新记录上报结果
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateStatusAsync(UpdateStatusDto data);
|
||||
/// <summary>
|
||||
/// 更新设备开机信息
|
||||
/// </summary>
|
||||
/// <param name="deviceid"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateRegInfoAsync(Guid deviceid);
|
||||
/// <summary>
|
||||
/// 心跳数据上报
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateHeartInfoAsync(DevHeartRequestDto data);
|
||||
|
||||
/// <summary>
|
||||
/// 更新设备版本信息
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateVersionAsync(DeviceVerS2SDto data);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,228 @@
|
|||
using DotNetCore.CAP;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DistributedIDGenerator;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Waste.Application.ThirdApiInfo;
|
||||
using Waste.Domain;
|
||||
|
||||
namespace Waste.Application.SubscribeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// CAP订阅相关接口
|
||||
/// </summary>
|
||||
public class SubscribeService : ISubscribeService, ICapSubscribe, ITransient
|
||||
{
|
||||
private readonly ISqlSugarRepository<W_Device> repository;
|
||||
private readonly SqlSugarClient dbClient;
|
||||
public SubscribeService(ISqlSugarRepository<W_Device> sqlSugarRepository)
|
||||
{
|
||||
repository = sqlSugarRepository;
|
||||
dbClient = repository.Context;
|
||||
}
|
||||
/// <summary>
|
||||
/// 添加记录
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[CapSubscribe("result.service.insert")]
|
||||
public async Task InsertResultAsync(ResultS2SDto data)
|
||||
{
|
||||
bool isfrist = false;
|
||||
if (data.LastHeartTime.HasValue && data.LastHeartTime.Value.Date != DateTime.Now.Date)
|
||||
{
|
||||
isfrist = true;
|
||||
}
|
||||
await dbClient.Ado.UseStoredProcedure().ExecuteCommandAsync("Proc_InsertResult", new
|
||||
{
|
||||
deviceid = data.DeviceId,
|
||||
businessid = data.BusinessId,
|
||||
resultid = data.ResultId,
|
||||
imei = data.imei,
|
||||
iccid = data.iccid,
|
||||
imsi = data.imsi,
|
||||
time = DateTime.Now,
|
||||
latitude = data.latitude,
|
||||
longitude = data.longtitude,
|
||||
sign = data.gslq,
|
||||
city = "",
|
||||
area = data.trash,
|
||||
wastetype = data.wastetype,
|
||||
weigth = data.weight,
|
||||
isheart = 0,
|
||||
tare = data.Tare,
|
||||
isfrist = isfrist
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 更新记录上报结果
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[CapSubscribe("result.service.update")]
|
||||
public async Task UpdateStatusAsync(UpdateStatusDto data)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 心跳数据上报
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[CapSubscribe("device.service.postheart")]
|
||||
public async Task UpdateHeartInfoAsync(DevHeartRequestDto data)
|
||||
{
|
||||
var device = await dbClient.Queryable<W_Device>().FirstAsync(x => x.Ecode == data.ECode);
|
||||
if (device == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (await dbClient.Queryable<W_DeviceData>().AnyAsync(x => x.DeviceId == device.Id))
|
||||
{
|
||||
//更新设备心跳信息
|
||||
if (data.Latitude == 0 || data.Longitude == 0)
|
||||
{
|
||||
await dbClient.Updateable<W_DeviceData>()
|
||||
.SetColumns(x => new W_DeviceData
|
||||
{
|
||||
LastBeatTime = DateTime.Now
|
||||
})
|
||||
.Where(x => x.DeviceId == device.Id).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
string longitude = data.Longitude.ToString();
|
||||
string Latitude = data.Latitude.ToString();
|
||||
await dbClient.Updateable<W_DeviceData>()
|
||||
.SetColumns(x => new W_DeviceData
|
||||
{
|
||||
LastBeatTime = DateTime.Now,
|
||||
Longitude = longitude,
|
||||
Latitude = Latitude
|
||||
})
|
||||
.Where(x => x.DeviceId == device.Id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var insertdata = new W_DeviceData
|
||||
{
|
||||
DeviceId = device.Id,
|
||||
Sign = data.GSLQ.ToString(),
|
||||
IMSI = data.IMSI,
|
||||
ICCID = data.ICCID,
|
||||
IMEI = data.IMEI,
|
||||
LastBeatTime = DateTime.Now,
|
||||
Latitude = data.Latitude.ToString(),
|
||||
Longitude = data.Longitude.ToString()
|
||||
};
|
||||
await dbClient.Insertable(insertdata).ExecuteCommandAsync();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新设备开机信息
|
||||
/// </summary>
|
||||
/// <param name="deviceid"></param>
|
||||
/// <returns></returns>
|
||||
[CapSubscribe("device.service.update")]
|
||||
public async Task UpdateRegInfoAsync(Guid deviceid)
|
||||
{
|
||||
//更新开机时间
|
||||
if (await dbClient.Queryable<W_DeviceData>().AnyAsync(x => x.DeviceId == deviceid))
|
||||
{
|
||||
await dbClient.Updateable<W_DeviceData>()
|
||||
.SetColumns(x => new W_DeviceData
|
||||
{
|
||||
LastStartTime = DateTime.Now
|
||||
})
|
||||
.Where(x => x.DeviceId == deviceid).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var insertdata = new W_DeviceData
|
||||
{
|
||||
DeviceId = deviceid,
|
||||
Sign = "",
|
||||
IMSI = "",
|
||||
ICCID = "",
|
||||
IMEI = "",
|
||||
Latitude = "0",
|
||||
Longitude = "0",
|
||||
LastStartTime = DateTime.Now
|
||||
};
|
||||
await dbClient.Insertable(insertdata).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新设备版本信息
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
[CapSubscribe("device.service.updatever")]
|
||||
public async Task UpdateVersionAsync(DeviceVerS2SDto data)
|
||||
{
|
||||
var deivce = await dbClient.Queryable<W_Device>().Select(x=>new W_Device { Id=x.Id}).FirstAsync(x => x.Ecode == data.ecode);
|
||||
if(deivce == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
//更新版本号
|
||||
if (await dbClient.Queryable<W_DeviceData>().AnyAsync(x => x.DeviceId == deivce.Id))
|
||||
{
|
||||
await dbClient.Updateable<W_DeviceData>()
|
||||
.SetColumns(x => new W_DeviceData
|
||||
{
|
||||
Version = data.ver
|
||||
})
|
||||
.Where(x => x.DeviceId == deivce.Id).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var insertdata = new W_DeviceData
|
||||
{
|
||||
DeviceId = deivce.Id,
|
||||
Sign = "",
|
||||
IMSI = "",
|
||||
ICCID = "",
|
||||
IMEI = "",
|
||||
Latitude = "0",
|
||||
Longitude = "0",
|
||||
LastStartTime = DateTime.Now,
|
||||
Version = data.ver
|
||||
};
|
||||
await dbClient.Insertable(insertdata).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Waste.Application.SubscribeInfo;
|
||||
|
||||
namespace Waste.Application.ThirdApiInfo
|
||||
{
|
||||
|
|
@ -37,5 +38,11 @@ namespace Waste.Application.ThirdApiInfo
|
|||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
Task<ResultInfo> UpdateStatusAsync(UpdateStatusDto data);
|
||||
/// <summary>
|
||||
/// 更新设备版本信息
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
Task UpdateVersionAsync(DeviceVerS2SDto data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Waste.Application.SubscribeInfo;
|
||||
|
||||
namespace Waste.Application.ThirdApiInfo
|
||||
{
|
||||
|
|
@ -83,7 +84,7 @@ namespace Waste.Application.ThirdApiInfo
|
|||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/reportbug/Post")]
|
||||
public async Task<object> PostAsync([FromQuery]string ecode="")
|
||||
public async Task<object> PostAsync([FromQuery] string ecode = "")
|
||||
{
|
||||
var Request = _httpContextAccessor.HttpContext.Request;
|
||||
//先保存上传的图片
|
||||
|
|
@ -115,7 +116,7 @@ namespace Waste.Application.ThirdApiInfo
|
|||
}
|
||||
else
|
||||
{
|
||||
string[] _permittedExtensions = {};
|
||||
string[] _permittedExtensions = { };
|
||||
long _fileSizeLimit = 1048576 * 10;
|
||||
string rootname = $"/bugs/{DateTime.Now.ToString("yyyyMMdd")}";
|
||||
string savefolder = _hostingEnvironment.WebRootPath;
|
||||
|
|
@ -195,7 +196,7 @@ namespace Waste.Application.ThirdApiInfo
|
|||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
[Route("api/reportbug/postbug")]
|
||||
public object PostBug(BugModel bug)
|
||||
public object PostBug(BugModel bug)
|
||||
{
|
||||
var errmsg = $"机器码:{bug.ecode},位置:{bug.ExceptionPos},信息:{bug.ExceptionInfo}";
|
||||
return new
|
||||
|
|
@ -218,8 +219,13 @@ namespace Waste.Application.ThirdApiInfo
|
|||
[HttpGet]
|
||||
[QueryParameters]
|
||||
[Route("api/upgrade/get")]
|
||||
public async Task<object> GetAsync(string type, string ecode = "",int myver=400)
|
||||
public async Task<object> GetAsync(string type, string ecode = "", int myver = 400)
|
||||
{
|
||||
await _openService.UpdateVersionAsync(new DeviceVerS2SDto
|
||||
{
|
||||
ecode = ecode,
|
||||
ver = myver.ToString()
|
||||
});
|
||||
string rootpath = _hostingEnvironment.WebRootPath;
|
||||
//读取文件,返回升级信息
|
||||
var path = $"{rootpath}/apks/upgrade/{type}.txt";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using Furion;
|
||||
using DotNetCore.CAP;
|
||||
using Furion;
|
||||
using Furion.DependencyInjection;
|
||||
using Furion.DistributedIDGenerator;
|
||||
using Nirvana.Common;
|
||||
|
|
@ -8,6 +9,7 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Waste.Application.SubscribeInfo;
|
||||
using Waste.Domain;
|
||||
|
||||
namespace Waste.Application.ThirdApiInfo
|
||||
|
|
@ -27,12 +29,14 @@ namespace Waste.Application.ThirdApiInfo
|
|||
private readonly SqlSugarClient dbClient;
|
||||
private readonly ISuZhouService _suZhouService;
|
||||
private readonly ILoggerService _loggerService;
|
||||
public OpenService(ISqlSugarRepository<W_Device> sqlSugarRepository, ISuZhouService suZhouService, ILoggerService loggerService)
|
||||
private readonly ICapPublisher _capBus;
|
||||
public OpenService(ISqlSugarRepository<W_Device> sqlSugarRepository, ISuZhouService suZhouService, ILoggerService loggerService, ICapPublisher capPublisher)
|
||||
{
|
||||
repository = sqlSugarRepository;
|
||||
dbClient = repository.Context;
|
||||
_suZhouService = suZhouService;
|
||||
_loggerService = loggerService;
|
||||
_capBus = capPublisher;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新上报状态
|
||||
|
|
@ -41,30 +45,8 @@ namespace Waste.Application.ThirdApiInfo
|
|||
/// <returns></returns>
|
||||
public async Task<ResultInfo> UpdateStatusAsync(UpdateStatusDto data)
|
||||
{
|
||||
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未找到");
|
||||
await _capBus.PublishAsync("result.service.update", data);
|
||||
return new ResultInfo(ResultState.SUCCESS, "success");
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取设备上报相关信息
|
||||
|
|
@ -75,155 +57,97 @@ namespace Waste.Application.ThirdApiInfo
|
|||
{
|
||||
//更新上报记录结果
|
||||
Guid resultid = Guid.Empty;
|
||||
if (!string.IsNullOrEmpty(data.ResultId) && Guid.TryParse(data.ResultId, out resultid))
|
||||
var device = await dbClient.Queryable<W_Device>().FirstAsync(x => x.Ecode == data.ECode);
|
||||
if (device == null)
|
||||
{
|
||||
var device = await dbClient.Queryable<W_Device>().FirstAsync(x => x.Ecode == data.ECode);
|
||||
if (device == null)
|
||||
return new ResultInfo(ResultState.FAIL, "设备未找到");
|
||||
}
|
||||
var returndata = new GetDevInfoResponseDto
|
||||
{
|
||||
ResultId = IDGen.NextID(),
|
||||
UserId = UserId,
|
||||
PostUrl = ApiUrl
|
||||
};
|
||||
var devicesecret = await dbClient.Queryable<W_SZDevice>().FirstAsync(x => x.DeviceId == device.Id);
|
||||
if (devicesecret == null || string.IsNullOrEmpty(devicesecret.Secret)
|
||||
|| string.IsNullOrEmpty(devicesecret.SecretHash)
|
||||
|| string.IsNullOrEmpty(devicesecret.DevId))
|
||||
{
|
||||
return new ResultInfo(ResultState.FAIL, "设备还未获取验证信息");
|
||||
}
|
||||
//解析协议,IC卡数据@垃圾桶编号@厨余垃圾@7.91
|
||||
// 00000000003031 40 0F00010009 40 C6E4CBFBC0ACBBF8 40 31352E39
|
||||
// 00000000003031 40 000F000002 40 C6E4CBFBC0ACBBF8 40 35312E30 0D0A
|
||||
if (!string.IsNullOrEmpty(data.data) && data.data.Length > 52)
|
||||
{
|
||||
data.data = data.data.Replace(" ", "");
|
||||
//收到的为16进制,对数据进行解析,0-4预留,5-垃圾种类,6-垃圾桶大小,7-@,8-12垃圾桶编号,13@,14-21垃圾种类汉字,22@,23-结束重量, OD OA 回车换行
|
||||
data.data = data.data.Substring(0, data.data.Length - 4);
|
||||
var trashhex = data.data.Substring(16, 10); //垃圾桶编号
|
||||
var typehex = data.data.Substring(28, 16); //垃圾种类
|
||||
var sizehex = data.data.Substring(12, 2);//桶大小,30-小桶,31-大桶
|
||||
var weighthex = data.data.Substring(46, data.data.Length - 46);
|
||||
returndata.trash = HextToDec(trashhex).ToString(); //垃圾桶编号使用10进制
|
||||
var type = GetChsFromHex(typehex);
|
||||
var weight = GetChsFromHex(weighthex);
|
||||
returndata.type = TrashType(type);
|
||||
returndata.Weight = weight.ToDouble();
|
||||
//计算净重,毛重-皮重=净重,如果净重小于等于0则不上报保存
|
||||
returndata.Weight = (returndata.Weight - device.Tare.ToDouble()).ToDouble(2);
|
||||
if (returndata.Weight <= 0)
|
||||
{
|
||||
return new ResultInfo(ResultState.FAIL, "设备未找到");
|
||||
_loggerService.AddLogger($"{data.ECode},{device.Name},重量小于等于0:{returndata.ToJson()}", 1);
|
||||
return new ResultInfo(ResultState.FAIL, "无效的重量");
|
||||
}
|
||||
var devicesecret = await dbClient.Queryable<W_SZDevice>().FirstAsync(x => x.DeviceId == device.Id);
|
||||
if (devicesecret == null || string.IsNullOrEmpty(devicesecret.Secret)
|
||||
|| string.IsNullOrEmpty(devicesecret.SecretHash)
|
||||
|| string.IsNullOrEmpty(devicesecret.DevId))
|
||||
//检查是否为15分钟内第一次上报
|
||||
var time15 = DateTime.Now.AddMinutes(-15);
|
||||
if (await dbClient.Queryable<W_DeviceResult>().AnyAsync(x => x.DeviceId == device.Id && x.LastTrash == returndata.trash && x.LastHeartTime > time15))
|
||||
{
|
||||
return new ResultInfo(ResultState.FAIL, "设备还未获取验证信息");
|
||||
_loggerService.AddLogger($"{data.ECode},{device.Name},重复垃圾桶编号的数据:{returndata.ToJson()}", 1);
|
||||
return new ResultInfo(ResultState.FAIL, "15分钟内同一垃圾桶编号上报");
|
||||
}
|
||||
int timestamp = _suZhouService.GetUTCTimestamp();
|
||||
int noncestr = _suZhouService.GetNonce();
|
||||
var result = await dbClient.Queryable<W_Result>().FirstAsync(x => x.Id == resultid);
|
||||
if (result == null)
|
||||
returndata.IsSuccessed = true;
|
||||
//记录数据
|
||||
data.IMEI = data.IMEI.ToStr();
|
||||
data.ICCID = data.ICCID.ToStr();
|
||||
data.IMSI = data.IMSI.ToStr();
|
||||
await _capBus.PublishAsync("result.service.insert", new ResultS2SDto
|
||||
{
|
||||
return new ResultInfo(ResultState.SUCCESS, "记录id未找到");
|
||||
}
|
||||
var returndata = new GetDevInfoResponseDto
|
||||
{
|
||||
DeviceId = devicesecret.DevId,
|
||||
noncestr = noncestr,
|
||||
timestamp = timestamp,
|
||||
Secret = devicesecret.Secret,
|
||||
SecretHash = devicesecret.SecretHash,
|
||||
UserId = UserId,
|
||||
PostUrl = ApiUrl,
|
||||
ScanningTime = timestamp,
|
||||
ResultId = resultid,
|
||||
trash = result.Registration,
|
||||
Weight = result.GrossWeight.ToDouble(),
|
||||
status = 0,
|
||||
IsSuccessed = true,
|
||||
type = TrashType(result.WasteType)
|
||||
};
|
||||
string[] paramlist = new string[] {
|
||||
returndata.Weight.ToString(),returndata.trash,returndata.type.ToString(),returndata.ScanningTime.ToString(),returndata.status.ToString()};
|
||||
returndata.sign = _suZhouService.GetUserApiSign(returndata.Secret, paramlist);
|
||||
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
|
||||
BusinessId = device.Businessid,
|
||||
DeviceId = device.Id,
|
||||
gslq = data.GSLQ,
|
||||
iccid = data.ICCID,
|
||||
imei = data.IMEI,
|
||||
imsi = data.IMSI,
|
||||
LastHeartTime = device.LastHeartTime,
|
||||
latitude = data.Latitude,
|
||||
longtitude = data.Longitude,
|
||||
ResultId = returndata.ResultId,
|
||||
Tare = device.Tare,
|
||||
trash = returndata.trash,
|
||||
wastetype = type,
|
||||
weight = weight
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
var device = await dbClient.Queryable<W_Device>().FirstAsync(x => x.Ecode == data.ECode);
|
||||
if (device == null)
|
||||
{
|
||||
return new ResultInfo(ResultState.FAIL, "设备未找到");
|
||||
}
|
||||
var returndata = new GetDevInfoResponseDto
|
||||
{
|
||||
ResultId = IDGen.NextID(),
|
||||
UserId = UserId,
|
||||
PostUrl = ApiUrl
|
||||
};
|
||||
//解析协议,IC卡数据@垃圾桶编号@厨余垃圾@7.91
|
||||
// 00000000003031 40 0F00010009 40 C6E4CBFBC0ACBBF8 40 31352E39
|
||||
// 00000000003031 40 000F000002 40 C6E4CBFBC0ACBBF8 40 35312E30 0D0A
|
||||
if (!string.IsNullOrEmpty(data.data) && data.data.Length > 52)
|
||||
{
|
||||
data.data = data.data.Replace(" ", "");
|
||||
//收到的为16进制,对数据进行解析,0-4预留,5-垃圾种类,6-垃圾桶大小,7-@,8-12垃圾桶编号,13@,14-21垃圾种类汉字,22@,23-结束重量, OD OA 回车换行
|
||||
data.data = data.data.Substring(0, data.data.Length - 4);
|
||||
var trashhex = data.data.Substring(16, 10); //垃圾桶编号
|
||||
var typehex = data.data.Substring(28, 16); //垃圾种类
|
||||
var sizehex = data.data.Substring(12, 2);//桶大小,30-小桶,31-大桶
|
||||
var weighthex = data.data.Substring(46, data.data.Length - 46);
|
||||
returndata.trash = HextToDec(trashhex).ToString(); //垃圾桶编号使用10进制
|
||||
var type = GetChsFromHex(typehex);
|
||||
var weight = GetChsFromHex(weighthex);
|
||||
returndata.type = TrashType(type);
|
||||
returndata.Weight = weight.ToDouble();
|
||||
//计算净重,毛重-皮重=净重,如果净重小于等于0则不上报保存
|
||||
returndata.Weight = (returndata.Weight - device.Tare.ToDouble()).ToDouble(2);
|
||||
if (returndata.Weight <= 0)
|
||||
{
|
||||
_loggerService.AddLogger($"重量小于等于0:{returndata.ToJson()}", 1);
|
||||
return new ResultInfo(ResultState.FAIL, "无效的重量");
|
||||
}
|
||||
//检查是否为15分钟内第一次上报
|
||||
var time15 = DateTime.Now.AddMinutes(-15);
|
||||
if (await dbClient.Queryable<W_Result>().AnyAsync(x => x.DeviceId == device.Id && x.Registration == returndata.trash && x.CreateTime > time15))
|
||||
{
|
||||
_loggerService.AddLogger($"重复垃圾桶编号的数据:{returndata.ToJson()}", 1);
|
||||
return new ResultInfo(ResultState.FAIL, "15分钟内同一垃圾桶编号上报");
|
||||
}
|
||||
returndata.IsSuccessed = true;
|
||||
//保存测量结果
|
||||
var devicedata = await dbClient.Queryable<W_DeviceData>().FirstAsync(x => x.DeviceId == device.Id);
|
||||
DateTime time = DateTime.Now;
|
||||
//检查设备是否为今天第一次上报
|
||||
bool isfrist = false;
|
||||
if (device.LastHeartTime.HasValue && device.LastHeartTime.Value.Date != DateTime.Now.Date)
|
||||
{
|
||||
isfrist = true;
|
||||
}
|
||||
//记录数据
|
||||
data.IMEI = data.IMEI.ToStr();
|
||||
data.ICCID = data.ICCID.ToStr();
|
||||
data.IMSI = data.IMSI.ToStr();
|
||||
await dbClient.Ado.UseStoredProcedure().ExecuteCommandAsync("Proc_InsertResult", new
|
||||
{
|
||||
deviceid = device.Id,
|
||||
businessid = device.Businessid,
|
||||
resultid = returndata.ResultId,
|
||||
imei = data.IMEI,
|
||||
iccid = data.ICCID,
|
||||
imsi = data.IMSI,
|
||||
time = time,
|
||||
latitude = data.Latitude,
|
||||
longitude = data.Longitude,
|
||||
sign = data.GSLQ,
|
||||
city = "",
|
||||
area = returndata.trash,
|
||||
wastetype = type,
|
||||
weigth = weight,
|
||||
isheart = 0,
|
||||
tare = device.Tare,
|
||||
isfrist = isfrist
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_loggerService.AddLogger($"协议格式不正确:{data.ToJson()}", 1);
|
||||
return new ResultInfo(ResultState.FAIL, "协议格式不正确");
|
||||
}
|
||||
var devicesecret = await dbClient.Queryable<W_SZDevice>().FirstAsync(x => x.DeviceId == device.Id);
|
||||
if (devicesecret == null || string.IsNullOrEmpty(devicesecret.Secret)
|
||||
|| string.IsNullOrEmpty(devicesecret.SecretHash)
|
||||
|| string.IsNullOrEmpty(devicesecret.DevId))
|
||||
{
|
||||
return new ResultInfo(ResultState.FAIL, "设备还未获取验证信息");
|
||||
}
|
||||
int timestamp = _suZhouService.GetUTCTimestamp();
|
||||
int noncestr = _suZhouService.GetNonce();
|
||||
returndata.DeviceId = devicesecret.DevId;
|
||||
returndata.noncestr = noncestr;
|
||||
returndata.timestamp = timestamp;
|
||||
returndata.Secret = devicesecret.Secret;
|
||||
returndata.SecretHash = devicesecret.SecretHash;
|
||||
returndata.ScanningTime = timestamp;
|
||||
string[] paramlist = new string[] {
|
||||
_loggerService.AddLogger($"{data.ECode},{device.Name},协议格式不正确:{data.ToJson()}", 1);
|
||||
return new ResultInfo(ResultState.FAIL, "协议格式不正确");
|
||||
}
|
||||
int timestamp = _suZhouService.GetUTCTimestamp();
|
||||
int noncestr = _suZhouService.GetNonce();
|
||||
returndata.DeviceId = devicesecret.DevId;
|
||||
returndata.noncestr = noncestr;
|
||||
returndata.timestamp = timestamp;
|
||||
returndata.Secret = devicesecret.Secret;
|
||||
returndata.SecretHash = devicesecret.SecretHash;
|
||||
returndata.ScanningTime = timestamp;
|
||||
string[] paramlist = new string[] {
|
||||
returndata.Weight.ToString(),returndata.trash,returndata.type.ToString(),returndata.ScanningTime.ToString(),returndata.status.ToString()
|
||||
};
|
||||
returndata.sign = _suZhouService.GetUserApiSign(returndata.Secret, paramlist);
|
||||
_loggerService.AddLogger($"发送的数据:{returndata.ToJson()}", 1);
|
||||
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
|
||||
}
|
||||
returndata.sign = _suZhouService.GetUserApiSign(returndata.Secret, paramlist);
|
||||
_loggerService.AddLogger($"{data.ECode},{device.Name},发送的数据:{returndata.ToJson()}", 1);
|
||||
return new ResultInfo(ResultState.SUCCESS, "success", returndata);
|
||||
}
|
||||
/// <summary>
|
||||
/// 16进制转汉字
|
||||
|
|
@ -314,52 +238,11 @@ namespace Waste.Application.ThirdApiInfo
|
|||
/// <returns></returns>
|
||||
public async Task<ResultInfo> PostHeartAsync(DevHeartRequestDto data)
|
||||
{
|
||||
var device = await dbClient.Queryable<W_Device>().FirstAsync(x => x.Ecode == data.ECode);
|
||||
if (device == null)
|
||||
if (!await dbClient.Queryable<W_Device>().AnyAsync(x => x.Ecode == data.ECode))
|
||||
{
|
||||
return new ResultInfo(ResultState.FAIL, "设备未找到");
|
||||
}
|
||||
if (await dbClient.Queryable<W_DeviceData>().AnyAsync(x => x.DeviceId == device.Id))
|
||||
{
|
||||
//更新设备心跳信息
|
||||
if (data.Latitude == 0 || data.Longitude == 0)
|
||||
{
|
||||
await dbClient.Updateable<W_DeviceData>()
|
||||
.SetColumns(x => new W_DeviceData
|
||||
{
|
||||
LastBeatTime = DateTime.Now
|
||||
})
|
||||
.Where(x => x.DeviceId == device.Id).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
string longitude = data.Longitude.ToString();
|
||||
string Latitude = data.Latitude.ToString();
|
||||
await dbClient.Updateable<W_DeviceData>()
|
||||
.SetColumns(x => new W_DeviceData
|
||||
{
|
||||
LastBeatTime = DateTime.Now,
|
||||
Longitude = longitude,
|
||||
Latitude = Latitude
|
||||
})
|
||||
.Where(x => x.DeviceId == device.Id).ExecuteCommandAsync();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var insertdata = new W_DeviceData
|
||||
{
|
||||
DeviceId = device.Id,
|
||||
Sign = data.GSLQ.ToString(),
|
||||
IMSI = data.IMSI,
|
||||
ICCID = data.ICCID,
|
||||
IMEI = data.IMEI,
|
||||
LastBeatTime = DateTime.Now,
|
||||
Latitude = data.Latitude.ToString(),
|
||||
Longitude = data.Longitude.ToString()
|
||||
};
|
||||
await dbClient.Insertable(insertdata).ExecuteCommandAsync();
|
||||
}
|
||||
await _capBus.PublishAsync("device.service.postheart", data);
|
||||
return new ResultInfo(ResultState.SUCCESS, "success");
|
||||
}
|
||||
/// <summary>
|
||||
|
|
@ -375,30 +258,8 @@ namespace Waste.Application.ThirdApiInfo
|
|||
return new ResultInfo(ResultState.FAIL, "设备未找到", new DevRegInfoResponseDto());
|
||||
}
|
||||
//更新开机时间
|
||||
if (await dbClient.Queryable<W_DeviceData>().AnyAsync(x => x.DeviceId == device.Id))
|
||||
{
|
||||
await dbClient.Updateable<W_DeviceData>()
|
||||
.SetColumns(x => new W_DeviceData
|
||||
{
|
||||
LastStartTime = DateTime.Now
|
||||
})
|
||||
.Where(x => x.DeviceId == device.Id).ExecuteCommandAsync();
|
||||
}
|
||||
else
|
||||
{
|
||||
var insertdata = new W_DeviceData
|
||||
{
|
||||
DeviceId = device.Id,
|
||||
Sign = "",
|
||||
IMSI = "",
|
||||
ICCID = "",
|
||||
IMEI = "",
|
||||
Latitude = "0",
|
||||
Longitude = "0",
|
||||
LastStartTime = DateTime.Now
|
||||
};
|
||||
await dbClient.Insertable(insertdata).ExecuteCommandAsync();
|
||||
}
|
||||
await _capBus.PublishAsync("device.service.update", device.Id);
|
||||
|
||||
var data = new DevRegInfoResponseDto
|
||||
{
|
||||
status = 0,
|
||||
|
|
@ -450,5 +311,14 @@ namespace Waste.Application.ThirdApiInfo
|
|||
}
|
||||
return returnStr;
|
||||
}
|
||||
/// <summary>
|
||||
/// 更新设备版本信息
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public async Task UpdateVersionAsync(DeviceVerS2SDto data)
|
||||
{
|
||||
await _capBus.PublishAsync("device.service.updatever", data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1701,6 +1701,176 @@
|
|||
<param name="role"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.SubscribeInfo.ResultS2SDto">
|
||||
<summary>
|
||||
测量记录
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.DeviceId">
|
||||
<summary>
|
||||
设备ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.LastHeartTime">
|
||||
<summary>
|
||||
最近使用时间
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.ResultId">
|
||||
<summary>
|
||||
记录ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.BusinessId">
|
||||
<summary>
|
||||
设备服务商ID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.imei">
|
||||
<summary>
|
||||
设备的IMEI
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.iccid">
|
||||
<summary>
|
||||
ICCID
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.imsi">
|
||||
<summary>
|
||||
IMSI
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.latitude">
|
||||
<summary>
|
||||
纬度
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.longtitude">
|
||||
<summary>
|
||||
经度
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.gslq">
|
||||
<summary>
|
||||
信号强度
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.wastetype">
|
||||
<summary>
|
||||
垃圾类型
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.trash">
|
||||
<summary>
|
||||
垃圾桶编号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.weight">
|
||||
<summary>
|
||||
毛重
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.ResultS2SDto.Tare">
|
||||
<summary>
|
||||
皮重
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.SubscribeInfo.DeviceVerS2SDto">
|
||||
<summary>
|
||||
设备版本信息
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.DeviceVerS2SDto.ecode">
|
||||
<summary>
|
||||
设备机器码
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Waste.Application.SubscribeInfo.DeviceVerS2SDto.ver">
|
||||
<summary>
|
||||
版本号
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Waste.Application.SubscribeInfo.ISubscribeService">
|
||||
<summary>
|
||||
CAP订阅相关接口
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.ISubscribeService.InsertResultAsync(Waste.Application.SubscribeInfo.ResultS2SDto)">
|
||||
<summary>
|
||||
添加记录
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.ISubscribeService.UpdateStatusAsync(Waste.Application.ThirdApiInfo.UpdateStatusDto)">
|
||||
<summary>
|
||||
更新记录上报结果
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.ISubscribeService.UpdateRegInfoAsync(System.Guid)">
|
||||
<summary>
|
||||
更新设备开机信息
|
||||
</summary>
|
||||
<param name="deviceid"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.ISubscribeService.UpdateHeartInfoAsync(Waste.Application.ThirdApiInfo.DevHeartRequestDto)">
|
||||
<summary>
|
||||
心跳数据上报
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.ISubscribeService.UpdateVersionAsync(Waste.Application.SubscribeInfo.DeviceVerS2SDto)">
|
||||
<summary>
|
||||
更新设备版本信息
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.SubscribeInfo.SubscribeService">
|
||||
<summary>
|
||||
CAP订阅相关接口
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.SubscribeService.InsertResultAsync(Waste.Application.SubscribeInfo.ResultS2SDto)">
|
||||
<summary>
|
||||
添加记录
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.SubscribeService.UpdateStatusAsync(Waste.Application.ThirdApiInfo.UpdateStatusDto)">
|
||||
<summary>
|
||||
更新记录上报结果
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.SubscribeService.UpdateHeartInfoAsync(Waste.Application.ThirdApiInfo.DevHeartRequestDto)">
|
||||
<summary>
|
||||
心跳数据上报
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.SubscribeService.UpdateRegInfoAsync(System.Guid)">
|
||||
<summary>
|
||||
更新设备开机信息
|
||||
</summary>
|
||||
<param name="deviceid"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.SubscribeInfo.SubscribeService.UpdateVersionAsync(Waste.Application.SubscribeInfo.DeviceVerS2SDto)">
|
||||
<summary>
|
||||
更新设备版本信息
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.CityListModel">
|
||||
<summary>
|
||||
地址列表
|
||||
|
|
@ -2235,6 +2405,13 @@
|
|||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.ThirdApiInfo.IOpenService.UpdateVersionAsync(Waste.Application.SubscribeInfo.DeviceVerS2SDto)">
|
||||
<summary>
|
||||
更新设备版本信息
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="T:Waste.Application.ThirdApiInfo.OpenAppService">
|
||||
<summary>
|
||||
开放数据
|
||||
|
|
@ -2350,6 +2527,13 @@
|
|||
<param name="bt"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.ThirdApiInfo.OpenService.UpdateVersionAsync(Waste.Application.SubscribeInfo.DeviceVerS2SDto)">
|
||||
<summary>
|
||||
更新设备版本信息
|
||||
</summary>
|
||||
<param name="data"></param>
|
||||
<returns></returns>
|
||||
</member>
|
||||
<member name="M:Waste.Application.IWasteService.GetTypeListAsync(Nirvana.Common.QueryParams)">
|
||||
<summary>
|
||||
垃圾分类列表
|
||||
|
|
|
|||
|
|
@ -15,11 +15,14 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Furion" Version="2.18.7" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="2.18.7" />
|
||||
<PackageReference Include="Furion.Extras.DatabaseAccessor.SqlSugar" Version="2.18.7" />
|
||||
<PackageReference Include="Furion.Extras.Logging.Serilog" Version="2.18.7" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="2.18.7" />
|
||||
<PackageReference Include="DotNetCore.CAP" Version="5.1.4" />
|
||||
<PackageReference Include="DotNetCore.CAP.RabbitMQ" Version="5.1.4" />
|
||||
<PackageReference Include="DotNetCore.CAP.SqlServer" Version="5.1.4" />
|
||||
<PackageReference Include="Furion" Version="2.19.1" />
|
||||
<PackageReference Include="Furion.Extras.Authentication.JwtBearer" Version="2.19.1" />
|
||||
<PackageReference Include="Furion.Extras.DatabaseAccessor.SqlSugar" Version="2.19.1" />
|
||||
<PackageReference Include="Furion.Extras.Logging.Serilog" Version="2.19.1" />
|
||||
<PackageReference Include="Furion.Extras.ObjectMapper.Mapster" Version="2.19.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Waste.CreateDB
|
||||
{
|
||||
public class CreateTable
|
||||
{
|
||||
public SqlSugarClient Db;
|
||||
public CreateTable()
|
||||
{
|
||||
Db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = "Server=123.60.2.99,4331;Database=waste;uid=jutian_user;pwd=jutian1qaz@WSX;",
|
||||
DbType = DbType.SqlServer,//设置数据库类型
|
||||
IsAutoCloseConnection = true,//自动释放数据库,如果存在事务,在事务结束之后释放。
|
||||
InitKeyType = InitKeyType.Attribute//从实体特性中读取主键自增列信息
|
||||
});
|
||||
Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql + "\r\n" + Db.Utilities.SerializeObject
|
||||
(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||
Console.WriteLine();
|
||||
};
|
||||
}
|
||||
|
||||
public void Create(bool Backup = false, int StringDefaultLength = 50, params Type[] types)
|
||||
{
|
||||
// Db.CodeFirst.SetStringDefaultLength(StringDefaultLength);
|
||||
Db.DbMaintenance.CreateDatabase();
|
||||
if (Backup)
|
||||
{
|
||||
Db.CodeFirst.BackupTable().InitTables(types);
|
||||
}
|
||||
else
|
||||
{
|
||||
Db.CodeFirst.InitTables(types);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
using System;
|
||||
using Waste.Domain;
|
||||
|
||||
namespace Waste.CreateDB
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Console.WriteLine("开始创建表!");
|
||||
var context = new CreateTable();
|
||||
context.Create(false, 50,
|
||||
typeof(W_DeviceData),
|
||||
typeof(W_DeviceResult)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SqlSugarCore" Version="5.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Waste.Domain\Waste.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
@ -1,71 +1,71 @@
|
|||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace Waste.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备信息
|
||||
/// </summary>
|
||||
[SugarTable("W_DeviceData", TableDescription = "设备信息", IsDisabledUpdateAll = false, IsDisabledDelete = true)]
|
||||
public class W_DeviceData
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备信息
|
||||
/// </summary>
|
||||
public W_DeviceData()
|
||||
{
|
||||
}
|
||||
|
||||
private System.Guid _DeviceId;
|
||||
/// <summary>
|
||||
///
|
||||
/// 设备ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public System.Guid DeviceId { get { return this._DeviceId; } set { this._DeviceId = value; } }
|
||||
public Guid DeviceId { get; set; }
|
||||
|
||||
private System.String _ICCID;
|
||||
/// <summary>
|
||||
/// ICCID
|
||||
/// </summary>
|
||||
public System.String ICCID { get { return this._ICCID; } set { this._ICCID = value?.Trim(); } }
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "ICCID")]
|
||||
public string ICCID { get; set; }
|
||||
|
||||
private System.String _IMEI;
|
||||
/// <summary>
|
||||
/// IMEI
|
||||
/// </summary>
|
||||
public System.String IMEI { get { return this._IMEI; } set { this._IMEI = value?.Trim(); } }
|
||||
private System.String _IMSI;
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "IMEI")]
|
||||
public string IMEI { get; set; }
|
||||
/// <summary>
|
||||
/// SIM卡IMSI
|
||||
/// </summary>
|
||||
public System.String IMSI { get { return this._IMSI; } set { this._IMSI = value?.Trim(); } }
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "SIM卡IMSI")]
|
||||
public string IMSI { get; set; }
|
||||
|
||||
private System.String _Longitude;
|
||||
/// <summary>
|
||||
/// 经度
|
||||
/// </summary>
|
||||
public System.String Longitude { get { return this._Longitude; } set { this._Longitude = value?.Trim(); } }
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "经度")]
|
||||
public string Longitude { get; set; }
|
||||
|
||||
private System.String _Latitude;
|
||||
/// <summary>
|
||||
/// 纬度
|
||||
/// </summary>
|
||||
public System.String Latitude { get { return this._Latitude; } set { this._Latitude = value?.Trim(); } }
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "纬度")]
|
||||
public string Latitude { get; set; }
|
||||
|
||||
private System.DateTime? _LastBeatTime;
|
||||
/// <summary>
|
||||
/// 最近心跳时间
|
||||
/// </summary>
|
||||
public System.DateTime? LastBeatTime { get { return this._LastBeatTime; } set { this._LastBeatTime = value; } }
|
||||
[SugarColumn(IsNullable =true, ColumnDescription = "最近心跳时间")]
|
||||
public DateTime? LastBeatTime { get; set; }
|
||||
|
||||
private System.DateTime? _LastStartTime;
|
||||
/// <summary>
|
||||
/// 最近开机时间
|
||||
/// </summary>
|
||||
public System.DateTime? LastStartTime { get { return this._LastStartTime; } set { this._LastStartTime = value; } }
|
||||
[SugarColumn(IsNullable =true, ColumnDescription = "最近开机时间")]
|
||||
public DateTime? LastStartTime { get; set; }
|
||||
|
||||
private System.String _Sign;
|
||||
/// <summary>
|
||||
/// 信号强度
|
||||
/// </summary>
|
||||
public System.String Sign { get { return this._Sign; } set { this._Sign = value?.Trim(); } }
|
||||
[SugarColumn(ColumnDataType = "varchar(100)", ColumnDescription = "信号强度")]
|
||||
public string Sign { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设备最新的app版本号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "设备最新的app版本号", IsNullable =true)]
|
||||
public string Version { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace Waste.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备测量有关数据
|
||||
/// </summary>
|
||||
[SugarTable("W_DeviceResult", TableDescription = "设备测量有关数据", IsDisabledUpdateAll = false, IsDisabledDelete = true)]
|
||||
public class W_DeviceResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public Guid DeviceId { get; set; }
|
||||
/// <summary>
|
||||
/// 最近使用的垃圾桶编号
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = "varchar(50)", ColumnDescription = "最近使用的垃圾桶编号")]
|
||||
public string LastTrash { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最近使用时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "最近使用时间")]
|
||||
public DateTime LastHeartTime { get; set; }
|
||||
/// <summary>
|
||||
/// 最近的记录ID
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "最近的记录ID")]
|
||||
public Guid ResultId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,7 @@ using Microsoft.Extensions.DependencyInjection;
|
|||
using Microsoft.Extensions.Hosting;
|
||||
using Nirvana.Common;
|
||||
using Serilog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
|
@ -21,6 +22,7 @@ namespace Waste.Web.Core
|
|||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
var configuration = App.Configuration;
|
||||
services.AddSession();//使用Session
|
||||
//services.AddJwt<JwtHandler>(options =>
|
||||
//{
|
||||
|
|
@ -30,6 +32,22 @@ namespace Waste.Web.Core
|
|||
services.AddCorsAccessor();
|
||||
// services.AddRemoteRequest();
|
||||
services.AddHttpClient();
|
||||
|
||||
//添加CAP
|
||||
services.AddCap(x => {
|
||||
//配置rabbitmq支持
|
||||
string port = configuration["RabbitmqSetting:Port"];
|
||||
int p = Convert.ToInt32(port);
|
||||
x.UseRabbitMQ(opt => {
|
||||
opt.HostName = configuration["RabbitmqSetting:HostName"]; //配置ip地址
|
||||
opt.Port = p;//配置端口
|
||||
opt.UserName = configuration["RabbitmqSetting:UserName"];//配置用户名
|
||||
opt.Password = configuration["RabbitmqSetting:Password"];//配置Miami
|
||||
});
|
||||
//配置sqlserver支持
|
||||
x.UseSqlServer(configuration["RabbitmqSetting:DBConnection"]);
|
||||
});
|
||||
|
||||
services.AddControllers(options => {
|
||||
options.EnableEndpointRouting = true;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
@page
|
||||
@model Waste.Web.Entry.Pages.Device.DetailModel
|
||||
@{
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace Waste.Web.Entry.Pages.Device
|
||||
{
|
||||
public class DetailModel : BaseModel
|
||||
{
|
||||
public void OnGet()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,7 @@
|
|||
</div>
|
||||
<script type="text/html" id="optpl">
|
||||
<a href="#" class="js-edit" title="编辑" data-id="{{d.id}}">编辑</a>
|
||||
<a href="#" class="js-detail" title="详情" data-id="{{d.id}}">详情</a>
|
||||
</script>
|
||||
<script type="text/html" id="lefttoolbar">
|
||||
<button class="btn btn-primary btn-lg" lay-event="js-fenpei">分配</button>
|
||||
|
|
@ -182,7 +183,7 @@
|
|||
}
|
||||
,
|
||||
{
|
||||
field: 'sign', title: '信号强度', templet: "#signtpl"
|
||||
field: 'sign', title: '信号强度', templet: "#signtpl", hide: true
|
||||
}
|
||||
,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,6 +50,13 @@
|
|||
"ApiSecretHash": "3f907fe05acb58c6",
|
||||
"SocketUrl": "wss://api.device.suzhou.ljflytjl.cn/device_rpc"
|
||||
},
|
||||
"RabbitmqSetting": { //rabbitmq配置
|
||||
"HostName": "localhost",
|
||||
"Port": 5672,
|
||||
"UserName": "liuzl",
|
||||
"Password": "liuzl",
|
||||
"DBConnection": "Server=123.60.2.99,4331;Database=waste;uid=jutian_user;pwd=jutian1qaz@WSX;" //数据保存库
|
||||
},
|
||||
"IsTask": "false", //定时任务是否开启
|
||||
"SoftName": "巨鼎物联网数字平台", //软件名称
|
||||
"SecureKey": "ybhdmob_waste_2021",
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Waste.MessageHandler", "Was
|
|||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WasteConsoleTest", "WasteConsoleTest\WasteConsoleTest\WasteConsoleTest.csproj", "{AB59B811-AADC-439B-9394-73CFF8F64C6F}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "3、数据库初始化", "3、数据库初始化", "{114F03F7-2D58-4BBE-B91A-CBB9F3DC12A0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Waste.CreateDB", "Waste.CreateDB\Waste.CreateDB.csproj", "{D722D30A-DB79-41C7-A377-0864E42E7AF1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -73,6 +77,10 @@ Global
|
|||
{AB59B811-AADC-439B-9394-73CFF8F64C6F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{AB59B811-AADC-439B-9394-73CFF8F64C6F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{AB59B811-AADC-439B-9394-73CFF8F64C6F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{D722D30A-DB79-41C7-A377-0864E42E7AF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{D722D30A-DB79-41C7-A377-0864E42E7AF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{D722D30A-DB79-41C7-A377-0864E42E7AF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{D722D30A-DB79-41C7-A377-0864E42E7AF1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
@ -88,6 +96,7 @@ Global
|
|||
{82C5EF90-C84C-4A83-A732-B82E0E429BDF} = {A10953C4-FF58-42A1-AAEF-7B68018F5EDB}
|
||||
{49EB30D4-FEB7-42FB-87A1-BE0440413392} = {A10953C4-FF58-42A1-AAEF-7B68018F5EDB}
|
||||
{AB59B811-AADC-439B-9394-73CFF8F64C6F} = {A10953C4-FF58-42A1-AAEF-7B68018F5EDB}
|
||||
{D722D30A-DB79-41C7-A377-0864E42E7AF1} = {114F03F7-2D58-4BBE-B91A-CBB9F3DC12A0}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {086B267B-9152-4816-8D48-30032ACB8A2C}
|
||||
|
|
|
|||
Loading…
Reference in New Issue