Explorar el Código

添加绩效统计模块
修正绩效计算模块totalActinal值为null问题
添加绩效国家(地区)栏位

luocaiyang hace 3 años
padre
commit
1adc13c318

+ 13 - 1
wispro.sp.api/Controllers/PerformanceItemController.cs

@@ -1583,6 +1583,7 @@ namespace wispro.sp.api.Controllers
                         if (temReviewerStatic != null)
                         {
                             temReviewerStatic.totalBasePoint += reviewerBasePoint;
+                            temReviewerStatic.totalActuallyPoint += reviewerBasePoint;
                         }
                         else
                         {
@@ -1594,6 +1595,7 @@ namespace wispro.sp.api.Controllers
                                     CalMonthId = calMonth.Id,
                                     StaffId = item.ReviewerId.Value,
                                     totalBasePoint = reviewerBasePoint,
+                                    totalActuallyPoint = reviewerBasePoint,
                                     jxType = temJxType
                                 };
 
@@ -1761,7 +1763,7 @@ namespace wispro.sp.api.Controllers
 
                 if (calMonth.A.HasValue)
                 {
-                    totalActualPoint = totalActualPoint + (calMonth.S.Value * 0.5);
+                    totalActualPoint = totalActualPoint + (calMonth.A.Value * 0.5);
                 }
                 #endregion
 
@@ -1771,6 +1773,7 @@ namespace wispro.sp.api.Controllers
                 IDictionary<int, NanduStatics> staffXiShu = new Dictionary<int, NanduStatics>();
                 foreach (StaffStatistics ss in retList)
                 {
+
                     if (ss.jxType.Contains("新申请") || ss.jxType.Contains("专案"))
                     {
                         if (!staffXiShu.ContainsKey(ss.StaffId))
@@ -1790,8 +1793,17 @@ namespace wispro.sp.api.Controllers
                     }
                     else
                     {
+                        if(ss.totalActuallyPoint == null)
+                        {
+                            ss.totalActuallyPoint = ss.totalBasePoint;
+                        }
                         ss.FinianlPoint = ss.totalActuallyPoint;
                     }
+
+                    if(ss.totalActuallyPoint == null || ss.FinianlPoint == null)
+                    {
+                        System.Diagnostics.Debug.WriteLine("");
+                    }
                 }
 
                 foreach(StaffStatistics ss in retList)

+ 130 - 0
wispro.sp.api/Controllers/ReportController.cs

@@ -23,6 +23,18 @@ namespace wispro.sp.api.Controllers
 
 
         }
+
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="type">
+        /// 0:申诉人;1:申诉类型;2:部门申诉统计;
+        /// 3:申诉人每月申诉统计;4:申诉类型每月申诉统计
+        /// </param>
+        /// <param name="start">开始时间</param>
+        /// <param name="end">结束时间</param>
+        /// <param name="userId"></param>
+        /// <returns></returns>
         public ChartDatas AppealReport(int type,DateTime? start,DateTime? end,int? userId)
         {
             ChartDatas retDatas = new ChartDatas();
@@ -130,5 +142,123 @@ namespace wispro.sp.api.Controllers
             }
             
         }
+
+        /// <summary>
+        /// 绩效统计报表
+        /// </summary>
+        /// <param name="type">
+        /// 0:按人统计
+        /// 1:按部门统计
+        /// 2:按人员专案统计
+        /// </param>
+        /// /// <param name="isYear">
+        /// 是否按年统计,默认为false按月统计
+        /// </param>
+        /// <returns></returns>
+        public ChartDatas StaticsReport(int type,bool isYear=false)
+        {
+            ChartDatas retDatas = new ChartDatas();
+            switch (type)
+            {
+                case 0:
+                    
+                    if (isYear)
+                    {
+                        var retYearData = Context.StaffStatistics.GroupBy(s => new { s.Staff.Name, s.CalMonth.Year })
+                        .Select(g => new { Name = g.Key.Name, Year = g.Key.Year ,  sum = g.Sum(s => s.FinianlPoint) })
+                        .OrderByDescending(g => g.sum);
+
+                        retDatas.ATitle = "代理人";
+                        retDatas.BTitle = "绩效年份";
+                        retDatas.Title = "代理人每年绩效统计";
+                        retDatas.Datas = new List<ChartData>();
+
+                        foreach (var key in retYearData)
+                        {
+                            retDatas.Datas.Add(new ChartData() { type = key.Name, year = $"{key.Year}", value = key.sum.HasValue ? key.sum.Value : 0 });
+                        }
+                        return retDatas;
+                    }
+                    else
+                    {
+                        var retData = Context.StaffStatistics.GroupBy(s => new { s.Staff.Name, s.CalMonth.Year,s.CalMonth.Month  })
+                        .Select(g => new { Name = g.Key.Name,  Year=g.Key.Year,Month=g.Key.Month , sum = g.Sum(s => s.FinianlPoint) })
+                        .OrderByDescending(g => g.sum);
+
+                        retDatas.ATitle = "代理人";
+                        retDatas.BTitle = "绩效月份";
+                        retDatas.Title = "代理人每月绩效统计";
+                        retDatas.Datas = new List<ChartData>();
+
+                        foreach (var key in retData)
+                        {
+                            retDatas.Datas.Add(new ChartData() { type = key.Name, year = $" {DateTime.Parse($"{key.Year}-{key.Month}-1").ToString("yyyy-MM")}", value = key.sum.HasValue ? key.sum.Value : 0 });
+                        }
+                        return retDatas;
+
+                    }
+
+                    
+
+                    break;
+                case 1:
+                    if (isYear)
+                    {
+                        var retData2 = Context.StaffStatistics.GroupBy(s => new { s.Staff.Department, s.CalMonth.Year })
+                            .Select(g => new { Name = g.Key.Department, Year = g.Key.Year, sum = g.Sum(s => s.FinianlPoint) })
+                            .OrderByDescending(g => g.sum);
+
+                        retDatas.ATitle = "部门";
+                        retDatas.BTitle = "绩效月份";
+                        retDatas.Title = "部门每月绩效统计";
+                        retDatas.Datas = new List<ChartData>();
+
+                        foreach (var key in retData2)
+                        {
+                            retDatas.Datas.Add(new ChartData() { type = key.Name, year = $"{key.Year }", value = key.sum.HasValue ? key.sum.Value : 0 });
+                        }
+                        return retDatas;
+                    }
+                    else
+                    {
+                        var retData1 = Context.StaffStatistics.GroupBy(s => new { s.Staff.Department, s.CalMonth.Year,s.CalMonth.Month  })
+                            .Select(g => new { Name = g.Key.Department, Year = g.Key.Year, Month = g.Key.Month, sum = g.Sum(s => s.FinianlPoint) })
+                            .OrderByDescending(g => g.sum);
+
+                        retDatas.ATitle = "部门";
+                        retDatas.BTitle = "绩效月份";
+                        retDatas.Title = "部门每月绩效统计";
+                        retDatas.Datas = new List<ChartData>();
+
+                        foreach (var key in retData1)
+                        {
+                            retDatas.Datas.Add(new ChartData() { type = key.Name, year = $" {DateTime.Parse($"{key.Year}-{key.Month}-1").ToString("yyyy-MM")}", value = key.sum.HasValue ? key.sum.Value : 0 });
+                        }
+                        return retDatas;
+                    }
+                    break;
+                case 2:
+                    var retData3 = Context.StaffStatistics.Where(s=>s.jxType.Contains("专案")).GroupBy(s => new { s.Staff.Name, s.CalMonth.Year, s.CalMonth.Month })
+                        .Select(g => new { Name = g.Key.Name, Year = g.Key.Year, Month = g.Key.Month, sum = g.Sum(s => s.FinianlPoint) })
+                        .OrderByDescending(g => g.sum);
+
+                    retDatas.ATitle = "人员";
+                    retDatas.BTitle = "绩效月份";
+                    retDatas.Title = "人员每月专案绩效统计";
+                    retDatas.Datas = new List<ChartData>();
+
+                    foreach (var key in retData3)
+                    {
+                        retDatas.Datas.Add(new ChartData() { type = key.Name, year = $" {DateTime.Parse($"{key.Year}-{key.Month}-1").ToString("yyyy-MM")}", value = key.sum.HasValue ? key.sum.Value : 0 });
+                    }
+                    return retDatas;
+                    break;
+                case 3:
+                    break;
+
+            }
+
+            return retDatas;
+        }
     }
 }

