public HttpResponseMessage consumerecords(requestConsumeRecords requestData)
        {
            if (requestData.pageIndex <= 0)
            {
                requestData.pageIndex = 1;
            }
            if (requestData.pageSize <= 0)
            {
                requestData.pageSize = 10;
            }
            APIResultBase <responseConsumeRecords> apiresult = new APIResultBase <responseConsumeRecords>();
            string message = "";
            responseConsumeRecords records = new responseConsumeRecords();
            int result = new ConsumeBaseBLL().SearchConsumeRecords(requestData, ref records, out message);

            if (result != 0)
            {
                apiresult.code = "1";
                if (string.IsNullOrWhiteSpace(message))
                {
                    message = "查询消费记录失败";
                }
                apiresult.msg = message;
            }
            apiresult.data = records;
            return(Request.CreateResponse(apiresult));
        }
示例#2
0
        /// <summary>
        /// 获取消费记录
        /// </summary>
        /// <param name="requestData"></param>
        /// <param name="totalCount"></param>
        /// <param name="pageCount"></param>
        /// <returns></returns>
        public ICollection <reponseMealRecord> GetMealRecords(requestConsumeRecords requestData, out int totalCount, out int pageCount)
        {
            totalCount = 0;
            pageCount  = 0;
            if (requestData.pageIndex <= 0)
            {
                requestData.pageIndex = 1;
            }
            if (requestData.pageSize <= 0)
            {
                requestData.pageSize = 10;
            }

            int pageBegin = (requestData.pageIndex - 1) * requestData.pageSize;
            int pageEnd   = requestData.pageIndex * requestData.pageSize;
            //获取消费明细
            string sql = @"select t.nRecSeq,t.clock_id, t.emp_id,t.emp_fname,t.depart_id,t.depart_name, t.card_id,t.card_consume,t.sign_time,t.clock_name,t.dinRoom_id,t.dinRoom_name  from (select ROW_NUMBER() over( order by a.sign_time ) as row_id,a.nRecSeq,a.clock_id, a.emp_id,b.emp_fname,c.depart_id,c.depart_name, a.card_id,a.card_consume,a.sign_time,d.clock_name,e.dinRoom_id,e.dinRoom_name 
                            FROM [MealRecords] a with(nolock) inner join  (select * from [Employee] with(nolock) where emp_fname like '%{0}%' {1} ) b on a.emp_id =b.emp_id 
                            inner join  (select * from [Departs] with(nolock) where depart_name like '%{2}%' {3} ) c on b.depart_id = c.depart_id  left join [Clocks] d on d.clock_id = a.clock_id left join [DinRoom] e on d.DinRoom_id = e.DinRoom_id  where a.sign_time >='{4}' and a.sign_time<='{5}' {6}  {7}) t where row_id> " + pageBegin + " and row_id<=" + pageEnd;

            string sql0 = string.IsNullOrWhiteSpace(requestData.personName) ? "" : requestData.personName.Trim();
            string sql1 = string.IsNullOrWhiteSpace(requestData.ThirdPersonId) ? "" : " and emp_id='" + requestData.ThirdPersonId.Trim() + "' ";
            string sql2 = string.IsNullOrWhiteSpace(requestData.deptName) ? "" : requestData.deptName.Trim();
            string sql3 = string.IsNullOrWhiteSpace(requestData.ThirdDeptId) ? "" : " and depart_id='" + requestData.ThirdDeptId.Trim() + "' ";
            string sql4 = string.IsNullOrWhiteSpace(requestData.startTime) ? DateTime.Now.ToShortDateString() : requestData.startTime;
            string sql5 = string.IsNullOrWhiteSpace(requestData.endTime) ? DateTime.Now.ToShortDateString() : requestData.endTime;
            string sql6 = string.IsNullOrWhiteSpace(requestData.cardNo) ? "" : " and a.card_id='" + requestData.cardNo.Trim() + "' ";
            string sql7 = string.IsNullOrWhiteSpace(requestData.dinRoomName) ? "" : " and e.DinRoom_name like '%" + requestData.dinRoomName.Trim() + "'% ";

            sql = string.Format(sql, sql0, sql1, sql2, sql3, sql4, sql5, sql6, sql7);

            //获取总记录数
            string totalsql = @"select count(0) from [MealRecords]  a with(nolock) inner join  (select * from [Employee] with(nolock) where emp_fname like '%{0}%' {1} ) b on a.emp_id =b.emp_id
                            inner join  (select * from [Departs] with(nolock) where depart_name like '%{2}%' {3} ) c on b.depart_id = c.depart_id  left join [Clocks] d on d.clock_id = a.clock_id left join [DinRoom] e on d.DinRoom_id = e.DinRoom_id  where a.sign_time >='{4}' and a.sign_time<='{5}' {6}  {7} ";

            totalsql = string.Format(totalsql, sql0, sql1, sql2, sql3, sql4, sql5, sql6, sql7);

            DataTable dt = GetDataTableBySqlString(totalsql, null);

            if (dt != null && dt.Rows.Count > 0)
            {
                totalCount = int.Parse(dt.Rows[0][0].ToString());
            }

            pageCount = (totalCount + requestData.pageSize - 1) / requestData.pageSize;


            return(GetEnityListBySqlString <reponseMealRecord>(sql, null));
        }
        /// <summary>
        /// 查询消费记录
        /// </summary>
        /// <param name="requestData"></param>
        /// <param name="records"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public int SearchConsumeRecords(requestConsumeRecords requestData, ref responseConsumeRecords records, out string message)
        {
            int result = 0;

            message = "";
            IThirdApp thirdApp = ThirdAppFactory.Create(Common.CommonSettings.ThirdApp);

            if (thirdApp == null)
            {
                result = 1;
                LogHelper.Error("ThirdApp未配置");
            }
            else
            {
                result = thirdApp.SearchConsumeRecords(requestData, ref records, out message);
            }
            return(result);
        }
