Browse Source

导游地接资料新增字段LastUpdate(更新日期)

jiangjc 10 months ago
parent
commit
3a0ed39608

+ 4 - 0
OASystem/OASystem.Domain/Entities/Resource/Res_LocalGuideData.cs

@@ -119,6 +119,10 @@ namespace OASystem.Domain.Entities.Resource
         /// <summary>
         /// 导游地接的类型:0公司1私人
         /// </summary>
+        [SugarColumn(IsNullable = true, ColumnDataType = "int")]
         public int StaffType { get; set; }
+
+        [SugarColumn(IsNullable = true, ColumnDataType = "dateTime")]
+        public DateTime LastUpdate { get; set; }
     }
 }

+ 46 - 0
OASystem/OASystem.Domain/ViewModels/Resource/Res_LocalGuideData_ListItemView.cs

@@ -0,0 +1,46 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace OASystem.Domain.ViewModels.Resource
+{
+    public class Res_LocalGuideData_ListItemView
+    {
+        /// <summary>
+        /// Id
+        /// </summary>
+        public int Id { get; set; }
+
+        /// <summary>
+        /// 单位区域
+        /// </summary>
+        public string UnitArea { get; set; }
+
+        /// <summary>
+        /// 单位名称
+        /// </summary>
+        public string UnitName { get; set; }
+
+        /// <summary>
+        /// 联系人
+        /// </summary>
+        public string Contact { get; set; }
+
+        /// <summary>
+        /// 联系电话
+        /// </summary>
+        public string ContactTel { get; set; }
+
+        /// <summary>
+        /// 评分
+        /// </summary>
+        public int Score { get; set; }
+
+        /// <summary>
+        /// 更新时间
+        /// </summary>
+        public string LastUpdateStr { get; set; }
+    }
+}

+ 69 - 7
OASystem/OASystem.Infrastructure/Repositories/Resource/LocalGuideDataRepository.cs

@@ -4,6 +4,7 @@ using OASystem.Domain.Dtos.Resource;
 using OASystem.Domain.Entities.Groups;
 using OASystem.Domain.Entities.Resource;
 using OASystem.Domain.ViewModels.Resource;
+using SqlSugar.Extensions;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -17,7 +18,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
         private readonly IMapper _mapper;
         public LocalGuideDataRepository(SqlSugarClient sqlSugar, IMapper mapper) : base(sqlSugar)
         {
-            _mapper=mapper;
+            _mapper = mapper;
         }
         public async Task<Result> LocalGuideOperation(LocalGuideOperationDto dto)
         {
@@ -31,23 +32,25 @@ namespace OASystem.Infrastructure.Repositories.Resource
                     var LocalGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(selectSql).FirstAsync();//查询是否存在
                     if (LocalGuideData != null)
                     {
-                         return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
-                         
+                        return result = new Result() { Code = -1, Msg = "该信息已存在,请勿重复添加!" };
+
                     }
                     else//不存在,可添加
                     {
                         Res_LocalGuideData _LocalGuideDat = _mapper.Map<Res_LocalGuideData>(dto);
+                        _LocalGuideDat.LastUpdate = DateTime.Now;
                         int id = await AddAsyncReturnId(_LocalGuideDat);
                         if (id == 0)
                         {
                             return result = new Result() { Code = -1, Msg = "添加失败!" };
 
                         }
-                         result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
+                        result = new Result() { Code = 0, Msg = "添加成功!", Data = new { Id = id } };
                     }
                 }
