Bläddra i källkod

添加结算管理部分数据结构

xuan.wang 8 månader sedan
förälder
incheckning
c74ee6ec9a

+ 54 - 0
AIPlatform.Protocol/Entities/DistributionRecord.cs

@@ -0,0 +1,54 @@
+using System.Collections.Generic;
+
+namespace AIPlatform.Protocol.Entities
+{
+    /// <summary>
+    /// 每月发放记录
+    /// </summary>
+    public class DistributionRecord : Entity
+    {
+        /// <summary>
+        /// 所属组织Ids
+        /// </summary>
+        public List<long> OrganizationIds { get; set; }
+        /// <summary>
+        /// 年
+        /// </summary>
+        public int Year { get; set; }
+        /// <summary>
+        /// 月
+        /// </summary>
+        public int Month { get; set; }
+        /// <summary>
+        /// 对象
+        /// </summary>
+        public EntityBase Target { get; set; }
+        /// <summary>
+        /// 对象类型
+        /// </summary>
+        public DistributionTargetType TargetType { get; set; }
+        /// <summary>
+        /// 是否发放
+        /// </summary>
+        public bool IsDistributed { get; set; }
+        /// <summary>
+        /// 备注
+        /// </summary>
+        public string Note { get; set; }
+    }
+
+    /// <summary>
+    /// 发放对象类型
+    /// </summary>
+    public enum DistributionTargetType
+    {
+        /// <summary>
+        /// 机构
+        /// </summary>
+        Institutional,
+        /// <summary>
+        /// 个体
+        /// </summary>
+        Individual,
+    }
+}

+ 0 - 1
AIPlatform.Protocol/Entities/IndividualCoefficient.cs

@@ -1,6 +1,5 @@
 using System;
 using System.Collections.Generic;
-using System.ComponentModel.DataAnnotations;
 
 namespace AIPlatform.Protocol.Entities
 {

+ 9 - 0
AIPlatform.Protocol/Entities/PricingType.cs

@@ -5,8 +5,17 @@
     /// </summary>
     public enum PricingType
     {
+        /// <summary>
+        /// 个体定价
+        /// </summary>
         IndividualPrice,
+        /// <summary>
+        /// 个体系数
+        /// </summary>
         IndividualCoefficient,
+        /// <summary>
+        /// 机构定价
+        /// </summary>
         InstitutionalPrice,
     }
 }

+ 10 - 0
AIPlatform.Protocol/Entities/SettlementActualStatistic.cs

@@ -0,0 +1,10 @@
+namespace AIPlatform.Protocol.Entities
+{
+    /// <summary>
+    /// 结算-实际(导出)统计
+    /// </summary>
+    public class SettlementActualStatistic : SettlementBasicStatistic
+    {
+
+    }
+}

+ 27 - 0
AIPlatform.Protocol/Entities/SettlementBasicStatistic.cs

@@ -0,0 +1,27 @@
+using System.Collections.Generic;
+
+namespace AIPlatform.Protocol.Entities
+{
+    /// <summary>
+    /// 结算-基础统计
+    /// </summary>
+    public class SettlementBasicStatistic : Entity
+    {
+        /// <summary>
+        /// 所属组织Ids
+        /// </summary>
+        public List<long> OrganizationIds { get; set; }
+        /// <summary>
+        /// 年
+        /// </summary>
+        public int Year { get; set; }
+        /// <summary>
+        /// 月
+        /// </summary>
+        public int Month { get; set; }
+        /// <summary>
+        /// 人员
+        /// </summary>
+        public EntityBase Account { get; set; }
+    }
+}

+ 21 - 0
AIPlatform.Protocol/Entities/SettlementType.cs

@@ -0,0 +1,21 @@
+using System.ComponentModel.DataAnnotations;
+
+namespace AIPlatform.Protocol.Entities
+{
+    /// <summary>
+    /// 结算类型
+    /// </summary>
+    public enum SettlementType
+    {
+        /// <summary>
+        /// 基础
+        /// </summary>
+        [Display(Name = "基础")]
+        Basic,
+        /// <summary>
+        /// 实际
+        /// </summary>
+        [Display(Name = "实际")]
+        Actual,
+    }
+}

+ 32 - 0
aipmgr/Models/DistributionRecordModel.cs

