| | |
| | | } |
| | | } |
| | | |
| | | //一键调拨拆分 |
| | | public ProductionPickDto ScanYjdbCF(WarehouseQuery query) |
| | | { |
| | | // 安全获取dynamic属性值,避免空引用异常 |
| | | var p_bill_no = query.daa001?.ToString() ?? string.Empty; |
| | | var p_item_barcode = query.barcode?.ToString() ?? string.Empty; |
| | | var p_kw = query.sectionCode?.ToString() ?? string.Empty; |
| | | var c_user = query.userName?.ToString() ?? string.Empty; |
| | | |
| | | // 验证单据号 |
| | | if (string.IsNullOrEmpty(p_bill_no)) throw new Exception("请选取单据号!"); |
| | | // 验证条码 |
| | | if (string.IsNullOrEmpty(p_item_barcode)) throw new Exception("请扫描条码!"); |
| | | // 验证库位 |
| | | if (string.IsNullOrEmpty(p_kw)) throw new Exception("请选择库位!"); |
| | | // 验证用户名 |
| | | if (string.IsNullOrEmpty(c_user)) throw new Exception("用户名不能为空!"); |
| | | |
| | | // 查询出库单并验证状态 |
| | | var transferOut = Db.Queryable<MesDbck>() |
| | | .Where(x => x.FBillNo == p_bill_no && x.FApproveStatus == 1) |
| | | .First(); |
| | | if (transferOut == null) throw new Exception("未找到调拨申请单或者调拨申请单没审核"); |
| | | |
| | | // 查询条码库存信息并验证 |
| | | var stock = Db.Queryable<MesInvItemStocks>() |
| | | .Where(x => x.ItemBarcode == p_item_barcode |
| | | && x.Quantity > 0) |
| | | .First(); |
| | | if (stock == null) throw new Exception($"库存中无此条码,请核对!{p_item_barcode}"); |
| | | |
| | | // 查询物料信息 |
| | | var item = Db.Queryable<MesItems>() |
| | | .Where(x => x.Id == stock.ItemId) |
| | | .First(); |
| | | if (item == null) throw new Exception("未找到物料"); |
| | | |
| | | var _strMsg = ""; |
| | | var _intSum = ""; |
| | | var _cfBar = ""; |
| | | |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[prc_pda_YJDB_CF]", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@outMsg", SqlDbType.NVarChar, 2000), |
| | | new("@outSum", SqlDbType.NVarChar, 300), |
| | | new("@outCfBar", SqlDbType.NVarChar, 300), |
| | | new("@c_User", c_user), |
| | | new("@p_biLL_no", p_bill_no), |
| | | new("@p_item_barcode", p_item_barcode), |
| | | new("@num", query.Num), |
| | | new("@p_kw", p_kw) |
| | | }; |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | parameters[2].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | _strMsg = parameters[0].Value.ToString(); |
| | | _intSum = parameters[1].Value.ToString(); |
| | | _cfBar = parameters[2].Value.ToString(); |
| | | |
| | | |
| | | var result = Convert.ToInt32(_intSum); |
| | | if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | | var dto = new ProductionPickDto |
| | | { |
| | | daa001 = query.daa001, |
| | | barcode = query.barcode,//原条码 |
| | | cfBarcode = _cfBar//拆分后条码 |
| | | }; |
| | | |
| | | return dto; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |