コード例 #1
0
ファイル: CNGGAS.ashx.cs プロジェクト: jxsgood/WEBCNG
        /// <summary>
        /// 取得当班对象 
        /// </summary>
        /// <param name="dt">日期</param>
        /// <param name="zd">站点</param>
        /// <param name="bz">班组</param>
        /// <param name="yb">夜班</param>
        /// <param name="scql">生产气量</param>
        /// <returns></returns>
        private string getGasSc(DateTime dt, int zd, int bz, bool yb, double scql)
        {
            DAL dal = new DAL();
            CW_每班统计 dqBz = new CW_每班统计();//当班数据
            CW_每班统计 syBz = new CW_每班统计();//上一班数据
            DateTime sydt; //上一班日期
            string retext = "{\"sc\":输差对象,\"s\":水对象,\"y\":油对象,\"d\":电对象,\"ysj\":压缩机对象}";
            int sybz;//上一班 班组
            gassc sc = new gassc();
            string SQL = "SELECT ID  FROM [CNGQT].[dbo].[CW_每班统计] where [站点]=" + zd.ToString() + " and [日期]='" + dt.ToString() + "' and [班组]='" + bz.ToString() + "'";
            string id = dal.RunSqlGetID(SQL);
            if (id == null) { return "[]"; }
            dqBz = ZDGAS.GetModel_CW_每班统计(int.Parse(id));
            if (zd == 4)
            {
                sydt = dt.AddDays(-1);
                sybz = bz - 1;
                if (sybz == 0) { sybz = 4; }
            }
            else
            {
                if (yb)//当前班是否是夜班
                {
                    sydt = dt;
                }
                else
                {
                    sydt = dt.AddDays(-1);
                }
                sybz = bz - 1;
                if (sybz == 0) { sybz = 3; }
            }
            SQL = "SELECT ID  FROM [CNGQT].[dbo].[CW_每班统计] where [站点]=" + zd.ToString() + " and [日期]='" + sydt.ToString() + "' and [班组]='" + sybz.ToString() + "'";
            id = dal.RunSqlGetID(SQL);
            syBz = ZDGAS.GetModel_CW_每班统计(int.Parse(id));//上一班数据

            //取当班 流量计修正值
            SQL = "SELECT [总电峰],[总电平],[总电谷],[商电峰],[商电平],[商电谷],[正无功],[反无功],[普通水],[消防水],[流量计] FROM [CNGQT].[dbo].[CW_每班修正] where 日期='" + dt.ToString() + "' AND 站点=" + zd.ToString() + " AND 班组=" + bz.ToString();
            xzz dbxzz = new xzz();
            dbxzz.init();
            string[] val = dal.RunSqlStrings(SQL);
            if (val != null)
            {
                dbxzz.zdf = double.Parse(val[0]);
                dbxzz.zdp = double.Parse(val[1]);
                dbxzz.zdg = double.Parse(val[2]);
                dbxzz.sdf = double.Parse(val[3]);
                dbxzz.sdp = double.Parse(val[4]);
                dbxzz.sdg = double.Parse(val[5]);
                dbxzz.zwg = double.Parse(val[6]);
                dbxzz.fwg = double.Parse(val[7]);
                dbxzz.pts = double.Parse(val[8]);
                dbxzz.xfs = double.Parse(val[9]);
                dbxzz.llj = double.Parse(val[10]);
            }

            sc.进站起 = dqBz.SX_进站起数;
            sc.进站止 = dqBz.SX_进站止数;
            sc.进站气量 = sc.进站止 - sc.进站起;
            sc.再生起 = dqBz.SX_再生起数;
            sc.再生止 = dqBz.SX_再生止数;
            sc.再生气量 = sc.再生止 - sc.再生起;
            sc.生产气量 = scql;
            sc.购进气量 = sc.进站气量 - sc.再生气量 + dbxzz.llj;
            sc.罐储气 = dqBz.SX_罐储气;
            sc.罐差 = dqBz.SX_罐储气 - syBz.SX_罐储气;
            sc.罐储气起 = syBz.SX_罐储气;
            sc.罐储气止 = dqBz.SX_罐储气;
            sc.输差 = sc.购进气量 - sc.生产气量 - sc.罐差;
            sc.修正值 = dbxzz.llj;
            if (sc.生产气量 == 0 || sc.购进气量 == 0)
            {
                sc.输差率 = 0;
            }
            else
            {
                sc.输差率 = sc.输差 / sc.购进气量;
            }

            string temp = "{{ \"total\": 1, \"rows\": [{{ \"进站起\": {0:f},\"进站止\":{1:f},\"再生起\":{2:f},\"再生止\":{3:f},\"购进气量\":{4:f},\"生产气量\":{5:f},\"罐储气\":{6:f},\"罐差\":{7:f},\"输差\":{8:f},\"输差率\":{9:f},\"修正\":{10:f} }}]}}";
            temp = string.Format(temp, sc.进站起, sc.进站止, sc.再生起, sc.再生止, sc.购进气量, sc.生产气量, sc.罐储气, sc.罐差, sc.输差, sc.输差率 * 100, sc.修正值);
            retext = retext.Replace("输差对象", temp);

            temp = jsonYouLei(syBz, dqBz);
            retext = retext.Replace("油对象", temp);

            temp = jsonDianLei(syBz, dqBz, dbxzz);
            retext = retext.Replace("电对象", temp);

            temp = jsonShuiLei(syBz, dqBz, dbxzz);
            retext = retext.Replace("水对象", temp);

            temp = jsonYaShoJi(syBz, dqBz);
            retext = retext.Replace("压缩机对象", temp);
            Sys.DebugMes(temp);
            return retext;
        }
