| | |
| | | public (bool success, List<MesItemBlDetail> pendingList) SplitBarcode( |
| | | WarehouseQuery query) |
| | | { |
| | | |
| | | // 输入参数验证(保持不变) |
| | | 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("补料单号不能为空!"); |
| | | |
| | | // 准备存储过程参数 |
| | | var outMsg = ""; |
| | | var outSum = -1; |
| | | var outCfBar = ""; |
| | | |
| | | try |
| | | { |
| | | // 调用存储过程 |
| | | 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", null, true), // 输出消息 |
| | | new SugarParameter("@OUT_SUM", null, true), // 执行结果(1成功,-1失败) |
| | | new SugarParameter("@OUT_CF_BAR", null, true) // 输出新条码编号 |
| | | }; |
| | | |
| | | // 执行存储过程 |
| | | Db.Ado.UseStoredProcedure().ExecuteCommand("PRC_PDA_SCBLCL_CF", parameters); |
| | | |
| | | // 获取输出参数 |
| | | outMsg = parameters.First(p => p.ParameterName == "@OUT_MSG").Value?.ToString(); |
| | | outSum = Convert.ToInt32(parameters.First(p => p.ParameterName == "@OUT_SUM").Value); |
| | | outCfBar = parameters.First(p => p.ParameterName == "@OUT_CF_BAR").Value?.ToString(); |
| | | |
| | | // 处理存储过程返回结果 |
| | | if (outSum != 1) |
| | | { |
| | | throw new Exception(outMsg ?? "操作失败"); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(outMsg ?? ex.Message); |
| | | } |
| | | |
| | | // 获取待发料明细列表(保持不变) |
| | | 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("用户名不能为空!"); |
| | | |