Browse Source

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

yuanrf 2 years ago
parent
commit
31a09582f4
35 changed files with 1065 additions and 320 deletions
  1. 5 3
      OASystem/EntitySync/Program.cs
  2. 16 2
      OASystem/OASystem.Api/Controllers/BusinessController.cs
  3. 12 6
      OASystem/OASystem.Api/Controllers/GroupsController.cs
  4. 73 27
      OASystem/OASystem.Api/Controllers/ResourceController.cs
  5. 53 6
      OASystem/OASystem.Api/Controllers/SmallFunController.cs
  6. 0 32
      OASystem/OASystem.Api/Controllers/SystemController.cs
  7. 3 3
      OASystem/OASystem.Api/OAMethodLib/GroupStepForDelegation.cs
  8. 0 139
      OASystem/OASystem.Api/OAMethodLib/JuHeAPI/ExchangeRateTool.cs
  9. 16 2
      OASystem/OASystem.Api/OAMethodLib/JuHeAPI/IJuHeApiService.cs
  10. 260 20
      OASystem/OASystem.Api/OAMethodLib/JuHeAPI/JuHeApiService.cs
  11. 25 12
      OASystem/OASystem.Api/Program.cs
  12. 91 1
      OASystem/OASystem.Api/appsettings.json
  13. 5 0
      OASystem/OASystem.Domain/Dtos/DtoBase.cs
  14. 11 0
      OASystem/OASystem.Domain/Dtos/Resource/ThreeCodeDto.cs
  15. 30 0
      OASystem/OASystem.Domain/Dtos/SmallFun/ExchangeRateDto.cs
  16. 41 0
      OASystem/OASystem.Domain/Entities/Business/Bus_ConfItemInfo.cs
  17. 24 0
      OASystem/OASystem.Domain/Entities/Business/Bus_ConfItemListInfo.cs
  18. 3 3
      OASystem/OASystem.Domain/Enums/GrpScheduleEnum.cs
  19. 13 0
      OASystem/OASystem.Domain/ViewModels/Business/Bus_ConfItemListView.cs
  20. 2 1
      OASystem/OASystem.Domain/ViewModels/Groups/Grp_ScheduleCombinView.cs
  21. 1 0
      OASystem/OASystem.Domain/ViewModels/Groups/Grp_ScheduleDetailView.cs
  22. 26 0
      OASystem/OASystem.Domain/ViewModels/Groups/Grp_ScheduleView.cs
  23. 22 0
      OASystem/OASystem.Domain/ViewModels/JuHeExchangeRate/JuHeAPIResult.cs
  24. 6 0
      OASystem/OASystem.Domain/ViewModels/Resource/HotelDataView.cs
  25. 13 0
      OASystem/OASystem.Domain/ViewModels/Resource/SetDataTypeView.cs
  26. 5 0
      OASystem/OASystem.Domain/ViewModels/Resource/ThreeCodeView.cs
  27. 50 0
      OASystem/OASystem.Domain/ViewModels/SmallFun/ExchangeRateView.cs
  28. 47 48
      OASystem/OASystem.Infrastructure/Repositories/Groups/DelegationInfoRepository.cs
  29. 35 3
      OASystem/OASystem.Infrastructure/Repositories/Groups/GrpScheduleRepository.cs
  30. 1 0
      OASystem/OASystem.Infrastructure/Repositories/Resource/CarDataRepository.cs
  31. 1 0
      OASystem/OASystem.Infrastructure/Repositories/Resource/HotelDataRepository.cs
  32. 1 0
      OASystem/OASystem.Infrastructure/Repositories/Resource/LocalGuideDataRepository.cs
  33. 24 0
      OASystem/OASystem.Infrastructure/Repositories/Resource/SetDataTypeRepository.cs
  34. 112 12
      OASystem/OASystem.Infrastructure/Repositories/Resource/ThreeCodeRepository.cs
  35. 38 0
      OASystem/OASystem.Infrastructure/Tools/CommonFun.cs

+ 5 - 3
OASystem/EntitySync/Program.cs

@@ -1,4 +1,5 @@
 using OASystem.Domain.Entities;
+using OASystem.Domain.Entities.Business;
 using OASystem.Domain.Entities.Customer;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.Resource;
@@ -83,11 +84,12 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Crm_DeleClient)
     //typeof(Crm_NewClientData)
 
-    typeof(Crm_ClientDataAndUser),
-    typeof(Crm_ClientDataAndBusiness),
+    //typeof(Crm_ClientDataAndUser),
+    //typeof(Crm_ClientDataAndBusiness),
     
     //typeof(Res_ItemDetailInfo),
     //typeof(Res_ItemVendor)
-    typeof(Res_CountryFeeCost)
+    typeof(Bus_ConfItemInfo)
+    //typeof(Res_CountryFeeCost)
 });
 Console.WriteLine("数据库结构同步完成!");

+ 16 - 2
OASystem/OASystem.Api/Controllers/BusinessController.cs

@@ -30,18 +30,32 @@ namespace OASystem.API.Controllers
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> PostConferenceList()
         {
-            List<Grp_DelegationInfo> listSource = _busRep.Query<Grp_DelegationInfo>(s => s.TeamDid == 691).ToList();
+            List<Grp_DelegationInfo> listSource = _busRep.Query<Grp_DelegationInfo>(s => s.TeamDid == 691 && s.IsDel == 0).ToList();
             List<GroupNameView> viewList = new List<GroupNameView>();
             foreach (var group in listSource)
             {
                 GroupNameView _view = new GroupNameView();
-                _view.Id=group.Id;
+                _view.Id = group.Id;
                 _view.GroupName = group.TeamName;
             }
 
             return Ok(JsonView(viewList));
         }
 
+        /// <summary>
+        /// 获取会务的采购物品计划清单
+        /// </summary>
+        /// <param name="ConfId">会务活动Id</param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> PostConfItemList(int ConfId)
+        {
+            
+
+            return Ok(JsonView(false));
+        }
+
         #endregion
     }
 }

+ 12 - 6
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -35,14 +35,14 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> PostSearchGrpSchedule(string paras)
+        public async Task<IActionResult> PostSearchGrpSchedule(JsonDtoBase _jsonDto)
         {
-            if (string.IsNullOrEmpty(paras))
+            if (string.IsNullOrEmpty(_jsonDto.Paras))
             {
                 return Ok(JsonView(false, "参数为空"));
             }
 
-            Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(paras);
+            Grp_ScheduleDto _ScheduleDto = JsonConvert.DeserializeObject<Grp_ScheduleDto>(_jsonDto.Paras);
             if (_ScheduleDto != null)
             {
                 if (_ScheduleDto.SearchType == 2)//获取列表
@@ -212,6 +212,7 @@ namespace OASystem.API.Controllers
         {
             try
             {
+                Logs("请求:" + JsonConvert.SerializeObject(dto));
                 var groupData = await _groupRepository.GroupOperation(dto);
                 if (groupData.Code != 0)
                 {
@@ -294,9 +295,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>
@@ -313,7 +319,7 @@ namespace OASystem.API.Controllers
             {
                 return Ok(JsonView(false, groupData.Msg));
             }
-            
+
             return Ok(JsonView(groupData.Data, groupData.Data.Count));
         }
 
@@ -358,7 +364,7 @@ namespace OASystem.API.Controllers
             return Ok(JsonView(groupData.Data));
         }
 
-       
+
 
         #endregion
     }

+ 73 - 27
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -19,10 +19,12 @@ namespace OASystem.API.Controllers
         private readonly ResItemInfoRepository _resItemInfoRep;
         private readonly SetDataRepository _setDataRepository;
         private readonly CountryFeeRepository _countryFeeRep;
+        private readonly SetDataTypeRepository _setDataTypeRep;
 
         public ResourceController(IMapper mapper, IConfiguration config, CarDataRepository carDataRep,
             LocalGuideDataRepository localGuideDataRep, ThreeCodeRepository threeCodeRep,
-            HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository, CountryFeeRepository countryFeeRep)
+            HotelDataRepository hotelDataRep, ResItemInfoRepository resItemInfoRep, SetDataRepository setDataRepository,
+            CountryFeeRepository countryFeeRep, SetDataTypeRepository setDataTypeRep)
         {
             _mapper = mapper;
             _config = config;
@@ -33,8 +35,14 @@ namespace OASystem.API.Controllers
             _resItemInfoRep = resItemInfoRep;
             _setDataRepository = setDataRepository;
             _countryFeeRep = countryFeeRep;
+            _setDataTypeRep = setDataTypeRep;
         }
         #region 数据类型资料
+        /// <summary>
+        /// 根据类型查询数据
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
         public async Task<IActionResult> QuerySetData(SetDataDto dto)
@@ -58,6 +66,31 @@ namespace OASystem.API.Controllers
                 throw;
             }
         }
+        /// <summary>
+        /// 数据类型大全
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QuerySetDataType(DtoBase dto)
+        {
+            try
+            {
+                var setDataType = _setDataTypeRep.QueryDto<Sys_SetDataType, SetDataTypeView>().ToList();
+                if (setDataType.Count==0)
+                {
+                    return Ok(JsonView(false, "暂无数据!"));
+                }
+                setDataType = setDataType.OrderByDescending(s => s.CreateTime).ToList();
+                return Ok(JsonView(true, "查询成功!", setDataType));
+            }
+            catch (Exception)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
         #endregion
 
         #region 车公司资料板块
@@ -394,40 +427,19 @@ namespace OASystem.API.Controllers
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> QueryThreeCode(DtoBase dto)
+        public async Task<IActionResult> QueryThreeCode(QueryThreeCodeDto dto)
         {
             try
             {
-                if (dto.PortType == 1)
-                {
-                    var ThreeCode = _localGuideDataRep.QueryDto<Res_ThreeCode, ThreeCodeView>().ToList();
-                    if (ThreeCode.Count == 0)
-                    {
-                        return Ok(JsonView(false, "暂无数据!"));
-                    }
-                    ThreeCode = ThreeCode.OrderByDescending(s => s.CreateTime).ToList();
-                    return Ok(JsonView(true, "查询成功", ThreeCode));
-                }
-                else if (dto.PortType == 2)
+                Result LocalGuide = await _ThreeCodeRep.QueryThreeCode(dto);
+                if (LocalGuide.Code == 0)
                 {
-                    //分页写法
-                    if (dto.PageIndex == 0 || dto.PageSize == 0)
-                    {
-                        return Ok(JsonView(false, "请传入PageIndex和PageSize参数"));
-                    }
-                    JsonView _ThreeCode = await _ThreeCodeRep.QuerThreeCode(dto.PageIndex, dto.PageSize);
-                    if (_ThreeCode.Code != 0)
-                    {
-                        return Ok(JsonView(false, _ThreeCode.Msg));
-                    }
-
-                    return Ok(_ThreeCode);
+                    return Ok(JsonView(true, "查询成功", LocalGuide.Data));
                 }
                 else
                 {
-                    return Ok(JsonView(false, "请传入PortType参数!1:Web,2:Android,3:IOS"));
+                    return Ok(JsonView(false, LocalGuide.Msg));
                 }
-
             }
             catch (Exception ex)
             {
@@ -437,6 +449,40 @@ namespace OASystem.API.Controllers
 
 
         }
+        /// <summary>
+        /// 机场三字码数据城市下拉框数据
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> QueryThreeCodeSelect()
+        {
+            try
+            {
+                var ThreeCode = _carDataRep.QueryDto<Res_ThreeCode, ThreeCodeSelectView>().ToList();
+                if (ThreeCode.Count == 0)
+                {
+                    return Ok(JsonView(false, "暂无数据!"));
+                }
+                ThreeCode.Add(new ThreeCodeSelectView { Id = 0, City = "全部" });
+                ThreeCode = ThreeCode.Where((x, i) => ThreeCode.FindIndex(z => z.City == x.City && z.City != "") == i).ToList();
+                ThreeCode = ThreeCode.OrderBy(x => x.Id).ToList();
+                List<ThreeCodeSelectView> data = new List<ThreeCodeSelectView>();
+                foreach (ThreeCodeSelectView _ThreeCode in ThreeCode)
+                {
+                    if (!string.IsNullOrWhiteSpace(_ThreeCode.City))
+                    {
+                        data.Add(_ThreeCode);
+                    }
+                }
+                return Ok(JsonView(true, "查询成功", data));
+            }
+            catch (Exception)
+            {
+                return Ok(JsonView(false, "程序错误!"));
+                throw;
+            }
+        }
 
         /// <summary>
         /// 机场三字码资料操作(Status:1.新增,2.修改)

+ 53 - 6
OASystem/OASystem.Api/Controllers/SmallFunController.cs

@@ -1,6 +1,19 @@
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Options;
+using MySqlX.XDevAPI;
 using OASystem.API.OAMethodLib.JuHeAPI;
+using OASystem.Domain.Dtos.Groups;
+using OASystem.Domain.Dtos.SmallFun;
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using SqlSugar;
+using System.Buffers;
+using System.Collections.Generic;
+using System.Collections.Immutable;
+using System.Collections.Specialized;
+using System.Text.Json;
+using System.Text.Json.Nodes;
+using System.Xml.Linq;
 
 namespace OASystem.API.Controllers
 {
@@ -12,30 +25,64 @@ namespace OASystem.API.Controllers
     public class SmallFunController : ControllerBase
     {
         private readonly IJuHeApiService _juHeApiService;
+        private readonly IConfiguration _config;
 
         /// <summary>
         /// 初始化
         /// </summary>
         /// <param name="juHeApiService"></param>
-        public SmallFunController(IJuHeApiService juHeApiService)
+        public SmallFunController(IJuHeApiService juHeApiService, IConfiguration config)
         {
             this._juHeApiService = juHeApiService;
+            this._config = config;
         }
 
+
+        #region 聚合汇率相关
         /// <summary>
-        /// 获取汇率
+        /// 获取汇率币种
         /// </summary>
-        /// <param name="dto"></param>
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> GetMsgList()
+        public async Task<IActionResult> GeRateCurrency()
         {
-            var msgData = await _juHeApiService.GetExchangeRateAsync();
+            var rateCurrencyData = AppSettingsHelper.Get<RateCurrencyModel>("RateCurrency");
+
+            return Ok(JsonView(rateCurrencyData));
+        }
 
 
-            return Ok(JsonView(true));
+        /// <summary>
+        /// 获取汇率费用
+        /// </summary>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> GeExchangeRate(ExchangeRateDto rateDto)
+        {
+            #region 参数处理
+            if (string.IsNullOrEmpty(rateDto.CurrencyCodePer) || string.IsNullOrEmpty(rateDto.CurrencyCodeSuf))
+            {
+                return Ok(JsonView(false, "币种参数为空!"));
+            }
+
+            if (rateDto.Money <= 0)
+            {
+                return Ok(JsonView(false, "转换金额 <= 0!"));
+            }
+            #endregion
+
+            var result = await _juHeApiService.GetExchangeRateAsync(rateDto);
+            if (result.Code != 0 || result == null)
+            {
+                return Ok(JsonView(false, result.Msg));
+            }
+            return Ok(JsonView(result.Data));
         }
+        #endregion
+
+
 
     }
 }

+ 0 - 32
OASystem/OASystem.Api/Controllers/SystemController.cs

@@ -134,39 +134,7 @@ namespace OASystem.API.Controllers
         }
         #endregion
 
-        #region 类型表
-        /// <summary>
-        /// 查询类型数据
-        /// </summary>
-        /// <param name="dto"></param>
-        /// <returns></returns>
-        [HttpPost]
-        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> QuerySetData(SetDataDto dto)
-        {
-            try
-            {
-                if (dto.DataType==0)
-                {
-                    return Ok(JsonView(false, "请传类型Id!"));
-                }
-                var setData = _setDataRepository.QueryDto<Sys_SetData, SetDataView>(s=>s.STid==dto.DataType).ToList();
-                if (setData.Count == 0)
-                {
-                    return Ok(JsonView(false, "暂无数据!"));
-                }
-                return Ok(JsonView(true, "查询成功!",setData));
-            }
-            catch (Exception ex)
-            {
-                return Ok(JsonView(false, "程序错误!"));
-                throw;
-            }
-        }
-
        
-        #endregion
-
         #region 企业操作
         /// <summary>
         /// 查询企业数据

+ 3 - 3
OASystem/OASystem.Api/OAMethodLib/GroupStepForDelegation.cs

@@ -48,7 +48,7 @@ namespace OASystem.API.OAMethodLibs
                 _primary.Leader = _groupConfig.Leader;
                 _primary.PrimaryStep = GrpSchedulePrimaryStepEnum.Wait;
                 _primary.Remark = "请设置各流程负责人、预计开始/结束时间";
-                int _primaryId = await _grpScheduleRep.AddAsync(_primary);
+                int _primaryId = await _grpScheduleRep.AddAsyncReturnId(_primary);
                 if (_primaryId > 0)
                 {
                     #region 子流程
@@ -62,7 +62,7 @@ namespace OASystem.API.OAMethodLibs
                     _model.ExpectBeginDt = dftBeginDt;
                     _model.ExpectEndDt = dftEndDt;
                     _model.Remark = "未设置负责人";
-                    _model.ScheduleId = DiId;
+                    _model.ScheduleId = _primaryId;
                     _model.StepStatus = 0;
                     #endregion
                     #region 经费预算
@@ -361,7 +361,7 @@ Where d.Id={0} And u.Id not in({1})", DepartmentCode.IC, _groupConfig.FilterUser
                         foreach (var item in personList)
                         {
                             item.CreateUserId = _groupConfig.DefaultUser;
-                            item.ScheduleId = DiId;
+                            item.ScheduleId = _primaryId;
                         }
                         _grpScheduleRep.bulkInsert(personList);
                     }

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

@@ -1,139 +0,0 @@
-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 - 2
OASystem/OASystem.Api/OAMethodLib/JuHeAPI/IJuHeApiService.cs

@@ -1,4 +1,5 @@
-using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using OASystem.Domain.Dtos.SmallFun;
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
 
 namespace OASystem.API.OAMethodLib.JuHeAPI
 {
@@ -11,6 +12,19 @@ namespace OASystem.API.OAMethodLib.JuHeAPI
         /// 获取汇率
         /// </summary>
         /// <returns></returns>
-        Task<string> GetExchangeRateAsync();
+        Task<JuHeAPIResult> GetExchangeRateAsync();
+
+        /// <summary>
+        /// 获取汇率 Single
+        /// </summary>
+        /// <param name="currencyCode">币种code</param>
+        /// <returns></returns>
+        Task<Result> GetSingleRateAsync(string currencyCode);
+
+        /// <summary>
+        /// 获取汇率转换结果
+        /// </summary>
+        /// <returns></returns>
+        Task<Result> GetExchangeRateAsync(ExchangeRateDto dto);
     }
 }

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

@@ -1,6 +1,13 @@
-using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using Dm;
+using Newtonsoft.Json;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.SmallFun;
+using OASystem.Domain.ViewModels.JuHeExchangeRate;
+using OASystem.Domain.ViewModels.SmallFun;
+using System.DirectoryServices.Protocols;
 using System.Net.Http;
 using System.Net.Http.Json;
+using System.Text.Json;
 using Ubiety.Dns.Core;
 
 namespace OASystem.API.OAMethodLib.JuHeAPI
@@ -16,39 +23,272 @@ 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>
-        /// 汇率转换
+        /// 获取汇率
         /// </summary>
         /// <returns></returns>
