/// <summary> /// 程序执行主入口 /// </summary> /// <param name="requestEntity"></param> /// <param name="responseEntity"></param> protected override void DoExecute(RequestEntity requestEntity, ResponseEntity responseEntity) { // 定义接收客户端参数的变量 XtgJhzkCheckFilter filter = ServiceUtility.ConvertToFilterFromDict <XtgJhzkCheckFilter>(requestEntity.Parameters); filter.UserId = responseEntity.UserId; // 清除到账日期 Singleton <BaseUpdateBLL <ClearXtgJhzkToAcountTimeDAL> > .Instance.UpdateData(filter, responseEntity); }
/// <summary> /// 根据实收编号,更新到账时间 /// </summary> /// <param name="filter"></param> /// <returns></returns> public string UpdateXtgJhzkToAccountTimeByReceiveId(XtgJhzkCheckFilter filter) { if (string.IsNullOrEmpty(filter.ReceivedIDs)) { return(""); } StringBuilder sb = new StringBuilder(); sb.Append(" UPDATE dbo.Received "); sb.Append(" SET ToAcountTime = '" + filter.ToAcountTime.ToString() + "'"); sb.Append(" , OperatorID =" + filter.OperatorID); sb.Append(" WHERE ReceivedID IN (" + filter.ReceivedIDs + ")"); return(sb.ToString()); }
/// <summary> /// 获取检索数据的存储过程名 /// </summary> /// <param name="baseFilter"></param> /// <returns></returns> protected override string GetUpdateSql(BaseFilter baseFilter) { XtgJhzkCheckFilter filter = baseFilter as XtgJhzkCheckFilter; if (filter == null) { return(""); } if (filter.IsUpdateAll) { return(UpdateAllXtgJhzkToAccountTime(filter)); } else { return(UpdateXtgJhzkToAccountTimeByReceiveId(filter)); } }
/// <summary> /// 根据检索条件,全部更新到账时间 /// </summary> /// <param name="filter"></param> /// <returns></returns> private string UpdateAllXtgJhzkToAccountTime(XtgJhzkCheckFilter filter) { StringBuilder sb = new StringBuilder(); sb.Append(" UPDATE dbo.Received "); sb.Append(" SET ToAcountTime = '" + filter.ToAcountTime.ToString() + "'"); sb.Append(" , OperatorID =" + filter.OperatorID); sb.Append(" WHERE ReceivedID IN ("); sb.Append(" SELECT ReceivedID FROM dbo.ViewXTGJHZK"); sb.Append(" WHERE 1 = 1"); string condition = CombineCondition(filter); if (!string.IsNullOrEmpty(condition)) { sb.Append(condition); } sb.Append(" )"); return(sb.ToString()); }
/// <summary> /// 根据过滤条件,返回检索数据的Sql文 /// </summary> /// <param name="baseFilter"></param> /// <returns></returns> protected override string GetSearchSql(BaseFilter baseFilter) { XtgJhzkCheckFilter filter = baseFilter as XtgJhzkCheckFilter; if (filter == null) { return(""); } StringBuilder sb = new StringBuilder(); sb.Append(" SELECT * "); sb.Append(" FROM ( "); sb.Append(" SELECT ROW_NUMBER() OVER(ORDER BY Bid) AS RowId"); sb.Append(" ,Bid "); sb.Append(" ,ContractNo "); sb.Append(" ,CreateTime "); sb.Append(" ,BillMonth "); sb.Append(" ,Subject "); sb.Append(" ,SavingCard "); sb.Append(" ,SavingUser "); sb.Append(" ,Amount "); sb.Append(" ,ReceivedType "); sb.Append(" ,ReceivedTime "); sb.Append(" ,ToAcountTime "); sb.Append(" ,Region "); sb.Append(" ,ReceivedID "); sb.Append(" FROM [dbo].[ViewXTGJHZK] "); string condition = CombineCondition(filter); if (!string.IsNullOrEmpty(condition)) { sb.Append(condition); } sb.Append(" ) a"); sb.AppendFormat(" WHERE a.RowId > {0} AND a.RowId <= {1}", filter.FromIndex, filter.ToIndex); return(sb.ToString()); }
/// <summary> /// 根据过滤条件,返回检索件数的Sql文 /// </summary> /// <param name="baseFilter"></param> /// <returns></returns> protected override string GetCountSql(BaseFilter baseFilter) { XtgJhzkCheckFilter filter = baseFilter as XtgJhzkCheckFilter; if (filter == null) { return(""); } StringBuilder sb = new StringBuilder(); sb.Append(" SELECT COUNT(*) AS TOTALCOUNT"); sb.Append(" FROM [dbo].[ViewXTGJHZK] "); string condition = CombineCondition(filter); if (!string.IsNullOrEmpty(condition)) { sb.Append(condition); } return(sb.ToString()); }
/// <summary> /// 获取检索数据的存储过程名 /// </summary> /// <param name="baseFilter"></param> /// <returns></returns> protected override string GetUpdateSql(BaseFilter baseFilter) { XtgJhzkCheckFilter filter = baseFilter as XtgJhzkCheckFilter; if (filter == null) { return(""); } if (string.IsNullOrEmpty(filter.ReceivedIDs)) { return(""); } StringBuilder sb = new StringBuilder(); sb.Append(" UPDATE dbo.Received "); sb.Append(" SET ToAcountTime = null"); sb.Append(" , OperatorID =" + filter.OperatorID); sb.Append(" WHERE ReceivedID IN (" + filter.ReceivedIDs + ")"); return(sb.ToString()); }
/// <summary> /// 生成检索条件 /// </summary> /// <param name="filter"></param> /// <returns></returns> private string CombineCondition(XtgJhzkCheckFilter filter) { StringBuilder sb = new StringBuilder(); if (!string.IsNullOrEmpty(filter.Region)) { sb.Append(" AND Region = '" + filter.Region + "'"); } if (filter.BusinessID != 0) { sb.Append(" AND Bid = " + filter.BusinessID); } if (!string.IsNullOrEmpty(filter.ContractNo)) { sb.Append(" AND ContractNo = '" + filter.ContractNo + "'"); } if (!string.IsNullOrEmpty(filter.CashCardNo)) { sb.Append(" AND SavingCard = '" + filter.CashCardNo + "'"); } if (!string.IsNullOrEmpty(filter.BillStatus)) { sb.Append(" AND BusinessStatus = " + filter.BillStatus.ToByte()); } if (!string.IsNullOrEmpty(filter.BillType)) { sb.Append(" AND ProductType = " + filter.BillType.ToByte()); } if (!string.IsNullOrEmpty(filter.LendingSide)) { sb.Append(" AND LendingSide = '" + filter.LendingSide + "'"); } if (!string.IsNullOrEmpty(filter.ServiceSide)) { sb.Append(" AND ServiceSide = '" + filter.ServiceSide + "'"); } if (!string.IsNullOrEmpty(filter.ReceiveAccount) && "1" == filter.ReceiveAccount) { sb.Append(" AND AccountID IN (11, 13, 14)"); } if (!string.IsNullOrEmpty(filter.StartTime)) { DateTime receivedTimeB = DateTime.Parse(filter.StartTime); if (receivedTimeB > DateTime.Parse(filter.StartTime).Date) { receivedTimeB = DateTime.Parse(filter.StartTime); } else { receivedTimeB = DateTime.Parse(filter.StartTime).Date; } sb.Append(" AND ReceivedTime >= '" + receivedTimeB.ToString() + "'"); } if (!string.IsNullOrEmpty(filter.EndTime)) { DateTime receivedTimeE = DateTime.Parse(filter.EndTime); if (receivedTimeE > DateTime.Parse(filter.EndTime).Date) { receivedTimeE = DateTime.Parse(filter.EndTime).AddSeconds(1); } else { receivedTimeE = receivedTimeE.Date.AddDays(1); } sb.Append(" AND ReceivedTime < '" + receivedTimeE.ToString() + "'"); } if (!string.IsNullOrEmpty(filter.ToAccountBeginDate)) { sb.Append(" AND ToAcountTime >= '" + filter.ToAccountBeginDate + "'"); } if (!string.IsNullOrEmpty(filter.ToAccountEndDate)) { sb.Append(" AND ToAcountTime <= '" + filter.ToAccountEndDate + "'"); } if (!string.IsNullOrEmpty(filter.ReceiveType)) { sb.Append(" AND ReceivedType IN ('" + filter.ReceiveType + "')"); } if (!string.IsNullOrEmpty(filter.ReptColSubject)) { sb.Append(" AND Subject IN ('" + filter.ReptColSubject + "')"); } return(sb.ToString()); }
/// <summary> /// 检索数据 /// </summary> /// <param name="filter"></param> /// <param name="responseEntity"></param> public void SearchData(XtgJhzkCheckFilter filter, ResponseEntity responseEntity) { if (filter == null) { ServiceUtility.SetResponseStatus(responseEntity, EnumResponseState.RequestCommandError); return; } // 获取件数 int totalCount = 0; if (filter.IsReGetCount) { totalCount = Singleton <XtgJhzkCheckSearchDAL <XtgJhzkViewData> > .Instance.GetCount(filter); } else { totalCount = filter.TotalCount; } if (totalCount <= 0) { ServiceUtility.SetResponseStatus(responseEntity, EnumResponseState.NoResult); m_Logger.Info("未查询到数据。"); return; } decimal totalAmount = 0; if (filter.IsReGetCount) { totalAmount = Singleton <XtgJhzkCheckSearchDAL <XtgJhzkViewData> > .Instance.GetSumAmount(filter); } else { totalAmount = filter.TotalAmount; } if (filter.PageNo < 1) { filter.PageNo = 1; } int fromIndex = (filter.PageNo - 1) * filter.PageSize; int toIndex = filter.PageNo * filter.PageSize; if (toIndex > totalCount) { toIndex = totalCount; } filter.FromIndex = fromIndex; filter.ToIndex = toIndex; var lstXtgJhzkViewDatas = Singleton <XtgJhzkCheckSearchDAL <XtgJhzkViewData> > .Instance.SearchData(filter); if (lstXtgJhzkViewDatas == null || lstXtgJhzkViewDatas.Count == 0) { ServiceUtility.SetResponseStatus(responseEntity, EnumResponseState.NoResult); m_Logger.Info("未查询到数据。"); } else { lstXtgJhzkViewDatas.ForEach(x => x.TotalAmount = totalAmount); var responseResult = new ResponseListResult <XtgJhzkViewData>(); responseResult.TotalCount = totalCount; responseResult.LstResult = lstXtgJhzkViewDatas; ServiceUtility.SetResponseStatus(responseEntity, EnumResponseState.Success); responseEntity.Results = responseResult; } }