|
|
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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public string QueryDataProduct(string para_code, string para_category)
|
|
|
{
|
|
|
|
|
|
|
|
|
var entity = QueryDataProductByParaCodeAndParaCategory(para_code, para_category);
|
|
|
if(entity == null)
|
|
|
{
|
|
|
return "0";
|
|
|
}
|
|
|
return entity.TargetVal;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|