| | |
| | | } |
| | | try |
| | | { |
| | | // 2. æ§è¡å é¤ï¼æ ¹æ® DeliveryNo å¹é
è¡¨ä¸æ°æ®ï¼å¯¹åºå®ä½ç DeliveryNo åæ®µï¼ |
| | | // 2. æ¥è¯¢è¦å é¤çæ¡ç ä¿¡æ¯ |
| | | var barcodesToDelete = Db.Queryable<BarcodeInformation>() |
| | | .Where(barcode => barcode.DeliveryNo == deliveryNo) |
| | | .ToList(); |
| | | |
| | | if (!barcodesToDelete.Any()) |
| | | { |
| | | throw new KeyNotFoundException($"æªæ¾å°éè´§åå·ä¸ºã{deliveryNo}ãçæ¡ç æ°æ®ï¼å 餿使ªæ§è¡"); |
| | | } |
| | | |
| | | // 3. æ ¡éªæ¡ç æ¯å¦å¨åºå表ä¸åå¨ |
| | | foreach (var barcode in barcodesToDelete) |
| | | { |
| | | CheckBarcodeInInventory(barcode.SmallBarcode, barcode.OuterBarcode); |
| | | } |
| | | |
| | | // 4. æ§è¡å é¤ï¼æ ¹æ® DeliveryNo å¹é
è¡¨ä¸æ°æ®ï¼å¯¹åºå®ä½ç DeliveryNo åæ®µï¼ |
| | | int deletedCount = Db.Deleteable<BarcodeInformation>() |
| | | .Where(barcode => barcode.DeliveryNo == deliveryNo) // è¡¨åæ®µä¸éè´§åå·å¹é
|
| | | .ExecuteCommand(); // è¿ååå½±åçè¡æ° |
| | | |
| | | // 3. å¤æç»æï¼è³å°å é¤1æ¡åè§ä¸ºæåï¼å¦åæåºâæªæ¾å°æ°æ®âå¼å¸¸ |
| | | // 5. å¤æç»æï¼è³å°å é¤1æ¡åè§ä¸ºæåï¼å¦åæåº"æªæ¾å°æ°æ®"å¼å¸¸ |
| | | if (deletedCount > 0) |
| | | { |
| | | return true; |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 4. å
è£
ä¸å¡å¼å¸¸ï¼è¡¥å
ä¸ä¸æä¿¡æ¯ |
| | | // 6. å
è£
ä¸å¡å¼å¸¸ï¼è¡¥å
ä¸ä¸æä¿¡æ¯ |
| | | throw new ApplicationException($"æ ¹æ®éè´§åå·å 餿¡ç æ°æ®å¤±è´¥ï¼DeliveryNoï¼{deliveryNo}ï¼ï¼{ex.Message}", ex); |
| | | } |
| | | } |
| | |
| | | } |
| | | try |
| | | { |
| | | // 2. æ¥è¯¢æ°æ®åºä¸åå¨çéè´§åå· |
| | | // 2. æ¥è¯¢æ°æ®åºä¸åå¨çéè´§åå·å对åºçæ¡ç ä¿¡æ¯ |
| | | var existingNos = Db.Queryable<BarcodeInformation>().Where(barcode => deliveryNoList.Contains(barcode.DeliveryNo)).Select(barcode => barcode.DeliveryNo).Distinct().ToList(); |
| | | var barcodesToDelete = Db.Queryable<BarcodeInformation>().Where(barcode => deliveryNoList.Contains(barcode.DeliveryNo)).ToList(); |
| | | |
| | | // 3. æ§è¡æ¹éå é¤ |
| | | // 3. æ ¡éªæ¡ç æ¯å¦å¨åºå表ä¸åå¨ |
| | | foreach (var barcode in barcodesToDelete) |
| | | { |
| | | CheckBarcodeInInventory(barcode.SmallBarcode, barcode.OuterBarcode); |
| | | } |
| | | |
| | | // 4. æ§è¡æ¹éå é¤ |
| | | int totalDeleted = Db.Deleteable<BarcodeInformation>().Where(barcode => deliveryNoList.Contains(barcode.DeliveryNo)).ExecuteCommand(); |
| | | |
| | | // 4. è¿åç»æ |
| | | // 5. è¿åç»æ |
| | | return new BatchDeleteResult |
| | | { |
| | | TotalRequested = deliveryNoList.Count, |
| | |
| | | |
| | | try |
| | | { |
| | | // 2. è忡件å é¤ï¼å¹é
DeliveryNoï¼éè´§åå·ï¼å DnLinesï¼è¡å
ç ï¼å®ä½å段对åºè¡¨ç dnLines åï¼ |
| | | // 2. æ¥è¯¢è¦å é¤çæ¡ç ä¿¡æ¯ |
| | | var barcodesToDelete = Db.Queryable<BarcodeInformation>() |
| | | .Where(barcode => barcode.DeliveryNo == deliveryNo && barcode.DnLines == lineNo) |
| | | .ToList(); |
| | | |
| | | if (!barcodesToDelete.Any()) |
| | | { |
| | | throw new KeyNotFoundException($"æªæ¾å°éè´§åå·ã{deliveryNo}ãä¸è¡å
ç ã{lineNo}ã对åºçæ¡ç æ°æ®ï¼å 餿使ªæ§è¡"); |
| | | } |
| | | |
| | | // 3. æ ¡éªæ¡ç æ¯å¦å¨åºå表ä¸åå¨ |
| | | foreach (var barcode in barcodesToDelete) |
| | | { |
| | | CheckBarcodeInInventory(barcode.SmallBarcode, barcode.OuterBarcode); |
| | | } |
| | | |
| | | // 4. è忡件å é¤ï¼å¹é
DeliveryNoï¼éè´§åå·ï¼å DnLinesï¼è¡å
ç ï¼å®ä½å段对åºè¡¨ç dnLines åï¼ |
| | | int deletedCount = Db.Deleteable<BarcodeInformation>().Where(barcode =>barcode.DeliveryNo == deliveryNo && barcode.DnLines == lineNo) // å¹é
è¡å
ç ï¼å®ä½ DnLines 对åºè¡¨ dnLines åæ®µï¼ |
| | | .ExecuteCommand(); // è¿ååå½±åçè¡æ° |
| | | |
| | | // 3. ç»æå¤æï¼ææ°æ®è¢«å é¤åæåï¼å¦åæâæªæ¾å°æ°æ®âå¼å¸¸ |
| | | // 5. ç»æå¤æï¼ææ°æ®è¢«å é¤åæåï¼å¦åæ"æªæ¾å°æ°æ®"å¼å¸¸ |
| | | if (deletedCount > 0) |
| | | { |
| | | return true; |
| | |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 4. å
è£
å¼å¸¸ï¼è¡¥å
è忡件ä¸ä¸æï¼ä¾¿äºå®ä½é®é¢ |
| | | // 6. å
è£
å¼å¸¸ï¼è¡¥å
è忡件ä¸ä¸æï¼ä¾¿äºå®ä½é®é¢ |
| | | throw new ApplicationException($"æéè´§åå·+è¡å
ç å 餿¡ç æ°æ®å¤±è´¥ï¼DeliveryNoï¼{deliveryNo}ï¼LineNoï¼{lineNo}ï¼ï¼{ex.Message}",ex); |
| | | } |
| | | } |
| | |
| | | foreach (var item in validItems) |
| | | { |
| | | // æ£æ¥å½åç»åæ¯å¦åå¨ |
| | | var exists = Db.Queryable<BarcodeInformation>().Any(b => b.DeliveryNo == item.DeliveryNo && b.DnLines == item.LineNo); |
| | | var barcodesToDelete = Db.Queryable<BarcodeInformation>() |
| | | .Where(b => b.DeliveryNo == item.DeliveryNo && b.DnLines == item.LineNo) |
| | | .ToList(); |
| | | |
| | | if (exists) |
| | | if (barcodesToDelete.Any()) |
| | | { |
| | | // æ ¡éªæ¡ç æ¯å¦å¨åºå表ä¸åå¨ |
| | | foreach (var barcode in barcodesToDelete) |
| | | { |
| | | CheckBarcodeInInventory(barcode.SmallBarcode, barcode.OuterBarcode); |
| | | } |
| | | |
| | | // æ§è¡å é¤ |
| | | var deleted = Db.Deleteable<BarcodeInformation>().Where(b => b.DeliveryNo == item.DeliveryNo && b.DnLines == item.LineNo).ExecuteCommand(); |
| | | totalDeleted += deleted; |
| | |
| | | { |
| | | throw new ArgumentException("å 餿ä½çæ¡ç Idä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | // æ¥è¯¢è¦å é¤çæ¡ç ä¿¡æ¯ |
| | | var barcodeToDelete = Db.Queryable<BarcodeInformation>().Where(entity => entity.Id == id).First(); |
| | | if (barcodeToDelete == null) |
| | | { |
| | | throw new NotImplementedException($"æ¡ç å é¤å¤±è´¥ï¼æªæ¾å°Id为ã{id}ãçæ¡ç è®°å½"); |
| | | } |
| | | |
| | | // æ ¡éªæ¡ç æ¯å¦å¨MesInvItemBarcode表ä¸åå¨ |
| | | CheckBarcodeInInventory(barcodeToDelete.SmallBarcode, barcodeToDelete.OuterBarcode); |
| | | |
| | | var deleteRowCount = Db.Deleteable<BarcodeInformation>().Where(entity => entity.Id == id).ExecuteCommand(); |
| | | |
| | | return deleteRowCount > 0 ? true : throw new NotImplementedException($"æ¡ç å é¤å¤±è´¥ï¼æªæ¾å°Id为ã{id}ãçæ¡ç è®°å½"); |
| | |
| | | { |
| | | throw new ArgumentException("æ¹éå é¤çæ¡ç Idæ°ç»ä¸è½ä¸ºç©º"); |
| | | } |
| | | |
| | | // æ¥è¯¢è¦å é¤çæ¡ç ä¿¡æ¯ |
| | | var barcodesToDelete = Db.Queryable<BarcodeInformation>().Where(entity => ids.Contains(entity.Id)).ToList(); |
| | | if (!barcodesToDelete.Any()) |
| | | { |
| | | throw new NotImplementedException($"æ¹éæ¡ç å é¤å¤±è´¥ï¼æªæ¾å°ä»»ä½å¹é
çæ¡ç è®°å½"); |
| | | } |
| | | |
| | | // æ¹éæ ¡éªæ¡ç æ¯å¦å¨åºå表ä¸åå¨ |
| | | foreach (var barcode in barcodesToDelete) |
| | | { |
| | | CheckBarcodeInInventory(barcode.SmallBarcode, barcode.OuterBarcode); |
| | | } |
| | | |
| | | var deleteRowCount = Db.Deleteable<BarcodeInformation>().Where(entity => ids.Contains(entity.Id)).ExecuteCommand(); |
| | | |
| | | return deleteRowCount > 0 ? true : throw new NotImplementedException($"æ¹éæ¡ç å é¤å¤±è´¥ï¼å
±{ids.Length}个Id"); |
| | |
| | | (!string.IsNullOrEmpty(entity.OuterBarcode) && x.OuterBarcode == entity.OuterBarcode)); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ ¡éªæ¡ç æ¯å¦å¨åºå表ä¸åå¨ï¼å¦æåå¨åæåºå¼å¸¸ä¸å
许å é¤ |
| | | /// </summary> |
| | | /// <param name="smallBarcode">å°å
è£
æ¡ç </param> |
| | | /// <param name="outerBarcode">å¤å
è£
æ¡ç </param> |
| | | private void CheckBarcodeInInventory(string smallBarcode, string outerBarcode) |
| | | { |
| | | var existsInInventory = false; |
| | | var existingBarcode = string.Empty; |
| | | |
| | | // æ£æ¥å°å
è£
æ¡ç æ¯å¦å¨åºå表ä¸åå¨ |
| | | if (!string.IsNullOrEmpty(smallBarcode)) |
| | | { |
| | | existsInInventory = Db.Queryable<MesInvItemBarcodes>() |
| | | .Any(x => x.ItemBarcode == smallBarcode); |
| | | if (existsInInventory) |
| | | { |
| | | existingBarcode = smallBarcode; |
| | | } |
| | | } |
| | | |
| | | // æ£æ¥å¤å
è£
æ¡ç æ¯å¦å¨åºå表ä¸åå¨ï¼å¦æå°å
è£
æ¡ç ä¸åå¨çè¯ï¼ |
| | | if (!existsInInventory && !string.IsNullOrEmpty(outerBarcode)) |
| | | { |
| | | existsInInventory = Db.Queryable<MesInvItemBarcodes>() |
| | | .Any(x => x.ItemBarcode == outerBarcode); |
| | | if (existsInInventory) |
| | | { |
| | | existingBarcode = outerBarcode; |
| | | } |
| | | } |
| | | |
| | | // 妿æ¡ç å¨åºå表ä¸åå¨ï¼åæåºå¼å¸¸ä¸å
许å é¤ |
| | | if (existsInInventory) |
| | | { |
| | | throw new InvalidOperationException($"æ¡ç ã{existingBarcode}ãå·²å¨åºåä¸ï¼ä¸å
许å é¤"); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | } |