| | |
| | | try |
| | | { |
| | | List<dynamic>? blDetails = Db.Ado.SqlQuery<dynamic>( |
| | | "EXEC prc_pda_wwll_detailList @daa001,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters); |
| | | "EXEC prc_pda_wwcksq_detailList @daa001,@pi_orgId,@inP1,@inP2,@inP3,@inP4", parameters); |
| | | var items = blDetails.Where(x => x.DSQty > 0).ToList(); // 待扫物料 |
| | | var ysitems = blDetails.Where(x => x.SQty > 0).ToList(); // 已扫物料 |
| | | var planNo = blDetails.FirstOrDefault()?.ErpProductionOrderNo?.ToString();// 获取工单计划号 |
| | |
| | | daa001 = query.daa001, |
| | | PlanNo = planNo, |
| | | items = items, |
| | | ysitems = ysitems |
| | | ysitems = ysitems, |
| | | allList = blDetails |
| | | }; |
| | | } |
| | | catch (Exception ex) |
| | |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// w委外出库 |
| | | /// </summary> |
| | | /// <param name="query"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public ProductionPickDto WwckScanCode(WarehouseQuery query) |
| | | { |
| | | var _strMsg = ""; |
| | | var _intSum = ""; |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | if (query.userName.IsNullOrEmpty()) throw new Exception("用户名不允许为空"); |
| | | if (query.daa001.IsNullOrEmpty()) throw new Exception("领料单号不允许为空"); |
| | | if (query.barcode.IsNullOrEmpty()) throw new Exception("条码不允许为空"); |
| | | |
| | | using (var cmd = new SqlCommand("[PRC_PDA_WWCK_SCAN]", conn)) |
| | | { |
| | | try |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | //SqlParameter[] parameters = |
| | | //{ |
| | | // new("@outMsg", SqlDbType.NVarChar, 300), |
| | | // new("@outSum", SqlDbType.NVarChar, 300), |
| | | // new("@barcode_num", SqlDbType.NVarChar, 300), |
| | | // new("@split_num", SqlDbType.NVarChar, 300), |
| | | // new("@c_User", query.userName), |
| | | // new("@p_biLL_no", query.daa001), |
| | | // new("@p_item_barcode", query.barcode) |
| | | //}; |
| | | |
| | | 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 |
| | | } |
| | | }; |
| | | |
| | | parameters[5].Direction = ParameterDirection.Output; |
| | | parameters[6].Direction = ParameterDirection.Output; |
| | | parameters[7].Direction = ParameterDirection.Output; |
| | | parameters[8].Direction = ParameterDirection.Output; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | cmd.ExecuteNonQuery(); |
| | | _strMsg = parameters[5].Value.ToString(); |
| | | _intSum = parameters[6].Value.ToString(); |
| | | |
| | | var barcodeNum = parameters[7].Value.ToString(); |
| | | var splitNum = parameters[8].Value.ToString(); |
| | | |
| | | var result = Convert.ToInt32(_intSum); |
| | | if (result <= 0) throw new Exception(_strMsg); |
| | | |
| | | var dto = new ProductionPickDto |
| | | { |
| | | daa001 = query.daa001, |
| | | barcodeNum = barcodeNum, |
| | | splitNum = splitNum, |
| | | barcode = query.barcode, |
| | | strMsg = _strMsg, |
| | | result = _intSum |
| | | }; |
| | | |
| | | return dto; |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw new Exception(ex.Message); |
| | | } |
| | | finally |
| | | { |
| | | conn.Close(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 委外拆分出库拆分 |
| | | /// </summary> |
| | | /// <param name="query"></param> |
| | | /// <returns></returns> |
| | | /// <exception cref="Exception"></exception> |
| | | public ProductionPickDto WwckScanCodeCF(WarehouseQuery query) |
| | | { |
| | | // Validate input parameters |
| | | if (string.IsNullOrEmpty(query.userName)) |
| | | 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_WWCK_SCAN_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 ?? "操作失败"); |
| | | } |
| | | |
| | | |
| | | var dto = new ProductionPickDto |
| | | { |
| | | daa001 = query.billNo, |
| | | barcode = query.barcode,//原条码 |
| | | cfBarcode = outCfBar//拆分后条码 |
| | | }; |
| | | |
| | | return dto; |
| | | } |
| | | |
| | | #region 委外退料 |
| | | |
| | | /// <summary> |