|
|
|
|
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<BaseSpaceDetail> _mesRepository = new Repository<BaseSpaceDetail>("mes");
|
|
|
|
|
|
|
|
|
|
private LogHelper logHelper = LogHelper.Instance;
|
|
|
|
|
|
|
|
|
|
private JsonChange jsonChange = JsonChange.Instance;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据物料编号删除货道明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过物料编号获取货道明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="materialCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public BaseSpaceDetail GetSpaceDetailByMaterialCode(string materialCode)
|
|
|
|
|
{
|
|
|
|
|
BaseSpaceDetail spaceDetail = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<BaseSpaceDetail, bool>> 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通过货道号获取货道明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="spaceCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<BaseSpaceDetail> GetSpaceDetailsBySpaceCode(string storeCode, string spaceCode)
|
|
|
|
|
{
|
|
|
|
|
List<BaseSpaceDetail> spaceDetails = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<BaseSpaceDetail, bool>> 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据物料类型获取可用的货道明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="storeCode"></param>
|
|
|
|
|
/// <param name="materialType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public List<BaseSpaceDetail> GetSpaceDetailsByMaterialType(string storeCode, string materialType)
|
|
|
|
|
{
|
|
|
|
|
List<BaseSpaceDetail> spaceDetails = null;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Expression<Func<BaseSpaceDetail, bool>> 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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 添加货道明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="spaceDetail"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool InsertSpaceDetail(BaseSpaceDetail spaceDetail)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = _mesRepository.Insert(spaceDetail);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("添加货道明细异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 更新货道明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="spaceDetail"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool UpdateSpaceDetail(BaseSpaceDetail spaceDetail)
|
|
|
|
|
{
|
|
|
|
|
bool result = false;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = _mesRepository.Update(spaceDetail);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
logHelper.Error("更新货道明细异常", ex);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|