forked from wenjy/HighWayIot
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.
124 lines
3.3 KiB
C#
124 lines
3.3 KiB
C#
using HighWayIot.Log4net;
|
|
using HighWayIot.Repository.domain;
|
|
using Models;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Expressions;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace HighWayIot.Repository.service
|
|
{
|
|
public class ZxRecipeService
|
|
{
|
|
private static readonly Lazy<ZxRecipeService> lazy = new Lazy<ZxRecipeService>(() => new ZxRecipeService());
|
|
|
|
public static ZxRecipeService Instance
|
|
{
|
|
get
|
|
{
|
|
return lazy.Value;
|
|
}
|
|
}
|
|
|
|
private LogHelper log = LogHelper.Instance;
|
|
Repository<ZxRecipeEntity> _repository => new Repository<ZxRecipeEntity>("sqlserver");
|
|
|
|
/// <summary>
|
|
/// 查询配方信息
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<ZxRecipeEntity> GetRecipeInfos()
|
|
{
|
|
try
|
|
{
|
|
List<ZxRecipeEntity> entity = _repository.GetList(x => x.IsDeleted == false);
|
|
return entity;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("配方信息获取异常", ex);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据配方编号查询配方信息
|
|
/// </summary>
|
|
/// <param name="recipeCode">配方编号</param>
|
|
/// <returns></returns>
|
|
public List<ZxRecipeEntity> GetRecipeInfosByRecipeCode(string recipeCode)
|
|
{
|
|
try
|
|
{
|
|
List<ZxRecipeEntity> entity = _repository.GetList(x => x.IsDeleted == false && x.RecipeCode == recipeCode);
|
|
return entity;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("根据编号查询配方信息获取异常", ex);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 修改配方信息
|
|
/// </summary>
|
|
/// <param name="recipeEntity"></param>
|
|
/// <returns></returns>
|
|
public bool UpdateRecipeInfo(ZxRecipeEntity recipeEntity)
|
|
{
|
|
try
|
|
{
|
|
return _repository.Update(recipeEntity);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
log.Error("配方信息修改异常", ex);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 新增配方信息
|
|
/// </summary>
|
|
/// <param name="recipeEntity"></param>
|
|
/// <returns></returns>
|
|
public bool InsertRecipeInfo(ZxRecipeEntity recipeEntity)
|
|
{
|
|
try
|
|
{
|
|
return _repository.Insert(recipeEntity);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("配方信息添加异常", ex);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除配方信息
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
public bool DeleteRecipeInfoById(int id)
|
|
{
|
|
try
|
|
{
|
|
ZxRecipeEntity e = _repository.GetById(id);
|
|
e.IsDeleted = true;
|
|
return _repository.Update(e);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error("配方信息删除异常", ex);
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
}
|