| | |
| | | return details; |
| | | } |
| | | |
| | | public String ScanInDepotsQT(WarehouseQuery query) |
| | | public string ScanInDepotsQT(WarehouseQuery query) |
| | | { |
| | | var sectionCode = query.sectionCode; |
| | | var billNo = query.billNo; |
| | | |
| | | // 1. 验证库位条码是否为空 |
| | | if (string.IsNullOrEmpty(sectionCode)) |
| | | { |
| | | throw new Exception("请扫库位条码!"); |
| | | } |
| | | if (string.IsNullOrEmpty(sectionCode)) throw new Exception("请扫库位条码!"); |
| | | |
| | | // 2. 查询库位对应的仓库编码 |
| | | var depotCode = Db.Queryable<MesDepotSections, MesDepots>( |
| | |
| | | .First(); |
| | | |
| | | if (depotCode == null) |
| | | { |
| | | throw new Exception($"库位编码 {sectionCode} 不存在,请确认!"); |
| | | } |
| | | |
| | | // 3. 查询申请单对应的仓库 |
| | | var qtrk = Db.Queryable<MesItemQtrk>() |
| | |
| | | .Select(x => x.Qt011) |
| | | .First(); |
| | | |
| | | if (qtrk == null) |
| | | { |
| | | throw new Exception($"库位编码 {sectionCode} 不存在,请确认!"); |
| | | } |
| | | if (qtrk == null) throw new Exception($"库位编码 {sectionCode} 不存在,请确认!"); |
| | | |
| | | // 4. 验证库位是否属于申请仓库 |
| | | if (depotCode != qtrk) |
| | | { |
| | | throw new Exception($"扫码库位 {sectionCode} 不属于申请此仓库!"); |
| | | } |
| | | |
| | | // 5. 返回成功信息 |
| | | return $"仓库:{qtrk} 库位:{sectionCode}"; |
| | |
| | | |
| | | // 1. 验证库位条码是否为空 |
| | | if (string.IsNullOrEmpty(p_section_code)) |
| | | { |
| | | throw new Exception("请扫库位条码!"); |
| | | } |
| | | |
| | | // 2. 查询库位对应的仓库编码和仓库ID |
| | | var depotInfo = Db.Queryable<MesDepotSections, MesDepots>( |
| | |
| | | .First(); |
| | | |
| | | if (depotInfo == null) |
| | | { |
| | | throw new Exception($"库位编码 {p_section_code} 不存在,请确认!"); |
| | | } |
| | | |
| | | var c_depot_code = depotInfo.DepotCode; |
| | | var c_depot_id = depotInfo.DepotId; |
| | |
| | | var existsInStock = Db.Queryable<MesInvItemInCDetails>() |
| | | .Any(x => x.ItemBarcode == p_item_barcode); |
| | | |
| | | if (existsInStock) |
| | | { |
| | | throw new Exception("此条码已扫码入库完成,请核对!"); |
| | | } |
| | | if (existsInStock) throw new Exception("此条码已扫码入库完成,请核对!"); |
| | | |
| | | // 4. 查询条码信息 |
| | | var barcode = Db.Queryable<MesInvItemBarcodes>() |
| | | .Where(x => x.ItemBarcode == p_item_barcode) |
| | | .First(); |
| | | |
| | | if (barcode == null) |
| | | { |
| | | throw new Exception("条码不存在,请核对!"); |
| | | } |
| | | if (barcode == null) throw new Exception("条码不存在,请核对!"); |
| | | |
| | | if (barcode.ComeFlg != 3) |
| | | { |
| | | throw new Exception("条码不是其他入库条码,无法用其他入库!"); |
| | | } |
| | | if (barcode.ComeFlg != 3) throw new Exception("条码不是其他入库条码,无法用其他入库!"); |
| | | |
| | | // 验证条码是否已在库存中 |
| | | var stockCount = Db.Queryable<MesInvItemStocks>() |
| | | .Where(x => x.ItemBarcode == p_item_barcode) |
| | | .Count(); |
| | | |
| | | if (stockCount > 0) |
| | | { |
| | | throw new Exception("此条码已扫码入库完成,请核对!"); |
| | | } |
| | | if (stockCount > 0) throw new Exception("此条码已扫码入库完成,请核对!"); |
| | | |
| | | // 5. 查询其他入库申请单 |
| | | var qtrk = Db.Queryable<MesItemQtrk>() |
| | | .Where(x => x.Qtck == p_bill_no) |
| | | .First(); |
| | | |
| | | if (qtrk == null) |
| | | { |
| | | throw new Exception("其他入库申请单不存在!"); |
| | | } |
| | | if (qtrk == null) throw new Exception("其他入库申请单不存在!"); |
| | | |
| | | // 6. 查询申请单明细 |
| | | var detail = Db.Queryable<MesItemQtrrDetail>() |
| | |
| | | .First(); |
| | | |
| | | if (detail == null) |
| | | { |
| | | throw new Exception($"其他入库申请单{p_bill_no}无此物料{barcode.ItemNo} 请核对!"); |
| | | } |
| | | |
| | | // 7. 验证数量 |
| | | if (barcode.Quantity > (detail.Qd007 ?? 0) - (detail.Qd008 ?? 0)) |
| | | { |
| | | throw new Exception("条码数量超过申请数量,请核对!"); |
| | | } |
| | | |
| | | var details = new List<MesItemQtrrDetail>(); |
| | | |
| | |
| | | .First(); |
| | | |
| | | if (existingItem == null) |
| | | { |
| | | // 不存在则新增入库明细 |
| | | res += db.Insertable(new MesInvItemInCItems |
| | | { |
| | |
| | | LineK3id = barcode.LineK3id, |
| | | ItemId = barcode.ItemId |
| | | }).IgnoreColumns(true).ExecuteCommand(); |
| | | } |
| | | else |
| | | { |
| | | // 存在则更新数量 |
| | | res += db.Updateable<MesInvItemInCItems>() |
| | | .SetColumns( |
| | |
| | | && x.WorkNo == barcode.WorkNo |
| | | && x.WorkLine == barcode.WorkLine) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | |
| | | // 插入入库明细记录 |
| | |
| | | SuppNo = barcode.SuppNo, |
| | | EbelnK3id = barcode.EbelnK3id, |
| | | LineK3id = barcode.LineK3id, |
| | | ItemId = barcode.ItemId, |
| | | ItemId = barcode.ItemId |
| | | // SalesOrder = barcode.SalesOrder, |
| | | // IsZy = barcode.IsZy, |
| | | // OuterBarcode = barcode.OuterBarcode |
| | |
| | | EbelnK3id = barcode.EbelnK3id, |
| | | LineK3id = barcode.LineK3id, |
| | | ItemId = barcode.ItemId, |
| | | BillNo = barcode.BillNo, |
| | | BillNo = barcode.BillNo |
| | | // SalesOrder = barcode.SalesOrder, |
| | | // IsZy = barcode.IsZy, |
| | | // Visable = 0, |
| | |
| | | .First(); |
| | | |
| | | if ((detail1.Qd007 ?? 0) - (detail1.Qd008 ?? 0) == barcode.Quantity) |
| | | { |
| | | res += db.Updateable<MesItemQtrrDetail>() |
| | | .SetColumns(x => x.Qd011 == 1) |
| | | .Where(x => x.Guid == detail1.Guid) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | details = Db.Queryable<MesItemQtrk, MesItemQtrrDetail, MesItems>( |
| | | (a, b, c) => new JoinQueryInfos( |
| | |
| | | .ToList(); |
| | | |
| | | if (CollectionUtil.IsNullOrEmpty(details)) |
| | | { |
| | | res += db.Updateable<MesItemQtrk>() |
| | | .SetColumns(s => s.Qt014 == 1) |
| | | .Where(x => x.Qtck == p_bill_no) |
| | | .ExecuteCommand(); |
| | | } |
| | | |
| | | if (res < 5) |
| | | { |
| | | throw new Exception("插入或更新失败"); |
| | | } |
| | | if (res < 5) throw new Exception("插入或更新失败"); |
| | | |
| | | return res; |
| | | }); |