| | |
| | | try |
| | | { |
| | | // 调用存储过程 |
| | | var parameters = new List<SqlParameter> |
| | | { |
| | | new SqlParameter("@c_user", query.userName), |
| | | new SqlParameter("@p_bill_no", query.billNo ?? string.Empty), |
| | | new SqlParameter("@p_item_barcode", query.barcode), |
| | | new SqlParameter("@p_bl_no", query.blNo), |
| | | new SqlParameter("@p_type", query.Type), |
| | | new SqlParameter("@outMsg", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output }, |
| | | new SqlParameter("@outSum", SqlDbType.Int) { Direction = ParameterDirection.Output }, |
| | | new SqlParameter("@barcode_num", SqlDbType.Decimal) { Direction = ParameterDirection.Output }, |
| | | new SqlParameter("@split_num", SqlDbType.Decimal) { Direction = ParameterDirection.Output } |
| | | }; |
| | | var parameters = new SqlParameter[] |
| | | { |
| | | new SqlParameter("@C_USER", SqlDbType.NVarChar, 100) { Value = query.userName ?? string.Empty }, |
| | | new SqlParameter("@P_BILL_NO", SqlDbType.NVarChar, 50) { Value = query.billNo ?? string.Empty }, |
| | | new SqlParameter("@P_ITEM_BARCODE", SqlDbType.NVarChar, 100) { Value = query.barcode ?? string.Empty }, |
| | | new SqlParameter("@P_BL_NO", SqlDbType.NVarChar, 100) { Value = query.blNo ?? string.Empty }, |
| | | new SqlParameter("@P_TYPE", SqlDbType.NVarChar, 20) { Value = query.Type ?? string.Empty }, |
| | | new SqlParameter("@OUT_MSG", SqlDbType.NVarChar, 2000) { Direction = ParameterDirection.Output }, |
| | | new SqlParameter("@OUT_SUM", SqlDbType.Int) { Direction = ParameterDirection.Output }, |
| | | new SqlParameter("@BARCODE_NUM", SqlDbType.Decimal) { |
| | | Direction = ParameterDirection.Output, |
| | | Precision = 18, |
| | | Scale = 10 |
| | | }, |
| | | new SqlParameter("@SPLIT_NUM", SqlDbType.Decimal) { |
| | | Direction = ParameterDirection.Output, |
| | | Precision = 18, |
| | | Scale = 10 |
| | | } |
| | | }; |
| | | |
| | | // 执行存储过程 |
| | | Db.Ado.ExecuteCommand( |
| | | "EXEC PRC_PDA_SCBLCL @c_user, @p_bill_no, @p_item_barcode, @p_bl_no, @p_type, @outMsg OUTPUT, @outSum OUTPUT, @barcode_num OUTPUT, @split_num OUTPUT", |
| | | parameters.ToArray()); |
| | | string procedureName = "PRC_PDA_SCBLCL"; |
| | | int res = DbHelperSQL.RunProcedure_NonQuery(procedureName, parameters); |
| | | |
| | | // 获取输出参数 |
| | | outMsg = parameters[5].Value?.ToString() ?? ""; |
| | | outSum = Convert.ToInt32(parameters[6].Value); |
| | | barcodeNum = Convert.ToDecimal(parameters[7].Value); |
| | | splitNum = Convert.ToDecimal(parameters[8].Value); |
| | | outSum = parameters[6].Value as int? ?? 0; // 默认值根据需求调整 |
| | | barcodeNum = parameters[7].Value as decimal? ?? 0m; |
| | | splitNum = parameters[8].Value as decimal? ?? 0m; |
| | | |
| | | // 处理存储过程返回的结果 |
| | | if (outSum == 2) // 需要拆分 |
| | |
| | | public (bool success, List<MesItemBlDetail> pendingList) SplitBarcode( |
| | | WarehouseQuery query) |
| | | { |
| | | |
| | | // Validate input parameters |
| | | if (string.IsNullOrEmpty(query.userName)) |
| | | throw new Exception("用户名不能为空!"); |
| | | |
| | | if (string.IsNullOrEmpty(query.billNo)) |
| | | throw new Exception("请选取单据号!"); |
| | | |
| | | if (string.IsNullOrEmpty(query.barcode)) |
| | | throw new Exception("请扫描条码!"); |
| | | |
| | | if ((query.Num ?? 0) <= 0) |
| | | throw new Exception("请输入正确的发料数量!"); |
| | | |
| | | if (string.IsNullOrEmpty(query.blNo)) |
| | | throw new Exception("补料单号不能为空!"); |
| | | |
| | | // Prepare parameters for the stored procedure |
| | | var parameters = new List<SugarParameter> |
| | | { |
| | | new SugarParameter("@C_USER", query.userName), |
| | | new SugarParameter("@P_BILL_NO", query.billNo), |
| | | new SugarParameter("@P_ITEM_BARCODE", query.barcode), |
| | | new SugarParameter("@P_BL_NO", query.blNo), |
| | | new SugarParameter("@P_TYPE", query.Type), |
| | | new SugarParameter("@NUM", query.Num), |
| | | new SugarParameter("@OUT_MSG", "", System.Data.DbType.String, ParameterDirection.Output), |
| | | new SugarParameter("@OUT_SUM", 0, System.Data.DbType.Int32, ParameterDirection.Output), |
| | | new SugarParameter("@OUT_CF_BAR", "", System.Data.DbType.String, ParameterDirection.Output) |
| | | }; |
| | | |
| | | // Execute the stored procedure |
| | | Db.Ado.UseStoredProcedure().ExecuteCommand("PRC_PDA_SCBLCL_CF", parameters); |
| | | |
| | | // Get output parameters |
| | | var outMsg = parameters.FirstOrDefault(p => p.ParameterName == "@OUT_MSG")?.Value?.ToString(); |
| | | var outSum = Convert.ToInt32(parameters.FirstOrDefault(p => p.ParameterName == "@OUT_SUM")?.Value ?? -1); |
| | | var outCfBar = parameters.FirstOrDefault(p => p.ParameterName == "@OUT_CF_BAR")?.Value?.ToString(); |
| | | |
| | | // Handle the result |
| | | if (outSum == -1) |
| | | { |
| | | throw new Exception(outMsg ?? "操作失败"); |
| | | } |
| | | |
| | | if (outSum == 2) |
| | | { |
| | | // Handle case where barcode needs to be split |
| | | // You might want to return the new barcode to the client |
| | | } |
| | | |
| | | // Get pending list for the supplement order |
| | | var pendingList = Db.Queryable<MesItemBl, MesItemBlDetail>((a, b) => |
| | | new JoinQueryInfos(JoinType.Left, a.Id == b.Mid)) |
| | | .Where((a, b) => a.BlNo == query.blNo |
| | | && (b.Bld007 ?? 0) - (b.Bld008 ?? 0) > 0) |
| | | .Select((a, b) => new MesItemBlDetail |
| | | { |
| | | Bld012 = b.Bld012, |
| | | Bld002 = b.Bld002, |
| | | Bld003 = b.Bld003, |
| | | Bld004 = b.Bld004, |
| | | Bld007 = b.Bld007, |
| | | Bld008 = b.Bld008 |
| | | }) |
| | | .ToList(); |
| | | |
| | | return (outSum == 1, pendingList); |
| | | |
| | | //if (string.IsNullOrEmpty(query.userName)) |
| | | // throw new Exception("用户名不能为空!"); |
| | | |