leiy před 1 rokem
rodič
revize
bdec65ba62

+ 7 - 1
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -213,6 +213,7 @@ namespace OASystem.API.Controllers
         {
             try
             {
+                Logs("请求:" + JsonConvert.SerializeObject(dto));
                 var groupData = await _groupRepository.GroupOperation(dto);
                 if (groupData.Code != 0)
                 {
@@ -295,9 +296,14 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, groupData.Msg));
             }
 
+            TeamCodeView teamCodeView = new TeamCodeView
+            {
+                TourCode = groupData.Data
+            }; 
+
             GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
 
-            return Ok(JsonView(groupData.Data));
+            return Ok(JsonView(teamCodeView));
         }
 
         /// <summary>

+ 47 - 4
OASystem/OASystem.Api/Controllers/SmallFunController.cs

@@ -1,6 +1,13 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Options;
 using OASystem.API.OAMethodLib.JuHeAPI;
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using System.Buffers;
+using System.Collections.Specialized;
+using System.Text.Json;
+using System.Text.Json.Nodes;
+using System.Xml.Linq;
 
 namespace OASystem.API.Controllers
 {
@@ -22,20 +29,56 @@ namespace OASystem.API.Controllers
             this._juHeApiService = juHeApiService;
         }
 
+
+        #region 聚合汇率相关
         /// <summary>
-        /// 获取汇率
+        /// 获取汇率接口
         /// </summary>
-        /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GetMsgList()
+        public async Task<IActionResult> GeExchangeRate()
         {
-            var msgData = await _juHeApiService.GetExchangeRateAsync();
+            string rateDataString = await RedisRepository.RedisFactory
+                                                         .CreateRedisRepository()
+                                                         .StringGetAsync<string>("OA2023JuHeExchangeRate");//string 取
+
+            //if (string.IsNullOrEmpty(rateDataString))
+            //{
+                var rateData = await _juHeApiService.GetExchangeRateAsync();
+                if (rateData.Resultcode == "200" && rateData.Error_code == 0)
+                {
+                    var data = rateData.Result;
+
+                    System.Text.Json.JsonSerializer.Deserialize<ListDictionary>(data.ToJson());
+
+
+                    var node = JsonNode.Parse(data.ToJson());
+                    var responseData = System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, dynamic>>(node);
+                //var responseData = System.Text.Json.JsonSerializer.Deserialize<ExchangeRateModel>(data);
+
+                //var responseData = JsonSerializer.Deserialize<Dictionary<string, dynamic>>(data);
+                //var node = JsonNode.Parse(data.ToJson());
+                //var myClass = node.GetValue<ExchangeRateModel>;
 
 
+                TimeSpan ts = DateTime.Now.AddMinutes(120) - DateTime.Now; //设置redis 过期时间 比 jwt 时间 快一分钟
+                    await RedisRepository.RedisFactory.CreateRedisRepository()
+                                                      .StringSetAsync<string>("OA2023JuHeExchangeRate", data.ToJson(), ts);//string 存
+                                                                                                                                                   //JsonObject.Create(data, ExchangeRateModel).ToJson();
+                }
+            //}
+
+           
+
             return Ok(JsonView(true));
         }
+        #endregion
+        /// <summary>
+        /// 获取汇率
+        /// </summary>
+        /// <returns></returns>
+
 
     }
 }

+ 1 - 1
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/IJuHeApiService.cs

@@ -11,6 +11,6 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
         /// 获取汇率
         /// </summary>
         /// <returns></returns>
-        Task<string> GetExchangeRateAsync();
+        Task<JuHeAPIResult> GetExchangeRateAsync();
     }
 }

+ 34 - 20
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/JuHeApiService.cs

@@ -1,6 +1,8 @@
-using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using Dm;
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
 using System.Net.Http;
 using System.Net.Http.Json;
+using System.Text.Json;
 using Ubiety.Dns.Core;
 
 namespace OASystem.API.OAMethodLib.JuHeAPI
@@ -16,11 +18,10 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
         /// <summary>
         /// 初始化
         /// </summary>
