using com.hnshituo.core.webapp.vo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Common
{
    public class MeterWorkRailwayActualService
    {
        /// <summary>
        /// 查询一次该车最近的3条计量历史数据
        /// </summary>
        /// <returns></returns>
        public RESTfulResult<DataTable> doQueryCountWf(CommonPage<MeterWorkRailwayActual> cpc)
        {
            DbHelper db = new DbHelper();
            cpc.pageNum = 1;
            cpc.pageSize = 100;
            RESTfulResult<PageList<List<MeterWorkRailwayActual>>> rm = db.doOption<PageList<List<MeterWorkRailwayActual>>>("meterworkrailwayactuals", "doQueryWf", new object[] { cpc }, 1);
            RESTfulResult<DataTable> result = new RESTfulResult<DataTable>();
            result.Succeed = rm.Succeed;
            result.Status = rm.Status;
            result.Message = rm.Message;
            result.ResultMessage = rm.ResultMessage;
            result.Code = rm.Code;

            if (rm.Succeed && rm.Data != null && rm.Data.list != null && rm.Data.list.Count > 0)
            {
                result.Data = rm.Data.list.ListToDataTable();
            }
            else
            {
                result.Data = new DataTable();
            }
            return result;
        }

        /// <summary>
        /// 查询数据，平台公共方法
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public RESTfulResult<List<MeterWorkRailwayActual>> doQueryActWf(MeterWorkRailwayActual info)
        {
            DbHelper db = new DbHelper();
            RESTfulResult<PageList<List<MeterWorkRailwayActual>>> rm = db.doOption<PageList<List<MeterWorkRailwayActual>>>("meterworkrailwayactuals", "doQueryActWf", new object[] { info }, 0);

            RESTfulResult<List<MeterWorkRailwayActual>> result = new RESTfulResult<List<MeterWorkRailwayActual>>();
            result.Succeed = rm.Succeed;
            result.Status = rm.Status;
            result.Message = rm.Message;
            result.ResultMessage = rm.ResultMessage;
            result.Code = rm.Code;
            if (rm.Data != null && rm.Data.list != null && rm.Data.list.Count > 0)
            {
                result.Data = rm.Data.list;
            }

            return result;
        }

        /// <summary>
        /// 查询视图的数据，条件createTime1；createTime2
        /// </summary>
        /// <param name="info"></param>
        /// <returns></returns>
        public RESTfulResult<List<MeterWorkRailwayActual>> doQuerySelectView(MeterWorkRailwayActual info)
        {
            DbHelper db = new DbHelper();
            RESTfulResult<PageList<List<MeterWorkRailwayActual>>> rm = db.doOption<PageList<List<MeterWorkRailwayActual>>>("meterworkrailwayactuals", "selectView", new object[] { info }, 0);

            RESTfulResult<List<MeterWorkRailwayActual>> result = new RESTfulResult<List<MeterWorkRailwayActual>>();
            result.Succeed = rm.Succeed;
            result.Status = rm.Status;
            result.Message = rm.Message;
            result.ResultMessage = rm.ResultMessage;
            result.Code = rm.Code;
            if (rm.Data != null && rm.Data.list != null && rm.Data.list.Count > 0)
            {
                result.Data = rm.Data.list;
            }

            return result;
        }
    }
}
