chenhaozhe
2025-11-04 dd6804dcec1435e3b4129c7fef786fee5b80992b
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
using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Pub_Class;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Web.Http;
using WebAPI.DLL;
using WebAPI.Models;
using WebAPI.Service;
using Kingdee.BOS.WebApi.Client;
using System.Linq;
 
namespace WebAPI.Controllers.基础资料.基础资料
{
 
 
    public class Gy_PlanImplementation_ReportController : ApiController
    {
        private json objJsonResult = new json();
        public DataSet ds = new DataSet();
        public SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        // GET: Gy_PlanImplementation_Report
        [Route("Gy_PlanImplementation_ReportController/PlanStatusReport")]
        [HttpGet]
        public object PlanStatusReport(string sWhere, string HBeginDate, string HEndDate)
        {
            List<object> columnNameList = new List<object>();
            try
            {
                // 验证日期
                if (!DateTime.TryParse(HBeginDate, out DateTime beginDate) || !DateTime.TryParse(HEndDate, out DateTime endDate))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "日期格式不正确";
                    return objJsonResult;
 
                }
                if(sWhere!=null)
                ds = oCN.RunProcReturn($"select * from PlanImplementationStatus where 日期<='{HEndDate}' and 日期>='{HBeginDate}' and {sWhere}", "PlanImplementationStatus");
                else
                    ds = oCN.RunProcReturn($"select * from PlanImplementationStatus where 日期<='{HEndDate}' and 日期>='{HBeginDate}'", "PlanImplementationStatus");
                // 添加列名
                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));
                }
 
                objJsonResult.code = "1";
                objJsonResult.count = ds.Tables[0].Rows.Count;
                objJsonResult.Message = "Success!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
            
 
        }
 
 
        [Route("Gy_PlanImplementation_ReportController/OperationBillReport")]
        [HttpGet]
        public object OperationBillReport(string HEquipmentNumber, string HBeginDate, string HEndDate)
        {
            List<object> columnNameList = new List<object>();
            try
            {
                // 验证日期
                if (!DateTime.TryParse(HBeginDate, out DateTime beginDate) || !DateTime.TryParse(HEndDate, out DateTime endDate))
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "日期格式不正确";
                    return objJsonResult;
 
                }
                
                ds = oCN.RunProcReturn($"exec h_p_OperationBill '{HBeginDate}','{HEndDate}','{HEquipmentNumber}'", "h_p_OperationBill");
                // 添加列名
                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));
                }
 
                objJsonResult.code = "1";
                objJsonResult.count = ds.Tables[0].Rows.Count;
                objJsonResult.Message = "Success!";
                objJsonResult.data = ds.Tables[0];
                objJsonResult.list = columnNameList;
                return objJsonResult;
            }
            catch (Exception e)
            {
 
                objJsonResult.code = "0";
                objJsonResult.count = 0;
                objJsonResult.Message = "Exception!" + e.ToString();
                objJsonResult.data = null;
                return objJsonResult;
            }
 
 
        }
    }
}