-                else if(dto.Status == 2)//修改
+                else if (dto.Status == 2)//修改
                 {
+                    DateTime dtLastUpdate = DateTime.Now
                     bool res = await UpdateAsync(a => a.Id == dto.Id, a => new Res_LocalGuideData
                     {
                         UnitArea = dto.UnitArea,
@@ -66,8 +69,9 @@ namespace OASystem.Infrastructure.Repositories.Resource
                         FitScore = dto.FitScore,
                         StrainScore = dto.StrainScore,
                         LocalAndChineseScore = dto.LocalAndChineseScore,
-                        StaffType=dto.StaffType,
+                        StaffType = dto.StaffType,
                         Remark = dto.Remark,
+                        LastUpdate = dtLastUpdate
                     });
                     if (!res)
                     {
@@ -77,7 +81,7 @@ namespace OASystem.Infrastructure.Repositories.Resource
                 }
                 else
                 {
-                    return  result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
+                    return result = new Result() { Code = -1, Msg = "请传入Status参数,1添加 2修改!" };
                 }
             }
             catch (Exception ex)
@@ -210,6 +214,64 @@ namespace OASystem.Infrastructure.Repositories.Resource
                         };
                     }
                 }
+                else if (dto.PortType == 3)
+                {
+                    string sql = string.Format(@"select Id,UnitArea,UnitName,Contact,ContactTel,Score,LastUpdate from Res_LocalGuideData {0}", sqlWhere);
+                    List<Res_LocalGuideData> LocalGuideData = await _sqlSugar.SqlQueryable<Res_LocalGuideData>(sql).ToListAsync();
+                    if (LocalGuideData.Count == 0)
+                    {
+                        return result = new Result() { Code = 0, Msg = "暂无数据" };
+                    }
+                    LocalGuideData = LocalGuideData.OrderByDescending(x => x.CreateTime).ToList();
+
+                    if (dto.PageSize == 0 && dto.PageIndex == 0)
+                    {
+                        return result = new Result()
+                        {
+                            Code = 0,
+                            Msg = "查询成功",
+                            Data = LocalGuideData,
+                        };
+                    }
+                    else
+                    {
+                        int count = LocalGuideData.Count;
+                        float totalPage = (float)count / dto.PageSize;//总页数
+                        if (totalPage == 0) totalPage = 1;
+                        else totalPage = (int)Math.Ceiling((double)totalPage);
+
+                        List<Res_LocalGuideData_ListItemView> ListData = new List<Res_LocalGuideData_ListItemView>();
+                        for (int i = 0; i < dto.PageSize; i++)
+                        {
+                            var RowIndex = i + (dto.PageIndex - 1) * dto.PageSize;
+                            if (RowIndex < LocalGuideData.Count)
+                            {
+                                Res_LocalGuideData_ListItemView temp = new Res_LocalGuideData_ListItemView()
+                                {
+                                    Contact = LocalGuideData[RowIndex].Contact,
+                                    ContactTel = LocalGuideData[RowIndex].ContactTel,
+                                    Id = LocalGuideData[RowIndex].Id,
+                                    Score = LocalGuideData[RowIndex].Score,
+                                    UnitArea = LocalGuideData[RowIndex].UnitArea,
+                                    UnitName = LocalGuideData[RowIndex].UnitName
+                                };
+                                temp.LastUpdateStr = LocalGuideData[RowIndex].CreateTime.ToString("yyyy-MM-dd");
+
+                                ListData.Add(temp);
+                            }
+                            else
+                            {
+                                break;
+                            }
+                        }
+                        return result = new Result()
+                        {
+                            Code = 0,
+                            Msg = "查询成功",
+                            Data = new { pageCount = count, totalPage = (int)totalPage, pageIndex = dto.PageIndex, pageSize = dto.PageSize, pageSource = ListData },
+                        };
+                    }
+                }
                 else
                 {
                     return result = new Result() { Code = -2, Msg = "请传入PortType参数!1:Web,2:Android,3:IOS" };

+ 1 - 1
OASystem/OpWin/OpWin.csproj

@@ -14,7 +14,7 @@
 
   <ItemGroup>
     <Reference Include="Aspose.Words">
-      <HintPath>..\..\..\OA2021\Lib\Aspose.Words.dll</HintPath>
+      <HintPath>..\package\Aspose.Words.dll</HintPath>
     </Reference>
   </ItemGroup>