-        /// <exception cref="NotImplementedException"></exception>
-        public async Task<string> GetExchangeRateAsync()
+        public async Task<JuHeAPIResult> 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 result = new JuHeAPIResult() { Resultcode = "-2",Reason="未知错误" };
+
+            string rateDataString = await RedisRepository.RedisFactory
+                                                         .CreateRedisRepository()
+                                                         .StringGetAsync<string>("JuHeApiExchangeRate");//string 取
+
+            if (string.IsNullOrEmpty(rateDataString))
             {
-                var stringResponse = await exchangeReq.Content.ReadAsStringAsync();
+                #region 请求接口并存入缓存
+                string url = string.Format("/finance/exchange/rmbquot");
+
+                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 });
+
+                        if (result.Resultcode == "200")
+                        {
+                            List<ExchangeRateModel> rateList = new List<ExchangeRateModel>();
+
+                            #region 处理数据类型
+                            JArray jar = JArray.Parse(result.Result.ToJson());
+                            for (int i = 0; i < jar.Count; i++)
+                            {
+                                JObject j = JObject.Parse(jar[i].ToString());
+                                for (int x = 1; x < j.Count + 1; x++)
+                                {
+                                    string rateName = "data" + x;
+                                    string rateDataStr = j[rateName].ToString();
+                                    if (!string.IsNullOrEmpty(rateDataStr))
+                                    {
+                                        ExchangeRateModel exchangeRate = JsonConvert.DeserializeObject<ExchangeRateModel>(rateDataStr);
+                                        rateList.Add(exchangeRate);
+                                    }
+                                }
+                            }
+                            #endregion
 
 
+                            TimeSpan ts = DateTime.Now.AddMinutes(120) - DateTime.Now; //设置redis 过期时间 120分钟
+                            await RedisRepository
+                                .RedisFactory
+                                .CreateRedisRepository()
+                                .StringSetAsync<string>("JuHeApiExchangeRate", rateList.ToJson(), ts);//string 存
+
+                            result.Result = rateList;
+                        }
+                        else
+                        {
+                            result.Reason = string.Format("聚合APIError[Error_Code:{0} Resultcode:{1} Msg:{2}]",
+                                result.Error_code, result.Resultcode, result.Result);
+                        }
+
+                    }
+                    else
+                    {
+                        result.Reason = "汇率接口请求失败!";
+                    }
+                }
+                catch (Exception ex)
+                {
+                    result.Reason = ex.Message;
+                }
+                #endregion
+
             }
-            else {
-               
+            else
+            {
+                result.Resultcode = "200";
+                result.Result = JsonConvert.DeserializeObject<List<ExchangeRateModel>>(rateDataString);
             }
+            return result;
+        }
+
+        /// <summary>
+        /// 获取汇率 Single
+        /// </summary>
+        /// <param name="currencyCode">币种code</param>
+        /// <returns></returns>
+        public async Task<Result> GetSingleRateAsync(string currencyCode)
+        {
 
-            throw new HttpRequestException(exchangeReq.ReasonPhrase);
+            var result = new Result() { Code = -2, Msg = "未知错误" };
+            if (currencyCode.ToUpper() == "CNY" )
+            {
+                return result;
+            }
 
+            var resultData = await GetExchangeRateAsync();
+            var rateCurrencyData = AppSettingsHelper.Get<RateCurrencyModel>("RateCurrency");
+            var currencyModel = rateCurrencyData.Where(a => a.CurrencyCode == currencyCode).FirstOrDefault();
+            if (currencyModel != null)
+            {
+                if (resultData.Resultcode == "200")
+                {
+                    if (resultData.Result != null)
+                    {
+                        result.Code = 0;
+                        result.Data = ((List<ExchangeRateModel>)resultData.Result).Where(a => a.Name == currencyModel.CurrencyName).FirstOrDefault();
+                    }
+                }
+                else
+                {
+                    result.Msg = resultData.Reason;
+                }
+            }
+            return result;
         }
+
+        /// <summary>
+        /// 获取汇率转换结果
+        /// </summary>
+        /// <returns></returns>
+        public async Task<Result> GetExchangeRateAsync(ExchangeRateDto dto)
+        {
+            var result = new Result() { Code = -2, Msg = "未知错误" };
+
+            var rateCurrencyData = AppSettingsHelper.Get<RateCurrencyModel>("RateCurrency");
+
+            if (dto.CurrencyCodePer.ToUpper() == "CNY")
+            {
+                var currencyModelSuf = rateCurrencyData.Where(a => a.CurrencyCode == dto.CurrencyCodeSuf).FirstOrDefault();
+                if (currencyModelSuf == null)
+                {
+                    result.Msg = "转换后币种未找到!";
+                    return result;
+                }
+                var rateModelSuf = await GetSingleRateAsync(currencyModelSuf.CurrencyCode);
+                if (rateModelSuf.Code != 0)
+                {
+                    result.Msg = rateModelSuf.Msg;
+                    return result;
+                }
+                if (string.IsNullOrEmpty(rateModelSuf.Data.FSellPri))
+                {
+                    result.Msg = string.Format("{0}({1})暂无汇率!", currencyModelSuf.CurrencyName, currencyModelSuf.CurrencyCode);
+                    return result;
+                }
+
+                decimal moneySuf = Convert.ToDecimal(rateModelSuf.Data.FSellPri) / 100 ; //fSellPri
+                decimal settlementMoney = dto.Money / moneySuf;
+                var rateView = new ExchangeRateView { 
+                    CurrencyCodePre = dto.CurrencyCodePer,
+                    CurrencyNamePre = "人民币",
+                    MoneyPre = dto.Money,
+                    CurrencyCodeSuf = dto.CurrencyCodeSuf,
+                    CurrencyNameSuf = currencyModelSuf.CurrencyName,
+                    MoneySuf = CommonFun.CutDecimalWithN( settlementMoney,4),
+                    UpdateTime = string.Format("{0} {1}", rateModelSuf.Data.Date, rateModelSuf.Data.Time)
+                };
+
+                result.Code = 0;
+                result.Msg = "成功!";
+                result.Data = rateView;
+                return result;
+            }
+            else
+            {
+                var currencyModelPre = rateCurrencyData.Where(a => a.CurrencyCode == dto.CurrencyCodePer).FirstOrDefault();
+
+                if (currencyModelPre == null)
+                {
+                    result.Msg = "转换前币种未找到!";
+                    return result;
+                }
+
+                var rateModelPre = await GetSingleRateAsync(currencyModelPre.CurrencyCode);
+                if (rateModelPre.Code != 0)
+                {
+                    result.Msg = rateModelPre.Msg;
+                    return result;
+                }
+
+                if (string.IsNullOrEmpty(rateModelPre.Data.FSellPri))
+                {
+                    result.Msg = string.Format("{0}({1})暂无汇率!", currencyModelPre.CurrencyName, currencyModelPre.CurrencyCode);
+                    return result;
+                }
+
+                decimal moneyPre = (Convert.ToDecimal(rateModelPre.Data.FSellPri) / 100) * dto.Money; //fSellPri
+
+                if (dto.CurrencyCodeSuf.ToUpper() == "CNY")
+                {
+                    var rateView = new ExchangeRateView
+                    {
+                        CurrencyCodePre = dto.CurrencyCodePer,
+                        CurrencyNamePre = currencyModelPre.CurrencyName,
+                        MoneyPre = dto.Money,
+                        CurrencyCodeSuf = "CNY",
+                        CurrencyNameSuf = "人民币",
+                        MoneySuf = CommonFun.CutDecimalWithN(moneyPre, 4),
+                        UpdateTime = string.Format("{0} {1}", rateModelPre.Data.Date, rateModelPre.Data.Time)
+                    };
+
+                    result.Code = 0;
+                    result.Msg = "成功!";
+                    result.Data = rateView;
+                }
+                else
+                {
+                    var currencyModelSuf = rateCurrencyData.Where(a => a.CurrencyCode == dto.CurrencyCodeSuf).FirstOrDefault();
+
+                    if (currencyModelSuf == null)
+                    {
+                        result.Msg = "转换后币种未找到!";
+                        return result;
+                    }
+
+                    var rateModelSuf = await GetSingleRateAsync(currencyModelSuf.CurrencyCode);
+                    if (rateModelSuf.Code != 0)
+                    {
+                        result.Msg = rateModelSuf.Msg;
+                        return result;
+                    }
+                    if (string.IsNullOrEmpty(rateModelSuf.Data.FSellPri))
+                    {
+                        result.Msg = string.Format("{0}({1})暂无汇率!", currencyModelSuf.CurrencyName, currencyModelSuf.CurrencyCode);
+                        return result;
+                    }
+
+                    decimal moneySuf = Convert.ToDecimal(rateModelSuf.Data.FSellPri) / 100; //fSellPri
+
+                    decimal settlementMoney = moneyPre / moneySuf;
+                    var rateView = new ExchangeRateView
+                    {
+                        CurrencyCodePre = dto.CurrencyCodePer,
+                        CurrencyNamePre = currencyModelPre.CurrencyName,
+                        MoneyPre = dto.Money,
+                        CurrencyCodeSuf = dto.CurrencyCodeSuf,
+                        CurrencyNameSuf = currencyModelSuf.CurrencyName,
+                        MoneySuf = CommonFun.CutDecimalWithN(settlementMoney, 4),
+                        UpdateTime = string.Format("{0} {1}", rateModelSuf.Data.Date, rateModelSuf.Data.Time)
+                    };
+
+                    result.Code = 0;
+                    result.Msg = "成功!";
+                    result.Data = rateView;
+                }
+            }
+
+            return result;
+        }
+
     }
 }

