using System;
|
using System.Collections.Generic;
|
using System.Linq.Expressions;
|
using System.Text;
|
using Model.ModelDto.BllCheckDto;
|
using SqlSugar;
|
using WMS.DAL;
|
using WMS.Entity.BllCheckEntity;
|
using WMS.Entity.Context;
|
using WMS.Entity.SysEntity;
|
using WMS.IBLL.IBllCheckServer;
|
|
namespace WMS.BLL.BllCheckServer
|
{
|
public class StockCheckLogServer:DbHelper<BllStockCheckLog>,IStockCheckLogServer
|
{
|
private static readonly SqlSugarScope Db = DataContext.Db;
|
public StockCheckLogServer() : base(Db)
|
{
|
}
|
|
//获取盘点记录
|
public List<StockCheckLogDto> GetStockCheckLogList(string crNo, string status, string palletNo, string boxNo, string skuNo, string skuName, string lotNo, int page, int limit, out int count)
|
{
|
try
|
{
|
Expression<Func<BllStockCheckLog, bool>> item = Expressionable.Create<BllStockCheckLog>()
|
.AndIF(!string.IsNullOrWhiteSpace(crNo), m => m.CRNo.Contains(crNo.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(status), m => m.CheckResult == int.Parse(status))
|
.AndIF(!string.IsNullOrWhiteSpace(palletNo), m => m.PalletNo.Contains(palletNo.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(boxNo), m => m.BoxNo.Contains(boxNo.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(skuNo), m => m.SkuNo.Contains(skuName.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(skuName), m => m.SkuName.Contains(lotNo.Trim()))
|
.AndIF(!string.IsNullOrWhiteSpace(lotNo), m => m.LotNo.Contains(lotNo.Trim()))
|
.And(m => m.IsDel == "0")
|
.ToExpression();//注意 这一句 不能少
|
var total = 0;
|
var list = GetAllWhereAsync(item)
|
.LeftJoin<SysUserInfor>((a, b) => a.CheckUserId == b.Id)
|
.LeftJoin<SysUserInfor>((a, b,c) => a.CreateUser == c.Id)
|
.LeftJoin<SysUserInfor>((a, b, c,d) => a.UpdateUser == d.Id)
|
.Select((a, b, c,d) => new StockCheckLogDto()
|
{
|
Id = a.Id,
|
CrNo = a.CRNo,
|
PalletNo = a.PalletNo,
|
BoxNo = a.BoxNo,
|
BoxNo2 = a.BoxNo2,
|
BoxNo3 = a.BoxNo3,
|
Qty = a.Qty,
|
RealQty = a.RealQty,
|
CheckDate = a.CheckDate,
|
CheckResult = a.CheckResult,
|
CheckUserName = b.RealName,
|
SkuNo = a.SkuNo,
|
SkuName = a.SkuName,
|
Standard = a.Standard,
|
LotNo = a.LotNo,
|
LotText = a.LotText,
|
SupplierLot = a.SupplierLot,
|
|
CreateUserName = c.RealName,
|
UpdateUserName = d.RealName,
|
CreateTime = a.CreateTime,
|
UpdateTime = a.UpdateTime,
|
|
}).OrderByDescending(a=>a.CreateTime).ToOffsetPage(page, limit, ref total);
|
count = total;
|
|
return list;
|
}
|
catch (Exception e)
|
{
|
throw new Exception(e.Message);
|
}
|
}
|
|
#region 数据归档
|
/// <summary>
|
/// 获取盘点记录-数据归档
|
/// </summary>
|
/// <returns></returns>
|
public List<StockCheckLogDto> GetArchivingStockCheckLogList(string crNo, string status, string palletNo, string boxNo, string skuNo, string skuName,
|
string lotNo, int page, int limit, out int count)
|
{
|
try
|
{
|
string sqlString = string.Empty;
|
string sqlCount = string.Empty;
|
string sqlPub = string.Empty;
|
sqlCount += "SELECT COUNT(tb1.ID) FROM ArchivingStockCheckLog AS tb1 ";
|
sqlString += "select tb1.*,tb2.RealName as CheckUserName,tb3.RealName as CreateUserName,tb4.RealName as UpdateUserName from ArchivingStockCheckLog as tb1 ";
|
sqlPub += "left join SysUserInfor as tb2 on tb1.CheckUserId=tb2.Id ";
|
sqlPub += "left join SysUserInfor as tb3 on tb1.CreateUser=tb3.Id ";
|
sqlPub += "left join SysUserInfor as tb4 on tb1.UpdateUser=tb4.Id ";
|
sqlPub += "where tb1.IsDel = '0' ";
|
if (!string.IsNullOrEmpty(crNo))
|
{
|
sqlPub += $"AND tb1.CRNo like '%{crNo.Trim()}%' ";
|
}
|
if (!string.IsNullOrEmpty(status))
|
{
|
sqlPub += $"AND tb1.CheckResult = {int.Parse(status)} ";
|
}
|
if (!string.IsNullOrEmpty(palletNo))
|
{
|
sqlPub += $"AND tb1.PalletNo like '%{palletNo.Trim()}%' ";
|
}
|
if (!string.IsNullOrEmpty(boxNo))
|
{
|
sqlPub += $"AND tb1.BoxNo like '%{boxNo.Trim()}%' ";
|
}
|
if (!string.IsNullOrEmpty(skuNo))
|
{
|
sqlPub += $"AND tb1.SkuNo like '%{skuNo.Trim()}%' ";
|
}
|
if (!string.IsNullOrEmpty(skuName))
|
{
|
sqlPub += $"AND tb1.SkuName like '%{skuName.Trim()}%' ";
|
}
|
if (!string.IsNullOrEmpty(lotNo))
|
{
|
sqlPub += $"AND tb1.LotNo like '%{lotNo.Trim()}%' ";
|
}
|
|
sqlCount += sqlPub;
|
sqlPub += " order by tb1.CreateTime desc ";
|
if (page == 0)
|
{
|
page = 1;
|
}
|
sqlString += sqlPub + $" offset {((page - 1) * limit)} rows fetch next {limit} rows only;";
|
|
var com = new Common();
|
count = com.GetRowCount(sqlCount);
|
|
var modelList = Db.Ado.SqlQuery<StockCheckLogDto>(sqlString);
|
|
return modelList;
|
}
|
catch (Exception e)
|
{
|
throw new Exception(e.Message);
|
}
|
}
|
#endregion
|
}
|
}
|