ソースを参照

Merge branch 'develop' of http://132.232.92.186:3000/XinXiBu/OA2023 into develop

yuanrf 1 年間 前
コミット
b8e3e15a0a

+ 4 - 1
OASystem/OASystem.Api/Controllers/AuthController.cs

@@ -77,6 +77,7 @@ namespace OASystem.API.Controllers
             string role = string.Empty;
             int uId = 0;
             int unReadCount = 0;
+            int announcementUnReadCount = 0;
             if (userData.Data != null)
             {
                 uId = (userData.Data as UserLoginInfoView).UserId;
@@ -84,6 +85,7 @@ namespace OASystem.API.Controllers
                 role = (userData.Data as UserLoginInfoView).JobName;
                 authData = _SystemMenuPermissionRepository.QueryMenuLoad(uId, dto.PortType);
                 unReadCount = await _messageRep.GetUnReadCount(uId);
+                announcementUnReadCount = await _messageRep.GetAnnouncementUnReadCount(uId);
             }
 
             //_hubContext.Login(uId, uName);
@@ -91,7 +93,8 @@ namespace OASystem.API.Controllers
             {
                 UserInfo = userData == null ? null : userData.Data,
                 AuthData = authData == null ? null : authData.Data,
-                UnReadCount = unReadCount
+                UnReadCount = unReadCount,
+                AnnouncementUnReadCount = announcementUnReadCount
             };
 
             DateTime createZebraTime = DateTime.Now;

+ 77 - 0
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -62,6 +62,7 @@ using System.Security.Policy;
 using System.Xml;
 using OASystem.Domain.Dtos.QiYeWeChat;
 using static NPOI.POIFS.Crypt.CryptoFunctions;
+using Aspose.Words.Lists;
 
 namespace OASystem.API.Controllers
 {
@@ -9185,6 +9186,82 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(viewData.Data));
         }
 
+        /// <summary>
+        /// 倒推表 
+        /// File Download
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostInvertedListFileDownload(InvertedListFileDownloadDto dto)
+        {
+
+            var info1 = await _invertedListRep._sqlSugar.Queryable<Grp_InvertedList>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).FirstAsync();
+            if (info1 == null)
+            {
+                return Ok(JsonView(false, "倒推表数据未生成,请先生成倒退表数据!"));
+            }
+
+            var info = await _invertedListRep._sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.Id == dto.DiId).FirstAsync();
+            string teamName = "";
+            if (info != null) teamName = info.TeamName;
+
+            //载入模板
+            Document doc = new Document(AppSettingsHelper.Get("WordBasePath") + "Template/倒退表模板20200617.doc");
+            DocumentBuilder builder = new DocumentBuilder(doc);
+
+            //利用键值对存放数据
+            Dictionary<string, string> dic = new Dictionary<string, string>();
+            dic.Add("TeamName", teamName);
+
+            dic.Add("StartTime", info1.AirportdDropOffDt.ConvertToDatetime());
+
+            dic.Add("BPtime", info1.ApprovalDataDt.ConvertToDatetime());
+            dic.Add("BPRemark", info1.ApprovalDataRemark);
+
+            dic.Add("SQtime", info1.ApprovalDt.ConvertToDatetime());
+            dic.Add("SQRemark", info1.ApprovalRemark);
+
+            dic.Add("CPJtime", info1.ApprovalDt.ConvertToDatetime());
+            dic.Add("CPJRemark", info1.ApprovalRemark);
+
+            dic.Add("HZtime", info1.ApplyPassportDt.ConvertToDatetime());
+            dic.Add("HZRemark", info1.ApplyPassportRemark);
+
+            dic.Add("QZtime", info1.VisaInformationDt.ConvertToDatetime());
+            dic.Add("QZRemark", info1.VisaInformationRemark);
+
+            dic.Add("SQQZtime", info1.SendVisaDt.ConvertToDatetime());
+            dic.Add("SQQZRemark", info1.SendVisaRemark);
+
+            dic.Add("CQtime", info1.IssueVisaDt.ConvertToDatetime());
+            dic.Add("CQRemark", info1.IssueVisaRemark);
+
+            dic.Add("XQHtime", info1.PreTripMeetingDt.ConvertToDatetime());
+            dic.Add("XQHRemark", info1.PreTripMeetingRemark);
+
+            dic.Add("SJtime", info1.AirportdDropOffDt.ConvertToDatetime());
+            dic.Add("SJRemark", info1.AirportdDropOffRemark);
+
+            #region 填充word模板书签内容
+            foreach (var key in dic.Keys)
+            {
+                builder.MoveToBookmark(key);
+                builder.Write(dic[key]);
+            }
+
+            #endregion
+
+            var fileDir = AppSettingsHelper.Get("WordBasePath");
+            string fileName = $"{teamName}团出行准备流程表.doc";  
+            string filePath = fileDir + $@"InvertedList/{fileName}";
+            doc.Save(filePath);
+            string Url = $@"{AppSettingsHelper.Get("WordBaseUrl")}Office/Word/InvertedList/{fileName}";
+            return Ok(JsonView(true, "操作成功!", Url));
+        }
+
+
         #endregion
     }
 }

+ 474 - 0
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -1098,5 +1098,479 @@ namespace OASystem.API.Controllers
 
         #endregion
 
+
+        #region 报表/折线图统计
+        //企业利润-团组利润
+        //企业利润-会务利润
+
+        /// <summary>
+        ///  企业利润
+        ///  Details 
+        /// </summary>
+        /// <param name="_dto">团组列表请求dto</param>
+        /// <returns></returns>
+        [HttpPost("PostCorporateProfit")]
+        //[JsonConverter(typeof(DecimalConverter), 2)]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostCorporateProfit(PostCorporateProfitDto _dto)
+        {
+            #region  参数验证
+            if (_dto.UserId < 1) return Ok(JsonView(false, "员工Id为空"));
+            if (_dto.PageId < 1) _dto.PageId = 38; //团组报表页面Id
+            if (_dto.StatisticsType > 2 && _dto.StatisticsType < 1) return Ok(JsonView(false, "请输入有效的StatisticsType参数,1 月份 2 季度"));
+            if (_dto.BusinessType > 3 && _dto.BusinessType < 1) return Ok(JsonView(false, "请输入有效的BusinessType参数,1 所有 2 团组 3 会务"));
+
+            PageFunAuthViewBase pageFunAuthView = new PageFunAuthViewBase();
+            #region 页面操作权限验证
+            //pageFunAuthView = await GeneralMethod.PostUserPageFuncDatas(_dto.UserId, _dto.PageId);
+
+            //if (pageFunAuthView.CheckAuth == 0) return Ok(JsonView(false, "您没有查看权限"));
+            #endregion
+
+            string sqlWhere = string.Empty;
+
+            //起止时间
+            string beginDt = $"{_dto.Year}-01-01 00:00";
+            string endDt = $"{_dto.Year}-12-31 59:59";
+
+            sqlWhere = string.Format(@$" Where Isdel = 0 And CreateTime Between {beginDt} And {endDt}");
+
+            //业务类型
+            List<int> groupTypeId = new List<int>();
+            if (_dto.BusinessType == 2) //团组
+            {
+                groupTypeId.AddRange(new List<int>() {
+                    38,   //  政府团
+                    39,   //  企业团
+                    40,   //  散客团
+                    1048  // 高校团
+                });
+            }
+            else if (_dto.BusinessType == 3) //会务
+            {
+                groupTypeId.AddRange(new List<int>() {
+                   102,   // 未知
+                   248,   // 非团组
+                   302,   // 成都-会务活动
+                   691,   // 四川-会务活动
+                   762,   // 四川-赛事项目收入
+                   1047   // 成都-赛事项目收入
+                });
+            }
+
+            if (groupTypeId.Count > 0 )
+            {
+                sqlWhere += string.Format(@$" And TeamDid In ({string.Join(',', groupTypeId)})");
+            }
+
+            string sql = string.Format(@$"Select * From Grp_DelegationInfo {sqlWhere}");
+
+            var groupInfos = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql).ToListAsync();
+
+            if (groupInfos.Count < 1) return Ok(JsonView(false, "暂无相关团组!"));
+
+            List<int> diIds = groupInfos.Select(it => it.Id).ToList();
+
+            List<CorporateProfit> corporateProfits = await CorporateProfit(diIds);
+
+
+
+            return Ok(JsonView(true));
+            #endregion
+
+        }
+
+        /// <summary>
+        /// 计算团组利润
+        /// </summary>
+        /// <param name="diIds"></param>
+        /// <returns></returns>
+        private async Task<List<CorporateProfit>> CorporateProfit(List<int> diIds)
+        {
+            List<CorporateProfit> corporateProfits = new List<CorporateProfit>();
+            if (diIds.Count < 1)
+            {
+                return corporateProfits;
+            }
+
+            #region 计算团组利润
+
+            /* 
+            * 团组报表计算方式
+            * 当前总支出 = 团组支出.Sum() + 超支费用.Sum()
+            * 应收金额 = 应收表.Sum()
+            * 已收金额 = 已收表.Sum()
+            * 应收利润(应收-支出) = 应收金额 - 收款退还 - 当前总支出
+            * 已收利润(已收-支出) = 已收金额 - 收款退还 - 当前总支出
+            * 
+            */
+
+
+            string diIdStr = string.Join(",", diIds);
+
+            string sql = string.Format(@$"Select * From Grp_DelegationInfo Where Isdel = 0 And Id In ({diIdStr})");
+            var groupInfos = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(sql).ToListAsync();
+
+            #region 费用类型 币种,转账,客户信息
+
+            List<Sys_SetData> _setDatas = await _sqlSugar.Queryable<Sys_SetData>().Where(it => it.IsDel == 0).ToListAsync();
+            var _clientDatas = await _sqlSugar.Queryable<Crm_DeleClient>().Where(it => it.IsDel == 0).ToListAsync();
+
+            #endregion
+
+            foreach (var _diId in diIds)
+            {
+
+                List<ExpenditureInfo> expenditureInfos = new List<ExpenditureInfo>();
+
+                #region 团组收入
+
+                /*
+                 * 应收报表
+                 */
+                decimal frTotalAmount = 0.00M;//应收总金额
+                string _frSql = string.Format(@"Select fr.Id,fr.Diid,fr.PriceName,fr.Price,fr.Count,fr.Unit,fr.Currency,
+										        sd.Name As CurrencyCode,sd.Remark As CurrencyName,fr.Rate,fr.ItemSumPrice,fr.CreateTime
+										        From Fin_ForeignReceivables fr
+										        Left Join Sys_SetData sd On fr.Currency = sd.Id
+										        Where fr.IsDel = 0 And fr.Diid = {0} Order By CreateTime", _diId);
+                List<Gsd_ForeignReceivablesView> _frViews = await _sqlSugar.SqlQueryable<Gsd_ForeignReceivablesView>(_frSql).ToListAsync();
+                frTotalAmount = _frViews.Sum(it => it.ItemSumPrice);
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "应收项", Amount = frTotalAmount });
+
+                /*
+                 * 已收报表
+                 */
+                decimal prTotalAmount = 0.00M;//已收总金额
+                string _prSql = string.Format(@"Select pr.Id,pr.Diid,pr.SectionTime As SectionTimeDt,pr.Price,pr.Currency,
+										        sd1.Name As CurrencyCode,sd1.Remark As CurrencyName,pr.Client,
+										        pr.ReceivablesType,sd2.Name As ReceivablesTypeName,pr.Remark,pr.CreateTime
+										        From Fin_ProceedsReceived  pr
+										        Left Join Sys_SetData sd1 On pr.Currency = sd1.Id
+										        Left Join Sys_SetData sd2 On pr.ReceivablesType = sd2.Id
+										        Where pr.IsDel = 0 and pr.Diid = {0} Order By CreateTime", _diId);
+                List<Gsd_ProceedsReceivedView> _prViews = await _sqlSugar.SqlQueryable<Gsd_ProceedsReceivedView>(_prSql).ToListAsync();
+                prTotalAmount = _prViews.Sum(it => it.Price);
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "已收项", Amount = prTotalAmount });
+
+                /*
+                 * 超支费用 
+                 */
+                decimal exTotalAmount = 0.00M;
+                string _ecSql = string.Format(@"Select gec.Id As GECId,gec.DiId As GECDiId,gec.PriceName,ccp.PayMoney,sd1.Name As PaymentCurrency,
+													   ccp.RMBPrice As CNYPrice,ccp.DayRate,ccp.Payee,ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,
+													   sd3.Name As CardType,ccp.IsPay,u.CnName As Applicant,gec.CreateTime
+												From OA2023DB.dbo.Fin_GroupExtraCost gec
+												Left Join Grp_CreditCardPayment ccp On gec.Id = ccp.CId
+                                                Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
+                                                Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id 
+                                                Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
+                                                Left Join Sys_Users u On ccp.CreateUserId = u.Id
+												Where ccp.IsDel = 0 And ccp.CTable = 1015 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And ccp.DiId = {0} Order By CreateTime", _diId);
+
+                List<Gsd_ExtraCostsView> _ExtraCostsViews = await _sqlSugar.SqlQueryable<Gsd_ExtraCostsView>(_ecSql).ToListAsync();
+                exTotalAmount = _ExtraCostsViews.Sum(it => it.CNYPrice);
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "超支费用", Amount = exTotalAmount });
+
+                /*
+                 * 收款退还
+                 */
+                decimal promTotalAmount = 0.00M;// 收款退还总金额
+                List<Gsd_PaymentRefundAndOtherMoneyView> _promView = new List<Gsd_PaymentRefundAndOtherMoneyView>();
+
+                //删除了  And prom.PriceType = 1
+                string _ropSql = string.Format(@"Select u.CnName As Appliction,prom.Id As PrId,prom.DiId As PrDiId,prom.Price As PrPrice,
+										         prom.PriceName AS PrPriceName,prom.CurrencyId As PrCurrencyId,
+										         prom.PayType As PrPayType,prom.PriceType As PrPriceType,ccp.*,prom.CreateTime As PrCreateTime
+										         From Fin_PaymentRefundAndOtherMoney prom
+										         Left Join Grp_CreditCardPayment ccp On prom.DiId = ccp.DIId And prom.Id = ccp.CId
+										         Left Join Sys_Users u On ccp.CreateUserId = u.Id
+										         Where prom.IsDel = 0  And prom.PayType = 1 And ccp.CTable = 285
+										         And ccp.IsAuditGM = 1 And ccp.IsPay = 1
+										         And prom.DiId = {0} Order By PrCreateTime", _diId);
+                var _promDatas = await _sqlSugar.SqlQueryable<Gsd_PaymentRefundAndOtherMoneyDataSource1View>(_ropSql).ToListAsync();
+
+                foreach (var ropItem in _promDatas)
+                {
+                    string thisCueencyCode = "Unknown";
+                    string thisCueencyName = "Unknown";
+                    var currency = _setDatas.Where(it => it.Id == ropItem.PaymentCurrency).FirstOrDefault();
+                    if (currency != null)
+                    {
+                        thisCueencyCode = currency.Name;
+                        thisCueencyName = currency.Remark;
+                    }
+
+                    string orbitalPrivateTransferStr = "Unknown";
+                    var orbitalPrivateTransfer = _setDatas.Where(it => it.Id == ropItem.OrbitalPrivateTransfer).FirstOrDefault();
+                    if (orbitalPrivateTransfer != null)
+                    {
+                        orbitalPrivateTransferStr = orbitalPrivateTransfer.Name;
+                    }
+
+                    string payStr = "Unknown";
+                    var pay = _setDatas.Where(it => it.Id == ropItem.PayDId).FirstOrDefault();
+                    if (pay != null)
+                    {
+                        payStr = pay.Name;
+                    }
+
+                    Gsd_PaymentRefundAndOtherMoneyView gsd_PaymentRefund = new Gsd_PaymentRefundAndOtherMoneyView()
+                    {
+                        Id = ropItem.Id,
+                        DiId = ropItem.DIId,
+                        PriceName = ropItem.PrPriceName,
+                        PayCurrencyCode = thisCueencyCode,
+                        PayCurrencyName = thisCueencyName,
+                        Price = ropItem.PrPrice,
+                        CNYPrice = ropItem.RMBPrice,
+                        ThisRate = ropItem.DayRate,
+                        Payee = ropItem.Payee,
+                        PayTime = ropItem.AuditGMDate,
+                        OrbitalPrivateTransfer = ropItem.OrbitalPrivateTransfer,
+                        PayType = payStr,
+                        IsPay = ropItem.IsPay,
+                        Applicant = ropItem.Appliction
+
+                    };
+
+                    _promView.Add(gsd_PaymentRefund);
+                }
+
+                promTotalAmount = _promView.Sum(it => it.CNYPrice);
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "收款退还", Amount = promTotalAmount });
+                #endregion
+
+                #region 团组支出
+                GroupExpenditureView _geView = new GroupExpenditureView();
+
+                #region 酒店预定费用
+                List<GroupHotelFeeView> groupHotelFeeViews = new List<GroupHotelFeeView>();
+
+                string hotelFeeSql = string.Format(@"Select hr.Id As HrId,hr.DiId As HrDiId,hr.City,hr.HotelName,hr.CheckInDate,hr.CheckOutDate,
+                                                     sd1.Name As PaymentCurrency,hr.SingleRoomPrice,hr.SingleRoomCount,hr.DoubleRoomPrice,
+                                                     hr.DoubleRoomCount,hr.SuiteRoomPrice,hr.SuiteRoomCount,hr.OtherRoomPrice,hr.OtherRoomCount,
+                                                     hr.BreakfastPrice,sd4.Name As BreakfastCurrency,hr.Isoppay,hr.GovernmentRent,
+                                                     sd5.Name As GovernmentRentCurrency,hr.CityTax,sd6.Name As CityTaxCurrency,
+                                                     ccp.PayMoney,ccp.RMBPrice As CNYPrice,ccp.DayRate,ccp.Payee,ccp.OrbitalPrivateTransfer,
+                                                     sd2.Name As PayWay,sd3.Name As CardType,ccp.IsPay,u.CnName As Applicant
+                                                     From Grp_HotelReservations  hr
+                                                     Left Join Grp_CreditCardPayment ccp On hr.Id = ccp.CId
+                                                     Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
+                                                     Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
+                                                     Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
+                                                     Left Join Sys_Users u On ccp.CreateUserId = u.Id
+                                                     Left Join Sys_SetData sd4 On hr.BreakfastCurrency = sd4.Id
+                                                     Left Join Sys_SetData sd5 On hr.GovernmentRentCurrency = sd5.Id
+                                                     Left Join Sys_SetData sd6 On hr.CityTaxCurrency = sd6.Id
+                                                     Where hr.IsDel = 0 And ccp.IsDel = 0 And ccp.CTable = 76 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And hr.DiId = {0} 
+                                                     Order By CheckInDate Asc", _diId);
+
+                groupHotelFeeViews = await _sqlSugar.SqlQueryable<GroupHotelFeeView>(hotelFeeSql).ToListAsync();
+
+                decimal HotelCNYTotalPrice = groupHotelFeeViews.Sum(it => it.CNYPrice);
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "酒店预定", Amount = HotelCNYTotalPrice });
+                #endregion
+
+                #region 地接费用
+
+                List<GroupCTGGRFeeView> groupCTGGRFeeViews = new List<GroupCTGGRFeeView>();
+
+                string CTGGRFeeSql = string.Format(@"Select ctggr.Id As CTGGRId,ctggr.DiId As CTGGRDiId,ctggr.Area,ctggrc.*,ctggrc.Price As PayMoney,
+                                                     sd2.name As PaymentCurrency,ccp.PayPercentage,
+                                                     (ctggrc.Price / (ccp.PayPercentage / 100)) As AmountPaid,
+                                                     (ctggrc.Price / (ccp.PayPercentage / 100) - ctggrc.Price) As BalancePayment,
+                                                     ccp.DayRate,(ctggrc.Price * ccp.DayRate)  As CNYPrice,ccp.Payee,ccp.AuditGMDate,
+                                                     ccp.OrbitalPrivateTransfer,sd1.Name As PayWay,ccp.IsPay,u.CnName As Applicant,ctggr.CreateTime
+                                                     From Grp_CarTouristGuideGroundReservations ctggr
+                                                     Left Join ( Select cggrc.CTGGRId,sd1.Name As PriceName,cggrc.Price,sd2.Name As PriceCurrency,
+                                                                     cggrc.PriceContent
+                                                             From Grp_CarTouristGuideGroundReservationsContent cggrc
+                                                             Left Join Sys_SetData sd1 On cggrc.SId = sd1.Id
+                                                             Left Join Sys_SetData sd2 On cggrc.Currency = sd2.Id
+                                                             Where cggrc.ISdel = 0 And cggrc.Price != 0.00 
+                                                             ) ctggrc On ctggr.Id = ctggrc.CTGGRId 
+                                                     Left Join Grp_CreditCardPayment ccp On ccp.IsDel = 0  And ccp.CTable = 79 And ctggr.Id = ccp.CId
+                                                     Left Join Sys_SetData sd1 On ccp.PayDId = sd1.Id
+                                                     Left Join Sys_SetData sd2 On ccp.PaymentCurrency = sd2.Id
+                                                     Left Join Sys_Users u On ccp.CreateUserId = u.Id
+                                                     Where ctggr.IsDel = 0 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And ctggr.DiId = {0}
+                                                     Order By CreateTime", _diId);
+
+                groupCTGGRFeeViews = await _sqlSugar.SqlQueryable<GroupCTGGRFeeView>(CTGGRFeeSql).ToListAsync();
+
+                decimal CTGGRCNYTotalPrice = groupCTGGRFeeViews.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00")));
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "地接", Amount = CTGGRCNYTotalPrice });
+                #endregion
+
+                #region 机票预订费用
+
+                List<GroupAirFeeView> groupAirFeeViews = new List<GroupAirFeeView>();
+                string groupAirFeeSql = string.Format(@"Select atr.Id As AirId,atr.DIId As AirDiId,atr.FlightsCode,atr.FlightsCity,sd4.Name As AirTypeName,
+                                                        atr.FlightsDate,atr.FlightsTime,atr.ClientName,atr.ClientNum,ccp.PayMoney,
+                                                        sd1.Name As PayMoneyCurrency,ccp.RMBPrice As CNYPrice,ccp.DayRate,ccp.Payee,ccp.AuditGMDate,
+                                                        ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,sd3.Name As CardType,ccp.IsPay,u.CnName As Applicant,atr.CreateTime
+                                                        From Grp_AirTicketReservations atr
+                                                        Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 85 And atr.Id = ccp.CId
+                                                        Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
+                                                        Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
+                                                        Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
+                                                        Left Join Sys_SetData sd4 On atr.CType = sd4.Id
+                                                        Left Join Sys_Users u On ccp.CreateUserId = u.Id
+                                                        Where atr.IsDel = 0 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And atr.DiId = {0} Order By CreateTime", _diId);
+                groupAirFeeViews = await _sqlSugar.SqlQueryable<GroupAirFeeView>(groupAirFeeSql).ToListAsync();
+
+                decimal AirCNYTotalPrice = groupAirFeeViews.Sum(it => it.CNYPrice);
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "机票预订", Amount = AirCNYTotalPrice });
+                #endregion
+
+                #region 签证费用
+
+                List<GroupVisaFeeView> groupVisaFeeViews = new List<GroupVisaFeeView>();
+                string groupVisaFeeSql = string.Format(@"Select vi.Id As VisaId,vi.DIId As VisaDiId,vi.VisaClient,ccp.PayMoney,sd1.Name As PayMoneyCurrency,
+                                                         ccp.DayRate,ccp.Payee,ccp.AuditGMDate,ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,
+                                                         sd3.Name As CardTypeName,ccp.IsPay,u.CnName As Applicant,vi.CreateTime
+                                                         From Grp_VisaInfo vi
+                                                         Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 80 And vi.Id = ccp.CId
+                                                         Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
+                                                         Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
+                                                         Left Join Sys_SetData sd3 On ccp.CTDId = sd3.Id
+                                                         Left Join Sys_Users u On ccp.CreateUserId = u.Id
+                                                         Where vi.IsDel = 0 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And vi.DIId = {0} Order By CreateTime", _diId);
+
+                groupVisaFeeViews = await _sqlSugar.SqlQueryable<GroupVisaFeeView>(groupVisaFeeSql).ToListAsync();
+
+                decimal VisaCNYTotalPirce = groupVisaFeeViews.Sum(it => it.PayMoney);
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "签证", Amount = VisaCNYTotalPirce });
+                #endregion
+
+                #region 邀请/公务活动  CTable = 81
+
+                List<GroupInvitationalFeeView> groupInvitationalFeeViews = new List<GroupInvitationalFeeView>();
+                string groupInvitationalFeeSql = string.Format(@"Select ioa.Id As IOAId,ioa.DiId As IOADiId,ioa.InviterArea,ioa.Inviter,ioa.InviteTime,
+                                                                 ioa.InviteCost,sd3.Name As InviteCurrency,ioa.SendCost,sd4.Name As SendCurrency,ioa.EventsCost,
+                                                                 sd5.Name As EventsCurrency,ioa.TranslateCost,sd6.Name As TranslateCurrency,ccp.PayMoney,
+                                                                 sd7.Name As PaymentCurrency,ccp.RMBPrice As CNYPrice,ccp.Payee,ccp.AuditGMDate,
+                                                                 ccp.OrbitalPrivateTransfer,sd2.Name As PayWay,ccp.IsPay,u.CnName As Applicant,ioa.CreateTime
+                                                                 From  Grp_InvitationOfficialActivities ioa
+                                                                 Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 81 And ioa.Id = ccp.CId
+                                                                 Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
+                                                                 Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
+                                                                 Left Join Sys_SetData sd3 On ioa.InviteCurrency = sd3.Id
+                                                                 Left Join Sys_SetData sd4 On ioa.SendCurrency = sd4.Id
+                                                                 Left Join Sys_SetData sd5 On ioa.EventsCurrency = sd5.Id
+                                                                 Left Join Sys_SetData sd6 On ioa.TranslateCurrency = sd6.Id
+                                                                 Left Join Sys_SetData sd7 On ccp.PaymentCurrency = sd7.Id
+                                                                 Left Join Sys_Users u On ccp.CreateUserId = u.Id
+                                                                 Where ioa.IsDel = 0 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And  ioa.Diid = {0} Order By CreateTime", _diId);
+
+                groupInvitationalFeeViews = await _sqlSugar.SqlQueryable<GroupInvitationalFeeView>(groupInvitationalFeeSql).ToListAsync();
+
+                decimal InvitationalCNYTotalPrice = groupInvitationalFeeViews.Sum(it => it.CNYPrice);
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "邀请/公务活动", Amount = InvitationalCNYTotalPrice });
+                #endregion
+
+                #region 保险费用
+                List<GroupInsuranceFeeView> groupInsuranceFeeViews = new List<GroupInsuranceFeeView>();
+                string groupInsuranceFeeSql = string.Format(@"Select ic.Id As InsuranceId,ic.Diid As InsuranceDiId,ClientName,ccp.PayMoney,ccp.RMBPrice As CNYPrice,
+                                                              sd1.Name As PayMoneyCurrency,ccp.Payee,ccp.AuditGMDate,ccp.OrbitalPrivateTransfer,
+                                                              sd2.Name As PayWay,ccp.IsPay,u.CnName As Applicant,ic.CreateTime
+                                                              From Grp_Customers ic
+                                                              Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 82 And ic.Id = ccp.CId
+                                                              Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
+                                                              Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
+                                                              Left Join Sys_Users u On ccp.CreateUserId = u.Id
+                                                              Where ic.IsDel = 0 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And ic.DiId = {0} Order By CreateTime", _diId);
+                groupInsuranceFeeViews = await _sqlSugar.SqlQueryable<GroupInsuranceFeeView>(groupInsuranceFeeSql).ToListAsync();
+
+                decimal InsuranceCNYTotalPrice = groupInsuranceFeeViews.Sum(it => it.CNYPrice);
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "保险费用", Amount = InsuranceCNYTotalPrice });
+                #endregion
+
+                #region 其他款项费用  98
+                List<GroupDecreaseFeeView> groupDecreaseFeeViews = new List<GroupDecreaseFeeView>();
+                string groupDecreaseFeeSql = string.Format(@"Select dp.Id As DPId,dp.DiId As DPDiId,dp.PriceName,ccp.PayMoney,sd1.Name As PayMoneyCurrency,
+                                                              (((ccp.PayMoney * ccp.DayRate) / ccp.PayPercentage) * 100) As CNYPrice,   
+                                                             ccp.DayRate,ccp.Payee,ccp.AuditGMDate,ccp.OrbitalPrivateTransfer,
+                                                             sd2.Name As PayWay,ccp.IsPay,u.CnName As Applicant,dp.CreateTime
+                                                             From Grp_DecreasePayments dp
+                                                             Left Join Grp_CreditCardPayment ccp On ccp.isdel = 0 And ccp.CTable = 98 And dp.Id = ccp.CId
+                                                             Left Join Sys_SetData sd1 On ccp.PaymentCurrency = sd1.Id
+                                                             Left Join Sys_SetData sd2 On ccp.PayDId = sd2.Id
+                                                             Left Join Sys_Users u On ccp.CreateUserId = u.Id
+                                                             Where dp.IsDel = 0 And ccp.Ctable = 98 And ccp.IsAuditGM = 1 And ccp.IsPay = 1 And dp.Diid = {0} 
+                                                             Order By CreateTime", _diId);
+                groupDecreaseFeeViews = await _sqlSugar.SqlQueryable<GroupDecreaseFeeView>(groupDecreaseFeeSql).ToListAsync();
+
+                decimal DecreaseCNYTotalPrice = groupDecreaseFeeViews.Sum(it => Convert.ToDecimal(it.CNYPrice.ToString("#0.00")));
+
+                expenditureInfos.Add(new ExpenditureInfo() { ItemName = "其他款项", Amount = DecreaseCNYTotalPrice });
+                #endregion
+
+                #endregion
+
+                /* 
+                 * 团组报表计算方式
+                 * 当前总支出 = 团组支出.Sum() + 超支费用.Sum()
+                 * 应收金额 = 应收表.Sum()
+                 * 已收金额 = 已收表.Sum()
+                 * 应收利润(应收-支出) = 应收金额 - 收款退还 - 当前总支出
+                 * 已收利润(已收-支出) = 已收金额 - 收款退还 - 当前总支出
+                 * 
+                 */
+                decimal _totalExpenditure = 0.00M; //总支出
+                decimal _amountReceivable = 0.00M; //应收金额
+                decimal _amountReceived = 0.00M;   //已收金额
+                decimal _receivableProfit = 0.00M; //应收利润
+                decimal _receivedProfit = 0.00M;   //已收利润
+                _totalExpenditure = HotelCNYTotalPrice + CTGGRCNYTotalPrice + AirCNYTotalPrice + VisaCNYTotalPirce + InvitationalCNYTotalPrice +
+                                    InsuranceCNYTotalPrice + DecreaseCNYTotalPrice + exTotalAmount;
+                _amountReceivable = frTotalAmount;
+                _amountReceived = prTotalAmount;
+                _receivableProfit = _amountReceivable - promTotalAmount - _totalExpenditure;
+                _receivedProfit = _amountReceived - promTotalAmount - _totalExpenditure;
+
+                var groupInfo = groupInfos.Find(it => it.Id == _diId);
+                corporateProfits.Add(new CorporateProfit()
+                {
+                    DiId = _diId,
+                    TeamName = groupInfo?.TeamName ?? "Unkwnon",
+                    CreateDt = groupInfo?.CreateTime.ToString("yyyy-MM-dd") ?? "Unkwnon",
+                    TotalExpenditure = _totalExpenditure,
+                    ExpenditureItem = expenditureInfos,
+                    AmountReceivable = _amountReceivable,
+                    AmountReceived = _amountReceived,
+                    ReceivableProfit = _receivableProfit,
+                    ReceivedProfit = _receivedProfit,
+                });
+
+            }
+
+            #endregion
+
+
+            return corporateProfits;
+        }
+
+
+
+
+        //未来预测-地区接团/出团量
+        //未来预测-地区酒店预订量
+        //未来预测-地区机票预订量
+        //未来预测-地区车辆预订量
+
+        #endregion
+
     }
 }