+ 20 - 0
wispro.sp.api/Job/ImportReportJob.cs

@@ -458,6 +458,11 @@ namespace wispro.sp.api.Job
                 item.WorkflowUserId = GetStaff(row["业务人员"].ToString().Trim());
             }
 
+            if (row.Table.Columns.Contains("国家(地区)"))
+            {
+                item.Country = row["国家(地区)"].ToString().Trim();
+            }
+
             return item;
         }
         private PerformanceItem Row2Item_2(DataRow row, CalMonth calMonth)
@@ -473,6 +478,11 @@ namespace wispro.sp.api.Job
             item.CaseState = row["案件状态"].ToString().Trim();
             item.DoItem = row["处理事项"].ToString().Trim();
 
+            if (row.Table.Columns.Contains("国家(地区)"))
+            {
+                item.Country = row["国家(地区)"].ToString().Trim();
+            }
+
             DateTime temDate = new DateTime();
             if (DateTime.TryParse(row["内部期限"].ToString().Trim(), out temDate))
             {
@@ -697,6 +707,11 @@ namespace wispro.sp.api.Job
             item.ApplicationName = row["申请人"].ToString().Trim();
             item.CaseName = row["案件名称"].ToString().Trim();
 
+            if (row.Table.Columns.Contains("国家(地区)"))
+            {
+                item.Country = row["国家(地区)"].ToString().Trim();
+            }
+
             //案件备注
             item.CaseMemo = $"发文日期:{row["发文日期"].ToString().Trim()}\r\n客户文号:{row["客户文号"].ToString().Trim()}\r\n上传日期:{row["上传日期"].ToString().Trim()}\r\n文件描述:{row["文件描述"].ToString().Trim()}";
             
@@ -756,6 +771,11 @@ namespace wispro.sp.api.Job
             item.ApplicationType = row["申请类型"].ToString().Trim();
             item.BusinessType = row["业务类型"].ToString().Trim();
 
+            if (row.Table.Columns.Contains("国家(地区)"))
+            {
+                item.Country = row["国家(地区)"].ToString().Trim();
+            }
+
             if (row.Table.Columns.Contains("备注(填表注意事项)"))
                 item.AgentFeedbackMemo = row["备注(填表注意事项)"].ToString().Trim();
 

+ 5 - 1
wispro.sp.api/Job/InvalidDataMessageJob.cs

@@ -53,7 +53,11 @@ namespace wispro.sp.api.Job
                     row["基础点数"] = p.BasePoint;
                     row["绩效类型"] = p.Type;
                     row["备注"] = p.CaseMemo;
-                    row["业务人员"] = p.WorkflowUser?.Name;
+
+                    if (p.WorkflowUser != null)
+                    {
+                        row["业务人员"] = p.WorkflowUser.Name;
+                    }
 
                     dt.Rows.Add(row);
                 }

+ 60 - 0
wispro.sp.share/ChartData.cs

@@ -1,5 +1,6 @@
 using System;
 using System.Collections.Generic;
+using System.Data;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -29,6 +30,65 @@ namespace wispro.sp.share
 
         public string BTitle { get; set; }
 
+        protected static List<string> GetColumns(List<ChartData> chartDatas)
+        {
+            List<string> retColumns = new List<string>();
+
+            foreach (var cData in chartDatas)
+            {
+                if (!retColumns.Contains(cData.year))
+                {
+                    retColumns.Add(cData.year);
+                }
+            }
+
+            retColumns.Sort();
+
+            return retColumns;
+        }
+
+        public DataTable GetTableData()
+        {
+            DataTable retTable = new DataTable();
+            List<string> Columns = GetColumns(Datas);
+            retTable.Columns.Add(ATitle);
+
+            foreach (string col in Columns)
+            {
+                retTable.Columns.Add(col);
+            }
+
+            foreach (var cData in Datas)
+            {
+                int iIndex = Columns.IndexOf(cData.year);
+
+                DataRow row = null;
+                foreach (DataRow temRow in retTable.Rows)
+                {
+                    if (temRow[ATitle].ToString() == cData.type)
+                    {
+                        row = temRow;
+                        break;
+                    }
+                }
+
+                if (row != null)
+                {
+                    row[cData.year] = cData.value;
+                }
+                else
+                {
+                    row = retTable.NewRow();
+                    row[ATitle] = cData.type;
+                    row[cData.year] = cData.value;
+                    retTable.Rows.Add(row);
+
+                }
+            }
+
+            return retTable;
+        }
+
 
     }
 }

+ 9 - 0
wispro.sp.web/Layouts/BasicLayout.razor

@@ -82,6 +82,7 @@
                     Path="/AppealRecords",
                     Icon ="message",
                 }
+
             }
         },
         new MenuDataItem
@@ -134,8 +135,16 @@
                     Name ="申诉趋势统计",
                     Key= "appealTrend",
                     Icon = "line-chart"
+                },
+                new MenuDataItem
+                {
+                    Path ="/Report/StaticsTrend",
+                    Name ="绩效统计",
+                    Key= "StaticsTrend",
+                    Icon = "line-chart"
                 }
                 
+
             }
         },
         new MenuDataItem

+ 1 - 1
wispro.sp.web/Pages/Report/AppealTrend.razor

@@ -43,7 +43,7 @@
             <center>
 
             @{
-                System.Data.DataTable tableData = GetTableData(Datas);
+                System.Data.DataTable tableData = Datas.GetTableData();
 
                 <table width="80%" border="1">
                     <thead>

+ 1 - 58
wispro.sp.web/Pages/Report/AppealTrend.razor.cs

@@ -163,63 +163,6 @@ namespace wispro.sp.web.Pages.Report
             await base.OnInitializedAsync();
         }
 
-        private List<string> GetColumns(List<ChartData> chartDatas)
-        {
-            List<string> retColumns = new List<string>();
-
-            foreach(var cData in chartDatas)
-            {
-                if (!retColumns.Contains(cData.year))
-                {
-                    retColumns.Add(cData.year);
-                }
-            }
-
-            retColumns.Sort();
-
-            return retColumns;
-        }
-
-        private DataTable GetTableData(ChartDatas chartDatas)
-        {
-            DataTable retTable = new DataTable();
-            List<string> Columns = GetColumns(chartDatas.Datas);
-            retTable.Columns.Add(chartDatas.ATitle);
-
-            foreach(string col in Columns)
-            {
-                retTable.Columns.Add(col);
-            }
-
-            foreach(var cData in chartDatas.Datas)
-            {
-                int iIndex = Columns.IndexOf(cData.year);
-
-                DataRow row = null;
-                foreach(DataRow temRow in retTable.Rows)
-                {
-                    if(temRow[chartDatas.ATitle].ToString()== cData.type)
-                    {
-                        row = temRow;
-                        break;
-                    }
-                }
-
-                if (row!= null)
-                {
-                    row[cData.year] = cData.value;
-                }
-                else
-                {
-                    row = retTable.NewRow();
-                    row[chartDatas.ATitle] = cData.type;
-                    row[cData.year] = cData.value;
-                    retTable.Rows.Add(row);
-                    
-                }
-            }
-
-            return retTable;
-        }
+        
     }
 }

+ 83 - 0
wispro.sp.web/Pages/Report/StaffStaticsReport.razor

