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/ExecutePlanInfoServiceImpl.cs

133 lines
4.4 KiB
C#

using HighWayIot.Common;
using HighWayIot.Log4net;
using HighWayIot.Repository.domain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace HighWayIot.Repository.service.Impl
{
public class ExecutePlanInfoServiceImpl : IExecutePlanInfoService
{
private Repository<ExecutePlanInfo> _mesRepository = new Repository<ExecutePlanInfo>("scada");
private LogHelper logHelper = LogHelper.Instance;
private JsonChange jsonChange = JsonChange.Instance;
/// <summary>
/// 通过执行计划编号获取执行计划
/// </summary>
/// <param name="executePlanCode"></param>
/// <returns></returns>
public ExecutePlanInfo GetExecutePlanInfoByPlanCode(string executePlanCode)
{
ExecutePlanInfo planInfo = null;
try
{
Expression<Func<ExecutePlanInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.executePlanCode == executePlanCode);
planInfo = _mesRepository.GetFirst(exp);
logHelper.Info($"根据执行计划编号{executePlanCode};获取到的执行计划信息:{jsonChange.ModeToJson(planInfo)}");
}
catch (Exception ex)
{
logHelper.Error("通过执行计划编号获取执行计划异常", ex);
}
return planInfo;
}
/// <summary>
/// 通过产线工位获取执行计划
/// </summary>
/// <param name="productLineCode"></param>
/// <returns></returns>
public List<ExecutePlanInfo> GetExecutePlanInfosByProductLineCode(string productLineCode)
{
List<ExecutePlanInfo> planInfos = null;
try
{
Expression<Func<ExecutePlanInfo, 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="productPlanCode"></param>
/// <returns></returns>
public List<ExecutePlanInfo> GetExecutePlanInfosByProductPlanCode(string productPlanCode)
{
List<ExecutePlanInfo> planInfos = null;
try
{
Expression<Func<ExecutePlanInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.productPlanCode == productPlanCode);
planInfos = _mesRepository.GetList(exp);
logHelper.Info($"根据生产计划编号:{productPlanCode};获取到的执行计划信息:{jsonChange.ModeToJson(planInfos)}");
}
catch (Exception ex)
{
logHelper.Error("通过生产计划编号获取执行计划异常", ex);
}
return planInfos;
}
/// <summary>
/// 新增执行计划
/// </summary>
/// <param name="executePlanInfo"></param>
/// <returns></returns>
public bool InsertExecutePlanInfo(ExecutePlanInfo executePlanInfo)
{
bool result = false;
try
{
result = _mesRepository.Insert(executePlanInfo);
}
catch (Exception ex)
{
logHelper.Error("新增执行计划异常", ex);
}
return result;
}
/// <summary>
/// 修改执行计划
/// </summary>
/// <param name="executePlanInfo"></param>
/// <returns></returns>
public bool UpdateExecutePlanInfo(ExecutePlanInfo executePlanInfo)
{
bool result = false;
try
{
result = _mesRepository.Update(executePlanInfo);
}
catch (Exception ex)
{
logHelper.Error("修改执行计划异常", ex);
}
return result;
}
}
}