Compare commits

...

11 Commits

@ -1 +1 @@
start "lansheng" cmd /k docker build -f Lansheng\LanShengAPI\Dockerfile -t lansheng:latest .
start "lansheng" cmd /k docker build -f Lansheng\LanShengAPI\Dockerfile -t lansheng:1.0.2 .

@ -103,11 +103,11 @@ namespace LanShengAPI.Controllers
[HttpGet("DeviceErrorList")]
public async Task<ActionResult> DeviceErrorList()
public async Task<ActionResult> DeviceErrorList([FromQuery] string search = "")
{
try
{
return Ok(await DeviceService.GetErrorList());
return Ok(await DeviceService.GetErrorList(search));
}
catch (BadRequestException ex)
{

@ -8,7 +8,7 @@
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5048"
"applicationUrl": "http://localhost:5000"
},
"IIS Express": {
"commandName": "IISExpress",

@ -5,6 +5,9 @@
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"Default": "Data Source=124.71.176.44;database=lsdb;User Id=root;Pwd=root;charset=utf8;pooling=true;"
},
"DotNetty": {
"Use": "Y",
"ThreadPool": 8,

@ -39,6 +39,6 @@ namespace LanShengInterface
/// <returns></returns>
Task<DeviceErrorReport> GetDeviceErrorReport(DeviceErrorReport report);
Task<IEnumerable<DeviceError>> GetErrorList();
Task<IEnumerable<DeviceError>> GetErrorList(string search);
}
}

@ -190,6 +190,18 @@ namespace LanShengModel
[SugarColumn(IsNullable = true)]
public int? Data13 { get; set; }
/// <summary>
/// 进料门接触器 0断开 1吸合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data13_B7 { get; set; }
/// <summary>
/// 出料门接触器 0断开 1吸合
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data13_B6 { get; set; }
/// <summary>
/// 一体机操作模式1智能模式2笼顶操作3防坠测试
/// </summary>
@ -293,7 +305,7 @@ namespace LanShengModel
public int? Data16_B4 { get; set; }
/// <summary>
/// 门机控制 0无1进料门2出料门
/// 手动选择 0无1进料门2出料门
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data16_B2 { get; set; }
@ -448,6 +460,12 @@ namespace LanShengModel
[SugarColumn(Length = 50, IsNullable = true)]
public string? ICCID { get; set; }
/// <summary>
/// 外召盒GPS编号
/// </summary>
[SugarColumn(Length = 50, IsNullable = true)]
public string? WZGPS { get; set; }
/// <summary>
/// 东经
/// </summary>
@ -499,9 +517,626 @@ namespace LanShengModel
[SugarColumn(IsNullable = true,IsOnlyIgnoreInsert = true,DefaultValue = "0")]
public int? RunCount { get; set; }
/// <summary>
/// 更新版本号
/// </summary>
[SugarColumn(IsNullable = true)]
public int? UVersion { get; set; }
/// <summary>
/// FTP地址长度
/// </summary>
[SugarColumn(IsNullable = true)]
public int? FtpLength { get; set; }
/// <summary>
/// FTP地址
/// </summary>
[SugarColumn(IsNullable = true)]
public string? FtpUrl { get; set; }
/// <summary>
/// 用户密码长度
/// </summary>
[SugarColumn(IsNullable = true)]
public int? UserLength { get; set; }
/// <summary>
/// 用户密码
/// </summary>
[SugarColumn(IsNullable = true)]
public string? UserPwd { get; set; }
/// <summary>
/// Bin地址长度
/// </summary>
[SugarColumn(IsNullable = true)]
public int? BinLength { get; set; }
/// <summary>
/// Bin地址
/// </summary>
[SugarColumn(IsNullable = true)]
public string? BinUrl { get; set; }
/// <summary>
/// Bin文件大小
/// </summary>
[SugarColumn(IsNullable = true)]
public int? BinSize { get; set; }
/// <summary>
/// 更新时间范围
/// </summary>
[SugarColumn(IsNullable = true)]
public int? UpdateSpan { get; set; }
/// <summary>
/// 外召主机通讯
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data16_B5_N { get; set; }
/// <summary>
/// 进料门上光电(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data19_B7 { get; set; }
/// <summary>
/// 出料门上光电(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data19_B6 { get; set; }
/// <summary>
/// 上行通道检测限位(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data19_B5 { get; set; }
/// <summary>
/// 下行通道检测限位(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data19_B4 { get; set; }
/// <summary>
/// 预留1限位(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data19_B3 { get; set; }
/// <summary>
/// 预留2限位(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data19_B2 { get; set; }
/// <summary>
/// 预留3限位(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data19_B1 { get; set; }
/// <summary>
/// 左右笼设置 0左笼 1右笼
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data28_B7 { get; set; }
/// <summary>
/// 中间B1楼层开关 0无B1层 1有B1层
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data28_B6 { get; set; }
/// <summary>
/// 中途位置丢失功能 0不动作 1自动到1楼
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data28_B5 { get; set; }
/// <summary>
/// 中途位置丢失自动到1楼高速开关 0不使能高速 1使能笼顶高速
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data28_B4 { get; set; }
/// <summary>
/// 自动下降开关 0关闭 1开启
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data28_B3 { get; set; }
/// <summary>
/// 满载直驶人数限制开关 0关闭 1开启
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data28_B2 { get; set; }
/// <summary>
/// 满载直驶重量限制开关 0关闭 1开启
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data28_B1 { get; set; }
/// <summary>
/// 货运模式开关 0关闭 1开启
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data28_B0 { get; set; }
/// <summary>
/// 预留
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data29_B7 { get; set; }
/// <summary>
/// 进料门光幕屏蔽 0不屏蔽 1屏蔽
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data29_B6 { get; set; }
/// <summary>
/// 出料门光幕屏蔽 0不屏蔽 1屏蔽
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data29_B5 { get; set; }
/// <summary>
/// 上行通道检测屏蔽 0不屏蔽 1屏蔽
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data29_B4 { get; set; }
/// <summary>
/// 下行通道检测屏蔽 0不屏蔽 1屏蔽
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data29_B3 { get; set; }
/// <summary>
/// 楼栋号
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data30 { get; set; }
/// <summary>
/// USR207模块信道
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data31 { get; set; }
/// <summary>
/// USR207模块目标地址
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data32_33 { get; set; }
/// <summary>
/// USR207模块速率
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data34 { get; set; }
/// <summary>
/// USR207模块前向纠错
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data35 { get; set; }
/// <summary>
/// 关门后运行等待时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data36 { get; set; }
/// <summary>
/// 停机后运行等待时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data37 { get; set; }
/// <summary>
/// 一体机开门超时时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data38_39 { get; set; }
/// <summary>
/// 吊笼内限制人数
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data40 { get; set; }
/// <summary>
/// 自动下降楼层
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data41 { get; set; }
/// <summary>
/// 自动下降等待时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data42_43 { get; set; }
/// <summary>
/// 满载直驶人数限制值
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data44 { get; set; }
/// <summary>
/// 满载直驶重量限制值
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data45_46 { get; set; }
/// <summary>
/// 自动关门延时时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data47_48 { get; set; }
/// <summary>
/// 延时按键延时时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data49_50 { get; set; }
/// <summary>
/// 进料门开门总时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data51_52 { get; set; }
/// <summary>
/// 进料门关门总时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data53_54 { get; set; }
/// <summary>
/// 出料门开门总时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data55_56 { get; set; }
/// <summary>
/// 出料门关门总时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data57_58 { get; set; }
/// <summary>
/// 进料门开门高速时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data59_60 { get; set; }
/// <summary>
/// 进料门关门高速时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data61_62 { get; set; }
/// <summary>
/// 出料门开门高速时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data63_64 { get; set; }
/// <summary>
/// 出料门关门高速时间
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data65_66 { get; set; }
/// <summary>
/// B1层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data67_B7 { get; set; }
/// <summary>
/// 01层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data67_B6 { get; set; }
/// <summary>
/// 02层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data67_B5 { get; set; }
/// <summary>
/// 03层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data67_B4 { get; set; }
/// <summary>
/// 04层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data67_B3 { get; set; }
/// <summary>
/// 05层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data67_B2 { get; set; }
/// <summary>
/// 06层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data67_B1 { get; set; }
/// <summary>
/// 07层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data67_B0 { get; set; }
/// <summary>
/// 08层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data68_B7 { get; set; }
/// <summary>
/// 09层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data68_B6 { get; set; }
/// <summary>
/// 10层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data68_B5 { get; set; }
/// <summary>
/// 11层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data68_B4 { get; set; }
/// <summary>
/// 12层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data68_B3 { get; set; }
/// <summary>
/// 13层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data68_B2 { get; set; }
/// <summary>
/// 14层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data68_B1 { get; set; }
/// <summary>
/// 15层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data68_B0 { get; set; }
/// <summary>
/// 16层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data69_B7 { get; set; }
/// <summary>
/// 17层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data69_B6 { get; set; }
/// <summary>
/// 18层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data69_B5 { get; set; }
/// <summary>
/// 19层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data69_B4 { get; set; }
/// <summary>
/// 20层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data69_B3 { get; set; }
/// <summary>
/// 21层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data69_B2 { get; set; }
/// <summary>
/// 22层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data69_B1 { get; set; }
/// <summary>
/// 23层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data69_B0 { get; set; }
/// <summary>
/// 24层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data70_B7 { get; set; }
/// <summary>
/// 25层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data70_B6 { get; set; }
/// <summary>
/// 26层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data70_B5 { get; set; }
/// <summary>
/// 27层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data70_B4 { get; set; }
/// <summary>
/// 28层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data70_B3 { get; set; }
/// <summary>
/// 29层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data70_B2 { get; set; }
/// <summary>
/// 30层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data70_B1 { get; set; }
/// <summary>
/// 31层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data70_B0 { get; set; }
/// <summary>
/// 32层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data71_B7 { get; set; }
/// <summary>
/// 33层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data71_B6 { get; set; }
/// <summary>
/// 34层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data71_B5 { get; set; }
/// <summary>
/// 35层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data71_B4 { get; set; }
/// <summary>
/// 36层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data71_B3 { get; set; }
/// <summary>
/// 37层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data71_B2 { get; set; }
/// <summary>
/// 38层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data71_B1 { get; set; }
/// <summary>
/// 39层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data71_B0 { get; set; }
/// <summary>
/// 40层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data72_B7 { get; set; }
/// <summary>
/// 41层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data72_B6 { get; set; }
/// <summary>
/// 42层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data72_B5 { get; set; }
/// <summary>
/// 43层有效
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data72_B4 { get; set; }
/// <summary>
/// 恢复出厂设置
/// </summary>
[SugarColumn(IsIgnore = true)]
public int? Data8_B7_1104 { get; set; }
/// <summary>
/// 左笼配电箱急停按钮(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B7_2103 { get; set; }
/// <summary>
/// 右笼配电箱急停按钮(0断开1闭合)
/// </summary>
[SugarColumn(IsNullable = true)]
public int? Data2_B6_2103 { get; set; }
#region 业务字段
[SugarColumn(IsIgnore = true)]
public string? MsgType { get; set; }
[SugarColumn(IsIgnore = true)]
public DeviceData? WZ { get; set; }
#endregion
public static string[] GetNotNullColumns(IEnumerable<DeviceData> datas)
{
var Result = new List<string>();
var Type = typeof(DeviceData);
foreach (var Propety in Type.GetProperties())
{
if (datas.Any(x => Propety.GetValue(x) != null)) {
Result.Add(Propety.Name);
}
}
return Result.ToArray();
}
}
}