+ 10 - 2
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -239,13 +239,21 @@ namespace OASystem.API.Controllers
 
             try
             {
+                int messageUnReadCount = 0;
+                int announcementUnReadCount = 0;
                 var data = await _messageRep.GetUnReadCount(dto.UserId);
                 if (data != null)
                 {
-                    return Ok(JsonView(true, "操作成功!", data));
+                    messageUnReadCount = data;
+
+                }
+                var data1 = await _messageRep.GetAnnouncementUnReadCount(dto.UserId);
+                if (data1 != null)
+                {
+                    announcementUnReadCount = data1;
                 }
 
-                return Ok(JsonView(false, "操作失败!"));
+                return Ok(JsonView(true, "操作成功!", new { messageUnReadCount = messageUnReadCount, announcementUnReadCount = announcementUnReadCount }));
             }
             catch (Exception ex)
             {

+ 22 - 0
OASystem/OASystem.Api/OAMethodLib/GeneralMethod.cs

@@ -1348,6 +1348,28 @@ namespace OASystem.API.OAMethodLib
         }
 
 
+        #endregion
+
+        #region 日期 格式转换 
+
+        /// <summary>
+        /// 验证数字字符串
+        /// </summary>
+        /// <param name="str"></param>
+        /// <returns></returns>
+        public static string ConvertToDatetime(this string str)
+        {
+            if (!string.IsNullOrEmpty(str))
+            {
+                DateTime currentDate = Convert.ToDateTime(str);
+
+                return $"{currentDate.Year}年{currentDate.Month}月{currentDate.Day}日";
+            }
+
+            return "";
+        }
+
+
         #endregion
     }
 }

