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.
Aucma.Scada/HighWayIot.Repository/service/Impl/ProductPlanInfoServiceImpl.cs

105 lines
3.3 KiB
C#

using Aucma.Scada.Model.domain;
using HighWayIot.Common;
using HighWayIot.Log4net;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace HighWayIot.Repository.service.Impl
{
public class ProductPlanInfoServiceImpl : IProductPlanInfoService
{
private Repository<ProductPlanInfo> _mesRepository = new Repository<ProductPlanInfo>("mes");
private LogHelper logHelper = LogHelper.Instance;
private JsonChange jsonChange = JsonChange.Instance;
/// <summary>
/// 通过计划编号获取计划信息
/// </summary>
/// <param name="planCode"></param>
/// <returns></returns>
public ProductPlanInfo GetProductPlanByPlanCode(string planCode)
{
ProductPlanInfo planInfo = null;
try
{
Expression<Func<ProductPlanInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.planCode == planCode);
planInfo = _mesRepository.GetFirst(exp);
logHelper.Info($"根据计划编号{planCode};获取到的计划信息:{jsonChange.ModeToJson(planInfo)}");
}
catch (Exception ex)
{
logHelper.Error("通过计划编号获取计划信息异常", ex);
}
return planInfo;
}
/// <summary>
/// 通过产线工位获取生产计划
/// </summary>
/// <param name="productLineCode"></param>
/// <returns></returns>
public List<ProductPlanInfo> GetProductPlanInfosByProductLineCode(string productLineCode)
{
List<ProductPlanInfo> planInfos = null;
try
{
Expression<Func<ProductPlanInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.productLineCode == productLineCode);
planInfos = _mesRepository.GetList(exp);
logHelper.Info($"根据产线工位编号:{productLineCode};获取到的计划信息:{jsonChange.ModeToJson(planInfos)}");
}
catch (Exception ex)
{
logHelper.Error("通过产线工位获取生产计划异常", ex);
}
return planInfos;
}
/// <summary>
/// 添加生产计划
/// </summary>
/// <param name="productPlanInfo"></param>
/// <returns></returns>
public bool InsertProductPlanInfo(ProductPlanInfo productPlanInfo)
{
bool result = false;
try
{
result = _mesRepository.Insert(productPlanInfo);
}
catch (Exception ex)
{
logHelper.Error("添加生产计划异常", ex);
}
return result;
}
/// <summary>
/// 修改生产计划
/// </summary>
/// <param name="productPlanInfo"></param>
/// <returns></returns>
public bool UpdateProductPlanInfo(ProductPlanInfo productPlanInfo)
{
bool result = false;
try
{
result = _mesRepository.Update(productPlanInfo);
}
catch (Exception ex)
{
logHelper.Error("修改生产计划异常", ex);
}
return result;
}
}
}