| | |
| | | |
| | | public ItemInBaseModel SaveBarCodes(WarehouseQuery entity) |
| | | { |
| | | // 参数验证 |
| | | if (entity == null) |
| | | throw new ArgumentNullException(nameof(entity), "参数对象不能为空"); |
| | | |
| | | if (string.IsNullOrEmpty(entity.userName)) |
| | | throw new ArgumentException("用户名不能为空", nameof(entity.userName)); |
| | | |
| | | if (string.IsNullOrEmpty(entity.barcode)) |
| | | throw new ArgumentException("条码不能为空", nameof(entity.barcode)); |
| | | |
| | | string functionName = "采购入库", fieldName = null, inFieldVal = null; |
| | | string user = entity.userName, |
| | | sectionCode = entity.sectionCode, |
| | |
| | | if (string.IsNullOrEmpty(sectionCode)) |
| | | throw new Exception("请扫库位条码!"); |
| | | |
| | | var itemBarcodeDetails = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(it => it.ItemBarcode == itemBarcode) |
| | | .First(); |
| | | |
| | | if (itemBarcodeDetails == null) |
| | | MesInvItemBarcodes itemBarcodeDetails; |
| | | try |
| | | { |
| | | itemBarcodeDetails = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(it => it.ItemBarcode == itemBarcode) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception("条码不存在,请核对!"); |
| | | } |
| | | |
| | | if (string.IsNullOrEmpty(itemBarcodeDetails.Memo) || itemBarcodeDetails.Memo != "采购入库") |
| | | throw new Exception("此条码不属于到货条码,无法用采购入库!"); |
| | | |
| | | var inventory = Db.Queryable<MesInvItemArn>() |
| | | .Where(it => it.BillNo == itemBarcodeDetails.BillNo && it.Fstatus == true ) |
| | | .First(); |
| | | |
| | | if (inventory == null) |
| | | MesInvItemArn inventory; |
| | | try |
| | | { |
| | | inventory = Db.Queryable<MesInvItemArn>() |
| | | .Where(it => it.BillNo == itemBarcodeDetails.BillNo && it.Fstatus == true ) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception("此条码找不到对应收货单或未审核!"); |
| | | } |
| | | |
| | | // var inventoryDetails = Db.Queryable<MesInvItemArnDetail>() |
| | | // .Where(it => it.ParentGuid == inventory.Guid |
| | |
| | | // && it.Ebeln == itemBarcodeDetails.WorkNo) |
| | | // .First(); |
| | | |
| | | var inventoryDetails = Db.Queryable<MesInvItemArnDetail>() |
| | | .Where(it => it.Guid == itemBarcodeDetails.AboutGuid) |
| | | .First(); |
| | | |
| | | var cgddDetails = Db.Queryable<MesRohInData>() |
| | | .Where(it => it.EbelnK3id == inventoryDetails.LineK3id) |
| | | .First(); |
| | | |
| | | if (cgddDetails == null) |
| | | throw new Exception("此条码找不到对应采购订单明细!"); |
| | | |
| | | if (inventoryDetails == null) |
| | | MesInvItemArnDetail inventoryDetails; |
| | | try |
| | | { |
| | | inventoryDetails = Db.Queryable<MesInvItemArnDetail>() |
| | | .Where(it => it.Guid == itemBarcodeDetails.AboutGuid) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception("此条码找不到对应收货单明细!"); |
| | | } |
| | | |
| | | MesRohInData cgddDetails; |
| | | try |
| | | { |
| | | cgddDetails = Db.Queryable<MesRohInData>() |
| | | .Where(it => it.EbelnK3id == inventoryDetails.LineK3id) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception("此条码找不到对应采购订单明细!"); |
| | | } |
| | | |
| | | //获取到货检验明细 |
| | | var sqlParams = new List<SugarParameter> { new("@dhmxGuid", itemBarcodeDetails.AboutGuid) }; |
| | | var sql1 = @"SELECT *FROM v_dhmx WHERE dhmxGuid = @dhmxGuid "; |
| | | var dhjymx = Db.Ado.SqlQuery<vDhmx>(sql1, sqlParams).First(); |
| | | vDhmx dhjymx; |
| | | try |
| | | { |
| | | dhjymx = Db.Ado.SqlQuery<vDhmx>(sql1, sqlParams).First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception("该条码找不到对应的检验明细!"); |
| | | } |
| | | |
| | | //判定检验能否入库 |
| | | if (dhjymx.CanStore!= 1) |
| | | { |
| | | throw new Exception($"该条码对应的收料单检验结果:【{dhjymx.InspectionResult}】,判定结果:【{dhjymx.JudgmentResult}】,处理意见:【{dhjymx.HandlingSuggestion}】,无法入库"); |
| | | } |
| | | |
| | | var depotCode = Db.Queryable<MesDepotSections>() |
| | | .Where(it => it.DepotSectionCode == sectionCode) |
| | | .Select(it => it.DepotGuid) |
| | | .First(); |
| | | |
| | | var depotCode2 = Db.Queryable<MesInvItemArn>() |
| | | .Where(it => it.BillNo == itemBarcodeDetails.BillNo) |
| | | .Select(it => it.DepotsId) |
| | | .First(); |
| | | string depotCode; |
| | | try |
| | | { |
| | | depotCode = Db.Queryable<MesDepotSections>() |
| | | .Where(it => it.DepotSectionCode == sectionCode) |
| | | .Select(it => it.DepotGuid) |
| | | .First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception("库位编码 " + sectionCode + " 不存在,请确认!"); |
| | | } |
| | | |
| | | MesDepots mesDepost = null; |
| | | |
| | | var checkGuid = UtilityHelper.CheckGuid(depotCode); |
| | | if (checkGuid && depotCode != null) |
| | | { |
| | | mesDepost = Db.Queryable<MesDepots>() |
| | | .Where(s => s.DepotId.ToString() == depotCode).First(); |
| | | try |
| | | { |
| | | mesDepost = Db.Queryable<MesDepots>() |
| | | .Where(s => s.Guid == depotCode).First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception("库位编码 " + sectionCode + " 对应的仓库不存在,请确认!"); |
| | | } |
| | | |
| | | // if (depotCode != mesDepost.Guid) |
| | | // throw new Exception("扫描库位与采购入库库位不一致!"); |
| | |
| | | billNo: "", // 根据实际单据号传值 |
| | | transactionNo: "101" // 事务类型与存储过程匹配 |
| | | ); |
| | | |
| | | if (checkResult == null) |
| | | throw new Exception("入库校验失败:返回结果为空"); |
| | | |
| | | if (Convert.ToInt32(checkResult.result) < 1) |
| | | throw new Exception($"入库校验失败:{checkResult.strMsg}"); |
| | |
| | | it.Guid, |
| | | it.BillNo |
| | | }) |
| | | .First(); |
| | | .ToList() |
| | | .FirstOrDefault(); |
| | | |
| | | var cId = Guid.Empty; |
| | | string cBillNo = null; |
| | |
| | | cId = Guid.NewGuid(); |
| | | cBillNo = BillNo.GetBillNo("CGRK(采购入库)"); |
| | | |
| | | var suppNo = db.Queryable<MesSupplier>() |
| | | .Where(s => s.Id.ToString() == inventory.SuppId).First(); |
| | | MesSupplier suppNo; |
| | | try |
| | | { |
| | | suppNo = db.Queryable<MesSupplier>() |
| | | .Where(s => s.Id.ToString() == inventory.SuppId).First(); |
| | | } |
| | | catch |
| | | { |
| | | throw new Exception("找不到对应的供应商信息!"); |
| | | } |
| | | |
| | | db.Insertable(new MesInvItemIns |
| | | { |
| | |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | } |
| | | |
| | | cSyQty = itemBarcodeDetails.Quantity.Value; |
| | | cSyQty = itemBarcodeDetails.Quantity ?? 0; |
| | | |
| | | if (cSyQty <= 0) |
| | | throw new Exception("条码数量无效,请检查条码信息!"); |
| | | |
| | | entity.id = cId.ToString(); |
| | | entity.PageIndex = 1; |