Browse Source

Merge branch 'master' of http://git.ius.plus/AIPlatform_SDK/AIPlatform

xuan.wang 8 months ago
parent
commit
1467d30466

+ 6 - 1
AIPlatform.Protocol/Entities/CategoryType.cs

@@ -14,4 +14,9 @@
         /// </summary>
         GatherCategory,
     }
-}
+
+    public class CategoryItem : EntityBase
+    {
+        public CategoryType Type { get; set; }
+    }
+}

+ 4 - 63
AIPlatform.Protocol/Entities/GatherCategory.cs

@@ -1,5 +1,4 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 
 namespace AIPlatform.Protocol.Entities
 {
@@ -19,72 +18,14 @@ namespace AIPlatform.Protocol.Entities
         public EntityBase Organization { get; set; }
 
         /// <summary>
-        /// Gets or sets the collectors
+        /// Gets or sets the gatherers
         /// </summary>
-        public List<EntityBase> Collectors { get; set; }
+        public List<EntityBase> Gatherers { get; set; }
 
         public GatherCategory()
         {
             Organization = new EntityBase();
-            Collectors = new List<EntityBase>();
-        }
-    }
-
-    /// <summary>
-    /// 采集数据
-    /// </summary>
-    public class GatherData : Entity
-    {
-        /// <summary>
-        /// 采集大类
-        /// </summary>
-        public EntityBase GatherCategory { get; set; }
-
-        /// <summary>
-        /// Gets or sets the organization
-        /// </summary>
-        public EntityBase Organization { get; set; }
-
-        /// <summary>
-        /// 采集人员
-        /// </summary>
-        public EntityBase Collector { get; set; }
-
-        /// <summary>
-        /// 机型
-        /// </summary>
-        public string ModelType { get; set; }
-
-        /// <summary>
-        /// 来源
-        /// </summary>
-        public string Source { get; set; }
-
-        /// <summary>
-        /// 采集数量
-        /// </summary>
-        public int CollectionQuantity { get; set; }
-
-        /// <summary>
-        /// 采集起始时间
-        /// </summary>
-        public DateTime StartTime { get; set; }
-
-        /// <summary>
-        /// 采集结束时间
-        /// </summary>
-        public DateTime EndTime { get; set; }
-
-        /// <summary>
-        /// 结算时间
-        /// </summary>
-        public DateTime SettlementTime { get; set; }
-
-        public GatherData()
-        {
-            GatherCategory = new EntityBase();
-            Organization = new EntityBase();
-            Collector = new EntityBase();
+            Gatherers = new List<EntityBase>();
         }
     }
 }

+ 62 - 0
AIPlatform.Protocol/Entities/GatherData.cs

@@ -0,0 +1,62 @@
+using System;
+
+namespace AIPlatform.Protocol.Entities
+{
+    /// <summary>
+    /// 采集数据
+    /// </summary>
+    public class GatherData : Entity
+    {
+        /// <summary>
+        /// 大类信息
+        /// </summary>
+        public CategoryItem Category { get; set; }
+
+        /// <summary>
+        /// Gets or sets the organization
+        /// </summary>
+        public EntityBase Organization { get; set; }
+
+        /// <summary>
+        /// 采集人员
+        /// </summary>
+        public EntityBase Gatherer { get; set; }
+
+        /// <summary>
+        /// 机型
+        /// </summary>
+        public string ModelType { get; set; }
+
+        /// <summary>
+        /// 来源
+        /// </summary>
+        public string Source { get; set; }
+
+        /// <summary>
+        /// 采集数量
+        /// </summary>
+        public int CollectionQuantity { get; set; }
+
+        /// <summary>
+        /// 采集起始时间
+        /// </summary>
+        public DateTime StartTime { get; set; }
+
+        /// <summary>
+        /// 采集结束时间
+        /// </summary>
+        public DateTime EndTime { get; set; }
+
+        /// <summary>
+        /// 结算时间
+        /// </summary>
+        public DateTime SettlementTime { get; set; }
+
+        public GatherData()
+        {
+            Category = new CategoryItem();
+            Organization = new EntityBase();
+            Gatherer = new EntityBase();
+        }
+    }
+}

+ 11 - 0
AIPlatform.Protocol/Entities/ImageCategory.cs

@@ -60,6 +60,11 @@ namespace AIPlatform.Protocol.Entities
         /// 共享者
         /// </summary>
         Sharer,
+
+        /// <summary>
+        /// 采集者
+        /// </summary>
+        Gatherer,
     }
 
     /// <summary>
@@ -104,6 +109,11 @@ namespace AIPlatform.Protocol.Entities
         /// </summary>
         public List<EntityBase> Sharers { get; set; }
 
+        /// <summary>
+        /// Gets or sets the gatherers
+        /// </summary>
+        public List<EntityBase> Gatherers { get; set; }
+
         /// <summary>
         /// Gets or sets the image quantity item
         /// </summary>
@@ -185,6 +195,7 @@ namespace AIPlatform.Protocol.Entities
             Labelers = new List<EntityBase>();
             Developers = new List<EntityBase>();
             Sharers = new List<EntityBase>();
+            Gatherers = new List<EntityBase>();
             VideoItem = new VideoItem();
             GroupItem = new QuantityItem();
             FileItem = new QuantityItem();

+ 1 - 1
AIPlatform.Protocol/Model/SearchGatherCategoryModel.cs

@@ -11,7 +11,7 @@
         /// 采集者名称
         /// </summary>
 
-        public string CollectorName { get; set; }
+        public string GathererName { get; set; }
 
         /// <summary>
         /// 组织Id

+ 1 - 1
AIPlatform.Protocol/Model/SearchGatherDataModel.cs

@@ -13,7 +13,7 @@ namespace AIPlatform.Protocol.Model
         /// 采集者名称
         /// </summary>
 
-        public string CollectorName { get; set; }
+        public string GathererName { get; set; }
 
         /// <summary>
         /// 组织Id

+ 10 - 19
AIPlatform.Protocol/Services/IAdminService.cs

@@ -1762,9 +1762,9 @@ namespace AIPlatform.Protocol.Services
         /// <param name="sessionId"></param>
         /// <param name="name"></param>
         /// <param name="organziation"></param>
-        /// <param name="collectors"></param>
+        /// <param name="gatherers"></param>
         /// <returns></returns>
-        Task CreateGatherCategoryAsync(long sessionId, string name, EntityBase organziation, List<EntityBase> collectors);
+        Task CreateGatherCategoryAsync(long sessionId, string name, EntityBase organziation, List<EntityBase> gatherers);
 
         /// <summary>
         /// Update a GatherCategory
@@ -1772,9 +1772,9 @@ namespace AIPlatform.Protocol.Services
         /// <param name="sessionId"></param>
         /// <param name="id"></param>
         /// <param name="name"></param>
-        /// <param name="collectors"></param>
+        /// <param name="gatherers"></param>
         /// <returns></returns>
-        Task UpdateGatherCategoryAsync(long sessionId, long id, string name, List<EntityBase> collectors);
+        Task UpdateGatherCategoryAsync(long sessionId, long id, string name, List<EntityBase> gatherers);
 
         /// <summary>
         /// Get  GatherCategory by id
@@ -1812,9 +1812,9 @@ namespace AIPlatform.Protocol.Services
         /// Create Gather Data
         /// </summary>
         /// <param name="sessionId"></param>
-        /// <param name="categoryId"></param>
+        /// <param name="category"></param>
         /// <param name="organization"></param>
-        /// <param name="collector"></param>
+        /// <param name="gatherer"></param>
         /// <param name="modelType"></param>
         /// <param name="source"></param>
         /// <param name="collectionQuantity"></param>
@@ -1822,16 +1822,16 @@ namespace AIPlatform.Protocol.Services
         /// <param name="endTime"></param>
         /// <param name="SettlementTime"></param>
         /// <returns></returns>
-        Task CreateGatherDataAsync(long sessionId, long categoryId, EntityBase organization, EntityBase collector, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime SettlementTime);
+        Task CreateGatherDataAsync(long sessionId, CategoryItem category, EntityBase organization, EntityBase gatherer, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime SettlementTime);
 
         /// <summary>
         /// Update Gather Data
         /// </summary>
         /// <param name="sessionId"></param>
         /// <param name="id"></param>
-        /// <param name="categoryId"></param>
+        /// <param name="category"></param>
         /// <param name="organization"></param>
-        /// <param name="collector"></param>
+        /// <param name="gatherer"></param>
         /// <param name="modelType"></param>
         /// <param name="source"></param>
         /// <param name="collectionQuantity"></param>
@@ -1839,7 +1839,7 @@ namespace AIPlatform.Protocol.Services
         /// <param name="endTime"></param>
         /// <param name="SettlementTime"></param>
         /// <returns></returns>
-        Task UpdateGatherDataAsync(long sessionId, long id, long categoryId, EntityBase organization, EntityBase collector, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime SettlementTime);
+        Task UpdateGatherDataAsync(long sessionId, long id, CategoryItem category, EntityBase organization, EntityBase gatherer, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime SettlementTime);
 
         /// <summary>
         /// Get  Gather Data by id
