Переглянути джерело

提交最新代码

master
fyf 2 роки тому
джерело
коміт
0682de9627
3 змінених файлів з 118 додано та 11 видалено
  1. +79
    -1
      DataVAPI.Tools/IOT/ScreenMonitorModel.cs
  2. +29
    -8
      DataVAPI/UpAndDown/ProcessServer.cs
  3. +10
    -2
      DataVApi.Order/OrderProvider.cs

+ 79
- 1
DataVAPI.Tools/IOT/ScreenMonitorModel.cs Переглянути файл

@@ -35,7 +35,7 @@ namespace DataVAPI.Tool.IOT
/// <summary>
/// 下单数量
/// </summary>
public object OrderNumber { get; set; }
public OrderCount OrderNumber { get; set; }
/// 返回JSON
/// </summary>
/// <returns></returns>
@@ -149,6 +149,84 @@ namespace DataVAPI.Tool.IOT
public List<DevStatus> data { get; set; }
}
/// <summary>
/// 订单数量
/// </summary>
public class OrderCount
{
public int Year { get; set; }
public int L_Year { get; set; }
public int Month { get; set; }
public int L_Month { get; set; }
public int Day { get; set; }
public int L_Day { get; set; }

private string B_Year_Str { get; set; }
public ALYColor YearColor { get; set; }
private int _B_Year { get; set; }
public int B_Year
{
get { return _B_Year; }
set
{
_B_Year = value;
if (_B_Year > 0)
{
YearColor = new ALYColor { r = 18, g = 186, b = 96, a = 1 };
B_Year_Str = $"增长 {_B_Year}%";
}
else
{
YearColor = new ALYColor { r = 255, g = 0, b = 0, a = 1 };
B_Year_Str = $"下降 {_B_Year}%";
}
}
}

private string B_Month_Str { get; set; }
public ALYColor MonthColor { get; set; }
private int _B_Month { get; set; }
public int B_Month
{
get { return _B_Month; }
set
{
_B_Month = value;
if (_B_Month > 0)
{
MonthColor = new ALYColor { r = 18, g = 186, b = 96, a = 1 };
B_Month_Str = $"增长 {_B_Year}%";
}
else
{
MonthColor = new ALYColor { r = 255, g = 0, b = 0, a = 1 };
B_Month_Str = $"下降 {_B_Year}%";
}
}
}

private string B_Day_Str { get; set; }
public ALYColor DayColor { get; set; }
private int _B_Day { get; set; }
public int B_Day
{
get { return _B_Day; }
set
{
_B_Day = value;
if (_B_Day > 0)
{
DayColor = new ALYColor { r = 18, g = 186, b = 96, a = 1 };
B_Day_Str = $"增长 {_B_Year}%";
}
else
{
DayColor = new ALYColor { r = 255, g = 0, b = 0, a = 1 };
B_Day_Str = $"下降 {_B_Year}%";
}
}
}
}
/// <summary>
/// 设备状态
/// </summary>
public class DevStatus : DeviceBase


+ 29
- 8
DataVAPI/UpAndDown/ProcessServer.cs Переглянути файл

@@ -20,14 +20,11 @@ namespace DataVAPI.UpAndDown
/// 上报大屏总Model
/// </summary>
public ScreenMonitorModel devModel { get; set; }

public DeviceController deviceController { get; set; }
public LogController logController { get; set; }
public ScreenController screenController { get; set; }
public AlarmController alarmController { get; set; }
public OrderProvider orderProvider { get; set; }


#region 不需要监听
private static ProcessServer _instance;
public static ProcessServer Instance
@@ -56,12 +53,15 @@ namespace DataVAPI.UpAndDown
devModel = new ScreenMonitorModel();
devModel.operatingDeviceStatus = new OperatingDeviceStatus(); devModel.operatingDeviceStatus.data = new List<DevStatus>();//现场设备于状态
devModel.infoMessage = new InfoMessage(); devModel.infoMessage.data = new List<DeviceBase>();//通知消息

//加载店铺信息 //加载店铺信息
LoadingShopInformation();
//MQTT 数据接收处理
ConsoleHelper.WriteInfoLine("尝试连接阿里云.");
if (IOTDevServer.GetInstance().CreateLinks("grgpECHSL7q", "Transit", "562dcc779b918a54c2d6589ec30ee230"))
{
ConsoleHelper.WriteSuccessLine($"阿里云【Transit】连接成功");
}
else
{
ConsoleHelper.WriteSuccessLine($"阿里云【Transit】连接失败");
@@ -73,10 +73,12 @@ namespace DataVAPI.UpAndDown
Subscribe(IOTDevServer.HeartbeatSubTopic);

IOTDevServer.DevIOTAction += DevIOTActionHandler;
//执行队列任务
QueueTask();

ConsoleHelper.WriteSuccessLine("开始接收数据,执行队列任务!");
}

