Commit c91e04e9 by 1391696987

手工录入:汇总,查看详情,下拉框,录入判断,审核;

考勤:增加超出考勤时间多少天,修改返回时间为短时间
parent 6894dee7
......@@ -3,7 +3,6 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Performance.DtoModels;
using Performance.DtoModels.Request;
using Performance.DtoModels.Response;
using Performance.EntityModels;
using Performance.Infrastructure;
......@@ -892,12 +891,10 @@ public ApiResponse GetGatherHands([FromRoute] int allotId, [FromBody] GatherRequ
/// <returns></returns>
[Route("savegatherhands/{allotId}")]
[HttpPost]
public ApiResponse SaveGatherHands([FromBody] int allotId, [FromBody] SaveGatherData request)
public ApiResponse SaveGatherHands([FromRoute] int allotId, [FromBody] SaveGatherData request)
{
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
if (string.IsNullOrEmpty(request.Source) || string.IsNullOrEmpty(request.Category))
return new ApiResponse(ResponseType.Fail);
if (request.Data == null || !request.Data.Any())
return new ApiResponse(ResponseType.Fail, "用户提交数据为空");
......@@ -942,6 +939,37 @@ public ApiResponse GetGatherTotal([FromBody] Gather gather)
return new ApiResponse(ResponseType.OK, result);
}
/// <summary>
/// 手工录入列表 - 删除
/// </summary>
/// <param name="gather"></param>
/// <returns></returns>
[Route("deleteGather")]
[HttpPost]
public ApiResponse DeleteGather([FromBody] Gather gather)
{
if (gather.AllotId <= 0 || string.IsNullOrEmpty(gather.Source) || string.IsNullOrEmpty(gather.Category) || string.IsNullOrEmpty(gather.Department))
return new ApiResponse(ResponseType.Fail, "参数错误", "请检查allotId,source,category,department是否正确");
var result = employeeService.DeleteGather(gather);
if(result) return new ApiResponse(ResponseType.OK, "删除成功");
else return new ApiResponse(ResponseType.Fail, "删除失败");
}
/// <summary>
/// 批量审核
/// </summary>
/// <param name="gather"></param>
/// <returns></returns>
[Route("auditGather")]
[HttpPost]
public ApiResponse auditGather([FromBody] List<Gather> gather)
{
employeeService.auditGather(gather);
return new ApiResponse(ResponseType.OK,"");
}
#endregion
}
}
......@@ -1393,6 +1393,20 @@
<param name="gather"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.EmployeeController.DeleteGather(Performance.DtoModels.Gather)">
<summary>
手工录入列表 - 删除
</summary>
<param name="gather"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.EmployeeController.auditGather(System.Collections.Generic.List{Performance.DtoModels.Gather})">
<summary>
批量审核
</summary>
<param name="gather"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ExConfigController.Extract(Performance.DtoModels.ModModuleRequest)">
<summary>
绩效数据抽取模板
......
......@@ -3489,6 +3489,36 @@
汇总
</summary>
</member>
<member name="P:Performance.DtoModels.Gather.UserId">
<summary>
用户Id
</summary>
</member>
<member name="P:Performance.DtoModels.Gather.Department">
<summary>
科室
</summary>
</member>
<member name="P:Performance.DtoModels.Gather.Source">
<summary>
来源
</summary>
</member>
<member name="P:Performance.DtoModels.Gather.Category">
<summary>
核算项目
</summary>
</member>
<member name="P:Performance.DtoModels.Gather.Status">
<summary>
状态
</summary>
</member>
<member name="P:Performance.DtoModels.Gather.Remark">
<summary>
失败理由
</summary>
</member>
<member name="P:Performance.DtoModels.GuaranteeResponse.AllotId">
<summary>
......
......@@ -3624,6 +3624,11 @@
来源
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.Submitter">
<summary>
提交人
</summary>
</member>
<member name="P:Performance.EntityModels.ex_result_gather.CreateTime">
<summary>
创建时间
......
......@@ -171,4 +171,11 @@ public enum Deduction
}
}
public enum AuditGather
{
未审核 = 0,
未通过 = 1,
已通过 = 2,
}
}
......@@ -95,11 +95,11 @@ public class ColumnHeadsConfig
public static List<Heads> GatherHeads { get; } = new List<Heads>
{
new Heads{Column="来源",Name=nameof(GatherInfoRequest.Source)},
new Heads{Column="科室",Name=nameof(GatherInfoRequest.Department)},
new Heads{Column="His科室",Name=nameof(GatherInfoRequest.Department)},
new Heads{Column="医生姓名",Name=nameof(GatherInfoRequest.DoctorName)},
new Heads{Column="人员工号",Name=nameof(GatherInfoRequest.PersonnelNumber)},
new Heads{Column="费用类型",Name=nameof(GatherInfoFee.Category)},
new Heads{Column="费用",Name=nameof(GatherInfoFee.Fee)},
new Heads{Column="数值类型",Name=nameof(GatherInfoFee.Category)},
new Heads{Column="数值",Name=nameof(GatherInfoFee.Fee)},
};
public static List<Heads> GatherTotal { get; } = new List<Heads>
......@@ -107,6 +107,7 @@ public class ColumnHeadsConfig
new Heads{Column="核算组别",Name=nameof(GatherTotalRequest.Department)},
new Heads{Column="来源",Name=nameof(GatherTotalRequest.Source)},
new Heads{Column="核算项目",Name=nameof(GatherTotalRequest.Category)},
new Heads{Column="提交人",Name=nameof(UserRequest.Login)},
new Heads{Column="提交日期",Name=nameof(GatherTotalRequest.CreateTime)},
new Heads{Column="审核日期",Name=nameof(GatherTotalRequest.AuditTime)},
new Heads{Column="审核状态",Name=nameof(GatherTotalRequest.States)},
......
......@@ -52,20 +52,42 @@ public class GatherTotalRequest
}
public class Gather: PersonParamsRequest
{
public int AllotId { get; set; }
/// <summary>
/// 用户Id
/// </summary>
public int UserId { get; set; }
/// <summary>
/// 科室
/// </summary>
public string Department { get; set; }
/// <summary>
/// 来源
/// </summary>
public string Source { get; set; }
/// <summary>
/// 核算项目
/// </summary>
public string Category { get; set; }
/// <summary>
/// 状态
/// </summary>
public string Status { get; set; }
/// <summary>
/// 失败理由
/// </summary>
public string Remark { get; set; }
}
public class GatherInfoRequest
{
public int UserId { get; set; }
public string Source { get; set; }
public string CreateTime { get; set; }
public string Department { get; set; }
public string DoctorName { get; set; }
public string PersonnelNumber { get; set; }
public GatherInfoFee Detail { get; set; }
public GatherInfoFee[] Detail { get; set; }
}
public class GatherInfoFee
......
......@@ -32,6 +32,7 @@ public class SaveCustomData
public class SaveGatherData
{
public int UserId { get; set; }
public string Source { get; set; }
public string Category { get; set; }
public string[] ColHeaders { get; set; }
......
......@@ -39,6 +39,10 @@ public class ex_result_gather
/// </summary>
public string Source { get; set; }
/// <summary>
/// 提交人
/// </summary>
public int Submitter { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime CreateTime { get; set; }
......
......@@ -240,7 +240,7 @@ public ApiResponse BatchCallIn(int allotId, int hospitalId, SaveCollectData requ
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "调入核算单元", newAttendanceVacatione[i].CallInAccountingUnit??"" },
{ "调入组别", newAttendanceVacatione[i].CallInUnitType??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate.ToString()??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate?.ToString("d")??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "“关键信息缺失”请补全或删除" },
});
......@@ -255,9 +255,9 @@ public ApiResponse BatchCallIn(int allotId, int hospitalId, SaveCollectData requ
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "调入核算单元", newAttendanceVacatione[i].CallInAccountingUnit??"" },
{ "调入组别", newAttendanceVacatione[i].CallInUnitType??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate.ToString()??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate?.ToString("d")??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "调入时间不在当前绩效月份范围内" },
{ "错误原因", $"调入时间不在当前绩效月份范围内,已超出{SplitEveryDay(dt.AddDays(-1),newAttendanceVacatione[i].CallInDate.Value).Count-1}天"},
});
}
......@@ -270,7 +270,7 @@ public ApiResponse BatchCallIn(int allotId, int hospitalId, SaveCollectData requ
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "调入核算单元", newAttendanceVacatione[i].CallInAccountingUnit??"" },
{ "调入组别", newAttendanceVacatione[i].CallInUnitType??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate.ToString()??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate?.ToString("d")??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "该核算单元的调入组别不一致或不存在" },
});
......@@ -285,7 +285,7 @@ public ApiResponse BatchCallIn(int allotId, int hospitalId, SaveCollectData requ
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "调入核算单元", newAttendanceVacatione[i].CallInAccountingUnit??"" },
{ "调入组别", newAttendanceVacatione[i].CallInUnitType??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate.ToString()??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate?.ToString("d")??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "该人员与人员字典不一致或不存在" },
});
......@@ -300,7 +300,7 @@ public ApiResponse BatchCallIn(int allotId, int hospitalId, SaveCollectData requ
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "调入核算单元", newAttendanceVacatione[i].CallInAccountingUnit??"" },
{ "调入组别", newAttendanceVacatione[i].CallInUnitType??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate.ToString()??"" },
{ "调入时间", newAttendanceVacatione[i].CallInDate?.ToString("d")??"" },
{ "来源", "“粘贴数据”与“历史数据”比对" },
{ "错误原因", $"原名“{oldEmp.PersonnelName}”,工号相同但姓名不同,请删除“历史数据”中该员工" },
});
......@@ -529,8 +529,8 @@ public ApiResponse AttendanceBatch(int allotId, int hospitalId, SaveCollectData
{ "人员工号", newAttendanceVacatione[i].PersonnelNumber??"" },
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "考勤类型", newAttendanceVacatione[i].AttendanceName??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString()??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString()??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString("d")??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString("d")??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "“关键信息缺失”请补全或删除" },
});
......@@ -545,8 +545,8 @@ public ApiResponse AttendanceBatch(int allotId, int hospitalId, SaveCollectData
{ "人员工号", newAttendanceVacatione[i].PersonnelNumber??"" },
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "考勤类型", newAttendanceVacatione[i].AttendanceName??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString()??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString()??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString("d")??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString("d")??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "没有该考勤类型" },
});
......@@ -559,8 +559,8 @@ public ApiResponse AttendanceBatch(int allotId, int hospitalId, SaveCollectData
{ "人员工号", newAttendanceVacatione[i].PersonnelNumber??"" },
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "考勤类型", newAttendanceVacatione[i].AttendanceName??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString()??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString()??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString("d")??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString("d")??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "该人员与人员字典不一致或不存在" },
});
......@@ -574,16 +574,16 @@ public ApiResponse AttendanceBatch(int allotId, int hospitalId, SaveCollectData
{ "人员工号", newAttendanceVacatione[i].PersonnelNumber??"" },
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "考勤类型", newAttendanceVacatione[i].AttendanceName??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString()??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString()??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString("d")??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString("d")??"" },
{ "来源", "“粘贴数据”与“历史数据”比对" },
{ "错误原因", $"原名“{oldEmp.PersonnelName}”,工号相同但姓名不同,请删除“历史数据”中该员工" },
});
}
DateTime dt = new DateTime(per_allot.Year, per_allot.Month, 1);
if (newAttendanceVacatione[i].BegDate >= dt && newAttendanceVacatione[i].EndDate > dt.AddMonths(1))
DateTime dt = new DateTime(per_allot.Year, per_allot.Month, 1).AddMonths(1);
if (newAttendanceVacatione[i].BegDate >= dt && newAttendanceVacatione[i].EndDate > dt)
{
error.Add(new Dictionary<string, string>
{
......@@ -591,10 +591,10 @@ public ApiResponse AttendanceBatch(int allotId, int hospitalId, SaveCollectData
{ "人员工号", newAttendanceVacatione[i].PersonnelNumber??"" },
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "考勤类型", newAttendanceVacatione[i].AttendanceName??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString()??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString()??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString("d")??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString("d")??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "考勤时间不在该绩效月份内" },
{ "错误原因", $"考勤时间不在该绩效月份内,已超出{SplitEveryDay(dt.AddDays(-1),newAttendanceVacatione[i].EndDate).Count-1}" },
});
}
if (newAttendanceVacatione[i].BegDate > newAttendanceVacatione[i].EndDate)
......@@ -605,8 +605,8 @@ public ApiResponse AttendanceBatch(int allotId, int hospitalId, SaveCollectData
{ "人员工号", newAttendanceVacatione[i].PersonnelNumber??"" },
{ "人员姓名", newAttendanceVacatione[i].PersonnelName??"" },
{ "考勤类型", newAttendanceVacatione[i].AttendanceName??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString()??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString()??"" },
{ "开始日期", newAttendanceVacatione[i].BegDate.ToString("d")??"" },
{ "结束日期", newAttendanceVacatione[i].EndDate.ToString("d")??"" },
{ "来源", "粘贴数据" },
{ "错误原因", "开始时间不能大于结束时间" },
});
......
......@@ -1253,27 +1253,33 @@ public ComparisonResponse<DtoModels.Comparison<DeptComparisonTotal>> GetDeptComp
public List<GatherDropResponse> GetGatherDrop(Gather gather)
{
var collectPermission = perforcollectpermissionRepository.GetEntities(t=>t.UserId == gather.UserId).Select(t=> t.SheetName).Distinct();
var collectPermission = perforcollectpermissionRepository.GetEntities(t => t.UserId == gather.UserId).Select(t => Regex.Replace(t.SheetName.Replace(" ", "").Replace(".", ""), "[0-9]", "")).Distinct();
var perSheets = perforPersheetRepository.GetEntities(t => t.AllotID == gather.AllotId && new[] { 3, 4, 7 }.Contains(t.SheetType.Value)).Select(s=> new{
var perSheets = perforPersheetRepository.GetEntities(t => t.AllotID == gather.AllotId && new[] { 3, 4, 7 }.Contains(t.SheetType.Value)).Select(s => new
{
s.ID,
SheetName = Regex.Replace(s.SheetName.Replace(" ", "").Replace(".", ""), "[0-9]", "")
});
if (perSheets == null || !perSheets.Any())
{
var allot = perallotRepository.GetEntity(t => t.ID == gather.AllotId);
var list = perallotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (list == null || !list.Any(t => t.ID == allot.ID)) return new List<GatherDropResponse>();
var username = userRepository.GetEntity(t => t.ID == gather.UserId).Login;
if (username != "admin")
perSheets = perSheets.Where(w => collectPermission.Contains(w.SheetName));
//if (perSheets == null || !perSheets.Any())
//{
// var allot = perallotRepository.GetEntity(t => t.ID == gather.AllotId);
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
// var list = perallotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
// if (list == null || !list.Any(t => t.ID == allot.ID)) return new List<GatherDropResponse>();
var index = list.IndexOf(list.First(t => t.ID == allot.ID));
// list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
gather.AllotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
if (gather.AllotId == allot.ID) return new List<GatherDropResponse>();
}
// var index = list.IndexOf(list.First(t => t.ID == allot.ID));
// // 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
// gather.AllotId = index + 1 < list.Count ? list[index + 1].ID : list.First().ID;
// if (gather.AllotId == allot.ID) return new List<GatherDropResponse>();
//}
......@@ -1301,7 +1307,7 @@ public List<GatherDropResponse> GetGatherDrop(Gather gather)
foreach (var sheet in perSheets)
{
var drop = new GatherDropResponse();
var header = imHeaders.Where(t =>!cellValue.Contains(t.CellValue)).Select(t => t.CellValue).Distinct();
var header = imHeaders.Where(t => !cellValue.Contains(t.CellValue)).Select(t => t.CellValue).Distinct();
drop.Label = Regex.Replace(sheet.SheetName.Replace(" ", "").Replace(".", ""), "[0-9]", "")/*sheet.SheetName.Split(' ')[1]*/;
drop.Value = Regex.Replace(sheet.SheetName.Replace(" ", "").Replace(".", ""), "[0-9]", "")/*sheet.SheetName.Split(' ')[1]*/;
drop.Children = header.Select(t => new GatherDropResponse() { Label = t, Value = t }).ToList();
......@@ -1362,8 +1368,9 @@ public HandsonTable GetGatherHands(int AllotId, GatherRequest request)
public void SaveGatherHands(int allotId, SaveGatherData request)
{
var dicData = CreateDataRow(0, allotId, request, Gather);
List<ex_result_gather> depts = new List<ex_result_gather>();
List<string> deptData = new List<string>();
DateTime timeNow = DateTime.Now;
foreach (var item in dicData)
{
......@@ -1374,14 +1381,24 @@ public void SaveGatherHands(int allotId, SaveGatherData request)
data.Source = request.Source;
data.Category = request.Category;
data.AllotId = allotId;
data.Submitter = request.UserId;
data.CreateTime = timeNow;
depts.Add(data);
}
deptData.Add(data.Department);
}
exresultgatherRepository.Execute($@"delete from ex_result_gather where allotid = @allotid and source like '%{request.Source}%' and category = '{request.Category}' ", new { allotId });
var delete = exresultgatherRepository.GetEntities(t => t.AllotId == allotId && deptData.Contains(t.Department) && t.Source == request.Source && t.Category == request.Category);
//exresultgatherRepository.Execute($@"delete from ex_result_gather where allotid = @allotid and department like '%{request.Department}%'and source like '%{request.Source}%' and category like '%{request.Category}%' ", new { allotId });
exresultgatherRepository.RemoveRange(delete.ToArray());
exresultgatherRepository.AddRange(depts.ToArray());
}
public bool DeleteGather(Gather gather)
{
var delete = exresultgatherRepository.GetEntities(t => t.AllotId == gather.AllotId && t.Department == gather.Department && t.Source == gather.Source && t.Category == gather.Category);
//exresultgatherRepository.Execute($@"delete from ex_result_gather where allotid = @allotid and department like '%{request.Department}%'and source like '%{request.Source}%' and category like '%{request.Category}%' ", new { allotId });
return exresultgatherRepository.RemoveRange(delete.ToArray());
}
public GatherInfo GetGather(Gather gather)
{
......@@ -1390,20 +1407,17 @@ public GatherInfo GetGather(Gather gather)
if (gather != null && !string.IsNullOrEmpty(gather.SearchQuery))
exp = exp.And(t => t.DoctorName.Contains(gather.SearchQuery) || t.PersonnelNumber.Contains(gather.SearchQuery));
var datas = exresultgatherRepository.GetEntities(exp);
var datas = exresultgatherRepository.GetEntities(exp).OrderByDescending(t=>t.CreateTime);
var result = datas.Select(t => new GatherInfoRequest
{
Source = Regex.Replace(t.Source.Replace(" ", "").Replace(".", ""), "[0-9]", ""),
CreateTime = t.CreateTime.ToString("d"),
Department = t.Department,
UserId = t.Submitter,
PersonnelNumber = t.PersonnelNumber,
DoctorName = t.DoctorName,
Detail = new GatherInfoFee
{
Category = gather.Category,
Fee = t.Fee
},
Detail = new GatherInfoFee[] { new GatherInfoFee { Category = gather.Category, Fee = t.Fee } }
});
var head = ColumnHeadsConfig.GatherHeads;
......@@ -1432,27 +1446,33 @@ public GatherResponse GetGatherTotal(Gather gather)
{
exp = exp.And(t => t.Category.Contains(gather.SearchQuery));
}
var username = userRepository.GetEntities();
if (username.FirstOrDefault(t => t.ID == gather.UserId).Login != "admin")
{
var userSource = perforcollectpermissionRepository.GetEntities(t => t.UserId == gather.UserId)
.Select(s => Regex.Replace(s.SheetName.Replace(" ", "").Replace(".", ""), "[0-9]", ""))
.Distinct().ToList();
exp = exp.And(t => userSource.Contains(t.Source));
}
var datas = exresultgatherRepository.GetEntities(exp)
.GroupBy(t => new { t.Department, t.Source, t.Category })
.Select(s => new {
.GroupBy(t => new { t.Department, t.Source, t.Category, t.Submitter })
.Select(s => new
{
Department = s.Key.Department,
Source = s.Key.Source,
Category = s.Key.Category,
UserId = s.Key.Submitter,
Login = username.FirstOrDefault(t => t.ID == s.Key.Submitter).Login,
CreateTime = s.Max(t => t.CreateTime).ToString("d"),
AuditTime = s.Max(t => t.AuditTime)?.ToString("d"),
States = s.Any(w => w.States == 1) ? "未通过"
: s.Any(w => w.States == 3) ? "审核中"
: s.Count() == s.Where(w => w.States == 2).Count() ? "已通过"
: s.Count() == s.Where(w => w.States == 0).Count() ? "未审核" : "未知",
States = s.Any(w => w.States == (int)AuditGather.未通过) ? "未通过"
: s.Count() == s.Where(w => w.States == (int)AuditGather.已通过).Count() ? "已通过"
: s.Count() == s.Where(w => w.States == (int)AuditGather.未审核).Count() ? "未审核" : "未知",
Remark = s.FirstOrDefault()?.Remark,
});
}).OrderByDescending(t=>t.CreateTime);
var ser = JsonConvert.SerializeObject(datas);
var rows = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(ser);
......@@ -1568,24 +1588,35 @@ public void CheckGatherData(int allotId, SaveGatherData saveGather)
if (!sheets.Select(t => t.SheetName).Any(t => t.Contains(saveGather.Source)))
throw new PerformanceException($"来源错误[{saveGather.Source}]");
}
}
private static void SetDataStatesAndRemark(IEnumerable<ex_result_gather> data, int states, string remark, Func<ex_result_gather, string> func = null)
var accountingUnit = userRepository.GetEntity(t => t.ID == saveGather.UserId).Login;
if (accountingUnit != "admin")
{
if (new int[] { 1, 2 }.Contains(states)) return;
var hasDept = perdeptdicRepository.GetEntities(d => d.AccountingUnit == accountingUnit).Select(s => s.HISDeptName);
var otherDept = data.Where(w => !hasDept.Contains(w[0]) && !string.IsNullOrEmpty(w[0]));
if (data == null || !data.Any()) return;
if (otherDept != null && otherDept.Any())
throw new PerformanceException($"[{string.Join(",", otherDept.Select(t => t[0]).Distinct())}]科室不属于[{accountingUnit}]核算单元,[{accountingUnit}]核算单元有[{string.Join(",", hasDept)}]科室");
}
foreach (var item in data)
{
if (func != null)
remark = string.Format(remark, func.Invoke(item));
//item.States = states;
item.Remark = (!string.IsNullOrEmpty(item.Remark) && item.Remark.Length > 0) ? item.Remark + ", " + remark : remark;
}
}
//private static void SetDataStatesAndRemark(IEnumerable<ex_result_gather> data, int states, string remark, Func<ex_result_gather, string> func = null)
//{
// if (new int[] { 1, 2 }.Contains(states)) return;
// if (data == null || !data.Any()) return;
// foreach (var item in data)
// {
// if (func != null)
// remark = string.Format(remark, func.Invoke(item));
// //item.States = states;
// item.Remark = (!string.IsNullOrEmpty(item.Remark) && item.Remark.Length > 0) ? item.Remark + ", " + remark : remark;
// }
//}
public void AddCategoryToConfig(int allotId)
{
var allot = perallotRepository.GetEntity(w => w.ID == allotId);
......@@ -1669,6 +1700,53 @@ public void SyncDataToResult(int allotId)
exresultRepository.AddRange(syncData.ToArray());
}
public void auditGather(List<Gather> gather)
{
List<ex_result_gather> ex_Result_Gathers = new List<ex_result_gather>();
var submitter = userRepository.GetEntities(u => gather.Select(g => g.UserId).Contains(u.ID));
var audit = gather.GroupBy(g => new
{
g.AllotId,
g.UserId,
g.Department,
g.Source,
g.Category
}).Select(s => new
{
s.Key.AllotId,
s.Key.UserId,
s.Key.Department,
s.Key.Source,
s.Key.Category
}).ToList();
var datas = exresultgatherRepository.GetEntities(t =>
t.AllotId == audit.FirstOrDefault().AllotId
&& audit.Select(a => a.UserId).Contains(t.Submitter)
&& audit.Select(a => a.Department).Contains(t.Department)
&& audit.Select(a => a.Source).Contains(t.Source)
&& audit.Select(a => a.Category).Contains(t.Category)
);
var gatherFirst = gather.FirstOrDefault();
if (gatherFirst.Status == "通过")
datas.ForEach(d =>
{
d.AuditTime = DateTime.Now;
d.States = (int)AuditGather.已通过;
});
else if (gatherFirst.Status == "失败")
datas.ForEach(d =>
{
d.AuditTime = DateTime.Now;
d.States = (int)AuditGather.未通过;
d.Remark = gatherFirst.Remark;
});
exresultgatherRepository.UpdateRange(datas.ToArray());
}
#endregion
}
......
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