@@ -1866,15 +1866,6 @@ namespace AIPlatform.Protocol.Services
         /// <returns></returns>
         Task<long> GetGatherDatasCountAsync(long sessionId, SearchGatherDataModel searchGatherDataModel);
 
-        /// <summary>
-        /// GetCollectorsByGatherCategoryIdAsync
-        /// </summary>
-        /// <param name="id"></param>
-        /// <param name="organizationId"></param>
-        /// <param name="gatherCategoryId"></param>
-        /// <returns></returns>
-        Task<List<EntityBase>> GetCollectorsByGatherCategoryIdAsync(long id, long organizationId, long gatherCategoryId);
-
         #endregion GatherCategory
 
         #region 定价管理

+ 3 - 2
AIPlatform.Protocol/Utilities/ExTranslater.cs

@@ -90,8 +90,9 @@ namespace AIPlatform.Protocol.Utilities
                 .Replace("UploaderVersionNotMatched", "上传工具版本不匹配")
                 .Replace("LabelerVersionNotMatched", "标注工具版本不匹配")
                 .Replace("VentilatorParameterAnalyisFail", "参数信息解析失败")
-                .Replace("GatherCategoryAlreadyExists", "采集大类已存在")
-                .Replace("SettlementTimeIsExpired", "结算日期已过,无法修改!");
+                .Replace("GatherCategoryAlreadyExists", "已经存在同名的采集大类")
+                .Replace("SettlementTimeIsExpired", "结算日期已过,无法修改!")
+                .Replace("ImageCategoryAlreadyExists", "已经存在同名的图像大类");
         }
     }
 }

+ 8 - 13
aipadmin/AdminManager.cs

@@ -1,7 +1,6 @@
 using AIPlatform.Protocol.Entities;
 using AIPlatform.Protocol.Entities.Ventilator;
 using AIPlatform.Protocol.Model;
-using IdGen;
 using System;
 using System.Collections.Generic;
 using System.IO;
@@ -2272,18 +2271,18 @@ namespace aipadmin
         /// Create Gather Category
         /// </summary>
         /// <returns></returns>
-        public async Task CreateGatherCategoryAsync(string name, EntityBase organziation, List<EntityBase> collectors)
+        public async Task CreateGatherCategoryAsync(string name, EntityBase organziation, List<EntityBase> gatherers)
         {
-            await ServerProxy.AdminService.CreateGatherCategoryAsync(_session.Id, name, organziation, collectors);
+            await ServerProxy.AdminService.CreateGatherCategoryAsync(_session.Id, name, organziation, gatherers);
         }
 
         /// <summary>
         /// Update Gather Category
         /// </summary>
         /// <returns></returns>
-        public async Task UpdateGatherCategoryAsync(long id, string name, List<EntityBase> collectors)
+        public async Task UpdateGatherCategoryAsync(long id, string name, List<EntityBase> gatherers)
         {
-            await ServerProxy.AdminService.UpdateGatherCategoryAsync(_session.Id, id, name, collectors);
+            await ServerProxy.AdminService.UpdateGatherCategoryAsync(_session.Id, id, name, gatherers);
         }
 
         /// <summary>
@@ -2325,18 +2324,18 @@ namespace aipadmin
         /// Create Gather Data
         /// </summary>
         /// <returns></returns>
-        public async Task CreateGatherDataAsync(long gatherCategoryId, EntityBase organziation, EntityBase Collector, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime settlementTime)
+        public async Task CreateGatherDataAsync(CategoryItem category, EntityBase organziation, EntityBase gatherer, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime settlementTime)
         {
-            await ServerProxy.AdminService.CreateGatherDataAsync(_session.Id, gatherCategoryId, organziation, Collector, modelType, source, collectionQuantity, startTime, endTime, settlementTime);
+            await ServerProxy.AdminService.CreateGatherDataAsync(_session.Id, category, organziation, gatherer, modelType, source, collectionQuantity, startTime, endTime, settlementTime);
         }
 
         /// <summary>
         /// Update Gather Data
         /// </summary>
         /// <returns></returns>
-        public async Task UpdateGatherDataAsync(long id, long gatherCategoryId, EntityBase organziation, EntityBase Collector, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime settlementTime)
+        public async Task UpdateGatherDataAsync(long id, CategoryItem category, EntityBase organziation, EntityBase gatherer, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime settlementTime)
         {
-            await ServerProxy.AdminService.UpdateGatherDataAsync(_session.Id, id, gatherCategoryId, organziation, Collector, modelType, source, collectionQuantity, startTime, endTime, settlementTime);
+            await ServerProxy.AdminService.UpdateGatherDataAsync(_session.Id, id, category, organziation, gatherer, modelType, source, collectionQuantity, startTime, endTime, settlementTime);
         }
 
         /// <summary>
@@ -2365,10 +2364,6 @@ namespace aipadmin
             return await ServerProxy.AdminService.GetGatherDatasCountAsync(_session.Id, searchGatherDataModel);
         }
 
-        public async Task<List<EntityBase>> GetCollectorsByGatherCategoryIdAsync(long organizationId, long gatherCategoryId)
-        {
-            return await ServerProxy.AdminService.GetCollectorsByGatherCategoryIdAsync(_session.Id, organizationId, gatherCategoryId);
-        }
         #endregion GatherCategory
 
         #region 定价管理

+ 5 - 5
aipmgr/Models/GatherCategoryModel.cs

@@ -22,22 +22,22 @@ namespace aipmgr.Models
         public string? Name { get; set; }
 
         [Display(Name = "采集人员")]
-        public List<EntityBase> Collectors { get; set; }
+        public List<EntityBase> Gatherers { get; set; }
 
         [Display(Name = "采集人员")]
-        public string? CollectorName { get; set; }
+        public string? GathererName { get; set; }
 
         [Display(Name = "创建时间")]
         public DateTime CreateTime { get; set; }
 
         [Display(Name = "采集人员")]
         [Required(ErrorMessage = "{0}不能为空")]
-        public List<string> CollectorValues { get; set; }
+        public List<string> GatherersValue { get; set; }
 
         public GatherCategoryModel()
         {
-            Collectors = new List<EntityBase>();
-            CollectorValues = new List<string>();
+            Gatherers = new List<EntityBase>();
+            GatherersValue = new List<string>();
         }
     }
 }

+ 13 - 7
aipmgr/Models/GatherDataModel.cs

