Commit 3ed95802 by lcx

新增绩效copy数据时方法调整

parent 3fcacf6d
......@@ -890,25 +890,25 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request)
/// <param name="iD"></param>
public void Copy(per_allot allot)
{
var list = perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId)
.OrderBy(t => t.Year).ThenBy(t => t.Month).ToList();
int allotId = 0;
for (int i = 0; i < list.Count; i++)
{
if (list[i].ID == allot.ID && (i - 1) >= 0)
allotId = list[i - 1].ID;
}
var hospital = perforHospitalRepository.GetEntity(t => t.ID == allot.HospitalId);
var list = perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId);
if (list == null || !list.Any(t => t.ID == allot.ID)) return;
logger.LogInformation($"apramount{allotId} {allot.ID}");
//CopyAprData(allotId, allot.ID);
list = list.OrderByDescending(t => t.Year).ThenByDescending(t => t.Month).ToList();
personService.CreateAllotPersons(allot.HospitalId, allot.ID, allotId);
var index = list.IndexOf(list.First(t => t.ID == allot.ID));
//CopyCMIData(allotId, allot.ID);
// 先取上一个月的绩效Id,若没有取最后一个月的绩效Id,若都不存在则获取allotId为-1的数据
int allotId = index == list.Count - 1 ? list.First().ID : list[index - 1].ID;
if (allotId == allot.ID) allotId = -1;
#region 弃用
//var hospital = perforHospitalRepository.GetEntity(t => t.ID == allot.HospitalId);
//logger.LogInformation($"apramount{allotId} {allot.ID}");
//CopyAprData(allotId, allot.ID);
//CopyCMIData(allotId, allot.ID);
//var orgDirector = _directorRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgDirector == null || orgDirector.Count == 0)
//{
......@@ -939,8 +939,6 @@ public void Copy(per_allot allot)
// _workyearRepository.AddRange(newWorkyears.ToArray());
//}
#endregion
//logger.LogInformation($"orgDurgprop");
//var orgDurgprop = _drugpropRepository.GetEntities(t => t.AllotID == allot.ID);
//if (orgDurgprop == null || orgDurgprop.Count == 0)
......@@ -953,44 +951,54 @@ public void Copy(per_allot allot)
// _drugpropRepository.AddRange(newDurgprops.ToArray());
//}
logger.LogInformation($"workItem");
var workItem = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
if (workItem == null || workItem.Count == 0)
#endregion
personService.CreateAllotPersons(allot.HospitalId, allot.ID, allotId);
logger.LogInformation($"copy workItems");
var workItems = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
if (workItems == null || !workItems.Any())
{
workItem = _workitemRepository.GetEntities(t => t.AllotID == allotId) ?? _workitemRepository.GetEntities(t => t.AllotID == -1);
if (workItem != null && workItem.Count > 0)
workItems = _workitemRepository.GetEntities(t => t.AllotID == allotId) ?? _workitemRepository.GetEntities(t => t.AllotID == -1);
if (workItems != null && workItems.Any())
{
var newWorkItem = workItem.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
_workitemRepository.AddRange(newWorkItem.ToArray());
var newWorkItems = workItems.Select(t => new cof_workitem { AllotID = allot.ID, Type = t.Type, Item = t.Item });
_workitemRepository.AddRange(newWorkItems.ToArray());
}
}
logger.LogInformation($"cofDrugtype");
var cofDrugtype = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (cofDrugtype == null || cofDrugtype.Count == 0)
logger.LogInformation($"copy drugTypes");
var drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (drugTypes == null || !drugTypes.Any())
{
drugTypes = _drugtypeRepository.GetEntities(t => t.AllotID == allotId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
if (drugTypes != null && drugTypes.Any())
{
var drugtype = _drugtypeRepository.GetEntities(t => t.AllotID == allotId) ?? _drugtypeRepository.GetEntities(t => t.AllotID == -1);
var newAgains = drugtype.Select(t => new cof_drugtype { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeRepository.AddRange(newAgains.ToArray());
var newDrugTypes = drugTypes.Select(t => new cof_drugtype { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
_drugtypeRepository.AddRange(newDrugTypes.ToArray());
}
}
logger.LogInformation($"cofDrugtypeDisburse");
var cofDrugtypeDisburse = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID);
if (cofDrugtypeDisburse == null || cofDrugtypeDisburse.Count == 0)
logger.LogInformation($"copy drugTypeDisburses");
var drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allot.ID);
if (drugTypeDisburses == null || !drugTypeDisburses.Any())
{
var Disburse = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId)
?? drugtypeDisburseRepository.GetEntities(t => t.AllotID == -1);
var newAgains = Disburse.Select(t => new cof_drugtype_disburse { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
drugtypeDisburseRepository.AddRange(newAgains.ToArray());
drugTypeDisburses = drugtypeDisburseRepository.GetEntities(t => t.AllotID == allotId) ?? drugtypeDisburseRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeDisburses != null && drugTypeDisburses.Any())
{
var newDrugTypeDisburses = drugTypeDisburses.Select(t => new cof_drugtype_disburse { HospitalId = allot.HospitalId, AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
drugtypeDisburseRepository.AddRange(newDrugTypeDisburses.ToArray());
}
}
logger.LogInformation($"cofDrugtypefactor");
var cofDrugtypeFactor = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allot.ID);
if (cofDrugtypeFactor == null || cofDrugtypeFactor.Count == 0)
logger.LogInformation($"copy drugTypeFactors");
var drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allot.ID);
if (drugTypeFactors == null || !drugTypeFactors.Any())
{
drugTypeFactors = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allotId) ?? cofdrugtypefactorRepository.GetEntities(t => t.AllotID == -1);
if (drugTypeFactors != null && drugTypeFactors.Any())
{
var drugtypefactor = cofdrugtypefactorRepository.GetEntities(t => t.AllotID == allotId) ?? cofdrugtypefactorRepository.GetEntities(t => t.AllotID == -1);
var newdrugtypefactor = drugtypefactor?.Select(t => new cof_drugtype_factor
var newDrugtypeFactors = drugTypeFactors.Select(t => new cof_drugtype_factor
{
HospitalId = allot.HospitalId,
AllotID = allot.ID,
......@@ -998,42 +1006,47 @@ public void Copy(per_allot allot)
Charge = t.Charge,
YSZ = t.YSZ,
HLZ = t.HLZ,
YJZ = t.YJZ,
YJZ = t.YJZ
});
if (newdrugtypefactor != null && newdrugtypefactor.Any())
cofdrugtypefactorRepository.AddRange(newdrugtypefactor.ToArray());
cofdrugtypefactorRepository.AddRange(newDrugtypeFactors.ToArray());
}
}
logger.LogInformation($"cofDepttype");
var cofDepttype = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (cofDepttype == null || cofDepttype.Count == 0)
logger.LogInformation($"copy deptTypes");
var deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (deptTypes == null || !deptTypes.Any())
{
deptTypes = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId) ?? perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
if (deptTypes != null && deptTypes.Any())
{
var depttype = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId)
?? perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
var newAgains = depttype?.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
if (newAgains != null && newAgains.Any())
perforCofdepttypeRepository.AddRange(newAgains.ToArray());
var newDeptTypes = deptTypes.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
perforCofdepttypeRepository.AddRange(newDeptTypes.ToArray());
}
}
logger.LogInformation($"again");
var data = _againRepository.GetEntities(t => t.AllotID == allot.ID);
if (data == null || data.Count == 0)
logger.LogInformation($"copy agains");
var agains = _againRepository.GetEntities(t => t.AllotID == allot.ID);
if (agains == null || !agains.Any())
{
agains = _againRepository.GetEntities(t => t.AllotID == allotId) ?? _againRepository.GetEntities(t => t.AllotID == -1);
if (agains != null && agains.Any())
{
var again = _againRepository.GetEntities(t => t.AllotID == allotId) ?? _againRepository.GetEntities(t => t.AllotID == -1);
var days = DateTime.DaysInMonth(allot.Year, allot.Month);
var newAgains = again.Select(t => new cof_again
{ AllotID = allot.ID, Type = t.Type, Department = t.Department, TypeName = t.TypeName, Value = t.TypeName == "满勤天数" ? days : t.Value });
var newAgains = agains.Select(t => new cof_again { AllotID = allot.ID, Type = t.Type, Department = t.Department, TypeName = t.TypeName, Value = t.TypeName == "满勤天数" ? days : t.Value });
_againRepository.AddRange(newAgains.ToArray());
}
}
logger.LogInformation($"accounting");
logger.LogInformation($"copy accountings");
var accountings = cofaccountingRepository.GetEntities(t => t.AllotId == allot.ID);
if (accountings == null || accountings.Count == 0)
if (accountings == null || !accountings.Any())
{
accountings = cofaccountingRepository.GetEntities(t => t.AllotId == allotId) ?? cofaccountingRepository.GetEntities(t => t.AllotId == -1);
if (accountings != null && accountings.Any())
{
var prevData = cofaccountingRepository.GetEntities(t => t.AllotId == allotId);
var newData = prevData?.Select(t => new cof_accounting { AllotId = allot.ID, UnitType = t.UnitType, AccountingUnit = t.AccountingUnit });
if (newData != null && newData.Any())
cofaccountingRepository.AddRange(newData.ToArray());
var newAccountings = accountings.Select(t => new cof_accounting { AllotId = allot.ID, UnitType = t.UnitType, AccountingUnit = t.AccountingUnit });
cofaccountingRepository.AddRange(newAccountings.ToArray());
}
}
}
......
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