新增颜色返回

parent f521dec1
......@@ -670,7 +670,7 @@ public ApiResponse RedistributionCompute([FromBody] SecondComputeDto request)
// 重算部分数据
_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 });
}
catch (Exception ex)
......
......@@ -3788,7 +3788,7 @@
</member>
<member name="P:Performance.DtoModels.SecondLoadDto.OverrideMode">
<summary>
数据加载方式:0 保存,1 上次,2 字典,3 测算表
数据加载方式:0 保存,1 上次,2 字典
</summary>
</member>
<member name="P:Performance.DtoModels.SelectionOptions.SelectionID">
......
......@@ -9,12 +9,13 @@ public class SecondColumnDictionary
public int Sort { get; set; }
public string Site { get; set; }
public string Type { get; set; }
public string Color { get; set; }
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;
Key = key;
......@@ -23,6 +24,7 @@ public SecondColumnDictionary(string label, string key, bool isTrue, int sort, s
Site = site;
Fixed = fix;
Type = type;
Color = color;
}
}
}
......@@ -8,7 +8,7 @@ public class SecondLoadDto
/// </summary>
public int ComputeMode { get; set; }
/// <summary>
/// 数据加载方式:0 保存,1 上次,2 字典,3 测算表
/// 数据加载方式:0 保存,1 上次,2 字典
/// </summary>
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.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Text.RegularExpressions;
namespace Performance.Infrastructure
{
......@@ -17,5 +19,26 @@ public static string GetSmsCode()
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 @@
using Performance.DtoModels.Second;
using Microsoft.Extensions.Logging;
using System.Diagnostics;
using System.Drawing;
namespace Performance.Services
{
......@@ -135,7 +136,7 @@ public SecondDetailDto Load(int secondId, ComputeMode computeMode, EmployeeSourc
/// <param name="second"></param>
/// <param name="loads"></param>
/// <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>()
{
......@@ -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.Post),true,100 ),
new SecondColumnDictionary("人员系数",nameof(ag_bodysource.StaffCoefficient),false,200 ),
new SecondColumnDictionary("出勤",nameof(ag_bodysource.ActualAttendance),false,201 ),
new SecondColumnDictionary("职称",nameof(ag_bodysource.JobTitle),false,202 ),
new SecondColumnDictionary("职称系数",nameof(ag_bodysource.TitleCoefficient),false,203 ),
new SecondColumnDictionary("人员系数",nameof(ag_bodysource.StaffCoefficient),false,200, color: Color.DarkTurquoise.ToRGB() ),
new SecondColumnDictionary("出勤",nameof(ag_bodysource.ActualAttendance),false,201, color: Color.DarkTurquoise.ToRGB() ),
new SecondColumnDictionary("职称",nameof(ag_bodysource.JobTitle),false,202, color: Color.DarkTurquoise.ToRGB() ),
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.WorkPerformance),true,399 ),
......@@ -166,11 +167,21 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute
// 工作量
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;
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);
if (headDynamic != null && headDynamic.Any())
......@@ -185,7 +196,7 @@ public List<SecondColumnDictionary> GetTableHeaderDictionary(ComputeMode compute
int singleAwardsSort = 400;
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();
}
......
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