@ -9,6 +9,7 @@ namespace LanShengModel
{
[SugarTable("LS_TcpDataLog_{year}{month}{day}")]
[SplitTable(SplitType.Day)]
[SugarIndex("TcpDataLog_DTU_INDEX",nameof(TcpDataLog.DTU_ID),OrderByType.Asc,nameof(TcpDataLog.CreateDate),OrderByType.Desc)]
public class TcpDataLog
{
@ -40,6 +41,7 @@ namespace LanShengModel
[SugarTable("LS_TcpDataLog_{year}{month}{day}")]
[SplitTable(SplitType.Day)]
[SugarIndex("TcpDataLog_DTU_INDEX", nameof(TcpDataLog.DTU_ID), OrderByType.Asc, nameof(TcpDataLog.CreateDate), OrderByType.Desc)]
public class TcpDataLog<T>
{

@ -36,10 +36,6 @@ namespace LanShengService
Db.CodeFirst.SplitTables().InitTables(typeof(DeviceError));
Columns1001 = DeviceData1001.GetColumns();
Columns1103 = DeviceData1103.GetColumns();
Logger.LogDebug("加载数据结构");
CacheService = services.GetRequiredService<CacheInterface.ICacheService>();
@ -51,6 +47,8 @@ namespace LanShengService
Logger.LogDebug("加载设备故障表");
Logger.LogDebug("创建设备服务");
ClearDataLogDo();
}
private readonly IServiceProvider Services;
@ -69,21 +67,18 @@ namespace LanShengService
private readonly int ValidClearDataLogDo = 1000 * 60 * 60 * 24 * 3;
private readonly string[] Columns1001;
private readonly string[] Columns1103;
public async Task InsertData(DeviceData deviceData)
{
Logger.LogDebug($"设备数据插入队列{JsonSerializer.Serialize(deviceData)}");
if (deviceData.MsgType!.StartsWith("1"))
{
await SetError(deviceData);
await SetRunCount(deviceData);
}
await CacheService.Set($"DeviceData:{deviceData.Id}.{Guid.NewGuid().ToString()}", deviceData, 5);
await CacheService.Set($"CacheData:{deviceData.Id}", deviceData, 5);
}
public async Task TimerInsertDataDo()
@ -128,7 +123,7 @@ namespace LanShengService
await temp.AsInsertable.ExecuteCommandAsync();
await temp.AsUpdateable
.UpdateColumns(Columns1001)
.UpdateColumns(DeviceData.GetNotNullColumns(Values1001))
.ExecuteCommandAsync();
}
@ -141,7 +136,33 @@ namespace LanShengService
await temp.AsInsertable.ExecuteCommandAsync();
await temp.AsUpdateable
.UpdateColumns(Columns1103)
.UpdateColumns(DeviceData.GetNotNullColumns(Values1103))
.ExecuteCommandAsync();
}
var Values2001 = DeviceValues.Where(x => x != null && (x.MsgType == "2001" || x.MsgType == "8104")).ToList();
if (Values2001.Count > 0)
{
var temp = Db.Storageable(Values2001).ToStorage();
await temp.AsInsertable.ExecuteCommandAsync();
await temp.AsUpdateable
.UpdateColumns(DeviceData.GetNotNullColumns(Values2001))
.ExecuteCommandAsync();
}
var Values2103 = DeviceValues.Where(x => x != null && x.MsgType == "2103").ToList();
if (Values2103.Count > 0)
{
var temp = Db.Storageable(Values2103).ToStorage();
await temp.AsInsertable.ExecuteCommandAsync();
await temp.AsUpdateable
.UpdateColumns(DeviceData.GetNotNullColumns(Values2103))
.ExecuteCommandAsync();
}
}
@ -213,7 +234,15 @@ namespace LanShengService
public async Task ClearDataLogDo()
{
await Db.Deleteable<TcpDataLog>().Where(x => x.CreateDate < DateTime.Now.AddMilliseconds(-ValidClearDataLogDo)).SplitTable(tas => tas.Take(10)).ExecuteCommandAsync();
while (true)
{
var _Deletes = Db.SplitHelper<TcpDataLog>().GetTables().Where(x => x.Date < DateTime.Now.AddDays(-5));
foreach (var _Table in _Deletes)
{
Db.DbMaintenance.DropTable(_Table.TableName);
}
await Task.Delay(1000 * 60 * 6 * 10);
}
}
public async Task Offline(string id = "")
@ -255,22 +284,7 @@ namespace LanShengService
public async Task<List<DeviceData>> GetDeviceData(string[] ids)
{
var Result = new List<DeviceData>();
var CacheIds = new List<string>();
ids.ToList().ForEach((x) =>
{
CacheIds.Add($"CacheData:{x}");
});
var CacheResult = await CacheService.BatchGet<DeviceData>(CacheIds);
Result.AddRange(CacheResult.Where(x => x.Value != null).Select(x => x.Value));
var NotCacheIds = CacheResult.Where(x => x.Value == null).Select(x => x.Key.Remove(0, 10)).ToList();
if (NotCacheIds.Count() > 0)
{
var DbResult = await Db.Queryable<DeviceData>().In("Id", NotCacheIds)
var Result = await Db.Queryable<DeviceData>().In("Id", ids)
.IgnoreColumns(x => new
{
x.Data25_B4,
@ -280,19 +294,7 @@ namespace LanShengService
})
.ToListAsync();
Result.AddRange(DbResult.ToList());
var DbCache = new Dictionary<string, DeviceData>();
foreach (var Item in DbResult)
{
DbCache.Add($"CacheData:{Item.Id}", Item);
}
await CacheService.BatchSet<DeviceData>(DbCache, 60);
}
Result = JsonSerializer.Deserialize<List<DeviceData>>(JsonSerializer.Serialize(Result))!;
Result.ForEach(x =>
Result.ForEach(async x =>
{
x.Data6 = x.Data6 / 10;
decimal Latitude = 0;
@ -301,6 +303,11 @@ namespace LanShengService
decimal Longitude = 0;
Decimal.TryParse(x.Longitude, out Longitude);
x.Longitude = (Longitude / 1000000).ToString();
if (!string.IsNullOrEmpty(x.WZGPS))
{
x.WZ = await Db.Queryable<DeviceData>().FirstAsync(y => y.Id == x.WZGPS);
}
});
return Result;
@ -340,181 +347,181 @@ namespace LanShengService
#endregion
#region 自定义故障
int TempTime = 12;
//int TempTime = 12;
//进料门限位保护
if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
{
var Data3_B7_Date = CacheService.Get<DateTime>($"Data3_B7_Date:{deviceData.Id}").Result;
if (Data3_B7_Date == default)
{
CacheService.Set<DateTime>($"Data3_B7_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data3_B7:{deviceData.Id}", deviceData.Data3_B7).Wait();
}
else
{
var Data3_B7 = CacheService.Get<int?>($"Data3_B7:{deviceData.Id}").Result;
if (Data3_B7 == deviceData.Data3_B7)
{
TimeSpan span = DateTime.Now - Data3_B7_Date;
if (span.TotalHours > TempTime)
{
deviceData.ErrCode = "LS001";
deviceData.ErrMsg = "进料门限位长时间未动作";
}
}
else
{
CacheService.Set<DateTime>($"Data3_B7_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data3_B7:{deviceData.Id}", deviceData.Data3_B7).Wait();
}
}
}
//if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
//{
// var Data3_B7_Date = CacheService.Get<DateTime>($"Data3_B7_Date:{deviceData.Id}").Result;
// if (Data3_B7_Date == default)
// {
// CacheService.Set<DateTime>($"Data3_B7_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data3_B7:{deviceData.Id}", deviceData.Data3_B7).Wait();
// }
// else
// {
// var Data3_B7 = CacheService.Get<int?>($"Data3_B7:{deviceData.Id}").Result;
// if (Data3_B7 == deviceData.Data3_B7)
// {
// TimeSpan span = DateTime.Now - Data3_B7_Date;
// if (span.TotalHours > TempTime)
// {
// deviceData.ErrCode = "LS001";
// deviceData.ErrMsg = "进料门限位长时间未动作";
// }
// }
// else
// {
// CacheService.Set<DateTime>($"Data3_B7_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data3_B7:{deviceData.Id}", deviceData.Data3_B7).Wait();
// }
// }
//}
//出料门限位保护
if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
{
var Data3_B6_Date = CacheService.Get<DateTime>($"Data3_B6_Date:{deviceData.Id}").Result;
if (Data3_B6_Date == default)
{
CacheService.Set<DateTime>($"Data3_B6_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data3_B6:{deviceData.Id}", deviceData.Data3_B6).Wait();
}
else
{
var Data3_B6 = CacheService.Get<int?>($"Data3_B6:{deviceData.Id}").Result;
if (Data3_B6 == deviceData.Data3_B6)
{
TimeSpan span = DateTime.Now - Data3_B6_Date;
if (span.TotalHours > TempTime)
{
deviceData.ErrCode = "LS002";
deviceData.ErrMsg = "出料门限位长时间未动作";
}
}
else
{
CacheService.Set<DateTime>($"Data3_B6_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data3_B6:{deviceData.Id}", deviceData.Data3_B6).Wait();
}
}
}
//if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
//{
// var Data3_B6_Date = CacheService.Get<DateTime>($"Data3_B6_Date:{deviceData.Id}").Result;
// if (Data3_B6_Date == default)
// {
// CacheService.Set<DateTime>($"Data3_B6_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data3_B6:{deviceData.Id}", deviceData.Data3_B6).Wait();
// }
// else
// {
// var Data3_B6 = CacheService.Get<int?>($"Data3_B6:{deviceData.Id}").Result;
// if (Data3_B6 == deviceData.Data3_B6)
// {
// TimeSpan span = DateTime.Now - Data3_B6_Date;
// if (span.TotalHours > TempTime)
// {
// deviceData.ErrCode = "LS002";
// deviceData.ErrMsg = "出料门限位长时间未动作";
// }
// }
// else
// {
// CacheService.Set<DateTime>($"Data3_B6_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data3_B6:{deviceData.Id}", deviceData.Data3_B6).Wait();
// }
// }
//}
//进料门上限位保护
if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
{
var Data15_B3_Date = CacheService.Get<DateTime>($"Data15_B3_Date:{deviceData.Id}").Result;
if (Data15_B3_Date == default)
{
CacheService.Set<DateTime>($"Data15_B3_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data15_B3:{deviceData.Id}", deviceData.Data15_B3).Wait();
}
else
{
var Data15_B3 = CacheService.Get<int?>($"Data15_B3:{deviceData.Id}").Result;
if (Data15_B3 == deviceData.Data15_B3)
{
TimeSpan span = DateTime.Now - Data15_B3_Date;
if (span.TotalHours > TempTime)
{
deviceData.ErrCode = "LS003";
deviceData.ErrMsg = "进料门上限位长时间未动作";
}
}
else
{
CacheService.Set<DateTime>($"Data15_B3_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data15_B3:{deviceData.Id}", deviceData.Data3_B6).Wait();
}
}
}
//if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
//{
// var Data15_B3_Date = CacheService.Get<DateTime>($"Data15_B3_Date:{deviceData.Id}").Result;
// if (Data15_B3_Date == default)
// {
// CacheService.Set<DateTime>($"Data15_B3_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data15_B3:{deviceData.Id}", deviceData.Data15_B3).Wait();
// }
// else
// {
// var Data15_B3 = CacheService.Get<int?>($"Data15_B3:{deviceData.Id}").Result;
// if (Data15_B3 == deviceData.Data15_B3)
// {
// TimeSpan span = DateTime.Now - Data15_B3_Date;
// if (span.TotalHours > TempTime)
// {
// deviceData.ErrCode = "LS003";
// deviceData.ErrMsg = "进料门上限位长时间未动作";
// }
// }
// else
// {
// CacheService.Set<DateTime>($"Data15_B3_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data15_B3:{deviceData.Id}", deviceData.Data3_B6).Wait();
// }
// }
//}
//进料门下限位保护
if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
{
var Data15_B2_Date = CacheService.Get<DateTime>($"Data15_B2_Date:{deviceData.Id}").Result;
if (Data15_B2_Date == default)
{
CacheService.Set<DateTime>($"Data15_B2_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data15_B2:{deviceData.Id}", deviceData.Data15_B2).Wait();
}
else
{
var Data15_B2 = CacheService.Get<int?>($"Data15_B2:{deviceData.Id}").Result;
if (Data15_B2 == deviceData.Data15_B2)
{
TimeSpan span = DateTime.Now - Data15_B2_Date;
if (span.TotalHours > TempTime)
{
deviceData.ErrCode = "LS004";
deviceData.ErrMsg = "进料门下限位长时间未动作";
}
}
else
{
CacheService.Set<DateTime>($"Data15_B2_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data15_B2:{deviceData.Id}", deviceData.Data15_B2).Wait();
}
}
}
//if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
//{
// var Data15_B2_Date = CacheService.Get<DateTime>($"Data15_B2_Date:{deviceData.Id}").Result;
// if (Data15_B2_Date == default)
// {
// CacheService.Set<DateTime>($"Data15_B2_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data15_B2:{deviceData.Id}", deviceData.Data15_B2).Wait();
// }
// else
// {
// var Data15_B2 = CacheService.Get<int?>($"Data15_B2:{deviceData.Id}").Result;
// if (Data15_B2 == deviceData.Data15_B2)
// {
// TimeSpan span = DateTime.Now - Data15_B2_Date;
// if (span.TotalHours > TempTime)
// {
// deviceData.ErrCode = "LS004";
// deviceData.ErrMsg = "进料门下限位长时间未动作";
// }
// }
// else
// {
// CacheService.Set<DateTime>($"Data15_B2_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data15_B2:{deviceData.Id}", deviceData.Data15_B2).Wait();
// }
// }
//}
//出料门上限位保护
if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
{
var Data15_B1_Date = CacheService.Get<DateTime>($"Data15_B1_Date:{deviceData.Id}").Result;
if (Data15_B1_Date == default)
{
CacheService.Set<DateTime>($"Data15_B1_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data15_B1:{deviceData.Id}", deviceData.Data15_B1).Wait();
}
else
{
var Data15_B1 = CacheService.Get<int?>($"Data15_B1:{deviceData.Id}").Result;
if (Data15_B1 == deviceData.Data15_B1)
{
TimeSpan span = DateTime.Now - Data15_B1_Date;
if (span.TotalHours > TempTime)
{
deviceData.ErrCode = "LS005";
deviceData.ErrMsg = "出料门上限位长时间未动作";
}
}
else
{
CacheService.Set<DateTime>($"Data15_B1_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data15_B1:{deviceData.Id}", deviceData.Data15_B1).Wait();
}
}
}
//if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
//{
// var Data15_B1_Date = CacheService.Get<DateTime>($"Data15_B1_Date:{deviceData.Id}").Result;
// if (Data15_B1_Date == default)
// {
// CacheService.Set<DateTime>($"Data15_B1_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data15_B1:{deviceData.Id}", deviceData.Data15_B1).Wait();
// }
// else
// {
// var Data15_B1 = CacheService.Get<int?>($"Data15_B1:{deviceData.Id}").Result;
// if (Data15_B1 == deviceData.Data15_B1)
// {
// TimeSpan span = DateTime.Now - Data15_B1_Date;
// if (span.TotalHours > TempTime)
// {
// deviceData.ErrCode = "LS005";
// deviceData.ErrMsg = "出料门上限位长时间未动作";
// }
// }
// else
// {
// CacheService.Set<DateTime>($"Data15_B1_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data15_B1:{deviceData.Id}", deviceData.Data15_B1).Wait();
// }
// }
//}
//出料门下限位保护
if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
{
var Data15_B0_Date = CacheService.Get<DateTime>($"Data15_B0_Date:{deviceData.Id}").Result;
if (Data15_B0_Date == default)
{
CacheService.Set<DateTime>($"Data15_B0_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data15_B0:{deviceData.Id}", deviceData.Data15_B0).Wait();
}
else
{
var Data15_B0 = CacheService.Get<int?>($"Data15_B0:{deviceData.Id}").Result;
if (Data15_B0 == deviceData.Data15_B0)
{
TimeSpan span = DateTime.Now - Data15_B0_Date;
if (span.TotalHours > TempTime)
{
deviceData.ErrCode = "LS007";
deviceData.ErrMsg = "出料门下限位长时间未动作";
}
}
else
{
CacheService.Set<DateTime>($"Data15_B0_Date:{deviceData.Id}", DateTime.Now).Wait();
CacheService.Set<int?>($"Data15_B0:{deviceData.Id}", deviceData.Data15_B0).Wait();
}
}
}
//if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
//{
// var Data15_B0_Date = CacheService.Get<DateTime>($"Data15_B0_Date:{deviceData.Id}").Result;
// if (Data15_B0_Date == default)
// {
// CacheService.Set<DateTime>($"Data15_B0_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data15_B0:{deviceData.Id}", deviceData.Data15_B0).Wait();
// }
// else
// {
// var Data15_B0 = CacheService.Get<int?>($"Data15_B0:{deviceData.Id}").Result;
// if (Data15_B0 == deviceData.Data15_B0)
// {
// TimeSpan span = DateTime.Now - Data15_B0_Date;
// if (span.TotalHours > TempTime)
// {
// deviceData.ErrCode = "LS007";
// deviceData.ErrMsg = "出料门下限位长时间未动作";
// }
// }
// else
// {
// CacheService.Set<DateTime>($"Data15_B0_Date:{deviceData.Id}", DateTime.Now).Wait();
// CacheService.Set<int?>($"Data15_B0:{deviceData.Id}", deviceData.Data15_B0).Wait();
// }
// }
//}
//人数摄像头保护
if (string.IsNullOrEmpty(deviceData.ErrCode) && string.IsNullOrEmpty(deviceData.ErrMsg))
@ -1286,30 +1293,35 @@ namespace LanShengService
throw new BadRequestException("单元无效");
}
#endregion
if ((report.CompanyIds != null && report.CompanyIds.Count() > 0) || (report.ProjectIds != null && report.ProjectIds.Count() > 0) || (report.DeviceIds != null && report.DeviceIds.Count() > 0)) {
if ((report.CompanyIds != null && report.CompanyIds.Count() > 0) || (report.ProjectIds != null && report.ProjectIds.Count() > 0) || (report.DeviceIds != null && report.DeviceIds.Count() > 0))
{
var TempCompanyIds = report.CompanyIds;
var TempProjectIds = report.ProjectIds;
var TempDeviceIds = report.DeviceIds;
var TempGpss = Db.Queryable<DeviceDO>()
.LeftJoin<ProjectDO>((x, y) => x.ProjectId == y.Id)
.WhereIF(TempCompanyIds != null, (x, y) => TempCompanyIds!.Contains(y.CompanyId))
.WhereIF(TempProjectIds != null, (x, y) => TempProjectIds!.Contains(x.ProjectId))
.WhereIF(TempDeviceIds != null, (x, y) => TempDeviceIds!.Contains(x.Id))
.WhereIF(TempCompanyIds != null && TempCompanyIds.Count() > 0, (x, y) => TempCompanyIds!.Contains(y.CompanyId))
.WhereIF(TempProjectIds != null && TempProjectIds.Count() > 0, (x, y) => TempProjectIds!.Contains(x.ProjectId))
.WhereIF(TempDeviceIds != null && TempDeviceIds.Count() > 0, (x, y) => TempDeviceIds!.Contains(x.Id))
.Where((x, y) => x.Deleted == 0)
.Select((x,y)=> x.Gps!.ToString())
.Select((x, y) => x.Gps!.ToString())
.ToList();
var TempGpsIds = new List<string>();
TempGpss.ForEach(v => {
TempGpss.ForEach(v =>
{
try
{
var tempGps = JsonSerializer.Deserialize<IEnumerable<DeviceGpsDO>>(v!);
TempGpsIds.AddRange(tempGps!.Select(x => x.Id!));
}
catch {
catch
{
}
});
report.GpsIds = TempGpsIds!;
report.GpsIds = report.GpsIds == null ? TempGpsIds! : report.GpsIds.Concat(TempGpsIds!);
}
var TempErrors = await GetDayError(report);
var TempErrorGroup = TempErrors.Select(x => x.ErrCode).Distinct();
@ -1345,7 +1357,8 @@ namespace LanShengService
TempItems.Add(item);
}
}
else if (report.Unit.ToLower() == "month") {
else if (report.Unit.ToLower() == "month")
{
var TempErrorDate = TempErrors.Select(x => x.Id!.Substring(0, 7)).Distinct();
foreach (var group in TempErrorGroup)
{
@ -1423,15 +1436,25 @@ namespace LanShengService
return Task.FromResult(result);
}
public async Task<IEnumerable<DeviceError>> GetErrorList() {
return await Db.Queryable<DeviceError>()
public async Task<IEnumerable<DeviceError>> GetErrorList(string search)
{
var _Query = Db.Queryable<DeviceError>()
.WhereIF(!string.IsNullOrWhiteSpace(search), x => x.ErrCode!.Contains(search) || x.ErrMsg!.Contains(search))
.Distinct()
.Select(x => new DeviceError
{
ErrCode = x.ErrCode,
ErrMsg = x.ErrMsg
}).Distinct()
})
.SplitTable(DateTime.Now.AddYears(-1), DateTime.Now)
.ToListAsync();
.Distinct()
.Select(x => new DeviceError
{
ErrCode = x.ErrCode,
ErrMsg = x.ErrMsg
});
var _Sql = _Query.ToSqlString();
return await _Query.ToListAsync();
}
#endregion
}

@ -43,15 +43,13 @@ namespace LanShengService.Tcp
DTU_Id = packet!.DTU_ID!;
Logger.LogDebug($"接收到数据:{JsonSerializer.Serialize<TcpDataLog<DeviceData>>(packet!)}");
await TcpService.AddChannel(packet!.DTU_ID!, context);
await DeviceService.InsertDataLog(packet!);
if (packet.Msg_ID == "1001" || packet.Msg_ID == "1103")
{
if (packet!.Content != null)
{
await DeviceService.InsertData(packet!.Content);
}
if (packet.Msg_ID == "1001" || packet.Msg_ID == "1103")
{
await DeviceService.InsertDataLog(packet!);
var Reply = new TcpDataLog<DeviceData>
{
Frame_START = packet.Frame_START,
@ -63,7 +61,7 @@ namespace LanShengService.Tcp
{
Reply.Msg_ID = "9001";
}
if (packet.Msg_ID == "1103")
else if (packet.Msg_ID == "1103")
{
Reply.Msg_ID = "9103";
}
@ -76,10 +74,47 @@ namespace LanShengService.Tcp
await context.CloseAsync();
}
}
else if (packet.Msg_ID == "2001" || packet.Msg_ID == "2103")
{
if (packet!.Content != null)
{
await DeviceService.InsertData(packet!.Content);
}
var Reply = new TcpDataLog<DeviceData>
{
Frame_START = packet.Frame_START,
Frame_number = packet.Frame_number,
DTU_ID = packet.DTU_ID,
Frame_END = packet.Frame_END
};
if (packet.Msg_ID == "2001")
{
Reply.Msg_ID = "8001";
}
else if (packet.Msg_ID == "2103")
{
Reply.Msg_ID = "8103";
}
try
{
await context.WriteAndFlushAsync(Reply);
}
catch
{
await context.CloseAsync();
}
}
if (packet.Msg_ID == "9104")
{
await TcpService.RemoveMessageItem(packet);
}
if (packet.Msg_ID == "9107")
{
await TcpService.RemoveMessageItem(packet);
}
if (packet.Msg_ID == "8104") {
await TcpService.RemoveMessageItem(packet);
}
TryCount = 0;
}

@ -9,6 +9,7 @@ using System.Text;
using System.Threading.Tasks;
using CommonExtend;
using CommonModel;
using static Google.Rpc.Context.AttributeContext.Types;
namespace LanShengService.Tcp
{
@ -68,93 +69,34 @@ namespace LanShengService.Tcp
{
case "1001":
case "9104":
request.Content.AgreementVersion = Content.ReadInt(1);
request.Content.DataTick = Content.ReadInt(2);
request.Content.ICCID = Content.ReadString(20, Encoding.ASCII);
Content.SkipBytes(4);
request.Content.Longitude = Content.ReadString(9, Encoding.ASCII);
request.Content.Latitude = Content.ReadString(8, Encoding.ASCII);
request.Content.ConnectStrLength = Content.ReadInt(1);
request.Content.ConnectString = Content.ReadString((int)request.Content.ConnectStrLength, Encoding.ASCII);
if (request.Content.Id.StartsWith("QC") || request.Content.Id.StartsWith("ZK"))
{
Decode1001ZK(request.Content, Content);
}
else
{
Decode1001RY(request.Content, Content);
}
break;
case "1103":
request.Content.Version = Content.ReadInt(1);
var Data2 = Content.ReadBitArray();
request.Content.Data2_B7 = Data2[0];
request.Content.Data2_B6 = Data2[1];
request.Content.Data2_B5 = Data2[2];
request.Content.Data2_B4 = Data2[3];
request.Content.Data2_B3 = Data2[4];
request.Content.Data2_B2 = Data2[5];
request.Content.Data2_B1 = Data2[6];
request.Content.Data2_B0 = Data2[7];
var Data3 = Content.ReadBitArray();
request.Content.Data3_B7 = Data3[0];
request.Content.Data3_B6 = Data3[1];
request.Content.Data3_B5 = Data3[2];
request.Content.Data3_B4 = Data3[3];
request.Content.Data3_B3 = Data3[4];
request.Content.Data3_B2 = Data3[5];
request.Content.Data3_B1 = Data3[6];
request.Content.Data3_B0 = Data3[7];
request.Content.Data4 = Content.ReadInt(1);
request.Content.Data5 = Content.ReadInt(1);
request.Content.Data6 = Content.ReadInt(1);
request.Content.Data7 = Content.ReadInt(1);
request.Content.Data8 = Content.ReadInt(2);
request.Content.Data10 = Content.ReadInt(1);
request.Content.Data11 = Content.ReadInt(1);
request.Content.Data12 = Content.ReadInt(1);
request.Content.Data13 = Content.ReadInt(1);
var Data14 = Content.ReadBitArray();
request.Content.Data14_B6 = Convert.ToInt32($"{Data14[1]}{Data14[0]}", 2);
request.Content.Data14_B5 = Data14[2];
request.Content.Data14_B4 = Data14[3];
request.Content.Data14_B3 = Data14[4];
request.Content.Data14_B2 = Data14[5];
request.Content.Data14_B1 = Data14[6];
request.Content.Data14_B0 = Data14[7];
var Data15 = Content.ReadBitArray();
request.Content.Data15_B6 = Convert.ToInt32($"{Data15[1]}{Data15[0]}", 2);
request.Content.Data15_B4 = Convert.ToInt32($"{Data15[3]}{Data15[2]}", 2);
request.Content.Data15_B3 = Data15[4];
request.Content.Data15_B2 = Data15[5];
request.Content.Data15_B1 = Data15[6];
request.Content.Data15_B0 = Data15[7];
var Data16 = Content.ReadBitArray();
request.Content.Data16_B7 = Data16[0];
request.Content.Data16_B6 = Data16[1];
request.Content.Data16_B5 = Data16[2];
request.Content.Data16_B4 = Data16[3];
request.Content.Data16_B2 = Convert.ToInt32($"{Data16[5]}{Data16[4]}", 2);
request.Content.Data16_B1 = Data16[6];
request.Content.Data16_B0 = Data16[7];
request.Content.Data17 = Content.ReadInt(1);
request.Content.Data18 = Content.ReadInt(1);
request.Content.Data19 = Content.ReadInt(1);
request.Content.Data20 = Content.ReadInt(1);
request.Content.Data21 = Content.ReadInt(1);
request.Content.Data22 = Content.ReadInt(1);
request.Content.Data23 = Content.ReadInt(1);
request.Content.Data24 = Content.ReadInt(1);
var Data25 = Content.ReadBitArray();
request.Content.Data25_B4 = Convert.ToInt32($"{Data25[3]}{Data25[2]}{Data25[1]}{Data25[0]}", 2);
request.Content.Data25_B0 = Convert.ToInt32($"{Data25[7]}{Data25[6]}{Data25[5]}{Data25[4]}", 2);
var Data26 = Content.ReadBitArray();
request.Content.Data26_B4 = Convert.ToInt32($"{Data26[3]}{Data26[2]}{Data26[1]}{Data26[0]}", 2);
request.Content.Data26_B0 = Convert.ToInt32($"{Data26[7]}{Data26[6]}{Data26[5]}{Data26[4]}", 2);
var Data27 = Content.ReadBitArray();
request.Content.Data27_B7 = Data27[0];
request.Content.Data27_B6 = Data27[1];
request.Content.Data27_B5 = Data27[2];
request.Content.Data27_B4 = Data27[3];
request.Content.Data27_B3 = Data27[4];
request.Content.Data27_B0 = Data27[7];
if (request.Content.Id.StartsWith("QC") || request.Content.Id.StartsWith("ZK"))
{
Decode1103ZK(request.Content, Content);
}
else
{
Decode1103RY(request.Content, Content);
}
break;
case "2001":
Decode2001ZK(request.Content, Content);
break;
case "2103":
Decode2103ZK(request.Content, Content);
break;
default:
break;
}
request.Content = request.Content;
}
catch
{
@ -174,5 +116,298 @@ namespace LanShengService.Tcp
return;
}
}
private void Decode1103RY(DeviceData device, IByteBuffer content)
{
device.Version = content.ReadInt(1);
var Data2 = content.ReadBitArray();
device.Data2_B7 = Data2[0];
device.Data2_B6 = Data2[1];
device.Data2_B5 = Data2[2];
device.Data2_B4 = Data2[3];
device.Data2_B3 = Data2[4];
device.Data2_B2 = Data2[5];
device.Data2_B1 = Data2[6];
device.Data2_B0 = Data2[7];
var Data3 = content.ReadBitArray();
device.Data3_B7 = Data3[0];
device.Data3_B6 = Data3[1];
device.Data3_B5 = Data3[2];
device.Data3_B4 = Data3[3];
device.Data3_B3 = Data3[4];
device.Data3_B2 = Data3[5];
device.Data3_B1 = Data3[6];
device.Data3_B0 = Data3[7];
device.Data4 = content.ReadInt(1);
device.Data5 = content.ReadInt(1);
device.Data6 = content.ReadInt(1);
device.Data7 = content.ReadInt(1);
device.Data8 = content.ReadInt(2);
device.Data10 = content.ReadInt(1);
device.Data11 = content.ReadInt(1);
device.Data12 = content.ReadInt(1);
device.Data13 = content.ReadInt(1);
var Data14 = content.ReadBitArray();
device.Data14_B6 = Convert.ToInt32($"{Data14[1]}{Data14[0]}", 2);
device.Data14_B5 = Data14[2];
device.Data14_B4 = Data14[3];
device.Data14_B3 = Data14[4];
device.Data14_B2 = Data14[5];
device.Data14_B1 = Data14[6];
device.Data14_B0 = Data14[7];
var Data15 = content.ReadBitArray();
device.Data15_B6 = Convert.ToInt32($"{Data15[1]}{Data15[0]}", 2);
device.Data15_B4 = Convert.ToInt32($"{Data15[3]}{Data15[2]}", 2);
device.Data15_B3 = Data15[4];
device.Data15_B2 = Data15[5];
device.Data15_B1 = Data15[6];
device.Data15_B0 = Data15[7];
var Data16 = content.ReadBitArray();
device.Data16_B7 = Data16[0];
device.Data16_B6 = Data16[1];
device.Data16_B5 = Data16[2];
device.Data16_B4 = Data16[3];
device.Data16_B2 = Convert.ToInt32($"{Data16[5]}{Data16[4]}", 2);
device.Data16_B1 = Data16[6];
device.Data16_B0 = Data16[7];
device.Data17 = content.ReadInt(1);
device.Data18 = content.ReadInt(1);
device.Data19 = content.ReadInt(1);
device.Data20 = content.ReadInt(1);
device.Data21 = content.ReadInt(1);
device.Data22 = content.ReadInt(1);
device.Data23 = content.ReadInt(1);
device.Data24 = content.ReadInt(1);
var Data25 = content.ReadBitArray();
device.Data25_B4 = Convert.ToInt32($"{Data25[3]}{Data25[2]}{Data25[1]}{Data25[0]}", 2);
device.Data25_B0 = Convert.ToInt32($"{Data25[7]}{Data25[6]}{Data25[5]}{Data25[4]}", 2);
var Data26 = content.ReadBitArray();
device.Data26_B4 = Convert.ToInt32($"{Data26[3]}{Data26[2]}{Data26[1]}{Data26[0]}", 2);
device.Data26_B0 = Convert.ToInt32($"{Data26[7]}{Data26[6]}{Data26[5]}{Data26[4]}", 2);
var Data27 = content.ReadBitArray();
device.Data27_B7 = Data27[0];
device.Data27_B6 = Data27[1];
device.Data27_B5 = Data27[2];
device.Data27_B4 = Data27[3];
device.Data27_B3 = Data27[4];
device.Data27_B0 = Data27[7];
}
private void Decode1103ZK(DeviceData device, IByteBuffer content)
{
device.Version = content.ReadInt(1);
var Data2 = content.ReadBitArray();
device.Data2_B7 = Data2[0];
device.Data2_B6 = Data2[1];
device.Data2_B5 = Data2[2];
device.Data2_B4 = Data2[3];
device.Data2_B3 = Data2[4];
device.Data2_B2 = Data2[5];
device.Data2_B1 = Data2[6];
device.Data2_B0 = Data2[7];
var Data3 = content.ReadBitArray();
device.Data3_B7 = Data3[0];
device.Data3_B6 = Data3[1];
device.Data3_B5 = Data3[2];
device.Data3_B4 = Data3[3];
device.Data3_B3 = Data3[4];
device.Data3_B2 = Data3[5];
device.Data3_B1 = Data3[6];
device.Data3_B0 = Data3[7];
device.Data4 = content.ReadInt(1);
device.Data5 = content.ReadInt(1);
device.Data6 = content.ReadInt(1);
device.Data7 = content.ReadInt(1);
device.Data8 = content.ReadInt(2);
device.Data10 = content.ReadInt(1);
device.Data11 = content.ReadInt(1);
device.Data12 = content.ReadInt(1);
var Data13 = content.ReadBitArray();
device.Data13_B7 = Data13[0];
device.Data13_B6 = Data13[1];
var Data14 = content.ReadBitArray();
device.Data14_B6 = Convert.ToInt32($"{Data14[1]}{Data14[0]}", 2);
device.Data14_B5 = Data14[2];
device.Data14_B4 = Data14[3];
device.Data14_B3 = Data14[4];
device.Data14_B2 = Data14[5];
device.Data14_B1 = Data14[6];
device.Data14_B0 = Data14[7];
var Data15 = content.ReadBitArray();
device.Data15_B6 = Convert.ToInt32($"{Data15[1]}{Data15[0]}", 2);
device.Data15_B4 = Convert.ToInt32($"{Data15[3]}{Data15[2]}", 2);
device.Data15_B3 = Data15[4];
device.Data15_B2 = Data15[5];
device.Data15_B1 = Data15[6];
device.Data15_B0 = Data15[7];
var Data16 = content.ReadBitArray();
device.Data16_B7 = Data16[0];
device.Data16_B6 = Data16[1];
device.Data16_B5_N = Data16[2];
device.Data16_B4 = Data16[3];
device.Data16_B2 = Convert.ToInt32($"{Data16[5]}{Data16[4]}", 2);
device.Data16_B1 = Data16[6];
device.Data16_B0 = Data16[7];
device.Data17 = content.ReadInt(1);
device.Data18 = content.ReadInt(1);
var Data19 = content.ReadBitArray();
device.Data19_B7 = Data19[0];
device.Data19_B6 = Data19[1];
device.Data19_B5 = Data19[2];
device.Data19_B4 = Data19[3];
device.Data19_B3 = Data19[4];
device.Data19_B2 = Data19[5];
device.Data19_B1 = Data19[6];
device.Data20 = content.ReadInt(1);
device.Data21 = content.ReadInt(1);
device.Data22 = content.ReadInt(1);
device.Data23 = content.ReadInt(1);
device.Data24 = content.ReadInt(1);
var Data25 = content.ReadBitArray();
device.Data25_B4 = Convert.ToInt32($"{Data25[3]}{Data25[2]}{Data25[1]}{Data25[0]}", 2);
device.Data25_B0 = Convert.ToInt32($"{Data25[7]}{Data25[6]}{Data25[5]}{Data25[4]}", 2);
var Data26 = content.ReadBitArray();
device.Data26_B4 = Convert.ToInt32($"{Data26[3]}{Data26[2]}{Data26[1]}{Data26[0]}", 2);
device.Data26_B0 = Convert.ToInt32($"{Data26[7]}{Data26[6]}{Data26[5]}{Data26[4]}", 2);
var Data27 = content.ReadBitArray();
device.Data27_B7 = Data27[0];
device.Data27_B6 = Data27[1];
device.Data27_B5 = Data27[2];
device.Data27_B4 = Data27[3];
device.Data27_B3 = Data27[4];
var Data28 = content.ReadBitArray();
device.Data28_B7 = Data28[0];
device.Data28_B6 = Data28[1];
device.Data28_B5 = Data28[2];
device.Data28_B4 = Data28[3];
device.Data28_B3 = Data28[4];
device.Data28_B2 = Data28[5];
device.Data28_B1 = Data28[6];
device.Data28_B0 = Data28[7];
var Data29 = content.ReadBitArray();
device.Data29_B6 = Data29[1];
device.Data29_B5 = Data29[2];
device.Data29_B4 = Data29[3];
device.Data29_B3 = Data29[4];
device.Data30 = content.ReadInt(1);
device.Data31 = content.ReadInt(1);
device.Data32_33 = content.ReadInt(2);
device.Data34 = content.ReadInt(1);
device.Data35 = content.ReadInt(1);
device.Data36 = content.ReadInt(1);
device.Data37 = content.ReadInt(1);
device.Data38_39 = content.ReadInt(2);
device.Data40 = content.ReadInt(1);
device.Data41 = content.ReadInt(1);
device.Data42_43 = content.ReadInt(2);
device.Data44 = content.ReadInt(1);
device.Data45_46 = content.ReadInt(2);
device.Data47_48 = content.ReadInt(2);
device.Data49_50 = content.ReadInt(2);
device.Data51_52 = content.ReadInt(2);
device.Data53_54 = content.ReadInt(2);
device.Data55_56 = content.ReadInt(2);
device.Data57_58 = content.ReadInt(2);
device.Data59_60 = content.ReadInt(2);
device.Data61_62 = content.ReadInt(2);
device.Data63_64 = content.ReadInt(2);
device.Data65_66 = content.ReadInt(2);
var Data67 = content.ReadBitArray();
device.Data67_B7 = Data67[0];
device.Data67_B6 = Data67[1];
device.Data67_B5 = Data67[2];
device.Data67_B4 = Data67[3];
device.Data67_B3 = Data67[4];
device.Data67_B2 = Data67[5];
device.Data67_B1 = Data67[6];
device.Data67_B0 = Data67[7];
var Data68 = content.ReadBitArray();
device.Data68_B7 = Data68[0];
device.Data68_B6 = Data68[1];
device.Data68_B5 = Data68[2];
device.Data68_B4 = Data68[3];
device.Data68_B3 = Data68[4];
device.Data68_B2 = Data68[5];
device.Data68_B1 = Data68[6];
device.Data68_B0 = Data68[7];
var Data69 = content.ReadBitArray();
device.Data69_B7 = Data69[0];
device.Data69_B6 = Data69[1];
device.Data69_B5 = Data69[2];
device.Data69_B4 = Data69[3];
device.Data69_B3 = Data69[4];
device.Data69_B2 = Data69[5];
device.Data69_B1 = Data69[6];
device.Data69_B0 = Data69[7];
var Data70 = content.ReadBitArray();
device.Data70_B7 = Data70[0];
device.Data70_B6 = Data70[1];
device.Data70_B5 = Data70[2];
device.Data70_B4 = Data70[3];
device.Data70_B3 = Data70[4];
device.Data70_B2 = Data70[5];
device.Data70_B1 = Data70[6];
device.Data70_B0 = Data70[7];
var Data71 = content.ReadBitArray();
device.Data71_B7 = Data71[0];
device.Data71_B6 = Data71[1];
device.Data71_B5 = Data71[2];
device.Data71_B4 = Data71[3];
device.Data71_B3 = Data71[4];
device.Data71_B2 = Data71[5];
device.Data71_B1 = Data71[6];
device.Data71_B0 = Data71[7];
var Data72 = content.ReadBitArray();
device.Data72_B7 = Data72[0];
device.Data72_B6 = Data72[1];
device.Data72_B5 = Data72[2];
device.Data72_B4 = Data72[3];
}
private void Decode1001RY(DeviceData device, IByteBuffer content)
{
device.AgreementVersion = content.ReadInt(1);
device.DataTick = content.ReadInt(2);
device.ICCID = content.ReadString(20, Encoding.ASCII);
content.SkipBytes(4);
device.Longitude = content.ReadString(9, Encoding.ASCII);
device.Latitude = content.ReadString(8, Encoding.ASCII);
device.ConnectStrLength = content.ReadInt(1);
device.ConnectString = content.ReadString((int)device.ConnectStrLength, Encoding.ASCII);
}
private void Decode1001ZK(DeviceData device, IByteBuffer content)
{
device.AgreementVersion = content.ReadInt(1);
device.DataTick = content.ReadInt(2);
device.ICCID = content.ReadString(20, Encoding.ASCII);
device.WZGPS = content.ReadString(17, Encoding.ASCII);
content.SkipBytes(4);
device.Longitude = content.ReadString(9, Encoding.ASCII);
device.Latitude = content.ReadString(8, Encoding.ASCII);
device.ConnectStrLength = content.ReadInt(1);
device.ConnectString = content.ReadString((int)device.ConnectStrLength, Encoding.ASCII);
}
private void Decode2001ZK(DeviceData device,IByteBuffer content)
{
device.AgreementVersion = content.ReadInt(1);
device.DataTick = content.ReadInt(2);
device.ICCID = content.ReadString(20, Encoding.ASCII);
device.WZGPS = content.ReadString(17, Encoding.ASCII);
content.SkipBytes(4);
device.Longitude = content.ReadString(9, Encoding.ASCII);
device.Latitude = content.ReadString(8, Encoding.ASCII);
device.ConnectStrLength = content.ReadInt(1);
device.ConnectString = content.ReadString((int)device.ConnectStrLength, Encoding.ASCII);
}
private void Decode2103ZK(DeviceData device,IByteBuffer content)
{
device.AgreementVersion = content.ReadInt(1);
var Data2 = content.ReadBitArray();
device.Data2_B7_2103 = Data2[0];
device.Data2_B6_2103 = Data2[1];
}
}
}

