public ResponsePZZTotalGet PZZTotalGet([FromBody] RequestPZZTotalGet request) { try { PZZBLL bll = new PZZBLL(); return(bll.PZZTotalGet(request)); } catch (Exception ex) { throw new HttpResponseException( Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); } }
public ResponsePZZTotalGet PZZTotalGet(RequestPZZTotalGet request) { ResponsePZZTotalGet response = new ResponsePZZTotalGet(); using (cnn = GetConnection()) { var ts = cnn.BeginTransaction(); try { var user = this.UserInfoGet(request.Token, ts); string sql = "select * from TKS_FAS_CertificateWord where accountId=@AccountId order by isdefault desc"; List <TKS_FAS_CertificateWord> data = cnn.Query <TKS_FAS_CertificateWord>(sql, new { AccountId = user.AccountId }, ts).ToList(); AccountSetBLL account = new AccountSetBLL(cnn); PeriodBLL periodBLL = new PeriodBLL(cnn); var activePeriod = account.GetActivePeriod(user.AccountId, ts); sql = @"select top 1 * from TKS_FAS_Doc where accountid=@AccountId and PZDate>=@StartDate order by CreateDate desc "; var doc = cnn.QueryFirstOrDefault <TKS_FAS_Doc>(sql, new { AccountId = user.AccountId, StartDate = activePeriod.StartDate, }, ts); var period = new TKS_FAS_MonthPeriodInfo(); if (request.Type == "GD") { //add by Hero.Zhang 计提折旧日期默认为当前活动期间 period = activePeriod; response.DefaultDate = DateTime.Parse(period.EndDate.ToString()).ToString("yyyy-MM-dd"); } else { if (doc != null) { response.DefaultDate = (doc.PZDate ?? DateTime.Now).ToString("yyyy-MM-dd"); period = periodBLL.GetPeriod(doc.PeriodId, ts); } else { period = activePeriod; if (period.Month == DateTime.Now.Month && period.Year == DateTime.Now.Year) { //当天日期属于本期 response.DefaultDate = DateTime.Parse(DateTime.Now.ToString()).ToString("yyyy-MM-dd"); } else { response.DefaultDate = DateTime.Parse(period.EndDate.ToString()).ToString("yyyy-MM-dd"); } } } sql = @"select (case when max(pzzno) is null then 0 else max(pzzno) end) from TKS_FAS_Doc where accountid=@AccountId and periodId=@PeriodId"; var max = cnn.ExecuteScalar(sql, new { AccountId = user.AccountId, PeriodId = period.Id }, ts); response.No = (int.Parse(max.ToString()) + 1).ToString(); var currentAccount = account.GetAccountSetByAccountId(user.AccountId, ts); ts.Commit(); response.AccountName = currentAccount.QY_Name; response.IsSuccess = true; response.Message = "加载完毕"; response.Data = data; return(response); } catch (Exception ex) { ts.Rollback(); return(this.DealException(response, ex) as ResponsePZZTotalGet); } } }