+ 12 - 0
OASystem/OASystem.Domain/Dtos/Groups/InvertedListDto.cs

@@ -38,4 +38,16 @@ namespace OASystem.Domain.Dtos.Groups
         /// </summary>
         public int PortType { get; set; }
     }
+
+    /// <summary>
+    /// 倒推表 Dto
+    /// File Download
+    /// </summary>
+    public class InvertedListFileDownloadDto : PortDtoBase
+    {
+        /// <summary>
+        /// 请求类型
+        /// </summary>
+        public int DiId { get; set; }
+    }
 }

+ 23 - 0
OASystem/OASystem.Domain/Dtos/Statistics/GroupStatementDto.cs

@@ -41,4 +41,27 @@ namespace OASystem.Domain.Dtos.Statistics
         public int DiId { get; set; }
     }
 
+    /// <summary>
+    /// 企业利润请求dto
+    /// </summary>
+    public class PostCorporateProfitDto : UserPageFuncDtoBase
+    {
+        /// <summary>
+        /// 年份
+        /// </summary>
+        public string Year { get; set; }
+
+        /// <summary>
+        /// 业务类型
+        /// 1 所有 2 团组 3 会务 
+        /// </summary>
+        public int BusinessType { get; set; }
+
+        /// <summary>
+        /// 统计类型
+        /// 1 月份 2 季度 
+        /// </summary>
+        public int StatisticsType { get; set; }
+    }
+
 }