@ -24,39 +24,20 @@ namespace LanShengService.Tcp
switch (message.Msg_ID)
{
case "1104":
Temp.AddRange(((int)message.Content!.Version!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content!.DataTick!).Int2Byte().BytePadLeft(2));
int[] Data1 = new int[] {
(int)message.Content!.Data27_B7!,
(int)message.Content!.Data27_B6!,
(int)message.Content!.Data27_B5!,
(int)message.Content!.Data27_B4!,
(int)message.Content!.Data27_B3!,
0,
0,
(int)message.Content!.Data27_B0!,
};
Temp.AddRange(Data1.BitArray2Byte());
int[] Data2 = new int[] {
(int)message.Content!.Data23!,
(int)message.Content!.Data20!,
(int)message.Content!.Data19!,
(int)message.Content!.Data18!,
((int)message.Content!.Data16_B2!).Int2Bit(2)[1],
((int)message.Content!.Data16_B2!).Int2Bit(2)[0],
0,
0
};
Temp.AddRange(Data2.BitArray2Byte());
Temp.AddRange(((int)message.Content.Data25_B4!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content.Data25_B0!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content.Data26_B4!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content.Data26_B0!).Int2Byte().BytePadLeft(1));
Temp.AddRange(((int)message.Content.UpdateTag!).Int2Byte().BytePadLeft(1));
var ConnectByte = Encoding.ASCII.GetBytes(message.Content.ConnectString!);
message.Content.ConnectStrLength = message.Content.ConnectString!.Length;
Temp.AddRange(((int)message.Content.ConnectStrLength!).Int2Byte().BytePadLeft(1));
Temp.AddRange(ConnectByte);
if (message.Content!.Id!.StartsWith("QC") || message.Content!.Id!.StartsWith("ZK"))
{
Encode1104ZK(Temp, message.Content!);
}
else
{
Encode1104RY(Temp, message.Content!);
}
break;
case "1107":
Encode1107ZK(Temp, message.Content!);
break;
case "2104":
Encode2104ZK(Temp, message.Content!);
break;
default:
break;
@ -68,5 +49,219 @@ namespace LanShengService.Tcp
Temp.AddRange(message.Frame_END!.HexString2Byte().BytePadLeft(2));
output.WriteBytes(Temp.ToArray());
}
private void Encode1104RY(List<byte> bytes, DeviceData device)
{
bytes.AddRange(((int)device.Version!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.DataTick!).Int2Byte().BytePadLeft(2));
int[] Data1 = new int[] {
(int)device.Data27_B7!,
(int)device.Data27_B6!,
(int)device.Data27_B5!,
(int)device.Data27_B4!,
(int)device.Data27_B3!,
0,
0,
(int)device.Data27_B0!,
};
bytes.AddRange(Data1.BitArray2Byte());
int[] Data2 = new int[] {
(int)device.Data23!,
(int)device.Data20!,
(int)device.Data19!,
(int)device.Data18!,
((int)device.Data16_B2!).Int2Bit(2)[1],
((int)device.Data16_B2!).Int2Bit(2)[0],
0,
0
};
bytes.AddRange(Data2.BitArray2Byte());
bytes.AddRange(((int)device.Data25_B4!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data25_B0!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data26_B4!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data26_B0!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.UpdateTag!).Int2Byte().BytePadLeft(1));
var ConnectByte = Encoding.ASCII.GetBytes(device.ConnectString!);
device.ConnectStrLength = device.ConnectString!.Length;
bytes.AddRange(((int)device.ConnectStrLength!).Int2Byte().BytePadLeft(1));
bytes.AddRange(ConnectByte);
}
private void Encode1104ZK(List<byte> bytes, DeviceData device)
{
bytes.AddRange(((int)device.Version!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.DataTick!).Int2Byte().BytePadLeft(2));
int[] Data1 = new int[] {
(int)device.Data27_B7!,
(int)device.Data27_B6!,
(int)device.Data27_B5!,
(int)device.Data27_B4!,
(int)device.Data27_B3!,
0,
0,
0
};
bytes.AddRange(Data1.BitArray2Byte());
int[] Data2 = new int[] {
(int)device.Data23!,
0,
((int)device.Data18!).Int2Bit(2)[1],
((int)device.Data18!).Int2Bit(2)[0],
((int)device.Data16_B2!).Int2Bit(2)[1],
((int)device.Data16_B2!).Int2Bit(2)[0],
0,
0
};
bytes.AddRange(Data2.BitArray2Byte());
bytes.AddRange(((int)device.Data25_B4!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data25_B0!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data26_B4!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data26_B0!).Int2Byte().BytePadLeft(1));
int[] Data7 = new int[] {
(int)device.Data28_B7!,
(int)device.Data28_B6!,
(int)device.Data28_B5!,
(int)device.Data28_B4!,
(int)device.Data28_B3!,
(int)device.Data28_B2!,
(int)device.Data28_B1!,
(int)device.Data28_B0!
};
bytes.AddRange(Data7.BitArray2Byte());
int[] Data8 = new int[] {
(int)device.Data8_B7_1104!,
(int)device.Data29_B6!,
(int)device.Data29_B5!,
(int)device.Data29_B4!,
(int)device.Data29_B3!,
0,
0,
0
};
bytes.AddRange(Data8.BitArray2Byte());
bytes.AddRange(((int)device.Data30!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data31!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data32_33!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data34!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data35!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data36!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data37!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data38_39!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data40!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data41!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data42_43!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data44!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.Data45_46!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data47_48!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data49_50!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data51_52!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data53_54!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data55_56!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data57_58!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data59_60!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data61_62!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data63_64!).Int2Byte().BytePadLeft(2));
bytes.AddRange(((int)device.Data65_66!).Int2Byte().BytePadLeft(2));
int[] Data32 = new int[] {
(int)device.Data67_B7!,
(int)device.Data67_B6!,
(int)device.Data67_B5!,
(int)device.Data67_B4!,
(int)device.Data67_B3!,
(int)device.Data67_B2!,
(int)device.Data67_B1!,
(int)device.Data67_B0!
};
bytes.AddRange(Data32.BitArray2Byte());
int[] Data33 = new int[] {
(int)device.Data68_B7!,
(int)device.Data68_B6!,
(int)device.Data68_B5!,
(int)device.Data68_B4!,
(int)device.Data68_B3!,
(int)device.Data68_B2!,
(int)device.Data68_B1!,
(int)device.Data68_B0!
};
bytes.AddRange(Data33.BitArray2Byte());
int[] Data34 = new int[] {
(int)device.Data69_B7!,
(int)device.Data69_B6!,
(int)device.Data69_B5!,
(int)device.Data69_B4!,
(int)device.Data69_B3!,
(int)device.Data69_B2!,
(int)device.Data69_B1!,
(int)device.Data69_B0!
};
bytes.AddRange(Data34.BitArray2Byte());
int[] Data35 = new int[] {
(int)device.Data70_B7!,
(int)device.Data70_B6!,
(int)device.Data70_B5!,
(int)device.Data70_B4!,
(int)device.Data70_B3!,
(int)device.Data70_B2!,
(int)device.Data70_B1!,
(int)device.Data70_B0!
};
bytes.AddRange(Data35.BitArray2Byte());
int[] Data36 = new int[] {
(int)device.Data71_B7!,
(int)device.Data71_B6!,
(int)device.Data71_B5!,
(int)device.Data71_B4!,
(int)device.Data71_B3!,
(int)device.Data71_B2!,
(int)device.Data71_B1!,
(int)device.Data71_B0!
};
bytes.AddRange(Data36.BitArray2Byte());
int[] Data37 = new int[] {
(int)device.Data72_B7!,
(int)device.Data72_B6!,
(int)device.Data72_B5!,
(int)device.Data72_B4!,
0,
0,
0,
0
};
bytes.AddRange(Data37.BitArray2Byte());
var ConnectByte = Encoding.ASCII.GetBytes(device.ConnectString!);
device.ConnectStrLength = device.ConnectString!.Length;
bytes.AddRange(((int)device.ConnectStrLength!).Int2Byte().BytePadLeft(1));
bytes.AddRange(ConnectByte);
}
private void Encode1107ZK(List<byte> bytes, DeviceData device)
{
bytes.AddRange(((int)device.UVersion!).Int2Byte().BytePadLeft(2));
var FtpUrlByte = Encoding.ASCII.GetBytes(device.FtpUrl!);
device.FtpLength = device.FtpUrl!.Length;
bytes.AddRange(((int)device.FtpLength!).Int2Byte().BytePadLeft(1));
bytes.AddRange(FtpUrlByte);
var FtpUserByte = Encoding.ASCII.GetBytes(device.UserPwd!);
device.UserLength = device.UserPwd!.Length;
bytes.AddRange(((int)device.UserLength!).Int2Byte().BytePadLeft(1));
bytes.AddRange(FtpUserByte);
var BinUrlByte = Encoding.ASCII.GetBytes(device.BinUrl!);
device.BinLength = device.BinUrl!.Length;
bytes.AddRange(((int)device.BinLength!).Int2Byte().BytePadLeft(1));
bytes.AddRange(BinUrlByte);
bytes.AddRange(((int)device.BinSize!).Int2Byte().BytePadLeft(3));
bytes.AddRange(((int)device.UpdateSpan!).Int2Byte().BytePadLeft(1));
}
private void Encode2104ZK(List<byte> bytes, DeviceData device)
{
bytes.AddRange(((int)device.Version!).Int2Byte().BytePadLeft(1));
bytes.AddRange(((int)device.DataTick!).Int2Byte().BytePadLeft(2));
bytes.AddRange(0.Int2Byte().BytePadLeft(4));
var ConnectByte = Encoding.ASCII.GetBytes(device.ConnectString!);
device.ConnectStrLength = device.ConnectString!.Length;
bytes.AddRange(((int)device.ConnectStrLength!).Int2Byte().BytePadLeft(1));
bytes.AddRange(ConnectByte);
}
}
}

