Browse Source

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

jiangjc 1 year ago
parent
commit
5430070ba5

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

@@ -3,6 +3,7 @@ using Newtonsoft.Json.Serialization;
 using OASystem.API.OAMethodLibs;
 using OASystem.Domain.Dtos.Groups;
 using OASystem.Domain.Entities.Groups;
+using OASystem.Domain.ViewModels.Group;
 using OASystem.Domain.ViewModels.Groups;
 using OASystem.Infrastructure.Repositories.Groups;
 
@@ -279,6 +280,26 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(salesQuoteNo));
         }
 
+        /// <summary>
+        /// 设置确认出团
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> SetConfirmationGroup(ConfirmationGroupDto dto)
+        {
+            var groupData = await _groupRepository.ConfirmationGroup(dto);
+            if (groupData.Code != 0)
+            {
+                return Ok(JsonView(false, groupData.Msg));
+            }
+
+            GroupStepForDelegation.CreateWorkStep(dto.GroupId); //创建管控流程
+
+            return Ok(JsonView(groupData.Data));
+        }
+
         /// <summary>
         /// 获取团组名称 List
         /// </summary>
@@ -294,7 +315,6 @@ namespace OASystem.API.Controllers
                 return Ok(JsonView(false, groupData.Msg));
             }
             
-
             return Ok(JsonView(groupData.Data, groupData.Data.Count));
         }
 

+ 41 - 0
OASystem/OASystem.Api/Controllers/SmallFunController.cs

@@ -0,0 +1,41 @@
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using OASystem.API.OAMethodLib.JuHeAPI;
+
+namespace OASystem.API.Controllers
+{
+    /// <summary>
+    /// 小功能接口
+    /// </summary>
+    [Route("api/[controller]/[action]")]
+    [ApiController]
+    public class SmallFunController : ControllerBase
+    {
+        private readonly IJuHeApiService _juHeApiService;
+
+        /// <summary>
+        /// 初始化
+        /// </summary>
+        /// <param name="juHeApiService"></param>
+        public SmallFunController(IJuHeApiService juHeApiService)
+        {
+            this._juHeApiService = juHeApiService;
+        }
+
+        /// <summary>
+        /// 获取汇率
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GetMsgList()
+        {
+            var msgData = await _juHeApiService.GetExchangeRateAsync();
+
+
+            return Ok(JsonView(true));
+        }
+
+    }
+}

+ 1 - 1
OASystem/OASystem.Api/Controllers/TencentOCRController.cs

@@ -1,4 +1,4 @@
-using OASystem.API.OAMethodLib;
+using OASystem.API.OAMethodLib.TencentCloudAPI;
 using OASystem.Domain.Dtos.CRM;
 using OASystem.Domain.Dtos.Tencent;
 using OASystem.Domain.ViewModels.TencentOCR;

+ 139 - 0
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/ExchangeRateTool.cs