@@ -1,4 +1,5 @@
-using System.ComponentModel.DataAnnotations;
+using AIPlatform.Protocol.Entities;
+using System.ComponentModel.DataAnnotations;
 
 namespace aipmgr.Models
 {
@@ -15,21 +16,26 @@ namespace aipmgr.Models
         [Display(Name = "所属组织")]
         [Required(ErrorMessage = "{0}不能为空")]
         public string? OrganizationName { get; set; }
-        [Display(Name = "名称")]
+        [Display(Name = "大类")]
         [Required(ErrorMessage = "{0}不能为空")]
-        public string? GatherCategoryName { get; set; }
+        public string? CategoryName { get; set; }
 
-        [Display(Name = "名称")]
+        /// <summary>
+        /// 大类类型
+        /// </summary>
+        public CategoryType CategoryType { get; set; }
+
+        [Display(Name = "大类")]
         [Required(ErrorMessage = "{0}不能为空")]
-        public long GatherCategoryId { get; set; }
+        public long CategoryId { get; set; }
 
         [Display(Name = "采集人员")]
         [Required(ErrorMessage = "{0}不能为空")]
-        public string? CollectorName { get; set; }
+        public string? GathererName { get; set; }
 
         [Display(Name = "采集人员")]
         [Required(ErrorMessage = "{0}不能为空")]
-        public long? CollectorId { get; set; }
+        public long GathererId { get; set; }
 
         [Display(Name = "机型")]
         [Required(ErrorMessage = "{0}不能为空")]

+ 4 - 0
aipmgr/Models/ImageCategoryModel.cs

@@ -31,6 +31,9 @@ namespace aipmgr.Models
         [Display(Name = "共享开发人员")]
         public List<EntityBase> Sharers { get; set; }
 
+        [Display(Name = "采集人员")]
+        public List<EntityBase> Gatherers { get; set; }
+
         [Display(Name = "金标准")]
         public GoldStandardQuantityItem GoldStandardQuantityItem { get; set; }
 
@@ -65,6 +68,7 @@ namespace aipmgr.Models
             Labelers = new List<EntityBase>();
             Developers = new List<EntityBase>();
             Sharers = new List<EntityBase>();
+            Gatherers = new List<EntityBase>();
             GoldStandardQuantityItem = new GoldStandardQuantityItem();
             SelfCheckQuantityItem = new SelfCheckQuantityItem();
             VideoItem = new VideoItem();

+ 3 - 3
aipmgr/Pages/GatherCategories.razor

@@ -14,7 +14,7 @@
     <TableColumns>
         <TableColumn @bind-Field="@context.Name" TextWrap="false" Editable="true" TextEllipsis="true" Width="130" />
         <TableColumn @bind-Field="@context.OrganizationName" TextWrap="false" Width="50" IsReadonlyWhenEdit="true" TextEllipsis="true" />
-        <TableColumn @bind-Field="@context.Collectors" Width="120" TextWrap="false" IsReadonlyWhenEdit="true" TextEllipsis="true">
+        <TableColumn @bind-Field="@context.Gatherers" Width="120" TextWrap="false" IsReadonlyWhenEdit="true" TextEllipsis="true">
             <Template Context="value">
                 @if (value != null)
                 {
@@ -33,7 +33,7 @@
                 <BootstrapInput TValue="string" @bind-Value="@context.Name" ShowLabel="true" PlaceHolder="请输入..." />
             </div>
             <div class="col-12 col-sm-4">
-                <BootstrapInput TValue="string" @bind-Value="@context.CollectorName" ShowLabel="true" PlaceHolder="请输入..." />
+                <BootstrapInput TValue="string" @bind-Value="@context.GathererName" ShowLabel="true" PlaceHolder="请输入..." />
             </div>
         </div>
     </SearchTemplate>
@@ -63,7 +63,7 @@
                         }
                     </div>
                     <div class="col-12 col-sm-12">
-                        <MultiSelect Items="@_collectorItems" @bind-Value="@_currentGatherCategory.CollectorValues" OnSelectedItemsChanged="OnCollectorsChanged" />
+                        <MultiSelect Items="@_gathererItems" @bind-Value="@_currentGatherCategory.GatherersValue" OnSelectedItemsChanged="OnGatherersChanged" />
                     </div>
                 </div>
             </ValidateForm>

+ 16 - 16
aipmgr/Pages/GatherCategories.razor.cs

@@ -26,7 +26,7 @@ namespace aipmgr.Pages
         private List<SelectedItem>? _organizationItems { get; set; }
 
         [NotNull]
-        private List<SelectedItem>? _collectorItems { get; set; }
+        private List<SelectedItem>? _gathererItems { get; set; }
 
         [NotNull]
         private Modal? _createOrEditModal { get; set; }
@@ -40,7 +40,7 @@ namespace aipmgr.Pages
         {
             await base.OnInitializedAsync();
             _organizationItems = new List<SelectedItem>();
-            _collectorItems = new List<SelectedItem>();
+            _gathererItems = new List<SelectedItem>();
             _currentGatherCategory = new GatherCategoryModel();
             var organizations = await AdminManager.Shared.GetOrganizationsAsync();
             _organizationItems = organizations.Select(x => new SelectedItem
@@ -57,8 +57,8 @@ namespace aipmgr.Pages
                 await LoadingManager.OpenAsync();
                 _currentGatherCategory.OrganizationId = long.Parse(item.Value);
                 _currentGatherCategory.OrganizationName = item.Text;
-                var collectors = (await AdminManager.Shared.GetAccountsAsync(Role.Gatherer)).Where(x => x.Organizations.Any(y => y.Id == _currentGatherCategory.OrganizationId)).ToList();
-                _collectorItems = collectors.Select(x => new SelectedItem
+                var gatherers = (await AdminManager.Shared.GetAccountsAsync(Role.Gatherer)).Where(x => x.Organizations.Any(y => y.Id == _currentGatherCategory.OrganizationId)).ToList();
+                _gathererItems = gatherers.Select(x => new SelectedItem
                 {
                     Value = x.Id.ToString(),
                     Text = x.Name
@@ -75,18 +75,18 @@ namespace aipmgr.Pages
             }
         }
 
-        private Task OnCollectorsChanged(IEnumerable<SelectedItem> items)
+        private Task OnGatherersChanged(IEnumerable<SelectedItem> items)
         {
-            var collectors = new List<EntityBase>();
+            var gatherers = new List<EntityBase>();
             foreach (var item in items)
             {
-                collectors.Add(new EntityBase
+                gatherers.Add(new EntityBase
                 {
                     Id = long.Parse(item.Value),
                     Name = item.Text
                 });
             }
-            _currentGatherCategory.Collectors = collectors;
+            _currentGatherCategory.Gatherers = gatherers;
             return Task.CompletedTask;
         }
 
@@ -100,12 +100,11 @@ namespace aipmgr.Pages
                     Value = x.Id.ToString(),
                     Text = x.Name
                 }).ToList();
-
                 var searchModel = new SearchGatherCategoryModel
                 {
                     Name = SearchModel.Name,
                     OrganizationId = SearchModel.OrganizationId,
-                    CollectorName = SearchModel.CollectorName,
+                    GathererName = SearchModel.GathererName,
                 };
                 var pageIndex = options.PageIndex - 1;
                 var pageSize = options.PageItems;
@@ -118,7 +117,7 @@ namespace aipmgr.Pages
                     vo.OrganizationId = item.Organization.Id;
                     vo.OrganizationName = item.Organization.Name;
                     vo.CreateTime = vo.CreateTime.ToLocalTime();
-                    vo.CollectorValues = item.Collectors.Select(x => x.Id.ToString()).ToList();
+                    vo.GatherersValue = item.Gatherers.Select(x => x.Id.ToString()).ToList();
                     items.Add(vo);
                 }
                 return await Task.FromResult(new QueryData<GatherCategoryModel>()
@@ -144,7 +143,7 @@ namespace aipmgr.Pages
                     item.OrganizationName = _organizationItems.First().Text;
                 }
                 item.Name = null;
-                item.CollectorName = null;
+                item.GathererName = null;
             }
             catch (Exception ex)
             {
@@ -198,17 +197,18 @@ namespace aipmgr.Pages
             try
             {
                 await LoadingManager.OpenAsync();
+
                 if (string.IsNullOrEmpty(_currentGatherCategory.Name))
                 {
                     await _messageBaseRef.ShowMessageBaseAsync("请输入名称!");
                     return;
                 }
-                if (string.IsNullOrEmpty(_currentGatherCategory.OrganizationName))
+                if (_currentGatherCategory.OrganizationId == 0)
                 {
                     await _messageBaseRef.ShowMessageBaseAsync("请选择组织!");
                     return;
                 }
-                if (_currentGatherCategory.Collectors.Count == 0)
+                if (_currentGatherCategory.Gatherers.Count == 0)
                 {
                     await _messageBaseRef.ShowMessageBaseAsync("请选择采集者!");
                     return;
@@ -216,7 +216,7 @@ namespace aipmgr.Pages
                 if (_changedType == ItemChangedType.Update)
                 {
                     var gatherCategory = await AdminManager.Shared.GetGatherCategoryByIdAsync(_currentGatherCategory.Id);
-                    await AdminManager.Shared.UpdateGatherCategoryAsync(_currentGatherCategory.Id, _currentGatherCategory.Name, _currentGatherCategory.Collectors);
+                    await AdminManager.Shared.UpdateGatherCategoryAsync(_currentGatherCategory.Id, _currentGatherCategory.Name, _currentGatherCategory.Gatherers);
                 }
                 else if (_changedType == ItemChangedType.Add)
                 {
@@ -224,7 +224,7 @@ namespace aipmgr.Pages
                     {
                         Id = _currentGatherCategory.OrganizationId,
                         Name = _currentGatherCategory.OrganizationName
-                    }, _currentGatherCategory.Collectors);
+                    }, _currentGatherCategory.Gatherers);
                 }
                 StateHasChanged();
                 await _createOrEditModal.Close();

+ 12 - 12
aipmgr/Pages/GatherDatas.razor

@@ -12,13 +12,13 @@
         <TableToolbarButton TItem="GatherDataModel" Color="BootstrapBlazor.Components.Color.Success" Icon="fa fa-plus" Text="新建" TooltipText="新建采集分类" OnClick="@OnAddAsync" />
     </TableToolbarTemplate>
     <TableColumns>
-        <TableColumn @bind-Field="@context.GatherCategoryName" TextWrap="false" TextEllipsis="true" Width="130" />
-        <TableColumn @bind-Field="@context.OrganizationName" TextWrap="false" Width="50" IsReadonlyWhenEdit="true" TextEllipsis="true" />
-        <TableColumn @bind-Field="@context.CollectorName" Width="120" TextWrap="false" IsReadonlyWhenEdit="true" TextEllipsis="true" />
-        <TableColumn @bind-Field="@context.ModelType" TextWrap="false" Width="50" IsReadonlyWhenEdit="true" TextEllipsis="true" />
-        <TableColumn @bind-Field="@context.Source" Width="120" TextWrap="false" IsReadonlyWhenEdit="true" TextEllipsis="true" />
-        <TableColumn @bind-Field="@context.CollectionQuantity" Width="120" TextWrap="false" IsReadonlyWhenEdit="true" TextEllipsis="true" />
-        <TableColumn @bind-Field="@context.GatherTime" Width="120" TextWrap="false" IsReadonlyWhenEdit="true" TextEllipsis="true">
+        <TableColumn @bind-Field="@context.CategoryName" TextWrap="false" TextEllipsis="true" Width="130" />
+        <TableColumn @bind-Field="@context.OrganizationName" TextWrap="false" Width="50" TextEllipsis="true" />
+        <TableColumn @bind-Field="@context.GathererName" Width="120" TextWrap="false" TextEllipsis="true" />
+        <TableColumn @bind-Field="@context.ModelType" TextWrap="false" Width="50" TextEllipsis="true" />
+        <TableColumn @bind-Field="@context.Source" Width="120" TextWrap="false" TextEllipsis="true" />
+        <TableColumn @bind-Field="@context.CollectionQuantity" Width="120" TextWrap="false" TextEllipsis="true" />
+        <TableColumn @bind-Field="@context.GatherTime" Width="200" TextWrap="false" TextEllipsis="true">
             <Template Context="value">
                 @if (value != null)
                 {
@@ -26,7 +26,7 @@
                 }
             </Template>
         </TableColumn>
-        <TableColumn @bind-Field="@context.SettlementTime" TextWrap="false" IsReadonlyWhenEdit="true" Width="175" TextEllipsis="true" FormatString="yyyy-MM-dd" Sortable="true" />
+        <TableColumn @bind-Field="@context.SettlementTime" TextWrap="false" Width="175" TextEllipsis="true" FormatString="yyyy-MM-dd" />
     </TableColumns>
     <SearchTemplate>
         <div class="row g-3 form-inline">
@@ -34,10 +34,10 @@
                 <Select @bind-Value="@context.OrganizationId" Items="@_organizationItems" ShowLabel="true" />
             </div>
             <div class="col-12 col-sm-4">
-                <BootstrapInput TValue="string" @bind-Value="@context.GatherCategoryName" ShowLabel="true" PlaceHolder="请输入..." />
+                <BootstrapInput TValue="string" @bind-Value="@context.CategoryName" ShowLabel="true" PlaceHolder="请输入..." />
             </div>
             <div class="col-12 col-sm-4">
-                <BootstrapInput TValue="string" @bind-Value="@context.CollectorName" ShowLabel="true" PlaceHolder="请输入..." />
+                <BootstrapInput TValue="string" @bind-Value="@context.GathererName" ShowLabel="true" PlaceHolder="请输入..." />
             </div>
 
             <div class="col-12 col-sm-4">
@@ -67,10 +67,10 @@
                         <Select Items="@_organizationItems" @bind-Value="@_currentGatherData.OrganizationId" OnSelectedItemChanged="OnOrganizationChanged" />
                     </div>
                     <div class="col-12 col-sm-12">
-                        <Select Items="@_gatherCategoryItems" @bind-Value="@_currentGatherData.GatherCategoryId" OnSelectedItemChanged="OnGatherCategoryChanged" />
+                        <Select Items="@_categoryItems" @bind-Value="@_currentGatherData.CategoryId" OnSelectedItemChanged="OnGatherCategoryChanged" />
                     </div>
                     <div class="col-12 col-sm-12">
-                        <Select Items="@_collectorItems" @bind-Value="@_currentGatherData.CollectorId" OnSelectedItemChanged="OnCollectorChanged" />
+                        <Select Items="@_gathererItems" @bind-Value="@_currentGatherData.GathererId" OnSelectedItemChanged="OnGatherChanged" />
                     </div>
                     <div class="col-12 col-sm-12">
                         <BootstrapInput @bind-Value="@_currentGatherData.ModelType" />

+ 104 - 47
aipmgr/Pages/GatherDatas.razor.cs

@@ -30,10 +30,10 @@ namespace aipmgr.Pages
         private List<SelectedItem>? _organizationItems { get; set; }
 
         [NotNull]
-        private List<SelectedItem>? _collectorItems { get; set; }
+        private List<SelectedItem>? _gathererItems { get; set; }
 
         [NotNull]
-        private List<SelectedItem>? _gatherCategoryItems { get; set; }
+        private List<SelectedItem>? _categoryItems { get; set; }
 
         [NotNull]
         private Modal? _createOrEditModal { get; set; }
@@ -47,8 +47,8 @@ namespace aipmgr.Pages
         {
             await base.OnInitializedAsync();
             _organizationItems = new List<SelectedItem>();
-            _collectorItems = new List<SelectedItem>();
-            _gatherCategoryItems = new List<SelectedItem>();
+            _gathererItems = new List<SelectedItem>();
+            _categoryItems = new List<SelectedItem>();
             _currentGatherData = new GatherDataModel();
             var organizations = await AdminManager.Shared.GetOrganizationsAsync();
             _organizationItems = organizations.Select(x => new SelectedItem
@@ -63,23 +63,47 @@ namespace aipmgr.Pages
             try
             {
                 await LoadingManager.OpenAsync();
-                _currentGatherData.OrganizationId = long.Parse(item.Value);
                 _currentGatherData.OrganizationName = item.Text;
                 if (_currentGatherData.OrganizationId == 0)
                 {
-                    _currentGatherData.GatherCategoryId = 0;
-                    _currentGatherData.GatherCategoryName = null;
-                    _currentGatherData.CollectorId = 0;
-                    _currentGatherData.CollectorName = null;
+                    _categoryItems.Clear();
+                    _currentGatherData.CategoryId = 0;
+                    _currentGatherData.CategoryName = null;
+                    _currentGatherData.GathererId = 0;
+                    _currentGatherData.GathererName = null;
                 }
-                if (_currentGatherData.OrganizationId > 0)
+                else if (_currentGatherData.OrganizationId > 0)
                 {
-                    var categories = await AdminManager.Shared.GetGatherCategoriesByOrganizationIdAsync(_currentGatherData.OrganizationId);
-                    _gatherCategoryItems = categories.Select(x => new SelectedItem
+                    _categoryItems.Clear();
+                    var imageCategories = await AdminManager.Shared.GetImageCategoriesByLevelAsync(CategoryLevel.MainCategory);
+                    if (imageCategories != null)
                     {
-                        Value = x.Id.ToString(),
-                        Text = x.Name
-                    }).ToList();
+                        foreach (var imageCategory in imageCategories)
+                        {
+                            var selectItem = new SelectedItem
+                            {
+                                Value = imageCategory.Id.ToString(),
+                                Text = imageCategory.Name,
+                                GroupName = "图像大类",
+                            };
+                            _categoryItems.Add(selectItem);
+                        }
+                    }
+                    var gatherCategories = await AdminManager.Shared.GetGatherCategoriesByOrganizationIdAsync(_currentGatherData.OrganizationId);
+                    if (gatherCategories != null)
+                    {
+                        foreach (var gatherCategory in gatherCategories)
+                        {
+                            var selectItem = new SelectedItem
+                            {
+                                Value = gatherCategory.Id.ToString(),
+                                Text = gatherCategory.Name,
+                                GroupName = "采集大类",
+                            };
+                            _categoryItems.Add(selectItem);
+                        }
+                    }
+                    _categoryItems.Insert(0, new SelectedItem("0", "请选择..."));
                 }
             }
             catch (Exception ex)
@@ -98,19 +122,36 @@ namespace aipmgr.Pages
             try
             {
                 await LoadingManager.OpenAsync();
-                if (_currentGatherData.GatherCategoryId == 0)
+                _currentGatherData.CategoryName = item.Text;
+                if (_currentGatherData.CategoryId == 0)
                 {
-                    _currentGatherData.CollectorId = 0;
-                    _currentGatherData.CollectorName = null;
+                    _gathererItems.Clear();
+                    _currentGatherData.GathererId = 0;
+                    _currentGatherData.GathererName = null;
                 }
                 else
                 {
-                    var collectors = await AdminManager.Shared.GetCollectorsByGatherCategoryIdAsync(_currentGatherData.OrganizationId, _currentGatherData.GatherCategoryId);
-                    _collectorItems = collectors.Select(x => new SelectedItem
+                    if (item.GroupName == "图像大类")
+                    {
+                        var imageCategory = await AdminManager.Shared.GetImageCategoryAsync(_currentGatherData.CategoryId);
+                        _gathererItems = imageCategory.Gatherers.Select(x => new SelectedItem
+                        {
+                            Value = x.Id.ToString(),
+                            Text = x.Name
+                        }).ToList();
+                        _currentGatherData.CategoryType = CategoryType.ImageCategory;
+                    }
+                    else if (item.GroupName == "采集大类")
                     {
-                        Value = x.Id.ToString(),
-                        Text = x.Name
-                    }).ToList();
+                        var gatherCategory = await AdminManager.Shared.GetGatherCategoryByIdAsync(_currentGatherData.CategoryId);
+                        _gathererItems = gatherCategory.Gatherers.Select(x => new SelectedItem
+                        {
+                            Value = x.Id.ToString(),
+                            Text = x.Name
+                        }).ToList();
+                        _currentGatherData.CategoryType = CategoryType.GatherCategory;
+                    }
+                    _gathererItems.Insert(0, new SelectedItem("0", "请选择..."));
                 }
             }
             catch (Exception ex)
@@ -124,13 +165,12 @@ namespace aipmgr.Pages
             }
         }
 
