Commit 331a8fff by 纪旭 韦

Merge branch 'feature/手工录入上传文件' into develop

parents 90822afd 2fa66a41
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Performance.DtoModels; using Performance.DtoModels;
using Performance.DtoModels.Response; using Performance.DtoModels.Response;
using Performance.EntityModels; using Performance.EntityModels;
...@@ -1034,7 +1035,6 @@ public ApiResponse DeleteGather([FromBody] Gather gather) ...@@ -1034,7 +1035,6 @@ public ApiResponse DeleteGather([FromBody] Gather gather)
else return new ApiResponse(ResponseType.Fail, "删除失败"); else return new ApiResponse(ResponseType.Fail, "删除失败");
} }
/// <summary> /// <summary>
/// 批量审核 /// 批量审核
/// </summary> /// </summary>
...@@ -1047,6 +1047,69 @@ public ApiResponse AuditGather([FromBody] List<Gather> gather) ...@@ -1047,6 +1047,69 @@ public ApiResponse AuditGather([FromBody] List<Gather> gather)
employeeService.AuditGather(gather); employeeService.AuditGather(gather);
return new ApiResponse(ResponseType.OK, ""); return new ApiResponse(ResponseType.OK, "");
} }
/// <summary>
/// 上传手工录入文件
/// </summary>
/// <param name="gatherGroup"></param>
/// <param name="file"></param>
/// <returns></returns>
[Route("uploadgatherfile")]
[HttpPost]
public ApiResponse UploadGatherFile([FromForm] GatherGroup gatherGroup, [FromForm] IFormFile file)
{
if (!file.FileName.EndsWith(".xlsx"))
return new ApiResponse(ResponseType.Fail, "请上传xlsx文件");
var dpath = Path.Combine(evn.ContentRootPath, "Files", "GatherFile");
FileHelper.CreateDirectory(dpath);
var fileName = string.Concat(gatherGroup.source, gatherGroup.category, gatherGroup.department, Path.GetFileName(file.FileName));
string path = Path.Combine(dpath, fileName);
var result = employeeService.UploadGatherFile(path, gatherGroup);
if (!string.IsNullOrEmpty(result))
return new ApiResponse(ResponseType.Fail, result);
if (!string.IsNullOrEmpty(path) && FileHelper.IsExistFile(path))
FileHelper.DeleteFile(path);
using (var stream = file.OpenReadStream())
{
byte[] bytes = new byte[stream.Length];
stream.Read(bytes, 0, bytes.Length);
if (!FileHelper.CreateFile(path, bytes))
return new ApiResponse(ResponseType.Fail, "上传失败");
}
return new ApiResponse(ResponseType.OK, "上传成功");
}
/// <summary>
/// 下载手工录入上传文件
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
[Route("downloadgatherfile")]
[HttpPost]
public IActionResult DownloadGatherFile(string path)
{
if (string.IsNullOrEmpty(path))
throw new PerformanceException("尚未提交文件");
if (!FileHelper.IsExistFile(path))
throw new PerformanceException("测算表文件路径无效");
var memoryStream = new MemoryStream();
using (var stream = new FileStream(path, FileMode.Open))
{
stream.CopyToAsync(memoryStream).Wait();
}
memoryStream.Seek(0, SeekOrigin.Begin);
var provider = new FileExtensionContentTypeProvider();
FileInfo fileInfo = new FileInfo(path);
var memi = provider.Mappings[".xlsx"];
return File(memoryStream, memi, Path.GetFileName(fileInfo.Name));
}
#endregion #endregion
} }
} }
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
}, },
"AppConnection": { "AppConnection": {
//"PerformanceConnectionString": "server=112.124.13.17;database=db_performance;uid=suvalue;pwd=suvalue2016;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;", //"PerformanceConnectionString": "server=112.124.13.17;database=db_performance;uid=suvalue;pwd=suvalue2016;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"PerformanceConnectionString": "server=192.168.18.166;database=db_beiliu2;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;" "PerformanceConnectionString": "server=192.168.18.166;database=db_performance_screen;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;"
//"PerformanceConnectionString": "server=116.62.245.55;database=db_performance;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;" //"PerformanceConnectionString": "server=116.62.245.55;database=db_performance;uid=root;pwd=1234qwer;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;"
}, },
"Application": { "Application": {
......
...@@ -1402,6 +1402,21 @@ ...@@ -1402,6 +1402,21 @@
<param name="gather"></param> <param name="gather"></param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Performance.Api.Controllers.EmployeeController.UploadGatherFile(Performance.DtoModels.GatherGroup,Microsoft.AspNetCore.Http.IFormFile)">
<summary>
上传手工录入文件
</summary>
<param name="gatherGroup"></param>
<param name="file"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.EmployeeController.DownloadGatherFile(System.String)">
<summary>
下载手工录入上传文件
</summary>
<param name="path"></param>
<returns></returns>
</member>
<member name="M:Performance.Api.Controllers.ExConfigController.Extract(Performance.DtoModels.ModModuleRequest)"> <member name="M:Performance.Api.Controllers.ExConfigController.Extract(Performance.DtoModels.ModModuleRequest)">
<summary> <summary>
绩效数据抽取模板 绩效数据抽取模板
......
...@@ -3682,6 +3682,11 @@ ...@@ -3682,6 +3682,11 @@
失败理由 失败理由
</summary> </summary>
</member> </member>
<member name="P:Performance.EntityModels.ex_result_gather.Path">
<summary>
文件路径
</summary>
</member>
<member name="T:Performance.EntityModels.ex_script"> <member name="T:Performance.EntityModels.ex_script">
<summary> <summary>
......
...@@ -94,4 +94,13 @@ public class GatherInfoFee ...@@ -94,4 +94,13 @@ public class GatherInfoFee
public decimal? Fee { get; set; } public decimal? Fee { get; set; }
} }
public class GatherGroup
{
public int allotid { get; set; }
public string department { get; set; }
public string source { get; set; }
public string category { get; set; }
}
} }
...@@ -58,5 +58,9 @@ public class ex_result_gather ...@@ -58,5 +58,9 @@ public class ex_result_gather
/// 失败理由 /// 失败理由
/// </summary> /// </summary>
public string Remark { get; set; } public string Remark { get; set; }
/// <summary>
/// 文件路径
/// </summary>
public string Path { get; set; }
} }
} }
...@@ -1533,6 +1533,7 @@ public GatherResponse GetGatherTotal(Gather gather) ...@@ -1533,6 +1533,7 @@ public GatherResponse GetGatherTotal(Gather gather)
: s.Count() == s.Where(w => w.States == (int)EnumResult.AuditGather.已通过).Count() ? "已通过" : s.Count() == s.Where(w => w.States == (int)EnumResult.AuditGather.已通过).Count() ? "已通过"
: s.Count() == s.Where(w => w.States == (int)EnumResult.AuditGather.未审核).Count() ? "未审核" : "未知", : s.Count() == s.Where(w => w.States == (int)EnumResult.AuditGather.未审核).Count() ? "未审核" : "未知",
Remark = s.FirstOrDefault()?.Remark, Remark = s.FirstOrDefault()?.Remark,
Path = s.FirstOrDefault()?.Path,
}); });
if (gather.Status == "失败") datas = datas.Where(w => w.States == "未通过"); if (gather.Status == "失败") datas = datas.Where(w => w.States == "未通过");
...@@ -1570,7 +1571,19 @@ public GatherResponse GetGatherTotal(Gather gather) ...@@ -1570,7 +1571,19 @@ public GatherResponse GetGatherTotal(Gather gather)
return gatherResponse; return gatherResponse;
} }
public string UploadGatherFile(string path, GatherGroup gatherGroup)
{
var datas = exresultgatherRepository.GetEntities(w => w.AllotId == gatherGroup.allotid && w.Department == gatherGroup.department && w.Source == gatherGroup.source && w.Category == gatherGroup.category);
if (datas?.Any() != true)
return "未找到核算项目信息";
datas.ForEach(w =>
{
w.Path = path;
});
exresultgatherRepository.UpdateRange(datas.ToArray());
return "";
}
public static Dictionary<string, string> Gather { get; } = new Dictionary<string, string> public static Dictionary<string, string> Gather { get; } = new Dictionary<string, string>
{ {
{nameof(ex_result_gather.Department), "科室"}, {nameof(ex_result_gather.Department), "科室"},
......
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