| | |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 根据用户选择的采购明细guid,读取需要作入库到货单的明细 |
| | | /// </summary> |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 读取列表,支持分页 |
| | | /// </summary> |
| | | /// <param name="model"></param> |
| | | /// <returns></returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<PageList<dynamic>> SelectMxForm([FromBody] dynamic model) |
| | | { |
| | | int currentPage = model.currentPage; |
| | | int everyPageSize = model.everyPageSize; |
| | | string sortName = model.sortName; |
| | | string keyWhere = model.keyWhere; |
| | | string inBusType = model.inBusType; |
| | | string inSupId = model.inSupId; |
| | | string inReceiveOrgId = model.inReceiveOrgId; |
| | | var dset = new DataSet(); |
| | | try |
| | | { |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[prc_cgdhdmx_select]", conn)) |
| | | { |
| | | conn.Open(); |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | SqlParameter[] parameters = |
| | | { |
| | | new("@inCurrentPage", currentPage), |
| | | new("@inEveryPageSize", everyPageSize), |
| | | new("@inSortName", sortName), |
| | | new("@inSortOrder", ""), |
| | | new("@inQueryWhere", keyWhere), |
| | | new("@inBusType", inBusType), |
| | | new("@inSupId", inSupId), |
| | | new("@inP1", inReceiveOrgId),//组织 |
| | | new("@inP2", "") |
| | | }; |
| | | foreach (var parameter in parameters) |
| | | cmd.Parameters.Add(parameter); |
| | | using (var dt = |
| | | new SqlDataAdapter(cmd)) |
| | | { |
| | | dt.Fill(dset, "0"); |
| | | } |
| | | } |
| | | conn.Close(); |
| | | } |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | LogHelper.Debug(ToString(), "GetListPage error:" + ex.Message); |
| | | return ReturnDto<PageList<dynamic>>.QuickReturn( |
| | | default(PageList<dynamic>), ReturnCode.Exception, "读取失败"); |
| | | } |
| | | |
| | | var _pglist = new PageList<dynamic> |
| | | { |
| | | total = 0, |
| | | everyPageSize = 0, |
| | | pages = 0, |
| | | list = new List<dynamic>() |
| | | }; |
| | | if (dset != null && dset.Tables.Count > 0 && |
| | | dset.Tables[0].Rows.Count > 0) //有数据 |
| | | { |
| | | var intTotal = |
| | | int.Parse(dset.Tables[1].Rows[0]["intTotal"].ToString()); |
| | | var pages = intTotal % everyPageSize != 0 |
| | | ? intTotal / everyPageSize + 1 |
| | | : intTotal / everyPageSize; |
| | | _pglist.total = intTotal; |
| | | _pglist.everyPageSize = everyPageSize; |
| | | _pglist.pages = pages; |
| | | var _dy = dset.Tables[0].TableToDynamicList(); |
| | | _pglist.list = _dy; |
| | | } |
| | | |
| | | return ReturnDto<PageList<dynamic>>.QuickReturn(_pglist, |
| | | ReturnCode.Success, "读取成功"); |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 处理勾选的采购到货明细数据(根据guid集合执行操作) |
| | | /// </summary> |
| | | /// <param name="model">包含勾选的guid列表(动态类型,适配前端传入格式)</param> |
| | | /// <returns>处理结果(符合项目ReturnDto<ExpandoObject>规范)</returns> |
| | | [RequestMethod(RequestMethods.POST)] |
| | | public ReturnDto<ExpandoObject> SelectMxBtn([FromBody] dynamic model) |
| | | { |
| | | // 初始化返回的动态结果对象 |
| | | dynamic result = new ExpandoObject(); |
| | | result.outSum = -1; // 默认失败状态 |
| | | result.outMsg = ""; |
| | | |
| | | try |
| | | { |
| | | // 1. 解析前端传入的guid集合 |
| | | List<string> guidList = new List<string>(); |
| | | if (model.guidList == null) |
| | | { |
| | | result.outMsg = "未传入guid集合"; |
| | | return ReturnDto<ExpandoObject>.QuickReturn(result, ReturnCode.Default, result.outMsg); |
| | | } |
| | | |
| | | foreach (var item in model.guidList) |
| | | { |
| | | string guid = item?.ToString()?.Trim(); |
| | | if (!string.IsNullOrEmpty(guid)) |
| | | { |
| | | guidList.Add(guid); |
| | | } |
| | | } |
| | | |
| | | // 2. 参数校验 |
| | | if (guidList.Count == 0) |
| | | { |
| | | result.outMsg = "未传入有效的guid数据"; |
| | | return ReturnDto<ExpandoObject>.QuickReturn(result, ReturnCode.Default, result.outMsg); |
| | | } |
| | | |
| | | // 3. 调用存储过程处理勾选数据 |
| | | using (var conn = new SqlConnection(DbHelperSQL.strConn)) |
| | | { |
| | | using (var cmd = new SqlCommand("[prc_cgdhdmx_handle_selected]", conn)) |
| | | { |
| | | cmd.CommandType = CommandType.StoredProcedure; |
| | | |
| | | // 处理guid集合:转为适配存储过程的格式// 直接拼接纯GUID,用|分隔(无单引号) |
| | | string guidStr = string.Join("|", guidList); |
| | | //string guidStr = string.Join("|", guidList.Select(g => $"'{g.Replace("'", "''")}'")); |
| | | |
| | | // 定义参数(与存储过程严格匹配,输出参数后续设置方向) |
| | | SqlParameter[] parameters = |
| | | { |
| | | new SqlParameter("@outMsg", SqlDbType.NVarChar, 2500), |
| | | new SqlParameter("@outSum", SqlDbType.Int), |
| | | new SqlParameter("@inEdtUserGuid", _userGuid), |
| | | new SqlParameter("@inGuidList", guidStr), |
| | | new SqlParameter("@in1", "") |
| | | }; |
| | | |
| | | // 设置输出参数方向 |
| | | parameters[0].Direction = ParameterDirection.Output; |
| | | parameters[1].Direction = ParameterDirection.Output; |
| | | |
| | | // 循环添加参数 |
| | | foreach (var parameter in parameters) |
| | | { |
| | | cmd.Parameters.Add(parameter); |
| | | } |
| | | |
| | | // 执行存储过程 |
| | | conn.Open(); |
| | | cmd.ExecuteNonQuery(); |
| | | |
| | | // 获取存储过程输出结果 |
| | | result.outSum = parameters[1].Value?.ToString(); |
| | | result.outMsg = parameters[0].Value?.ToString(); |
| | | } |
| | | } |
| | | |
| | | // 4. 返回最终结果 |
| | | return ReturnDto<ExpandoObject>.QuickReturn(result, ReturnCode.Success, result.outMsg); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | // 异常处理 |
| | | LogHelper.Debug(ToString(), "SelectMxBtn接口处理异常:" + ex.Message); |
| | | result.outMsg = "处理失败:" + ex.Message; |
| | | return ReturnDto<ExpandoObject>.QuickReturn(result, ReturnCode.Exception, result.outMsg); |
| | | } |
| | | } |
| | | |
| | | #endregion |
| | | |
| | | |