|
|
|
@ -0,0 +1,137 @@
|
|
|
|
|
using Admin.Core.Model;
|
|
|
|
|
using Admin.Core.IRepository;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Admin.Core.Model.ViewModels;
|
|
|
|
|
using Admin.Core.Model.Model_New;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System;
|
|
|
|
|
using Microsoft.IdentityModel.Logging;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace Admin.Core.Repository
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// SysUserInfoRepository
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class SysUserInfoRepository : BaseRepository<SysUserInfo>, ISysUserInfoRepository
|
|
|
|
|
{
|
|
|
|
|
public SysUserInfoRepository(IUnitOfWork unitOfWork) : base(unitOfWork)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<List<ProductInfoView>> GetStationData(string code)
|
|
|
|
|
{
|
|
|
|
|
string sql = @$"SELECT BP.PLANT_CODE PLANT_CODE, BP.PARENT_ID PRODUCT_LINE_CODE, BPS.PROCESS_CODE, BP.PRODUCT_LINE_CODE STATION_CODE
|
|
|
|
|
FROM BASE_PRODUCTLINE BP
|
|
|
|
|
LEFT JOIN BASE_PROCESS_STATION BPS ON BPS.PARENT_ID LIKE '%' || BP.PRODUCT_LINE_CODE || '%'
|
|
|
|
|
WHERE BP.PRODUCT_LINE_CODE = '{code}'";
|
|
|
|
|
return await Db.CopyNew().Ado.SqlQueryAsync<ProductInfoView>(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 获取班组数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取班组数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
|
|
|
public async Task<List<CurrentTeamTimeView>> GetTeamData()
|
|
|
|
|
{
|
|
|
|
|
string sql = "SELECT * FROM VIEW_CURRENT_TEAM_TIME";
|
|
|
|
|
return await Db.CopyNew().Ado.SqlQueryAsync<CurrentTeamTimeView>(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取班组数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取班组数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
|
|
|
public async Task<List<ProductLineInfoView>> GetProductLineInfo(string productLineCode)
|
|
|
|
|
{
|
|
|
|
|
if (GetConnectionState() == false) return null;
|
|
|
|
|
string sql = @$"SELECT BP.PLANT_CODE PLANT_CODE, BP.PARENT_ID PRODUCT_LINE_CODE, BPS.PROCESS_CODE, BP.PRODUCT_LINE_CODE STATION_CODE FROM BASE_PRODUCTLINE BP
|
|
|
|
|
LEFT JOIN BASE_PROCESS_STATION BPS ON BPS.PARENT_ID LIKE '%' || BP.PRODUCT_LINE_CODE || '%' WHERE BP.PRODUCT_LINE_CODE = '{productLineCode}'";
|
|
|
|
|
return await Db.CopyNew().Ado.SqlQueryAsync<ProductLineInfoView>(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取钣金型号统计数据
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取班组数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <exception cref="System.NotImplementedException"></exception>
|
|
|
|
|
public async Task<List<SheetMetalTypeDataView>> GetSheetMetalTypeData(string productLineCode)
|
|
|
|
|
{
|
|
|
|
|
string sql = @$" WITH CTT AS (SELECT MIN(START_TIME) START_TIME, MAX(END_TIME) END_TIME
|
|
|
|
|
FROM VIEW_CURRENT_TEAM_TIME)
|
|
|
|
|
SELECT FB.MATERIAL_CODE as MATERUALNAME,
|
|
|
|
|
SUM(CASE WHEN FB.BOX_TYPE = 1 THEN FB.OUTPUT_AMOUNT ELSE 0 END) FRONTPLATE_AMOUNT,
|
|
|
|
|
SUM(CASE WHEN FB.BOX_TYPE = 2 THEN FB.OUTPUT_AMOUNT ELSE 0 END) REARPANEL_AMOUNT
|
|
|
|
|
FROM VIEW_RECORD_FRONT_BACK_COMP FB
|
|
|
|
|
CROSS JOIN CTT
|
|
|
|
|
WHERE FB.RECORD_TIME >= CTT.START_TIME
|
|
|
|
|
AND FB.RECORD_TIME < CTT.END_TIME
|
|
|
|
|
GROUP BY FB.MATERIAL_CODE";
|
|
|
|
|
|
|
|
|
|
return await Db.CopyNew().Ado.SqlQueryAsync<SheetMetalTypeDataView>(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 小时统计
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 小时统计
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="productLineCode">工位</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public async Task<List<SheetMetaHourDataView>> GetSheetMetaHourData(string productLineCode)
|
|
|
|
|
{
|
|
|
|
|
string sql = @$"SELECT CTT.HOUR_TIME,
|
|
|
|
|
SUM(CASE WHEN FB.BOX_TYPE = 1 THEN FB.OUTPUT_AMOUNT ELSE 0 END) FRONTPLATE_AMOUNT,
|
|
|
|
|
SUM(CASE WHEN FB.BOX_TYPE = 2 THEN FB.OUTPUT_AMOUNT ELSE 0 END) REARPANEL_AMOUNT
|
|
|
|
|
FROM VIEW_CURRENT_TEAM_TIME CTT
|
|
|
|
|
LEFT JOIN VIEW_RECORD_FRONT_BACK_COMP FB
|
|
|
|
|
ON FB.RECORD_TIME >= CTT.START_TIME AND FB.RECORD_TIME < CTT.END_TIME
|
|
|
|
|
GROUP BY CTT.HOUR_TIME
|
|
|
|
|
ORDER BY CTT.HOUR_TIME";
|
|
|
|
|
return await Db.CopyNew().Ado.SqlQueryAsync<SheetMetaHourDataView>(sql);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 当前订单执行第一次数据采集时候更新SAP计划
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 当前订单执行第一次数据采集时候更新SAP计划
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int UpdateSapPlan(string sapCode)
|
|
|
|
|
{
|
|
|
|
|
var parameters = new SugarParameter[]
|
|
|
|
|
{
|
|
|
|
|
new SugarParameter("@SAP_PLAN_CODE", sapCode)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
string sql = "UPDATE PRODUCT_CALENDAR_INFO SET IS_SCHEDULING = 0 WHERE SAP_PLAN_CODE = @SAP_PLAN_CODE";
|
|
|
|
|
int affectedRows = Db.CopyNew().Ado.ExecuteCommand(sql, parameters);
|
|
|
|
|
return affectedRows;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 统计夹具型号状态
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 统计夹具型号状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
public async Task<List<ModeStatusView>> StatisticalModelStatus()
|
|
|
|
|
{
|
|
|
|
|
string sql = "select * from table (scada_xk_fp_01('') )";
|
|
|
|
|
return await Db.CopyNew().Ado.SqlQueryAsync<ModeStatusView>(sql);
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|