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.
91 lines
3.0 KiB
C#
91 lines
3.0 KiB
C#
using ProductionSystem_Log;
|
|
using ProductionSystem_Model.DbModel;
|
|
using ProductionSystem_Model.Enum;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Runtime.InteropServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ProductionSystem_Service
|
|
{
|
|
public class ProductStepService : DbContext
|
|
{
|
|
/// <summary>
|
|
/// 新增产品步骤内容
|
|
/// </summary>
|
|
/// <param name="t_Product_Step"></param>
|
|
/// <returns></returns>
|
|
public int AddProductStep(T_Product_Step t_Product_Step)
|
|
{
|
|
try
|
|
{
|
|
return db.Insertable(t_Product_Step).ExecuteCommand();
|
|
}catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex, "执行ProductStepService下AddProductStep时异常");
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 查询最新一条记录
|
|
/// </summary>
|
|
/// <param name="stepName"></param>
|
|
/// <param name="equipmentName"></param>
|
|
/// <param name="productType"></param>
|
|
/// <returns></returns>
|
|
public T_Product_Step QueryLatestStep(string stepName,string equipmentName,string productType,string productCode)
|
|
{
|
|
return db.Queryable<T_Product_Step>().
|
|
Where(m => m.StepName == stepName
|
|
&& m.EquipmentName == equipmentName
|
|
&& m.ProductType == productType)
|
|
.Where(x=>x.ProductBarcode==productCode)
|
|
.OrderByDescending(x=>x.CreateTime)
|
|
.First();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 插入其他step
|
|
/// </summary>
|
|
/// <param name="producctType"></param>
|
|
/// <param name="productCode"></param>
|
|
/// <param name="stepName"></param>
|
|
public void InsertOther(string producctType,string equipment, string productCode,string toStepName)
|
|
{
|
|
var other = QueryLatestStep(ModeTypeEnum.BZ1_DB.ToString(), productCode, producctType,equipment);
|
|
if(other != null)
|
|
{
|
|
other.Id = Guid.NewGuid().ToString("N");
|
|
other.StepName = toStepName;
|
|
db.Insertable(other).ExecuteCommand();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新水泵速度
|
|
/// </summary>
|
|
/// <param name="producctType"></param>
|
|
/// <param name="productCode"></param>
|
|
/// <param name="stepName"></param>
|
|
/// <param name="equipment"></param>
|
|
/// <param name="writeVal"></param>
|
|
/// <param name="returnVal"></param>
|
|
public void UpdateSBSpeed(string producctType,string productCode, string stepName,string equipment,string writeVal,string returnVal)
|
|
{
|
|
var entity = QueryLatestStep(stepName, equipment, producctType, productCode);
|
|
if(entity != null)
|
|
{
|
|
entity.WriteValue = writeVal;
|
|
entity.ReturnValue = returnVal;
|
|
db.Updateable(entity).ExecuteCommand();
|
|
}
|
|
}
|
|
}
|
|
}
|