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 _mesRepository = new Repository("mes"); private LogHelper logHelper = LogHelper.Instance; private JsonChange jsonChange = JsonChange.Instance; /// /// 通过计划编号获取计划信息 /// /// /// public ProductPlanInfo GetProductPlanByPlanCode(string planCode) { ProductPlanInfo planInfo = null; try { Expression> 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; } /// /// 通过产线工位获取生产计划 /// /// /// public List GetProductPlanInfosByProductLineCode(string productLineCode) { List planInfos = null; try { Expression> 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; } /// /// 添加生产计划 /// /// /// public bool InsertProductPlanInfo(ProductPlanInfo productPlanInfo) { bool result = false; try { result = _mesRepository.Insert(productPlanInfo); } catch (Exception ex) { logHelper.Error("添加生产计划异常", ex); } return result; } /// /// 修改生产计划 /// /// /// public bool UpdateProductPlanInfo(ProductPlanInfo productPlanInfo) { bool result = false; try { result = _mesRepository.Update(productPlanInfo); } catch (Exception ex) { logHelper.Error("修改生产计划异常", ex); } return result; } } }