using SqlSugar; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using WMS.Core.APPBLL; using WMS.Info; using WMS.Util; namespace WMS.Core.ServiceCore { public class WcsDeviceprotocolService { /// /// 获取分页数据 /// /// public IEnumerable GetPageList(Pagination pagination, string queryJson) { SqlSugarClient client = null; try { client = WCSDbCore.GetDbCtx(); int count = 0; var queryParam = queryJson.ToJObject(); var db = client.Queryable(); if (!queryParam["keyword"].IsEmpty()) { string kw = queryParam["keyword"].ToString(); db.Where(ord => ord.Devicecode.Contains(kw)); } if (pagination.sord.ToUpper() != "ASC") { pagination.sidx = pagination.sidx + " DESC"; } var list = db.OrderBy(pagination.sidx).Select(@"*").ToPageList(pagination.page, pagination.rows, ref count); pagination.records = count; return list; } catch (Exception ex) { throw ex; } finally { client.Dispose(); } } /// /// 获取数据 /// /// public IEnumerable GetListByDevicecode(string Devicecode) { var client = WCSDbCore.GetDbCtx(); var db = client.Queryable(); var lists = db.Where(o => o.Devicecode == Devicecode).ToList(); return lists; } /// /// 获取实体数据 /// 主键 /// /// public WcsDeviceprotocolEntity GetEntity(int id) { return WCSDbCore.GetDbCtx().Queryable().Where(it => it.Id == id).First(); } /// /// 获取实体数据 /// /// /// public IEnumerable GetEntityByDevicecode(string Devicecode) { return WCSDbCore.GetDbCtx().Queryable().Where(it => it.Devicecode == Devicecode).ToList(); } /// /// 删除实体数据 /// 主键 /// /// public void DeleteEntity(int id) { WCSDbCore.GetDbCtx().Deleteable().Where(it => it.Id == id).ExecuteCommand(); } /// /// 删除数据 /// 主键 /// /// public void DeleteByDevicecode(string Devicecode) { WCSDbCore.GetDbCtx().Deleteable().Where(it => it.Devicecode == Devicecode).ExecuteCommand(); } } }