| | |
| | | string user = entity.userName, |
| | | sectionCode = entity.sectionCode, |
| | | itemBarcode = entity.barcode; |
| | | string transactionNo = "101"; |
| | | var transactionNo = "101"; |
| | | int? billTypeId = 100, num = 0, num2 = 0; |
| | | int freeze = 0; |
| | | var freeze = 0; |
| | | decimal cSyQty = 0; |
| | | |
| | | if (string.IsNullOrEmpty(sectionCode)) |
| | |
| | | if (itemBarcodeDetails == null) |
| | | throw new Exception("条码不存在,请核对!"); |
| | | |
| | | if (!itemBarcodeDetails.ComeFlg.Value) |
| | | if (itemBarcodeDetails.ComeFlg == 0) |
| | | throw new Exception("此条码不属于到货条码,无法用采购入库!"); |
| | | |
| | | var inventory = Db.Queryable<MesInvItemArn>() |
| | |
| | | if (inventory == null) |
| | | throw new Exception("此条码找不到对应收货单!"); |
| | | |
| | | // var inventoryDetails = Db.Queryable<MesInvItemArnDetail>() |
| | | // .Where(it => it.ParentGuid == inventory.Guid |
| | | // && it.ItemId == itemBarcodeDetails.ItemId |
| | | // && it.EbelnLine == itemBarcodeDetails.WorkLine |
| | | // && it.Ebeln == itemBarcodeDetails.WorkNo) |
| | | // .First(); |
| | | |
| | | var inventoryDetails = Db.Queryable<MesInvItemArnDetail>() |
| | | .Where(it => it.ParentGuid == inventory.Guid |
| | | && it.ItemId == itemBarcodeDetails.ItemId |
| | | && it.EbelnLine == itemBarcodeDetails.WorkLine |
| | | && it.Ebeln == itemBarcodeDetails.WorkNo) |
| | | .Where(it => it.Guid == itemBarcodeDetails.AboutGuid) |
| | | .First(); |
| | | |
| | | if (inventoryDetails == null) |
| | |
| | | mesDepost = Db.Queryable<MesDepots>() |
| | | .Where(s => s.DepotId.ToString() == depotCode2).First(); |
| | | |
| | | if (depotCode != mesDepost.Guid) |
| | | throw new Exception("扫描库位与采购入库库位不一致!"); |
| | | // if (depotCode != mesDepost.Guid) |
| | | // throw new Exception("扫描库位与采购入库库位不一致!"); |
| | | } |
| | | else |
| | | { |
| | |
| | | throw new Exception("入库失败,到货单据有问题!"); |
| | | } |
| | | |
| | | PurchaseInventory result = new PurchaseInventory(); |
| | | var result = new PurchaseInventory(); |
| | | |
| | | UseTransaction(db => |
| | | { |
| | | var existingRecord = db.Queryable<MesInvItemIns>() |
| | | .Where(it => it.InsDate.Value.Date == DateTime.Now.Date |
| | | .Where(it => it.InsDate.Value.ToString("yyyy-MM-dd") == DateTime.Now.ToString("yyyy-MM-dd") |
| | | && it.Status == 0 |
| | | && it.TransctionNo == transactionNo |
| | | && it.BillNo == itemBarcodeDetails.BillNo |
| | |
| | | }) |
| | | .First(); |
| | | |
| | | Guid cId = Guid.Empty; |
| | | var cId = Guid.Empty; |
| | | string cBillNo = null; |
| | | |
| | | if (existingRecord != null) |
| | |
| | | LastupdateBy = user, |
| | | LastupdateDate = DateTime.Now, |
| | | UrgentFlag = itemBarcodeDetails.UrgentFlag.Value |
| | | ? (byte)1 |
| | | : (byte)0, |
| | | ? "1" |
| | | : "0", |
| | | CbillNo = itemBarcodeDetails.BillNo, |
| | | Fstatus = 0, |
| | | Status = 0 |
| | | Status = 0, |
| | | ReceiveOrgId = inventory.ReceiveOrgId |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | } |
| | | |
| | |
| | | IsdepsIn = true |
| | | }) |
| | | .Where(d => d.Guid == detail.Guid) |
| | | .IgnoreColumns(ignoreAllNullColumns: true) |
| | | .IgnoreColumns(true) |
| | | .ExecuteCommand(); |
| | | |
| | | // Check if already inserted |
| | |
| | | cSyQty -= remainingQty.Value; |
| | | |
| | | if (count == 0) |
| | | { |
| | | // Insert new item into MES_INV_ITEM_IN_C_ITEMS |
| | | db.Insertable(new MesInvItemInCItems |
| | | { |
| | |
| | | DepotCode = mesDepost.DepotCode, |
| | | ItemSname = itemBarcodeDetails.ItemSname, |
| | | Unit = itemBarcodeDetails.Unit, |
| | | Ebeln = detail.WorkNo, |
| | | Ebeln = detail.Ebeln, |
| | | BillNo = cBillNo, |
| | | WorkNo = detail.WorkNo, |
| | | CbillNo = detail.CbillNo, |
| | |
| | | EbelnK3id = detail.EbelnK3id, |
| | | LineK3id = detail.LineK3id |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | db.Updateable<MesInvItemInCItems>() |
| | | .SetColumns(it => |
| | | it.Quantity == it.Quantity + remainingQty) |
| | |
| | | it.ItemId == detail.ItemId && |
| | | it.WorkNo == detail.WorkNo && |
| | | it.WorkLine == detail.WorkLine) |
| | | .IgnoreColumns(ignoreAllNullColumns: true) |
| | | .IgnoreColumns(true) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | // Insert new detail into MES_INV_ITEM_IN_C_DETAILS |
| | | db.Insertable(new MesInvItemInCDetails |
| | |
| | | TaskNo = detail.WorkNo, |
| | | EbelnK3id = detail.EbelnK3id, |
| | | LineK3id = detail.LineK3id, |
| | | ItemId = detail.ItemId |
| | | ItemId = detail.ItemId, |
| | | ReceiveOrgId = inventory.ReceiveOrgId |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | } |
| | | else |
| | |
| | | OkRkqty = (int)((d.OkRkqty ?? 0) + cSyQty) |
| | | }) |
| | | .Where(d => d.Guid == detail.Guid) |
| | | .IgnoreColumns(ignoreAllNullColumns: true) |
| | | .IgnoreColumns(true) |
| | | .ExecuteCommand(); |
| | | |
| | | var count = db.Queryable<MesInvItemInCItems>() |
| | |
| | | .Count(); |
| | | |
| | | if (count == 0) |
| | | { |
| | | db.Insertable(new MesInvItemInCItems |
| | | { |
| | | ItemInId = cId, |
| | |
| | | LineK3id = detail.LineK3id, |
| | | ItemId = detail.ItemId |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | db.Updateable<MesInvItemInCItems>() |
| | | .SetColumns(it => |
| | | it.Quantity == it.Quantity + cSyQty) |
| | |
| | | it.ItemId == detail.ItemId && |
| | | it.WorkNo == detail.WorkNo && |
| | | it.WorkLine == detail.WorkLine) |
| | | .IgnoreColumns(ignoreAllNullColumns: true) |
| | | .IgnoreColumns(true) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | db.Insertable(new MesInvItemInCDetails |
| | | { |
| | |
| | | TaskNo = detail.WorkNo, |
| | | EbelnK3id = detail.EbelnK3id, |
| | | LineK3id = detail.LineK3id, |
| | | ItemId = detail.ItemId |
| | | ItemId = detail.ItemId, |
| | | ReceiveOrgId = inventory.ReceiveOrgId |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | |
| | | cSyQty = 0; // Remaining quantity fulfilled |
| | |
| | | .Count(); |
| | | |
| | | if (existingCount == 0) |
| | | { |
| | | // 不存在时插入新记录 |
| | | db.Insertable(new MesInvItemInCItems |
| | | { |
| | |
| | | LineK3id = itemBarcodeDetails.LineK3id, |
| | | ItemId = itemBarcodeDetails.ItemId |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | // 存在时更新数量 |
| | | db.Updateable<MesInvItemInCItems>() |
| | | .SetColumns(it => |
| | |
| | | it.ItemId == itemBarcodeDetails.ItemId && |
| | | it.WorkNo == itemBarcodeDetails.WorkNo && |
| | | it.WorkLine == itemBarcodeDetails.WorkLine) |
| | | .IgnoreColumns(ignoreAllNullColumns: true) |
| | | .IgnoreColumns(true) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | // 插入 mes_inv_item_in_c_details 表 |
| | | db.Insertable(new MesInvItemInCDetails |
| | |
| | | Ischeck = true, |
| | | CheckDate = inventoryDetails.CheckDate, |
| | | CheckRes = inventoryDetails.CheckRes, |
| | | CheckStates = inventoryDetails.CheckStates |
| | | CheckStates = inventoryDetails.CheckStates, |
| | | ReceiveOrgId = inventory.ReceiveOrgId |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | |
| | | // 插入 mes_inv_business2 表 |
| | |
| | | EbelnK3id = itemBarcodeDetails.EbelnK3id, |
| | | LineK3id = itemBarcodeDetails.LineK3id, |
| | | ItemId = itemBarcodeDetails.ItemId, |
| | | BillNo = itemBarcodeDetails.BillNo |
| | | BillNo = itemBarcodeDetails.BillNo, |
| | | DepotId = Convert.ToInt32(depotCode2) |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | |
| | | itemBarcodeDetails.Hbdy ??= 0; |
| | |
| | | var TotalOkRkQty = first.TotalOkRkQty ?? 0; |
| | | |
| | | if (TotalQuantity == TotalOkRkQty) |
| | | { |
| | | db.Updateable<MesInvItemArnDetail>() |
| | | .SetColumns(s => s.IsdepsIn == true) |
| | | .Where(s => s.Guid == inventoryDetails.Guid) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | |
| | | var totalSummary = db.Queryable<MesInvItemArnDetail>() |
| | |
| | | |
| | | if ((totalSummary.TotalQuantity ?? 0) == |
| | | (totalSummary.TotalOkRkQty ?? 0)) |
| | | { |
| | | db.Updateable<MesInvItemArn>() |
| | | .SetColumns(it => it.Status == 1) |
| | | .Where(it => it.BillNo == itemBarcodeDetails.BillNo) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | var totalCDetailsQuantity = db.Queryable<MesInvItemInCDetails>() |
| | | .Where(it => it.WorkLine == itemBarcodeDetails.WorkLine && |
| | |
| | | var diffQty = comeQty - invQty; |
| | | |
| | | if (detailSummary == null) |
| | | { |
| | | throw new Exception("此条码找不到对应收货单明细!"); |
| | | } |
| | | |
| | | var mesItems = db.Queryable<MesItems>() |
| | | .Where(s => s.Id == itemBarcodeDetails.ItemId).First(); |
| | |
| | | |
| | | if ((totalSummary.TotalQuantity ?? 0) == |
| | | (totalSummary.TotalOkRkQty ?? 0)) |
| | | { |
| | | db.Updateable<MesInvItemArn>() |
| | | .SetColumns(it => it.Status == 1) |
| | | .Where(it => it.BillNo == itemBarcodeDetails.BillNo) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | // Step 2: Calculate total sum from `mes_inv_item_in_c_details` |
| | | var totalCDetailsQuantity = db.Queryable<MesInvItemInCDetails>() |
| | |
| | | .First(); |
| | | |
| | | if (detailSummary == null) |
| | | { |
| | | throw new Exception("此条码找不到对应收货单明细!"); |
| | | } |
| | | |
| | | var comeQty = detailSummary.TotalComeQty ?? 0; |
| | | var invQty = detailSummary.TotalInvQty ?? 0; |
| | |
| | | var parsedGuid = Guid.Empty; |
| | | if (!string.IsNullOrEmpty(query.id)) |
| | | { |
| | | bool isValid = Guid.TryParse(query.id, out parsedGuid); |
| | | var isValid = Guid.TryParse(query.id, out parsedGuid); |
| | | if (!isValid) |
| | | throw new ApplicationException("GUID转换错误"); |
| | | } |
| | |
| | | { |
| | | //string转guid |
| | | var parsedGuid = Guid.Empty; |
| | | if (string.IsNullOrEmpty(pid)) |
| | | { |
| | | return ( []); |
| | | } |
| | | if (string.IsNullOrEmpty(pid)) return []; |
| | | |
| | | bool isValid = Guid.TryParse(pid, out parsedGuid); |
| | | var isValid = Guid.TryParse(pid, out parsedGuid); |
| | | if (!isValid) |
| | | throw new ApplicationException("GUID转换错误"); |
| | | |
| | |
| | | ItemNo = c.ItemNo, |
| | | ItemSname = g.ItemSname, |
| | | Quantity = g.Quantity, |
| | | Unit = d.Fname, |
| | | Unit = d.Fname |
| | | }) |
| | | .ToList(); |
| | | |
| | |
| | | { |
| | | //string转guid |
| | | var parsedGuid = Guid.Empty; |
| | | if (string.IsNullOrEmpty(pid)) |
| | | { |
| | | return ( []); |
| | | } |
| | | if (string.IsNullOrEmpty(pid)) return []; |
| | | |
| | | bool isValid = Guid.TryParse(pid, out parsedGuid); |
| | | var isValid = Guid.TryParse(pid, out parsedGuid); |
| | | if (!isValid) |
| | | throw new ApplicationException("GUID转换错误"); |
| | | |
| | |
| | | (g, c, d) => new JoinQueryInfos( |
| | | JoinType.Left, |
| | | g.ItemId == c.Id, JoinType.Inner, |
| | | d.Id.ToString() == c.Fpurchaseunitid |
| | | d.Id.ToString() == c.Fpurchaseunitid |
| | | ) |
| | | ).WhereIF(UtilityHelper.CheckGuid(parsedGuid), |
| | | (g, c, d) => g.ItemInId == parsedGuid) |
| | |
| | | .SetColumns(x => x.Status == entity.status) |
| | | .SetColumns(x => x.InsDate == entity.date) |
| | | .Where(x => x.BillNo == entity.billNo) |
| | | .IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand() > 0; |
| | | .IgnoreColumns(true).ExecuteCommand() > 0; |
| | | } |
| | | |
| | | private string GetErpParameters(string? billNo) |
| | |
| | | MesInvItemArnDetail>( |
| | | (g, c, d, a) => new JoinQueryInfos( |
| | | JoinType.Left, |
| | | g.ItemId == c.Id , JoinType.Inner, |
| | | g.ItemId == c.Id, JoinType.Inner, |
| | | d.Id.ToString() == c.Fpurchaseunitid, |
| | | JoinType.Inner, a.Ebeln == g.WorkNo && g.CbillNo == a.CbillNo |
| | | ) |
| | |
| | | |
| | | var jsonEntries = materials.Select(d => new |
| | | { |
| | | FMaterialId = d.FMaterialId, |
| | | FRealQty = d.FRealQty, |
| | | FStockId = d.FStockId, |
| | | FLot = d.FLot, |
| | | d.FMaterialId, |
| | | d.FRealQty, |
| | | d.FStockId, |
| | | d.FLot, |
| | | FUintId = d.FUnitID, |
| | | FSRCENTRYID = d.FsrcEntryId, |
| | | F_MES_ENTRYID = d.FMesEntryid |