Commit 7b2ca2d7 by ruyun.zhang

添加默认值

parent 4e202288
...@@ -331,6 +331,18 @@ public ApiResponse BatchCallIn(int allotId, int hospitalId, SaveCollectData requ ...@@ -331,6 +331,18 @@ public ApiResponse BatchCallIn(int allotId, int hospitalId, SaveCollectData requ
data.PermanentStaff = data.PermanentStaff.HasValue data.PermanentStaff = data.PermanentStaff.HasValue
? data.PermanentStaff ? data.PermanentStaff
: employees.FirstOrDefault(w => w.PersonnelNumber == data.PersonnelNumber)?.PermanentStaff; : employees.FirstOrDefault(w => w.PersonnelNumber == data.PersonnelNumber)?.PermanentStaff;
if (string.IsNullOrEmpty(data.CallInUnitType) || string.IsNullOrEmpty(data.CallInAccountingUnit))
{
var emp = employees.FirstOrDefault(w => w.PersonnelNumber == data.PersonnelNumber);
data.CallInUnitType = emp?.UnitType;
data.CallInAccountingUnit = emp?.AccountingUnit;
}
if (!data.CallInDate.HasValue || data.CallInDate.Value < new DateTime(1970, 1, 1))
{
data.CallInDate = new DateTime(allot.Year, allot.Month, 1);
}
addPer_Attendances.Add(data); addPer_Attendances.Add(data);
var any = oldCallinAttendance.FirstOrDefault(w => w.AllotId == allotId && w.HospitalId == hospitalId && w.CallInDate == data.CallInDate && w.CallInAccountingUnit?.Trim() == data.CallInAccountingUnit?.Trim() && w.CallInUnitType?.Trim() == data.CallInUnitType?.Trim() && w.PersonnelName?.Trim() == data.PersonnelName?.Trim() && w.PersonnelNumber?.Trim() == data.PersonnelNumber?.Trim()); var any = oldCallinAttendance.FirstOrDefault(w => w.AllotId == allotId && w.HospitalId == hospitalId && w.CallInDate == data.CallInDate && w.CallInAccountingUnit?.Trim() == data.CallInAccountingUnit?.Trim() && w.CallInUnitType?.Trim() == data.CallInUnitType?.Trim() && w.PersonnelName?.Trim() == data.PersonnelName?.Trim() && w.PersonnelNumber?.Trim() == data.PersonnelNumber?.Trim());
} }
...@@ -346,26 +358,51 @@ public ApiResponse BatchCallIn(int allotId, int hospitalId, SaveCollectData requ ...@@ -346,26 +358,51 @@ public ApiResponse BatchCallIn(int allotId, int hospitalId, SaveCollectData requ
public ApiResponse AttendanceAdd(int allotId, AttendanceData request) public ApiResponse AttendanceAdd(int allotId, AttendanceData request)
{ {
if (string.IsNullOrEmpty(request.PersonnelNumber))
throw new PerformanceException("人员工号必须填写");
var allot = perforPerallotRepository.GetEntity(w => w.ID == allotId); var allot = perforPerallotRepository.GetEntity(w => w.ID == allotId);
if (allot == null) if (allot == null)
throw new PerformanceException("当前绩效记录不存在"); throw new PerformanceException("当前绩效记录不存在");
var data = mapper.Map<per_attendance>(request); var data = mapper.Map<per_attendance>(request);
data.AllotId = allotId; data.AllotId = allotId;
data.HospitalId = allot.HospitalId; data.HospitalId = allot.HospitalId;
if (string.IsNullOrEmpty(request.CallInUnitType) || string.IsNullOrEmpty(request.CallInAccountingUnit))
{
var emp = perforPeremployeeRepository.GetEntity(w => w.AllotId == allotId && w.PersonnelNumber == request.PersonnelNumber);
data.CallInUnitType = emp?.UnitType;
data.CallInAccountingUnit = emp?.AccountingUnit;
}
if (!request.CallInDate.HasValue || request.CallInDate.Value < new DateTime(1970, 1, 1))
{
data.CallInDate = new DateTime(allot.Year, allot.Month, 1);
}
perforPerAttendanceRepository.Add(data); perforPerAttendanceRepository.Add(data);
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
public ApiResponse AttendanceUpdate(int allotId, AttendanceUpdateData request) public ApiResponse AttendanceUpdate(int allotId, AttendanceUpdateData request)
{ {
var allot = perforPerallotRepository.GetEntity(w => w.ID == allotId);
if (allot == null)
throw new PerformanceException("当前绩效记录不存在");
var data = perforPerAttendanceRepository.GetEntity(w => w.Id == request.AttendanceId && w.AllotId == allotId); var data = perforPerAttendanceRepository.GetEntity(w => w.Id == request.AttendanceId && w.AllotId == allotId);
if (data == null) throw new PerformanceException("当前调动记录不存在"); if (data == null) throw new PerformanceException("当前调动记录不存在");
data.PermanentStaff = request.PermanentStaff; data.PermanentStaff = request.PermanentStaff;
data.CallInUnitType = request.CallInUnitType; data.CallInUnitType = request.CallInUnitType;
data.CallInAccountingUnit = request.CallInAccountingUnit; data.CallInAccountingUnit = request.CallInAccountingUnit;
data.CallInDate = request.CallInDate; data.CallInDate = request.CallInDate;
if (string.IsNullOrEmpty(request.CallInUnitType) || string.IsNullOrEmpty(request.CallInAccountingUnit))
{
var emp = perforPeremployeeRepository.GetEntity(w => w.AllotId == allotId && w.PersonnelNumber == data.PersonnelNumber);
data.CallInUnitType = emp?.UnitType;
data.CallInAccountingUnit = emp?.AccountingUnit;
}
if (!request.CallInDate.HasValue || request.CallInDate.Value < new DateTime(1970, 1, 1))
{
data.CallInDate = new DateTime(allot.Year, allot.Month, 1);
}
perforPerAttendanceRepository.Update(data); perforPerAttendanceRepository.Update(data);
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
......
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