Browse Source

合并团组文件

amigotrip 9 months ago
parent
commit
39c2f14814

+ 4 - 1
OASystem/EntitySync/EntitySync.csproj

@@ -10,7 +10,10 @@
   <ItemGroup>
     <PackageReference Include="Autofac" Version="6.4.0" />
     <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
-    <PackageReference Include="SqlSugarCore" Version="5.1.3.32" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\OASystem.Api\OASystem.API.csproj" />
   </ItemGroup>
 
 </Project>

+ 2 - 1
OASystem/EntitySync/Program.cs

@@ -137,7 +137,8 @@ db.CodeFirst.SetStringDefaultLength(50).BackupTable().InitTables(new Type[]
     //typeof(Grp_ApprovalTravelDetails),  //公务出访表
      //typeof(Sys_Countries),  //洲
      //typeof(Sys_Continent),  //国家
-     //typeof(Sys_Cities),  //城市
+     typeof(Sys_Cities),  //城市
+     typeof(Grp_GroupModelFile),//团组文件
 
 });
 Console.WriteLine("数据库结构同步完成!");

+ 132 - 0
OASystem/OASystem.Api/Controllers/FinancialController.cs

@@ -47,6 +47,11 @@ using Org.BouncyCastle.Asn1.Crmf;
 using EyeSoft.Extensions;
 using System.Collections;
 using SqlSugar.Extensions;
