148 lines
6.8 KiB
C#
Executable File
148 lines
6.8 KiB
C#
Executable File
using Opsoft.Data;
|
|
using Opsoft.NetCore.O3App.Domain;
|
|
using Opsoft.NetCore.O3App.Domain.UnitOfWork.IPadReport.Model;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Opsoft.NetCore.O3App.Repositories.IPadReport
|
|
{
|
|
/// <summary>
|
|
/// 模治具业务处理类
|
|
/// </summary>
|
|
public static class MouldHandleRepository
|
|
{
|
|
#region 获取资源模具信息
|
|
/// <summary>
|
|
/// 查询资源模具信息
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <param name="reportID"></param>
|
|
/// <param name="fCode"></param>
|
|
/// <returns></returns>
|
|
public static List<MouldInfo> GetMouldInfos(APPServerContext context, string reportID, string fCode)
|
|
{
|
|
try
|
|
{
|
|
string sql = string.Format(@"
|
|
SELECT
|
|
S1.FINTERID
|
|
,S1.FNUMBER
|
|
,S1.FNAME
|
|
,S.FUPTIME AS FSTARTTIME
|
|
,S.FDOWNTIME AS FENDTIME
|
|
FROM T_SFC_REPORTENTRY4(NOLOCK) S
|
|
LEFT JOIN T_ENG_MOULDANDJIG(NOLOCK) S1 ON S1.FINTERID=S.FMOULDID
|
|
WHERE S.FINTERID='{0}' AND S.FCode='{1}' AND FDOWNTIME IS NULL
|
|
ORDER BY S.FUPTIME ASC ", reportID, fCode);
|
|
return context.Database.SqlQuery<MouldInfo>(sql);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 更新模具状态-上下模使用
|
|
/// <summary>
|
|
/// 更新模具状态
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <param name="mouldStatus"></param>
|
|
/// <param name="mouldData"></param>
|
|
/// <returns></returns>
|
|
public static async Task UpdateMouldStatus(APPServerContext context, string mouldStatus, List<Basic> mouldData)
|
|
{
|
|
try
|
|
{
|
|
string sql = string.Format(@$" UPDATE T_ENG_MOULDANDJIG SET FMOULDSTATUS={mouldStatus} WHERE FINTERID IN ('" + string.Join("','", mouldData.Select(o => o.FID).ToList()) + "')");
|
|
await context.Database.SqlNonQueryAsync(sql);
|
|
}
|
|
catch
|
|
{
|
|
throw new O3AppException("更新模治具状态失败!", 500);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 更新模具状态-汇报暂时使用
|
|
/// <summary>
|
|
/// 更新模具状态-汇报暂时使用
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <param name="mouldStatus"></param>
|
|
/// <param name="mouldData"></param>
|
|
/// <returns></returns>
|
|
public static async Task UpdateMouldStatusByReport(APPServerContext context, string mouldStatus, string reportId)
|
|
{
|
|
try
|
|
{
|
|
string sql = string.Format(@$" UPDATE T_ENG_MOULDANDJIG SET FMOULDSTATUS={mouldStatus} WHERE FINTERID IN (SELECT DISTINCT FMOULDID FROM T_SFC_REPORTENTRY4 WHERE FINTERID='{reportId}' AND FUPTIME IS NOT NULL )");
|
|
await context.Database.SqlNonQueryAsync(sql);
|
|
}
|
|
catch
|
|
{
|
|
throw new O3AppException("更新模治具状态失败!", 500);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 更新模具状态-汇报时使用
|
|
/// <summary>
|
|
/// 更新模具状态-汇报暂时使用
|
|
/// </summary>
|
|
/// <param name="context"></param>
|
|
/// <param name="reportClass"></param>
|
|
/// <param name="reportId"></param>
|
|
/// <returns></returns>
|
|
//public static async Task UpdateMouldByReport(APPServerContext context, ReportClass reportClass, string reportId)
|
|
//{
|
|
// try
|
|
// {
|
|
// string sql = string.Format(@$" UPDATE T_ENG_MOULDANDJIG
|
|
// SET FCOLUSELIFE=FCOLUSELIFE+{reportClass.FPassQty},
|
|
// FREMAINLIFE=FSTDUSELIFE-FCOLUSELIFE-{reportClass.FPassQty}
|
|
// WHERE FINTERID IN (SELECT DISTINCT FMOULDID FROM T_SFC_REPORTENTRY4 WHERE FINTERID='{reportId}' AND FUPTIME IS NOT NULL )");
|
|
// await context.Database.SqlNonQueryAsync(sql);
|
|
// }
|
|
// catch
|
|
// {
|
|
// throw new O3AppException("更新模治具使用寿命失败!", 500);
|
|
// }
|
|
//}
|
|
public static async Task UpdateMouldByReport(APPServerContext context, ReportClass reportClass, string reportId, string fCode)
|
|
{
|
|
try
|
|
{
|
|
string sql = string.Format(@$" UPDATE dbo.T_ENG_MOULDANDJIG
|
|
SET FREMAINLIFE = FREMAINLIFE - {reportClass.FPassQty + reportClass.FBadQty} * (CASE FNUMOFPOINTS
|
|
WHEN 0 THEN
|
|
1
|
|
ELSE
|
|
FNUMOFPOINTS
|
|
END
|
|
),
|
|
FCOLUSELIFE = FCOLUSELIFE +{reportClass.FPassQty + reportClass.FBadQty} * (CASE FNUMOFPOINTS
|
|
WHEN 0 THEN
|
|
1
|
|
ELSE
|
|
FNUMOFPOINTS
|
|
END
|
|
)
|
|
WHERE FINTERID IN
|
|
(
|
|
SELECT FMOULDID FROM dbo.T_SFC_REPORTENTRY4 WHERE FINTERID = '{reportId}' AND FCODE = '{fCode}'
|
|
);");
|
|
await context.Database.SqlNonQueryAsync(sql);
|
|
}
|
|
catch
|
|
{
|
|
throw new O3AppException("更新模治具使用寿命失败!", 500);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|