-        private async Task OnCollectorChanged(SelectedItem item)
+        private async Task OnGatherChanged(SelectedItem item)
         {
             try
             {
                 await LoadingManager.OpenAsync();
-                _currentGatherData.CollectorId = long.Parse(item.Value);
-                _currentGatherData.CollectorName = item.Text;
+                _currentGatherData.GathererName = item.Text;
             }
             catch (Exception ex)
             {
@@ -153,11 +193,10 @@ namespace aipmgr.Pages
                     Value = x.Id.ToString(),
                     Text = x.Name
                 }).ToList();
-
                 var searchModel = new SearchGatherDataModel
                 {
-                    Name = SearchModel.GatherCategoryName,
-                    CollectorName = SearchModel.CollectorName,
+                    Name = SearchModel.CategoryName,
+                    GathererName = SearchModel.GathererName,
                     OrganizationId = SearchModel.OrganizationId,
                     ModelType = SearchModel.ModelType,
                     Source = SearchModel.Source,
@@ -175,10 +214,11 @@ namespace aipmgr.Pages
                 foreach (var item in files)
                 {
                     var vo = MapHelper.Map<GatherDataModel, GatherData>(item);
-                    vo.CollectorName = item.Collector.Name;
-                    vo.CollectorId = item.Collector.Id;
-                    vo.GatherCategoryName = item.GatherCategory.Name;
-                    vo.GatherCategoryId = item.GatherCategory.Id;
+                    vo.GathererName = item.Gatherer.Name;
+                    vo.GathererId = item.Gatherer.Id;
+                    vo.CategoryName = item.Category.Name;
+                    vo.CategoryId = item.Category.Id;
+                    vo.CategoryType = item.Category.Type;
                     vo.OrganizationId = item.Organization.Id;
                     vo.OrganizationName = item.Organization.Name;
                     vo.GatherTime.StartTime = item.StartTime.ToLocalTime();
@@ -208,8 +248,8 @@ namespace aipmgr.Pages
                     item.OrganizationId = long.Parse(_organizationItems.First().Value);
                     item.OrganizationName = _organizationItems.First().Text;
                 }
-                item.GatherCategoryName = null;
-                item.CollectorName = null;
+                item.CategoryName = null;
+                item.GathererName = null;
                 item.ModelType = null;
                 item.Source = null;
                 item.SettlementTime = null;
@@ -275,17 +315,17 @@ namespace aipmgr.Pages
                     _currentGatherData.GatherTime.StartTime = GatherTimeRange.Start;
                     _currentGatherData.GatherTime.EndTime = GatherTimeRange.End;
                 }
