!提交代码
This commit is contained in:
126
WCS.BLL/Services/Service/MatInventoryDetailService.cs
Normal file
126
WCS.BLL/Services/Service/MatInventoryDetailService.cs
Normal file
@ -0,0 +1,126 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using TouchSocket.Core;
|
||||
using WCS.BLL.DbModels;
|
||||
using WCS.BLL.Services.IService;
|
||||
using WCS.DAL;
|
||||
using WCS.DAL.AuthDbModel;
|
||||
using WCS.DAL.Db;
|
||||
using WCS.DAL.DbModels;
|
||||
using WCS.Model;
|
||||
using WCS.Model.ApiModel;
|
||||
using WCS.Model.ApiModel.MatInventoryDetail;
|
||||
using WCS.Model.ApiModel.User;
|
||||
|
||||
namespace WCS.BLL.Services.Service
|
||||
{
|
||||
public class MatInventoryDetailService : IMatInventoryDetailService
|
||||
{
|
||||
public async Task<PageQueryResponse<InventoryDetail>> getMatInventoryDetail(GetMatInventoryDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.LeftJoin<StoreInfo>((id, si) => id.StoreId == si.Id)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSN), (id, si) => id.MatSN.Contains(request.MatSN))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCode), (id, si) => id.MatCode.Contains(request.MatCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatName), (id, si) => id.MatName.Contains(request.MatName))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatBatch), (id, si) => id.MatBatch.Contains(request.MatBatch))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSpec), (id, si) => id.MatSpec.Contains(request.MatSpec))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSupplier), (id, si) => id.MatSpec.Contains(request.MatSupplier))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCustomer), (id, si) => id.MatSpec.Contains(request.MatCustomer))
|
||||
|
||||
|
||||
.WhereIF(request.StoreId != 0, (id, si) => id.StoreId == request.StoreId)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StoreCode), (id, si) => id.StoreCode.Contains(request.StoreCode))
|
||||
;
|
||||
|
||||
var totalCount = await recordsQueryable.CountAsync();
|
||||
var records = await recordsQueryable
|
||||
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
||||
.Select<InventoryDetail>()
|
||||
.ToListAsync();
|
||||
//生成序号
|
||||
for (int i = 0; i < records.Count; i++)
|
||||
{
|
||||
records[i].RowNumber = (request.PageNumber - 1) * 10 + i + 1;
|
||||
}
|
||||
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<InventoryDetail>()
|
||||
{
|
||||
TotalCount = totalCount,
|
||||
MaxPage = request.PageSize == 0 ? 0 : (int)Math.Ceiling((decimal)totalCount / request.PageSize),
|
||||
Count = records.Count,
|
||||
Lists = records.ToList()
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PageQueryResponse<InventoryDetail>> exportMatInventoryDetail(GetMatInventoryDetailRequest request)
|
||||
{
|
||||
try
|
||||
{
|
||||
var recordsQueryable = DbHelp.db.Queryable<InventoryDetail>()
|
||||
.LeftJoin<StoreInfo>((id, si) => id.StoreId == si.Id)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSN), (id, si) => id.MatSN.Contains(request.MatSN))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCode), (id, si) => id.MatCode.Contains(request.MatCode))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatName), (id, si) => id.MatName.Contains(request.MatName))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatBatch), (id, si) => id.MatBatch.Contains(request.MatBatch))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSpec), (id, si) => id.MatSpec.Contains(request.MatSpec))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatSupplier), (id, si) => id.MatSpec.Contains(request.MatSupplier))
|
||||
.WhereIF(!string.IsNullOrEmpty(request.MatCustomer), (id, si) => id.MatSpec.Contains(request.MatCustomer))
|
||||
|
||||
|
||||
.WhereIF(request.StoreId != 0, (id, si) => id.StoreId == request.StoreId)
|
||||
.WhereIF(!string.IsNullOrEmpty(request.StoreCode), (id, si) => id.StoreCode.Contains(request.StoreCode))
|
||||
;
|
||||
var records = await recordsQueryable
|
||||
.Skip((request.PageNumber - 1) * request.PageSize).Take(request.PageSize)
|
||||
.Select<InventoryDetail>()
|
||||
.ToListAsync();
|
||||
//生成序号
|
||||
var index = 1;
|
||||
records.ForEach(r =>
|
||||
{
|
||||
r.RowNumber = index++;
|
||||
});
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 200,
|
||||
Message = $"success",
|
||||
Data = new PageQueryResponseData<InventoryDetail>()
|
||||
{
|
||||
Lists = records
|
||||
}
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return new PageQueryResponse<InventoryDetail>()
|
||||
{
|
||||
Code = 300,
|
||||
Message = $"操作失败:{ex.Message}",
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user