|
|
|
|
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 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|