1
yangle
2023-05-22 680b605296b299a426438579b8a271882521dc8a
WebAPI/Controllers/MateOutController.cs
@@ -1354,18 +1354,27 @@
                    "and (产品名称=''" + com.HProductName + "'' or ''" + com.HBillNo + "''='''') " +
                    "and (规格型号=''" + com.HProductModel + "'' or ''" + com.HProductModel + "''='''') " + com.RandomSearch;
                ds = oCN.RunProcReturn($"exec h_p_Kf_MaterOutSumReport_Cloth_New '{sql}','1' , ''" , "h_p_Kf_MaterOutSumReport_Cloth_New");
                DataTable dt = ds.Tables[0];
                ds = oCN.RunProcReturn($"exec h_p_Kf_MaterOutSumReport_Cloth_New '{sql}'" , "h_p_Kf_MaterOutSumReport_Cloth_New");
                //获取列名
                List<object> columnNameList = new List<object>();
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    int headLen = col.ColumnName.ToString().Length;        //列名的长度
                    int colLen = 0;
                    if (ds.Tables[1].Rows[0][col.ColumnName] != null)
                    {
                        string colLenStr=ds.Tables[1].Rows[0][col.ColumnName].ToString();
                        if(colLenStr != "")
                        {
                            colLen = int.Parse(colLenStr);   //列中最长数据的长度
                        }
                    }
                    colLen = (headLen >= colLen) ? headLen : colLen;
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\",\"width\":\"" + colLen + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
@@ -1373,7 +1382,7 @@
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                objJsonResult.list = columnNameList;
                objJsonResult.data = dt;
                objJsonResult.data = ds.Tables[0];
                return objJsonResult;
            }
            catch (Exception e)
@@ -1404,7 +1413,7 @@
                    "and (产品名称=''" + com.HProductName + "'' or ''" + com.HBillNo + "''='''') " +
                    "and (规格型号=''" + com.HProductModel + "'' or ''" + com.HProductModel + "''='''') " + com.RandomSearch;
                ds = oCN.RunProcReturn($"exec h_p_Kf_MaterOutEntryReport_Cloth_New '{sql}','1' , ''", "h_p_Kf_MaterOutEntryReport_Cloth_New");
                ds = oCN.RunProcReturn($"exec h_p_Kf_MaterOutEntryReport_Cloth_New '{sql}'", "h_p_Kf_MaterOutEntryReport_Cloth_New");
                DataTable dt = ds.Tables[0];
@@ -1413,8 +1422,20 @@
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    int headLen = col.ColumnName.ToString().Length;        //列名的长度
                    int colLen = 0;
                    if (ds.Tables[1].Rows[0][col.ColumnName] != null)
                    {
                        string colLenStr = ds.Tables[1].Rows[0][col.ColumnName].ToString();
                        if (colLenStr != "")
                        {
                            colLen = int.Parse(colLenStr);   //列中最长数据的长度
                        }
                    }
                    colLen = (headLen >= colLen) ? headLen : colLen;
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name +"\",\"width\":\"" + colLen + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }