Commit 3ec2b9d6 by 钟博

Merge branch '新增HRP人员科室' into v2020morge

# Conflicts:
#	performance/Performance.EntityModels/Context/PerformanceDbContext.cs
parents d36f3b19 5da68974
......@@ -535,5 +535,44 @@ public ApiResponse WorkHeader([CustomizeValidator(RuleSet = "Select"), FromBody]
var list = _configService.WorkHeader(request.AllotID);
return new ApiResponse(ResponseType.OK, "ok", list);
}
#region HRP人员科室
/// <summary>
/// 获取HRP人员科室
/// </summary>
/// <param name="hospitalId"></param>
/// <param name="allotId"></param>
/// <returns></returns>
[Route("hrpdepthands/{hospitalId}/allot/{allotId}")]
[HttpPost]
public ApiResponse GetHrpDeptHands([FromRoute] int hospitalId, int allotId)
{
if (hospitalId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "HospitalId无效");
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
var relust = _configService.GetHrpDeptHands(hospitalId, allotId);
return new ApiResponse(ResponseType.OK, relust);
}
/// <summary>
/// 保存HRP人员科室
/// </summary>
/// <param name=""></param>
/// <returns></returns>
[Route("savehrpdept/{hospitalId}/allot/{allotId}")]
[HttpPost]
public ApiResponse SaveHrpDept(int hospitalId, int allotId, [FromBody] SaveCollectData request)
{
if (hospitalId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "HospitalId无效");
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
_configService.SaveDepttypeHands(hospitalId, allotId, request);
return new ApiResponse(ResponseType.OK);
}
#endregion
}
}
\ No newline at end of file
......@@ -78,7 +78,8 @@ public PerformanceDbContext(DbContextOptions<PerformanceDbContext> options)
public virtual DbSet<cof_workloadtype> cof_workloadtype { get; set; }
/// <summary> 工龄对应绩效系数配置 </summary>
public virtual DbSet<cof_workyear> cof_workyear { get; set; }
/// <summary> </summary>
/// <summary> </summary>
public virtual DbSet<collect_data> collect_data { get; set; }
/// <summary> </summary>
public virtual DbSet<collect_permission> collect_permission { get; set; }
......
using System;
using System.Collections.Generic;
using System.Text;
using Performance.EntityModels;
namespace Performance.Repository.Repository
{
public partial class PerforCofHrpDeptRepository:PerforRepository<cof_hrp_department>
{
public PerforCofHrpDeptRepository(PerformanceDbContext context) : base(context)
{
}
}
}
......@@ -9,6 +9,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Performance.Repository.Repository;
namespace Performance.Services
{
......@@ -27,6 +28,7 @@ public class ConfigService : IAutoInjection
private PerforCofdepttypeRepository perforCofdepttypeRepository;
private PerforPerapramountRepository perapramountRepository;
//private PerforCofcmiRepository perforCofcmiRepository;
private PerforCofHrpDeptRepository perforCofHrpDeptRepository;
private PersonService personService;
private LogManageService logManageService;
private ILogger<ConfigService> logger;
......@@ -43,6 +45,7 @@ public class ConfigService : IAutoInjection
PerforCofdepttypeRepository perforCofdepttypeRepository,
PerforPerapramountRepository perapramountRepository,
//PerforCofcmiRepository perforCofcmiRepository,
PerforCofHrpDeptRepository perforCofHrpDeptRepository,
PersonService personService,
LogManageService logManageService,
ILogger<ConfigService> logger)
......@@ -59,6 +62,7 @@ public class ConfigService : IAutoInjection
this.perforCofdepttypeRepository = perforCofdepttypeRepository;
this.perapramountRepository = perapramountRepository;
//this.perforCofcmiRepository = perforCofcmiRepository;
this.perforCofHrpDeptRepository = perforCofHrpDeptRepository;
this.personService = personService;
this.logManageService = logManageService;
this.logger = logger;
......@@ -834,6 +838,95 @@ private void CopyAprData(int prevAllotId, int allotId)
}
}
public HandsonTable GetHrpDeptHands(int HospitalId,int AllotId)
{
var result = new HandsonTable((int)SheetType.Unidentifiable, HrpDept.Select(t => t.Value).ToArray(), HrpDept.Select(t => new collect_permission
{
HeadName = t.Value,
Visible = 1
}).ToList());
var data = perforCofHrpDeptRepository.GetEntities(t => t.HospitalId == HospitalId && t.AllotId == AllotId);
if (data == null)
return result;
List<HandsonRowData> rowDatas = new List<HandsonRowData>();
int i = 1;
foreach (var item in data)
{
var json = JsonHelper.Serialize(item);
var firstDic = JsonHelper.Deserialize<Dictionary<string, string>>(json);
var cells = (from conf in HrpDept join fst in firstDic on conf.Key.ToUpper() equals fst.Key.ToUpper() select new HandsonCellData(conf.Value, fst.Value)).ToList();
rowDatas.Add(new HandsonRowData(i, cells));
i++;
}
result.SetRowData(rowDatas, rowDatas != null);
return result;
}
public void SaveDepttypeHands(int hospitalId, int allotId,SaveCollectData request)
{
var dicData = CreateDataRow(hospitalId,allotId, request, HrpDept);
List<cof_hrp_department> depts = new List<cof_hrp_department>();
foreach (var item in dicData)
{
var json = JsonHelper.Serialize(item);
var data = JsonHelper.Deserialize<cof_hrp_department>(json);
if (!string.IsNullOrEmpty(data.HRPDepartment) && !string.IsNullOrEmpty(data.AccountingUnit))
{
data.HospitalId = hospitalId;
data.AllotId = allotId;
depts.Add(data);
}
}
perforCofHrpDeptRepository.Execute("delete from cof_hrp_department where HospitalId=@hospitalId and allotid = @allotid"
, new {hospitalId, allotId });
perforCofHrpDeptRepository.AddRange(depts.ToArray());
}
private List<Dictionary<string, string>> CreateDataRow(int hospitalId, int allotId, SaveCollectData request, Dictionary<string, string> config)
{
List<Dictionary<string, string>> allData = new List<Dictionary<string, string>>();
for (int r = 0; r < request.Data.Length; r++)
{
// 创建固定数据列
Dictionary<string, string> baseData = CreateBaseData(request, config, r);
baseData.Add(nameof(cof_hrp_department.AllotId), allotId.ToString());
baseData.Add(nameof(cof_hrp_department.HospitalId),hospitalId.ToString());
allData.Add(baseData);
}
return allData;
}
private Dictionary<string, string> CreateBaseData(SaveCollectData request, Dictionary<string, string> config, int rownumber)
{
Dictionary<string, string> result = new Dictionary<string, string>();
for (int c = 0; c < request.ColHeaders.Length; c++)
{
var header = request.ColHeaders[c];
var first = config.FirstOrDefault(w => w.Value == header);
if (!default(KeyValuePair<string, string>).Equals(first)
&& !result.ContainsKey(header)
&& request.Data[rownumber].Length > c)
{
result.Add(first.Key, request.Data[rownumber][c]);
}
}
return result;
}
public static Dictionary<string, string> HrpDept { get; } = new Dictionary<string, string>
{
{nameof(cof_hrp_department.HRPDepartment), "hrp人员科室"},
{nameof(cof_hrp_department.AccountingUnit), "核算单元"},
};
///// <summary>
///// CMI值
///// </summary>
......
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