You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
229 lines
12 KiB
C#
229 lines
12 KiB
C#
using System.Collections.Generic;
|
|
using System;
|
|
using CompressorXN_Log;
|
|
using CompressorXN_Model;
|
|
using CompressorXN_Model.ViewModel.Response;
|
|
using SqlSugar;
|
|
using CompressorXN_Model.ViewModel.Request;
|
|
|
|
namespace CompressorXN_Service
|
|
{
|
|
public class ResultService : DbContext
|
|
{
|
|
/// <summary>
|
|
/// 分页查询结果表
|
|
/// </summary>
|
|
/// <param name="queryResultVM"></param>
|
|
/// <param name="totalCount"></param>
|
|
/// <returns></returns>
|
|
public List<ResultVM> GetResultPageList(QueryResultVM queryResultVM, out int totalCount)
|
|
{
|
|
totalCount = 0;
|
|
try
|
|
{
|
|
return db.Queryable<T_Result>()
|
|
.WhereIF(!string.IsNullOrEmpty(queryResultVM.ProductTypeName), a => a.ProductType == queryResultVM.ProductTypeName)
|
|
.WhereIF(!string.IsNullOrEmpty(queryResultVM.Code), a => a.ProductCode.ToLower().Contains(queryResultVM.Code.ToLower())
|
|
|| a.MainPanelCode.ToLower().Contains(queryResultVM.Code.ToLower())
|
|
|| a.SamplePanelCode.ToLower().Contains(queryResultVM.Code.ToLower())
|
|
|| a.ScreenCode.ToLower().Contains(queryResultVM.Code.ToLower())
|
|
)
|
|
.Select((a) => new ResultVM
|
|
{
|
|
Id = a.Id,
|
|
SerialNum = SqlFunc.RowNumber(SqlFunc.Desc(a.CreatedTime)),
|
|
ProductType = a.ProductType,
|
|
ProductCode = a.ProductCode,
|
|
MainPanelCode = a.MainPanelCode,
|
|
SamplePanelCode = a.SamplePanelCode,
|
|
ScreenCode = a.ScreenCode,
|
|
ScreenTorque = a.ScreenTorque,
|
|
ScreenTorqueMaxVal = a.ScreenTorqueMaxVal,
|
|
ScreenTorqueMinVal = a.ScreenTorqueMinVal,
|
|
ScreenTorqueStatus = a.ScreenTorqueStatus,
|
|
ScreenAngle = a.ScreenAngle,
|
|
ScreenAngleMinVal = a.ScreenAngleMinVal,
|
|
ScreenAngleMaxVal = a.ScreenAngleMaxVal,
|
|
ScreenAngleStatus = a.ScreenAngleStatus,
|
|
RelayTorque1 = a.RelayTorque1,
|
|
RelayTorque1MinVal = a.RelayTorque1MinVal,
|
|
RelayTorque1MaxVal = a.RelayTorque1MaxVal,
|
|
RelayTorque1Status = a.RelayTorque1Status,
|
|
RelayAngle1 = a.RelayAngle1,
|
|
RelayAngle1MinVal = a.RelayAngle1MinVal,
|
|
RelayAngle1MaxVal = a.RelayAngle1MaxVal,
|
|
RelayAngle1Status = a.RelayAngle1Status,
|
|
RelayTorque2 = a.RelayTorque2,
|
|
RelayTorque2MinVal = a.RelayTorque2MinVal,
|
|
RelayTorque2MaxVal = a.RelayTorque2MaxVal,
|
|
RelayTorque2Status = a.RelayTorque2Status,
|
|
RelayAngle2 = a.RelayAngle2,
|
|
RelayAngle2MinVal = a.RelayAngle2MinVal,
|
|
RelayAngle2MaxVal = a.RelayAngle2MaxVal,
|
|
RelayAngle2Status = a.RelayAngle2Status,
|
|
MainPanelScrewTorque = a.MainPanelScrewTorque,
|
|
MainPanelScrewTorqueMinVal = a.MainPanelScrewTorqueMinVal,
|
|
MainPanelScrewTorqueMaxVal = a.MainPanelScrewTorqueMaxVal,
|
|
MainPanelScrewTorqueStatus = a.MainPanelScrewTorqueStatus,
|
|
MainPanelScrewAngle = a.MainPanelScrewAngle,
|
|
MainPanelScrewAngleMinVal = a.MainPanelScrewAngleMinVal,
|
|
MainPanelScrewAngleMaxVal = a.MainPanelScrewAngleMaxVal,
|
|
MainPanelScrewAngleStatus = a.MainPanelScrewAngleStatus,
|
|
MainPanelStud1Torque = a.MainPanelStud1Torque,
|
|
MainPanelStud1TorqueMinVal = a.MainPanelStud1TorqueMinVal,
|
|
MainPanelStud1TorqueMaxVal = a.MainPanelStud1TorqueMaxVal,
|
|
MainPanelStud1TorqueStatus = a.MainPanelStud1TorqueStatus,
|
|
MainPanelStud1Angle = a.MainPanelStud1Angle,
|
|
MainPanelStud1AngleMinVal = a.MainPanelStud1AngleMinVal,
|
|
MainPanelStud1AngleMaxVal = a.MainPanelStud1AngleMaxVal,
|
|
MainPanelStud1AngleStatus = a.MainPanelStud1AngleStatus,
|
|
MainPanelStud2Torque = a.MainPanelStud2Torque,
|
|
MainPanelStud2TorqueMinVal = a.MainPanelStud2TorqueMinVal,
|
|
MainPanelStud2TorqueMaxVal = a.MainPanelStud2TorqueMaxVal,
|
|
MainPanelStud2TorqueStatus = a.MainPanelStud2TorqueStatus,
|
|
MainPanelStud2Angle = a.MainPanelStud2Angle,
|
|
MainPanelStud2AngleMinVal = a.MainPanelStud2AngleMinVal,
|
|
MainPanelStud2AngleMaxVal = a.MainPanelStud2AngleMaxVal,
|
|
MainPanelStud2AngleStatus = a.MainPanelStud2AngleStatus,
|
|
ProductTorque1 = a.ProductTorque1,
|
|
ProductTorque1MinVal = a.ProductTorque1MinVal,
|
|
ProductTorque1MaxVal = a.ProductTorque1MaxVal,
|
|
ProductTorque1Status = a.ProductTorque1Status,
|
|
ProductAngle1 = a.ProductAngle1,
|
|
ProductAngle1MinVal = a.ProductAngle1MinVal,
|
|
ProductAngle1MaxVal = a.ProductAngle1MaxVal,
|
|
ProductAngle1Status = a.ProductAngle1Status,
|
|
ProductTorque2 = a.ProductTorque2,
|
|
ProductTorque2MinVal = a.ProductTorque2MinVal,
|
|
ProductTorque2MaxVal = a.ProductTorque2MaxVal,
|
|
ProductTorque2Status = a.ProductTorque2Status,
|
|
ProductAngle2 = a.ProductAngle2,
|
|
ProductAngle2MinVal = a.ProductAngle2MinVal,
|
|
ProductAngle2MaxVal = a.ProductAngle2MaxVal,
|
|
ProductAngle2Status = a.ProductAngle2Status,
|
|
MainPanelTp1Tp2 = a.MainPanelTp1Tp2,
|
|
MainPanelTp1Tp3 = a.MainPanelTp1Tp3,
|
|
MainPanelTp1Tp4 = a.MainPanelTp1Tp4,
|
|
MainPanelTp1Tp5 = a.MainPanelTp1Tp5,
|
|
MainPanelTp1Out1 = a.MainPanelTp1Out1,
|
|
MainPanelTp133V = a.MainPanelTp133V,
|
|
MainPanelTp1Vcc = a.MainPanelTp1Vcc,
|
|
MainPanelTp1Vref = a.MainPanelTp1Vref,
|
|
ScreenVccGnd = a.ScreenVccGnd,
|
|
CCSecGnd = a.CCSecGnd,
|
|
CCInGnd = a.CCInGnd,
|
|
CC5vGnd = a.CC5vGnd,
|
|
CC25vGnd = a.CC25vGnd,
|
|
CC33vGnd = a.CC33vGnd,
|
|
CCVrefGnd = a.CCVrefGnd,
|
|
IR5vGnd = a.IR5vGnd,
|
|
IR042vGnd = a.IR042vGnd,
|
|
IRr25vGnd = a.IRr25vGnd,
|
|
IR33vGnd = a.IR33vGnd,
|
|
ECSecGnd = a.ECSecGnd,
|
|
ECVoutGnd = a.ECVoutGnd,
|
|
EC5vGnd = a.EC5vGnd,
|
|
EC33vGnd = a.EC33vGnd,
|
|
CreatedTime = a.CreatedTime
|
|
}).OrderByDescending(a => a.CreatedTime).ToPageList(queryResultVM.PageIndex, queryResultVM.PageSize, ref totalCount);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex, "执行ResultService下GetResultPageList时异常");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询显示器条码和主板条码不为空,采样板条码为空的结果记录
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public T_Result QueryResult()
|
|
{
|
|
try
|
|
{
|
|
return db.Queryable<T_Result>().OrderByDescending(m => m.CreatedTime).First(m => !string.IsNullOrEmpty(m.ScreenCode) && !string.IsNullOrEmpty(m.MainPanelCode) && string.IsNullOrEmpty(m.SamplePanelCode));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex, "执行ResultService下QueryResult时异常");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 查询显示器条码和主板条码不为空,采样板条码为空的结果记录
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public T_Result QueryResult2()
|
|
{
|
|
try
|
|
{
|
|
return db.Queryable<T_Result>().OrderByDescending(m => m.CreatedTime).First(m => !string.IsNullOrEmpty(m.ScreenCode) && !string.IsNullOrEmpty(m.MainPanelCode) && !string.IsNullOrEmpty(m.SamplePanelCode));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex, "执行ResultService下QueryResult2时异常");
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改结果表壳体码
|
|
/// </summary>
|
|
/// <param name="productCode">修改壳体码(激光刻码)</param>
|
|
/// <returns></returns>
|
|
public int UpdateResultProductCode(string productTypeName, string productCode)
|
|
{
|
|
try
|
|
{
|
|
return db.Updateable<T_Result>()
|
|
.SetColumns(c => c.ProductCode == productCode)
|
|
.Where(m => m.ProductType == productTypeName && m.ProductCode == string.Empty)
|
|
.ExecuteCommand();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex, "执行ResultService下UpdateResultProductCode时异常");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 新增结果表
|
|
/// </summary>
|
|
/// <param name="dic"></param>
|
|
/// <returns></returns>
|
|
public int AddResult(T_Result t_Result)
|
|
{
|
|
try
|
|
{
|
|
return db.Insertable(t_Result).ExecuteCommand();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex, "执行ResultService下AddResult时异常");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改结果表
|
|
/// </summary>
|
|
/// <param name="t_Result"></param>
|
|
/// <returns></returns>
|
|
public int UpdateResult(T_Result t_Result)
|
|
{
|
|
try
|
|
{
|
|
return db.Updateable(t_Result).ExecuteCommand();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex, "执行ResultService下UpdateResult时异常");
|
|
return -1;
|
|
}
|
|
}
|
|
}
|
|
}
|