+ 7 - 0
OASystem/OASystem.Domain/ViewModels/LoginView.cs

@@ -29,4 +29,11 @@ public class LoginView
     /// 未读消息条数
     /// </summary>
     public int UnReadCount { get; set; }
+
+
+    /// <summary>
+    /// 公告未读
+    /// 未读消息条数
+    /// </summary>
+    public int AnnouncementUnReadCount { get; set; }
 }

+ 63 - 0
OASystem/OASystem.Domain/ViewModels/Statistics/CorporateProfit.cs

@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Statistics
+{
+    /// <summary>
+    /// 企业利润报表
+    /// </summary>
+    public class CorporateProfit
+    {
+        public int DiId { get; set; }
+
+        public string TeamName { get; set; }
+
+        public string CreateDt { get; set; }
+
+        /// <summary>
+        /// 总支出
+        /// </summary>
+        public decimal TotalExpenditure { get; set; }
+
+        /// <summary>
+        /// 支出Item
+        /// </summary>
+        public List<ExpenditureInfo> ExpenditureItem { get; set; }
+
+        /// <summary>
+        /// 应收金额
+        /// </summary>
+        public decimal AmountReceivable { get; set; }
+
+        /// <summary>
+        /// 已收金额
+        /// </summary>
+        public decimal AmountReceived { get; set; }
+
+        /// <summary>
+        /// 应收利润
+        /// </summary>
+        public decimal ReceivableProfit { get; set; }
+
+        /// <summary>
+        /// 已收利润
+        /// </summary>
+        public decimal ReceivedProfit { get; set; }
+    }
+
+    public class ExpenditureInfo
+    {
+        /// <summary>
+        /// 名称
+        /// </summary>
+        public string ItemName { get; set; }
+
+        /// <summary>
+        /// 金额
+        /// </summary>
+        public decimal Amount { get; set; }
+    }
+}

