Browse Source

1、公务出访有数据更新通知

amigotrip 7 months ago
parent
commit
0d5e96a27b

+ 12 - 10
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1732,20 +1732,24 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
         public async Task<IActionResult> OpOfficialActivities(OpOfficialActivitiesDto dto)
         {
         {
+
+            Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
+            if (groupData.Code != 0)
+            {
+                return Ok(JsonView(false, groupData.Msg));
+            }
+
             try
             try
             {
             {
-                Result groupData = await _officialActivitiesRep.OpOfficialActivities(dto);
-                if (groupData.Code != 0)
-                {
-                    return Ok(JsonView(false, groupData.Msg));
-                }
-                return Ok(JsonView(true, groupData.Msg, groupData.Data));
+                //公务出访变更发送通知
+                await AppNoticeLibrary.SendUserMsg_GroupShare_ToOP(dto.DiId, dto.CreateUserId);
             }
             }
             catch (Exception ex)
             catch (Exception ex)
             {
             {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
+                //抄送日志
             }
             }
+            return Ok(JsonView(true, groupData.Msg, groupData.Data));
+
         }
         }
         /// <summary>
         /// <summary>
         /// 上传文件
         /// 上传文件
@@ -1864,8 +1868,6 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
             }
             }
         }
         }
 
 
-
-
         /// <summary>
         /// <summary>
         /// 公务出访
         /// 公务出访
         /// 请示范例提示 
         /// 请示范例提示 

+ 81 - 20
OASystem/OASystem.Api/Controllers/StatisticsController.cs

@@ -30,6 +30,9 @@ using Microsoft.Extensions.Configuration;
 using System.Text.Json;
 using System.Text.Json;
 using OASystem.RedisRepository;
 using OASystem.RedisRepository;
 using OASystem.RedisRepository.RedisAsyncHelper;
 using OASystem.RedisRepository.RedisAsyncHelper;
+using System.Data;
+using OfficeOpenXml.Export.ToDataTable;
+using Aspose.Cells;
 
 
 namespace OASystem.API.Controllers
 namespace OASystem.API.Controllers
 {
 {
@@ -3061,28 +3064,86 @@ Left Join Sys_SetData sd2 On dfp.PriceTypeId = sd2.Id
 Where dfp.IsDel = 0 And dfp.IsPay = 1
 Where dfp.IsDel = 0 And dfp.IsPay = 1
 ",sqlWhere);//--Order By dfp.CreateTime Desc
 ",sqlWhere);//--Order By dfp.CreateTime Desc
 
 
-                RefAsync<int> total = 0;
-                var _view = await _sqlSugar.SqlQueryable<DailyFeePaymentRangeView>(sql)
-                                           //.Includes(x => x.Contents)
-                                           //.ToListAsync();
-                                           .Where(x => x.ApplicantDt >= _beginDt && x.ApplicantDt <= _endDt)
-                                           .WhereIF(dailypaymentTypeData.Count > 0,
-                                                    x => dailypaymentTypeData.Contains(x.PriceTypeId))
-                                           .OrderByDescending(x => x.ApplicantDt)
-                                           .ToPageListAsync(
-                                                pageNumber: _dto.PageIndex,
-                                                pageSize: _dto.PageSize,
-                                                totalNumber: total
-                                                );
-
-                _sqlSugar.ThenMapper(_view, x =>
+                
+                if (_dto.Type == 1) //data
                 {
                 {
-                    x.Contents = _sqlSugar.Queryable<DailyFeePaymentContentView>()
-                                          .SetContext(x1 => x1.DFPId, () => x.Id, x)
-                                          .ToList();
-                });
+                    RefAsync<int> total = 0;
+                    var _view = await _sqlSugar.SqlQueryable<DailyFeePaymentRangeView>(sql)
+                                               .Where(x => x.ApplicantDt >= _beginDt && x.ApplicantDt <= _endDt)
+                                               .WhereIF(dailypaymentTypeData.Count > 0,
+                                                        x => dailypaymentTypeData.Contains(x.PriceTypeId))
+                                               .OrderByDescending(x => x.ApplicantDt)
+                                               .ToPageListAsync(
+                                                    pageNumber: _dto.PageIndex,
+                                                    pageSize: _dto.PageSize,
+                                                    totalNumber: total
+                                                    );
+
+                    _sqlSugar.ThenMapper(_view, x =>
+                    {
+                        x.Contents = _sqlSugar.Queryable<DailyFeePaymentContentView>()
+                                              .SetContext(x1 => x1.DFPId, () => x.Id, x)
+                                              .ToList();
+                    });
+
+                    return Ok(JsonView(true, "操作成功!", _view, total));
+                }
+                else if (_dto.Type == 2) //view
+                {
+                    var _view = await _sqlSugar.SqlQueryable<ExcelView>(sql)
+                                               .Where(x => x.ApplicantDt >= _beginDt && x.ApplicantDt <= _endDt)
+                                               .WhereIF(dailypaymentTypeData.Count > 0,
+                                                        x => dailypaymentTypeData.Contains(x.PriceTypeId))
+                                               .OrderByDescending(x => x.ApplicantDt)
+                                               .ToPageListAsync(
+                                                    pageNumber: 1,
+                                                    pageSize: 99999
+                                                    ) ;
+
+                    _sqlSugar.ThenMapper(_view, x =>
+                    {
+                        x.Contents = _sqlSugar.Queryable<DailyFeePaymentContentView>()
+                                              .SetContext(x1 => x1.DFPId, () => x.Id, x)
+                                              .ToList();
+
+                        string str = "";
+                        int index = 1;
+                        foreach (var item in x.Contents)
+                        {
+                            string str1 = $"{index}、费用名称:[{item.PriceName}]   单价:[{item.Price.ToString("#0.00")}]   数量:[{item.Quantity.ToString("#0.00")}]   小计:[{item.ItemTotal.ToString("#0.00")}]   备注:[{item.Remark}]";
+
+                            if (index == x.Contents.Count) str += str1;
+                            else str += str1 + "\r\n";
+                            index++;
+                        }
+                        x.ContentStr = str;
+                    });
+
+                    if (_view.Count > 0 )
+                    {
+                        //DataTable dt = GeneralMethod.
+                        DataTable dt = CommonFun.GetDataTableFromIList(_view );
+                        dt.TableName = $"_view";
+                        decimal total = _view.Sum(x => x.SumPrice);
+                        WorkbookDesigner designer = new WorkbookDesigner();
+                        designer.Workbook = new Workbook(AppSettingsHelper.Get("ExcelBasePath") + "Template/日付报表模板.xls");
+                        designer.SetDataSource(dt);
+                        designer.SetDataSource("Total", total);
+                        designer.Workbook.Worksheets[0].Name = "日付报表";
+
+                        designer.Process();
+
+                        string fileName = $"DailyPayment/日付报表{ DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx";
+                        designer.Workbook.Save(AppSettingsHelper.Get("ExcelBasePath") + fileName);
+                        string rst = AppSettingsHelper.Get("ExcelBaseUrl") + AppSettingsHelper.Get("ExcelFtpPath") + fileName;
+                        return Ok(JsonView(true, "操作成功", new { url = rst })) ;
+                    }
+
+                    return Ok(JsonView(true, ",暂无数据"));
+                }
+
+                return Ok(JsonView(false, "操作失败"));
 
 
-                return Ok(JsonView(true, "操作成功!", _view, total));
             }
             }
             else return Ok(JsonView(false, "操作失败"));
             else return Ok(JsonView(false, "操作失败"));
         }
         }

+ 44 - 0
OASystem/OASystem.Api/OAMethodLib/QiYeWeChatAPI/AppNotice/Library.cs

@@ -902,6 +902,50 @@ namespace OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice
         }
         }
 
 
 
 
+        #region 公务出访数据变更发送通知
+        /// <summary>
+        /// 机票行程代码录入变更通知发送国交经理、主管、王鸽
+        /// </summary>
+        /// <param name="diId"></param>
+        /// <param name="operationId"></param>
+        /// <returns></returns>
+        public static async Task<bool> SendUserMsg_GroupShare_ToOP(int diId, int operationId)
+        {
+            Grp_DelegationInfo groupInfo = _grpDeleRep.Query<Grp_DelegationInfo>(s => s.Id == diId).First();
+
+            var operationName = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.Id == operationId).First()?.CnName ?? "Unknown";
+            var defaultJobPostIds = new List<int>();
+            List<string> receivedUserIds = _grpDeleRep.Query<Sys_Users>(s => s.IsDel == 0 && s.DepId == 7 && s.JobPostId == 28 ).Select(x => x.Id.ToString()).ToList();
+            var defaultUserIds = new List<string>() { "208", "233" };
+            receivedUserIds.AddRange(defaultUserIds);
+
+            if (receivedUserIds.Count > 0)
+            {
+                List<string> qwUserIdList = GetQiyeChatUserIdList(receivedUserIds);
+
+                string resMsg = string.Format(@" `公务出访有数据更新通知`  
+
+>团组:<font color='info'>{0}</font> 
+
+>操作人员:<font color='comment'>{1}</font> 
+>操作时间:<font color='comment'>{2}</font> 
+
+[详细信息请前往OA系统查看](http://oa.pan-american-intl.com:4399/)   ", groupInfo.TeamName, operationName, DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
+
+
+                ResponseBase result = await _qiYeWeChatApiService.GroupStatus_SendMessage_ToUser_Markdown(qwUserIdList, resMsg);
+                if (result.errcode != 0)
+                {
+                    //抄送日志 
+                    return false;
+                }
+            }
+
+            return true;
+        }
+
+        #endregion
+
         #endregion
         #endregion
 
 
 
 

+ 10 - 2
OASystem/OASystem.Domain/ViewModels/Financial/Fin_DailyFeePaymentView.cs

@@ -516,7 +516,8 @@ namespace OASystem.Domain.ViewModels.Financial
     [SqlSugar.SugarTable("Fin_DailyFeePayment")]
     [SqlSugar.SugarTable("Fin_DailyFeePayment")]
     public class DailyFeePaymentRangeView
     public class DailyFeePaymentRangeView
     {
     {
-
+        [SugarColumn(IsIgnore = true)]//需要加上
+        public int RowIndex { get; set; } //行号 序号
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
         public int Id { get; set; }
         public int Id { get; set; }
         public string Instructions { get; set; }
         public string Instructions { get; set; }
@@ -542,6 +543,8 @@ namespace OASystem.Domain.ViewModels.Financial
     public class DailyFeePaymentContentView
     public class DailyFeePaymentContentView
     {
     {
 
 
+        //[SugarColumn(IsIgnore = true)]//需要加上
+        //public int RowIndex { get; set; } //行号 序号
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
         [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
         public int Id { get; set; }
         public int Id { get; set; }
 
 
@@ -559,7 +562,12 @@ namespace OASystem.Domain.ViewModels.Financial
 
 
         //public int IsDel { get; set; }
         //public int IsDel { get; set; }
     }
     }
-    
+
+
+    public class ExcelView : DailyFeePaymentRangeView
+    {
+        public string ContentStr { get; set; }
+    }
 
 
     #endregion
     #endregion
 }
 }