Commit 5773f064 by ruyun.zhang

显示设置报错及应用

parent 6a117cdf
...@@ -5,6 +5,8 @@ namespace Performance.DtoModels ...@@ -5,6 +5,8 @@ namespace Performance.DtoModels
{ {
public class UniteDeptDetailItem public class UniteDeptDetailItem
{ {
public string Id { get; set; }
public string ParentId { get; set; }
public int SheetType { get; set; } public int SheetType { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string Remark { get; set; } public string Remark { get; set; }
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using Masuit.Tools; using Masuit.Tools;
using Masuit.Tools.Systems;
using NPOI.Util; using NPOI.Util;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.EntityModels; using Performance.EntityModels;
...@@ -26,6 +27,8 @@ public UniteDeptDetailResponse UniteDeptDetail(int allotId, UnitType unitType, s ...@@ -26,6 +27,8 @@ public UniteDeptDetailResponse UniteDeptDetail(int allotId, UnitType unitType, s
{ {
var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId); var allot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
if (allot == null) throw new PerformanceException("绩效月信息错误"); if (allot == null) throw new PerformanceException("绩效月信息错误");
//当角色对应时过滤
var userInfo = _userRepository.GetUser(userId);
var account = perforResaccountRepository.GetEntity(t => t.AllotID == allotId && t.UnitType == (int)unitType && t.AccountingUnit == accountingUnit); var account = perforResaccountRepository.GetEntity(t => t.AllotID == allotId && t.UnitType == (int)unitType && t.AccountingUnit == accountingUnit);
account ??= new res_account account ??= new res_account
...@@ -309,6 +312,8 @@ public UniteDeptDetailResponse UniteDeptDetail(int allotId, UnitType unitType, s ...@@ -309,6 +312,8 @@ public UniteDeptDetailResponse UniteDeptDetail(int allotId, UnitType unitType, s
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.调节系数.ToString(), Total = account.AdjustFactor ?? 1 }); response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.调节系数.ToString(), Total = account.AdjustFactor ?? 1 });
response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.实发绩效.ToString(), Total = account.RealGiveFee ?? 0 }); response.DetailItems.Add(new DeptDetailItem { Title = UniteDept.Title.实发绩效.ToString(), Total = account.RealGiveFee ?? 0 });
// 加载用户设置
var settings = GetUniteDeptDetailSetting(allotId);
// 显示详情 // 显示详情
#region 补全公共附属表明细 #region 补全公共附属表明细
{ {
...@@ -337,14 +342,20 @@ public UniteDeptDetailResponse UniteDeptDetail(int allotId, UnitType unitType, s ...@@ -337,14 +342,20 @@ public UniteDeptDetailResponse UniteDeptDetail(int allotId, UnitType unitType, s
{ {
if (ignore.Contains(post.Key.TypeName)) continue; if (ignore.Contains(post.Key.TypeName)) continue;
var settingItem = settings.FirstOrDefault(w => w.Title == detail.Title) ?? new UniteDeptDetailItem() { Children = new List<UniteDeptDetailItem>() };
var gs = settingItem.Children.FirstOrDefault(w => w.Title == post.Key.TypeName) ?? new UniteDeptDetailItem { Format = "" };
if (!userInfo.IsSecondAdmin || allot.States == (int)AllotStates.绩效下发 || allot.States == (int)AllotStates.归档)
{
var fz = post.Sum(group => group.IsFactor == 1 ? (group.CellValue * (group.FactorValue ?? 0)) : group.CellValue); var fz = post.Sum(group => group.IsFactor == 1 ? (group.CellValue * (group.FactorValue ?? 0)) : group.CellValue);
var row = new Dictionary<string, object> var row = new Dictionary<string, object>
{ {
{ "指标", post.Key.TypeName }, { "指标", post.Key.TypeName },
{ "分值", ValueFormating(fz, "") } { "分值", ValueFormating(fz, gs.Format) }
}; };
items.Add(row); items.Add(row);
} }
}
var amount = basicData?.Where(t => t.SheetID == sheet.ID && t.UnitType == (int)type && t.IsTotal == 1)?.FirstOrDefault()?.CellValue ?? 0; var amount = basicData?.Where(t => t.SheetID == sheet.ID && t.UnitType == (int)type && t.IsTotal == 1)?.FirstOrDefault()?.CellValue ?? 0;
detail.Total = amount; detail.Total = amount;
detail.Items = items; detail.Items = items;
...@@ -353,10 +364,7 @@ public UniteDeptDetailResponse UniteDeptDetail(int allotId, UnitType unitType, s ...@@ -353,10 +364,7 @@ public UniteDeptDetailResponse UniteDeptDetail(int allotId, UnitType unitType, s
} }
#endregion #endregion
//当角色对应时过滤
var userInfo = _userRepository.GetUser(userId);
// 应用用户设置的显示规则 // 应用用户设置的显示规则
var settings = GetUniteDeptDetailSetting(allotId);
foreach (var detail in response.DetailItems) foreach (var detail in response.DetailItems)
{ {
detail.Display = true; detail.Display = true;
...@@ -485,7 +493,6 @@ public List<UniteDeptDetailItem> GetUniteDeptDetailSetting(int allotId) ...@@ -485,7 +493,6 @@ public List<UniteDeptDetailItem> GetUniteDeptDetailSetting(int allotId)
// 显示详情 // 显示详情
#region 补全公共附属表明细 #region 补全公共附属表明细
{
var rightSheetTypeMaps = new List<UniteDeptDetailItem>() var rightSheetTypeMaps = new List<UniteDeptDetailItem>()
{ {
new UniteDeptDetailItem { Title = UniteDept.Title.预算比例.ToString(), SheetType = (int)SheetType.BudgetRatio, Format = UniteDept.Format.两位小数百分比.ToString(), }, new UniteDeptDetailItem { Title = UniteDept.Title.预算比例.ToString(), SheetType = (int)SheetType.BudgetRatio, Format = UniteDept.Format.两位小数百分比.ToString(), },
...@@ -513,7 +520,6 @@ public List<UniteDeptDetailItem> GetUniteDeptDetailSetting(int allotId) ...@@ -513,7 +520,6 @@ public List<UniteDeptDetailItem> GetUniteDeptDetailSetting(int allotId)
detail.Children = items; detail.Children = items;
} }
} }
}
#endregion #endregion
var entity = _perforCofDeptDetailRepository.GetEntity(w => w.AllotId == allotId); var entity = _perforCofDeptDetailRepository.GetEntity(w => w.AllotId == allotId);
...@@ -524,14 +530,22 @@ public List<UniteDeptDetailItem> GetUniteDeptDetailSetting(int allotId) ...@@ -524,14 +530,22 @@ public List<UniteDeptDetailItem> GetUniteDeptDetailSetting(int allotId)
var enumItems = EnumHelper.GetItems<UniteDept.Title>(); var enumItems = EnumHelper.GetItems<UniteDept.Title>();
foreach (var detail in response) foreach (var detail in response)
{ {
detail.Id = SnowFlake.GetInstance().GetLongId().ToString();
detail.Display = UniteDept.DisplayRule.始终显示.ToString(); detail.Display = UniteDept.DisplayRule.始终显示.ToString();
detail.Children ??= new List<UniteDeptDetailItem>();
foreach (var item in detail.Children)
{
item.Id = SnowFlake.GetInstance().GetLongId().ToString();
item.ParentId = detail.Id;
}
var cfg = enumItems.FirstOrDefault(w => w.Name == detail.Title); var cfg = enumItems.FirstOrDefault(w => w.Name == detail.Title);
// 只对右侧设置排序 // 只对右侧设置排序
detail.Sort = cfg == null ? detail.Sort : cfg.Value; detail.Sort = cfg == null ? detail.Sort : cfg.Value;
// 读取数据库保存内容 // 读取数据库保存内容
detail.Children ??= new List<UniteDeptDetailItem>();
var temp1 = cofDeptDetail.FirstOrDefault(w => w.Title == detail.Title); var temp1 = cofDeptDetail.FirstOrDefault(w => w.Title == detail.Title);
if (temp1 == null) continue; if (temp1 != null)
{
detail.SheetType = temp1.SheetType; detail.SheetType = temp1.SheetType;
detail.Remark = temp1.Remark; detail.Remark = temp1.Remark;
detail.Title = temp1.Title; detail.Title = temp1.Title;
...@@ -541,13 +555,21 @@ public List<UniteDeptDetailItem> GetUniteDeptDetailSetting(int allotId) ...@@ -541,13 +555,21 @@ public List<UniteDeptDetailItem> GetUniteDeptDetailSetting(int allotId)
foreach (var item in detail.Children) foreach (var item in detail.Children)
{ {
var temp2 = cofDeptDetail.FirstOrDefault(w => w.Title == item.Title); var temp2 = cofDeptDetail.FirstOrDefault(w => w.Title == item.Title);
if (temp2 == null) continue; if (temp2 != null)
detail.SheetType = temp2.SheetType; {
detail.Remark = temp2.Remark; item.SheetType = temp2.SheetType;
detail.Title = temp2.Title; item.Remark = temp2.Remark;
detail.Format = temp2.Format; item.Title = temp2.Title;
detail.Sort = temp2.Sort; item.Format = temp2.Format;
detail.Display = temp2.Display; item.Sort = temp2.Sort;
item.Display = temp2.Display;
}
}
foreach (var item2 in temp1.Children)
{
if (!detail.Children.Any(w => w.Title == item2.Title))
detail.Children.Add(item2);
}
} }
} }
......
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