+ 4 - 3
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -176,15 +176,16 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// </summary>
         /// <param name="teamName"></param>
         /// <returns></returns>
-        public string FormartTeamName( string teamName) 
+        public string FormartTeamName(string teamName) 
         {
             string str = "";
             if (!string.IsNullOrEmpty(teamName))
             {
-                List<string> searchreplaces = new List<string>() { "|", "、", " ", "/", ",", "," };
+                str = teamName;
+                List<string> searchreplaces = new List<string>() { "|", " ", "/", ",", "," };
                 foreach (var item in searchreplaces)
                 {
-                    str = teamName.Replace(item, "、");
+                    str = str.Replace(item, "、");
                 }
             }
             return str.Trim();

+ 2 - 3
OASystem/OASystem.Infrastructure/Repositories/Groups/HotelPriceRepository.cs

@@ -795,6 +795,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         /// <returns></returns>
         public async Task<Result> _AddOrEdit(HotelReservationsAddOrEditDto _dto)
         {
+            _result.Code = -1;
             int portType = _dto.PortType;
             if (portType == 1 || portType == 2 || portType == 3)
             {
@@ -849,7 +850,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 decimal currencyRate = 0.00M;
                 if (_CreditCardPayment.PayMoney != 0)
                 {
-                    if(_CreditCardPayment.PaymentCurrency <= 0)
+                    if(_CreditCardPayment.PaymentCurrency < 1)
                     {
                         _result.Msg = "请选择付款币种!";
                         return _result;
@@ -1043,8 +1044,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 {
                     _result.Msg = "请输入正确的数据Id!";
                 }
-
-
             }
             else
             {

+ 14 - 13
OASystem/OASystem.Infrastructure/Repositories/Groups/InvertedListRepository.cs

@@ -53,7 +53,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
             _result.Code = 0;
             _result.Msg = "操作成功!";
             _result.Data = new {
-                groupData = groupData1,
+                groupData = groupData,
                 officialTypeData = officialTypeData,
                 visaTypeData = visaTypeData
             };
@@ -84,7 +84,9 @@ namespace OASystem.Infrastructure.Repositories.Groups
             var info = await _sqlSugar.SqlQueryable<InvertedListInfoView>(sql).FirstAsync();
 
             if (info == null) {
+
                 info = new InvertedListInfoView();
+                info.IsQuery = true;
 
                 var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == diId).FirstAsync();
                 if (groupInfo == null)
@@ -126,11 +128,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 return _result; 
             }
 
-            info.IsQuery = true;
             int ilId = info.Id;
 
             string visaSql = string.Format(@$"Select * From Grp_InvertedListVisaCountry Where Isdel={0} And ILId = {ilId}");
-            var visaCountryInfo = await _sqlSugar.SqlQueryable<VisaCountryInfo>(sql).ToListAsync();
+            var visaCountryInfo = await _sqlSugar.SqlQueryable<VisaCountryInfo>(visaSql).ToListAsync();
 
             info.VisaCountryData = visaCountryInfo;
             _result.Data = info;
@@ -167,7 +168,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
             }
 
             var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == diId).FirstAsync();
-            if (groupInfo != null)
+            if (groupInfo == null)
             {
                 _result.Msg = @$"团组数据不存在,不可创建!";
                 return _result;
@@ -200,14 +201,14 @@ namespace OASystem.Infrastructure.Repositories.Groups
              * 默认步骤所需提前天数
              * A 自然日 B 工作日
              */
-            int approvalData_advanceDays = 60,     //报批资料准备
-                approval_advanceDays = 45,         //报批
-                IssueApproval_advanceDays = 33,    //出批件
-                ApplyPassport_advanceDays = 30,    //办护照
-                VisaInformation_advanceDays = 16,  //签证资料准备
-                sendVisa_advanceDays = 12,         //送签
-                issueVisa_advanceDays = 5,         //出签
-                preTripMeeting_advanceDays = 3,    //行前会
+            int approvalData_advanceDays = -60,     //报批资料准备
+                approval_advanceDays = -45,         //报批
+                IssueApproval_advanceDays = -33,    //出批件
+                ApplyPassport_advanceDays = -30,    //办护照
+                VisaInformation_advanceDays = -16,  //签证资料准备
+                sendVisa_advanceDays = -12,         //送签
+                issueVisa_advanceDays = -5,         //出签
+                preTripMeeting_advanceDays = -3,    //行前会
                 airportdDropOff_advanceDays = 0;   //送机
 
             var info = new Grp_InvertedList() { 
@@ -249,7 +250,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 });
             }
 
-            int add2 = await _sqlSugar.Insertable<Grp_InvertedList>(info).ExecuteReturnIdentityAsync();
+            int add2 = await _sqlSugar.Insertable<Grp_InvertedListVisaCountry>(_InvertedListVisaCountries).ExecuteReturnIdentityAsync();
 
             _sqlSugar.CommitTran();
             _result.Code = 0;

+ 91 - 86
OASystem/OASystem.Infrastructure/Repositories/Groups/TeamRateRepository.cs

@@ -455,7 +455,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
             #region 团组汇率
 
-
             foreach (TeamRateInfoView item in teamRateInfo)
             {
                 TeamRateModelView teamRateModelInfo = new TeamRateModelView();
@@ -463,39 +462,104 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 teamRateModelInfo.Id = item.Id;
                 teamRateModelInfo.CTableId = item.CTable;
                 teamRateModelInfo.CTableName = item.Name;
-                List<TeamRateDescView> teamRateDescViews = new List<TeamRateDescView>();
+                //拆分remark里的汇率
+                teamRateModelInfo.TeamRates = GroupCurrencySplittings(item.Remark);
+                teamRateModels.Add(teamRateModelInfo);
+            }
 
-                #region 拆分remark里的汇率
+            #endregion
 
-                if (item.Remark.Contains("|"))
+            return teamRateModels;
+
+        }
+
+        /// <summary>
+        /// 团组汇率币种拆分
+        /// 团组币种按指定格式拆分 返回集合
+        /// </summary>
+        /// <param name="currStr"></param>
+        /// <returns></returns>
+        public  List<TeamRateDescView> GroupCurrencySplittings(string currStr)
+        {
+            List<TeamRateDescView> _view = new List<TeamRateDescView>();
+
+            if (!string.IsNullOrEmpty(currStr))
+            {
+                if (currStr.Contains("|"))
                 {
-                    string[] currencyArr = item.Remark.Split("|");
+                    string[] currencyArr = currStr.Split("|");
                     foreach (string currency in currencyArr)
                     {
-                        string[] currency1 = currency.Split(":");
-                        string[] currency2 = currency1[0].Split("(");
-
-                        TeamRateDescView rateDescView = new TeamRateDescView()
-                        {
-                            CurrencyCode = currency2[1].Replace(")", "").TrimEnd(),
-                            CurrencyName = currency2[0],
-                            Rate = decimal.Parse(currency1[1]),
-                        };
-                        teamRateDescViews.Add(rateDescView);
+                        _view.Add(GroupCurrencySplittingSingle(currency));
                     }
                 }
+                else
+                {
+                    _view.Add(GroupCurrencySplittingSingle(currStr));
+                }
+            }
 
-                #endregion
+            return _view;
+        }
 
