|
@@ -202,10 +202,10 @@ namespace SCADA_DAQ.Plugin.Tailg.Service
|
|
if (timespan < staticCacheDuration)
|
|
if (timespan < staticCacheDuration)
|
|
return new RpcResponse<object>() { Data = StaticCache["GetMonthOutput"]["Cache"], Message = null };
|
|
return new RpcResponse<object>() { Data = StaticCache["GetMonthOutput"]["Cache"], Message = null };
|
|
|
|
|
|
- var sql = $"SELECT YEAR(StartTime_Dt) AS 年份, MONTH(StartTime_Dt) AS 月份, " +
|
|
|
|
|
|
+ var sql = $"SELECT YEAR(EndTime_Dt) AS 年份, MONTH(EndTime_Dt) AS 月份, " +
|
|
$"WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, COUNT(*) AS 产量 " +
|
|
$"WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, COUNT(*) AS 产量 " +
|
|
$"FROM APP_TaiLing_ProductionRecord " +
|
|
$"FROM APP_TaiLing_ProductionRecord " +
|
|
- $"GROUP BY YEAR(StartTime_Dt), MONTH(StartTime_Dt), WorkShopId_Str, ProductionLineId_Str";
|
|
|
|
|
|
+ $"GROUP BY YEAR(EndTime_Dt), MONTH(EndTime_Dt), WorkShopId_Str, ProductionLineId_Str";
|
|
var dt = Env.SgIDAL.ReadDataTable(sql);
|
|
var dt = Env.SgIDAL.ReadDataTable(sql);
|
|
|
|
|
|
// 设置静态缓存
|
|
// 设置静态缓存
|
|
@@ -229,15 +229,15 @@ namespace SCADA_DAQ.Plugin.Tailg.Service
|
|
// 三表联查,人均小时产出率直接用sql算出来
|
|
// 三表联查,人均小时产出率直接用sql算出来
|
|
var sql = "SELECT tb1.年份, tb1.月份, tb1.车间号, tb1.产线号, tb1.时长, tb2.产量, tb3.NumberOfPeople_Int AS 人数, " +
|
|
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 人均小时产出率 " +
|
|
"CONVERT(DECIMAL(13,3),3600.0*tb2.产量/tb3.NumberOfPeople_Int/tb1.时长) AS 人均小时产出率 " +
|
|
- "FROM((SELECT YEAR(StartTime_Dt) AS 年份, MONTH(StartTime_Dt) AS 月份, " +
|
|
|
|
|
|
+ "FROM((SELECT YEAR(EndTime_Dt) AS 年份, MONTH(EndTime_Dt) AS 月份, " +
|
|
"WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, SUM(DurationSec_Int) AS 时长 " +
|
|
"WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, SUM(DurationSec_Int) AS 时长 " +
|
|
"FROM APP_TaiLing_ProductionLineStateRecord " +
|
|
"FROM APP_TaiLing_ProductionLineStateRecord " +
|
|
"WHERE ProductionLineState_Str = 'Running' " +
|
|
"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 月份, " +
|
|
|
|
|
|
+ "GROUP BY YEAR(EndTime_Dt), MONTH(EndTime_Dt), WorkShopId_Str, ProductionLineId_Str) AS tb1 " +
|
|
|
|
+ "LEFT JOIN(SELECT YEAR(EndTime_Dt) AS 年份, MONTH(EndTime_Dt) AS 月份, " +
|
|
"WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, COUNT(*) AS 产量 " +
|
|
"WorkShopId_Str AS 车间号, ProductionLineId_Str AS 产线号, COUNT(*) AS 产量 " +
|
|
"FROM APP_TaiLing_ProductionRecord " +
|
|
"FROM APP_TaiLing_ProductionRecord " +
|
|
- "GROUP BY YEAR(StartTime_Dt), MONTH(StartTime_Dt), WorkShopId_Str, ProductionLineId_Str) AS tb2 " +
|
|
|
|
|
|
+ "GROUP BY YEAR(EndTime_Dt), MONTH(EndTime_Dt), WorkShopId_Str, ProductionLineId_Str) AS tb2 " +
|
|
"ON tb1.年份 = tb2.年份 AND tb1.月份 = tb2.月份 AND tb1.车间号 = tb2.车间号 AND tb1.产线号 = tb2.产线号) " +
|
|
"ON tb1.年份 = tb2.年份 AND tb1.月份 = tb2.月份 AND tb1.车间号 = tb2.车间号 AND tb1.产线号 = tb2.产线号) " +
|
|
"LEFT JOIN APP_TaiLing_ProductionLineManagement AS tb3 " +
|
|
"LEFT JOIN APP_TaiLing_ProductionLineManagement AS tb3 " +
|
|
"ON tb1.车间号 = tb3.WorkShopId_Str AND tb1.产线号 = tb3.ProductionLineId_Str";
|
|
"ON tb1.车间号 = tb3.WorkShopId_Str AND tb1.产线号 = tb3.ProductionLineId_Str";
|