| | |
| | | public MesInvItemBarcodes ScanInBarcodeQC(WarehouseQuery query) |
| | | { |
| | | if (string.IsNullOrWhiteSpace(query.sectionCode)) |
| | | { |
| | | throw new Exception("请扫库位条码!"); |
| | | } |
| | | |
| | | var depotCode = GetDepotCode(query.sectionCode); |
| | | if (depotCode == null) |
| | | { |
| | | throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!"); |
| | | } |
| | | |
| | | var checkBarcodeAlreadyReceived = |
| | | CheckBarcodeAlreadyReceived(query.barcode); |
| | | |
| | | if (checkBarcodeAlreadyReceived > 0) |
| | | { |
| | | throw new Exception("条码重复扫描,请核对!"); |
| | | } |
| | | if (checkBarcodeAlreadyReceived > 0) throw new Exception("条码重复扫描,请核对!"); |
| | | |
| | | if (CheckBarcodeInStock(query.barcode) > 0) |
| | | { |
| | | throw new Exception("条码已在库存中,请核对!"); |
| | | } |
| | | |
| | | var barcodeInfo = GetBarcodeInfo(query.barcode); |
| | | if (barcodeInfo == null || barcodeInfo.ComeFlg != 0) |
| | | { |
| | | throw new Exception("条码不是期初条码,无法用期初入库!"); |
| | | } |
| | | |
| | | var inventoryItemInId = GetOrCreateInventoryItemInId(barcodeInfo, |
| | | depotCode, query.userName, out string billNo); |
| | | depotCode, query.userName, out var billNo); |
| | | |
| | | UseTransaction(db => |
| | | { |
| | |
| | | var mesInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(s => s.ItemBarcode == query.barcode).Count(); |
| | | |
| | | if (mesInvItemBarcodes <= 0) |
| | | { |
| | | throw new Exception("条码不存在"); |
| | | } |
| | | if (mesInvItemBarcodes <= 0) throw new Exception("条码不存在"); |
| | | |
| | | var mesInvItemInCDetails = Db.Queryable<MesInvItemInCDetails>() |
| | | .Where(s => s.ItemBarcode == query.barcode).Single(); |
| | | |
| | | PurchaseInventory entity = new PurchaseInventory |
| | | var entity = new PurchaseInventory |
| | | { |
| | | ItemIns = GetMesInvItemIns(mesInvItemInCDetails.ItemInId), |
| | | InvItemInCDetails = |
| | |
| | | TaskNo = barcodeInfo.TaskNo |
| | | }).ExecuteCommand(); |
| | | |
| | | if (executeCommand <= 0) |
| | | { |
| | | throw new Exception("写入失败"); |
| | | } |
| | | if (executeCommand <= 0) throw new Exception("写入失败"); |
| | | } |
| | | |
| | | private decimal GetOrCreateInventoryItemInId(MesInvItemBarcodes barcodeInfo, |
| | |
| | | SuppNo = barcodeInfo.SuppNo |
| | | }).ExecuteCommand(); |
| | | |
| | | if (executeCommand <= 0) |
| | | { |
| | | throw new Exception("写入失败"); |
| | | } |
| | | if (executeCommand <= 0) throw new Exception("写入失败"); |
| | | } |
| | | |
| | | private void InsertBusinessRecord(MesInvItemBarcodes barcodeInfo, |
| | |
| | | SuppNo = barcodeInfo.SuppNo |
| | | }).ExecuteCommand(); |
| | | |
| | | if (executeCommand <= 0) |
| | | { |
| | | throw new Exception("写入失败"); |
| | | } |
| | | if (executeCommand <= 0) throw new Exception("写入失败"); |
| | | } |
| | | } |