| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using System.Threading.Tasks; |
| | | using WMS.BLL.LogServer; |
| | | using WMS.DAL; |
| | | using WMS.Entity.BllAsnEntity; |
| | |
| | | /// <param name="model"></param> |
| | | /// <param name="count"></param> |
| | | /// <returns></returns> |
| | | public List<ProcurePlanNoticeDto> GetProcurePlanNoticeList(ProcurePlanNoticeVm model, out int count) |
| | | public async Task<List<ProcurePlanNoticeDto>> GetProcurePlanNoticeList(ProcurePlanNoticeVm model, RefAsync<int> count) |
| | | { |
| | | string sqlString = string.Empty; |
| | | string sqlCount = string.Empty; |
| | | string sqlPub = string.Empty; |
| | | try |
| | | { |
| | | sqlCount += "SELECT DISTINCT COUNT(tb1.ID) FROM BllProcurePlanNotice AS tb1 "; |
| | | sqlString += "SELECT DISTINCT tb1.*,tb3.RealName as CreateUserName,tb4.RealName as UpdateUserName FROM BllProcurePlanNotice AS tb1 "; |
| | | sqlPub += "LEFT JOIN BllProcurePlanNoticeDetail AS tb2 ON tb1.Id = tb2.ParentId "; |
| | | 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' "; |
| | | sqlPub += $"AND tb2.SkuNo LIKE '%{model.SkuNo}%' AND tb2.SkuName LIKE '%{model.SkuName}%' "; |
| | | sqlPub += $"AND tb2.CustomerName LIKE '%{model.CustomerName}%' "; |
| | | if (!string.IsNullOrEmpty(model.Status)) |
| | | { |
| | | sqlPub += $"AND tb1.Status = '{model.Status}' "; |
| | | } |
| | | if (!string.IsNullOrEmpty(model.StartTime)) |
| | | { |
| | | sqlPub += $"AND tb1.CreateTime >= '{model.StartTime}' "; |
| | | } |
| | | if (!string.IsNullOrEmpty(model.EndTime)) |
| | | { |
| | | sqlPub += $"AND tb1.CreateTime <= '{model.EndTime}' "; |
| | | } |
| | | sqlCount += sqlPub; |
| | | sqlPub += " order by tb1.Id desc "; |
| | | if (model.Page == 0) |
| | | { |
| | | model.Page = 1; |
| | | } |
| | | sqlString += sqlPub + $" offset {((model.Page - 1) * model.Limit)} rows fetch next {model.Limit} rows only;"; |
| | | |
| | | var com = new Common(); |
| | | count = com.GetRowCount(sqlCount); |
| | | |
| | | var modelList = Db.Ado.SqlQuery<ProcurePlanNoticeDto>(sqlString); |
| | | |
| | | return modelList; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw ex; |
| | | } |
| | | var modelList = await Db.Queryable<BllProcurePlanNotice>() |
| | | .LeftJoin<BllProcurePlanNoticeDetail>((tb1, tb2) => tb1.Id == tb2.ParentId) |
| | | .LeftJoin<SysUserInfor>((tb1, tb2, tb3) => tb1.CreateUser == tb3.Id) |
| | | .LeftJoin<SysUserInfor>((tb1, tb2, tb3, tb4) => tb1.UpdateUser == tb4.Id) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(model.Status), tb1 => tb1.Status == model.Status) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(model.StartTime), tb1 => tb1.CreateTime >= Convert.ToDateTime(model.StartTime)) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(model.EndTime), tb1 => tb1.CreateTime <= Convert.ToDateTime(model.EndTime).AddDays(1)) |
| | | .WhereIF(!string.IsNullOrWhiteSpace(model.SkuName), (tb1,tb2) => tb2.SkuName.Contains(model.SkuName)) |
| | | .Where(tb1 => tb1.IsDel == "0") |
| | | .OrderByDescending(tb1 => tb1.Id) |
| | | .Distinct() |
| | | .Select((tb1, tb2, tb3, tb4) => new ProcurePlanNoticeDto() { |
| | | Id = tb1.Id, |
| | | Status = tb1.Status, |
| | | OrderCode = tb1.OrderCode, |
| | | UserName = tb1.UserName, |
| | | CompleteTime = tb1.CompleteTime, |
| | | CreateTime = tb1.CreateTime, |
| | | CreateUserName = tb3.RealName, |
| | | UpdateTime = tb1.UpdateTime.ToString(), |
| | | UpdateUserName = tb4.RealName |
| | | }).ToPageListAsync(model.Page, model.Limit, count); |
| | | |
| | | return modelList; |
| | | } |
| | | /// <summary> |
| | | /// 获取采购单明细信息 |