1
zrg
2024-06-25 4bfab3d9173fcced07cea4afb71227b83b47c469
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
using DAL;
using DBUtility;
using Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using SQLHelper;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using WebAPI;
using WebAPI.Models;
using WebAPI.Service;
 
namespace WebAPI.Controllers
{
    public class PM_ReportController : ApiController
    {
        public string sWhere = "";
        public DataSet ds = new DataSet();
        private json objJsonResult = new json();
        SQLHelper.ClsCN oCn = new SQLHelper.ClsCN();
 
        #region 报表数据获取方法
 
        #region 项目人天耗用明细分析报表
 
        /// <summary>
        /// 项目人天耗用明细分析报表
        /// </summary>
        /// <returns></returns>
        [Route("PM_ReportController/GetPM_ProjectWorkDaysEntryReport_Json")]
        [HttpGet]
        public object GetPM_ProjectWorkDaysEntryReport_Json(string sWhere)
        {
            try
            {
                ds = oCn.RunProcReturn("exec h_p_PM_ProjectWorkDaysEntryReport " + sWhere, "h_p_PM_ProjectWorkDaysEntryReport");
                //if (ds == null || ds.Tables[0].Rows.Count == 0)
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "当前所输入过滤条件,没有返回任何结果!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //else
                //{
                    List<object> columnNameList = new List<object>();
                    //添加列名
                    foreach (DataColumn col in ds.Tables[0].Columns)
                    {
                        Type dataType = col.DataType;
                        string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                        columnNameList.Add(JsonConvert.DeserializeObject(ColmString));  //获取到DataColumn列对象的列名
                    }
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!";
                    objJsonResult.data = ds.Tables[0];
                    objJsonResult.list = columnNameList;
                    return objJsonResult;
                //}
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "返回报表信息失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
 
        #endregion
 
        #region 项目人天耗用统计分析报表
 
        /// <summary>
        /// 项目人天耗用统计分析报表
        /// </summary>
        /// <returns></returns>
        [Route("PM_ReportController/GetPM_ProjectWorkDaysSumReport_Json")]
        [HttpGet]
        public object GetPM_ProjectWorkDaysSumReport_Json(string sWhere)
        {
            try
            {
                ds = oCn.RunProcReturn("exec h_p_PM_ProjectWorkDaysSumReport " + sWhere, "h_p_PM_ProjectWorkDaysSumReport");
                //if (ds == null || ds.Tables[0].Rows.Count == 0)
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "当前所输入过滤条件,没有返回任何结果!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //else
                //{
                    List<object> columnNameList = new List<object>();
                    //添加列名
                    foreach (DataColumn col in ds.Tables[0].Columns)
                    {
                        Type dataType = col.DataType;
                        string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                        columnNameList.Add(JsonConvert.DeserializeObject(ColmString));  //获取到DataColumn列对象的列名
                    }
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!";
                    objJsonResult.data = ds.Tables[0];
                    objJsonResult.list = columnNameList;
                    return objJsonResult;
                //}
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "返回报表信息失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
 
        #endregion
 
        #region 月度汇报统计表
 
        /// <summary>
        /// 月度汇报统计表
        /// </summary>
        /// <returns></returns>
        [Route("PM_ReportController/GetPM_WorkTaskReportMonthSumReport_Json")]
        [HttpGet]
        public object GetPM_WorkTaskReportMonthSumReport_Json(string sWhere)
        {
            try
            {
                ds = oCn.RunProcReturn("exec h_p_PM_WorkTaskReportMonthSumReport " + sWhere, "h_p_PM_WorkTaskReportMonthSumReport");
                //if (ds == null || ds.Tables[0].Rows.Count == 0)
                //{
                //    objJsonResult.code = "0";
                //    objJsonResult.count = 0;
                //    objJsonResult.Message = "当前所输入过滤条件,没有返回任何结果!";
                //    objJsonResult.data = null;
                //    return objJsonResult;
                //}
                //else
                //{
                    List<object> columnNameList = new List<object>();
                    //添加列名
                    foreach (DataColumn col in ds.Tables[0].Columns)
                    {
                        Type dataType = col.DataType;
                        string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                        columnNameList.Add(JsonConvert.DeserializeObject(ColmString));  //获取到DataColumn列对象的列名
                    }
                    objJsonResult.code = "0";
                    objJsonResult.count = 1;
                    objJsonResult.Message = "成功!";
                    objJsonResult.data = ds.Tables[0];
                    objJsonResult.list = columnNameList;
                    return objJsonResult;
                //}
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "返回报表信息失败!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
 
        #endregion
 
        #region 我的项目 查询
        /// <summary>
        /// 我的项目查询
        /// </summary>
        /// <param name="sWhere"></param>
        /// <param name="user"></param>
        /// <returns></returns>
        [Route("PM_ReportController/PM_ProjectBillMYList")]
        [HttpGet]
        public object PM_ProjectBillMYList(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                //查看权限
                if (!DBUtility.ClsPub.Security_Log("PM_ProjectBillMainMy_Query", 1, false, user))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查看权限!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
                string sql = "exec h_p_My_PM_ProjectReportBill " + user+",0,''";
                ds=oCn.RunProcReturn(sql, "h_p_My_PM_ProjectReportBill");
 
                //添加列名
                foreach (DataColumn col in ds.Tables[0].Columns)
                {
                    Type dataType = col.DataType;
                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//获取到DataColumn列对象的列名
                }
 
                objJsonResult.code = "0";
                objJsonResult.count = 1;
                objJsonResult.Message = "成功!";
                objJsonResult.data = ds;
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
        }
        #endregion
 
        #endregion
 
 
    }
}