shgx_tz_mom/ZR.Service/mes/wms/WmGoodsChangeLogService.cs

89 lines
3.1 KiB
C#

using Infrastructure.Attribute;
using SqlSugar;
using System;
using ZR.Model;
using ZR.Model.MES.wms;
using ZR.Model.MES.wms.Dto;
using ZR.Repository;
using ZR.Service.mes.wms.IService;
namespace ZR.Service.Business
{
/// <summary>
/// 仓库操作日志Service业务层处理
/// </summary>
[AppService(ServiceType = typeof(IWmGoodsChangeLogService), ServiceLifetime = LifeTime.Transient)]
public class WmGoodsChangeLogService : BaseService<WmGoodsChangeLog>, IWmGoodsChangeLogService
{
/// <summary>
/// 查询仓库操作日志列表
/// </summary>
/// <param name="parm"></param>
/// <returns></returns>
public PagedInfo<WmGoodsChangeLogDto> GetList(WmGoodsChangeLogQueryDto parm)
{
DateTime searchStartTime = DateTime.Now;
DateTime searchEndTime = DateTime.Now;
var predicate = Expressionable.Create<WmGoodsChangeLog>()
.AndIF(parm.Type > 0, it => it.Type == parm.Type)
.AndIF(!string.IsNullOrEmpty(parm.Description), it => it.Description.Contains(parm.Description))
// 当天0点
.AndIF(DateTime.TryParse(parm.StartTimeStr, out searchStartTime), it => it.CreatedTime > searchStartTime)
// 当天23点59分59秒
.AndIF(DateTime.TryParse(parm.EndTimeStr, out searchEndTime), it => it.CreatedTime < searchEndTime.AddDays(1).AddTicks(-1))
;
var response = Queryable()
.Where(predicate.ToExpression())
.OrderBy(it => it.CreatedTime, OrderByType.Desc)
.ToPage<WmGoodsChangeLog, WmGoodsChangeLogDto>(parm);
return response;
}
/// <summary>
/// 获取详情
/// </summary>
/// <param name="Id"></param>
/// <returns></returns>
public WmGoodsChangeLog GetInfo(int Id)
{
var response = Queryable()
.Where(x => x.Id == Id)
.First();
return response;
}
/// <summary>
/// 添加仓库操作日志
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public WmGoodsChangeLog AddWmGoodsChangeLog(WmGoodsChangeLog model)
{
return Context.Insertable(model).ExecuteReturnEntity();
}
/// <summary>
/// 修改仓库操作日志
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateWmGoodsChangeLog(WmGoodsChangeLog model)
{
//var response = Update(w => w.Id == model.Id, it => new WmGoodsChangeLog()
//{
// Type = model.Type,
// Description = model.Description,
// JsonMsg = model.JsonMsg,
// CreatedBy = model.CreatedBy,
// CreatedTime = model.CreatedTime,
// UpdatedBy = model.UpdatedBy,
// UpdatedTime = model.UpdatedTime,
//});
//return response;
return Update(model, true);
}
}
}