yusijie
2024-08-26 d6852d68cc3dce5dc4347981d9a687b21df02f8d
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
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.Web.Http;
using WebAPI.Models;
namespace WebAPI.Controllers
{
    public class Sc_ProductionReportsController : ApiController
    {
        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
        private json objJsonResult = new json();
        private json objJsonResultReturn = new json();
        SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
        DataSet ds;
 
        #region 生产模块 计划达成率报表
        /// <summary>
        /// 返回计划达成率报表
        ///参数:string sql。
        ///返回值:object。
        /// </summary>
        [Route("Sc_ProductionReport/PlanAchievementRate")]
        [HttpGet]
        public object PlanAchievementRate(string sWhere, string user)
        {
            try
            {
                List<object> columnNameList = new List<object>();
                if (sWhere == null || sWhere == "")
                {
                    objJsonResult.code = "0";
                    objJsonResult.count = 0;
                    objJsonResult.Message = "无查询条件!";
                    objJsonResult.data = null;
                    return objJsonResult;
                }
 
                Dictionary<object, object> dic = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<object, object>>(sWhere);
 
                string HBeginDate = dic["HBeginDate"].ToString();
                string HEndDate = dic["HEndDate"].ToString();
                int HDeptID = int.Parse(dic["HDeptID"].ToString());
                string HSourceName = dic["HSourceName"].ToString();
                string HMaterNumber = dic["HMaterNumber"].ToString();
                string HMaterName = dic["HMaterName"].ToString();
                string HMaterModel = dic["HMaterModel"].ToString();
                string HCustomize = dic["HCustomize"].ToString();
 
                ds = oCN.RunProcReturn("exec h_p_Sc_PlanAchievementRateReport '" + HBeginDate + "','" + HEndDate + "'," + HDeptID + ",'" + HSourceName + "','" + HMaterNumber + "','" + HMaterName + "','" + HMaterModel + "','" + HCustomize + "'", "h_p_Sc_PlanAchievementRateReport");
 
                //添加列名
                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 = "1";
                objJsonResult.count = 1;
                objJsonResult.Message = "Sucess!";
                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;
            }
        }
        #endregion
    }
}