-                if (string.IsNullOrEmpty(_currentGatherData.OrganizationName))
+                if (_currentGatherData.OrganizationId == 0)
                 {
                     await _messageBaseRef.ShowMessageBaseAsync("请选择组织!");
                     return;
                 }
-                if (_currentGatherData.GatherCategoryId <= 0)
+                if (_currentGatherData.CategoryId == 0)
                 {
                     await _messageBaseRef.ShowMessageBaseAsync("请选择采集大类!");
                     return;
                 }
-                if (_currentGatherData.CollectorId == null || _currentGatherData.GatherCategoryId <= 0)
+                if (_currentGatherData.GathererId == 0)
                 {
                     await _messageBaseRef.ShowMessageBaseAsync("请选择采集人员!");
                     return;
@@ -323,26 +363,43 @@ namespace aipmgr.Pages
                 if (_changedType == ItemChangedType.Update)
                 {
                     var gatherData = await AdminManager.Shared.GetGatherDataByIdAsync(_currentGatherData.Id);
-                    await AdminManager.Shared.UpdateGatherDataAsync(gatherData.Id, _currentGatherData.GatherCategoryId, new EntityBase
+                    await AdminManager.Shared.UpdateGatherDataAsync(gatherData.Id,
+                    new CategoryItem
+                    {
+                        Id = _currentGatherData.CategoryId,
+                        Name = _currentGatherData.CategoryName,
+                        Type = _currentGatherData.CategoryType,
+                    },
+                    new EntityBase
                     {
                         Id = _currentGatherData.OrganizationId,
                         Name = _currentGatherData.OrganizationName,
-                    }, new EntityBase
+                    },
+                    new EntityBase
                     {
-                        Id = _currentGatherData.CollectorId.Value,
-                        Name = _currentGatherData.CollectorName,
-                    }, _currentGatherData.ModelType, _currentGatherData.Source, _currentGatherData.CollectionQuantity.Value, _currentGatherData.GatherTime.StartTime.Value, _currentGatherData.GatherTime.EndTime.Value, _currentGatherData.SettlementTime.Value);
+                        Id = _currentGatherData.GathererId,
+                        Name = _currentGatherData.GathererName,
+                    },
+                    _currentGatherData.ModelType, _currentGatherData.Source, _currentGatherData.CollectionQuantity.Value, _currentGatherData.GatherTime.StartTime.Value, _currentGatherData.GatherTime.EndTime.Value, _currentGatherData.SettlementTime.Value);
                 }
                 else if (_changedType == ItemChangedType.Add)
                 {
-                    await AdminManager.Shared.CreateGatherDataAsync(_currentGatherData.GatherCategoryId, new EntityBase
+                    await AdminManager.Shared.CreateGatherDataAsync(
+                    new CategoryItem
+                    {
+                        Id = _currentGatherData.CategoryId,
+                        Name = _currentGatherData.CategoryName,
+                        Type = _currentGatherData.CategoryType,
+                    },
+                    new EntityBase
                     {
                         Id = _currentGatherData.OrganizationId,
                         Name = _currentGatherData.OrganizationName,
-                    }, new EntityBase
+                    },
+                    new EntityBase
                     {
-                        Id = _currentGatherData.CollectorId.Value,
-                        Name = _currentGatherData.CollectorName,
+                        Id = _currentGatherData.GathererId,
+                        Name = _currentGatherData.GathererName,
                     }, _currentGatherData.ModelType, _currentGatherData.Source, _currentGatherData.CollectionQuantity.Value, _currentGatherData.GatherTime.StartTime.Value, _currentGatherData.GatherTime.EndTime.Value, _currentGatherData.SettlementTime.Value);
                 }
                 StateHasChanged();

+ 40 - 31
aipmgr/Pages/ImageCategories.razor

@@ -37,35 +37,43 @@
                 }
             </Template>
         </TableColumn>
-        <TableColumn @bind-Field="@context.GoldStandardQuantityItem" Width="90" TextWrap="true">
+        <TableColumn @bind-Field="@context.Gatherers" Width="110" TextWrap="true">
             <Template Context="value">
-                <div class="row g-3 form-inline mt-0">
-                    @if (value != null && value.Row.Level == CategoryLevel.MainCategory)
-                    {
-                        <div class="col-12 m-0">
-                            比例:@value.Value.Proportion
-                        </div>
-                        <div class="col-12 m-0">
-                            达标人数:@value.Value.QualifiedPeople
-                        </div>
-                    }
-                </div>
-            </Template>
-        </TableColumn>
-        <TableColumn @bind-Field="@context.SelfCheckQuantityItem" Width="90" TextWrap="true">
-            <Template Context="value">
-                <div class="row g-3 form-inline mt-0">
-                    @if (value != null && value.Row.Level == CategoryLevel.MainCategory)
-                    {
-                        <div class="col-12 m-0">
-                            比例:@value.Value.Proportion
-                        </div>
-                    }
-                </div>
+                @if (value != null)
+                {
+                    @string.Join(", ", value.Value.Select(v => v.Name))
+                }
             </Template>
         </TableColumn>
+        @*  <TableColumn @bind-Field="@context.GoldStandardQuantityItem" Width="90" TextWrap="true">
+        <Template Context="value">
+        <div class="row g-3 form-inline mt-0">
+        @if (value != null && value.Row.Level == CategoryLevel.MainCategory)
+        {
+        <div class="col-12 m-0">
+        比例:@value.Value.Proportion
+        </div>
+        <div class="col-12 m-0">
+        达标人数:@value.Value.QualifiedPeople
+        </div>
+        }
+        </div>
+        </Template>
+        </TableColumn> *@
+        @* <TableColumn @bind-Field="@context.SelfCheckQuantityItem" Width="90" TextWrap="true">
+        <Template Context="value">
+        <div class="row g-3 form-inline mt-0">
+        @if (value != null && value.Row.Level == CategoryLevel.MainCategory)
+        {
+        <div class="col-12 m-0">
+        比例:@value.Value.Proportion
+        </div>
+        }
+        </div>
+        </Template>
+        </TableColumn>  *@
         <TableColumn @bind-Field="@context.IsSupportedSkipFrame" Width="90">