-        /// <param name="httpClient"></param>
-        public JuHeApiService(HttpClient httpClient)
+        /// <param name="clientFactory"></param>
+        public JuHeApiService(IHttpClientFactory clientFactory)
         {
-            _httpClient = httpClient;
-            _httpClient.BaseAddress = new Uri("http://web.juhe.cn:8080");
+            _httpClient = clientFactory.CreateClient("PublicJuHeApi"); ;
         }
 
         /// <summary>
@@ -28,27 +29,40 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
         /// </summary>
         /// <returns></returns>
         /// <exception cref="NotImplementedException"></exception>
-        public async Task<string> GetExchangeRateAsync()
+        public async Task<JuHeAPIResult> GetExchangeRateAsync()
         {
+            var result = new JuHeAPIResult() { Resultcode = "10000",Reason="未知错误" };
+
             string url = string.Format("/finance/exchange/rmbquot");
-            var parameters2 = new Dictionary<string, string>();
-            parameters2.Add("key", _appKey);//你申请的key 
-            parameters2.Add("type", "0"); //两种格式(0或者1,默认为0)
-            parameters2.Add("bank", "3"); //(0:工商银行,1:招商银行,2:建设银行,3:中国银行,4:交通银行,5:农业银行,默认为:0)
-            var httpContent = new StringContent(JsonConvert.SerializeObject(parameters2), Encoding.UTF8, "application/json");
-            var exchangeReq = await _httpClient.PostAsync(url, httpContent);
-            if (exchangeReq.IsSuccessStatusCode)
-            {
-                var stringResponse = await exchangeReq.Content.ReadAsStringAsync();
 
+            try
+            {
+                var exchangeReq = await _httpClient.PostAsync(url,
+                                    new FormUrlEncodedContent(new List<KeyValuePair<string, string>>()
+                                    {
+                                        new KeyValuePair<string, string>("key",_appKey),//你申请的key 
+                                        new KeyValuePair<string, string>("type","0"),   //两种格式(0或者1,默认为0)
+                                        new KeyValuePair<string, string>("bank","3")    //(0:工商银行,1:招商银行,2:建设银行,3:中国银行,
+                                                                                        //4:交通银行,5:农业银行,默认为:0)
+                                    }));
+                if (exchangeReq.IsSuccessStatusCode)
+                {
+                    var stringResponse = await exchangeReq.Content.ReadAsStringAsync();
 
+                    result = System.Text.Json.JsonSerializer.Deserialize<JuHeAPIResult>(stringResponse,
+                    new JsonSerializerOptions() { PropertyNamingPolicy = JsonNamingPolicy.CamelCase });
+                }
+                else
+                {
+                    result.Reason = "汇率接口请求失败!";
+                }
             }
-            else {
-               
+            catch (Exception ex)
+            {
+                result.Reason = ex.Message;
             }
-
-            throw new HttpRequestException(exchangeReq.ReasonPhrase);
-
+            
+            return result;
         }
     }
 }

+ 27 - 22
OASystem/OASystem.Api/Program.cs

@@ -36,29 +36,33 @@ builder.Services.AddControllers()
     });
 
 
+
+#region Cors
+builder.Services.AddCors(policy =>
+{
+    policy.AddPolicy("Cors", opt => opt
+    .AllowAnyOrigin()
+    .AllowAnyHeader()
+    .AllowAnyMethod()
+    .WithExposedHeaders("X-Pagination"));
+});
+#endregion
+
 #region 上传文件 
-//builder.Services.AddCors(policy =>
-//{
-//    policy.AddPolicy("Cors", opt => opt
-//    .AllowAnyOrigin()
-//    .AllowAnyHeader()
-//    .AllowAnyMethod()
-//    .WithExposedHeaders("X-Pagination"));
-//});
-
-//builder.Services.Configure<FormOptions>(options =>
-//{
-//    options.KeyLengthLimit = int.MaxValue;
-//    options.ValueLengthLimit = int.MaxValue;
-//    options.MultipartBodyLengthLimit = int.MaxValue;
-//    options.MultipartHeadersLengthLimit = int.MaxValue;
-//});
 
