| | |
| | | |
| | | namespace MES.Service.service.Warehouse; |
| | | |
| | | public class OpeningReceiptServer :RepositoryNoEntity |
| | | public class OpeningReceiptServer : RepositoryNoEntity |
| | | { |
| | | |
| | | private const string Factory = "1000"; |
| | | |
| | | private const string Company = "1000"; |
| | | |
| | | private const int billTypeId = 100; |
| | | |
| | | private const int transactionNo = 601; |
| | | |
| | | public MesInvItemBarcodes ScanInBarcodeQC(WarehouseQuery query) |
| | | { |
| | |
| | | { |
| | | throw new Exception($"002[库位编码 {query.sectionCode} 不存在,请确认!"); |
| | | } |
| | | |
| | | int billTypeId = 100; |
| | | int transactionNo = 601; |
| | | |
| | | var checkBarcodeAlreadyReceived = |
| | | CheckBarcodeAlreadyReceived(query.barcode); |
| | |
| | | } |
| | | |
| | | var inventoryItemInId = GetOrCreateInventoryItemInId(barcodeInfo, |
| | | depotCode, query.userName, transactionNo, out string billNo); |
| | | depotCode, query.userName, out string billNo); |
| | | |
| | | UseTransaction(db => |
| | | { |
| | |
| | | return 1; |
| | | }); |
| | | |
| | | |
| | | return barcodeInfo; |
| | | } |
| | | |
| | | public PurchaseInventory GetForm(WarehouseQuery query) |
| | | { |
| | | var mesInvItemBarcodes = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(s => s.ItemBarcode == query.barcode).Count(); |
| | | |
| | | if (mesInvItemBarcodes <= 0) |
| | | { |
| | | throw new Exception("条码不存在"); |
| | | } |
| | | |
| | | var mesInvItemInCDetails = Db.Queryable<MesInvItemInCDetails>() |
| | | .Where(s => s.ItemBarcode == query.barcode).Single(); |
| | | |
| | | PurchaseInventory entity = new PurchaseInventory |
| | | { |
| | | ItemIns = GetMesInvItemIns(mesInvItemInCDetails.ItemInId), |
| | | InvItemInCDetails = |
| | | GetMesInvItemInCDetailsList(mesInvItemInCDetails.ItemInId), |
| | | ItemStocks = Db.Queryable<MesInvItemStocks>() |
| | | .Where(s => s.ItemBarcode == query.barcode).ToList() |
| | | }; |
| | | |
| | | return entity; |
| | | } |
| | | |
| | | public MesInvItemIns GetMesInvItemIns(decimal id) |
| | | { |
| | | return Db.Queryable<MesInvItemIns>() |
| | | .Where(s => s.Id == id).Single(); |
| | | } |
| | | |
| | | public List<MesInvItemInCDetails> GetMesInvItemInCDetailsList(decimal id) |
| | | { |
| | | return Db.Queryable<MesInvItemInCDetails, MesUnit>((a, b) => |
| | | new JoinQueryInfos(JoinType.Inner, a.Unit == b.Id.ToString())) |
| | | .Where((a, b) => a.ItemInId == id) |
| | | .Select((a, b) => new MesInvItemInCDetails |
| | | { |
| | | ItemBarcode = a.ItemBarcode, |
| | | ItemNo = a.ItemNo, |
| | | ItemSname = a.ItemSname, |
| | | DepotSectionCode = a.DepotSectionCode, |
| | | Quantity = a.Quantity, |
| | | Unit = b.Fname, |
| | | Remark = a.Remark |
| | | }) |
| | | .ToList(); |
| | | } |
| | | |
| | | private void InsertInventoryDetails(decimal itemInId, string billNo, |
| | |
| | | } |
| | | |
| | | private decimal GetOrCreateInventoryItemInId(MesInvItemBarcodes barcodeInfo, |
| | | string depotCode, string userName, int transactionNo, out string billNo) |
| | | string depotCode, string userName, out string billNo) |
| | | { |
| | | var inventory = Db.Queryable<MesInvItemIns>() |
| | | .Where(d => d.InsDate >= DateTime.Today && |
| | |
| | | d.SuppNo == barcodeInfo.SuppNo && |
| | | d.DepotsCode == depotCode) |
| | | .First(); |
| | | |
| | | if (inventory != null) |
| | | { |
| | | billNo = inventory.BillNo; |
| | |
| | | var executeReturnIdentity = Db.Insertable(new MesInvItemIns |
| | | { |
| | | BillNo = billNo, |
| | | BillTypeId = 100, |
| | | BillTypeId = billTypeId, |
| | | InsDate = DateTime.Now, |
| | | DepotsCode = depotCode, |
| | | TransctionNo = transactionNo.ToString(), |
| | |
| | | var executeCommand = Db.Insertable(new MesInvBusiness2 |
| | | { |
| | | Status = 1, |
| | | BillTypeId = 100, |
| | | BillTypeId = billTypeId, |
| | | TransactionCode = "601", |
| | | BusinessType = 1, |
| | | ItemBarcode = barcodeInfo.ItemBarcode, |