Commit b7bcc7c8 by 李承祥

二次绩效选择模板时,删除无用数据,绩效归档时,数据显示根据录入数据的列显示

parent 615e4e1b
...@@ -1514,6 +1514,9 @@ ...@@ -1514,6 +1514,9 @@
用户科室 用户科室
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.UseTempRequest.IsArchive">
<summary> 是否归档 </summary>
</member>
<member name="P:Performance.DtoModels.WorkItemRequest.Item"> <member name="P:Performance.DtoModels.WorkItemRequest.Item">
<summary> <summary>
工作量绩效项 工作量绩效项
...@@ -2100,6 +2103,9 @@ ...@@ -2100,6 +2103,9 @@
菜单状态 1 启用 2禁用 菜单状态 1 启用 2禁用
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.SecondListResponse.IsArchive">
<summary> 是否归档 </summary>
</member>
<member name="P:Performance.DtoModels.SecondTempResponse.TempName"> <member name="P:Performance.DtoModels.SecondTempResponse.TempName">
<summary> <summary>
模板名称 模板名称
......
...@@ -191,6 +191,8 @@ public AutoMapperConfigs() ...@@ -191,6 +191,8 @@ public AutoMapperConfigs()
.ForMember(dest => dest.FiledName, opt => opt.MapFrom(src => src.ItemName)) .ForMember(dest => dest.FiledName, opt => opt.MapFrom(src => src.ItemName))
.ForMember(dest => dest.Value, opt => opt.MapFrom(src => src.ItemValue)); .ForMember(dest => dest.Value, opt => opt.MapFrom(src => src.ItemValue));
CreateMap<ag_temp, SecondTempResponse>(); CreateMap<ag_temp, SecondTempResponse>();
CreateMap<ag_secondallot, SecondListResponse>().ReverseMap();
} }
} }
} }
...@@ -16,6 +16,9 @@ public class UseTempRequest ...@@ -16,6 +16,9 @@ public class UseTempRequest
public string UnitType { get; set; } public string UnitType { get; set; }
public int SecondId { get; set; } public int SecondId { get; set; }
/// <summary> 是否归档 </summary>
public int IsArchive { get; set; }
} }
public class UseTempRequestValidator : AbstractValidator<UseTempRequest> public class UseTempRequestValidator : AbstractValidator<UseTempRequest>
{ {
......
using Performance.EntityModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.DtoModels
{
public class SecondListResponse : ag_secondallot
{
/// <summary> 是否归档 </summary>
public int IsArchive { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
public static partial class UtilExtensions
{
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
{
return first.AndAlso<T>(second, Expression.AndAlso);
}
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> first, Expression<Func<T, bool>> second)
{
return first.AndAlso<T>(second, Expression.OrElse);
}
private static Expression<Func<T, bool>> AndAlso<T>(this Expression<Func<T, bool>> expr1, Expression<Func<T, bool>> expr2, Func<Expression, Expression, BinaryExpression> func)
{
var parameter = Expression.Parameter(typeof(T));
var leftVisitor = new ReplaceExpressionVisitor(expr1.Parameters[0], parameter);
var left = leftVisitor.Visit(expr1.Body);
var rightVisitor = new ReplaceExpressionVisitor(expr2.Parameters[0], parameter);
var right = rightVisitor.Visit(expr2.Body);
return Expression.Lambda<Func<T, bool>>(
func(left, right), parameter);
}
private class ReplaceExpressionVisitor : ExpressionVisitor
{
private readonly Expression _oldValue;
private readonly Expression _newValue;
public ReplaceExpressionVisitor(Expression oldValue, Expression newValue)
{
_oldValue = oldValue;
_newValue = newValue;
}
public override Expression Visit(Expression node)
{
if (node == _oldValue)
return _newValue;
return base.Visit(node);
}
}
}
\ No newline at end of file
...@@ -353,16 +353,20 @@ public void Pigeonhole(per_allot allot) ...@@ -353,16 +353,20 @@ public void Pigeonhole(per_allot allot)
{ {
allot.States = 8; allot.States = 8;
allot.Remark = "归档"; allot.Remark = "归档";
if (_allotRepository.Update(allot)) _allotRepository.Update(allot);
{ //if (_allotRepository.Update(allot))
var again = _againallotRepository.GetEntities(t => t.AllotID == allot.ID); //{
foreach (var item in again) // var again = _againallotRepository.GetEntities(t => t.AllotID == allot.ID);
{ // if (again != null && again.Count > 0)
item.Remark = $"原状态:{item.States},归档更改状态"; // {
item.States = 5; // foreach (var item in again)
_againallotRepository.Update(item); // {
} // item.Remark = $"原状态:{item.States},归档更改状态";
} // item.States = 5;
// _againallotRepository.Update(item);
// }
// }
//}
} }
/// <summary> /// <summary>
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions;
using System.Text; using System.Text;
namespace Performance.Services namespace Performance.Services
...@@ -64,7 +65,7 @@ public class SecondAllotService : IAutoInjection ...@@ -64,7 +65,7 @@ public class SecondAllotService : IAutoInjection
/// </summary> /// </summary>
/// <param name="userId"></param> /// <param name="userId"></param>
/// <returns></returns> /// <returns></returns>
public List<ag_secondallot> GetSecondList(int userId) public List<SecondListResponse> GetSecondList(int userId)
{ {
var user = perforUserRepository.GetEntity(t => t.ID == userId); var user = perforUserRepository.GetEntity(t => t.ID == userId);
if (user == null) if (user == null)
...@@ -73,7 +74,7 @@ public List<ag_secondallot> GetSecondList(int userId) ...@@ -73,7 +74,7 @@ public List<ag_secondallot> GetSecondList(int userId)
var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userId); var hospital = perforUserhospitalRepository.GetEntity(t => t.UserID == userId);
if (hospital == null) if (hospital == null)
throw new NotImplementedException("人员未选择医院"); throw new NotImplementedException("人员未选择医院");
var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && t.States == 6); var allotList = perforPerallotRepository.GetEntities(t => t.HospitalId == hospital.HospitalID && new List<int> { 6, 8 }.Contains(t.States));
if (allotList == null || allotList.Count == 0) if (allotList == null || allotList.Count == 0)
throw new NotImplementedException("该医院未生成绩效"); throw new NotImplementedException("该医院未生成绩效");
...@@ -121,7 +122,9 @@ public List<ag_secondallot> GetSecondList(int userId) ...@@ -121,7 +122,9 @@ public List<ag_secondallot> GetSecondList(int userId)
secondList.AddRange(newSecond); secondList.AddRange(newSecond);
} }
return secondList; var list = Mapper.Map<List<SecondListResponse>>(secondList);
list?.ForEach(t => t.IsArchive = allotList.FirstOrDefault(a => a.ID == t.AllotId).States == 8 ? 1 : 0);
return list;
} }
/// <summary> /// <summary>
...@@ -164,6 +167,37 @@ public bool UseTemp(UseTempRequest request) ...@@ -164,6 +167,37 @@ public bool UseTemp(UseTempRequest request)
{ {
entity.UseTempId = request.TempId; entity.UseTempId = request.TempId;
result = perforAgusetempRepository.Update(entity); result = perforAgusetempRepository.Update(entity);
//删除多余的数据
if (result)
{
//获取固定模板列头
var tempItem = perforAgtempitemRepository.GetEntities(t => t.TempId == request.TempId);
var headItems = Mapper.Map<List<HeadItem>>(tempItem) ?? new List<HeadItem>();
//获取工作量列头
var workItem = perforAgworkloadRepository.GetEntities(t => t.HospitalId == request.HospitalId && t.Department == request.Department && t.UnitType == request.UnitType);
if (workItem != null && workItem.Count > 0)
{
var workDtos = Mapper.Map<List<HeadItem>>(workItem);
workDtos.ForEach(t => { t.Type = 3; });
headItems.AddRange(workDtos);
}
List<ag_fixatitem> list = new List<ag_fixatitem>();
//获取数据
var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId);
foreach (var item in headItems)
{
list.AddRange(fixatList.Where(t => t.ItemName == item.FiledName && t.Type == item.Type));
}
if (list != null && list.Count > 0)
{
var delList = fixatList.Except(list);
perforAgfixatitemRepository.RemoveRange(delList.ToArray());
}
}
} }
return result; return result;
} }
...@@ -382,6 +416,25 @@ public SecondResponse GetSecondDetail(UseTempRequest request) ...@@ -382,6 +416,25 @@ public SecondResponse GetSecondDetail(UseTempRequest request)
var result = new SecondResponse { HeadItems = headItems, BodyItems = new List<BodyItem>() }; var result = new SecondResponse { HeadItems = headItems, BodyItems = new List<BodyItem>() };
//获取数据 //获取数据
var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue); var fixatList = perforAgfixatitemRepository.GetEntities(t => t.SecondId == request.SecondId && t.RowNumber.HasValue);
if (request.IsArchive == 1)
{
if (fixatList == null || fixatList.Count == 0)
throw new PerformanceException("绩效归档时,尚未添加数据。");
else
{
var existHead = fixatList.Select(t => new { FiledName = t.ItemName, Sort = t.Sort.Value, SourceType = t.SourceType.Value, Type = t.Type.Value, FactorValue = t.FactorValue.Value }).Distinct().ToList();
headItems = existHead.Select(t => new HeadItem
{
FiledId = headItems.FirstOrDefault(h => h.FiledName == t.FiledName && h.Type == t.Type)?.FiledId ?? "无FiledId",
FiledName = t.FiledName,
Sort = t.Sort,
SourceType = t.SourceType,
Type = t.Type,
FactorValue = t.FactorValue
}).Where(t => t.FiledId != "无FiledId").ToList();
}
}
if (fixatList != null && fixatList.Count > 0) if (fixatList != null && fixatList.Count > 0)
{ {
//补充数据 //补充数据
......
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