¶Ô±ÈÐÂÎļþ |
| | |
| | | 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 |
| | | { |
| | | /// <summary> |
| | | /// SNæä½ |
| | | /// </summary> |
| | | public partial class MqSNData : IMqSNData |
| | | { |
| | | /// <summary> |
| | | /// éåå 餿¡ç |
| | | /// </summary> |
| | | /// <param name="barcode"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction> ReturnSN(string barcode) |
| | | { |
| | | var result = new ApiAction(); |
| | | try |
| | | { |
| | | SNData_His data_His = await Db.Queryable<SNData_His>().Where(x => x.OriginalSN == barcode).FirstAsync(); |
| | | if (data_His == null) |
| | | { |
| | | result.IsSuccessed = false; |
| | | result.Message = $"éåå 餿¡ç ä¸åå¨"; |
| | | return result; |
| | | } |
| | | List<SNData> sndatas = await Db.Queryable<SNData>().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; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// å页 |
| | | /// </summary> |
| | | /// <param name="pageList"></param> |
| | | /// <returns></returns> |
| | | public async Task<ApiAction<PageAble<SNData_His>>> GetSNDataHis(PageAble<SNData_His> pageList) |
| | | { |
| | | var res = new ApiAction<PageAble<SNData_His>>(); |
| | | try |
| | | { |
| | | string[] strTime = pageList.sqlcmd?.Split(','); |
| | | RefAsync<int> total = 0; |
| | | pageList.data = await Db.Queryable<SNData_His>() |
| | | .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; |
| | | } |
| | | } |
| | | } |
| | | } |