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.
ProductionSystem/ProductionSystem_Service/DataProductService.cs

59 lines
1.9 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using ProductionSystem_Log;
using ProductionSystem_Model.DbModel;
using ProductionSystem_Model.DbModel.System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProductionSystem_Service
{
public class DataProductService : DbContext
{
/// <summary>
/// 新增产品数据
/// </summary>
/// <param name="t_Data_Product"></param>
/// <returns></returns>
public (bool isOk,string msg) AddDataProduct(T_Data_Product t_Data_Product)
{
try
{
var row = db.Insertable(t_Data_Product).ExecuteCommand();
return (row > 0, row > 0 ? "操作成功!" : "操作失败!");
}
catch (Exception ex)
{
var errorMsg = $"执行DataProductService下AddDataProduct时异常{ex.Message}";
LogHelper.Error(ex, errorMsg);
return (false, errorMsg);
}
}
/// <summary>
/// 根据参数编码和参数类别查询目标值
/// </summary>
/// <param name="para_code"></param>
/// <param name="para_category"></param>
/// <returns></returns>
public T_Data_Product QueryDataProductByParaCodeAndParaCategory(string para_code,string para_category)
{
try
{
return db.Queryable<T_Data_Product>()
.Where((a) => a.ParaCode == para_code && a.ParaCategory == para_category)
.Select((a) => new T_Data_Product
{
TargetVal = a.TargetVal
}).First();
}
catch (Exception ex)
{
LogHelper.Error(ex, "执行DataProductService下QueryDataProductByParaCodeAndParaCategory时异常");
return null;
}
}
}
}