-                teamRateModelInfo.TeamRates = teamRateDescViews;
-                teamRateModels.Add(teamRateModelInfo);
+
+        /// <summary>
+        /// 团组汇率币种拆分
+        /// 团组币种按指定格式拆分 返回集合
+        /// return TeamRateDescView
+        /// </summary>
+        /// <param name="currStr"></param>
+        /// <returns></returns>
+        public TeamRateDescView GroupCurrencySplittingSingle(string currStr)
+        {
+            TeamRateDescView _view = new TeamRateDescView();
+
+            if (!string.IsNullOrEmpty(currStr))
+            {
+                string[] currency1 = currStr.Split(":");
+                string[] currency2 = currency1[0].Split("(");
+
+                _view = new TeamRateDescView()
+                {
+                    CurrencyCode = currency2[1].Replace(")", "").TrimEnd(),
+                    CurrencyName = currency2[0],
+                    Rate = decimal.Parse(currency1[1]),
+                };
             }
 
-            #endregion
+            return _view;
+        }
 
+        /// <summary>
+        /// 团组汇率币种拆分 注意返回 实体类
+        /// 团组币种按指定格式拆分 返回集合
+        /// return TeamRateDescView
+        /// </summary>
+        /// <param name="currStr"></param>
+        /// <returns></returns>
+        public TeamRateDescAddCurrencyIdView GroupCurrencySplittingSingle(List<SetDataInfoView> currs,string currStr)
+        {
+            TeamRateDescAddCurrencyIdView _view = new TeamRateDescAddCurrencyIdView();
 
-            return teamRateModels;
+            if (!string.IsNullOrEmpty(currStr))
+            {
+                string[] currency1 = currStr.Split(":");
+                string[] currency2 = currency1[0].Split("(");
+
+                string currencyCode = currency2[1].Replace(")", "").TrimEnd();
+                SetDataInfoView dataInfoView = new SetDataInfoView();
+                dataInfoView = currs.Where(it => it.Name == currencyCode).FirstOrDefault();
+                int currencyId = currs.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
+                _view = new TeamRateDescAddCurrencyIdView()
+                {
+                    CurrencyId = dataInfoView.Id,
+                    CurrencyCode = currencyCode,
+                    CurrencyName = currency2[0],
+                    Rate = decimal.Parse(currency1[1]),
+                };
+            }
 
+            return _view;
         }
 
 