@@ -0,0 +1,32 @@
+using AIPlatform.Protocol.Entities;
+using System.ComponentModel.DataAnnotations;
+
+namespace aipmgr.Models
+{
+    public class DistributionRecordModel
+    {
+        [Key]
+        [Display(Name = "主键")]
+        public long Id { get; set; }
+
+        [Display(Name = "所属组织")]
+        public List<long> OrganizationIds { get; set; }
+
+        [Display(Name = "所属组织")]
+        public long SelectedOrganizationId { get; set; }
+
+        [Display(Name = "年")]
+        public int Year { get; set; }
+
+        [Display(Name = "月")]
+        public int Month { get; set; }
+
+        [Display(Name = "类型")]
+        public DataProcessingType Type { get; set; }
+
+        public DistributionRecordModel()
+        {
+            OrganizationIds = new List<long>();
+        }
+    }
+}

+ 32 - 0
aipmgr/Models/SettlementModel.cs

@@ -0,0 +1,32 @@
+using AIPlatform.Protocol.Entities;
+using System.ComponentModel.DataAnnotations;
+
+namespace aipmgr.Models
+{
+    public class SettlementModel
+    {
+        [Key]
+        [Display(Name = "主键")]
+        public long Id { get; set; }
+
+        [Display(Name = "所属组织")]
+        public List<long> OrganizationIds { get; set; }
+
+        [Display(Name = "所属组织")]
+        public long SelectedOrganizationId { get; set; }
+
+        [Display(Name = "年")]
+        public int Year { get; set; }
+
+        [Display(Name = "月")]
+        public int Month { get; set; }
+
+        [Display(Name = "类型")]
+        public DataProcessingType Type { get; set; }
+
+        public SettlementModel()
+        {
+            OrganizationIds = new List<long>();
+        }
+    }
+}

+ 1 - 1
aipmgr/Pages/IndividualCoefficients.razor

@@ -23,7 +23,7 @@
     </RowButtonTemplate>
 </Table>
 
-<Modal @ref="Modal" OnCloseAsync="@OnCloseCaseAsync">
+<Modal @ref="Modal" OnCloseAsync="@OnCloseAsync">
     <ModalDialog Size="Size.Medium" Title="新建个体系数" IsCentered="true" ShowFooter="false">
         <BodyTemplate>
             <ValidateForm Model="@ValidateModel" OnValidSubmit="@OnSubmitAsync">

+ 1 - 1
aipmgr/Pages/IndividualCoefficients.razor.cs

@@ -315,7 +315,7 @@ namespace aipmgr.Pages
             }
         }
 
-        private Task OnCloseCaseAsync()
+        private Task OnCloseAsync()
         {
             CategoryItems.Clear();
             AccountItems.Clear();

+ 1 - 1
aipmgr/Pages/InstitutionalPrices.razor

@@ -25,7 +25,7 @@
     </RowButtonTemplate>
 </Table>
 
-<Modal @ref="Modal" OnCloseAsync="@OnCloseCaseAsync">
+<Modal @ref="Modal" OnCloseAsync="@OnCloseAsync">
     <ModalDialog Size="Size.Medium" Title="新建机构定价" IsCentered="true" ShowFooter="false">
         <BodyTemplate>
             <ValidateForm Model="@ValidateModel" OnValidSubmit="@OnSubmitAsync">

+ 1 - 1
aipmgr/Pages/InstitutionalPrices.razor.cs

@@ -314,7 +314,7 @@ namespace aipmgr.Pages
             }
         }
 