@@ -0,0 +1,139 @@
+using System.Web;
+
+namespace OASystem.API.OAMethodLib.JuHeAPI
+{
+    /// <summary>
+    /// 集合接口 - 汇率转换tools
+    /// </summary>
+    public static class ExchangeRateTool
+    {
+        //初始化 appkey
+        static string appKey = "0f5429e9fbb8637c0ff3f14bbb42c732";
+
+        /// <summary>
+        /// Http (GET/POST)
+        /// </summary>
+        /// <param name="url">请求URL</param>
+        /// <param name="parameters">请求参数</param>
+        /// <param name="method">请求方法</param>
+        /// <returns>响应内容</returns>
+        static string SendRequest(string url, IDictionary<string, string> parameters, string method)
+        {
+            if (method.ToLower() == "post")
+            {
+                HttpWebRequest req = null;
+                HttpWebResponse rsp = null;
+                System.IO.Stream reqStream = null;
+                try
+                {
+                    req = (HttpWebRequest)WebRequest.Create(url);
+                    req.Method = method;
+                    req.KeepAlive = false;
+                    req.ProtocolVersion = HttpVersion.Version10;
+                    req.Timeout = 5000;
+                    req.ContentType = "application/x-www-form-urlencoded;charset=utf-8";
+                    byte[] postData = Encoding.UTF8.GetBytes(BuildQuery(parameters, "utf8"));
+                    reqStream = req.GetRequestStream();
+                    reqStream.Write(postData, 0, postData.Length);
+                    rsp = (HttpWebResponse)req.GetResponse();
+                    Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet);
+                    return GetResponseAsString(rsp, encoding);
+                }
+                catch (Exception ex)
+                {
+                    return ex.Message;
+                }
+                finally
+                {
+                    if (reqStream != null) reqStream.Close();
+                    if (rsp != null) rsp.Close();
+                }
+            }
+            else
+            {
+                //创建请求
+                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url + "?" + BuildQuery(parameters, "utf8"));
+
+                //GET请求
+                request.Method = "GET";
+                request.ReadWriteTimeout = 5000;
+                request.ContentType = "text/html;charset=UTF-8";
+                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
+                Stream myResponseStream = response.GetResponseStream();
+                StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
+
+                //返回内容
+                string retString = myStreamReader.ReadToEnd();
+                return retString;
+            }
+        }
+
+        /// <summary>
+        /// 组装普通文本请求参数。
+        /// </summary>
+        /// <param name="parameters">Key-Value形式请求参数字典</param>
+        /// <returns>URL编码后的请求数据</returns>
+        static string BuildQuery(IDictionary<string, string> parameters, string encode)
+        {
+            StringBuilder postData = new StringBuilder();
+            bool hasParam = false;
+            IEnumerator<KeyValuePair<string, string>> dem = parameters.GetEnumerator();
+            while (dem.MoveNext())
+            {
+                string name = dem.Current.Key;
+                string value = dem.Current.Value;
+                // 忽略参数名或参数值为空的参数
+                if (!string.IsNullOrEmpty(name))//&& !string.IsNullOrEmpty(value)
+                {
+                    if (hasParam)
+                    {
+                        postData.Append("&");
+                    }
+                    postData.Append(name);
+                    postData.Append("=");
+                    if (encode == "gb2312")
+                    {
+                        postData.Append(HttpUtility.UrlEncode(value, Encoding.GetEncoding("gb2312")));
+                    }
+                    else if (encode == "utf8")
+                    {
+                        postData.Append(HttpUtility.UrlEncode(value, Encoding.UTF8));
+                    }
+                    else
+                    {
+                        postData.Append(value);
+                    }
+                    hasParam = true;
+                }
+            }
+            return postData.ToString();
+        }
+
+        /// <summary>
+        /// 把响应流转换为文本。
+        /// </summary>
+        /// <param name="rsp">响应流对象</param>
+        /// <param name="encoding">编码方式</param>
+        /// <returns>响应文本</returns>
+        static string GetResponseAsString(HttpWebResponse rsp, Encoding encoding)
+        {
+            System.IO.Stream stream = null;
+            StreamReader reader = null;
+            try
+            {
+                // 以字符流的方式读取HTTP响应
+                stream = rsp.GetResponseStream();
+                reader = new StreamReader(stream, encoding);
+                return reader.ReadToEnd();
+            }
+            finally
+            {
+                // 释放资源
+                if (reader != null) reader.Close();
+                if (stream != null) stream.Close();
+                if (rsp != null) rsp.Close();
+            }
+        }
+
+    }
+}

+ 16 - 0
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/IJuHeApiService.cs

@@ -0,0 +1,16 @@
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
+
+namespace OASystem.API.OAMethodLib.JuHeAPI
+{
+    /// <summary>
+    /// 聚合Api 服务
+    /// </summary>
+    public interface IJuHeApiService
+    {
+        /// <summary>
+        /// 获取汇率
+        /// </summary>
+        /// <returns></returns>
+        Task<string> GetExchangeRateAsync();
+    }
+}

+ 54 - 0
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/JuHeApiService.cs