+ 25 - 12
OASystem/OASystem.Api/Program.cs

@@ -36,6 +36,18 @@ 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 =>
 {
@@ -46,19 +58,19 @@ builder.Services.AddCors(policy =>
     .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<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<KestrelServerOptions>(options =>
+{
+    options.Limits.MaxRequestBodySize = int.MaxValue;
+    options.Limits.MaxRequestBufferSize = int.MaxValue;
+});
 
 #endregion
 
@@ -223,6 +235,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
 

+ 91 - 1
OASystem/OASystem.Api/appsettings.json

@@ -12,5 +12,95 @@
     "DefaultUser": "51",
     "Boss": "21",
     "FilterUser": "51,180"
-  }
+  },
+  "RateCurrency": [
+    {
+      "CurrencyName": "人民币",
+      "CurrencyCode": "CNY"
+    },
+    {
+      "CurrencyName": "美元",
+      "CurrencyCode": "USD"
+    },
+    {
+      "CurrencyName": "欧元",
+      "CurrencyCode": "EUR"
+    },
+    {
+      "CurrencyName": "港币",
+      "CurrencyCode": "HKD"
+    },
+    {
+      "CurrencyName": "日元",
+      "CurrencyCode": "JPY"
+    },
+    {
+      "CurrencyName": "英镑",
+      "CurrencyCode": "GBP"
+    },
+    {
+      "CurrencyName": "澳大利亚元",
+      "CurrencyCode": "AUD"
+    },
+    {
+      "CurrencyName": "加拿大元",
+      "CurrencyCode": "CAD"
+    },
+    {
+      "CurrencyName": "泰国铢",
+      "CurrencyCode": "THB"
+    },
+    {
+      "CurrencyName": "新加坡元",
+      "CurrencyCode": "SGD"
+    },
+    {
+      "CurrencyName": "瑞士法郎",
+      "CurrencyCode": "CHK"
+    },
+    {
+      "CurrencyName": "丹麦克朗",
+      "CurrencyCode": "DKK"
+    },
+    {
+      "CurrencyName": "澳门元",
+      "CurrencyCode": "MOP"
+    },
+    {
+      "CurrencyName": "林吉特",
+      "CurrencyCode": "MYR"
+    },
+    {
+      "CurrencyName": "挪威克朗",
+      "CurrencyCode": "NOK"
+    },
+    {
+      "CurrencyName": "新西兰元",
+      "CurrencyCode": "NZD"
+    },
+    {
+      "CurrencyName": "卢布",
+      "CurrencyCode": "RUB"
+    },
+    {
+      "CurrencyName": "瑞典克朗",
+      "CurrencyCode": "SEK"
+    },
+    {
+      "CurrencyName": "菲律宾比索",
+      "CurrencyCode": "PHP"
+    },
+    {
+      "CurrencyName": "新台币",
+      "CurrencyCode": "TWD"
+    },
+    {
+      "CurrencyName": "巴西雷亚尔",
+      "CurrencyCode": "BRL"
+    },
+    {
+      "CurrencyName": "韩国元",
+      "CurrencyCode": "ZAR"
+    }
+  ]
 }

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

@@ -20,4 +20,9 @@ namespace OASystem.Domain.Dtos
         public int PageIndex { get; set; } = 1;
         public int PageSize { get; set; } = 10;
     }
+
+    public class JsonDtoBase
+    {
+        public string Paras { get; set; }
+    }
 }

+ 11 - 0
OASystem/OASystem.Domain/Dtos/Resource/ThreeCodeDto.cs

