using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WMS.Info; using WMS.Util; namespace WMS.Core.ServiceCore { public class FxInventoryTransactionCore { /// /// 获取分页数据 /// /// public IEnumerable GetInventoryPageList(Pagination pagination, string queryJson) { SqlSugarClient client = null; try { client = SysDbCore.GetDbCtx(); int count = 0; var queryParam = queryJson.ToJObject(); var db = client.Queryable(); //单据日期 if (!queryParam["Btime"].IsEmpty() && !queryParam["Etime"].IsEmpty()) { db.Where(ord => ord.F_addTime >= queryParam["Btime"].ToDate() && ord.F_addTime <= queryParam["Etime"].ToDate()); } if (!queryParam["keyword"].IsEmpty()) { string matNo = queryParam["keyword"].ToString(); db.Where(ord => ord.F_matNo.Contains(matNo) || ord.F_matName.Contains(matNo)); } if (!queryParam["F_trayNo"].IsEmpty()) { string trayNo = queryParam["F_trayNo"].ToString(); db.Where(ord => ord.F_sourceTrayNo.Contains(trayNo) || ord.F_targetTrayNo.Contains(trayNo)); } if (!queryParam["F_boxNo"].IsEmpty()) { string boxNo = queryParam["F_boxNo"].ToString(); db.Where(ord => ord.F_boxNo.Contains(boxNo)); } if (!queryParam["F_matType"].IsEmpty()) { string matType = queryParam["F_matType"].ToString(); db.Where(ord => ord.F_matType == FuncStr.NullToInt(matType)); } if (pagination.sord.ToUpper() != "ASC") { pagination.sidx = pagination.sidx + " DESC"; } // (case when regexp_substr(ord.F_NO,'[^_]+',1,2) is null then ord.F_NO else regexp_substr(ord.F_NO,'[^_]+',1,2) end) var list = db.OrderBy(pagination.sidx).Select(@" [F_inventoryNo], [F_warehouseNo], [F_projectNo], [F_matNo], [F_matName], [F_matType], [F_sourceQuantity], [F_sourceLockQty], [F_targetQuantity], [F_targetLockQty], [F_sourceTrayNo], [F_targetTrayNo], [F_batchNo], [F_memo], [F_isBonded], [F_UID], [F_addUserNo], [F_addTime], [F_boxNo], [F_productDate]").ToPageList(pagination.page, pagination.rows, ref count); pagination.records = count; return list; } catch (Exception ex) { throw ex; } finally { client.Dispose(); } } } }