|
@@ -4,6 +4,7 @@ using LiveCharts.Helpers;
|
|
|
using LiveCharts.Wpf;
|
|
|
using Microsoft.DwayneNeed.Shapes;
|
|
|
using Microsoft.DwayneNeed.Win32.Gdi32;
|
|
|
+using Microsoft.DwayneNeed.Win32.Kernel32;
|
|
|
using Microsoft.DwayneNeed.Win32.User32;
|
|
|
using MySqlX.XDevAPI.Common;
|
|
|
using NPOI.HSSF.Record;
|
|
@@ -36,7 +37,7 @@ using static NPOI.HSSF.Util.HSSFColor;
|
|
|
namespace SCADA_DAQ.Customer.Service
|
|
|
{
|
|
|
/// <summary>
|
|
|
- ///
|
|
|
+ /// 看板API服务
|
|
|
/// </summary>
|
|
|
[DisplayName("自定义服务")]
|
|
|
public class CustomerService : BaseService
|
|
@@ -523,63 +524,60 @@ namespace SCADA_DAQ.Customer.Service
|
|
|
}
|
|
|
|
|
|
|
|
|
- ///// <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 RpcResponse<object> GetLineOutput()
|
|
|
+ {
|
|
|
+ var sql = $"DECLARE @W VARCHAR(10), @P VARCHAR(10);" +
|
|
|
+ $"SET @W = '{CustomerEnv.ProductionLineConfigValue.WorkShopId}'; " +
|
|
|
+ $"SET @P = '{CustomerEnv.ProductionLineConfigValue.ProductionLineId}';" +
|
|
|
+ $"SELECT WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, COUNT(*) AS 日产量, " +
|
|
|
+ $"(SELECT COUNT(*) FROM APP_TaiLing_ProductionRecord " +
|
|
|
+ $"WHERE DATEDIFF(mm, EndTime_Dt, GETDATE()) = 0 AND WorkShopId_Str = @W AND ProductionLineId_Str = @P) AS 月产量," +
|
|
|
+ $"(SELECT COUNT(*) FROM APP_TaiLing_ProductionRecord " +
|
|
|
+ $"WHERE WorkShopId_Str = @W AND ProductionLineId_Str = @P) AS 总产量 " +
|
|
|
+ $"FROM APP_TaiLing_ProductionRecord " +
|
|
|
+ $"WHERE DATEDIFF(dd, EndTime_Dt, GETDATE())= 0 AND WorkShopId_Str = @W AND ProductionLineId_Str = @P " +
|
|
|
+ $"GROUP BY WorkShopId_Str, ProductionLineId_Str; ";
|
|
|
+ var dt = DAL.ReadDataTable(sql);
|
|
|
+ return new RpcResponse<object>() { Data = dt, Message = null };
|
|
|
+ }
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 获取产线当天异常次数和时长
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ public RpcResponse<object> GetLineExceptionData()
|
|
|
+ {
|
|
|
+ Dictionary<string, string> workShopMap = new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "一车间","W01"}, {"二车间","W02"}, {"三车间","W03"}, {"四车间","W04"},
|
|
|
+ { "五车间","W05"}, {"六车间","W06"}, {"七车间","W07"}, {"八车间","W08"},
|
|
|
+ };
|
|
|
+ Dictionary<string, string> productionLineMap = new Dictionary<string, string>()
|
|
|
+ {
|
|
|
+ { "产线1号","P01"}, {"产线2号","P02"}, {"产线3号","P03"}, {"产线4号","P04"},
|
|
|
+ { "产线5号","P05"}, {"产线6号","P06"}, {"产线7号","P07"}, {"产线8号","P08"},
|
|
|
+ };
|
|
|
+
|
|
|
+ var sql = $"SELECT LEFT(Device_Str, 3) 车间号, SUBSTRING(Device_Str,4,4) 产线号, " +
|
|
|
+ $"COUNT(*) AS 次数, SUM(Duration_Int) 时长 " +
|
|
|
+ $"FROM V_Base_AlarmLog " +
|
|
|
+ $"WHERE DATEDIFF(dd, CreateTime_Dt, GETDATE())=0 AND AlarmType_Str='停止' " +
|
|
|
+ $"AND Device_Str='{CustomerEnv.ProductionLineConfigValue.PlcName}' " +
|
|
|
+ $"GROUP BY LEFT(Device_Str, 3), SUBSTRING(Device_Str,4,4)";
|
|
|
+ var dt = DAL.ReadDataTable(sql);
|
|
|
+ foreach (DataRow dr in dt.Rows)
|
|
|
+ {
|
|
|
+ dr["车间号"] = workShopMap[dr["车间号"].ToString()];
|
|
|
+ dr["产线号"] = productionLineMap[dr["产线号"].ToString()];
|
|
|
+ }
|
|
|
|
|
|
+ return new RpcResponse<object>() { Data = dt, Message = null };
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/// <summary>
|