| | |
| | | return dto; |
| | | } |
| | | |
| | | public string ScanInDepotsQT(WarehouseQuery query) |
| | | public dynamic ScanInDepotsQT(WarehouseQuery query) |
| | | { |
| | | var sectionCode = query.sectionCode; |
| | | var billNo = query.billNo; |
| | |
| | | // 1. 验证库位条码是否为空 |
| | | if (string.IsNullOrEmpty(sectionCode)) throw new Exception("请扫库位条码!"); |
| | | |
| | | // 2. 查询库位对应的仓库编码 |
| | | var depotId = Db.Queryable<MesDepotSections, MesDepots>( |
| | | (a, b) => new JoinQueryInfos( |
| | | JoinType.Inner, a.DepotGuid == b.Guid)) |
| | | .Where((a, b) => a.DepotSectionCode == sectionCode) |
| | | .Select((a, b) => b.DepotId) |
| | | .First(); |
| | | var sqlParams = new List<SugarParameter> { new("@sectionCode", sectionCode) }; |
| | | |
| | | if (depotId == null) |
| | | var sql2 = @" SELECT TOP 1 b.depot_code, |
| | | b.depot_id, |
| | | B.FSubsidiary, |
| | | B.depot_name |
| | | FROM MES_DEPOT_SECTIONS a |
| | | INNER JOIN |
| | | MES_DEPOTS b ON a.depot_guid = b.Guid |
| | | WHERE a.depot_section_code = @sectionCode;"; |
| | | |
| | | var depotInfo = Db.Ado.SqlQuery<dynamic>(sql2, sqlParams).First(); |
| | | |
| | | if (depotInfo is null) |
| | | throw new Exception($"库位编码 {sectionCode} 不存在,请确认!"); |
| | | |
| | | // 3. 查询申请单对应的仓库 |
| | | var qtrk = Db.Queryable<MesItemQtrk>() |
| | | .Where(x => x.Qtck == billNo) |
| | | .Select(x => x.Qt008) |
| | | .First(); |
| | | |
| | | if (qtrk == null) throw new Exception($"库位编码 {sectionCode} 不存在,请确认!"); |
| | | |
| | | // 4. 验证库位是否属于申请仓库 |
| | | if (depotId != Convert.ToInt32(qtrk)) |
| | | throw new Exception($"扫码库位 {sectionCode} 不属于申请仓库!"); |
| | | |
| | | // 5. 返回成功信息 |
| | | return $"仓库:{qtrk} 库位:{sectionCode}"; |
| | | return depotInfo; |
| | | } |
| | | |
| | | public (WarehouseQuery form, List<MesItemQtrrDetail> item) |
| | |
| | | |
| | | var c_depot_code = depotInfo.DepotCode; |
| | | var c_depot_id = depotInfo.DepotId; |
| | | |
| | | var sqlParams = new List<SugarParameter> { new("@barcode", p_item_barcode), new("@billNo", p_bill_no) }; |
| | | |
| | | var sql1 = @" SELECT TOP 1 A.rkCkId |
| | | FROM MES_QA_ITEMS_DETECT_01 A |
| | | LEFT JOIN MES_INV_ITEM_BARCODES B ON A.item_id = B.ITEM_ID |
| | | WHERE order_type = '其它入库检' |
| | | AND A.lot_no = @billNo |
| | | AND ITEM_BARCODE = @barcode "; |
| | | |
| | | var appDepotInfo = Db.Ado.SqlQuery<dynamic>(sql1, sqlParams).First(); |
| | | |
| | | if(appDepotInfo.rkCkId != c_depot_id) |
| | | throw new Exception($"该 {p_section_code} 对应的仓库 与 检验判定的入库仓库不一致,请确认!"); |
| | | |
| | | |
| | | var mesDepost = Db.Queryable<MesDepots>() |
| | | .Where(s => s.DepotId == c_depot_id).First(); |
| | |
| | | |
| | | if (qtrk == null) throw new Exception("其他入库申请单不存在!"); |
| | | |
| | | // 验证库位是否属于申请仓库 |
| | | if (c_depot_id != Convert.ToInt32(qtrk.Qt008)) |
| | | throw new Exception($"扫码库位 {p_section_code} 不属于申请仓库!"); |
| | | //// 验证库位是否属于申请仓库 |
| | | //if (c_depot_id != Convert.ToInt32(qtrk.Qt008)) |
| | | // throw new Exception($"扫码库位 {p_section_code} 不属于申请仓库!"); |
| | | |
| | | // 6. 查询申请单明细 |
| | | var detail = Db.Queryable<MesItemQtrrDetail>() |