@@ -0,0 +1,83 @@
+@page  "/Report/StaticsTrend"
+
+<PageContainer>
+    <Breadcrumb>
+        <Breadcrumb>
+            <BreadcrumbItem>
+                <a href="/Home"><Icon Type="home"></Icon></a>
+            </BreadcrumbItem>
+            <BreadcrumbItem>
+                <span>申诉单项统计</span>
+            </BreadcrumbItem>
+        </Breadcrumb>
+    </Breadcrumb>
+    <Content>
+        <Space>
+            <SpaceItem>统计类型:</SpaceItem>
+            <SpaceItem>
+                <Select DataSource="@Types"
+                        @bind-Value="@iType"
+                        LabelName="@nameof(TJType.Name)"
+                        ValueName="@nameof(TJType.value)"
+                        Placeholder="请选择统计类型">
+                </Select>
+            </SpaceItem>
+            <SpaceItem><Button Icon="search" Loading="_noIconLoading" OnClick="OnButtonClick">开始统计</Button></SpaceItem>
+        </Space>
+    </Content>
+    <ChildContent>
+        <div>
+            @if (Datas == null)
+            {
+
+            }
+            else
+            {
+                <div>
+                    <AntDesign.Charts.Line Data="Datas.Datas" Config="config" @ref="@chart" />
+
+                    <center>
+
+                        @{
+                            System.Data.DataTable tableData = Datas.GetTableData();
+
+                            <table width="80%" border="1">
+                                <thead>
+                                <th>序号</th>
+
+                                @foreach (System.Data.DataColumn column in tableData.Columns)
+                                {
+                                    <th>@column.ColumnName</th>
+                                }
+
+                                </thead>
+                                <tbody>
+                                    @{
+                                        int iIndex = 1;
+                                        foreach (System.Data.DataRow row in tableData.Rows)
+                                        {
+                                            <tr>
+                                                <td style="text-align: center;">@iIndex</td>
+
+                                                @foreach (System.Data.DataColumn column in tableData.Columns)
+                                                {
+                                                    <td>@row[column.ColumnName].ToString()</td>
+                                                }
+                                            </tr>
+                                            iIndex++;
+                                        }
+                                    }
+                                </tbody>
+                            </table>
+                        }
+
+
+
+                    </center>
+                </div>
+            }
+        </div>
+    </ChildContent>
+</PageContainer>
+
+

+ 171 - 0
wispro.sp.web/Pages/Report/StaffStaticsReport.razor.cs