@ -26,6 +26,7 @@ using DotNetty.Transport.Channels.Groups;
using CommonModel;
using DotNetty.Handlers.Timeout;
using System.Diagnostics;
using System.Reflection;
namespace LanShengService
{
@ -117,7 +118,7 @@ namespace LanShengService
Bootstrap
.Option(ChannelOption.SoBacklog, 1024)
.Option(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
.Option(ChannelOption.RcvbufAllocator,new AdaptiveRecvByteBufAllocator())
.Option(ChannelOption.RcvbufAllocator, new AdaptiveRecvByteBufAllocator())
.ChildOption(ChannelOption.Allocator, UnpooledByteBufferAllocator.Default)
.ChildOption(ChannelOption.RcvbufAllocator, new AdaptiveRecvByteBufAllocator())
.ChildOption(ChannelOption.SoKeepalive, true)
@ -208,7 +209,7 @@ namespace LanShengService
Frame_START = "FAAA",
Frame_number = Frame_number,
DTU_ID = deviceData.Id,
Msg_ID = "1104",
Msg_ID = string.IsNullOrEmpty(deviceData.MsgType) ? "1104" : deviceData.MsgType,
Frame_END = "BBFB",
Content = deviceData
};
@ -231,34 +232,8 @@ namespace LanShengService
{
var oldData = Db.Queryable<DeviceData>().Where(x => x.Id == deviceData.Id).First();
if (deviceData.Version == null)
{
deviceData.Version = oldData.Version;
}
if (deviceData.DataTick == null)
{
deviceData.DataTick = oldData.DataTick;
}
if (deviceData.Data27_B7 == null)
{
deviceData.Data27_B7 = oldData.Data27_B7;
}
if (deviceData.Data27_B6 == null)
{
deviceData.Data27_B6 = oldData.Data27_B6;
}
if (deviceData.Data27_B5 == null)
{
deviceData.Data27_B5 = oldData.Data27_B5;
}
if (deviceData.Data27_B4 == null)
{
deviceData.Data27_B4 = oldData.Data27_B4;
}
if (deviceData.Data27_B3 == null)
{
deviceData.Data27_B3 = oldData.Data27_B3;
}
Type TempType = typeof(DeviceData);
PropertyInfo[] TempPropertys = TempType.GetProperties();
if (deviceData.ConnectString != null && deviceData.ConnectString != oldData.ConnectString)
{
deviceData.Data27_B0 = 1;
@ -267,50 +242,26 @@ namespace LanShengService
{
deviceData.Data27_B0 = 0;
}
if (deviceData.Data23 == null)
{
deviceData.Data23 = oldData.Data23;
}
if (deviceData.Data20 == null)
{
deviceData.Data20 = oldData.Data20;
}
if (deviceData.Data19 == null)
{
deviceData.Data19 = oldData.Data19;
}
if (deviceData.Data18 == null)
{
deviceData.Data18 = oldData.Data18;
}
if (deviceData.Data16_B2 == null)
{
deviceData.Data16_B2 = oldData.Data16_B2;
}
if (deviceData.Data25_B4 == null)
if (deviceData.UpdateTag == null)
{
deviceData.Data25_B4 = oldData.Data25_B4;
deviceData.UpdateTag = 0;
}
if (deviceData.Data25_B0 == null)
if (deviceData.Data8_B7_1104 == null)
{
deviceData.Data25_B0 = oldData.Data25_B0;
deviceData.Data8_B7_1104 = 0;
}
if (deviceData.Data26_B4 == null)
if (deviceData.BinSize == null)
{
deviceData.Data26_B4 = oldData.Data26_B4;
deviceData.BinSize = 0;
}
if (deviceData.Data26_B0 == null)
foreach (PropertyInfo propertyInfo in TempPropertys)
{
deviceData.Data26_B0 = oldData.Data26_B0;
}
if (deviceData.UpdateTag == null)
if (propertyInfo.GetValue(deviceData) == null)
{
deviceData.UpdateTag = 0;
propertyInfo.SetValue(deviceData, propertyInfo.GetValue(oldData));
}
if (deviceData.ConnectString == null)
{
deviceData.ConnectString = oldData.ConnectString;
}
return Task.CompletedTask;
}

@ -151,6 +151,12 @@ namespace ZhongLianModel
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public string[]? ProcessResultPhoto { get; set; }
/// <summary>
/// 备注照片图片
/// </summary>
[SugarColumn(IsJson = true, IsNullable = true, ColumnDataType = "Text")]
public string[]? RemarkPhoto { get; set; }
/// <summary>
/// 创建日期
/// </summary>

@ -313,9 +313,10 @@ namespace ZhongLianService
.WhereIF(pageSearch.Mode != null && !string.IsNullOrEmpty(pageSearch.Mode.PatrolUid), x =>
x.PatrolUid == pageSearch.Mode!.PatrolUid
)
.OrderByDescending(x => x.Id)
.SplitTable((DateTime)pageSearch.StartDate!, (DateTime)pageSearch.EndDate!)
.OrderByDescending(x => x.Id)
.ToPageListAsync(pageSearch.Index, pageSearch.Size, _Total);
return new PageData<InstallDO>()
{
Index = pageSearch.Index,

@ -146,9 +146,9 @@ namespace ZhongLianService
.WhereIF(pageSearch.Mode != null && !string.IsNullOrEmpty(pageSearch.Mode.MaintenanceUid), x =>
x.MaintenanceUid == pageSearch.Mode!.MaintenanceUid
)
.SplitTable((DateTime)pageSearch.StartDate!, (DateTime)pageSearch.EndDate!)
.OrderBy("(CASE State WHEN 2 THEN 0 ELSE State END) ASC")
.OrderByDescending(x => x.Id)
.SplitTable((DateTime)pageSearch.StartDate!, (DateTime)pageSearch.EndDate!)
.ToPageListAsync(pageSearch.Index, pageSearch.Size, _Total);
return new PageData<MaintenanceDO>()
{

Loading…
Cancel
Save