-             <Template Context="value">
+            <Template Context="value">
                 @if (value != null && value.Row.Level == CategoryLevel.MainCategory)
                 {
                     @if (value.Value)
@@ -82,7 +90,7 @@
                     }
                 }
             </Template>
-            </TableColumn>
+        </TableColumn>
         <TableColumn @bind-Field="@context.DifficultyLevel" Width="90">
             <Template Context="value">
                 @if (value != null && value.Row.Level == CategoryLevel.MainCategory)
@@ -92,7 +100,7 @@
                     </div>
                 }
             </Template>
-         </TableColumn>
+        </TableColumn>
         @* <TableColumn @bind-Field="@context.CreateTime" Width="135" FormatString="yyyy-MM-dd HH:mm:ss" /> *@
         <TableColumn @bind-Field="@context.UpdateTime" Width="135" FormatString="yyyy-MM-dd HH:mm:ss" />
         @*<TableColumn @bind-Field="@context.Id" Width="250" Text="操作" TextWrap="true">
@@ -113,6 +121,7 @@
             <Button Size="Size.ExtraSmall" Color="BootstrapBlazor.Components.Color.Primary" Text="分配标注人员" OnClick="@(()=>OnAssignUserAsync(value, AccountType.Labeler))" />
             <Button Size="Size.ExtraSmall" Color="BootstrapBlazor.Components.Color.Success" Text="分配开发人员" OnClick="@(()=>OnAssignUserAsync(value, AccountType.Developer))" />
             <Button Size="Size.ExtraSmall" Color="BootstrapBlazor.Components.Color.Info" Text="分配共享开发人员" style="color:#ffffff" OnClick="@(()=>OnAssignUserAsync(value, AccountType.Sharer))" />
+            <Button Size="Size.ExtraSmall" Color="BootstrapBlazor.Components.Color.Secondary" Text="分配采集人员" style="color:#ffffff" OnClick="@(()=>OnAssignUserAsync(value, AccountType.Gatherer))" />
             <Button Size="Size.ExtraSmall" Color="BootstrapBlazor.Components.Color.Warning" Text="设置" TooltipText="设置金标准、自校验及其他" OnClick="@(()=>OnSetGoldStandardAsync(value))" />
         }
     </BeforeRowButtonTemplate>
@@ -180,20 +189,20 @@
                 <div class="col-12 col-sm-9">
                     <BootstrapInputNumber @bind-Value="@_currChild.VideoItem.IntervalFrame" Min="1" />
                 </div>
-                @if(_currChild.VideoItem.FrameMode == FrameMode.EqualInterval)
+                @if (_currChild.VideoItem.FrameMode == FrameMode.EqualInterval)
                 {
                     <div class="col-12 col-sm-3 col-form-label">
                         <span>相似度阈值(0~1)</span>
                     </div>
                     <div class="col-12 col-sm-9">
-                            <BootstrapInputNumber @bind-Value="@_currChild.VideoItem.SimilarityThreshold" Min="0" Max="1" Step="0.01" />
+                        <BootstrapInputNumber @bind-Value="@_currChild.VideoItem.SimilarityThreshold" Min="0" Max="1" Step="0.01" />
                     </div>
-                }  
+                }
                 <div class="col-12 col-sm-3 col-form-label">
                     <span>难度等级</span>
                 </div>
                 <div class="col-12 col-sm-9">
-                    <Select @bind-Value="@_currChild.DifficultyLevel"/>
+                    <Select @bind-Value="@_currChild.DifficultyLevel" />
                 </div>
             </div>
         </BodyTemplate>

+ 22 - 2
aipmgr/Pages/ImageCategories.razor.cs

@@ -206,7 +206,7 @@ namespace aipmgr.Pages
 
         #endregion 搜索,树型默认展开第一级
 
-        #region 分配标注/开发/共享人员
+        #region 分配标注/开发/共享人员/采集人员
 
         private async Task OnAssignUserAsync(ImageCategoryModel item, AccountType accountType)
         {
@@ -263,6 +263,23 @@ namespace aipmgr.Pages
                         }
                         _selectedUserValues = item.Sharers.Select(x => x.Id.ToString()).ToList();
                         break;
+
+                    case AccountType.Gatherer:
+                        _assignUserModalTitle = "分配采集人员";
+                        foreach (var gatherer in _accounts)
+                        {
+                            if (gatherer.Organizations.Any(x => x.Id == item.OrganizationId && gatherer.Roles.Contains(Role.Gatherer)))
+                            {
+                                _users.Add(new SelectedItem
+                                {
+                                    Value = gatherer.Id.ToString(),
+                                    Text = gatherer.Name
+                                });
+                            }
+                        }
+                        _selectedUserValues = item.Gatherers.Select(x => x.Id.ToString()).ToList();
+                        break;
+
                     default:
                         _assignUserModalTitle = "分配人员";
                         break;
@@ -305,6 +322,9 @@ namespace aipmgr.Pages
                     case AccountType.Sharer:
                         _currChild.Sharers = users;
                         break;
+                    case AccountType.Gatherer:
+                        _currChild.Gatherers = users;
+                        break;
                     default:
                         break;
                 }
@@ -330,7 +350,7 @@ namespace aipmgr.Pages
             return Task.CompletedTask;
         }
 
-        #endregion 分配标注/开发/共享人员
+        #endregion 分配标注/开发/共享人员/采集人员
 
         #region 设置金标准/自校验/视频标注帧
 

+ 62 - 90
aipsvr/Services/AdminService.cs

@@ -8477,6 +8477,15 @@ namespace aipsvr.Services
                 {
                     var databaseService = ServiceManager.GetService<IDatabaseService>();
                     var labelPackageDataManager = databaseService.GetManager<ILabelPackageDataManager>();
+                    var gatherDataManager = databaseService.GetManager<IGatherDataManager>();
+                    foreach (var organization in organizations)
+                    {
+                        var existItem = await gatherDataManager.GetGatherCategoryByNameAsync(name, organization.Id);
+                        if (existItem != null)
+                        {
+                            throw new InvalidDataException("GatherCategoryAlreadyExists");
+                        }
+                    }
                     var labelPackage = await labelPackageDataManager.GetLabelPackageAsync(name, organizations);
                     if (labelPackage == null)
                     {
@@ -10138,6 +10147,10 @@ namespace aipsvr.Services
                         await imageCategoryDataManager.UpdateImageCategorySharersAsync(id, users);
                         break;
 
+                    case AccountType.Gatherer:
+                        await imageCategoryDataManager.UpdateImageCategoryGatherersAsync(id, users);
+                        break;
+
                     default:
                         break;
                 }
@@ -12018,9 +12031,9 @@ namespace aipsvr.Services
         /// <param name="sessionId"></param>
         /// <param name="name"></param>
         /// <param name="organziation"></param>
-        /// <param name="collectors"></param>
+        /// <param name="gatherers"></param>
         /// <returns></returns>
-        public async Task CreateGatherCategoryAsync(long sessionId, string name, EntityBase organziation, List<EntityBase> collectors)
+        public async Task CreateGatherCategoryAsync(long sessionId, string name, EntityBase organziation, List<EntityBase> gatherers)
         {
             ActivateSession(sessionId);
             var session = SessionManager.GetSession(sessionId);
@@ -12030,22 +12043,25 @@ namespace aipsvr.Services
                 {
                     var databaseService = ServiceManager.GetService<IDatabaseService>();
                     var gatherDataManager = databaseService.GetManager<IGatherDataManager>();
-                    var existItem = await gatherDataManager.GetGatherCategoryByNameAsync(name);
-                    if (existItem == null)
+                    var labelPackageDataManager = databaseService.GetManager<ILabelPackageDataManager>();
+                    var imageCategory = await labelPackageDataManager.GetLabelPackageAsync(name, new List<EntityBase> { organziation });
+                    if (imageCategory == null)
                     {
-                        var gatherCategory = new GatherCategory
+                        var existItem = await gatherDataManager.GetGatherCategoryByNameAsync(name, organziation.Id);
+                        if (existItem == null)
                         {
-                            Name = name,
-                            Organization = organziation,
-                            Collectors = collectors
-                        };
-                        await gatherDataManager.CreateGatherCategoryAsync(gatherCategory);
-                        return;
-                    }
-                    else
-                    {
+                            var gatherCategory = new GatherCategory
+                            {
+                                Name = name,
+                                Organization = organziation,
+                                Gatherers = gatherers
+                            };
+                            await gatherDataManager.CreateGatherCategoryAsync(gatherCategory);
+                            return;
+                        }
                         throw new InvalidDataException("GatherCategoryAlreadyExists");
                     }
+                    throw new InvalidOperationException("ImageCategoryAlreadyExists");
                 }
             }
             throw new InvalidOperationException("InvalidAdminSession");
@@ -12055,9 +12071,9 @@ namespace aipsvr.Services
         /// update GatherCategory
         /// </summary>
         /// <param name="sessionId"></param>