@@ -6,6 +6,17 @@ using System.Threading.Tasks;
 
 namespace OASystem.Domain.Dtos.Resource
 {
+    public class QueryThreeCodeDto:DtoBase
+    {
+        /// <summary>
+        /// 三字码
+        /// </summary>
+        public string Three { get; set; }
+        /// <summary>
+        /// 城市
+        /// </summary>
+        public string City { get; set; }
+    }
     public class ThreeCodeOperationDto
     {
         /// <summary>

+ 30 - 0
OASystem/OASystem.Domain/Dtos/SmallFun/ExchangeRateDto.cs

@@ -0,0 +1,30 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Dtos.SmallFun
+{
+    /// <summary>
+    /// 获取汇率 请求dto
+    /// </summary>
+    public class ExchangeRateDto:DtoBase
+    {
+        /// <summary>
+        /// 转换前币种Code
+        /// </summary>
+        public string CurrencyCodePer { get; set; }
+
+        /// <summary>
+        /// 转换后Code
+        /// </summary>
+        public string CurrencyCodeSuf { get; set; }
+
+        /// <summary>
+        /// 转换金额
+        /// </summary>
+        public decimal Money { get; set; }
+
+    }
+}

+ 41 - 0
OASystem/OASystem.Domain/Entities/Business/Bus_ConfItemInfo.cs

@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Business
+{
+    /// <summary>
+    /// 会务采购物品
+    /// </summary>
+    [SugarTable("Bus_ConfItem")]
+    public class Bus_ConfItemInfo : EntityBase
+    {
+        /// <summary>
+        /// 物料编号
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int ItemId { get; set; }
+        /// <summary>
+        /// 清单Id
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int ConfListId { get; set; }
+        /// <summary>
+        /// 采购数量
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int Count { get; set; }
+        /// <summary>
+        /// 本次采购金额
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "decimal(9,2)")]
+        public decimal CurrCost { get; set; }
+        /// <summary>
+        /// 操作备注
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(500)")]
+        public string OpRemark { get; set; }
+    }
+}

+ 24 - 0
OASystem/OASystem.Domain/Entities/Business/Bus_ConfItemListInfo.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Business
+{
+    [SugarTable("Bus_ConfItemList")]
+    public class Bus_ConfItemListInfo : EntityBase
+    {
+        /// <summary>
+        /// 团组(会议)编号
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
+        public int Diid { get; set; }
+        /// <summary>
+        /// 总计成本
+        /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "decimal(10,2)")]
+        public decimal TotalCost { get; set; }
+
+    }
+}

+ 3 - 3
OASystem/OASystem.Domain/Enums/GrpScheduleEnum.cs

@@ -15,13 +15,13 @@ namespace OASystem.Domain.Enums
         /// <summary>
         /// 未开始/等待任务分配 I
         /// </summary>
-        [Description("未开始/等待任务分配")]
+        [Description("团组出行")]
         Wait = 0,
 
         /// <summary>
-        /// 确认出团/任务分配 I
+        /// 确认出团/任务分配完成 I
         /// </summary>
-        [Description("确认出团/任务分配完成")]
+        [Description("确认出团")]
         Confirm = 1,
 
         #region 经费预算

+ 13 - 0
OASystem/OASystem.Domain/ViewModels/Business/Bus_ConfItemListView.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Business
+{
+    public class Bus_ConfItemListView
+    {
+        public int MyProperty { get; set; }
+    }
+}

+ 2 - 1
OASystem/OASystem.Domain/ViewModels/Groups/Grp_ScheduleCombinView.cs

@@ -9,7 +9,8 @@ namespace OASystem.Domain.ViewModels.Groups
     public class Grp_ScheduleCombinView
     {
         public Grp_ScheduleView Primary { get; set; }
-        public List<Grp_ScheduleDetailView> ChildList { get; set; }
+        //public List<Grp_ScheduleDetailView> ChildList { get; set; }
         public List<Grp_SchedulePersonView> PersonList { get; set; }
+        public List<Grp_ScheduleRootView> RootList { get; set; }
     }
 }

+ 1 - 0
OASystem/OASystem.Domain/ViewModels/Groups/Grp_ScheduleDetailView.cs

@@ -37,6 +37,7 @@ namespace OASystem.Domain.ViewModels.Groups
         public string Remark { get; set; }
         public int Exception { get; set; }
         public int Level { get; set; }
+        public int StepStatus { get; set; }
         public List<Grp_ScheduleDetailView> ChildList { get; set; }
     }
 }

+ 26 - 0
OASystem/OASystem.Domain/ViewModels/Groups/Grp_ScheduleView.cs

@@ -2,6 +2,7 @@
 using OASystem.Domain.Enums;
 using System;
 using System.Collections.Generic;
+using System.Collections.Specialized;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -66,4 +67,29 @@ namespace OASystem.Domain.ViewModels.Groups
         /// </summary>
         public int Exception { get; set; }
     }
+
+    public class Grp_ScheduleRootView
+    {
+        public int Root { get; set; }
+        public string RootName
+        {
+            get
+            {
+                NameValueCollection nvc = EnumHelper.GetNVCFromEnumValue(typeof(GrpSchedulePrimaryStepEnum));
+                string rst = nvc[this.Root.ToString()];
+                if (string.IsNullOrEmpty(rst))
+                {
+                    rst = Root.ToString();
+                }
+                return rst;
+            }
+        }
+        public List<Grp_ScheduleDetailView> ChildList { get; set; }
+        public GrpConfig Config { get; set; }
+    }
+
+    public class GrpConfig
+    {
+        public string backgroundColor { get; set; }
+    }
 }

+ 22 - 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;
@@ -68,6 +69,11 @@ namespace OASystem.Domain.ViewModels.JuHeExchangeRate
         /// </summary>
         public string? MBuyPri { get; set; }
 
+        /// <summary>
+        /// 现汇卖出价
+        /// </summary>
+        public string? FSellPri { get; set; }
+
         /// <summary>
         /// 现钞卖出价
         /// </summary>
@@ -89,4 +95,20 @@ namespace OASystem.Domain.ViewModels.JuHeExchangeRate
         public string? Time { get; set; }
     }
 
+
+    /// <summary>
+    /// 汇率 币种Model
+    /// </summary>
+    public record RateCurrencyModel
+    {
+        /// <summary>
+        /// 币种名称
+        /// </summary>
+        public string CurrencyName { get; set; }
+
+        /// <summary>
+        /// 币种Code
+        /// </summary>
+        public string CurrencyCode{ get; set; }
+    }
 }

+ 6 - 0
OASystem/OASystem.Domain/ViewModels/Resource/HotelDataView.cs

@@ -11,7 +11,13 @@ namespace OASystem.Domain.ViewModels.Resource
     {
     }
     public class QueryHotelDataSelect {
+        /// <summary>
+        /// id
+        /// </summary>
         public int Id { get; set; }
+        /// <summary>
+        /// 城市名
+        /// </summary>
         public string City { get; set; }
     }
 