-//builder.Services.Configure<KestrelServerOptions>(options =>
-//{
-//    options.Limits.MaxRequestBodySize = int.MaxValue;
-//    options.Limits.MaxRequestBufferSize = int.MaxValue;
-//});
+builder.Services.Configure<FormOptions>(options =>
+{
+    options.KeyLengthLimit = int.MaxValue;
+    options.ValueLengthLimit = int.MaxValue;
+    options.MultipartBodyLengthLimit = int.MaxValue;
+    options.MultipartHeadersLengthLimit = int.MaxValue;
+});
+
+builder.Services.Configure<KestrelServerOptions>(options =>
+{
+    options.Limits.MaxRequestBodySize = int.MaxValue;
+    options.Limits.MaxRequestBufferSize = int.MaxValue;
+});
 
 #endregion
 
@@ -223,6 +227,7 @@ builder.Services.AddScoped<IMapper, Mapper>();
 #region 聚合API 服务
 builder.Services.AddControllersWithViews();
 builder.Services.AddSingleton<IJuHeApiService, JuHeApiService>();
+builder.Services.AddHttpClient("PublicJuHeApi", c => c.BaseAddress = new Uri("http://web.juhe.cn"));
 
 #endregion
 
@@ -239,7 +244,7 @@ app.UseStaticFiles();
 app.UseRouting();
 app.UseAuthentication(); // 认证
 app.UseAuthorization();  // 授权
-//app.UseCors("Cors");  //Cors
+app.UseCors("Cors");  //Cors
 //app.UseCors("AllowSpecificOrigin");  //Cors
 
 #region 启用swaggerUI

+ 6 - 0
OASystem/OASystem.Domain/ViewModels/JuHeExchangeRate/JuHeAPIResult.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Collections.Specialized;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -89,4 +90,9 @@ namespace OASystem.Domain.ViewModels.JuHeExchangeRate
         public string? Time { get; set; }
     }
 
+
+    public record AclRecord
+    {
+        public Dictionary<string, StringCollection> ACL { get; set; }
+    }
 }

+ 47 - 48
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -1,4 +1,5 @@
-using OASystem.Domain;
+using Newtonsoft.Json;
+using OASystem.Domain;
 using OASystem.Domain.Dtos;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Dtos.UserDto;
@@ -53,7 +54,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                                              Inner Join Sys_SetData ssd1 On gdi.TeamLevSId = ssd1.Id
                                              Left Join Sys_Users su On gdi.JietuanOperator = su.Id
                                              Where gdi.IsDel = 0 
-                                             Order By VisitDate Desc");
+                                             Order By gdi.CreateTime Desc");
 
                 var _DelegationList = await _sqlSugar.SqlQueryable<DelegationListView>(sql).ToListAsync();
                 if (_DelegationList.Count > 0)