+using System.Linq.Expressions;
+using MathNet.Numerics.Distributions;
+using System.Diagnostics.Metrics;
+using EyeSoft.Collections.Generic;
+using Microsoft.Extensions.Hosting;
 
 namespace OASystem.API.Controllers
 {
@@ -4774,6 +4779,133 @@ Group by PriceType ", dto.diId);
             {
 
 
+            }
+            else if (Invitation.Contains(userId))
+            {
+                // 2)付费公务活动部分:¥50 / 团;
+                //4)不付费公务活动部分(自己联络)额外奖励:¥200 / 团(若公务活动方与邀请方为同一机构,奖励金额为¥100 / 团);
+                //5)只发邀请的团组不付费邀请额外奖励:¥100 / 团;
+                //邀请方已授权我司签发的邀请仍按照:¥100 / 团,无额外奖励。 
+                var officialList = _sqlSugar.Queryable<Res_OfficialActivities, Grp_DelegationInfo>((x,a)=> 
+                    new JoinQueryInfos(JoinType.Left,a.Id == x.DiId)
+                ).Where((x,a) => x.IsSubmitApproval == 0 && x.IsDel == 0 && a.IsDel == 0
+                    && a.VisitDate > StartDateTime && a.VisitDate < EndDateTime
+                )
+                .Select((x, a) => new
+                {
+                    a.Id,
+                    a.TeamName,
+                    a.VisitDate,
+                    x.CreateUserId,
+                    x.Type
+                })
+                .ToList();
+
+                var groups = officialList.GroupBy(x => x.Id);
+
+                foreach (var group in groups)
+                {
+                    var officialGroupList = group.GroupBy(d => d.CreateUserId);
+                    int operUserMax = 0, operMaxCount = 0;
+
+                    foreach (var item in officialGroupList)
+                    {
+                        if (item.Count() > operMaxCount)
+                        {
+                            operUserMax = item.Key;
+                            operMaxCount = item.Count();
+                        }
+                    }
+
+                    string temp = string.Empty;
+                    bool isBasics = operUserMax == userId;
+                    var comMoney = 0;
+
+                    foreach (var item in group)
+                    {
+                        if (item.Type == 0)
+                        {
+                            comMoney += (100 + 300);
+                        }
+                        else if (item.Type == 1)
+                        {
+                            comMoney += 300;
+                        }
+                        else if (item.Type == 2)
+                        {
+                            comMoney += 200;
+                        }
+                    }
+                }
+            }
+            else if (Visa.Contains(userId)) //签证
+            {
+                // 1)办理英国、加拿大、美国签证¥50元 / 人 / 团;
+                // 申根国家及其他所有国家¥30元 / 人 / 团;
+                var existsCountry = new string[] { "英国", "加拿大", "美国" };
+                var whereExpression = Expressionable.Create<Grp_VisaInfo, Grp_DelegationInfo, Grp_CreditCardPayment>()
+                    .Or(
+                        (x, a, b) => x.IsDel == 0 && x.CreateUserId == userId && (b.IsAuditGM == 1 || b.IsAuditGM == 3)
+                        && a.IsDel == 0 && a.VisitDate > StartDateTime && a.VisitDate < EndDateTime && b.IsDel == 0 && x.IsThird == 0 && x.PassengerType == 974
+                    );
+                var listVisa = _sqlSugar.Queryable<Grp_VisaInfo, Grp_DelegationInfo, Grp_CreditCardPayment>((x, a, b) => new
+                    JoinQueryInfos(
+                        JoinType.Left, a.Id == x.DIId,
+                        JoinType.Left, b.CTable == 80 && b.CId == x.Id)
+                    )
+                .Where(whereExpression.ToExpression())
+                .Select((x, a, b) => new
+                    {
+                        a.Id,
+                        a.TeamName,
+                        a.VisitDate,
+                        a.TeamLevSId,
+                        a.VisitPNumber,
+                        a.VisitCountry,
+                        x.VisaDescription,
+                        x.VisaFreeNumber,
+                        x.VisaNumber,
+                        x.VisaPrice
+                })
+                .ToList();
+
+                var groupByid = listVisa.GroupBy(x => x.Id);
+                foreach (var visaArr in groupByid)
+                {
+                    var groupinfo = listVisa.First(x => x.Id == visaArr.Key);
+                    var singlePrice = existsCountry.Where(x => groupinfo.VisitCountry.Contains(x)).Count() > 0 ? 50 : 30;
+                    int count = 0, money = 0;
+                    var arr = new ArrayList();
+                    foreach (var visa in visaArr)
+                    {
+                        if (visa.VisaPrice > 0)
+                        {
+                            count += visa.VisaFreeNumber + visa.VisaNumber;
+                            money += singlePrice * (visa.VisaFreeNumber + visa.VisaNumber);
+                        }
+                        else
+                        {
+                            count -= visa.VisaFreeNumber + visa.VisaNumber;
+                            money -= singlePrice * (visa.VisaFreeNumber + visa.VisaNumber);
+                        }
+                        string info = $"签证 {visa.VisaDescription}  {(visa.VisaPrice > 0 ? "" : "此笔为退费!")} 人数为{visa.VisaFreeNumber + visa.VisaNumber} 单价为{singlePrice} 金额为{singlePrice * (visa.VisaFreeNumber + visa.VisaNumber)}";
+                        arr.Add(info);
+                    }
+                   
+                    string temp  = "本团人数" + groupinfo.VisitPNumber + ",该人员" + user.CnName + "共办理英国、加拿大、美国签证" + (singlePrice == 50 ? count : 0).ToString() + "本护照(包含免签人员),申根国家及其他所有国家" + (singlePrice == 30 ? count : 0).ToString() + "本。" + user.CnName + "提成共" + money.ToString("#0.00") + "元";
+
+                    resultArr.Add(new
+                    {
+                        groupinfo.TeamName,
+                        groupinfo.Id,
+                        chiArr = arr,
+                        teamLvStr = teamLv.Find(x => x.Id == groupinfo.TeamLevSId)?.Name,
+                        groupinfo.VisitDate,
+                        temp,
+                        price = money,
+                    });
+                }
+
             }
 
             jw.Data = resultArr;

+ 98 - 0
OASystem/OASystem.Api/Controllers/GroupsController.cs

@@ -89,6 +89,8 @@ using K4os.Compression.LZ4.Internal;
 using static Pipelines.Sockets.Unofficial.SocketConnection;
 using System.Diagnostics.PerformanceData;
 using System.Drawing.Printing;
+using OASystem.Domain.Dtos.FileDto;
+using Microsoft.VisualBasic;
 
 namespace OASystem.API.Controllers
 {
@@ -3559,6 +3561,102 @@ namespace OASystem.API.Controllers
             }
         }
 
