| | |
| | | using System.Linq.Expressions; |
| | | using System.Reflection; |
| | | using System.Reflection.Metadata; |
| | | using WIDESEA_Common.OrderEnum; |
| | | using WIDESEA_Core.BaseRepository; |
| | | using WIDESEA_Core.Const; |
| | | using WIDESEA_Core.DB.Models; |
| | |
| | | if (string.IsNullOrEmpty(where)) |
| | | where += $"{searchParametersList[i].Name} >= '{searchParametersList[i].Value}'"; |
| | | else |
| | | where += $" and {searchParametersList[i].Name} {searchParametersList[i].DisplayType.GetLinqCondition()} '{searchParametersList[i].Value}'"; |
| | | where += $" and {searchParametersList[i].Name} >= '{searchParametersList[i].Value}'"; |
| | | } |
| | | else if (searchParametersList[i].DisplayType.GetLinqCondition() == LinqExpressionType.LessThanOrEqual) |
| | | { |
| | |
| | | Type t = typeof(TEntity); |
| | | |
| | | if (pageData.Value == null) return new PageGridData<object>(total: 0, null); |
| | | |
| | | string keyName = t.GetKeyName(); |
| | | ////çææ¥è¯¢æ¡ä»¶ |
| | | //Expression<Func<TEntity, bool>> whereExpression = keyName.CreateExpression<TEntity>(pageData.Value, LinqExpressionType.Equal); |
| | | int totalCount = 0; |
| | | PropertyInfo propertyInfo = t.GetProperties().FirstOrDefault(x => x.GetCustomAttribute<Navigate>() != null); |
| | | List<ExpandoObject> detailList = new List<ExpandoObject>(); |
| | | |
| | | if (propertyInfo != null) |
| | | { |
| | | Type detailType = propertyInfo.PropertyType.GetGenericArguments()[0]; |
| | | Navigate navigate = propertyInfo.GetCustomAttribute<Navigate>(); |
| | | List<ExpandoObject> list = BaseDal.Db.Queryable(detailType.Name, "detail").Where(navigate.GetName(), "=", pageData.Value).ToPageList(pageData.Page, pageData.Rows, ref totalCount); |
| | | return new PageGridData<ExpandoObject>(totalCount, list); |
| | | |
| | | detailList = BaseDal.Db.Queryable(detailType.Name, "detail") |
| | | .Where(navigate.GetName(), "=", pageData.Value) |
| | | .ToPageList(pageData.Page, pageData.Rows, ref totalCount); |
| | | |
| | | if (detailList.Any()) |
| | | { |
| | | // 1. æåæç»ææbarcode |
| | | List<string> allBarcodes = new List<string>(); |
| | | foreach (var expando in detailList) |
| | | { |
| | | var detailDict = (IDictionary<string, object>)expando; |
| | | if (detailDict.ContainsKey("barcode") && detailDict["barcode"] != null) |
| | | { |
| | | string barcodeValue = (detailDict["barcode"] as string)?.Trim() ?? string.Empty; |
| | | if (!string.IsNullOrWhiteSpace(barcodeValue)) |
| | | { |
| | | allBarcodes.Add(barcodeValue); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (allBarcodes.Count == 0) |
| | | { |
| | | foreach (var expando in detailList) |
| | | { |
| | | var detailDict = (IDictionary<string, object>)expando; |
| | | detailDict["palletCode"] = ""; |
| | | } |
| | | return new PageGridData<ExpandoObject>(totalCount, detailList); |
| | | } |
| | | |
| | | // 2. æ¥åºåæç»è¡¨ï¼è·åbarcode â StockIdæ å° |
| | | Dictionary<string, object> barcodeToStockIdDict = new Dictionary<string, object>(); |
| | | var distinctBarcodes = allBarcodes.Distinct().ToList(); |
| | | var barcodeStockIdList = BaseDal.Db.Queryable("Dt_StockInfoDetail", "sd") |
| | | .In("sd.barcode", distinctBarcodes) |
| | | .Select("sd.barcode, sd.StockId") |
| | | .ToList(); |
| | | |
| | | foreach (var item in barcodeStockIdList) |
| | | { |
| | | if (item == null) continue; |
| | | var itemDict = (IDictionary<string, object>)item; |
| | | |
| | | if (itemDict.ContainsKey("barcode") && itemDict["barcode"] != null) |
| | | { |
| | | string barcode = (itemDict["barcode"] as string)?.Trim() ?? string.Empty; |
| | | object stockId = itemDict.ContainsKey("StockId") ? itemDict["StockId"] : null; |
| | | |
| | | if (!string.IsNullOrWhiteSpace(barcode) && !barcodeToStockIdDict.ContainsKey(barcode)) |
| | | { |
| | | barcodeToStockIdDict.Add(barcode, stockId); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (barcodeToStockIdDict.Count == 0) |
| | | { |
| | | foreach (var expando in detailList) |
| | | { |
| | | var detailDict = (IDictionary<string, object>)expando; |
| | | detailDict["palletCode"] = ""; |
| | | } |
| | | return new PageGridData<ExpandoObject>(totalCount, detailList); |
| | | } |
| | | |
| | | Dictionary<object, string> stockIdToPalletDict = new Dictionary<object, string>(); |
| | | var allStockIds = barcodeToStockIdDict.Values.Distinct().ToList(); |
| | | var stockIdPalletList = BaseDal.Db.Queryable("Dt_StockInfo", "s") |
| | | .In("s.Id", allStockIds) |
| | | .Select("s.Id, s.PalletCode") |
| | | .ToList(); |
| | | |
| | | // æå PalletCode |
| | | foreach (var item in stockIdPalletList) |
| | | { |
| | | if (item == null) continue; |
| | | var itemDict = (IDictionary<string, object>)item; |
| | | if (itemDict.ContainsKey("Id") && itemDict["Id"] != null) |
| | | { |
| | | object stockId = itemDict["Id"]; |
| | | string palletCode = itemDict.ContainsKey("PalletCode") && itemDict["PalletCode"] != null |
| | | ? (itemDict["PalletCode"] as string)?.Trim() ?? string.Empty |
| | | : string.Empty; |
| | | if (!stockIdToPalletDict.ContainsKey(stockId)) |
| | | { |
| | | stockIdToPalletDict.Add(stockId, palletCode); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 5. ç»æç»çpalletCodeåæ®µèµå¼ä¸»è¡¨çPalletCodeå¼ |
| | | foreach (var expando in detailList) |
| | | { |
| | | var detailDict = (IDictionary<string, object>)expando; |
| | | string palletValue = string.Empty; |
| | | |
| | | if (detailDict.ContainsKey("barcode") && detailDict["barcode"] != null) |
| | | { |
| | | string barcode = (detailDict["barcode"] as string)?.Trim() ?? string.Empty; |
| | | // éè¿barcodeè·åStockId |
| | | if (!string.IsNullOrWhiteSpace(barcode) && barcodeToStockIdDict.TryGetValue(barcode, out var stockId)) |
| | | { |
| | | // éè¿StockIdè·å主表çPalletCode |
| | | stockIdToPalletDict.TryGetValue(stockId, out palletValue); |
| | | } |
| | | } |
| | | // å¨ææ´æ°/æ·»å palletCodeåæ®µ |
| | | if (detailDict.ContainsKey("palletCode")) |
| | | { |
| | | detailDict["palletCode"] = palletValue; |
| | | } |
| | | else |
| | | { |
| | | detailDict.Add("palletCode", palletValue); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | return new PageGridData<object>(total: 0, null); |
| | | |
| | | return new PageGridData<ExpandoObject>(totalCount, detailList); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | saveModel.MainData.Remove(keyPro.Name.FirstLetterToLower()); |
| | | } |
| | | } |
| | | saveModel.MainData["CreateType"] = (int)OrderCreateTypeEnum.CreateInSystem; |
| | | |
| | | saveModel.MainData["ReturnToMESStatus"] = 5; |
| | | |
| | | TEntity entity = saveModel.MainData.DicToModel<TEntity>(); |
| | | if (saveModel.DetailData == null || saveModel.DetailData.Count == 0) |
| | | { |