+ 13 - 0
OASystem/OASystem.Domain/ViewModels/Resource/SetDataTypeView.cs

@@ -0,0 +1,13 @@
+using OASystem.Domain.Entities.System;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Resource
+{
+    public class SetDataTypeView: Sys_SetDataType
+    {
+    }
+}

+ 5 - 0
OASystem/OASystem.Domain/ViewModels/Resource/ThreeCodeView.cs

@@ -10,4 +10,9 @@ namespace OASystem.Domain.ViewModels.Resource
     public class ThreeCodeView:Res_ThreeCode
     {
     }
+    public class ThreeCodeSelectView
+    {
+        public int Id { get; set; }
+        public string City { get; set; }
+    }
 }

+ 50 - 0
OASystem/OASystem.Domain/ViewModels/SmallFun/ExchangeRateView.cs

@@ -0,0 +1,50 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.SmallFun
+{
+    /// <summary>
+    /// 汇率
+    /// 返回视图
+    /// </summary>
+    public class ExchangeRateView
+    {
+        /// <summary>
+        /// 转换前币种
+        /// </summary>
+        public string CurrencyCodePre { get; set; }
+
+        /// <summary>
+        /// 转换前名称
+        /// </summary>
+        public string CurrencyNamePre { get; set; }
+
+        /// <summary>
+        /// 转换前金额
+        /// </summary>
+        public decimal MoneyPre { get; set; }
+
+        /// <summary>
+        /// 转换后币种
+        /// </summary>
+        public string CurrencyCodeSuf { get; set; }
+
+        /// <summary>
+        /// 转换后名称
+        /// </summary>
+        public string CurrencyNameSuf { get; set; }
+
+        /// <summary>
+        /// 转换后金额
+        /// </summary>
+        public decimal MoneySuf { get; set; }
+
+        /// <summary>
+        /// 更新时间
+        /// </summary>
+        public string? UpdateTime { 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;

+ 35 - 3
OASystem/OASystem.Infrastructure/Repositories/Groups/GrpScheduleRepository.cs

@@ -59,6 +59,29 @@ namespace OASystem.Infrastructure.Repositories.Groups
             #endregion
             _view.Primary = primary;
 
+            #region 主流程节点
+
+            List<Grp_ScheduleRootView> rootList = new List<Grp_ScheduleRootView>()
+            {
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Wait },
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Confirm},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Budget},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Feedback},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Puote},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Visa},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Business},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.CostAudit},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Pay},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Training},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.DropOff},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.PickUp},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Collect},
+                  new Grp_ScheduleRootView() { Root = (int)GrpSchedulePrimaryStepEnum.Finish}
+            };
+
+
+            #endregion
+
             #region 子节点
 
             //子节点
@@ -82,6 +105,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 temp.Remark = item.Remark;
                 temp.Root = item.ParentStep;
                 temp.Step = item.Step;
+                temp.StepStatus = item.StepStatus;
 
                 List<Grp_ScheduleDetailInfo> tempLv3List = LV3List.Where(s => s.ParentStep == item.Step).ToList();
                 List<Grp_ScheduleDetailView> tempChildList = new List<Grp_ScheduleDetailView>();
@@ -101,14 +125,22 @@ namespace OASystem.Infrastructure.Repositories.Groups
                         temp2.Remark = item2.Remark;
                         temp2.Root = item2.ParentStep;
                         temp2.Step = item2.Step;
+                        temp2.StepStatus = item2.StepStatus;
                         tempChildList.Add(temp2);
                     }
                 }
                 temp.ChildList = new List<Grp_ScheduleDetailView>(tempChildList);
+
+
                 childList.Add(temp);
             }
             #endregion
-            _view.ChildList = new List<Grp_ScheduleDetailView>(childList);
+            foreach (var item in rootList)
+            {
+                item.ChildList = new List<Grp_ScheduleDetailView>(childList.Where(s => s.Root == item.Root).ToList());
+            }
+
+            _view.RootList = new List<Grp_ScheduleRootView>(rootList);
 
             #region 流程人员
             List<Grp_SchedulePersonInfo> personEntityList = _sqlSugar.Queryable<Grp_SchedulePersonInfo>().Where(s => s.IsDel != 1 && s.ScheduleId == _dto.ScheduleId).ToList();
@@ -118,7 +150,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
                 Grp_SchedulePersonView temp = new Grp_SchedulePersonView();
                 temp.JobStr = item.JobStr;
                 temp.PersonId = item.Id;
-                temp.PersonRemark=item.Remark;
+                temp.PersonRemark = item.Remark;
                 temp.SysUserId = item.SysUserId;
                 temp.SysUserName = item.SysUserName;
                 personList.Add(temp);
@@ -143,7 +175,7 @@ namespace OASystem.Infrastructure.Repositories.Groups
             return _viewList;
         }
 
-        public void bulkInsert<T>(List<T> list)
+        public void bulkInsert<T>(List<T> list) where T : class, new()
         {
             _sqlSugar.Insertable(list).UseParameter().ExecuteCommand();
         }

+ 1 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/CarDataRepository.cs

@@ -41,6 +41,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
                 {
                     sqlWhere += string.Format(@" And ContactTel like '%{0}%'", dto.ContactTel);
                 }
