Commit dd4cd599 by 钟博

HRP保存

parent ff53294f
......@@ -569,8 +569,8 @@ public ApiResponse SaveHrpDept(int hospitalId, int allotId, [FromBody] SaveColle
if (hospitalId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "HospitalId无效");
if (allotId <= 0)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
_configService.SaveDepttypeHands(hospitalId, allotId, request);
return new ApiResponse(ResponseType.OK);
}
#endregion
......
......@@ -866,8 +866,61 @@ public HandsonTable GetHrpDeptHands(int HospitalId,int AllotId)
return result;
}
public void SaveDepttypeHands(int hospitalId, int allotId,SaveCollectData request)
{
var dicData = CreateDataRow(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))
{
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 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(collect_data.AllotID), allotId.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人员科室"},
......
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