Commit f49b1c57 by 李承祥

清除历史记录以及copy配置

parent 1e3f69cb
......@@ -112,7 +112,7 @@ public ApiResponse Import([FromForm] IFormCollection form)
var file = ((FormFileCollection)form.Files).FirstOrDefault();
if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "allotid无效");
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
var allot = _allotService.GetAllot(allotid);
if (allot == null)
......@@ -136,6 +136,8 @@ public ApiResponse Import([FromForm] IFormCollection form)
allot.UploadDate = DateTime.Now;
if (!_allotService.Update(allot))
return new ApiResponse(ResponseType.Fail, $"{file.FileName}上传成功,修改状态失败");
_perExcelService.Clear(allot.ID);
_perExcelService.Copy(allot);
}
return new ApiResponse(ResponseType.OK);
......@@ -148,8 +150,8 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody]Al
var allot = _allotService.GetAllot(request.ID);
if (null == allot || string.IsNullOrEmpty(allot.Path))
throw new PerformanceException("当前绩效记录不存在或没有上传数据文件");
//_perExcelService.Execute(allot);
BackgroundJob.Enqueue(() => _perExcelService.Execute(allot));
_perExcelService.Execute(allot);
//BackgroundJob.Enqueue(() => _perExcelService.Execute(allot));
return new ApiResponse(ResponseType.OK);
}
}
......
......@@ -27,8 +27,15 @@ public class PerExcelService : IAutoInjection
private PerforResAccountnurseRepository _perforImaccountnurseRepository;
private PerforCofpositionRepository _perforCofpositionRepository;
private PerforCofdirectorRepository _perforCofdirectorRepository;
private PerforCofdrugpropRepository _perforCofdrugpropRepository;
private PerforCofincomeRepository _perforCofincomeRepository;
private PerforCofworkyearRepository _perforCofworkyearRepository;
private PerforResAccountdoctorRepository _perforResAccountdoctorRepository;
private PerforResAccountnurseRepository _perforResAccountnurseRepository;
private PerforResbaiscnormRepository _perforResbaiscnormRepository;
private PerforRescomputeRepository _perforRescomputeRepository;
private PerforPerAllotRepository _perforPerAllotRepository;
public PerExcelService(PerSheetService perSheetService,
PerHeaderService perHeaderService,
PerforPerSheetRepository perforImSheetRepository,
......@@ -40,8 +47,14 @@ public class PerExcelService : IAutoInjection
PerforResAccountnurseRepository perforImaccountnurseRepository,
PerforCofpositionRepository perforCofpositionRepository,
PerforCofdirectorRepository perforCofdirectorRepository,
PerforCofdrugpropRepository perforCofdrugpropRepository,
PerforCofincomeRepository perforCofincomeRepository,
PerforCofworkyearRepository perforCofworkyearRepository,
PerforResAccountdoctorRepository perforResAccountdoctorRepository,
PerforResAccountnurseRepository perforResAccountnurseRepository)
PerforResAccountnurseRepository perforResAccountnurseRepository,
PerforResbaiscnormRepository perforResbaiscnormRepository,
PerforRescomputeRepository perforRescomputeRepository,
PerforPerAllotRepository perforPerAllotRepository)
{
_perSheetService = perSheetService;
_perHeaderService = perHeaderService;
......@@ -56,15 +69,21 @@ public class PerExcelService : IAutoInjection
_perforResAccountdoctorRepository = perforResAccountdoctorRepository;
_perforResAccountnurseRepository = perforResAccountnurseRepository;
_perforCofdirectorRepository = perforCofdirectorRepository;
_perforCofdrugpropRepository = perforCofdrugpropRepository;
_perforCofincomeRepository = perforCofincomeRepository;
_perforCofworkyearRepository = perforCofworkyearRepository;
_perforResbaiscnormRepository = perforResbaiscnormRepository;
_perforRescomputeRepository = perforRescomputeRepository;
_perforPerAllotRepository = perforPerAllotRepository;
}
public void Execute(per_allot allot)
{
//清空当前绩效下数据
Clear(allot.ID);
//Clear(allot.ID);
// 拷贝配置信息
Copy(allot.ID);
//Copy(allot.ID);
// 导出数据
var excel = Import(allot.Path);
......@@ -90,9 +109,38 @@ private void SendEmail(per_allot allot)
}
private void Clear(int iD)
public void Clear(int allotId)
{
var director = _perforCofdirectorRepository.GetEntities(t => t.AllotID == allotId);
if (director != null)
{
foreach (var item in director)
_perforCofdirectorRepository.Remove(item);
}
var durgprop = _perforCofdrugpropRepository.GetEntities(t => t.AllotID == allotId);
if (durgprop != null)
{
foreach (var item in durgprop)
_perforCofdrugpropRepository.Remove(item);
}
var income = _perforCofincomeRepository.GetEntities(t => t.AllotID == allotId);
if (income != null)
{
foreach (var item in income)
_perforCofincomeRepository.Remove(item);
}
var position = _perforCofpositionRepository.GetEntities(t => t.AllotID == allotId);
if (position != null)
{
foreach (var item in position)
_perforCofpositionRepository.Remove(item);
}
var workyear = _perforCofworkyearRepository.GetEntities(t => t.AllotID == allotId);
if (workyear != null)
{
foreach (var item in workyear)
_perforCofworkyearRepository.Remove(item);
}
}
/// <summary>
......@@ -132,9 +180,69 @@ public PerExcel Import(string path)
/// 复制报表基础配置
/// </summary>
/// <param name="iD"></param>
public void Copy(int iD)
public void Copy(per_allot allot)
{
//throw new NotImplementedException();
var list = _perforPerAllotRepository.GetEntities(t => t.HospitalId == allot.HospitalId)
.OrderByDescending(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;
}
if (allotId > 0)
{
var director = _perforCofdirectorRepository.GetEntities(t => t.AllotID == allotId);
if (director != null)
{
foreach (var item in director)
{
item.ID = 0;
item.AllotID = allot.ID;
_perforCofdirectorRepository.Add(item);
}
}
var durgprop = _perforCofdrugpropRepository.GetEntities(t => t.AllotID == allotId);
if (durgprop != null)
{
foreach (var item in durgprop)
{
item.ID = 0;
item.AllotID = allot.ID;
_perforCofdrugpropRepository.Add(item);
}
}
var income = _perforCofincomeRepository.GetEntities(t => t.AllotID == allotId);
if (income != null)
{
foreach (var item in income)
{
item.ID = 0;
item.AllotID = allot.ID;
_perforCofincomeRepository.Add(item);
}
}
var position = _perforCofpositionRepository.GetEntities(t => t.AllotID == allotId);
if (position != null)
{
foreach (var item in position)
{
item.ID = 0;
item.AllotID = allot.ID;
_perforCofpositionRepository.Add(item);
}
}
var workyear = _perforCofworkyearRepository.GetEntities(t => t.AllotID == allotId);
if (workyear != null)
{
foreach (var item in workyear)
{
item.ID = 0;
item.AllotID = allot.ID;
_perforCofworkyearRepository.Add(item);
}
}
}
}
/// <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