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 BaseSpaceDetailServiceImpl : IBaseSpaceDetailService { private Repository _mesRepository = new Repository("mes"); private LogHelper logHelper = LogHelper.Instance; private JsonChange jsonChange = JsonChange.Instance; /// /// 根据物料编号删除货道明细 /// /// /// public bool DeleteSpaceDetailByMaterialCode(string materialCode) { bool result = false; try { BaseSpaceDetail spaceDetail = this.GetSpaceDetailByMaterialCode(materialCode); result = _mesRepository.Delete(spaceDetail); } catch (Exception ex) { logHelper.Error("根据物料编号删除货道明细异常", ex); } return result; } /// /// 通过物料编号获取货道明细 /// /// /// public BaseSpaceDetail GetSpaceDetailByMaterialCode(string materialCode) { BaseSpaceDetail spaceDetail = null; try { Expression> exp = s1 => true; exp = exp.And(x => x.materialCode == materialCode); spaceDetail = _mesRepository.GetFirst(exp); logHelper.Info($"根据物料编号{materialCode};获取到的货道明细信息:{jsonChange.ModeToJson(spaceDetail)}"); } catch (Exception ex) { logHelper.Error("通过物料编号获取货道明细", ex); } return spaceDetail; } /// /// 通过货道号获取货道明细 /// /// /// /// public List GetSpaceDetailsBySpaceCode(string storeCode, string spaceCode) { List spaceDetails = null; try { Expression> exp = s1 => true; exp = exp.And(x => x.storeCode == storeCode && x.spaceCode == spaceCode); spaceDetails = _mesRepository.GetList(exp); logHelper.Info($"根据仓库编号:{storeCode};货道编号:{spaceCode};获取到的执货道明细:{jsonChange.ModeToJson(spaceDetails)}"); } catch (Exception ex) { logHelper.Error("通过货道号获取货道明细异常", ex); } return spaceDetails; } /// /// 根据物料类型获取可用的货道明细 /// /// /// /// public List GetSpaceDetailsByMaterialType(string storeCode, string materialType) { List spaceDetails = null; try { Expression> exp = s1 => true; exp = exp.And(x => x.storeCode == storeCode && x.materialType == materialType && x.isFlag != 1); spaceDetails = _mesRepository.GetList(exp); logHelper.Info($"根据仓库编号:{storeCode};物料类型:{materialType};获取到的货道明细:{jsonChange.ModeToJson(spaceDetails)}"); } catch (Exception ex) { logHelper.Error("通过物料类型获取货道明细异常", ex); } return spaceDetails; } /// /// 添加货道明细 /// /// /// public bool InsertSpaceDetail(BaseSpaceDetail spaceDetail) { bool result = false; try { result = _mesRepository.Insert(spaceDetail); } catch (Exception ex) { logHelper.Error("添加货道明细异常", ex); } return result; } /// /// 更新货道明细 /// /// /// public bool UpdateSpaceDetail(BaseSpaceDetail spaceDetail) { bool result = false; try { result = _mesRepository.Update(spaceDetail); } catch (Exception ex) { logHelper.Error("更新货道明细异常", ex); } return result; } } }