| | |
| | | } |
| | | |
| | | if (!UtilityHelper.CheckGuid(parsedGuid)) |
| | | { |
| | | throw new ApplicationException("更新错误,数据是不合法的"); |
| | | } |
| | | |
| | | var userName = entity.userName ?? "system"; |
| | | return Db.Updateable<MesInvItemOuts>() |
| | |
| | | message.Pid = newGuid; |
| | | var executeReturnIdentity = |
| | | Db.Insertable(message).IgnoreColumns(true).ExecuteCommand(); |
| | | if (executeReturnIdentity > 0) |
| | | { |
| | | return message; |
| | | } |
| | | if (executeReturnIdentity > 0) return message; |
| | | |
| | | throw new Exception("获取数据失败"); |
| | | } |
| | |
| | | |
| | | |
| | | var dto = new OutItemDto(); |
| | | dto.SumItem = GetItems(query); |
| | | //dto.SumItem = GetItems(query); |
| | | |
| | | var mesInvItemStocks = Db.Queryable<MesInvItemStocks>() |
| | | .Where(a => a.ItemBarcode == query.barcode).Single(); |
| | |
| | | FUnitID = d.Fnumber, |
| | | FLot = b.WorkNo, |
| | | F_MES_ENTRYID = b.Guid, |
| | | FsrcEntryId = e.Guid.ToString(), |
| | | FsrcEntryId = e.Guid.ToString() |
| | | }).ToList(); |
| | | |
| | | |
| | |
| | | |
| | | var jsonEntries = materials.Select(d => new |
| | | { |
| | | FMaterialId = d.FMaterialId, |
| | | FRMREALQTY = d.FRMREALQTY, |
| | | FStockId = d.FStockId, |
| | | FUnitID = d.FUnitID, |
| | | FLot = d.FLot, |
| | | d.FMaterialId, |
| | | d.FRMREALQTY, |
| | | d.FStockId, |
| | | d.FUnitID, |
| | | d.FLot, |
| | | F_MES_ENTRYID = d.F_MES_ENTRYID.ToString(), |
| | | FsrcEntryId = d.FsrcEntryId, |
| | | d.FsrcEntryId |
| | | }).ToList(); |
| | | var fdate = DateTime.Now.ToString("yyyy-MM-dd"); |
| | | var jsonString = JsonConvert.SerializeObject(jsonEntries); |
| | |
| | | |
| | | //调用存储过程 |
| | | var prcRfPdaBarcodeCgth = PrcRfPdaBarcodeCgth(query); |
| | | if (!prcRfPdaBarcodeCgth) |
| | | { |
| | | throw new Exception("执行失败"); |
| | | } |
| | | if (!prcRfPdaBarcodeCgth) throw new Exception("执行失败"); |
| | | |
| | | // 变量用于保存查询结果 |
| | | decimal? C_SQ_QTY = 0; |
| | |
| | | |
| | | var commit = UseTransaction(db => |
| | | { |
| | | if (string.IsNullOrEmpty(p_bill_no)) |
| | | { |
| | | throw new Exception("请选取单据号!"); |
| | | } |
| | | if (string.IsNullOrEmpty(p_bill_no)) throw new Exception("请选取单据号!"); |
| | | |
| | | // Retrieve mes_inv_item_outs |
| | | var c_mes_inv_item_outs = db.Queryable<MesInvItemOuts>() |
| | |
| | | .First(); |
| | | |
| | | if (c_mes_inv_item_outs == null) |
| | | { |
| | | throw new Exception("请选择或扫描正确的采购退货单!"); |
| | | } |
| | | |
| | | if (c_mes_inv_item_outs.Status == 0) |
| | | { |
| | | throw new Exception("采购退货申请单未审核!"); |
| | | } |
| | | |
| | | if (c_mes_inv_item_outs.Nflag == 1) |
| | | { |
| | | throw new Exception("采购退货单已完结推送ERP,不能操作!"); |
| | | } |
| | | |
| | | // Check for duplicate barcode scan |
| | | c_num = db.Queryable<MesInvItemOutCDetails>() |
| | |
| | | b.ItemOutId == c_mes_inv_item_outs.Guid) |
| | | .Count(); |
| | | |
| | | if (c_num > 0) |
| | | { |
| | | throw new Exception("此条码已采购退货扫码完成!"); |
| | | } |
| | | if (c_num > 0) throw new Exception("此条码已采购退货扫码完成!"); |
| | | |
| | | // Query item stock info |
| | | var c_mes_inv_item_stocks = db.Queryable<MesInvItemStocks>() |
| | |
| | | .First(); |
| | | |
| | | if (c_mes_inv_item_stocks == null) |
| | | { |
| | | throw new Exception($"库存中无此条码,请核对!{p_item_barcode}"); |
| | | } |
| | | |
| | | // Validate depot codes |
| | | if (c_mes_inv_item_outs.DepotCode != |
| | | c_mes_inv_item_stocks.DepotsCode) |
| | | { |
| | | throw new Exception( |
| | | $"此条码属于仓库 {c_mes_inv_item_stocks.DepotsCode} 与采购退货申请仓库 {c_mes_inv_item_outs.DepotCode} 不一致,请核对!"); |
| | | } |
| | | |
| | | C_STOCKNUM = c_mes_inv_item_stocks.Quantity.Value; |
| | | |
| | |
| | | var quantities = db.Queryable<MesInvItemOutItems, MesInvItemOuts>( |
| | | (s, d) => new object[] |
| | | { |
| | | JoinType.Left, s.ItemOutId == d.Guid, |
| | | JoinType.Left, s.ItemOutId == d.Guid |
| | | }) |
| | | .Where((s, d) => |
| | | d.ItemOutNo == p_bill_no && |
| | |
| | | .First(); |
| | | |
| | | if (quantities == null) |
| | | { |
| | | throw new Exception("采购退料单 '" + p_bill_no + "'未审核"); |
| | | } |
| | | |
| | | C_SQTY = quantities.TotalQuantity ?? 0; |
| | | C_OKQTY = quantities.CompletedQuantity ?? 0; |
| | |
| | | if (C_CQTY < C_STOCKNUM) return 1; |
| | | |
| | | // Handle barcode reduction |
| | | decimal p_number2 = C_STOCKNUM; |
| | | var p_number2 = C_STOCKNUM; |
| | | var itemOutItems = db.Queryable<MesInvItemOutItems>() |
| | | .Where(s => |
| | | s.ItemOutId == c_mes_inv_item_outs.Guid && |
| | |
| | | .First(); |
| | | |
| | | if (c_mes_inv_item_arn_detail == null) |
| | | { |
| | | throw new Exception("未找到采购退料来源单据"); |
| | | } |
| | | |
| | | if (CMI.Quantity - CMI.TlQty <= p_number2) |
| | | { |
| | |
| | | TaskNo = CMI.WorkNo, |
| | | ItemId = c_mes_inv_item_stocks.ItemId, |
| | | EbelnK3id = c_mes_inv_item_stocks.EbelnK3id, |
| | | LineK3id = c_mes_inv_item_stocks.LineK3id, |
| | | LineK3id = c_mes_inv_item_stocks.LineK3id |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | |
| | | if (p_number2 == 0) |
| | | { |
| | | db.Deleteable<MesInvItemStocks>() |
| | | .Where(s => s.Guid == c_mes_inv_item_outs.Guid) |
| | | .ExecuteCommand(); |
| | | } |
| | | } |
| | | else |
| | | { |
| | |
| | | SuppId = c_mes_inv_item_outs.SuppId.ToString(), |
| | | ItemId = c_mes_inv_item_stocks.ItemId, |
| | | EbelnK3id = c_mes_inv_item_stocks.EbelnK3id, |
| | | LineK3id = c_mes_inv_item_stocks.LineK3id, |
| | | LineK3id = c_mes_inv_item_stocks.LineK3id |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | p_number2 = 0; |
| | | } |
| | | } |
| | | |
| | | if (p_number2 > 0) |
| | | { |
| | | throw new Exception("物料数量将超采购退料申请单数量,无法出库"); |
| | | } |
| | | if (p_number2 > 0) throw new Exception("物料数量将超采购退料申请单数量,无法出库"); |
| | | |
| | | return 1; |
| | | }); |