新增颜色返回

parent f521dec1
...@@ -670,7 +670,7 @@ public ApiResponse RedistributionCompute([FromBody] SecondComputeDto request) ...@@ -670,7 +670,7 @@ public ApiResponse RedistributionCompute([FromBody] SecondComputeDto request)
// 重算部分数据 // 重算部分数据
_redistributionService.RedistributionCompute((ComputeMode)request.ComputeMode, request.Head, cleanDatas); _redistributionService.RedistributionCompute((ComputeMode)request.ComputeMode, request.Head, cleanDatas);
var dic = _redistributionService.GetTableHeaderDictionary((ComputeMode)request.ComputeMode, second, loads); var dic = _redistributionService.GetTableHeaderDictionary((ComputeMode)request.ComputeMode, second, loads, workloadGroups);
return new ApiResponse(ResponseType.OK, new { Head = request.Head, Body = cleanDatas, Dic = dic }); return new ApiResponse(ResponseType.OK, new { Head = request.Head, Body = cleanDatas, Dic = dic });
} }
catch (Exception ex) catch (Exception ex)
......
...@@ -3788,7 +3788,7 @@ ...@@ -3788,7 +3788,7 @@
</member> </member>
<member name="P:Performance.DtoModels.SecondLoadDto.OverrideMode"> <member name="P:Performance.DtoModels.SecondLoadDto.OverrideMode">
<summary> <summary>
数据加载方式:0 保存,1 上次,2 字典,3 测算表 数据加载方式:0 保存,1 上次,2 字典
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.SelectionOptions.SelectionID"> <member name="P:Performance.DtoModels.SelectionOptions.SelectionID">
......
...@@ -9,12 +9,13 @@ public class SecondColumnDictionary ...@@ -9,12 +9,13 @@ public class SecondColumnDictionary
public int Sort { get; set; } public int Sort { get; set; }
public string Site { get; set; } public string Site { get; set; }
public string Type { get; set; } public string Type { get; set; }
public string Color { get; set; }
public SecondColumnDictionary() public SecondColumnDictionary()
{ {
} }
public SecondColumnDictionary(string label, string key, bool isTrue, int sort, string site = "Table", string fix = "", string type = "") public SecondColumnDictionary(string label, string key, bool isTrue, int sort, string site = "Table", string fix = "", string type = "", string color = "")
{ {
Label = label; Label = label;
Key = key; Key = key;
...@@ -23,6 +24,7 @@ public SecondColumnDictionary(string label, string key, bool isTrue, int sort, s ...@@ -23,6 +24,7 @@ public SecondColumnDictionary(string label, string key, bool isTrue, int sort, s
Site = site; Site = site;
Fixed = fix; Fixed = fix;
Type = type; Type = type;
Color = color;
} }
} }
} }
...@@ -8,7 +8,7 @@ public class SecondLoadDto ...@@ -8,7 +8,7 @@ public class SecondLoadDto
/// </summary> /// </summary>
public int ComputeMode { get; set; } public int ComputeMode { get; set; }
/// <summary> /// <summary>
/// 数据加载方式:0 保存,1 上次,2 字典,3 测算表 /// 数据加载方式:0 保存,1 上次,2 字典
/// </summary> /// </summary>
public int OverrideMode { get; set; } public int OverrideMode { get; set; }
} }
......
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
namespace Performance.Infrastructure
{
public static partial class UtilExtensions
{
public static string ToRGB(this Color color)
{
return $"{color.R},{color.G},{color.B}";
}
}
}
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
namespace Performance.Infrastructure namespace Performance.Infrastructure
{ {
...@@ -17,5 +19,26 @@ public static string GetSmsCode() ...@@ -17,5 +19,26 @@ public static string GetSmsCode()
return code.ToString().PadLeft(4, '0'); return code.ToString().PadLeft(4, '0');
} }
public static List<Color> Color(Color sColor, Color eColor, int number)
{
int sr = sColor.R;
int sg = sColor.G;
int sb = sColor.B;
int er = eColor.R;
int eg = eColor.G;
int eb = eColor.B;
var colorList = new List<Color>();
for (int i = 0; i < number; i++)
{
var rAverage = sr + (int)((er - sr) * i / number);
var gAverage = sg + (int)((eg - sg) * i / number);
var bAverage = sb + (int)((eb - sb) * i / number);
colorList.Add(System.Drawing.Color.FromArgb(rAverage, gAverage, bAverage));
}
return colorList;
}
} }
} }
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
using Performance.DtoModels.Second; using Performance.DtoModels.Second;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -135,7 +136,7 @@ public SecondDetailDto Load(int secondId, ComputeMode computeMode, EmployeeSourc ...@@ -135,7 +136,7 @@ public SecondDetailDto Load(int secondId, ComputeMode computeMode, EmployeeSourc
/// <param name="second"></param> /// <param name="second"></param>
/// <param name="loads"></param> /// <param name="loads"></param>
/// <returns></returns> /// <returns></returns>
public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode computeMode, ag_secondallot second, List<TitleValue<string, decimal?>> loads) public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode computeMode, ag_secondallot second, List<TitleValue<string, decimal?>> loads, List<SecondWorkLoadDto> workloadGroups = null)
{ {
var maps = new List<SecondColumnDictionary>() var maps = new List<SecondColumnDictionary>()
{ {
...@@ -144,10 +145,10 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute ...@@ -144,10 +145,10 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute
new SecondColumnDictionary("科室",nameof(ag_bodysource.Department),true,100, fix:"Left"), new SecondColumnDictionary("科室",nameof(ag_bodysource.Department),true,100, fix:"Left"),
new SecondColumnDictionary("主管",nameof(ag_bodysource.Post),true,100 ), new SecondColumnDictionary("主管",nameof(ag_bodysource.Post),true,100 ),
new SecondColumnDictionary("人员系数",nameof(ag_bodysource.StaffCoefficient),false,200 ), new SecondColumnDictionary("人员系数",nameof(ag_bodysource.StaffCoefficient),false,200, color: Color.DarkTurquoise.ToRGB() ),
new SecondColumnDictionary("出勤",nameof(ag_bodysource.ActualAttendance),false,201 ), new SecondColumnDictionary("出勤",nameof(ag_bodysource.ActualAttendance),false,201, color: Color.DarkTurquoise.ToRGB() ),
new SecondColumnDictionary("职称",nameof(ag_bodysource.JobTitle),false,202 ), new SecondColumnDictionary("职称",nameof(ag_bodysource.JobTitle),false,202, color: Color.DarkTurquoise.ToRGB() ),
new SecondColumnDictionary("职称系数",nameof(ag_bodysource.TitleCoefficient),false,203 ), new SecondColumnDictionary("职称系数",nameof(ag_bodysource.TitleCoefficient),false,203, color: Color.DarkTurquoise.ToRGB() ),
new SecondColumnDictionary("职称绩效",nameof(ag_bodysource.TitlePerformance),true,299 ), new SecondColumnDictionary("职称绩效",nameof(ag_bodysource.TitlePerformance),true,299 ),
new SecondColumnDictionary("工作量绩效合计",nameof(ag_bodysource.WorkPerformance),true,399 ), new SecondColumnDictionary("工作量绩效合计",nameof(ag_bodysource.WorkPerformance),true,399 ),
...@@ -166,11 +167,21 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute ...@@ -166,11 +167,21 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute
// 工作量 // 工作量
if (computeMode != ComputeMode.NotCalculate) if (computeMode != ComputeMode.NotCalculate)
{ {
if (workloadGroups == null)
workloadGroups = GetTopWorkloadBodyGroups(loads);
var colors = RandomHelper.Color(Color.LightGreen, Color.LawnGreen, workloadGroups.Count);
var index = 0;
int workloadSort = 300; int workloadSort = 300;
foreach (var item in loads.Where(w => !w.Title.StartsWithIgnoreCase("SingleAwards_"))) foreach (var item in loads.Where(w => !w.Title.StartsWithIgnoreCase("SingleAwards_")))
{ {
maps.Add(new SecondColumnDictionary(item.Value, item.Title, false, ++workloadSort, type: "Workload")); if (workloadGroups.Any(w => w.Items?.FirstOrDefault() == item.Title))
index = workloadGroups.FindIndex(w => w.Items?.FirstOrDefault() == item.Title);
var color = index < colors.Count ? colors[index].ToRGB() : "";
maps.Add(new SecondColumnDictionary(item.Value, item.Title, false, ++workloadSort, type: "Workload", color: color));
} }
// 多工作量加载 // 多工作量加载
var headDynamic = _agworktypesourceRepository.GetEntities(t => t.SecondId == second.Id); var headDynamic = _agworktypesourceRepository.GetEntities(t => t.SecondId == second.Id);
if (headDynamic != null && headDynamic.Any()) if (headDynamic != null && headDynamic.Any())
...@@ -185,7 +196,7 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute ...@@ -185,7 +196,7 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute
int singleAwardsSort = 400; int singleAwardsSort = 400;
foreach (var item in loads.Where(w => w.Title.StartsWithIgnoreCase("SingleAwards_"))) foreach (var item in loads.Where(w => w.Title.StartsWithIgnoreCase("SingleAwards_")))
{ {
maps.Add(new SecondColumnDictionary(item.Value, item.Title, false, ++singleAwardsSort, type: "SingleAwards")); maps.Add(new SecondColumnDictionary(item.Value, item.Title, false, ++singleAwardsSort, type: "SingleAwards", color: Color.Cyan.ToRGB()));
} }
return maps.OrderBy(w => w.Sort).ToList(); return maps.OrderBy(w => w.Sort).ToList();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment