Bläddra i källkod

公务出访 获取团组所有信息,绑定下拉框
GetGroupAllList 新增 sql 语句

leiy 10 månader sedan
förälder
incheckning
b99b386e89
1 ändrade filer med 126 tillägg och 112 borttagningar
  1. 126 112
      OASystem/OASystem.Api/Controllers/ResourceController.cs

+ 126 - 112
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1552,8 +1552,9 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> GetGroupAllList(OfficialActivitiesByDiIdDto dto)
         {
-            List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a => a.IsDel == 0).OrderBy(a => a.CreateTime, OrderByType.Desc).ToList();
-            List<Sys_SetData> data = await _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToListAsync();
+            string groupSql = string.Format("Select * From Grp_DelegationInfo With(NoLock) Where IsDel = 0 Order By CreateTime Desc");
+            List<Grp_DelegationInfo> _DelegationInfos = _sqlSugar.SqlQueryable< Grp_DelegationInfo >(groupSql).ToList();
+            List<Sys_SetData> data = _sqlSugar.Queryable<Sys_SetData>().Where(a => a.IsDel == 0 && a.STid == 38).ToList();
             List<Grp_DeleFile> _DeleFile = _sqlSugar.Queryable<Grp_DeleFile>().Where(a => a.Diid == dto.DiId && a.IsDel == 0 && a.Category == 970).ToList();
             return Ok(JsonView(true, "查询成功!", new { Delegation = _DelegationInfos, SetData = data, DeleFile = _DeleFile }));
         }
@@ -1740,136 +1741,38 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 throw;
             }
         }
-        #endregion
 
-        #region 请示数据库
-        /// <summary>
-        /// 查询请示数据库初始化
-        /// </summary>
-        /// <param name="dto"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
-        {
-            try
-            {
-                Result groupData = await _askDataRep.QueryAskData(dto);
-                if (groupData.Code != 0)
-                {
-                    return Ok(JsonView(false, groupData.Msg));
-                }
-                return Ok(JsonView(true, groupData.Msg, groupData.Data));
-            }
-            catch (Exception ex)
-            {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
-            }
-        }
 
         /// <summary>