@@ -0,0 +1,54 @@
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using System.Net.Http;
+using System.Net.Http.Json;
+using Ubiety.Dns.Core;
+
+namespace OASystem.API.OAMethodLib.JuHeAPI
+{
+    /// <summary>
+    /// 聚合Api 服务
+    /// </summary>
+    public class JuHeApiService: IJuHeApiService
+    {
+        private readonly HttpClient _httpClient;
+        private readonly string _appKey = "0f5429e9fbb8637c0ff3f14bbb42c732"; //配置您申请的appkey
+
+        /// <summary>
+        /// 初始化
+        /// </summary>
+        /// <param name="httpClient"></param>
+        public JuHeApiService(HttpClient httpClient)
+        {
+            _httpClient = httpClient;
+            _httpClient.BaseAddress = new Uri("http://web.juhe.cn:8080");
+        }
+
+        /// <summary>
+        /// 汇率转换
+        /// </summary>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        public async Task<string> GetExchangeRateAsync()
+        {
+            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();
+
+
+            }
+            else {
+               
+            }
+
+            throw new HttpRequestException(exchangeReq.ReasonPhrase);
+
+        }
+    }
+}

+ 2 - 2
OASystem/OASystem.Api/OAMethodLib/TencentOCRTools.cs

@@ -4,7 +4,7 @@ using TencentCloud.Common;
 using TencentCloud.Ocr.V20181119.Models;
 using TencentCloud.Ocr.V20181119;
 