/// <summary>
/// 队列任务
/// </summary>
@@ -116,7 +118,7 @@ namespace DataVAPI.UpAndDown
if (!string.IsNullOrEmpty(par.clientId))
{
JsonMsg<List<AlarmTable>> jsonMsg = alarmController.QueryClientId(par.clientId);
par.IsAlarm = (jsonMsg.obj != null && jsonMsg.obj.data != null && jsonMsg.obj.data.Count > 0)?true:false;//ApiGetAlarm(par.clientId);
par.IsAlarm = (jsonMsg.obj != null && jsonMsg.obj.data != null && jsonMsg.obj.data.Count > 0)?true:false;
}
});
}
@@ -189,7 +191,6 @@ namespace DataVAPI.UpAndDown
IOTDevServer.GetInstance().IOT_Publish(PubTopic, Tools.JsonConvertTools<CommandModel>(command));
}


/// <summary>
/// 更新内存集合
/// </summary>
@@ -215,6 +216,10 @@ namespace DataVAPI.UpAndDown
LogMessage = $"设备{receiveModel.status.value}了!",
LogVla = "通知"
});
int index = 0;
if (receiveModel.status.value == "离线") index = devModel.operatingDeviceStatus.data.Count - 1;
int now = devModel.operatingDeviceStatus.data.IndexOf(dev);
Swap(devModel.operatingDeviceStatus.data, index, now);
}
else
{
@@ -225,8 +230,8 @@ namespace DataVAPI.UpAndDown
devModel.OrderLine = orderProvider.OrderLine(new DataVApi.Order.RequestModel.FullScreenBasic());
devModel.OrderDataState = orderProvider.GetAllOrderDataState(new DataVApi.Order.RequestModel.FullScreenInput()); devModel.OrderDataState = orderProvider.GetAllOrderDataState(new DataVApi.Order.RequestModel.FullScreenInput());
devModel.LocSale = orderProvider.GetLocSale();
devModel.OrderNumber = orderProvider.OrderNumber(new DataVApi.Order.RequestModel.FullScreenBasic());
object obj = orderProvider.OrderNumber(new DataVApi.Order.RequestModel.FullScreenBasic());
devModel.OrderNumber = Tools.JsonToObjectTools<OrderCount>(Tools.JsonConvertTools(obj));
ScreenMonitorModel screen1Monitor = Tools.JsonToObjectTools<ScreenMonitorModel>(devModel.ToJSON());
#region 1.设置data默认值
if (screen1Monitor.operatingDeviceStatus.data.Count == 0)
@@ -266,6 +271,22 @@ namespace DataVAPI.UpAndDown
}
}

/// <summary>
/// list 位置交换
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="list"></param>
/// <param name="index1"></param>
/// <param name="index2"></param>
/// <returns></returns>
private static List<T> Swap<T>(List<T> list, int index1, int index2)
{
var temp = list[index1];
list[index1] = list[index2];
list[index2] = temp;
return list;
}

/// <summary>
/// MQTT 消息
/// </summary>


+ 10
- 2
DataVApi.Order/OrderProvider.cs Переглянути файл

@@ -90,7 +90,7 @@ WHERE

List<object> res = new List<object>();

for (int index = 0; index < 10; index++)
for (int index = 10; index >= 0; index--)
{
var temp = DateTime.Now.AddDays(-index);
var end = DateTime.Parse(temp.ToString("yyyy-MM-dd 23:59:59"));
@@ -198,9 +198,17 @@ WHERE
return new
{
Year = data.Where(t => t.CreatedAt.Year == DateTime.Now.Year).Count(),
//YearBFB = (data.Where(t => t.CreatedAt.Year == DateTime.Now.Year).Count() / data.Where(t => t.CreatedAt.Year == DateTime.Now.AddYears(-1).Year).Count()),
L_Year = data.Where(t => t.CreatedAt.Year == DateTime.Now.AddYears(-1).Year).Count(),
B_Year = (data.Where(t => t.CreatedAt.Year == DateTime.Now.Year).Count() - data.Where(t => t.CreatedAt.Year == DateTime.Now.AddYears(-1).Year).Count())*100/(data.Where(t => t.CreatedAt.Year == DateTime.Now.Year).Count() + data.Where(t => t.CreatedAt.Year == DateTime.Now.AddYears(-1).Year).Count()),

Month = data.Where(t => t.CreatedAt.Month == DateTime.Now.Month).Count(),
L_Month = data.Where(t => t.CreatedAt.Month == DateTime.Now.AddMonths(-1).Month).Count(),
B_Month = (data.Where(t => t.CreatedAt.Month == DateTime.Now.Month).Count() - data.Where(t => t.CreatedAt.Month == DateTime.Now.AddMonths(-1).Month).Count()) * 100 / (data.Where(t => t.CreatedAt.Month == DateTime.Now.Month).Count() + data.Where(t => t.CreatedAt.Month == DateTime.Now.AddMonths(-1).Month).Count()),

Day = data.Where(t => t.CreatedAt.Day == DateTime.Now.Day).Count(),
L_Day = data.Where(t => t.CreatedAt.Day == DateTime.Now.AddDays(-1).Day).Count(),
B_Day = (data.Where(t => t.CreatedAt.Day == DateTime.Now.Day).Count() - data.Where(t => t.CreatedAt.Day == DateTime.Now.AddDays(-1).Day).Count()) * 100 / (data.Where(t => t.CreatedAt.Day == DateTime.Now.Day).Count() + data.Where(t => t.CreatedAt.Day == DateTime.Now.AddDays(-1).Day).Count())

};
}
}


Завантаження…
Відмінити
Зберегти