@@ -176,34 +177,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
 
             if (dto.PortType == 1 || dto.PortType == 2) //web
             {
-                Grp_DelegationInfo groupInfo = new Grp_DelegationInfo()
-                {
-                    SalesQuoteNo = dto.SalesQuoteNo,
-                    TeamLevSId = dto.TeamLevSId,
-                    ClientName = dto.ClientName,
-                    ClientUnit = dto.ClientUnit,
-                    TeamName = dto.TeamName,
-                    TeamDid = dto.TeamDid,
-                    VisitDate = Convert.ToDateTime(dto.VisitDate),
-                    VisitCountry = dto.VisitCountry,
-                    VisitPurpose = dto.VisitPurpose,
-                    VisitDays = dto.VisitDays,
-                    VisitPNumber = dto.VisitPNumber,
-                    SpecialNeeds = dto.SpecialNeeds,
-                    OtherNeeds = dto.OtherNeeds,
-                    Remark = dto.Remark,
-                    JietuanOperator = dto.UserId,
-                    TellPhone = dto.TellPhone,
-                    CGRWSPBMMC = dto.CGRWSPBMMC,
-                    CGRWSPWH = dto.CGRWSPWH,
-                    ZZSCBMMC = dto.ZZSCBMMC,
-                    ZZSCSPWH = dto.ZZSCSPWH,
-                    TontractTime = Convert.ToDateTime(dto.TontractTime),
-                    PaymentMoney = dto.PaymentMoney,
-                    PayDay = dto.PayDay
-                };
-
-
                 if (dto.Status == 1) //添加
                 {
                     string selectSql = string.Format(@"Select * From Grp_DelegationInfo 
@@ -232,24 +205,50 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     //    }
                     //}
 
-                    groupInfo.SalesQuoteNo = dto.SalesQuoteNo;
-                    groupInfo.TourCode = "";
-                    groupInfo.SalesDate = DateTime.Now;
-                    groupInfo.IsState = 0; //默认团组未完成 0
-                    groupInfo.JietuanTime = DateTime.Now;
-                    groupInfo.IsDel = 0;
-                    groupInfo.BudgetCost = 0.00M;
-                    groupInfo.HotelComplain = 0;
-                    groupInfo.OPComplain = 0;
-                    groupInfo.OAComplain = 0;
-                    groupInfo.AirComplain = 0;
-                    groupInfo.VisaComplain = 0;
-                    groupInfo.CreateUserId = dto.UserId;
-                    groupInfo.CreateTime = DateTime.Now;
-                    groupInfo.DeleteUserId = null;
-                    groupInfo.DeleteTime = new DateTime(1990, 1, 1).ToString("yyyy-MM-dd HH:mm:ss");
-
-                    var addId = await _sqlSugar.Insertable(groupInfo).ExecuteReturnIdentityAsync();
+                    Grp_DelegationInfo delegationInfo = new Grp_DelegationInfo()
+                    {
+                        SalesQuoteNo = dto.SalesQuoteNo,
+                        TeamLevSId = dto.TeamLevSId,
+                        ClientName = dto.ClientName,
+                        ClientUnit = dto.ClientUnit,
+                        TeamName = dto.TeamName,
+                        TeamDid = dto.TeamDid,
+                        VisitDate = Convert.ToDateTime(dto.VisitDate),
+                        VisitCountry = dto.VisitCountry,
+                        VisitPurpose = dto.VisitPurpose,
+                        VisitDays = dto.VisitDays,
+                        VisitPNumber = dto.VisitPNumber,
+                        SpecialNeeds = dto.SpecialNeeds,
+                        OtherNeeds = dto.OtherNeeds,
+                        Remark = dto.Remark,
+                        JietuanOperator = dto.UserId,
+                        TellPhone = dto.TellPhone,
+                        CGRWSPBMMC = dto.CGRWSPBMMC,
+                        CGRWSPWH = dto.CGRWSPWH,
+                        ZZSCBMMC = dto.ZZSCBMMC,
+                        ZZSCSPWH = dto.ZZSCSPWH,
+                        TontractTime = Convert.ToDateTime(dto.TontractTime),
+                        PaymentMoney = dto.PaymentMoney,
+                        PayDay = dto.PayDay,
+                        TourCode = "",
+                        SalesDate = DateTime.Now,
+                        IsState = 0, //默认团组未完成 0
+                        JietuanTime = DateTime.Now,
+                        IsDel = 0,
+                        BudgetCost = 0.00M,
+                        HotelComplain = 0,
+                        OPComplain = 0,
+                        OAComplain = 0,
+                        AirComplain = 0,
+                        VisaComplain = 0,
+                        CreateUserId = dto.UserId,
+                        CreateTime = DateTime.Now,
+                        DeleteUserId = null,
+                        DeleteTime = new DateTime(1990, 1, 1).ToString("yyyy-MM-dd HH:mm:ss")
+                    };
+
+                    Log.Information("添加:"+ JsonConvert.SerializeObject(delegationInfo));
+                    var addId = await _sqlSugar.Insertable(delegationInfo).ExecuteReturnIdentityAsync();
                     if (addId > 0)
                     {
                         result.Code = 0;