Kaynağa Gözat

1、请示资料信息 --> 新增 省外办、市外办 word文件下载

LEIYI 1 yıl önce
ebeveyn
işleme
7db560875b

+ 806 - 304
OASystem/OASystem.Api/Controllers/ResourceController.cs

@@ -1,5 +1,6 @@
 using Aspose.Words;
 using EyeSoft.Extensions;
+using NPOI.SS.Formula.Functions;
 using OASystem.API.OAMethodLib;
 using OASystem.API.OAMethodLib.QiYeWeChatAPI.AppNotice;
 using OASystem.Domain.Dtos.CRM;
@@ -12,6 +13,7 @@ using OASystem.Infrastructure.Repositories.Groups;
 using Org.BouncyCastle.Utilities.Encoders;
 using System.Data;
 using static OASystem.API.OAMethodLib.JWTHelper;
+using static OpenAI.GPT3.ObjectModels.SharedModels.IOpenAiModels;
 
 namespace OASystem.API.Controllers
 {
@@ -2665,7 +2667,7 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
         /// <returns></returns>
         [HttpPost]
         [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
-        public async Task<IActionResult> AskDataProvinceFile(AskDataProvinceFileDto dto)
+        public async Task<IActionResult> AskDataProvinceFAOPFile(AskDataProvinceFileDto dto)
         {
             if (dto.DataIdItem.Length < 1) return Ok(JsonView(false,$"请传入有效的数据Id集合!"));
             if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
@@ -2679,8 +2681,6 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
             //数据源
             var idItem = dto.DataIdItem.OrderBy(x => x);
             var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
-            //团组信息
-            var groupInfo = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
 
             //书签名
             string Area = "",
@@ -2703,7 +2703,6 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
                 Official = Official + ad.UnitName + "、";
 
                 //填充表格数据源
-
                 DataRow dr = dt.NewRow();
                 if (i > 0)
                 {
@@ -2760,314 +2759,817 @@ Inner Join Sys_Department as d With(Nolock) On u.DepId=d.Id Where m.Id={0} ", _m
 
             #endregion
 
-            //#region 填充word模板书签内容
-           
-            ////接团客户名单实例
-            //List<DeleClient> clientList = new DeleClientService().GetAll(Convert.ToInt32(ddlTourCode.SelectedValue));
-            ////机票代码实例
-            //DataTable airTable = PublicCode.GetTableByBlackCode(Convert.ToInt32(ddlTourCode.SelectedValue));
-            ////三字码dal
-            //ThreeCodeServices ts = new ThreeCodeServices();
-
-            ////团名
-            //if (doc.Range.Bookmarks["TeamName"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["TeamName"];
-            //    mark.Text = groupInfo.TeamName;
-            //}
-
-            ////团长名
-            //if (doc.Range.Bookmarks["ClientName2"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["ClientName2"];
-            //    if (clientList == null || clientList.Count == 0)
-            //    {
-            //        mark.Text = "【本团尚未录入客户名单,请联系主管!】";
-            //    }
-            //    else
-            //    {
-            //        mark.Text = clientList[0].Company + clientList[0].Job + clientList[0].LastName + clientList[0].Name;
-            //    }
-            //}
-            //if (doc.Range.Bookmarks["ClientName"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["ClientName"];
-            //    if (clientList == null || clientList.Count == 0)
-            //    {
-            //        mark.Text = "【本团尚未录入客户名单,请联系主管!】";
-            //    }
-            //    else
-            //    {
-            //        mark.Text = clientList[0].Company + clientList[0].Job + clientList[0].LastName + clientList[0].Name;
-            //    }
-            //}
-
-            ////跟团人数
-            //if (doc.Range.Bookmarks["ClientNumber2"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
-            //    mark.Text = di.VisitPNumber.ToString();
-            //}
-            //if (doc.Range.Bookmarks["ClientNumber"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
-            //    mark.Text = di.VisitPNumber.ToString();
-            //}
-
-            ////地区
-            //if (doc.Range.Bookmarks["Area"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Area"];
-            //    mark.Text = Area.TrimEnd('、');
-            //}
-            //if (doc.Range.Bookmarks["Area2"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Area2"];
-            //    mark.Text = Area.TrimEnd('、');
-            //}
-
-            ////出访目的
-            //if (doc.Range.Bookmarks["Destination2"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Destination2"];
-            //    mark.Text = di.VisitPurpose;
-            //}
-            //if (doc.Range.Bookmarks["Destination"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Destination"];
-            //    mark.Text = di.VisitPurpose;
-            //}
-
-            ////邀请方
-            //if (doc.Range.Bookmarks["Official"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Official"];
-            //    mark.Text = Official.TrimEnd('、');
-            //}
-
-            ////出访日期
-            //if (doc.Range.Bookmarks["VisitDate"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["VisitDate"];
-            //    mark.Text = mark.Text = di.VisitStartDate.Split('-')[0] + "年"
-            //              + di.VisitStartDate.Split('-')[1] + "月"
-            //              + di.VisitStartDate.Split('-')[2] + "日"
-            //              + "至"
-            //              + di.VisitEndDate.Split('-')[1] + "月"
-            //              + di.VisitEndDate.Split('-')[2] + "日";
-            //}
-
-            ////请示范例
-            //if (doc.Range.Bookmarks["Temp"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Temp"];
-            //    mark.Text = bookmark;
-            //}
-
-            ////出访起止日期
-            //if (doc.Range.Bookmarks["Duration"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Duration"];
-            //    mark.Text = di.VisitStartDate.Split('-')[0] + "年"
-            //              + di.VisitStartDate.Split('-')[1] + "月"
-            //              + di.VisitStartDate.Split('-')[2] + "日"
-            //              + "至"
-            //              + di.VisitEndDate.Split('-')[1] + "月"
-            //              + di.VisitEndDate.Split('-')[2] + "日";
-            //}
-
-            ////出访天数
-            //if (doc.Range.Bookmarks["Durationdays"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Durationdays"];
-            //    mark.Text = di.VisitDays.ToString();
-            //}
-            //if (doc.Range.Bookmarks["Durationdays2"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
-            //    mark.Text = di.VisitDays.ToString();
-            //}
-            //#region 根据黑屏代码获取国家呆的天数;获取路线
-            //string result_CountryAndDay = "", result_Air = "";
-
-            //if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
-            //{
-            //    result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
-            //    result_Air = result_CountryAndDay;
-            //}
-            //else
-            //{
-            //    string place_start, place_end;
-            //    DateTime time_start, time_end;
-            //    ThreeCode three = null;
-            //    for (int i = 0; i < airTable.Rows.Count; i++)
-            //    {
-            //        //三字码实例
-            //        three = ts.getByThree(airTable.Rows[i]["Three"].ToString().Substring(0, 3));
-            //        if (three == null)
-            //        {
-            //            place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
-            //        }
-            //        else
-            //        {
-            //            if (three.Country == "" || string.IsNullOrEmpty(three.Country))
-            //            {
-            //                place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
-            //            }
-            //            else
-            //            {
-            //                place_start = three.City;
-            //            }
-            //        }
-
-            //        three = ts.getByThree(airTable.Rows[i]["Three"].ToString().Substring(3, 3));
-            //        if (three == null)
-            //        {
-            //            place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
-            //        }
-            //        else
-            //        {
-            //            if (three.Country == "" || string.IsNullOrEmpty(three.Country))
-            //            {
-            //                place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
-            //            }
-            //            else
-            //            {
-            //                place_end = three.City;
-            //            }
-            //        }
-            //        result_Air += place_start + "一" + place_end + "一";
-
-
-            //        //获取国家和呆的天数
-            //        if (i > 0 && i < airTable.Rows.Count - 1)
-            //        {
-            //            time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
-            //            time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
-            //            TimeSpan daycount = time_end.Subtract(time_start);
-            //            result_CountryAndDay += place_start + daycount.Days + "天" + ",";
-            //        }
-
-
-            //    }
-            //}
-            //#endregion
-
-            ////每个国家呆的天数
-            //if (doc.Range.Bookmarks["CountryAndDay"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
-            //    mark.Text = result_CountryAndDay.TrimEnd(',');
-
-            //}
-
-            //#region 出访路线城市字符串去重
-            //result_Air = result_Air.TrimEnd('一');
-            //string[] airTemp = result_Air.Split('一');
-            //airTemp = airTemp.Distinct().ToArray();
-            //result_Air = "";
-            //foreach (string str in airTemp)
-            //{
-            //    result_Air += str + "一";
-            //}
-            //result_Air = result_Air + airTemp[0];
-            //#endregion
-
-            ////出访路线
-            //if (doc.Range.Bookmarks["Air"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Air"];
-            //    mark.Text = result_Air;
-            //}
-            //#endregion
-
-            //#region 客户名单
-
-            //NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
-            //Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
-
-            //if (clientList == null || clientList.Count == 0)
-            //{
-            //    builder.MoveToCell(0, 1, 0, 0);
-            //    builder.Write("【本团尚未录入客户名单,请联系主管!】");
-            //}
-            //else
-            //{
-            //    for (int i = 0; i < clientList.Count(); i++)
-            //    {
-            //        builder.MoveToCell(0, i + 1, 0, 0);
-            //        builder.Write((i + 1).ToString());
-
-            //        builder.MoveToCell(0, i + 1, 1, 0);
-            //        builder.Write(clientList[i].LastName.ToString() + clientList[i].Name.ToString());
-
-            //        builder.MoveToCell(0, i + 1, 2, 0);
-            //        builder.Write(clientList[i].Sex.ToString());
-
-            //        builder.MoveToCell(0, i + 1, 3, 0);
-            //        builder.Write(clientList[i].Birthday.ToString());
-
-            //        builder.MoveToCell(0, i + 1, 4, 0);
-            //        builder.Write(clientList[i].Company.ToString() + clientList[i].Job.ToString());
-
-            //    }
-            //}
-
-            //while (tableClient.Rows.Count > clientList.Count + 1)
-            //{
-            //    tableClient.Rows.RemoveAt(clientList.Count + 1);
-            //}
-            //#endregion
-
-            //#region 商邀行程
-            //string content = "", temp1 = "", temp2 = "";
-
-            ////获取数据,放到datatable
-            //List<ApprovalTravel> listapt = new ApprovalTravelService().GetByDiid(di.Id);
-
-            //if (listapt == null || listapt.Count == 0)
-            //{
-            //    content = "尚未生成商邀行程";
-            //}
-            //else
-            //{
-            //    for (int i = 0; i < listapt.Count; i++)
-            //    {
-            //        content = content + " " + listapt[i].Date + "\r\n";
-            //        temp1 = listapt[i].Time;
-            //        temp2 = listapt[i].Detail;
-            //        if (temp1 != "")
-            //        {
-            //            string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
-            //            string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
-            //            for (int j = 0; j < str.Count(); j++)
-            //            {
-            //                content = content + " " + str[j] + str2[j] + "\r\n";
-            //            }
-            //        }
-            //    }
-            //}
-
-            //if (doc.Range.Bookmarks["Content"] != null)
-            //{
-            //    Bookmark mark = doc.Range.Bookmarks["Content"];
-            //    mark.Text = content;
-            //}
-
-            //while (tableClient.Rows.Count > 1 + clientList.Count)
-            //{
-            //    tableClient.Rows.RemoveAt(1 + clientList.Count);
-            //}
-            //#endregion
+            #region 填充word模板书签内容
 
+            //团组信息
+            var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
+            //接团客户名单实例
+            string client_sql = string.Format(@"
+SELECT
+  tcl.Id,
+  tcl.DiId,
+  tcl.IsAccompany,
+  temp.*,
+  u.CnName AS Operator,
+  tcl.CreateTime AS OperatingTime
+FROM
+  Grp_TourClientList tcl
+  LEFT JOIN (
+    SELECT
+      dc.Id AS DcId,
+      dc.LastName,
+      dc.FirstName,
+      ccom.CompanyFullName,
+      dc.Job,
+      cc.CertNo AS IDCardNo,
+      dc.Sex,
+      dc.BirthDay
+    FROM
+      Crm_DeleClient dc
+      LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
+      AND ccom.IsDel = 0
+      LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
+      AND cc.SdId = 773
+      AND cc.IsDel = 0
+    WHERE
+      dc.IsDel = 0
+  ) temp ON temp.DcId = tcl.ClientId
+  LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
+WHERE
+  tcl.IsDel = 0
+  AND tcl.DiId = {0}", dto.DiId);
+            var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
+            //机票代码实例
+            DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
+            //三字码
+            var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0 ).ToListAsync();
+
+            //团名
+            if (doc.Range.Bookmarks["TeamName"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["TeamName"];
+                mark.Text = di.TeamName;
+            }
+
+            //团长名
+            if (doc.Range.Bookmarks["ClientName2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["ClientName2"];
+                if (clientList == null || clientList.Count == 0)
+                {
+                    mark.Text = "【本团尚未录入客户名单,请联系主管!】";
+                }
+                else
+                {
+                    mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
+                }
+            }
+            if (doc.Range.Bookmarks["ClientName"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["ClientName"];
+                if (clientList == null || clientList.Count == 0)
+                {
+                    mark.Text = "【本团尚未录入客户名单,请联系主管!】";
+                }
+                else
+                {
+                    mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
+                }
+            }
+
+            //跟团人数
+            if (doc.Range.Bookmarks["ClientNumber2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
+                mark.Text = di.VisitPNumber.ToString();
+            }
+            if (doc.Range.Bookmarks["ClientNumber"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
+                mark.Text = di.VisitPNumber.ToString();
+            }
+
+            //地区
+            if (doc.Range.Bookmarks["Area"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Area"];
+                mark.Text = Area.TrimEnd('、');
+            }
+            if (doc.Range.Bookmarks["Area2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Area2"];
+                mark.Text = Area.TrimEnd('、');
+            }
+
+            //出访目的
+            if (doc.Range.Bookmarks["Destination2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Destination2"];
+                mark.Text = di.VisitPurpose;
+            }
+            if (doc.Range.Bookmarks["Destination"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Destination"];
+                mark.Text = di.VisitPurpose;
+            }
+
+            //邀请方
+            if (doc.Range.Bookmarks["Official"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Official"];
+                mark.Text = Official.TrimEnd('、');
+            }
+
+            //出访日期
+            if (doc.Range.Bookmarks["VisitDate"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["VisitDate"];
+                mark.Text = di.VisitStartDate.Year + "年"
+                          + di.VisitStartDate.Month + "月"
+                          + di.VisitStartDate.Day + "日"
+                          + "至"
+                          + di.VisitEndDate.Month + "月"
+                          + di.VisitEndDate.Day + "日";
+            }
+
+            //请示范例
+            if (doc.Range.Bookmarks["Temp"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Temp"];
+                mark.Text = bookmark;
+            }
+
+            //出访起止日期
+            if (doc.Range.Bookmarks["Duration"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Duration"];
+                mark.Text = di.VisitStartDate.Year + "年"
+                          + di.VisitStartDate.Month + "月"
+                          + di.VisitStartDate.Day + "日"
+                          + "至"
+                          + di.VisitEndDate.Month + "月"
+                          + di.VisitEndDate.Day + "日";
+            }
+
+            //出访天数
+            if (doc.Range.Bookmarks["Durationdays"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Durationdays"];
+                mark.Text = di.VisitDays.ToString();
+            }
+            if (doc.Range.Bookmarks["Durationdays2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
+                mark.Text = di.VisitDays.ToString();
+            }
+            #region 根据黑屏代码获取国家呆的天数;获取路线
+            string result_CountryAndDay = "", result_Air = "";
+
+            if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
+            {
+                result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
+                result_Air = result_CountryAndDay;
+            }
+            else
+            {
+                string place_start, place_end;
+                DateTime time_start, time_end;
+                Res_ThreeCode three = null;
+                for (int i = 0; i < airTable.Rows.Count; i++)
+                {
+                    //三字码实例
+                    three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
+                    if (three == null)
+                    {
+                        place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
+                    }
+                    else
+                    {
+                        if (string.IsNullOrEmpty(three.Country))
+                        {
+                            place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
+                        }
+                        else
+                        {
+                            place_start = three.City;
+                        }
+                    }
+
+                    three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
+                    if (three == null)
+                    {
+                        place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
+                    }
+                    else
+                    {
+                        if (string.IsNullOrEmpty(three.Country))
+                        {
+                            place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
+                        }
+                        else
+                        {
+                            place_end = three.City;
+                        }
+                    }
+                    result_Air += place_start + "一" + place_end + "一";
+
+
+                    //获取国家和呆的天数
+                    if (i > 0 && i < airTable.Rows.Count - 1)
+                    {
+                        time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
+                        time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
+                        TimeSpan daycount = time_end.Subtract(time_start);
+                        result_CountryAndDay += place_start + daycount.Days + "天" + ",";
+                    }
+
+
+                }
+            }
             #endregion
 
+            //每个国家呆的天数
+            if (doc.Range.Bookmarks["CountryAndDay"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
+                mark.Text = result_CountryAndDay.TrimEnd(',');
 
-            return Ok(JsonView(false));
+            }
+
+            #region 出访路线城市字符串去重
+            result_Air = result_Air.TrimEnd('一');
+            string[] airTemp = result_Air.Split('一');
+            airTemp = airTemp.Distinct().ToArray();
+            result_Air = "";
+            foreach (string str in airTemp)
+            {
+                result_Air += str + "一";
+            }
+            result_Air = result_Air + airTemp[0];
+            #endregion
+
+            //出访路线
+            if (doc.Range.Bookmarks["Air"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Air"];
+                mark.Text = result_Air;
+            }
+            #endregion
+
+            #region 客户名单
+
+            NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
+            Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
+
+            if (clientList == null || clientList.Count == 0)
+            {
+                builder.MoveToCell(0, 1, 0, 0);
+                builder.Write("【本团尚未录入客户名单,请联系主管!】");
+            }
+            else
+            {
+                for (int i = 0; i < clientList.Count(); i++)
+                {
+                    builder.MoveToCell(0, i + 1, 0, 0);
+                    builder.Write((i + 1).ToString());
+
+                    builder.MoveToCell(0, i + 1, 1, 0);
+                    builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
+
+                    builder.MoveToCell(0, i + 1, 2, 0);
+                    builder.Write(clientList[i].Sex.ToString());
+
+                    builder.MoveToCell(0, i + 1, 3, 0);
+                    builder.Write(clientList[i].BirthDay);
+
+                    builder.MoveToCell(0, i + 1, 4, 0);
+                    builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
+
+                }
+            }
+
+            while (tableClient.Rows.Count > clientList.Count + 1)
+            {
+                tableClient.Rows.RemoveAt(clientList.Count + 1);
+            }
+            #endregion
+
+            #region 商邀行程
+            string content = "", temp1 = "", temp2 = "";
+
+            //获取数据,放到datatable
+            var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
+                .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
+                .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
+                .Select((at, atd) => new
+                {
+                    at.Id,
+                    at.Date,
+                    atd.Time,
+                    atd.Details
+                })
+                .ToListAsync();
+
+            if (listapt == null || listapt.Count == 0)
+            {
+                content = "尚未生成商邀行程";
+            }
+            else
+            {
+                for (int i = 0; i < listapt.Count; i++)
+                {
+                    content = content + " " + listapt[i].Date + "\r\n";
+                    temp1 = listapt[i].Time;
+                    temp2 = listapt[i].Details;
+                    if (!string.IsNullOrEmpty(temp1))
+                    {
+                        string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+                        string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+                        for (int j = 0; j < str.Count(); j++)
+                        {
+                            content = content + " " + str[j] + str2[j] + "\r\n";
+                        }
+                    }
+                }
+            }
+
+            if (doc.Range.Bookmarks["Content"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Content"];
+                mark.Text = content;
+            }
+
+            while (tableClient.Rows.Count > 1 + clientList.Count)
+            {
+                tableClient.Rows.RemoveAt(1 + clientList.Count);
+            }
+            #endregion
+
+            #endregion
+
+            string strFileName = $"/AskData/省外办出访请示{Guid.NewGuid().ToString()}.doc";
+            doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName);  //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
+            var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName;  //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
+
+            return Ok(JsonView(true,"操作成功!",new { url = url }));
         }
 
 
+        /// <summary>
+        /// 请示资料信息 
+        /// 市外办下载
+        /// </summary>
+        /// <param name="dto"></param>
+        /// <returns></returns>
+        [HttpPost]
+        [ProducesResponseType(typeof(JsonView), StatusCodes.Status200OK)]
+        public async Task<IActionResult> AskDataCityFAOPFile(AskDataProvinceFileDto dto)
+        {
+            if (dto.DataIdItem.Length < 1) return Ok(JsonView(false, $"请传入有效的数据Id集合!"));
+            if (dto.DiId < 1) return Ok(JsonView(false, $"请传入有效的数据DiId参数!"));
+
+            //大写数字序号
+            string[] num = { "一", "二", "三", "四", "五", "六", "七", "八", "九", "十" ,
+                             "十一","十二","十三","十四","十五","十六","十七","十八","十九","二十",
+                             "二十一","二十二","二十三","二十四","二十五","二十六","二十七","二十八","二十九","三十",
+                             "三十一","三十二","三十三","三十四","三十五","三十六","三十七","三十八","三十九","四十"};
+
+            //数据源
+            var idItem = dto.DataIdItem.OrderBy(x => x);
+            var askDatas = await _sqlSugar.Queryable<Res_AskData>().Where(x => x.IsDel == 0 && idItem.Contains(x.Id)).ToListAsync();
+
+            //书签名
+            string Area = "",
+                   Official = "";
+
+            //表格数据源
+            DataTable dt = new DataTable();
+            dt.Columns.Add("Country", typeof(string));
+            dt.Columns.Add("TalkCase", typeof(string));
+
+            int id = 0;
+            int TalkcaseOrder = 0;
+            int RowOrder = 0;
+            //填充数据
+            for (int i = 0; i < askDatas.Count; i++)
+            {
+                var ad = askDatas[i];
+
+                Area = Area + ad.Country + ad.Area + "、";
+                Official = Official + ad.UnitName + "、";
+
+                //填充表格数据源
+                DataRow dr = dt.NewRow();
+                if (i > 0)
+                {
+                    var adtemp = askDatas[i - 1];
+
+                    if (ad.Country == adtemp.Country)
+                    {
+                        TalkcaseOrder++;
+                        dt.Rows[RowOrder]["TalkCase"] = dt.Rows[RowOrder]["TalkCase"] + "\r\n" + (1 + TalkcaseOrder).ToString() + "、" + ad.TalkCase;
+                    }
+                    else
+                    {
+                        RowOrder++;
+                        dr = dt.NewRow();
+                        dr["Country"] = "(" + num[RowOrder] + ")" + ad.Country;
+                        dr["TalkCase"] = "1、" + ad.TalkCase;
+                        dt.Rows.Add(dr);
+                        TalkcaseOrder = 0;
+                    }
+                }
+                else
+                {
+                    dr["Country"] = "(" + num[i] + ")" + ad.Country;
+                    dr["TalkCase"] = "1、" + ad.TalkCase;
+                    dt.Rows.Add(dr);
+                }
+                id = ad.Id;
+            }
+
+            //模板路径
+            var tempPath = AppSettingsHelper.Get("WordBasePath") + "Template/市外办出访请示.doc";
+            //载入模板
+            Aspose.Words.Document doc = new Aspose.Words.Document(tempPath);
+
+            #region 填充word内容
+
+            #region 填充请示内容
+            //利用DocumentBuilder处理表格或是书签
+            Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
+            string bookmark = "";
+            try
+            {
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    bookmark = bookmark
+                        + dt.Rows[i]["Country"].ToString() + "\r\n"
+                        + dt.Rows[i]["TalkCase"].ToString() + "\r\n";
+                }
+            }
+            catch
+            {
+            }
+
+
+            #endregion
+
+            #region 填充word模板书签内容
+
+            //团组信息
+            var di = await _sqlSugar.Queryable<Grp_DelegationInfo>().Where(x => x.IsDel == 0 && x.Id == dto.DiId).FirstAsync();
+            //接团客户名单实例
+            string client_sql = string.Format(@"
+SELECT
+  tcl.Id,
+  tcl.DiId,
+  tcl.IsAccompany,
+  temp.*,
+  u.CnName AS Operator,
+  tcl.CreateTime AS OperatingTime
+FROM
+  Grp_TourClientList tcl
+  LEFT JOIN (
+    SELECT
+      dc.Id AS DcId,
+      dc.LastName,
+      dc.FirstName,
+      ccom.CompanyFullName,
+      dc.Job,
+      cc.CertNo AS IDCardNo,
+      dc.Sex,
+      dc.BirthDay
+    FROM
+      Crm_DeleClient dc
+      LEFT JOIN Crm_CustomerCompany ccom ON dc.CrmCompanyId = ccom.Id
+      AND ccom.IsDel = 0
+      LEFT JOIN Crm_CustomerCert cc ON dc.Id = cc.DcId
+      AND cc.SdId = 773
+      AND cc.IsDel = 0
+    WHERE
+      dc.IsDel = 0
+  ) temp ON temp.DcId = tcl.ClientId
+  LEFT JOIN Sys_Users u ON tcl.CreateUserId = u.Id
+WHERE
+  tcl.IsDel = 0
+  AND tcl.DiId = {0}", dto.DiId);
+            var clientList = await _sqlSugar.SqlQueryable<TourClientListDetailsView>(client_sql).ToListAsync();
+            //机票代码实例
+            DataTable airTable = GeneralMethod.GetTableByBlackCode(dto.DiId);
+            //三字码
+            var threeCodes = await _sqlSugar.Queryable<Res_ThreeCode>().Where(x => x.IsDel == 0).ToListAsync();
+
+            //团名
+            if (doc.Range.Bookmarks["TeamName"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["TeamName"];
+                mark.Text = di.TeamName;
+            }
+
+            //团长名
+            if (doc.Range.Bookmarks["ClientName2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["ClientName2"];
+                if (clientList == null || clientList.Count == 0)
+                {
+                    mark.Text = "【本团尚未录入客户名单,请联系主管!】";
+                }
+                else
+                {
+                    mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
+                }
+            }
+            if (doc.Range.Bookmarks["ClientName"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["ClientName"];
+                if (clientList == null || clientList.Count == 0)
+                {
+                    mark.Text = "【本团尚未录入客户名单,请联系主管!】";
+                }
+                else
+                {
+                    mark.Text = clientList[0].CompanyFullName + clientList[0].Job + clientList[0].LastName + clientList[0].FirstName;
+                }
+            }
+
+            //跟团人数
+            if (doc.Range.Bookmarks["ClientNumber2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["ClientNumber2"];
+                mark.Text = di.VisitPNumber.ToString();
+            }
+            if (doc.Range.Bookmarks["ClientNumber"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["ClientNumber"];
+                mark.Text = di.VisitPNumber.ToString();
+            }
+
+            //地区
+            if (doc.Range.Bookmarks["Area"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Area"];
+                mark.Text = Area.TrimEnd('、');
+            }
+            if (doc.Range.Bookmarks["Area2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Area2"];
+                mark.Text = Area.TrimEnd('、');
+            }
+
+            //出访目的
+            if (doc.Range.Bookmarks["Destination2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Destination2"];
+                mark.Text = di.VisitPurpose;
+            }
+            if (doc.Range.Bookmarks["Destination"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Destination"];
+                mark.Text = di.VisitPurpose;
+            }
+
+            //邀请方
+            if (doc.Range.Bookmarks["Official"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Official"];
+                mark.Text = Official.TrimEnd('、');
+            }
+
+            //出访日期
+            if (doc.Range.Bookmarks["VisitDate"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["VisitDate"];
+                mark.Text = di.VisitStartDate.Year + "年"
+                          + di.VisitStartDate.Month + "月"
+                          + di.VisitStartDate.Day + "日"
+                          + "至"
+                          + di.VisitEndDate.Month + "月"
+                          + di.VisitEndDate.Day + "日";
+            }
+
+            //请示范例
+            if (doc.Range.Bookmarks["Temp"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Temp"];
+                mark.Text = bookmark;
+            }
+
+            //出访起止日期
+            if (doc.Range.Bookmarks["Duration"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Duration"];
+                mark.Text = di.VisitStartDate.Year + "年"
+                          + di.VisitStartDate.Month + "月"
+                          + di.VisitStartDate.Day + "日"
+                          + "至"
+                          + di.VisitEndDate.Month + "月"
+                          + di.VisitEndDate.Day + "日";
+            }
+
+            //出访天数
+            if (doc.Range.Bookmarks["Durationdays"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Durationdays"];
+                mark.Text = di.VisitDays.ToString();
+            }
+            if (doc.Range.Bookmarks["Durationdays2"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Durationdays2"];
+                mark.Text = di.VisitDays.ToString();
+            }
+
+            #region 根据黑屏代码获取国家呆的天数;获取路线
+            string result_CountryAndDay = "", result_Air = "";
+
+            if (airTable.Rows[airTable.Rows.Count - 1]["Day"].ToString() == "")
+            {
+                result_CountryAndDay = airTable.Rows[airTable.Rows.Count - 1]["Fliagtcode"].ToString();
+                result_Air = result_CountryAndDay;
+            }
+            else
+            {
+                string place_start, place_end;
+                DateTime time_start, time_end;
+                Res_ThreeCode three = null;
+                for (int i = 0; i < airTable.Rows.Count; i++)
+                {
+                    //三字码实例
+                    three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(0, 3));
+                    if (three == null)
+                    {
+                        place_start = "【未收录三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
+                    }
+                    else
+                    {
+                        if (string.IsNullOrEmpty(three.Country))
+                        {
+                            place_start = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
+                        }
+                        else
+                        {
+                            place_start = three.City;
+                        }
+                    }
+
+                    three = threeCodes.Find(x => x.Three == airTable.Rows[i]["Three"].ToString().Substring(3, 3));
+                    if (three == null)
+                    {
+                        place_end = "【未收录" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + ",请联系机票同事】";
+                    }
+                    else
+                    {
+                        if (string.IsNullOrEmpty(three.Country))
+                        {
+                            place_end = "【本三字码" + airTable.Rows[i]["Three"].ToString().Substring(0, 3) + "未录入国家信息,请联系机票同事】";
+                        }
+                        else
+                        {
+                            place_end = three.City;
+                        }
+                    }
+                    result_Air += place_start + "一" + place_end + "一";
+
 
+                    //获取国家和呆的天数
+                    if (i > 0 && i < airTable.Rows.Count - 1)
+                    {
+                        time_start = Convert.ToDateTime(airTable.Rows[i - 1]["Day"]);
+                        time_end = Convert.ToDateTime(airTable.Rows[i]["Day"]);
+                        TimeSpan daycount = time_end.Subtract(time_start);
+                        result_CountryAndDay += place_start + daycount.Days + "天" + ",";
+                    }
+
+
+                }
+            }
+            #endregion
+
+            //每个国家呆的天数
+            if (doc.Range.Bookmarks["CountryAndDay"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["CountryAndDay"];
+                mark.Text = result_CountryAndDay.TrimEnd(',');
+
+            }
+
+            #region 出访路线城市字符串去重
+            result_Air = result_Air.TrimEnd('一');
+            string[] airTemp = result_Air.Split('一');
+            airTemp = airTemp.Distinct().ToArray();
+            result_Air = "";
+            foreach (string str in airTemp)
+            {
+                result_Air += str + "一";
+            }
+            result_Air = result_Air + airTemp[0];
+            #endregion
+
+            //出访路线
+            if (doc.Range.Bookmarks["Air"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Air"];
+                mark.Text = result_Air;
+            }
+            #endregion
+
+            #region 客户名单
+
+            NodeCollection allTables = doc.GetChildNodes(NodeType.Table, true);
+            Aspose.Words.Tables.Table tableClient = allTables[0] as Aspose.Words.Tables.Table;
+
+            if (clientList == null || clientList.Count == 0)
+            {
+                builder.MoveToCell(0, 1, 0, 0);
+                builder.Write("【本团尚未录入客户名单,请联系主管!】");
+            }
+            else
+            {
+                for (int i = 0; i < clientList.Count(); i++)
+                {
+                    builder.MoveToCell(0, i + 1, 0, 0);
+                    builder.Write((i + 1).ToString());
+
+                    builder.MoveToCell(0, i + 1, 1, 0);
+                    builder.Write(clientList[i].LastName.ToString() + clientList[i].FirstName.ToString());
+
+                    builder.MoveToCell(0, i + 1, 2, 0);
+                    builder.Write(clientList[i].Sex.ToString());
+
+                    builder.MoveToCell(0, i + 1, 3, 0);
+                    builder.Write(clientList[i].BirthDay);
+
+                    builder.MoveToCell(0, i + 1, 4, 0);
+                    builder.Write(clientList[i].CompanyFullName + clientList[i].Job.ToString());
+
+                }
+            }
+
+            while (tableClient.Rows.Count > clientList.Count + 1)
+            {
+                tableClient.Rows.RemoveAt(clientList.Count + 1);
+            }
+            #endregion
+
+            #region 商邀行程
+            string content = "", temp1 = "", temp2 = "";
+
+            //获取数据,放到datatable
+            var listapt = await _sqlSugar.Queryable<Grp_ApprovalTravel>()
+                .LeftJoin<Grp_ApprovalTravelDetails>((at, atd) => at.Id == atd.ParentId)
+                .Where((at, atd) => at.IsDel == 0 && at.Diid == dto.DiId)
+                .Select((at, atd) => new
+                {
+                    at.Id,
+                    at.Date,
+                    atd.Time,
+                    atd.Details
+                })
+                .ToListAsync();
+
+            if (listapt == null || listapt.Count == 0)
+            {
+                content = "尚未生成商邀行程";
+            }
+            else
+            {
+                for (int i = 0; i < listapt.Count; i++)
+                {
+                    content = content + " " + listapt[i].Date + "\r\n";
+                    temp1 = listapt[i].Time;
+                    temp2 = listapt[i].Details;
+                    if (!string.IsNullOrEmpty(temp1))
+                    {
+                        string[] str = temp1.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+                        string[] str2 = temp2.Replace("\r\n", " ").Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
+                        for (int j = 0; j < str.Count(); j++)
+                        {
+                            content = content + " " + str[j] + str2[j] + "\r\n";
+                        }
+                    }
+                }
+            }
+
+            if (doc.Range.Bookmarks["Content"] != null)
+            {
+                Bookmark mark = doc.Range.Bookmarks["Content"];
+                mark.Text = content;
+            }
+
+            while (tableClient.Rows.Count > 1 + clientList.Count)
+            {
+                tableClient.Rows.RemoveAt(1 + clientList.Count);
+            }
+            #endregion
+
+            #endregion
+
+            string strFileName = $"/AskData/市外办出访请示{Guid.NewGuid().ToString()}.doc";
+            doc.Save(AppSettingsHelper.Get("WordBasePath") + strFileName);  //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
+            var url = AppSettingsHelper.Get("WordBaseUrl") + AppSettingsHelper.Get("WordFtpPath") + strFileName;  //"C:\\Server\\File\\OA2023\\Office\\Word" + strFileName
+
+            return Ok(JsonView(true, "操作成功!", new { url = url }));
+        }
 
         #endregion
 

+ 0 - 2
OASystem/OASystem.Infrastructure/Repositories/Groups/TourClientListRepository.cs

@@ -37,8 +37,6 @@ namespace OASystem.Infrastructure.Repositories.Groups
             _mapper = mapper;
         }
 
-
-
         /// <summary>
         /// 根据团组Id客人名单List
         /// </summary>