+                sqlWhere += string.Format(@" And IsDel={0}", 0);
                 if (!string.IsNullOrEmpty(sqlWhere.Trim()))
                 {
                     Regex r = new Regex("And");

+ 1 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/HotelDataRepository.cs

@@ -101,6 +101,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
                 {
                     sqlWhere += string.Format(@" And ContactPhone like '%{0}%'", dto.ContactPhone);
                 }
+                sqlWhere += string.Format(@" And IsDel={0}", 0);
                 if (!string.IsNullOrEmpty(sqlWhere.Trim()))
                 {
                     Regex r = new Regex("And");

+ 1 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/LocalGuideDataRepository.cs

@@ -108,6 +108,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
                 {
                     sqlWhere += string.Format(@" And ContactTel like '%{0}%'", dto.ContactTel);
                 }
+                sqlWhere += string.Format(@" And IsDel={0}", 0);
                 if (!string.IsNullOrEmpty(sqlWhere.Trim()))
                 {
                     Regex r = new Regex("And");

+ 24 - 0
OASystem/OASystem.Infrastructure/Repositories/Resource/SetDataTypeRepository.cs

@@ -0,0 +1,24 @@
+using AutoMapper;
+using OASystem.Domain;
+using OASystem.Domain.Dtos.Resource;
+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 SetDataTypeRepository: BaseRepository<Sys_SetDataType, SetDataTypeView>
+    {
+        private readonly IMapper _mapper;
+        public SetDataTypeRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
+        {
+            _mapper = mapper;
+        }
+     
+    }
+   
+}

+ 112 - 12
OASystem/OASystem.Infrastructure/Repositories/Resource/ThreeCodeRepository.cs

@@ -21,31 +21,131 @@ namespace OASystem.Infrastructure.Repositories.Resource
         /// <param name="PageSize"></param>
         /// <returns></returns>
 
-        public async Task<JsonView> QuerThreeCode(int PageIndex, int PageSize)
+        public async Task<Result> QueryThreeCode(QueryThreeCodeDto dto)
         {
-            JsonView result = new JsonView();
+            Result result = new Result() { Code = -2, Msg = "未知错误" };
             try
             {
-               
-                int totalCount = 0;
-                List<Res_ThreeCode> page = _sqlSugar.Queryable<Res_ThreeCode>().ToPageList(PageIndex, PageSize, ref totalCount);
-                if (page.Count != 0)
+                string sqlWhere = string.Empty;
+                if (!string.IsNullOrWhiteSpace(dto.City))
+                {
+                    sqlWhere += string.Format(@" And City like '%{0}%'", dto.City);
+                }
+                if (!string.IsNullOrWhiteSpace(dto.Three))
+                {
+                    sqlWhere += string.Format(@" And Three like '%{0}%'", dto.Three);
+                }
+                sqlWhere += string.Format(@" And IsDel={0}", 0);
+                if (!string.IsNullOrEmpty(sqlWhere.Trim()))
                 {
-                    result=new JsonView(){Code=200,Msg = "查询成功!",Data = page,Count = totalCount };
+                    Regex r = new Regex("And");
+                    sqlWhere = r.Replace(sqlWhere, "Where", 1);
+                }
+                if (dto.PortType == 1)
+                {
+                    string sql = string.Format(@"select * from Res_ThreeCode  {0}", sqlWhere);
+                    List<Res_ThreeCode> ThreeCode = await _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToListAsync();
+                    if (ThreeCode.Count == 0)
+                    {
+                        return result = new Result() { Code = -1, Msg = "暂无数据" };
+                    }
+                    ThreeCode = ThreeCode.OrderByDescending(x => x.CreateTime).ToList();
+
+                    if (dto.PageSize == 0 && dto.PageIndex == 0)
+                    {
+                        return result = new Result()
+                        {
+                            Code = 0,
+                            Msg = "查询成功",
+                            Data = ThreeCode,
+                        };
+                    }
+                    else
+                    {
+                        int count = ThreeCode.Count;
+                        float totalPage = (float)count / dto.PageSize;//总页数
+                        if (totalPage == 0) totalPage = 1;
+                        else totalPage = (int)Math.Ceiling((double)totalPage);
+
+                        List<Res_ThreeCode> _ThreeCode = new List<Res_ThreeCode>();
+                        for (int i = 0; i < dto.PageSize; i++)
+                        {
+                            var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
+                            if (RowIndex < ThreeCode.Count)
+                            {
+                                _ThreeCode.Add(ThreeCode[RowIndex]);
+                            }
+                            else
+                            {
+                                break;
+                            }
+                        }
+                        return result = new Result()
+                        {
+                            Code = 0,
+                            Msg = "查询成功",
+                            Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _ThreeCode },
+                        };
+                    }
+
+                }
+                else if (dto.PortType == 2)
+                {
+                    string sql = string.Format(@"select * from Res_ThreeCode  {0}", sqlWhere);
+                    List<Res_ThreeCode> ThreeCode = await _sqlSugar.SqlQueryable<Res_ThreeCode>(sql).ToListAsync();
+                    if (ThreeCode.Count == 0)
+                    {
+                        return result = new Result() { Code = -1, Msg = "暂无数据" };
+                    }
+                    ThreeCode = ThreeCode.OrderByDescending(x => x.CreateTime).ToList();
+
+                    if (dto.PageSize == 0 && dto.PageIndex == 0)
+                    {
+                        return result = new Result()
+                        {
+                            Code = 0,
+                            Msg = "查询成功",
+                            Data = ThreeCode,
+                        };
+                    }
+                    else
+                    {
+                        int count = ThreeCode.Count;
+                        float totalPage = (float)count / dto.PageSize;//总页数
+                        if (totalPage == 0) totalPage = 1;
+                        else totalPage = (int)Math.Ceiling((double)totalPage);
+
+                        List<Res_ThreeCode> _ThreeCode = new List<Res_ThreeCode>();
+                        for (int i = 0; i < dto.PageSize; i++)
+                        {
+                            var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
+                            if (RowIndex < ThreeCode.Count)
+                            {
+                                _ThreeCode.Add(ThreeCode[RowIndex]);
+                            }
+                            else
+                            {
+                                break;
+                            }
+                        }
+                        return result = new Result()
+                        {
+                            Code = 0,
+                            Msg = "查询成功",
+                            Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = _ThreeCode },
+                        };
+                    }
                 }
                 else
                 {
-                    result = new JsonView(){ Code = 400, Msg = "查询失败!", Data = page, Count = totalCount };
+                    return result = new Result() { Code = -2, Msg = "请传入PortType参数!1:Web,2:Android,3:IOS" };
                 }
             }
             catch (Exception)
             {
-                result = new JsonView() { Code = 400, Msg = "程序错误!", Data = null, Count = 0 };
+                return result;
                 throw;
             }
-            
-           
-            return result;
         }
 
         /// <summary>

+ 38 - 0
OASystem/OASystem.Infrastructure/Tools/CommonFun.cs

@@ -196,4 +196,42 @@ public static class CommonFun
     }
 
     #endregion
+
+    #region decimal 截取
+    /// <summary>
+    /// 
+    /// </summary>
+    /// <param name="d"></param>
+    /// <param name="n"></param>
+    /// <returns></returns>
+    public static decimal CutDecimalWithN(decimal d, int n)
+    {
+        string strDecimal = d.ToString();
+        int index = strDecimal.IndexOf(".");
+        if (index == -1 || strDecimal.Length < index + n + 1)
+        {
+            strDecimal = string.Format("{0:F" + n + "}", d);
+        }
+        else
+        {
+            int length = index;
+            if (n != 0)
+            {
+                length = index + n + 1;
+            }
+            strDecimal = strDecimal.Substring(0, length);
+        }
+        return Decimal.Parse(strDecimal);
+    }
+
+    public static decimal CutDecimalWithN(decimal? d, int n)
+    {
+        if (d == null)
+        {
+            return Decimal.MinValue;
+        }
+        return CutDecimalWithN(Convert.ToDecimal(d), n);
+    }
+
+    #endregion
 }