using Rhea.Common; using SqlSugar; using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using Tiger.IBusiness; using Tiger.Model; using static Tiger.Business.Biz; namespace Tiger.Business { public partial class Biz { /// /// SN操作 /// public partial class MqSNData : IMqSNData { /// /// 退回删除条码 /// /// /// public async Task ReturnSN(string barcode) { var result = new ApiAction(); try { SNData_His data_His = await Db.Queryable().Where(x => x.OriginalSN == barcode).FirstAsync(); if (data_His == null) { result.IsSuccessed = false; result.Message = $"退回删除条码不存在"; return result; } List sndatas = await Db.Queryable().Where(x => x.SN == barcode || x.SN == data_His.SN).ToListAsync(); if (sndatas == null && sndatas.Count>0) { result.IsSuccessed = false; result.Message = $"退回删除条码不存在"; return result; } var db = Db; var dbTran = db.UseTran(() => { db.Deleteable(data_His).ExecuteCommand(); db.Deleteable(sndatas).ExecuteCommand(); }); if (!dbTran.IsSuccess) { result.IsSuccessed = false; result.Message = $"退回删除条码异常"; } } catch (Exception ex) { result.CatchExceptionWithLog(ex, "退回删除条码异常"); } return result; } /// /// 分页 /// /// /// public async Task>> GetSNDataHis(PageAble pageList) { var res = new ApiAction>(); try { string[] strTime = pageList.sqlcmd?.Split(','); RefAsync total = 0; pageList.data = await Db.Queryable() .WhereIF(!string.IsNullOrEmpty(strTime[0]), x => Convert.ToDateTime(x.ScanTime) > Convert.ToDateTime(strTime[0])) .WhereIF(!string.IsNullOrEmpty(strTime[1]) && strTime.Length == 2, x => Convert.ToDateTime(x.ScanTime) < Convert.ToDateTime(strTime[1])) .WhereIF(!string.IsNullOrEmpty(strTime[2]), x => x.ModelCode.Equals(strTime[2])) .WhereIF(!string.IsNullOrEmpty(strTime[3]), x => x.CustomerCode.Equals(strTime[3])) .ToPageListAsync(pageList.pageIndex, pageList.pageSize, total); pageList.totals = total; } catch (Exception ex) { res.CatchExceptionWithLog(ex, "查询异常"); } res.Data = pageList; return res; } } } }