+        /// <summary>
+        /// 团组模块文件上传
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        public IActionResult CommonSaveFile([FromForm] CommonSaveFileDto dto)
+        {
+            var jw = JsonView(false);
+
+            if (dto.File == null)
+            {
+                jw.Msg = "无文件信息!";
+                return Ok(jw);
+            }
+
+            var nameSp = dto.File.FileName.Split(".");
+            if (nameSp.Length < 2)
+            {
+                jw.Msg = "拓展名称有误!";
+                return Ok(jw);
+            }
+
+            var existsName = new string[]{ "RAR", "ZIP", "ARJ","GZ","Z","7Z","TAR" };
+            if (!existsName.Contains(nameSp[1].ToUpper()))
+            {
+                jw.Msg = $"请使用指定拓展名!({string.Join("-",existsName)})";
+                return Ok(jw);
+            }
+
+            var Ctable = _sqlSugar.Queryable<Sys_SetData>().First(x => x.STid == 16 && x.IsDel == 0 && x.Id == dto.Ctable);
+            if (Ctable == null)
+            {
+                jw.Msg = "Ctable指向有误!";
+                return Ok(jw);
+            }
+
+            var groupInfo = _sqlSugar.Queryable<Grp_DelegationInfo>().First(x => x.Id == dto.Diid && x.IsDel == 0);
+            if (groupInfo == null)
+            {
+                jw.Msg = "团组信息不存在!";
+                return Ok(jw);
+            }
+
+            Ctable.Name = Regex.Replace(Ctable.Name, @"[^\w\.@-]", "",
+                    RegexOptions.None, TimeSpan.FromSeconds(1.5));
+            groupInfo.TeamName = Regex.Replace(groupInfo.TeamName, @"[^\w\.@-]", "",
+                    RegexOptions.None, TimeSpan.FromSeconds(1.5));
+
+            var path = "\\GroupModelFiles\\" + groupInfo.TeamName + "\\" + Ctable.Name;
+            var fileBase = AppSettingsHelper.Get("GrpFileBasePath") + path;
+
+            try
+            {
+                if (!Directory.Exists(fileBase))
+                {
+                    Directory.CreateDirectory(fileBase);
+                }
+
+                var saveFilePath = fileBase +"\\"+ dto.File.FileName;
+
+                Grp_GroupModelFile file = new Grp_GroupModelFile()
+                {
+                    Cid = dto.Cid,
+                    CreateTime = DateTime.Now,
+                    CreateUserId = dto.Userid,
+                    Ctable = dto.Ctable,
+                    Diid = dto.Diid,
+                    IsDel = 0,
+                    FilePath = saveFilePath,
+                };
+
+                using (FileStream fs = System.IO.File.Create(saveFilePath))
+                {
+                    dto.File.CopyTo(fs);
+                    fs.Flush();
+                }
+
+                var addResult = _sqlSugar.Insertable<Grp_GroupModelFile>(file).ExecuteCommand();
+
+                jw = JsonView(true, "保存成功!", new
+                {
+                    url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("GrpFileFtpPath") + path + "\\" + dto.File.FileName
+                });
+            }
+            catch (Exception ex)
+            {
+                jw = JsonView(false, $"保存失败! ({ex.Message}) ", new
+                {
+                    url = ""
+                }) ;
+            }
+
+            return Ok(jw);
+        }
+
         #endregion
 
         #region 团组英文资料

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

@@ -120,6 +120,7 @@
 
   "GrpFileBaseUrl": "http://132.232.92.186:24/",
   "GrpFileBasePath": "C:/Server/File/OA2023/Office/GrpFile/",
+  "GrpFileFtpPath": "Office/GrpFile/",
 
   "VisaProgressImageBaseUrl": "http://132.232.92.186:24/",
   "VisaProgressImageBasePath": "C:/Server/File/OA2023/Image/Visa/",

+ 10 - 1
OASystem/OASystem.Domain/Dtos/DtoBase.cs

@@ -90,5 +90,14 @@ namespace OASystem.Domain.Dtos
         public int PageId { get; set; }
     }
 
-   
+    public class CommonSaveFileDto
+    {
+        public IFormFile File { get; set; }
+        public int Ctable { get; set; }
+        public int Diid { get; set; }
+
+        public int Cid { get; set; }
+
+        public int Userid { get; set; }
+    }
 }

+ 23 - 0
OASystem/OASystem.Domain/Entities/Groups/GroupModelFile.cs

@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.Entities.Groups
+{
+    /// <summary>
+    /// 团组模块文件
+    /// </summary>
+    public class Grp_GroupModelFile: EntityBase
+    {
+        public int Diid { get; set; }
+
+        [SugarColumn(IsNullable = true, ColumnDataType = "nvarchar(150)")]
+        public string FilePath { get; set; }
+
+        public int Ctable { get; set; }
+
+        public int Cid { get; set; }
+    }
+}