@@ -0,0 +1,171 @@
+using AntDesign;
+using AntDesign.Charts;
+using Microsoft.AspNetCore.Components;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text.Json;
+using System.Threading.Tasks;
+using wispro.sp.share;
+using wispro.sp.web.Services;
+
+namespace wispro.sp.web.Pages.Report
+{
+    public partial class StaffStaticsReport
+    {
+        private int iType = 3;
+        private DateTime? start = new DateTime(DateTime.Now.Year, 1, 1);
+        private DateTime? end = DateTime.Now;
+
+        internal class TJType
+        {
+            public string Name { get; set; }
+
+            public int value { get; set; }
+        }
+        List<TJType> Types = new List<TJType>
+        {
+            new TJType { value = 0,Name = "代理人每月绩效统计" },
+            new TJType { value = 2,Name = "代理人每年绩效统计" },
+            new TJType { value = 1,Name = "部门每月绩效统计" },
+            new TJType { value = 3,Name = "部门每年绩效统计" },
+            new TJType { value = 4,Name = "人员专案绩效统计" },
+            //new TJType { value = 4,Name = "部门申诉统计" },
+
+        };
+
+        share.ChartDatas Datas = new share.ChartDatas()
+        {
+            Title = "初始化标题",
+            Datas = new List<share.ChartData>() {
+                //new share.ChartData(){ type ="部门一", value =1, year="2022-01", CustomerType ="", CustomerYear=""},
+                //new share.ChartData(){ type ="部门一",value =5, year="2022-02",CustomerType ="", CustomerYear=""},
+                //new share.ChartData(){ type ="部门二", value =3, year="2022-01", CustomerType ="", CustomerYear=""},
+                //new share.ChartData(){ type ="部门二",value =4, year="2022-02",CustomerType ="", CustomerYear=""},
+                //new share.ChartData(){ type ="部门三",value =2.5, year="2022-02",CustomerType ="", CustomerYear=""}
+            },
+            ATitle = "部门",
+            BTitle = "申诉月份"
+        };
+
+        LineConfig config = new LineConfig
+        {
+            Title = new AntDesign.Charts.Title
+            {
+                Visible = true,
+                Text = "带数据点的折线图"
+            },
+            ForceFit = true,
+
+            Padding = "auto",
+            XField = "year",
+            YField = "value",
+            SeriesField = "type",
+
+            Point = new LineViewConfigPoint
+            {
+                Visible = true
+            },
+            Label = new Label
+            {
+                Visible = true,
+                Type = "point"
+            },
+            Legend = new Legend
+            {
+                Visible = false,
+                Position = "bottom",
+            },
+
+            XAxis = new ValueCatTimeAxis
+            {
+                Type = "time",
+                //Visible= true,
+                //Label = new BaseAxisLabel()
+                //{
+                //    AutoRotate = true
+                //},
+                //Title = new BaseAxisTitle()
+                //{
+                //    Text = "绩效月份",
+                //    AutoRotate = true
+                //}
+            },
+            YAxis = new ValueAxis
+            {
+                Label = new BaseAxisLabel()
+                {
+                    AutoRotate = true
+                },
+                Title = new BaseAxisTitle()
+                {
+                    Visible = true,
+                    Text = "申诉数量"
+                }
+            }
+        };
+
+
+        [Inject] ReportService reportService { get; set; }
+
+        [Inject] MessageService msgService { get; set; }
+
+        private AntDesign.Charts.IChartComponent chart;
+
+        private void OnTimeRangeChange(DateRangeChangedEventArgs args)
+        {
+            msgService.Info($"Selected Time: {JsonSerializer.Serialize(args.Dates)}");
+            Console.WriteLine($"Selected Time: {JsonSerializer.Serialize(args.Dates)}");
+            Console.WriteLine($"Formatted Selected Time: {JsonSerializer.Serialize(args.DateStrings)}");
+
+            if (args.Dates?.Length > 0)
+            {
+                Console.WriteLine(args.Dates[0]);
+                start = args.Dates[0];
+            }
+
+            if (args.Dates?.Length > 1)
+            {
+                Console.WriteLine(args.Dates[1]);
+                end = args.Dates[1];
+            }
+
+        }
+
+        private bool _noIconLoading;
+        private async Task OnButtonClick()
+        {
+            _noIconLoading = true;
+            Datas = await reportService.GetStaticReportData(iType);
+
+            if (Datas != null)
+            {
+                config.Title.Text = Datas.Title;
+                config.XField = Datas.ATitle;
+                await chart.ChangeData(Datas.Datas);
+                await chart.UpdateChart(config);
+                StateHasChanged();
+            }
+            _noIconLoading = false;
+        }
+
+        protected async override Task OnInitializedAsync()
+        {
+            //Datas = await reportService.GetAppealReportData(iType, DateTime.Parse("2022-01-01"), DateTime.Now, null);
+
+            if (Datas != null)
+            {
+                config.Title.Text = Datas.Title;
+
+                await chart.ChangeData(Datas.Datas);
+                await chart.UpdateChart(config);
+                StateHasChanged();
+            }
+
+            await base.OnInitializedAsync();
+        }
+
+        
+    }
+}

+ 31 - 0
wispro.sp.web/Services/ReportService.cs

@@ -36,5 +36,36 @@ namespace wispro.sp.web.Services
             var data = await _httpClient.Get<share.ChartDatas>(strUrl);
             return data;
         }
+
+        public async Task<ChartDatas> GetStaticReportData(int iType)
+        {
+            int i = 0;
+            bool isYear = false;
+            switch (iType)
+            {
+                case 0:
+                    i = 0;
+                    break;
+                case 2:
+                    i = 0;
+                    isYear = true;
+                    break;
+                case 1:
+                    i = 1;
+                    break;
+                case 3:
+                    i = 1;
+                    isYear = true;
+                    break;
+                case 4:
+                    i = 2;
+                    break;
+
+            }
+            string strUrl = $"Report/StaticsReport?type={i}&isYear={isYear}";
+            
+            var data = await _httpClient.Get<share.ChartDatas>(strUrl);
+            return data;
+        }
     }
 }

+ 5 - 0
wospro.sp.entity/PerformanceItem.cs

@@ -176,6 +176,11 @@ namespace wispro.sp.entity
         public string ReturnCasseNo { get; set; }
 
         /// <summary>
+        /// 国家或地区
+        /// </summary>
+        public string Country { get; set; }
+
+        /// <summary>
         /// 绩效类型
         /// </summary>
         public string Type { get; set; }