-        /// <param name="collectors"></param>
+        /// <param name="gatherers"></param>
         /// <returns></returns>
-        public async Task UpdateGatherCategoryAsync(long sessionId, long id, string name, List<EntityBase> collectors)
+        public async Task UpdateGatherCategoryAsync(long sessionId, long id, string name, List<EntityBase> gatherers)
         {
             ActivateSession(sessionId);
             var session = SessionManager.GetSession(sessionId);
@@ -12067,39 +12083,42 @@ namespace aipsvr.Services
                 {
                     var databaseService = ServiceManager.GetService<IDatabaseService>();
                     var gatherDataManager = databaseService.GetManager<IGatherDataManager>();
+                    var labelPackageDataManager = databaseService.GetManager<ILabelPackageDataManager>();
                     var gatherCategory = await gatherDataManager.GetGatherCategoryByIdAsync(id);
-                    var existItem = await gatherDataManager.GetGatherCategoryByNameAsync(name);
-                    if (existItem == null)
+                    var imageCategory = await labelPackageDataManager.GetLabelPackageAsync(name, new List<EntityBase> { gatherCategory.Organization });
+                    if (imageCategory == null)
                     {
-                        bool updateName = false;
-                        if (gatherCategory.Name != name)
-                        {
-                            updateName = true;
-                            gatherCategory.Name = name;
-                        }
-                        gatherCategory.Collectors = collectors;
-                        await gatherDataManager.UpdateGatherCategoryAsync(gatherCategory);
-                        if (updateName)
+                        var existItem = await gatherDataManager.GetGatherCategoryByNameAsync(name, gatherCategory.Organization.Id);
+                        if (existItem == null)
                         {
-                            var gatherDatas = await gatherDataManager.GetGatherDatasByCategoryIdAsync(id);
-                            if (gatherDatas != null)
+                            bool updateName = false;
+                            if (gatherCategory.Name != name)
                             {
-                                foreach (var gatherData in gatherDatas)
+                                updateName = true;
+                                gatherCategory.Name = name;
+                            }
+                            gatherCategory.Gatherers = gatherers;
+                            await gatherDataManager.UpdateGatherCategoryAsync(gatherCategory);
+                            if (updateName)
+                            {
+                                var gatherDatas = await gatherDataManager.GetGatherDatasByCategoryIdAsync(id);
+                                if (gatherDatas != null)
                                 {
-                                    gatherData.GatherCategory.Name = name;
-                                    await gatherDataManager.UpdateGatherDataAsync(gatherData);
+                                    foreach (var gatherData in gatherDatas)
+                                    {
+                                        gatherData.Category.Name = name;
+                                        await gatherDataManager.UpdateGatherDataAsync(gatherData);
+                                    }
                                 }
                             }
+                            return;
                         }
-                        return;
-                    }
-                    else
-                    {
                         throw new InvalidDataException("GatherCategoryAlreadyExists");
                     }
+                    throw new InvalidDataException("ImageCategoryAlreadyExists");
                 }
+                throw new InvalidOperationException("InvalidAdminSession");
             }
-            throw new InvalidOperationException("InvalidAdminSession");
         }
 
         /// <summary>
@@ -12198,7 +12217,7 @@ namespace aipsvr.Services
         /// <param name="sessionId"></param>
         /// <param name="gatherData"></param>
         /// <returns></returns>
-        public async Task CreateGatherDataAsync(long sessionId, long categoryId, EntityBase organization, EntityBase collector, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime SettlementTime)
+        public async Task CreateGatherDataAsync(long sessionId, CategoryItem category, EntityBase organization, EntityBase gatherer, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime SettlementTime)
         {
             ActivateSession(sessionId);
             var session = SessionManager.GetSession(sessionId);
@@ -12208,16 +12227,11 @@ namespace aipsvr.Services
                 {
                     var databaseService = ServiceManager.GetService<IDatabaseService>();
                     var gatherDataManager = databaseService.GetManager<IGatherDataManager>();
-                    var category = await gatherDataManager.GetGatherCategoryByIdAsync(categoryId);
                     var gatherData = new GatherData
                     {
-                        GatherCategory = new EntityBase
-                        {
-                            Id = categoryId,
-                            Name = category.Name,
-                        },
+                        Category = category,
                         Organization = organization,
-                        Collector = collector,
+                        Gatherer = gatherer,
                         ModelType = modelType,
                         Source = source,
                         CollectionQuantity = collectionQuantity,
@@ -12238,7 +12252,7 @@ namespace aipsvr.Services
         /// <param name="sessionId"></param>
         /// <param name="gatherData"></param>
         /// <returns></returns>
-        public async Task UpdateGatherDataAsync(long sessionId, long id, long categoryId, EntityBase organization, EntityBase collector, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime SettlementTime)
+        public async Task UpdateGatherDataAsync(long sessionId, long id, CategoryItem category, EntityBase organization, EntityBase gatherer, string modelType, string source, int collectionQuantity, DateTime startTime, DateTime endTime, DateTime SettlementTime)
         {
             ActivateSession(sessionId);
             var session = SessionManager.GetSession(sessionId);
@@ -12249,18 +12263,13 @@ namespace aipsvr.Services
                     var databaseService = ServiceManager.GetService<IDatabaseService>();
                     var gatherDataManager = databaseService.GetManager<IGatherDataManager>();
                     var gatherData = await gatherDataManager.GetGatherDataByIdAsync(id);
-                    var category = await gatherDataManager.GetGatherCategoryByIdAsync(categoryId);
                     if (DateTime.Now > gatherData.SettlementTime)
                     {
                         throw new InvalidOperationException("SettlementTimeIsExpired");
                     }
-                    gatherData.GatherCategory = new EntityBase
-                    {
-                        Id = categoryId,
-                        Name = category.Name,
-                    };
+                    gatherData.Category = category;
                     gatherData.Organization = organization;
-                    gatherData.Collector = collector;
+                    gatherData.Gatherer = gatherer;
                     gatherData.ModelType = modelType;
                     gatherData.Source = source;
                     gatherData.CollectionQuantity = collectionQuantity;
@@ -12341,43 +12350,6 @@ namespace aipsvr.Services
             }
             throw new InvalidOperationException("InvalidAdminSession");
         }
-
-        /// <summary>
-        /// GetCollectorsByGatherCategoryIdAsync
-        /// </summary>
-        /// <param name="sessionId"></param>
-        /// <param name="organizationId"></param>
-        /// <param name="gatherCategoryId"></param>
-        /// <returns></returns>
-        public async Task<List<EntityBase>> GetCollectorsByGatherCategoryIdAsync(long sessionId, long organizationId, long gatherCategoryId)
-        {
-            ActivateSession(sessionId);
-            var session = SessionManager.GetSession(sessionId);
-            if (session != null)
-            {
-                if (session.Type == SessionType.Admin)
-                {
-                    var databaseService = ServiceManager.GetService<IDatabaseService>();
-                    var gatherDataManager = databaseService.GetManager<IGatherDataManager>();
-                    var category = await gatherDataManager.GetGatherCategoryByIdAsync(gatherCategoryId);
-                    List<EntityBase> collectors = new List<EntityBase>();
-                    if (category?.Collectors != null)
-                    {
-                        foreach (var collector in category.Collectors)
-                        {
-                            var entityBase = new EntityBase
-                            {
-                                Id = collector.Id,
-                                Name = collector.Name
-                            };
-                            collectors.Add(entityBase);
-                        }
-                    }
-                    return collectors;
-                }
-            }
-            throw new InvalidOperationException("InvalidAdminSession");
-        }
         #endregion GatherCategory
 
         #region 定价管理

+ 1 - 1
aipsvr/Services/DatabaseManagers/IGatherDataManager.cs

@@ -73,7 +73,7 @@ namespace aipsvr.Services.DatabaseManagers
         /// </summary>
         /// <param name="name"></param>
         /// <returns></returns>
-        Task<GatherCategory> GetGatherCategoryByNameAsync(string name);
+        Task<GatherCategory> GetGatherCategoryByNameAsync(string name, long organizationId);
 
         /// <summary>
         /// Get Gather Data by Id

+ 7 - 1
aipsvr/Services/DatabaseManagers/IImageCategoryDataManager.cs

@@ -44,6 +44,12 @@ namespace aipsvr.Services.DatabaseManagers
         /// <returns></returns>
         Task UpdateImageCategorySharersAsync(long id, List<EntityBase> sharers);
 
+        /// <summary>
+        /// Update the image category gatherers in system.
+        /// </summary>
+        /// <returns></returns>
+        Task UpdateImageCategoryGatherersAsync(long id, List<EntityBase> gatherers);
+
         /// <summary>
         /// Delete an image category from the system.
         /// </summary>
@@ -153,4 +159,4 @@ namespace aipsvr.Services.DatabaseManagers
         /// <returns>The loaded ImageCategories</returns>
         Task<List<ImageCategory>> GetImageCategoriesHasChildrenAsync(long labelPackageContentId);
     }
-}
+}

+ 18 - 18
aipsvr/Services/DatabaseManagers/MongoDb/MongoDbGatherDataManager.cs

@@ -31,7 +31,7 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
             var update = Builders<GatherCategory>.Update.Set(x => x.UpdateTime, DateTime.UtcNow)
                          .Set(x => x.Name, gatherCategory.Name)
                          .Set(x => x.Organization, gatherCategory.Organization)
-                         .Set(x => x.Collectors, gatherCategory.Collectors);
+                         .Set(x => x.Gatherers, gatherCategory.Gatherers);
             await MongoDbClient.Instance.GatherCategories.FindOneAndUpdateAsync(x => x.Id == gatherCategory.Id, update);
         }
 
@@ -42,7 +42,7 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
         /// <returns></returns>
         public async Task<GatherCategory> GetGatherCategoryByIdAsync(long id)
         {
-            var result = await MongoDbClient.Instance.GatherCategories.FindAsync(x => x.Id == id);
+            var result = await MongoDbClient.Instance.GatherCategories.FindAsync(x => x.IsDeleted == false && x.Id == id);
             return await result.FirstOrDefaultAsync();
         }
 
@@ -58,9 +58,9 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
         /// </summary>
         /// <param name="name"></param>
         /// <returns></returns>
-        public async Task<GatherCategory> GetGatherCategoryByNameAsync(string name)
+        public async Task<GatherCategory> GetGatherCategoryByNameAsync(string name, long organizationId)
         {
-            var result = await MongoDbClient.Instance.GatherCategories.FindAsync(x => x.Name == name);
+            var result = await MongoDbClient.Instance.GatherCategories.FindAsync(x => x.IsDeleted == false && x.Organization.Id == organizationId && x.Name == name);
             return await result.FirstOrDefaultAsync();
         }
         /// <summary>
@@ -77,9 +77,9 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
             {
                 filters &= Builders<GatherCategory>.Filter.Where(x => x.Name.ToLower().Contains(searchGatherCategoryModel.Name.ToLower()));
             }
-            if (!string.IsNullOrEmpty(searchGatherCategoryModel.CollectorName))
+            if (!string.IsNullOrEmpty(searchGatherCategoryModel.GathererName))
             {
-                filters &= Builders<GatherCategory>.Filter.Where(x => x.Collectors.Any(y => y.Name.ToLower().Contains(searchGatherCategoryModel.CollectorName.ToLower())));
+                filters &= Builders<GatherCategory>.Filter.Where(x => x.Gatherers.Any(y => y.Name.ToLower().Contains(searchGatherCategoryModel.GathererName.ToLower())));
             }
             return await MongoDbClient.Instance.GatherCategories.Find(filters)
                 .SortByDescending(x => x.UpdateTime)
@@ -100,9 +100,9 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
             {
                 filters &= Builders<GatherCategory>.Filter.Where(x => x.Name.ToLower().Contains(searchGatherCategoryModel.Name.ToLower()));
             }
-            if (!string.IsNullOrEmpty(searchGatherCategoryModel.CollectorName))
+            if (!string.IsNullOrEmpty(searchGatherCategoryModel.GathererName))
             {
-                filters &= Builders<GatherCategory>.Filter.Where(x => x.Collectors.Any(y => y.Name.ToLower().Contains(searchGatherCategoryModel.CollectorName.ToLower())));
+                filters &= Builders<GatherCategory>.Filter.Where(x => x.Gatherers.Any(y => y.Name.ToLower().Contains(searchGatherCategoryModel.GathererName.ToLower())));
             }
             return await MongoDbClient.Instance.GatherCategories.CountDocumentsAsync(filters);
         }
@@ -128,9 +128,9 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
         public async Task UpdateGatherDataAsync(GatherData gatherData)
         {
             var update = Builders<GatherData>.Update.Set(x => x.UpdateTime, DateTime.UtcNow)
-                         .Set(x => x.GatherCategory, gatherData.GatherCategory)
+                         .Set(x => x.Category, gatherData.Category)
                          .Set(x => x.Organization, gatherData.Organization)
-                         .Set(x => x.Collector, gatherData.Collector)
+                         .Set(x => x.Gatherer, gatherData.Gatherer)
                          .Set(x => x.ModelType, gatherData.ModelType)
                          .Set(x => x.Source, gatherData.Source)
                          .Set(x => x.CollectionQuantity, gatherData.CollectionQuantity)
@@ -147,7 +147,7 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
         /// <returns></returns>
         public async Task<GatherData> GetGatherDataByIdAsync(long id)
         {
-            var result = await MongoDbClient.Instance.GatherDatas.FindAsync(x => x.Id == id);
+            var result = await MongoDbClient.Instance.GatherDatas.FindAsync(x => x.IsDeleted == false && x.Id == id);
             return await result.FirstOrDefaultAsync();
         }
 
@@ -163,11 +163,11 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
             var filters = Builders<GatherData>.Filter.Where(x => x.IsDeleted == false && x.Organization.Id == searchGatherDataModel.OrganizationId);
             if (!string.IsNullOrEmpty(searchGatherDataModel.Name))
             {
-                filters &= Builders<GatherData>.Filter.Where(x => x.GatherCategory.Name.ToLower().Contains(searchGatherDataModel.Name.ToLower()));
+                filters &= Builders<GatherData>.Filter.Where(x => x.Category.Name.ToLower().Contains(searchGatherDataModel.Name.ToLower()));
             }
-            if (!string.IsNullOrEmpty(searchGatherDataModel.CollectorName))
+            if (!string.IsNullOrEmpty(searchGatherDataModel.GathererName))
             {
-                filters &= Builders<GatherData>.Filter.Where(x => x.Collector.Name.ToLower().Contains(searchGatherDataModel.CollectorName.ToLower()));
+                filters &= Builders<GatherData>.Filter.Where(x => x.Gatherer.Name.ToLower().Contains(searchGatherDataModel.GathererName.ToLower()));
             }
             if (!string.IsNullOrEmpty(searchGatherDataModel.ModelType))
             {
@@ -198,11 +198,11 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
             var filters = Builders<GatherData>.Filter.Where(x => x.IsDeleted == false && x.Organization.Id == searchGatherDataModel.OrganizationId);
             if (!string.IsNullOrEmpty(searchGatherDataModel.Name))
             {
-                filters &= Builders<GatherData>.Filter.Where(x => x.GatherCategory.Name.ToLower().Contains(searchGatherDataModel.Name.ToLower()));
+                filters &= Builders<GatherData>.Filter.Where(x => x.Category.Name.ToLower().Contains(searchGatherDataModel.Name.ToLower()));
             }
-            if (!string.IsNullOrEmpty(searchGatherDataModel.CollectorName))
+            if (!string.IsNullOrEmpty(searchGatherDataModel.GathererName))
             {
-                filters &= Builders<GatherData>.Filter.Where(x => x.Collector.Name.ToLower().Contains(searchGatherDataModel.CollectorName.ToLower()));
+                filters &= Builders<GatherData>.Filter.Where(x => x.Gatherer.Name.ToLower().Contains(searchGatherDataModel.GathererName.ToLower()));
             }
             if (!string.IsNullOrEmpty(searchGatherDataModel.ModelType))
             {
@@ -226,7 +226,7 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
         /// <returns></returns>
         public async Task<List<GatherData>> GetGatherDatasByCategoryIdAsync(long categoryId)
         {
-            var filters = Builders<GatherData>.Filter.Where(x => x.IsDeleted == false && x.GatherCategory.Id == categoryId);
+            var filters = Builders<GatherData>.Filter.Where(x => x.IsDeleted == false && x.Category.Id == categoryId);
             return await MongoDbClient.Instance.GatherDatas.Find(filters).SortByDescending(x => x.UpdateTime).ToListAsync();
         }
 

+ 10 - 1
aipsvr/Services/DatabaseManagers/MongoDb/MongoDbImageCategoryDataManager.cs

@@ -2,7 +2,6 @@
 using MongoDB.Driver;
 using System;
 using System.Collections.Generic;
-using System.Linq;
 using System.Threading.Tasks;
 
 namespace aipsvr.Services.DatabaseManagers.MongoDb
@@ -99,6 +98,16 @@ namespace aipsvr.Services.DatabaseManagers.MongoDb
             await MongoDbClient.Instance.ImageCategories.FindOneAndUpdateAsync(x => x.Id == id, update);
         }
 
+        /// <summary>
+        /// Update the image category gatherers in system.
+        /// </summary>
+        /// <returns></returns>
+        public async Task UpdateImageCategoryGatherersAsync(long id, List<EntityBase> gatherers)
+        {
+            var update = Builders<ImageCategory>.Update.Set(x => x.UpdateTime, DateTime.UtcNow).Set(x => x.Gatherers, gatherers);
+            await MongoDbClient.Instance.ImageCategories.FindOneAndUpdateAsync(x => x.Id == id, update);
+        }
+
         /// <summary>
         /// Get the image categories count by keyword.
         /// </summary>