qinchaoyue 4 місяців тому
батько
коміт
6610975ebf

+ 9 - 5
src/Hotline.Api/Controllers/Snapshot/SnapshotController.cs

@@ -16,6 +16,7 @@ using Hotline.Tools;
 using Mapster;
 using Microsoft.AspNetCore.Authorization;
 using Microsoft.AspNetCore.Mvc;
+using SqlSugar;
 using System.ComponentModel.DataAnnotations;
 using System.Reflection;
 using XF.Domain.Exceptions;
@@ -34,6 +35,7 @@ public class SnapshotController : BaseController
     private readonly IIndustryRepository _industryRepository;
     private readonly IOrderDomainService _orderDomainService;
     private readonly IFileRepository _fileRepository;
+    private readonly IOrderSnapshotRepository _orderSnapshotRepository;
 
     public SnapshotController(IRepository<Order> orderRepository, ISnapshotApplication snapshotApplication, ISystemAreaDomainService systemAreaDomainService, IIndustryRepository industryRepository, IOrderDomainService orderDomainService, IFileRepository fileRepository)
     {
@@ -79,15 +81,17 @@ public class SnapshotController : BaseController
         order.AcceptTypeCode = industry.AcceptTypeCode;
         order.AcceptType = industry.AcceptType;
         order.FromGender = EGender.Unknown;
-        if (industry.IndustryType == EIndustryType.Declare)
-        {
-            order.Title = dto.GetTitle(industry.IndustryType, industry.AcceptType);
-            order.Content = dto.GetContent(industry.IndustryType);
-        }
+        order.Title = dto.GetTitle(industry.IndustryType, industry.AcceptType);
+        order.Content = dto.GetContent(industry.IndustryType);
         order.InitId();
         await _orderDomainService.AddAsync(order);
         if (dto.Files.NotNullOrEmpty())
             order.FileJson = await _fileRepository.AddFileAsync(dto.Files, order.Id, HttpContext.RequestAborted);
+        var orderSnapshot = dto.Adapt<OrderSnapshot>();
+        orderSnapshot.Id = order.Id;
+        orderSnapshot.IndustryId = dto.IndustryId;
+        orderSnapshot.IndustryName = industry.Name;
+        await _orderSnapshotRepository.AddAsync(orderSnapshot);
 
 
         return order.Adapt<AddSnapshotOrderOutDto>();

+ 9 - 1
src/Hotline.Application.Tests/Controller/SnapshotControllerTest.cs

@@ -23,7 +23,7 @@ public class SnapshotControllerTest : TestBase
     }
 
     [Fact]
-    public async Task GetAreaTreeTest()
+    public async Task GetAreaTree_Test()
     {
         var result = await _snapshotController.GetAreaTreeAsync();
         result.ShouldNotBeNull();
@@ -35,4 +35,12 @@ public class SnapshotControllerTest : TestBase
         zzz.ShouldNotBeNull();
     }
 
+    /// <summary>
+    /// 测试创建随手拍工单
+    /// </summary>
+    /// <returns></returns>
+    [Fact]
+    public async Task AddOrder_Test()
+    { 
+    }
 }

+ 17 - 0
src/Hotline.Repository.SqlSugar/Snapshot/OrderSnapshotRepository.cs

@@ -0,0 +1,17 @@
+using Hotline.Repository.SqlSugar.DataPermissions;
+using Hotline.Snapshot;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using XF.Domain.Dependency;
+
+namespace Hotline.Repository.SqlSugar.Snapshot;
+public class OrderSnapshotRepository : BaseRepository<OrderSnapshot>, IOrderSnapshotRepository, IScopeDependency
+{
+    public OrderSnapshotRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder) : base(uow, dataPermissionFilterBuilder)
+    {
+    }
+}

+ 6 - 17
src/Hotline.Repository.SqlSugar/Snapshot/ThirdAccountRepository.cs

@@ -1,29 +1,18 @@
-using Hotline.Snapshot;
+using Hotline.Repository.SqlSugar.DataPermissions;
+using Hotline.Snapshot;
+using SqlSugar;
 using XF.Domain.Dependency;
 using XF.Domain.Repository;
 
 namespace Hotline.Repository.SqlSugar.Snapshot;
