Browse Source

更新上下线转存

master
fyf 2 years ago
parent
commit
60172250ca
2 changed files with 71 additions and 33 deletions
  1. +1
    -1
      DataVAPI/Controllers/DeviceController.cs
  2. +70
    -32
      DataVAPI/UpAndDown/ProcessServer.cs

+ 1
- 1
DataVAPI/Controllers/DeviceController.cs View File

@@ -227,7 +227,7 @@ namespace DataVAPI.Controllers
st = System.Reflection.MethodBase.GetCurrentMethod().Name;
try
{
ProcessServer.Instance.LoadingShopInformation();
ProcessServer.Instance.LoadingShopInformationNew();
return JsonMsg<string>.OK("success!", st);
}
catch (Exception ex)


+ 70
- 32
DataVAPI/UpAndDown/ProcessServer.cs View File

@@ -58,7 +58,7 @@ namespace DataVAPI.UpAndDown
devModel.infoMessage = new InfoMessage(); devModel.infoMessage.data = new List<DeviceBase>();//通知消息

//加载店铺信息 //加载店铺信息
LoadingShopInformation();
LoadingShopInformationNew();
//MQTT 数据接收处理
ConsoleHelper.WriteInfoLine("尝试连接阿里云.");
//设置变量
@@ -163,6 +163,29 @@ namespace DataVAPI.UpAndDown
});
}

public void LoadingShopInformationNew()
{
devModel.operatingDeviceStatus.data.Clear();
var jsonMsg = deviceController.Query("", "", DateTime.MinValue, DateTime.MinValue);
jsonMsg.obj?.data?.ForEach(par =>
{
DevStatus devStatus = new DevStatus()
{
deviceName = par.devicename,
gmtCreate = par.devicesecret,
productKey = par.productkey,
DeviceMC = par.devtype,
DeviceMS = par.remark,
DeviceSJ = par.CreateTime.ToString("yyyy-MM-dd HH:mm:ss"),
DeviceZT = "离线",
clientId = par.ClientId,
deviceId = par.DeviceId
};
ConsoleHelper.WriteSuccessLine($"加载设备.{par.devtype} {par.remark}");
});
ConsoleHelper.WriteSuccessLine($"加载设备数[ {jsonMsg?.obj?.data?.Count} ]台...");
}

/// <summary>
/// 加载店铺信息
/// </summary>
@@ -261,38 +284,53 @@ namespace DataVAPI.UpAndDown
{
if (receiveModel?.deviceContext != null && receiveModel?.status != null)//状态变更消息
{
devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName)?.SetStatus(receiveModel.status.value);
//devModel?.infoMessage?.data?.Add(new DeviceBase { DeviceMC = receiveModel.deviceContext.deviceName, DeviceMS = $"设备{receiveModel.status.value}了!", DeviceSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });

DevStatus dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName);
if (dev == null) { LoadingShopInformation(); }
dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName);
if (dev != null)
{
logController.Create(new LogTable
{
devicename = receiveModel.deviceContext.deviceName,
ClientId = dev.clientId,
DeviceId = dev.deviceId,
LogTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
LogType = "提示",
LogMessage = $"设备{receiveModel.status.value}了!",
LogVla = "通知"
});
OnOrOffline(receiveModel.status.value, devModel.operatingDeviceStatus.data, dev);
}
else
var k= devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName);
logController.Create(new LogTable
{
LoadingShopInformation();
}
devicename = receiveModel.deviceContext.deviceName,
ClientId = k.clientId,
DeviceId = k.deviceId,
LogTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
LogType = "提示",
LogMessage = $"设备{receiveModel.status.value}了!",
LogVla = "通知"
});
}
//if (receiveModel?.deviceContext != null && receiveModel?.status != null)//状态变更消息
//{
// devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName)?.SetStatus(receiveModel.status.value);
// //devModel?.infoMessage?.data?.Add(new DeviceBase { DeviceMC = receiveModel.deviceContext.deviceName, DeviceMS = $"设备{receiveModel.status.value}了!", DeviceSJ = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") });

// DevStatus dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName);
// if (dev == null) { LoadingShopInformation(); }
// dev = devModel?.operatingDeviceStatus.data?.Find(par => par.deviceName == receiveModel.deviceContext.deviceName);
// if (dev != null)
// {
// logController.Create(new LogTable
// {
// devicename = receiveModel.deviceContext.deviceName,
// ClientId = dev.clientId,
// DeviceId = dev.deviceId,
// LogTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
// LogType = "提示",
// LogMessage = $"设备{receiveModel.status.value}了!",
// LogVla = "通知"
// });
// OnOrOffline(receiveModel.status.value, devModel.operatingDeviceStatus.data, dev);
// }
// else
// {
// LoadingShopInformation();
// }
//}

//devModel.OrderLine = orderProvider.OrderLine(new DataVApi.Order.RequestModel.FullScreenBasic());
//devModel.OrderDataState = orderProvider.GetAllOrderDataState(new DataVApi.Order.RequestModel.FullScreenInput());
////devModel.LocSale = orderProvider.GetLocSale();
//object obj = orderProvider.OrderNumber(new DataVApi.Order.RequestModel.FullScreenBasic());
//devModel.OrderNumber = Tools.JsonToObjectTools<OrderCount>(Tools.JsonConvertTools(obj));
ScreenMonitorModel screen1Monitor = Tools.JsonToObjectTools<ScreenMonitorModel>(devModel.ToJSON());
// ScreenMonitorModel screen1Monitor = Tools.JsonToObjectTools<ScreenMonitorModel>(devModel.ToJSON());
#region 1.设置data默认值
//if (screen1Monitor.operatingDeviceStatus.data.Count == 0)
//{
@@ -304,12 +342,12 @@ namespace DataVAPI.UpAndDown
//}
#endregion

string JSON = screen1Monitor.ToJSON();
if (!string.IsNullOrEmpty(JSON))
{
//screenController.CreateOrUpdate(new LargeScreenTable() { json = JSON, devicename = "Transit", ClientId = "-10", DeviceId = "-10" });
IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.ScreenShowPubTopic, JSON);
}
//string JSON = screen1Monitor.ToJSON();
//if (!string.IsNullOrEmpty(JSON))
//{
// //screenController.CreateOrUpdate(new LargeScreenTable() { json = JSON, devicename = "Transit", ClientId = "-10", DeviceId = "-10" });
// IOTDevServer.GetInstance().IOT_Publish(IOTDevServer.ScreenShowPubTopic, JSON);
//}

//if (devModel.infoMessage.data != null && devModel.infoMessage.data.Count > 0)
//{
@@ -418,7 +456,7 @@ namespace DataVAPI.UpAndDown
}
else if (message == "刷新店铺列表")
{
LoadingShopInformation();
LoadingShopInformationNew();
}
}
//else if (topic == IOTDevServer.TargetStatusSubTopic)//属性变更


Loading…
Cancel
Save