コード例 #2
0
ファイル: CNGGAS.ashx.cs プロジェクト: jxsgood/WEBCNG
        /// <summary>
        /// 取得输差对象 
        /// </summary>
        /// <param name="dt">日期</param>
        /// <param name="zd">站点</param>
        /// <param name="bz">班组</param>
        /// <param name="yb">夜班</param>
        /// <param name="scql">生产气量</param>
        /// <returns></returns>
        private string getGasSc(DateTime dt, int zd, int bz, bool yb, double scql)
        {
            DAL dal = new DAL();
            CW_每班统计 dqBz = new CW_每班统计();//当班数据
            CW_每班统计 syBz = new CW_每班统计();//上一班数据
            DateTime sydt; //上一班日期
            int sybz;//上一班 班组
            gassc sc = new gassc();
            string SQL = "SELECT ID  FROM [CNGQT].[dbo].[CW_每班统计] where [站点]=" + zd.ToString() + " and [日期]='" + dt.ToString() + "' and [班组]='" + bz.ToString() + "'";
            string id = dal.RunSqlGetID(SQL);
            if (id == null) { return "[]"; }
            dqBz = ZDGAS.GetModel_CW_每班统计(int.Parse(id));
            if (zd == 4)
            {
                sydt = dt.AddDays(-1);
                sybz = bz - 1;
                if (sybz == 0) { sybz = 4; }
            }
            else
            {
                if (yb)//当前班是否是夜班
                {
                    sydt = dt;
                }
                else
                {
                    sydt = dt.AddDays(-1);
                }
                sybz = bz - 1;
                if (sybz == 0) { sybz = 3; }
            }
            SQL = "SELECT ID  FROM [CNGQT].[dbo].[CW_每班统计] where [站点]=" + zd.ToString() + " and [日期]='" + sydt.ToString() + "' and [班组]='" + sybz.ToString() + "'";
            id = dal.RunSqlGetID(SQL);
            syBz = ZDGAS.GetModel_CW_每班统计(int.Parse(id));

            sc.进站起 = dqBz.SX_进站起数;
            sc.进站止 = dqBz.SX_进站止数;
            sc.进站气量 = sc.进站止 - sc.进站起;
            sc.再生起 = dqBz.SX_再生起数;
            sc.再生止 = dqBz.SX_再生止数;
            sc.再生气量 = sc.再生止 - sc.再生起;
            sc.生产气量 = scql;
            sc.实际用气 = sc.进站气量 - sc.再生气量;
            sc.罐储气 = dqBz.SX_罐储气;
            sc.罐差 = dqBz.SX_罐储气 - syBz.SX_罐储气;
            sc.输差 = sc.实际用气 - sc.生产气量 - sc.罐差;
            if (sc.生产气量 == 0 || sc.实际用气 == 0)
            {
                sc.输差率 = 0;
            }
            else
            {
                sc.输差率 = sc.输差 / sc.实际用气;
            }

            string temp = "{{ \"total\": 1, \"rows\": [{{ \"进站起\": {0:f},\"进站止\":{1:f},\"再生起\":{2:f},\"再生止\":{3:f},\"进站气量\":{4:f},\"再生气量\":{5:f},\"实际用气\":{6:f},\"生产气量\":{7:f},\"罐储气\":{8:f},\"罐差\":{9:f},\"输差\":{10:f},\"输差率\":{11:f} }}]}}";
            temp = string.Format(temp, sc.进站起, sc.进站止, sc.再生起, sc.再生止, sc.进站气量, sc.再生气量, sc.实际用气, sc.生产气量, sc.罐储气, sc.罐差, sc.输差, sc.输差率 * 100);
            Sys.DebugMes(temp);
            return temp;
        }