@@ -591,43 +655,13 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         string[] currencyArr = item.Remark.Split("|");
                         foreach (string currency in currencyArr)
                         {
-                            string[] currency1 = currency.Split(":");
-                            string[] currency2 = currency1[0].Split("(");
-
-                            string currencyCode = currency2[1].Replace(")", "").TrimEnd();
-                            SetDataInfoView dataInfoView = new SetDataInfoView();
-                            dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
-                            int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
-                            TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
-                            {
-                                CurrencyId = dataInfoView.Id,
-                                CurrencyCode = currencyCode,
-                                CurrencyName = currency2[0],
-                                Rate = decimal.Parse(currency1[1]),
-                            };
-                            teamRateDescViews.Add(rateDescView);
+                            teamRateDescViews.Add(GroupCurrencySplittingSingle(currencyDatas, currency));
                         }
                     }
                     else
                     {
-                        if (!string.IsNullOrEmpty(item.Remark))
-                        {
-                            string[] currency1 = item.Remark.Split(":");
-                            string[] currency2 = currency1[0].Split("(");
-
-                            string currencyCode = currency2[1].Replace(")", "").TrimEnd();
-                            SetDataInfoView dataInfoView = new SetDataInfoView();
-                            dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
-                            int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
-                            TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
-                            {
-                                CurrencyId = dataInfoView.Id,
-                                CurrencyCode = currencyCode,
-                                CurrencyName = currency2[0],
-                                Rate = decimal.Parse(currency1[1]),
-                            };
-                            teamRateDescViews.Add(rateDescView);
-                        }
+                        teamRateDescViews.Add(GroupCurrencySplittingSingle(currencyDatas, item.Remark));
+                       
                     }
 
                     #endregion
@@ -702,43 +736,14 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     string[] currencyArr = item.Remark.Split("|");
                     foreach (string currency in currencyArr)
                     {
-                        string[] currency1 = currency.Split(":");
-                        string[] currency2 = currency1[0].Split("(");
-
-                        string currencyCode = currency2[1].Replace(")", "").TrimEnd();
-                        SetDataInfoView dataInfoView = new SetDataInfoView();
-                        dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
-                        int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
-                        TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
-                        {
-                            CurrencyId = dataInfoView.Id,
-                            CurrencyCode = currencyCode,
-                            CurrencyName = currency2[0],
-                            Rate = decimal.Parse(currency1[1]),
-                        };
-                        teamRateDescViews.Add(rateDescView);
+
+                        teamRateDescViews.Add(GroupCurrencySplittingSingle(currencyDatas, currency));
                     }
                 }
                 else
                 {
-                    if (!string.IsNullOrEmpty(item.Remark))
-                    {
-                        string[] currency1 = item.Remark.Split(":");
-                        string[] currency2 = currency1[0].Split("(");
-
-                        string currencyCode = currency2[1].Replace(")", "").TrimEnd();
-                        SetDataInfoView dataInfoView = new SetDataInfoView();
-                        dataInfoView = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault();
-                        int currencyId = currencyDatas.Where(it => it.Name == currencyCode).FirstOrDefault().Id;
-                        TeamRateDescAddCurrencyIdView rateDescView = new TeamRateDescAddCurrencyIdView()
-                        {
-                            CurrencyId = dataInfoView.Id,
-                            CurrencyCode = currencyCode,
-                            CurrencyName = currency2[0],
-                            Rate = decimal.Parse(currency1[1]),
-                        };
-                        teamRateDescViews.Add(rateDescView);
-                    }
+
+                    teamRateDescViews.Add(GroupCurrencySplittingSingle(currencyDatas, item.Remark));
                 }
 
                 #endregion

+ 16 - 0
OASystem/OASystem.Infrastructure/Repositories/System/MessageRepository.cs

@@ -277,6 +277,22 @@ namespace OASystem.Infrastructure.Repositories.System
             return _unReadCount;
         }
 
+        /// <summary>
+        /// 获取公告消息消息未读消息条数
+        /// </summary>
+        /// <param name="uId">可读用户Id</param>
+        /// <returns></returns>
+        public async Task<int> GetAnnouncementUnReadCount(int userId)
+        {
+            int _unReadCount = 0;
+            string msgSqlWhere = $"Select COUNT(*) As UnreadCount From  Sys_MessageReadAuth  smra Left Join Sys_Message sm On sm.Id = smra.MsgId Where IsRead = 0 And smra.IsDel = 0 And sm.IsDel = 0  And sm.Type = 1 And ReadableUId = {userId}";
+            var _readableMsg = _sqlSugar.SqlQueryable<MessageUnreadTotalCountView>(msgSqlWhere).First();
+
+            _unReadCount = _readableMsg.UnreadCount;
+
+            return _unReadCount;
+        }
+
         /// <summary>
         /// 获取消息详细
         /// </summary>