示例#4
0
        public int SearchConsumeRecords(requestConsumeRecords requestData, ref responseConsumeRecords records, out string message)
        {
            message = "";
            int result     = 0;
            int totalCount = 0;
            int pageCount  = 0;
            ICollection <reponseMealRecord> IMealRecords    = new EastRiverBLL().GetMealRecords(requestData, out totalCount, out pageCount);
            List <ConsumeRecords>           LConsumeRecords = new List <ConsumeRecords>();

            if (IMealRecords != null && IMealRecords.Count > 0)
            {
                foreach (reponseMealRecord item in IMealRecords)
                {
                    ConsumeRecords record = new ConsumeRecords();
                    record.cardNo        = item.card_id;
                    record.consumeAmount = item.card_consume.ToString();
                    record.consumeTime   = item.sign_time.ToString("yyyy-MM-dd HH:mm:ss");
                    record.recordId      = item.nRecSeq.ToString();
                    //record.personId = item.emp_id;//该第三方集成的人员ID为相同,其他的此处可能需要查询数据库获取
                    record.personName  = item.emp_fname;
                    record.deptName    = item.depart_name;
                    record.deviceId    = item.clock_id;
                    record.deviceName  = item.clock_name;
                    record.dinRoomId   = item.dinRoom_id;
                    record.dinRoomName = item.dinRoom_name;
                    LConsumeRecords.Add(record);
                }
            }
            records.consumeRecords = LConsumeRecords;
            records.pageCount      = pageCount;
            records.totalCount     = totalCount;
            records.pageIndex      = requestData.pageIndex;
            records.pageSize       = requestData.pageSize;

            return(result);
        }
示例#5
0
 public ICollection <reponseMealRecord> GetMealRecords(requestConsumeRecords requestData, out int totalCount, out int pageCount)
 {
     return(MealRecordsDAL.ProxyInstance.GetMealRecords(requestData, out totalCount, out pageCount));
 }