Commit 7ec5bd17 by lcx

绩效下发

parent b5931dfa
......@@ -237,5 +237,21 @@ public ApiResponse AllotLog([CustomizeValidator(RuleSet = "Delete"), FromBody]Al
var list = _allotService.AllotLog(allot);
return new ApiResponse(ResponseType.OK, list);
}
/// <summary>
/// 绩效审核通过,绩效下发
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[Route("issued")]
[HttpPost]
public ApiResponse Issued([FromBody]AllotRequest request)
{
var allot = _allotService.GetAllot(request.ID);
if (null == allot)
throw new PerformanceException("当前绩效记录不存在");
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
return new ApiResponse(ResponseType.OK);
}
}
}
......@@ -186,6 +186,13 @@
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.AllotController.Issued(Performance.DtoModels.AllotRequest)">
<summary>
绩效审核通过,绩效下发
</summary>
<param name="request"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ComputeController.GetCompute(Performance.DtoModels.ComputerRequest)">
<summary>
获取绩效发放列表
......
......@@ -129,7 +129,7 @@
<summary> 正在生成绩效 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.GenerateSucceed">
<summary> 绩效结果解析成功 </summary>
<summary> 绩效结果通过审核,允许下发 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.GenerateFail">
<summary> 绩效解析失败 </summary>
......@@ -140,6 +140,9 @@
<member name="F:Performance.DtoModels.AllotStates.Wait">
<summary> 归档 </summary>
</member>
<member name="F:Performance.DtoModels.AllotStates.GenerateAccomplish">
<summary> 绩效结果解析成功 </summary>
</member>
<member name="P:Performance.DtoModels.PerAgainData.RowNumber">
<summary>
行号
......
......@@ -65,7 +65,7 @@ public enum AllotStates
/// <summary> 正在生成绩效 </summary>
[Description("正在生成绩效")]
InGenerate = 5,
/// <summary> 绩效结果解析成功 </summary>
/// <summary> 绩效结果通过审核,允许下发 </summary>
[Description("数据验证通过")]
GenerateSucceed = 6,
/// <summary> 绩效解析失败 </summary>
......@@ -77,5 +77,8 @@ public enum AllotStates
/// <summary> 归档 </summary>
[Description("等待")]
Wait = 9,
/// <summary> 绩效结果解析成功 </summary>
[Description("数据验证通过")]
GenerateAccomplish = 10,
}
}
......@@ -49,7 +49,7 @@ public class rep_importconfig
/// <summary>
/// 时间范围 1 当前 2 同期 3 上期
/// </summary>
public int TimeRange { get; set; }
public string TimeRange { get; set; }
/// <summary>
/// 是否有效 1 有效 0 无效
......
......@@ -137,6 +137,9 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
path = Path.Combine(dpath, FileHelper.GetFileName(file.FileName));
logger.LogInformation($"保存历史绩效文件保存路径:" + path);
if (!string.IsNullOrEmpty(path) && FileHelper.IsExistFile(path))
FileHelper.DeleteFile(path);
using (var stream = file.OpenReadStream())
{
byte[] bytes = new byte[stream.Length];
......@@ -151,10 +154,7 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
//string filePath = newExtractService.ExtractData(allotId, request.Email, hospitalId);
string filePath = dfExtractService.ExtractData(allotId, email, hospitalId, path); //抽取
if (!string.IsNullOrEmpty(path) && FileHelper.IsExistFile(path))
FileHelper.DeleteFile(path);
#region 保存文件到网站下
if (!string.IsNullOrEmpty(filePath) && FileHelper.IsExistFile(filePath))
......
......@@ -302,7 +302,7 @@ public void Generate(per_allot allot, string mail)
logManageService.WriteMsg("正在生成绩效", "保存绩效人均参考标准", 1, allot.ID, "ReceiveMessage", true);
perforResbaiscnormRepository.AddRange(baiscnormList.ToArray());
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateSucceed, EnumHelper.GetDescription(AllotStates.GenerateSucceed));
UpdateAllotStates(allot.ID, (int)AllotStates.GenerateAccomplish, EnumHelper.GetDescription(AllotStates.GenerateAccomplish));
logManageService.WriteMsg("正在生成报表数据", "正在生成报表数据", 1, allot.ID, "ReceiveMessage", true);
var res = reportService.ImportData(allot);
......
......@@ -36,6 +36,7 @@ public class DFExtractService : IAutoInjection
private readonly PerforImaccountbasicRepository perforImaccountbasicRepository;
private readonly PerforImspecialunitRepository perforImspecialunitRepository;
private readonly PerforImdataRepository perforImdataRepository;
private readonly PerforRepimportconfigRepository repimportconfigRepository;
private readonly LogManageService logManageService;
private IWorkbook workbook = null;
......@@ -58,6 +59,7 @@ public class DFExtractService : IAutoInjection
PerforImaccountbasicRepository perforImaccountbasicRepository,
PerforImspecialunitRepository perforImspecialunitRepository,
PerforImdataRepository perforImdataRepository,
PerforRepimportconfigRepository repimportconfigRepository,
LogManageService logManageService)
{
this.logger = logger;
......@@ -76,6 +78,7 @@ public class DFExtractService : IAutoInjection
this.perforImaccountbasicRepository = perforImaccountbasicRepository;
this.perforImspecialunitRepository = perforImspecialunitRepository;
this.perforImdataRepository = perforImdataRepository;
this.repimportconfigRepository = repimportconfigRepository;
this.logManageService = logManageService;
}
#endregion
......@@ -191,6 +194,8 @@ public string TemplateExecute(string email, per_allot lastAllot, sys_hospital ho
}
logManageService.WriteMsg("提取绩效数据", $"{hospital.HosName}HIS数据提取成功,文件路径:{newPath}。", 5, Allot.ID, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 {hospital.HosName}HIS数据提取成功,文件路径:{newPath}。");
ImportData(Allot, configs);
SendEmail(email, newPath, $"{hospital.HosName}HIS数据提取成功", $"{hospital.HosName}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}成功提取。");
return newPath;
}
......@@ -259,6 +264,8 @@ public string AlllotExecute(string email, per_allot lastAllot, sys_hospital hosp
}
logManageService.WriteMsg("提取绩效数据", $"{hospital.HosName}HIS数据提取成功,文件路径:{newPath}。", 5, Allot.ID, "ReceiveMessage");
logger.LogInformation($"提取绩效数据 {hospital.HosName}HIS数据提取成功,文件路径:{newPath}。");
ImportData(Allot, configs);
SendEmail(email, newPath, $"{hospital.HosName}HIS数据提取成功", $"{hospital.HosName}{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}成功提取。");
return newPath;
}
......@@ -849,6 +856,64 @@ private List<ExtractDto> QueryDatabase(sys_hospitalconfig config, mod_extract ex
return pairs;
}
/// <summary>
/// 从HIS抽取报表数据
/// </summary>
/// <param name="allot"></param>
/// <param name="configs"></param>
public void ImportData(per_allot allot, List<sys_hospitalconfig> configs)
{
Dictionary<string, object> pairs = new Dictionary<string, object>
{
{ "@allotid", allot.ID },
{ "@hospitalid", allot.HospitalId },
{ "@year", allot.Year },
{ "@month", allot.Month },
};
var imports = repimportconfigRepository.GetEntities(w => w.ScriptType == 1);
if (imports == null || !imports.Any()) return;
foreach (var import in imports)
{
var conf = configs.FirstOrDefault(w => w.HospitalId == allot.HospitalId && w.Id == import.ConfigId);
if (conf != null)
{
var timeRanges = import.TimeRange.SplitRemoveEmpty(",");
if (timeRanges == null || !timeRanges.Any()) continue;
foreach (var item in timeRanges)
{
if (item == "1")
{
pairs["@year"] = allot.Year;
pairs["@month"] = allot.Month;
}
else if (item == "2")
{
pairs["@year"] = allot.Year - 1;
pairs["@month"] = allot.Month;
}
else if (item == "3")
{
pairs["@year"] = allot.Year;
pairs["@month"] = allot.Month - 1;
}
try
{
DatabaseType type = (DatabaseType)conf.DataBaseType;
var connection = ConnectionBuilder.Create(type, conf.DbSource, conf.DbName, conf.DbUser, conf.DbPassword);
var data = connection.Query(import.ImportScript, new DynamicParameters(pairs), commandTimeout: 60 * 60);
perforPerallotRepository.ImportData(import, pairs, data);
}
catch (Exception ex)
{
logger.LogError(ex.ToString());
}
}
}
}
}
#endregion
#region Common
......@@ -872,7 +937,7 @@ private void SendEmail(string mail, string path, string subject, string body)
};
if (!string.IsNullOrEmpty(path))
message.Attachments = new List<string> { path };
emailService.Send(message);
//emailService.Send(message);
}
/// <summary>
......
......@@ -213,17 +213,17 @@ public void ImportData(per_allot allot, List<sys_hospitalconfig> configs)
var conf = configs.FirstOrDefault(w => w.HospitalId == allot.HospitalId && w.Id == import.ConfigId);
if (conf != null)
{
if (import.TimeRange == 1)
if (import.TimeRange == "1")
{
pairs.Add("@year", allot.Year);
pairs.Add("@month", allot.Month);
}
else if (import.TimeRange == 2)
else if (import.TimeRange == "2")
{
pairs.Add("@year", allot.Year - 1);
pairs.Add("@month", allot.Month);
}
else if (import.TimeRange == 3)
else if (import.TimeRange == "3")
{
pairs.Add("@year", allot.Year);
pairs.Add("@month", allot.Month - 1);
......
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