-public class ThirdAccountRepository : IThirdAccountRepository , IScopeDependency
+public class ThirdAccountRepository : BaseRepository<ThirdAccount>,  IThirdAccountRepository , IScopeDependency
 {
-    private readonly IRepository<ThirdAccount> _repository;
-
-    public ThirdAccountRepository(IRepository<ThirdAccount> repository)
-    {
-        _repository = repository;
-    }
-
-    public async Task<string> AddAsync(ThirdAccount entity)
+    public ThirdAccountRepository(ISugarUnitOfWork<HotlineDbContext> uow, IDataPermissionFilterBuilder dataPermissionFilterBuilder) : base(uow, dataPermissionFilterBuilder)
     {
-        return await _repository.AddAsync(entity);
     }
 
     public async Task<ThirdAccount> QueryByOpenIdAsync(string openId)
-        => await _repository.Queryable()
+        => await Queryable()
         .Where(p => p.OpenId == openId)
         .FirstAsync();
-
-    public async Task UpdateAsync(ThirdAccount entity)
-    {
-        await _repository.UpdateAsync(entity);
-    }
 }

+ 11 - 0
src/Hotline/Snapshot/IOrderSnapshotRepository.cs

@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using XF.Domain.Repository;
+
+namespace Hotline.Snapshot;
+public interface IOrderSnapshotRepository : IRepository<OrderSnapshot>
+{
+}

+ 4 - 4
src/Hotline/Snapshot/IThirdAccountRepository.cs

@@ -1,7 +1,7 @@
-namespace Hotline.Snapshot;
-public interface IThirdAccountRepository
+using XF.Domain.Repository;
+
+namespace Hotline.Snapshot;
+public interface IThirdAccountRepository : IRepository<ThirdAccount>
 {
-    Task<string> AddAsync(ThirdAccount entity);
     Task<ThirdAccount> QueryByOpenIdAsync(string openId);
-    Task UpdateAsync(ThirdAccount entity);
 }

+ 36 - 7
src/Hotline/Snapshot/OrderSnapshot.cs

@@ -7,17 +7,11 @@ namespace Hotline.Snapshot;
 
 /// <summary>
 /// 工单表扩展
+/// Id 和 Order.Id 相同
 /// </summary>
 [Description("工单表扩展")]
 public class OrderSnapshot : CreationSoftDeleteEntity
 {
-    /// <summary>
-    /// 关联工单编号
-    /// <inheritdoc cref="Order"/>表的Id字段
-    /// </summary>    
-    [SugarColumn(ColumnDescription = "关联工单编号")]
-    public string OrderId { get; set; }
-
     /// <summary>
     /// 行业Id
     /// <inheritdoc cref="Industry"/> 表的Id
@@ -39,6 +33,41 @@ public class OrderSnapshot : CreationSoftDeleteEntity
     [SugarColumn(ColumnDescription = "社区Id")]
     public string? CommunityId { get; set; }
 
+    /// <summary>
+    /// 作业类型
+    /// </summary>
+    [SugarColumn(ColumnDescription = "作业类型")]
+    public string? JobType { get; set; }
+
+    /// <summary>
+    /// 经营单位类别
+    /// </summary>
+    [SugarColumn(ColumnDescription = "经营单位类别")]
+    public string? BusinessUnitType { get; set; }
+
+    /// <summary>
+    /// 作业场所
+    /// </summary>
+    [SugarColumn(ColumnDescription = "作业场所")]
+    public string? Workplace { get; set; }
+
+    /// <summary>
+    /// 场所名称(多个场所使用 - 连接)
+    /// </summary>
+    [SugarColumn(ColumnDescription = "场所名称")]
+    public string? WorkplaceName { get; set; }
+
+    /// <summary>
+    /// 作业时间
+    /// </summary>
+    [SugarColumn(ColumnDescription = "作业时间")]
+    public DateTime? StartWorkTime { get; set; }
+
+    /// <summary>
+    /// 作业结束时间
+    /// </summary>
+    [SugarColumn(ColumnDescription = "作业时间")]
+    public DateTime? EndWorkTime { get; set; }
     #region 网格员回复
 
     /// <summary>