Browse Source

请示数据库查询接口

wangh 1 year ago
parent
commit
d7f1584e30

+ 1 - 0
OASystem/EntitySync/Program.cs

@@ -100,5 +100,6 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Fin_ProceedsReceived),      // 已收款项
     //typeof(Fin_OtherPrice),            // 其他款项
     //typeof(Res_OfficialActivities)     //公务出访
+    //typeof(Res_AskData),//请示数据库
 });
 Console.WriteLine("数据库结构同步完成!");

+ 71 - 5
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1,8 +1,12 @@
-using OASystem.API.OAMethodLib;
+using NPOI.HPSF;
+using OASystem.API.OAMethodLib;
 using OASystem.Domain.Dtos.Resource;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Infrastructure.Repositories.Groups;
+using Org.BouncyCastle.Utilities;
+using Quartz.Util;
 using System.Collections.Generic;
+using System.Net.Http.Headers;
 
 namespace OASystem.API.Controllers
 {
@@ -26,13 +30,14 @@ namespace OASystem.API.Controllers
         private readonly AirTicketAgentRepository _airTicketAgentRep;
         private readonly InvitationOfficialActivityDataRepository _InvitationOfficialActivityDataRep;
         private readonly OfficialActivitiesRepository _officialActivitiesRep;
+        private readonly AskDataRepository _askDataRep;
         private readonly SqlSugarClient _sqlSugar;
 
         public ResourceController(IMapper mapper, IConfiguration config, SqlSugarClient sqlSugar, CarDataRepository carDataRep,
             LocalGuideDataRepository localGuideDataRep, ThreeCodeRepository threeCodeRep,
             HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
             CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep, AirTicketAgentRepository airTicketAgentRep,
-            InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep)
+            InvitationOfficialActivityDataRepository invitationOfficialActivityDataRep, OfficialActivitiesRepository officialActivitiesRep, AskDataRepository askDataRep)
         {
             _mapper = mapper;
             _config = config;
@@ -48,6 +53,7 @@ namespace OASystem.API.Controllers
             _airTicketAgentRep = airTicketAgentRep;
             _InvitationOfficialActivityDataRep = invitationOfficialActivityDataRep;
             _officialActivitiesRep = officialActivitiesRep;
+            _askDataRep = askDataRep;
         }
 
 
@@ -1538,7 +1544,11 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 throw;
             }
         }
-
+        /// <summary>
+        /// 上传文件
+        /// </summary>
+        /// <param name="file"></param>
+        /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> UploadOfficialActivities(IFormFile file)
@@ -1591,7 +1601,11 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 throw;
             }
         }
-
+        /// <summary>
+        /// 删除文件
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> DelloadOfficialActivities(DelBaseDto dto)
@@ -1621,9 +1635,61 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 throw;
             }
         }
+
+        /// <summary>
+        /// 删除公务出访信息
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> DelOfficialActivities(DelBaseDto dto)
+        {
+            try
+            {
+                var res = await _officialActivitiesRep.SoftDeleteByIdAsync<Res_OfficialActivities>(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>
+        /// 查询请示数据库初始化
+        /// </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;
+            }
+        }
         #endregion
     }
-   
+
 
 }
 

+ 0 - 5
OASystem/OASystem.Domain/Dtos/DtoBase.cs

@@ -40,9 +40,4 @@ namespace OASystem.Domain.Dtos
         /// </summary>
         public int DeleteUserId { get; set; }
     }
-    public class DataDto
-    {
-        public IFormFile file { get; set; }
-        public string typeName { get; set; }
-    }
 }

+ 24 - 0
OASystem/OASystem.Domain/Dtos/Resource/QueryAskDataDto.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.Resource
+{
+    public class QueryAskDataDto
+    {
+        /// <summary>
+        /// 国家
+        /// </summary>
+        public string Country { get; set; }
+        /// <summary>
+        /// 地区
+        /// </summary>
+        public string Area { get; set; }
+        /// <summary>
+        /// 涉及领域
+        /// </summary>
+        public string Field { get; set; }
+    }
+}

+ 51 - 0
OASystem/OASystem.Domain/Entities/Resource/Res_AskData.cs

@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Resource
+{
+    /// <summary>
+    /// 请示数据库表
+    /// </summary>
+    [SugarTable("Res_AskData")]
+    public class Res_AskData:EntityBase
+    {
+        /// <summary>
+        /// 团组ID
+        /// </summary>
+        [SugarColumn(IsNullable =true,ColumnDataType ="int")]
+        public int DiId { get; set; }
+        /// <summary>
+        /// 团名
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(100)")]
+        public string DeleName { get; set; }
+        /// <summary>
+        /// 国家
+        /// </summary>
+        [SugarColumn(IsNullable =true,ColumnDataType ="varchar(100)")]
+        public string Country { get; set; }
+        /// <summary>
+        /// 地区
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(500)")]
+        public string Area { get; set; }
+        /// <summary>
+        /// 公务方名称
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(200)")]
+        public string UnitName { get; set; }
+        /// <summary>
+        /// 涉及领域
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(100)")]
+        public string Field { get; set; }
+        /// <summary>
+        /// 话术范例
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "varchar(500)")]
+        public string TalkCase { get; set; }
+    }
+}

+ 67 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/AskDataRepository.cs

@@ -0,0 +1,67 @@
+using AutoMapper;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.Resource;
+using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.Entities.Resource;
+using OASystem.Domain.ViewModels.Resource;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Infrastructure.Repositories.Resource
+{
+    public class AskDataRepository : BaseRepository<Res_AskData, QueryAskDataDto>
+    {
+        private readonly IMapper _mapper;
+        public AskDataRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
+        {
+            _mapper = mapper;
+        }
+
+        public async Task<Result> QueryAskData(QueryAskDataDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+            try
+            {
+                string sqlWhere = string.Empty;
+                if (!string.IsNullOrWhiteSpace(dto.Country))
+                {
+                    sqlWhere += string.Format(@"And Country like '%{0}%'", dto.Country);
+                }
+                if (!string.IsNullOrWhiteSpace(dto.Area))
+                {
+                    sqlWhere += string.Format(@"And Area like '%{0}%'", dto.Area);
+                }
+                if (!string.IsNullOrWhiteSpace(dto.Field))
+                {
+                    sqlWhere += string.Format(@"And Field like '%{0}%'", dto.Field);
+                }
+                sqlWhere += string.Format(@"And IsDel={0}", 0);
+
+                if (!string.IsNullOrEmpty(sqlWhere.Trim()))
+                {
+                    Regex r = new Regex("And");
+                    sqlWhere = r.Replace(sqlWhere, "Where", 1);
+                }
+                string sql = string.Format(@"select * from Res_AskData {0}", sqlWhere);
+                List<Res_AskData> askDatd = await _sqlSugar.SqlQueryable<Res_AskData>(sql).ToListAsync();
+                List<Grp_DelegationInfo> delegationInfo=await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(a=>a.IsDel==0).ToListAsync();
+                if (askDatd.Count != 0 && delegationInfo.Count!=0)
+                {
+                    result = new Result() { Code = 0, Msg = "查询成功!", Data = new { askDatd= askDatd, delegationInfo= delegationInfo } };
+                }
+                else
+                {
+                    result = new Result() { Code = 0, Msg = "暂无数据!", Data = new { askDatd = askDatd, delegationInfo = delegationInfo } };
+                }
+            }
+            catch (Exception ex)
+            {
+                result = new Result() { Code = -2, Msg = "未知错误" };
+            }
+            return result;
+        }
+    }
+}