Commit 55a85fed by 钟博

修改重新加载人员字典问题

parent b4255d09
......@@ -278,10 +278,13 @@ public ApiResponse SaveDeptHands(int hospitalId, SaveCollectData request)
/// <returns></returns>
[HttpPost]
[Route("peson/{hospitalId}/reloadPersonnel/{allotId}")]
public ApiResponse ReloadPersonnel(int hospitalId,int allotId)
public ApiResponse ReloadPersonnel(int hospitalId, int allotId)
{
personService.ReloadPersonnel(hospitalId, allotId);
return new ApiResponse(ResponseType.OK);
var result = personService.ReloadPersonnel(hospitalId, allotId);
if (result)
return new ApiResponse(ResponseType.OK, result);
else
return new ApiResponse(ResponseType.Error, result);
}
}
}
......@@ -1001,52 +1001,74 @@ public string GetPersonDictFile(int allotId, int userId)
return filepath;
}
public void ReloadPersonnel(int hospitalId, int allotId)
public bool ReloadPersonnel(int hospitalId, int allotId)
{
var allotList = perallotRepository.GetEntities(w => w.HospitalId == hospitalId)?.OrderBy(s => s.Year).ThenBy(s => s.Month).ToList();
if (allotList == null || !allotList.Any()) return;
if (allotList == null || !allotList.Any())
throw new PerformanceException("加载失败,绩效记录不存在!");
var allot = allotList.FirstOrDefault(w => w.ID == allotId);
if (allot == null) return;
if (allot == null)
throw new PerformanceException("加载失败,绩效记录不存在!");
var index = allotList.IndexOf(allot);
if (index == 0) return;
if (index == 0)
throw new PerformanceException("加载失败,绩效记录不存在!");
var prevAllot = allotList[index - 1];
if (prevAllot == null) prevAllot.ID = -1;
var persons = peremployeeRepository.GetEntities(t => t.HospitalId == hospitalId && t.AllotId == prevAllot.ID);
if (persons == null || !persons.Any()) return;
if (persons == null || !persons.Any())
throw new PerformanceException("加载失败,未查询到上月人员信息!");
var i = peremployeeRepository.Execute($@"DELETE FROM per_employee WHERE HospitalId=@HospitalId and AllotId=@AllotId;", new { hospitalId, allotId });
if (i <= 0) return;
if (i <= 0)
throw new PerformanceException("加载失败,人员信息重置失败!");
int day = DateTime.DaysInMonth(allot.Year, allot.Month);
var data = persons.Select(t => new per_employee
var data = persons.Select(t =>
{
HospitalId = t.HospitalId,
AllotId = allotId,
AccountingUnit = t.AccountingUnit,
Department = t.Department,
DoctorName = t.DoctorName,
JobCategory = t.JobCategory,
Duty = t.Duty,
JobTitle = t.JobTitle,
UnitType = t.UnitType,
AttendanceDay = day,
Attendance = 1,
PermanentStaff = t.PermanentStaff,
EfficiencyNumber = t.EfficiencyNumber,
WorkTime = t.WorkTime,
BirthDate = t.BirthDate,
Age = t.Age,
ReservedRatio = t.ReservedRatio,
BankCard = t.BankCard,
Remark = t.Remark,
CreateTime = DateTime.Now,
var entity = new per_employee
{
HospitalId = t.HospitalId,
AllotId = allotId,
AccountingUnit = t.AccountingUnit,
Department = t.Department,
DoctorName = t.DoctorName,
JobCategory = t.JobCategory,
Duty = t.Duty,
JobTitle = t.JobTitle,
UnitType = t.UnitType,
AttendanceDay = day,
Attendance = 1,
PermanentStaff = t.PermanentStaff,
EfficiencyNumber = t.EfficiencyNumber,
WorkTime = t.WorkTime,
BirthDate = t.BirthDate,
Age = t.Age,
ReservedRatio = t.ReservedRatio,
BankCard = t.BankCard,
Remark = t.Remark,
CreateTime = DateTime.Now,
};
if (!string.IsNullOrEmpty(t.PersonnelNumber) && !string.IsNullOrEmpty(t.JobNumber))
{
entity.PersonnelNumber = t.PersonnelNumber;
entity.JobNumber = t.JobNumber;
}
else
{
string number = !string.IsNullOrEmpty(t.PersonnelNumber) ? t.PersonnelNumber : t.JobNumber;
entity.PersonnelNumber = number;
entity.JobNumber = number;
}
return entity;
}).ToList();
SaveAllotPersons(data);
return true;
}
}
}
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