-        private Task OnCloseCaseAsync()
+        private Task OnCloseAsync()
         {
             CategoryItems.Clear();
 

+ 35 - 1
aipmgr/Pages/Settlement.razor

@@ -2,6 +2,40 @@
 @using AIPlatform.Protocol.Model
 @using aipmgr.Models
 
+<div class="row g-3 form-inline">
+    <div class="col-12 col-sm-3">
+        <Select @bind-Value="@SearchModel.SelectedOrganizationId" Items="@SearchOrganizationItems" ShowLabel="true" />
+    </div>
+    <div class="col-12 col-sm-3">
+        <DateTimePicker @bind-Value="SearchMonthValue" ShowLabel="true" DisplayText="时间" ViewMode="DatePickerViewMode.Month" DateFormat="yyyy-MM" />
+    </div>
+    <div class="col-12 col-sm-3">
+        <RadioList TValue="string" Items="@SearchSettlementTypeValues" OnSelectedChanged="@OnSelectedSettlementTypeChanged" />
+    </div>
+    <div class="col-12 col-sm-3">
+        <Button Color="BootstrapBlazor.Components.Color.Primary" OnClick="@OnEditDistributionAsync">编辑发放</Button>
+        <Button Color="BootstrapBlazor.Components.Color.Success">结算导出</Button>
+    </div>
+</div>
+
+<Modal @ref="DistributionModal">
+    <ModalDialog Size="Size.Large" Title="编辑发放" IsCentered="true" ShowFooter="false">
+        <BodyTemplate>
+            <ValidateForm Model="@ValidateDistributionModel" OnValidSubmit="@OnSubmitAsync">
+                <div class="row g-3 form-inline">
+                    <div class="col-12 col-sm-12">
+                        <DateTimePicker @bind-Value="SearchMonthValue" ShowLabel="true" DisplayText="时间" ViewMode="DatePickerViewMode.Month" DateFormat="yyyy-MM" />
+                    </div>
+                    
+                </div>
+                <div class="form-footer">
+                    <Button ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="保存" />
+                </div>
+            </ValidateForm>
+        </BodyTemplate>
+    </ModalDialog>
+</Modal>
+
 <Tab>
-    <div>我是结算管理</div>
+
 </Tab>

+ 94 - 54
aipmgr/Pages/Settlement.razor.cs

@@ -5,6 +5,7 @@ using aipmgr.Models;
 using aipmgr.Shared;
 using aipmgr.Utilities;
 using BootstrapBlazor.Components;
+using Microsoft.AspNetCore.Components.Forms;
 using System.Diagnostics.CodeAnalysis;
 
 namespace aipmgr.Pages
@@ -12,64 +13,65 @@ namespace aipmgr.Pages
     public sealed partial class Settlement
     {
         [NotNull]
-        private Table<AccountModel>? LabelerTable { get; set; }
+        private Table<SettlementModel>? SettlementTable { get; set; }
         private static List<int> PageItemsSource = new List<int> { 10, 20 };
         [NotNull]
+        public DistributionRecordModel? ValidateDistributionModel { get; set; }
+        [NotNull]
+        private Modal? DistributionModal { get; set; }
+        [NotNull]
         private MessageBase? _messageBaseRef { get; set; }
 
         #region Search
 
-        private AccountModel SearchModel { get; set; } = new AccountModel();
+        private SettlementModel SearchModel { get; set; } = new SettlementModel();
+        private DateTime SearchMonthValue { get; set; } = DateTime.Today;
         [NotNull]
-        private List<SelectedItem>? _organizationItems { get; set; }
+        private List<SelectedItem>? SearchOrganizationItems { get; set; }
         [NotNull]
-        private List<SelectedItem>? _institutionItems { get; set; }
+        private List<SelectedItem>? SearchSettlementTypeValues { get; set; }
 
         #endregion
 
         protected override async Task OnInitializedAsync()
         {
             await base.OnInitializedAsync();
-            _organizationItems = new List<SelectedItem>();
-            _institutionItems = new List<SelectedItem>();
+            SettlementTable = new();
+            SearchOrganizationItems = new List<SelectedItem>();
+            SearchSettlementTypeValues = new List<SelectedItem>();
+            foreach (SettlementType item in Enum.GetValues(typeof(SettlementType)))
+            {
+                SearchSettlementTypeValues.Add(new SelectedItem
+                {
+                    Value = item.ToString(),
+                    Text = item.ToDisplayName(),
+                });
+            }
+            var organizations = await AdminManager.Shared.GetOrganizationsAsync();
+            SearchOrganizationItems = organizations.Select(x => new SelectedItem
+            {
+                Value = x.Id.ToString(),
+                Text = x.Name
+            }).ToList();
+            if (organizations != null)
+            {
+                SearchModel.SelectedOrganizationId = organizations.FirstOrDefault().Id;
+            }
         }
 
         private async Task<QueryData<AccountModel>> OnQueryAsync(QueryPageOptions options)
         {
             try
             {
-                if (SearchModel.OrganizationId <= 0)
-                {
-                    var organizations = await AdminManager.Shared.GetOrganizationsAsync();
-                    _organizationItems = organizations.Select(x => new SelectedItem
-                    {
-                        Value = x.Id.ToString(),
-                        Text = x.Name
-                    }).ToList();
-                    if (_organizationItems != null)
-                    {
-                        await OnOrganizationItemChanged(_organizationItems.FirstOrDefault());
-                    }
-                    if (organizations != null)
-                    {
-                        SearchModel.OrganizationId = organizations.FirstOrDefault().Id;
-                    }
-                }
                 var keyword = options.SearchText;
                 var pageIndex = options.PageIndex - 1;
                 var pageSize = options.PageItems;
-                var labelers = await AdminManager.Shared.GetAccountsAsync(pageIndex, pageSize, keyword, SearchModel.OrganizationId, 0, Role.Labeler);
-                var labelerCount = await AdminManager.Shared.GetAccountCountAsync(keyword, SearchModel.OrganizationId, 0, Role.Labeler);
+                var labelers = await AdminManager.Shared.GetAccountsAsync(pageIndex, pageSize, keyword, SearchModel.SelectedOrganizationId, 0, Role.Labeler);
+                var labelerCount = await AdminManager.Shared.GetAccountCountAsync(keyword, SearchModel.SelectedOrganizationId, 0, Role.Labeler);
                 var items = new List<AccountModel>();
                 foreach (var item in labelers)
                 {
                     var vo = MapHelper.Map<AccountModel, Account>(item);
-                    //vo.OrganizationValues = vo.Organizations.Select(x => x.Id.ToString()).ToList();
-                    var findInstitution = _institutionItems.FirstOrDefault(x => x.Value == vo.InstitutionId.ToString());
-                    if (findInstitution != null)
-                    {
-                        vo.InstitutionName = findInstitution.Text;
-                    }
                     items.Add(vo);
                 }
                 return await Task.FromResult(new QueryData<AccountModel>()
@@ -80,49 +82,87 @@ namespace aipmgr.Pages
             }
             catch (Exception ex)
             {
-                await _messageBaseRef.ShowMessageBaseAsync($"查询用例失败,错误:{ex}");
+                await _messageBaseRef.ShowMessageBaseAsync($"查询失败,错误:{ex}");
                 return await Task.FromResult(new QueryData<AccountModel>());
             }
         }
 
-
-        private Task OnResetSearchAsync(AccountModel item)
+        private async Task OnSelectedSettlementTypeChanged(IEnumerable<SelectedItem> values, string val)
         {
-            item.Name = "";
-            item.InstitutionId = -1;
+            try
+            {
+                var value = values.FirstOrDefault();
 
-            return Task.CompletedTask;
+                StateHasChanged();
+            }
+            catch (Exception ex)
+            {
+                await _messageBaseRef.ShowMessageBaseAsync($"切换失败,错误:{ex.Translate()}");
+            }
         }
 
-        private async Task OnEnterSelectAllAsync(string val)
+        #region 编辑发放
+
+        public async Task OnEditDistributionAsync()
         {
-            SearchModel.Name = val;
-            await LabelerTable.QueryAsync();
+            try
+            {
+                await LoadingManager.OpenAsync();
+                ValidateDistributionModel = new DistributionRecordModel();
+               
+            }
+            catch (Exception ex)
+            {
+                await _messageBaseRef.ShowMessageBaseAsync($"新建失败,错误:{ex.Translate()}");
+            }
+            finally
+            {
+                await LoadingManager.CloseAsync();
+                StateHasChanged();
+            }
+            await DistributionModal.Show();
         }
 
-        private async Task OnOrganizationItemChanged(SelectedItem item)
+        private async Task OnSubmitAsync(EditContext context)
         {
             try
             {
-                if (item != null)
+                #region 验证
+
+                var model = context.Model as DistributionRecordModel;
+                if (model == null)
                 {
-                    //var institutions = new List<Institution>(); //await AdminManager.Shared.GetImageCategoriesByParentIdAsync(long.Parse(item.Value));
-                    //if (institutions != null && institutions.Count > 0)
-                    //{
-                    //    _institutionItems = institutions.Select(x => new SelectedItem
-                    //    {
-                    //        Value = x.Id.ToString(),
-                    //        Text = x.Name
-                    //    }).ToList();
-                    //    _institutionItems.Insert(0, new SelectedItem("", "请选择..."));
-                    //}
+                    await _messageBaseRef.ShowMessageBaseAsync("保存失败。");
+                    return;
                 }
-                StateHasChanged();
+
+                #endregion 验证
+
+                await LoadingManager.OpenAsync();
+                //foreach (var value in model.CategoryValues)
+                //{
+                  
+
+                //    var price = new DistributionRecord
+                //    {
+                //        OrganizationIds = model.OrganizationIds,
+                       
+                //    };
+                //    await AdminManager.Shared.CreateInstitutionalPriceAsync(price);
+                //}
+                await DistributionModal.Close();
+                await SettlementTable.QueryAsync();
             }
             catch (Exception ex)
             {
-                await _messageBaseRef.ShowMessageBaseAsync($"选择机构失败,错误:{ex.Translate()}");
+                await _messageBaseRef.ShowMessageBaseAsync($"新建失败,错误:{ex.Translate()}");
+            }
+            finally
+            {
+                await LoadingManager.CloseAsync();
             }
         }
+
+        #endregion
     }
 }