|
@@ -1,18 +1,26 @@
|
|
|
using ControlzEx.Standard;
|
|
|
+using ControlzEx.Theming;
|
|
|
using LiveCharts.Helpers;
|
|
|
+using LiveCharts.Wpf;
|
|
|
+using Microsoft.DwayneNeed.Shapes;
|
|
|
using Microsoft.DwayneNeed.Win32.Gdi32;
|
|
|
+using Microsoft.DwayneNeed.Win32.User32;
|
|
|
using MySqlX.XDevAPI.Common;
|
|
|
using NPOI.HSSF.Record;
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
using SCADA;
|
|
|
using SCADA.Comm;
|
|
|
+using SCADA.CommonCtrl.WpfWindow;
|
|
|
using SCADA.CommonLib;
|
|
|
+using SCADA.CommonLib.Data.DIL;
|
|
|
using SCADA.CommonLib.Helper;
|
|
|
using SCADA.CommonLib.Service;
|
|
|
using SCADA_DAQ.Customer.Models.DeviceMap;
|
|
|
using SCADA_DAQ.Customer.Models.NoticeManagement;
|
|
|
+using SCADA_DAQ.Customer.Models.ProductionLineManagement;
|
|
|
using SCADA_DAQ.Customer.Models.TaskManagement;
|
|
|
using System;
|
|
|
+using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel;
|
|
|
using System.Data;
|
|
@@ -38,14 +46,14 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
|
|
|
// 静态缓存时长/s
|
|
|
private static int staticCacheDuration = 2;
|
|
|
-
|
|
|
- // 静态缓存持续时间/s
|
|
|
- private static int taskInfoStaticCacheDuration = 0;
|
|
|
- private static int outputAndOrderStaticCacheDuration = 0;
|
|
|
-
|
|
|
- // 静态缓存结果
|
|
|
- private object taskInfoStaticCache = null;
|
|
|
- private object OutputAndOrderStaticCache = null;
|
|
|
+ // 静态缓存
|
|
|
+ private Dictionary<string, Dictionary<string, object>> StaticCache =
|
|
|
+ new Dictionary<string, Dictionary<string, object>>()
|
|
|
+ {
|
|
|
+ { "GetTaskInfo", new Dictionary<string, object>(){ {"Time",DateTime.Now}, { "Cache", null} } },
|
|
|
+ { "GetOutputAndOrder", new Dictionary<string, object>(){ { "Time", DateTime.Now }, { "Cache", null} } },
|
|
|
+ { "GetNoticeInfo", new Dictionary<string, object>(){ { "Time", DateTime.Now }, { "Cache", null} } }
|
|
|
+ };
|
|
|
|
|
|
|
|
|
private static CustomerService _instance;
|
|
@@ -89,26 +97,25 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
public override bool Start()
|
|
|
{
|
|
|
RpcService.GetInstance().Regiseter(this); //将服务中方法注册到RPC服务器,可以给WebApi调用
|
|
|
- Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
|
|
|
+ //Env.Schedual.DateTimeChanged += Schedual_DateTimeChanged;
|
|
|
+
|
|
|
+ // 创建定时任务
|
|
|
+ //CreateTask(GetData, );
|
|
|
return base.Start();
|
|
|
}
|
|
|
|
|
|
- /// <summary>
|
|
|
- /// 定时器
|
|
|
- /// </summary>
|
|
|
- /// <param name="sender"></param>
|
|
|
- /// <param name="e"></param>
|
|
|
- private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
|
|
|
- {
|
|
|
- if (e.TimeFlag.Second % 1 == 0)
|
|
|
- {
|
|
|
- if (taskInfoStaticCacheDuration > 0)
|
|
|
- taskInfoStaticCacheDuration--;
|
|
|
+ ///// <summary>
|
|
|
+ ///// 定时器
|
|
|
+ ///// </summary>
|
|
|
+ ///// <param name="sender"></param>
|
|
|
+ ///// <param name="e"></param>
|
|
|
+ //private void Schedual_DateTimeChanged(object sender, DateTimeChangedArgs e)
|
|
|
+ //{
|
|
|
+ // if (e.TimeFlag.Second % 1 == 0)
|
|
|
+ // {
|
|
|
|
|
|
- if (outputAndOrderStaticCacheDuration > 0)
|
|
|
- outputAndOrderStaticCacheDuration--;
|
|
|
- }
|
|
|
- }
|
|
|
+ // }
|
|
|
+ //}
|
|
|
|
|
|
|
|
|
|
|
@@ -152,19 +159,17 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
/// <returns>响应对象</returns>
|
|
|
public RpcResponse<object> GetTaskInfo(List<string> workShopId, List<string> productionLineId)
|
|
|
{
|
|
|
-
|
|
|
// 判断参数合理性
|
|
|
if (workShopId == null || productionLineId == null)
|
|
|
return new RpcResponse<object>() { Data = null, Message = "paras is empty." };
|
|
|
|
|
|
-
|
|
|
// 禁用动态缓存
|
|
|
var disableDynamicCache = true;
|
|
|
|
|
|
// 返回静态缓存
|
|
|
- if (taskInfoStaticCacheDuration > 0)
|
|
|
- return new RpcResponse<object>() { Data = taskInfoStaticCache, Message = null };
|
|
|
-
|
|
|
+ var timespan = (DateTime.Now - (DateTime)StaticCache["GetTaskInfo"]["Time"]).TotalSeconds;
|
|
|
+ if (timespan < staticCacheDuration)
|
|
|
+ return new RpcResponse<object>() { Data = StaticCache["GetTaskInfo"]["Cache"], Message = null };
|
|
|
|
|
|
List<TaskManagementModel> tableInfo = new List<TaskManagementModel>();
|
|
|
if (CustomerEnv.TaskInfoCache.Count <= 0 || disableDynamicCache)
|
|
@@ -204,7 +209,7 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
{
|
|
|
tableInfo = CustomerEnv.TaskInfoCache;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
// select多个字段,使用匿名类型
|
|
|
var result = tableInfo.Select((item) => new
|
|
@@ -224,12 +229,138 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
CompletionRate = Math.Round((double)item.CurrentProduction / (double)item.ScheduledProduction, 2)
|
|
|
}).ToList();
|
|
|
|
|
|
- // 启用静态缓存
|
|
|
- taskInfoStaticCacheDuration = staticCacheDuration;
|
|
|
- taskInfoStaticCache = result;
|
|
|
+ // 设置静态缓存
|
|
|
+ StaticCache["GetTaskInfo"] = new Dictionary<string, object>()
|
|
|
+ { { "Time", DateTime.Now}, { "Cache", result} };
|
|
|
return new RpcResponse<object>() { Data = result, Message = null };
|
|
|
}
|
|
|
|
|
|
+ ///// <summary>
|
|
|
+ ///// 获取产量和工单数
|
|
|
+ ///// </summary>
|
|
|
+ ///// <param name="workShopId">车间号</param>
|
|
|
+ ///// <param name="productionLineId">产线号</param>
|
|
|
+ ///// <param name="year">年份</param>
|
|
|
+ ///// <param name="month">月份</param>
|
|
|
+ ///// <returns></returns>
|
|
|
+ //public RpcResponse<object> GetOutputAndOrder(List<string> workShopId, List<string> productionLineId, int year, int month)
|
|
|
+ //{
|
|
|
+ // // 判断参数合理性
|
|
|
+ // if (workShopId == null || productionLineId == null)
|
|
|
+ // return new RpcResponse<object>() { Data = null, Message = "paras is empty." };
|
|
|
+
|
|
|
+ // // 返回静态缓存
|
|
|
+ // if (outputAndOrderStaticCacheDuration > 0)
|
|
|
+ // return new RpcResponse<object>() { Data = OutputAndOrderStaticCache, Message = null };
|
|
|
+
|
|
|
+ // bool isAllShop = false; // 是否查询所有车间
|
|
|
+ // bool isAllLine = false; // 是否查询所有产线
|
|
|
+ // bool isAllYear = false; // 是否查询所有年份
|
|
|
+ // bool isAllMonth = false; // 是否查询所有月份
|
|
|
+
|
|
|
+ // if (workShopId.Count <= 0)
|
|
|
+ // isAllShop = true;
|
|
|
+ // if (productionLineId.Count <= 0)
|
|
|
+ // isAllLine = true;
|
|
|
+ // if (year <= 0)
|
|
|
+ // isAllYear = true;
|
|
|
+ // if (month <= 0)
|
|
|
+ // isAllMonth = true;
|
|
|
+
|
|
|
+ // // 查询数据库
|
|
|
+ // List<TaskManagementModel> tableInfo = DAL.APP_TaiLing_TaskManagement.GetData<TaskManagementModel>();
|
|
|
+ // // tableInfo = DAL.APP_TaiLing_TaskManagement.GetData<TaskManagementModel>(t => t.OrderId == "1");
|
|
|
+ // if (tableInfo == null)
|
|
|
+ // {
|
|
|
+ // return new RpcResponse<object>() { Data = null, Message = null };
|
|
|
+ // }
|
|
|
+
|
|
|
+ // List<int> yearList = new List<int>(); // 年份列表
|
|
|
+ // List<object> resList = new List<object>(); // 结果列表
|
|
|
+
|
|
|
+
|
|
|
+ // if (!isAllShop)
|
|
|
+ // {
|
|
|
+ // var workShopIdDic = workShopId.ToLookup(t => t);
|
|
|
+ // // workShopId 不为空就查询指定车
|
|
|
+ // tableInfo = tableInfo.Where(t => workShopIdDic.Contains(t.WorkShopId)).ToList();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (!isAllLine)
|
|
|
+ // {
|
|
|
+ // // productionLineId 不为空就查询指定产线号
|
|
|
+ // tableInfo = tableInfo.Where(t => productionLineId.IndexOf(t.ProductionLineId) >= 0).ToList();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (!isAllYear)
|
|
|
+ // {
|
|
|
+ // // year>0 就查询指定年份
|
|
|
+ // tableInfo = tableInfo.Where(t => t.OrderDatetime.Year == year).ToList();
|
|
|
+ // yearList.Add(year);
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // // year<=0 就把记录时间等于year的放到yearList
|
|
|
+ // yearList = tableInfo.ToLookup(t => t.OrderDatetime.Year).Select(t => t.Key).ToList();
|
|
|
+ // }
|
|
|
+
|
|
|
+ // if (!isAllMonth)
|
|
|
+ // {
|
|
|
+ // // month>0 就查询指定月份
|
|
|
+ // var monthgroup = tableInfo.Where(t => t.OrderDatetime.Month == month).
|
|
|
+ // ToLookup(t => t.OrderDatetime.Year).Select(t => new
|
|
|
+ // {
|
|
|
+ // Year = t.Key,
|
|
|
+ // Month = month,
|
|
|
+ // Output = t.Sum(p => p.CurrentProduction),
|
|
|
+ // OrderQuantity = t.Count(),
|
|
|
+ // TotalDurationSec = t.Sum(p => p.DurationSec)
|
|
|
+ // });
|
|
|
+ // // 启用静态缓存
|
|
|
+ // outputAndOrderStaticCacheDuration = staticCacheDuration;
|
|
|
+ // OutputAndOrderStaticCache = monthgroup;
|
|
|
+ // return new RpcResponse<object>() { Data = monthgroup, Message = null };
|
|
|
+ // }
|
|
|
+
|
|
|
+ // tableInfo.ToLookup(t => t.OrderDatetime.Year).ForEach(yearData =>
|
|
|
+ // {
|
|
|
+ // Dictionary<int, int> yearOutput = new Dictionary<int, int>{
|
|
|
+ // { 1, 0 },{ 2, 0 },{ 3, 0 },{ 4, 0 },{ 5, 0 },{ 6, 0 },
|
|
|
+ // { 7, 0 },{ 8, 0 },{ 9, 0 },{ 10, 0 },{ 11, 0 },{ 12, 0 }
|
|
|
+ // };
|
|
|
+ // Dictionary<int, int> yearOrderQuantity = new Dictionary<int, int>{
|
|
|
+ // { 1, 0 },{ 2, 0 },{ 3, 0 },{ 4, 0 },{ 5, 0 },{ 6, 0 },
|
|
|
+ // { 7, 0 },{ 8, 0 },{ 9, 0 },{ 10, 0 },{ 11, 0 },{ 12, 0 }
|
|
|
+ // };
|
|
|
+ // Dictionary<int, int> yearDurationSec = new Dictionary<int, int>{
|
|
|
+ // { 1, 0 },{ 2, 0 },{ 3, 0 },{ 4, 0 },{ 5, 0 },{ 6, 0 },
|
|
|
+ // { 7, 0 },{ 8, 0 },{ 9, 0 },{ 10, 0 },{ 11, 0 },{ 12, 0 }
|
|
|
+ // };
|
|
|
+ // foreach (var item in yearData.ToLookup(t => t.OrderDatetime.Month))
|
|
|
+ // {
|
|
|
+ // yearOutput[item.Key] = item.Sum(t => t.CurrentProduction);
|
|
|
+ // yearOrderQuantity[item.Key] = item.Count();
|
|
|
+ // yearDurationSec[item.Key] = item.Sum(t => t.DurationSec);
|
|
|
+ // }
|
|
|
+ // resList.Add(new
|
|
|
+ // {
|
|
|
+ // Year = yearData.Key,
|
|
|
+ // Month = 0,
|
|
|
+ // Output = yearOutput,
|
|
|
+ // OrderQuantity = yearOrderQuantity,
|
|
|
+ // TotalDurationSec = yearDurationSec
|
|
|
+ // });
|
|
|
+
|
|
|
+ // });
|
|
|
+
|
|
|
+ // // 启用静态缓存
|
|
|
+ // outputAndOrderStaticCacheDuration = staticCacheDuration;
|
|
|
+ // OutputAndOrderStaticCache = resList;
|
|
|
+ // return new RpcResponse<object>() { Data = resList, Message = null };
|
|
|
+
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 获取产量和工单数
|
|
|
/// </summary>
|
|
@@ -243,12 +374,12 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
// 判断参数合理性
|
|
|
if (workShopId == null || productionLineId == null)
|
|
|
return new RpcResponse<object>() { Data = null, Message = "paras is empty." };
|
|
|
- //if (workShopId.GetType() != typeof(List<string>) || productionLineId.GetType() != typeof(List<string>))
|
|
|
- // return new RpcResponse<object>() { Data = null, Message = "paras type is not array." };
|
|
|
|
|
|
- // 返回静态缓存
|
|
|
- if (outputAndOrderStaticCacheDuration > 0)
|
|
|
- return new RpcResponse<object>() { Data = OutputAndOrderStaticCache, Message = null };
|
|
|
+ //// 返回静态缓存
|
|
|
+ var timespan = (DateTime.Now - (DateTime)StaticCache["GetOutputAndOrder"]["Time"]).TotalSeconds;
|
|
|
+ if (timespan < staticCacheDuration)
|
|
|
+ return new RpcResponse<object>() { Data = StaticCache["GetOutputAndOrder"]["Cache"], Message = null };
|
|
|
+
|
|
|
|
|
|
bool isAllShop = false; // 是否查询所有车间
|
|
|
bool isAllLine = false; // 是否查询所有产线
|
|
@@ -278,15 +409,17 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
|
|
|
if (!isAllShop)
|
|
|
{
|
|
|
- var workShopIdDic = workShopId.ToLookup(t => t);
|
|
|
+ var workShopIdDic = workShopId.ToLookup(t => t);
|
|
|
// workShopId 不为空就查询指定车
|
|
|
tableInfo = tableInfo.Where(t => workShopIdDic.Contains(t.WorkShopId)).ToList();
|
|
|
}
|
|
|
+
|
|
|
if (!isAllLine)
|
|
|
{
|
|
|
// productionLineId 不为空就查询指定产线号
|
|
|
tableInfo = tableInfo.Where(t => productionLineId.IndexOf(t.ProductionLineId) >= 0).ToList();
|
|
|
}
|
|
|
+
|
|
|
if (!isAllYear)
|
|
|
{
|
|
|
// year>0 就查询指定年份
|
|
@@ -297,32 +430,11 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
{
|
|
|
// year<=0 就把记录时间等于year的放到yearList
|
|
|
yearList = tableInfo.ToLookup(t => t.OrderDatetime.Year).Select(t => t.Key).ToList();
|
|
|
- //tableInfo.ForEach(num =>
|
|
|
- //{
|
|
|
- // if (yearList.IndexOf(num.OrderDatetime.Year) < 0)
|
|
|
- // yearList.Add(num.OrderDatetime.Year);
|
|
|
- //});
|
|
|
}
|
|
|
+
|
|
|
if (!isAllMonth)
|
|
|
{
|
|
|
// month>0 就查询指定月份
|
|
|
- //tableInfo = tableInfo.Where(t => t.OrderDatetime.Month == month).ToList();
|
|
|
- //yearList.ForEach(y =>
|
|
|
- //{
|
|
|
- // //var ytable = tableInfo.Where(t => t.OrderDatetime.Year == y).ToList();
|
|
|
- // //int monthOutput = ytable.Sum(n => n.CurrentProduction); // 月度产量
|
|
|
- // //int monthDurationSec = ytable.Sum(n => n.DurationSec); // 月度订单数
|
|
|
- // //int monthOrderQuantity = ytable.Count(); // 月度生产总时长
|
|
|
-
|
|
|
- // //resList.Add(new
|
|
|
- // //{
|
|
|
- // // Year = y,
|
|
|
- // // Month = month,
|
|
|
- // // Output = monthOutput,
|
|
|
- // // OrderQuantity = monthOrderQuantity,
|
|
|
- // // TotalDurationSec = monthDurationSec
|
|
|
- // //});
|
|
|
- //});
|
|
|
var monthgroup = tableInfo.Where(t => t.OrderDatetime.Month == month).
|
|
|
ToLookup(t => t.OrderDatetime.Year).Select(t => new
|
|
|
{
|
|
@@ -332,9 +444,9 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
OrderQuantity = t.Count(),
|
|
|
TotalDurationSec = t.Sum(p => p.DurationSec)
|
|
|
});
|
|
|
- // 启用静态缓存
|
|
|
- outputAndOrderStaticCacheDuration = staticCacheDuration;
|
|
|
- OutputAndOrderStaticCache = monthgroup;
|
|
|
+ // 设置静态缓存
|
|
|
+ StaticCache["GetOutputAndOrder"] = new Dictionary<string, object>()
|
|
|
+ { { "TIme", DateTime.Now}, { "Cache", monthgroup} };
|
|
|
return new RpcResponse<object>() { Data = monthgroup, Message = null };
|
|
|
}
|
|
|
|
|
@@ -369,52 +481,11 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
|
|
|
});
|
|
|
|
|
|
- // 启用静态缓存
|
|
|
- outputAndOrderStaticCacheDuration = staticCacheDuration;
|
|
|
- OutputAndOrderStaticCache = resList;
|
|
|
+ // 设置静态缓存
|
|
|
+ StaticCache["GetOutputAndOrder"] = new Dictionary<string, object>()
|
|
|
+ { { "Time", DateTime.Now}, { "Cache", resList} };
|
|
|
return new RpcResponse<object>() { Data = resList, Message = null };
|
|
|
|
|
|
- // month<=0
|
|
|
- //yearList.ForEach(y =>
|
|
|
- //{
|
|
|
- // Dictionary<int, int> yearOutput = new Dictionary<int, int>{
|
|
|
- // { 1, 0 },{ 2, 0 },{ 3, 0 },{ 4, 0 },{ 5, 0 },{ 6, 0 },
|
|
|
- // { 7, 0 },{ 8, 0 },{ 9, 0 },{ 10, 0 },{ 11, 0 },{ 12, 0 }
|
|
|
- // };
|
|
|
- // Dictionary<int, int> yearOrderQuantity = new Dictionary<int, int>{
|
|
|
- // { 1, 0 },{ 2, 0 },{ 3, 0 },{ 4, 0 },{ 5, 0 },{ 6, 0 },
|
|
|
- // { 7, 0 },{ 8, 0 },{ 9, 0 },{ 10, 0 },{ 11, 0 },{ 12, 0 }
|
|
|
- // };
|
|
|
- // Dictionary<int, int> yearDurationSec = new Dictionary<int, int>{
|
|
|
- // { 1, 0 },{ 2, 0 },{ 3, 0 },{ 4, 0 },{ 5, 0 },{ 6, 0 },
|
|
|
- // { 7, 0 },{ 8, 0 },{ 9, 0 },{ 10, 0 },{ 11, 0 },{ 12, 0 }
|
|
|
- // };
|
|
|
- // for (int i = 1; i <= yearOutput.Keys.Count; i++) // 字典遍历不能用foreach
|
|
|
- // {
|
|
|
- // yearOutput[i] = tableInfo.Where(t => t.OrderDatetime.Month == i && t.OrderDatetime.Year == y)
|
|
|
- // .Sum(t => t.CurrentProduction);
|
|
|
- // }
|
|
|
- // for (int i = 1; i <= yearOrderQuantity.Keys.Count; i++)
|
|
|
- // {
|
|
|
- // yearOrderQuantity[i] = tableInfo.Where(t => t.OrderDatetime.Month == i && t.OrderDatetime.Year == y)
|
|
|
- // .Count();
|
|
|
- // }
|
|
|
- // for (int i = 1; i <= yearDurationSec.Keys.Count; i++)
|
|
|
- // {
|
|
|
- // yearDurationSec[i] = tableInfo.Where(t => t.OrderDatetime.Month == i && t.OrderDatetime.Year == y)
|
|
|
- // .Sum(n => n.DurationSec);
|
|
|
- // }
|
|
|
- // resList.Add(new
|
|
|
- // {
|
|
|
- // Year = y,
|
|
|
- // Month = 0,
|
|
|
- // Output = yearOutput,
|
|
|
- // OrderQuantity = yearOrderQuantity,
|
|
|
- // TotalDurationSec = yearDurationSec
|
|
|
- // });
|
|
|
- //});
|
|
|
-
|
|
|
- //return new RpcResponse<object>() { Data = resList, Message = null };
|
|
|
}
|
|
|
|
|
|
|
|
@@ -425,7 +496,6 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
public RpcResponse<object> GetProductionLineInfo()
|
|
|
{
|
|
|
var tableInfo = CustomerEnv.ProductionLineConfigValue;
|
|
|
-
|
|
|
return new RpcResponse<object>() { Data = tableInfo, Message = null };
|
|
|
}
|
|
|
|
|
@@ -436,22 +506,89 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
/// <returns></returns>
|
|
|
public RpcResponse<object> GetNoticeInfo()
|
|
|
{
|
|
|
+ // 返回静态缓存
|
|
|
+ var timespan = (DateTime.Now - (DateTime)StaticCache["GetNoticeInfo"]["Time"]).TotalSeconds;
|
|
|
+ if (timespan < staticCacheDuration)
|
|
|
+ return new RpcResponse<object>() { Data = StaticCache["GetNoticeInfo"]["Cache"], Message = null };
|
|
|
+
|
|
|
var nowTime = DateTime.Now;
|
|
|
// 只获取激活的和在开始结束时间之间的公告
|
|
|
var tableInfo = DAL.APP_TaiLing_NoticeManagement.GetData<AnnouncementModel>()?
|
|
|
.Where(t => t.IsEnable == true && t.StartTime < nowTime && t.EndTime > nowTime).ToList();
|
|
|
|
|
|
+ // 设置静态缓存
|
|
|
+ StaticCache["GetNoticeInfo"] = new Dictionary<string, object>()
|
|
|
+ { { "Time", DateTime.Now}, { "Cache", tableInfo} };
|
|
|
return new RpcResponse<object>() { Data = tableInfo, Message = null };
|
|
|
}
|
|
|
|
|
|
|
|
|
+ ///// <summary>
|
|
|
+ ///// 获取当天产量
|
|
|
+ ///// </summary>
|
|
|
+ ///// <returns></returns>
|
|
|
+ //public RpcResponse<object> GetTodayOutput()
|
|
|
+ //{
|
|
|
+
|
|
|
+ // var sql = $"SELECT WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, COUNT(*) AS 产量 " +
|
|
|
+ // $"FROM APP_TaiLing_ProductionRecord WHERE DATEDIFF(dd, EndTime_Dt, GETDATE())= 0 " +
|
|
|
+ // $"GROUP BY WorkShopId_Str, ProductionLineId_Str";
|
|
|
+ // var res = DAL.ReadDataTable(sql);
|
|
|
+ // return new RpcResponse<object>() { Data = res, Message = null };
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ ///// <summary>
|
|
|
+ ///// 获取月度产量
|
|
|
+ ///// </summary>
|
|
|
+ ///// <returns></returns>
|
|
|
+ //public RpcResponse<object> GetMonthOutput()
|
|
|
+ //{
|
|
|
+ // var sql = $"SELECT YEAR(StartTime_Dt) AS 年份, MONTH(StartTime_Dt) AS 月份, " +
|
|
|
+ // $"WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, COUNT(*) AS 产量 " +
|
|
|
+ // $"FROM APP_TaiLing_ProductionRecord " +
|
|
|
+ // $"GROUP BY YEAR(StartTime_Dt), MONTH(StartTime_Dt), WorkShopId_Str, ProductionLineId_Str";
|
|
|
+ // var res = DAL.ReadDataTable(sql);
|
|
|
+ // return new RpcResponse<object>() { Data = res, Message = null };
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+ ///// <summary>
|
|
|
+ ///// 获取人均小时产出率
|
|
|
+ ///// </summary>
|
|
|
+ ///// <returns></returns>
|
|
|
+ //public RpcResponse<object> GetPerCapitaOutputPerHour()
|
|
|
+ //{
|
|
|
+
|
|
|
+ // // 三表联查,人均小时产出率直接用sql算出来
|
|
|
+ // var sql = "SELECT tb1.年份, tb1.月份, tb1.车间号, tb1.产线号, tb1.时长, tb2.产量, tb3.NumberOfPeople_Int AS 人数, " +
|
|
|
+ // "CONVERT(DECIMAL(13,3),3600.0*tb2.产量/tb3.NumberOfPeople_Int/tb1.时长) AS 人均小时产出率 " +
|
|
|
+ // "FROM((SELECT YEAR(StartTime_Dt) AS 年份, MONTH(StartTime_Dt) AS 月份, " +
|
|
|
+ // "WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, SUM(DurationSec_Int) AS 时长 " +
|
|
|
+ // "FROM APP_TaiLing_ProductionLineStateRecord " +
|
|
|
+ // "WHERE ProductionLineState_Str = 'Running' " +
|
|
|
+ // "GROUP BY YEAR(StartTime_Dt), MONTH(StartTime_Dt), WorkShopId_Str, ProductionLineId_Str) AS tb1 " +
|
|
|
+ // "LEFT JOIN(SELECT YEAR(StartTime_Dt) AS 年份, MONTH(StartTime_Dt) AS 月份, " +
|
|
|
+ // "WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, COUNT(*) AS 产量 " +
|
|
|
+ // "FROM APP_TaiLing_ProductionRecord " +
|
|
|
+ // "GROUP BY YEAR(StartTime_Dt), MONTH(StartTime_Dt), WorkShopId_Str, ProductionLineId_Str) AS tb2 " +
|
|
|
+ // "ON tb1.年份 = tb2.年份 AND tb1.月份 = tb2.月份 AND tb1.车间号 = tb2.车间号 AND tb1.产线号 = tb2.产线号) " +
|
|
|
+ // "LEFT JOIN APP_TaiLing_ProductionLineManagement AS tb3 " +
|
|
|
+ // "ON tb1.车间号 = tb3.WorkShopId_Str AND tb1.产线号 = tb3.ProductionLineId_Str";
|
|
|
+ // var res = DAL.ReadDataTable(sql);
|
|
|
+ // return new RpcResponse<object>() { Data = res, Message = null };
|
|
|
+ //}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 停止服务
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
public override bool Stop()
|
|
|
{
|
|
|
- Env.Schedual.DateTimeChanged -= Schedual_DateTimeChanged; // 销毁定时器
|
|
|
+ //Env.Schedual.DateTimeChanged -= Schedual_DateTimeChanged; // 销毁定时器
|
|
|
return base.Stop();
|
|
|
}
|
|
|
}
|