-namespace OASystem.API.OAMethodLib
+namespace OASystem.API.OAMethodLib.TencentCloudAPI
 {
     /// <summary>
     /// 腾讯OCR Tools
@@ -142,7 +142,7 @@ namespace OASystem.API.OAMethodLib
             {
                 Bitmap bmp = new Bitmap(ImageFileName);
                 MemoryStream ms = new MemoryStream();
-                bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
+                bmp.Save(ms, ImageFormat.Jpeg);
                 byte[] arr = new byte[ms.Length];
                 ms.Position = 0;
                 ms.Read(arr, 0, (int)ms.Length);

+ 29 - 36
OASystem/OASystem.Api/Program.cs

@@ -10,6 +10,7 @@ using OASystem.API.OAMethodLibs;
 using OASystem.Domain.Dtos.Groups;
 using Microsoft.AspNetCore.Http.Features;
 using Microsoft.AspNetCore.Server.Kestrel.Core;
+using OASystem.API.OAMethodLib.JuHeAPI;
 
 var builder = WebApplication.CreateBuilder(args);
 var basePath = AppContext.BaseDirectory;
@@ -36,45 +37,31 @@ builder.Services.AddControllers()
 
 
 #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.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;
+//});
 
 #endregion
 
-
-
-
 #region 接口分组
 var groups = new List<Tuple<string, string>>
 {
@@ -233,6 +220,12 @@ builder.Services.AddScoped<IMapper, Mapper>();
 
 #endregion
 
+#region 聚合API 服务
+builder.Services.AddControllersWithViews();
+builder.Services.AddSingleton<IJuHeApiService, JuHeApiService>();
+
+#endregion
+
 var app = builder.Build();
 AutofacIocManager.Instance.Container = app.UseHostFiltering().ApplicationServices.GetAutofacRoot();//AutofacIocManager
 
@@ -246,7 +239,7 @@ app.UseStaticFiles();
 app.UseRouting();
 app.UseAuthentication(); // 认证
 app.UseAuthorization();  // 授权
-app.UseCors("Cors");  //Cors
+//app.UseCors("Cors");  //Cors
 //app.UseCors("AllowSpecificOrigin");  //Cors
 
 #region 启用swaggerUI

+ 25 - 0
OASystem/OASystem.Domain/Dtos/Groups/GroupListDto.cs

@@ -55,6 +55,11 @@ namespace OASystem.Domain.Dtos.Groups
         /// </summary>
         public string SalesQuoteNo { get; set; }
 
+        ///// <summary>
+        ///// 团组号
+        ///// </summary>
+        //public string TeamNo { get; set; }
+
         /// <summary>
         /// 团组操作人
         /// </summary>
@@ -190,8 +195,28 @@ namespace OASystem.Domain.Dtos.Groups
     /// </summary>
     public class GroupNameDto : DtoBase
     {
+
     }
 
+
+    /// <summary>
+    /// 确认出团dto
+    /// </summary>
+    public class ConfirmationGroupDto:DtoBase 
+    {
+        /// <summary>
+        /// 团组Id
+        /// </summary>
+        public int GroupId { get; set; }
+
+        /// <summary>
+        /// 团组信息操作人
+        /// </summary>
+        public int GroupsOperator { get; set; }
+
+    }
+
+
     /// <summary>
     /// 根据团组ID获取签证人员请
     /// 求实体类

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

@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.JuHeExchangeRate
+{
+    /// <summary>
+    /// 聚合接口 Result
+    /// </summary>
+    public class JuHeAPIResult
+    {
+        /// <summary>
+        /// 服务级错误码
+        /// 202301	查询不到结果
+        /// </summary>
+        public int Error_code { get; set; }
+
+        /// <summary>
+        /// 系统级错误码
+        /// 错误码  说明            旧版本(resultcode)
+        /// 10001	错误的请求KEY	101
+ 	    /// 10002	该KEY无请求权限	102
+ 	    /// 10003	KEY过期	        103
+ 	    /// 10004	错误的OPENID	104
+ 	    /// 10005	应用未审核超时,请提交认证	105
+ 	    /// 10007	未知的请求源	107
+ 	    /// 10008	被禁止的IP	    108
+ 	    /// 10009	被禁止的KEY	    109
+ 	    /// 10011	当前IP请求超过限制	111
+ 	    /// 10012	请求超过次数限制	112
+ 	    /// 10013	测试KEY超过请求限制	113
+ 	    /// 10014	系统内部异常(调用充值类业务时,请务必联系客服或通过订单查询接口检测订单,避免造成损失)    114
+ 	    /// 10020	接口维护	    120
+ 	    /// 10021	接口停用	    121
+        /// </summary>
+        public string? Resultcode { get; set; }
+
+        /// <summary>
+        /// 消息
+        /// </summary>
+        public string? Reason { get; set; }
+
+        /// <summary>
+        /// 数据源
+        /// </summary>
+        public object? Result { get; set; }
+    }
+
+    /// <summary>
+    /// 汇率接口 返回实体类
+    /// </summary>
+    public class ExchangeRateModel
+    {
+        /// <summary>
+        /// 货币名称
+        /// </summary>
+        public string? Name { get; set; }
+
+        /// <summary>
+        /// 现汇买入价
+        /// </summary>
+        public string? FBuyPri { get; set; }
+
+        /// <summary>
+        /// 现钞买入价
+        /// </summary>
+        public string? MBuyPri { get; set; }
+
+        /// <summary>
+        /// 现钞卖出价
+        /// </summary>
+        public string? MSellPri { get; set; }
+
+        /// <summary>
+        /// 银行折算价/中间价
+        /// </summary>
+        public string? BankConversionPri { get; set; }
+
+        /// <summary>
+        /// 发布日期
+        /// </summary>
+        public string? Date { get; set; }
+
+        /// <summary>
+        /// 发布时间
+        /// </summary>
+        public string? Time { get; set; }
+    }
+
+}

+ 76 - 24
OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs

@@ -208,11 +208,10 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 {
                     string selectSql = string.Format(@"Select * From Grp_DelegationInfo 
                                                    Where IsDel = 0 
-                                                   And SalesQuoteNo = '{0}'
-                                                   And TeamName = '{1}'
-                                                   And ClientName = '{2}'
-                                                   And ClientUnit ='{3}'
-                                                   And VisitDate ='{4}'", dto.SalesQuoteNo, dto.TeamName, dto.ClientName, dto.ClientUnit, dto.VisitDate);
+                                                   And TeamName = '{0}'
+                                                   And ClientName = '{1}'
+                                                   And ClientUnit ='{2}'
+                                                   And VisitDate ='{3}'",dto.TeamName, dto.ClientName, dto.ClientUnit, dto.VisitDate);
                     var selectGroupInfo = await _sqlSugar.SqlQueryable<Grp_DelegationInfo>(selectSql).FirstAsync();
                     if (selectGroupInfo != null)
                     {
@@ -220,21 +219,21 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         return result;
                     }
 
-                    string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
-                    var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
-
-                    string teamCode = "";
-                    while (true)
-                    {
-                        teamCode = Tools.CommonFun.GetRandomStr(6);
-
-                        if (!teamCodeItem.Equals(teamCode))
-                        {
-                            break;
-                        }
-                    }
-
-                    groupInfo.TourCode = teamCode;
+                    //string teamCodeSql = string.Format("Select SalesQuoteNo From Grp_DelegationInfo");
+                    //var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
+
+                    //string SalesQuoteNo = "";
+                    //while (true)
+                    //{
+                    //    SalesQuoteNo = Tools.CommonFun.GetRandomStr(6);
+                    //    if (!teamCodeItem.Equals(SalesQuoteNo))
+                    //    {
+                    //        break;
+                    //    }
+                    //}
+
+                    groupInfo.SalesQuoteNo = dto.SalesQuoteNo;
+                    groupInfo.TourCode = "";
                     groupInfo.SalesDate = DateTime.Now;
                     groupInfo.IsState = 0; //默认团组未完成 0
                     groupInfo.JietuanTime = DateTime.Now;
@@ -262,7 +261,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                     }
 
 
-                }  //增加
+                }  
                 else if (dto.Status == 2)     //修改
                 {
                     var updateStatus = await UpdateAsync(a => a.Id == dto.Id, a => new Grp_DelegationInfo
@@ -327,7 +326,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
         }
 
         /// <summary>
-        /// 团组信息操作
+        /// 团组信息操作 - 删除
         /// </summary>
         /// <param name="dto"></param>
         /// <returns></returns>
@@ -367,8 +366,8 @@ namespace OASystem.Infrastructure.Repositories.Groups
         {
             Result result = new Result() { Code = -2, Msg = "未知错误" };
 
-            string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
-            var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
+            string teamCodeSql = string.Format("Select SalesQuoteNo From Grp_DelegationInfo");
+            var teamCodeItem = await _sqlSugar.SqlQueryable<SalesQuoteNoView>(teamCodeSql).ToListAsync();
 
             string teamCode = "";
             while (true)
@@ -415,6 +414,59 @@ namespace OASystem.Infrastructure.Repositories.Groups
             return result;
         }
 
+
+        /// <summary>
+        /// 团组确认出团
+        /// </summary>
+        /// <returns></returns>
+        public async Task<Result> ConfirmationGroup(ConfirmationGroupDto dto)
+        {
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
+
+
+            string teamCode = "";
+            if (dto.PortType == 1 || dto.PortType == 2) //web
+            {
+
+                string teamCodeSql = string.Format("Select TourCode From Grp_DelegationInfo");
+                var teamCodeItem = await _sqlSugar.SqlQueryable<TeamCodeView>(teamCodeSql).ToListAsync();
+
+                while (true)
+                {
+                    teamCode = Tools.CommonFun.GetRandomAllStr(6);
+
+                    if (!teamCodeItem.Equals(teamCode))
+                    {
+                        break;
+                    }
+                }
+
+
+                var deleteStatus = await UpdateAsync(a => a.Id == dto.GroupId, a => new Grp_DelegationInfo
+                {
+                    TourCode = teamCode,
+                    GroupsOperator = dto.GroupsOperator,
+                    GroupsTime = DateTime.Now
+                });
+
+                if (deleteStatus)
+                {
+                    result.Code = 0;
+                    result.Msg = "确认出团成功!";
+                }
+                else
+                {
+                    result.Msg = "确认出团失败!";
+                }
+
+            }
+
+            result.Code = 0;
+            result.Msg = "成功!";
+            result.Data = teamCode;
+            return result;
+        }
+
         /// <summary>
         /// 获取接团名称List
         /// </summary>