-        /// 根据Id查询请示数据库单挑数据
-        /// </summary>
-        /// <param name="dto"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
-        {
-            try
-            {
-                Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
-                if (_AskData==null)
-                {
-                    return Ok(JsonView(true, "暂无数据!", _AskData));
-                }
-                return Ok(JsonView(true, "查询成功!", _AskData));
-            }
-            catch (Exception ex)
-            {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
-            }
-        }
-        /// <summary>
-        /// 请示数据库操作(Status:1.新增,2.修改)
+        /// 公务出访 (省外办,市外办) File Downlaod
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> OpAskData(OpAskDataDto dto)
-        {
-            try
-            {
-                Result groupData = await _askDataRep.OpAskData(dto);
-                if (groupData.Code != 0)
-                {
-                    return Ok(JsonView(false, groupData.Msg));
-                }
-                return Ok(JsonView(true, groupData.Msg, groupData.Data));
-            }
-            catch (Exception ex)
-            {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
-            }
-        }
-        /// <summary>
-        /// 删除请示资料信息
-        /// </summary>
-        /// <param name="dto"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> DelAskData(DelBaseDto dto)
-        {
-            try
-            {
-                var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
-                if (!res)
-                {
-                    return Ok(JsonView(false, "删除失败"));
-                }
-                return Ok(JsonView(true, "删除成功!"));
-            }
-            catch (Exception ex)
-            {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
-            }
-        }
-
-
-        /// <summary>
-        /// 导出省外办请示
-        /// </summary>
-        /// <param name="dto"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> AskFileDownload(AskFileDownloadDto dto)
+        public async Task<IActionResult> OfficialActivitiesFileDownload(AskFileDownloadDto dto)
         {
             #region 参数验证
 
             if (dto.FileType < 1 || dto.FileType > 2) return Ok(JsonView(false, "请传入有效的FileType参数. 1 省外办出访请示 2 市外办出访请示"));
-            if (dto.DiId < 1 ) return Ok(JsonView(false, "请传入有效的DiId参数."));
+            if (dto.DiId < 1) return Ok(JsonView(false, "请传入有效的DiId参数."));
 
             #endregion
             //团组基础信息
             var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().Where(it => it.IsDel == 0 && it.Id == dto.DiId).First();
             if (groupInfo == null) return Ok(JsonView(false, "该团组基本信息不存在"));
 
+            //团组公务信息
+            var obDatas = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
+            if (obDatas.Count < 1) return Ok(JsonView(false, "请先录入公务信息!"));
+
+            //请示数据库范例数据
+
             //团组客户名单
             var guestResult = _tourClientListRep._ItemByDiId(1, dto.DiId);
             List<TourClientListByDiIdView> guestInfos = new List<TourClientListByDiIdView>();
             if (guestResult.Result.Code == 0) guestInfos = guestResult.Result.Data as List<TourClientListByDiIdView>;
 
-            //团组公务信息
-            var officialBusiness = _sqlSugar.Queryable<Res_OfficialActivities>().Where(it => it.IsDel == 0 && it.DiId == dto.DiId).ToList();
-            var obInfo = officialBusiness.FirstOrDefault();
-
             //载入模板
             string tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/省外办出访请示 - 模板.docx";
             var doc = new Document(tempPath);
@@ -1879,7 +1782,7 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
             Dictionary<string, string> dic = new Dictionary<string, string>();
 
             //××(组团单位):接团客户信息团组
-            dic.Add("GroupClient",groupInfo.ClientUnit);
+            dic.Add("GroupClient", groupInfo.ClientUnit);
 
             //关于××(职务、姓名)等×人赴××(国家或地区)进行×××(出访目的)的请示
             string guestName = "";
@@ -1897,7 +1800,17 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
 
             //应×××(邀请方名称+邀请人职务和姓名)的邀请,我单位拟派×××(职务、姓名)等×人(人数)于×××年×××月×××日赴×××(国家或地区)进行×××(出访目的)。现请示如下。
             string visitDateStr = @$"{groupInfo.VisitDate.Year}年{groupInfo.VisitDate.Month}月{groupInfo.VisitDate.Day}日";
-            string askSubTitle = $@"应{obInfo.Client}{obInfo.Job}{obInfo.Contact}的邀请,我单位拟派{guestInfoStr}等{guestInfos.Count}人于{visitDateStr}赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}。现请示如下。";
+            string obInfoStr = "";
+            foreach (var ob in obDatas)
+            {
+                obInfoStr += @$"{ob.Client}{ob.Job}{ob.Contact}、";
+            }
+            if (obInfoStr.Length > 0)
+            {
+                obInfoStr = obInfoStr.Substring(0, obInfoStr.Length - 1);
+            }
+
+            string askSubTitle = $@"应{obInfoStr}的邀请,我单位拟派{guestInfoStr}等{guestInfos.Count}人于{visitDateStr}赴{groupInfo.VisitCountry}进行{groupInfo.VisitPurpose}。现请示如下。";
             dic.Add("AskSubTitle", askSubTitle);
 
             //出访背景
@@ -1935,7 +1848,7 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
 
                 builder.MoveToCell(0, i + 1, 2, 0);
                 builder.Write(guestInfo.CompanyFullName + guestInfo.Job);
-                
+
 
                 builder.MoveToCell(0, i + 1, 3, 0);
                 string birthDay = "";
@@ -1958,6 +1871,107 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
 
         #endregion
 
+        #region 请示数据库
+        /// <summary>
+        /// 查询请示数据库初始化
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryAskData(QueryAskDataDto dto)
+        {
+            try
+            {
+                Result groupData = await _askDataRep.QueryAskData(dto);
+                if (groupData.Code != 0)
+                {
+                    return Ok(JsonView(false, groupData.Msg));
+                }
+                return Ok(JsonView(true, groupData.Msg, groupData.Data));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+
+        /// <summary>
+        /// 根据Id查询请示数据库单挑数据
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryAskDataById(QueryAskDataByIdDto dto)
+        {
+            try
+            {
+                Res_AskData _AskData = await _sqlSugar.Queryable<Res_AskData>().FirstAsync(a => a.IsDel == 0 && a.Id == dto.id);
+                if (_AskData==null)
+                {
+                    return Ok(JsonView(true, "暂无数据!", _AskData));
+                }
+                return Ok(JsonView(true, "查询成功!", _AskData));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+        /// <summary>
+        /// 请示数据库操作(Status:1.新增,2.修改)
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> OpAskData(OpAskDataDto dto)
+        {
+            try
+            {
+                Result groupData = await _askDataRep.OpAskData(dto);
+                if (groupData.Code != 0)
+                {
+                    return Ok(JsonView(false, groupData.Msg));
+                }
+                return Ok(JsonView(true, groupData.Msg, groupData.Data));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+        /// <summary>
+        /// 删除请示资料信息
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DelAskData(DelBaseDto dto)
+        {
+            try
+            {
+                var res = await _askDataRep.SoftDeleteByIdAsync<Res_AskData>(dto.Id.ToString(), dto.DeleteUserId);
+                if (!res)
+                {
+                    return Ok(JsonView(false, "删除失败"));
+                }
+                return Ok(JsonView(true, "删除成功!"));
+            }
+            catch (Exception ex)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
+
+        #endregion
+
         #region 机票黑屏代码
         /// <summary>
         /// 根据团组Id查询黑屏代码列表