Commit 37780167 by lcx

判断文件是否是xlsx文件

parent e430cd4d
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
using Performance.Infrastructure; using Performance.Infrastructure;
using Performance.Services; using Performance.Services;
using Performance.Services.AllotCompute; using Performance.Services.AllotCompute;
using Performance.Services.ExtractExcelService;
using Performance.Services.Queues; using Performance.Services.Queues;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
...@@ -138,12 +139,16 @@ public ApiResponse Import([FromForm] IFormCollection form) ...@@ -138,12 +139,16 @@ public ApiResponse Import([FromForm] IFormCollection form)
if (file == null) if (file == null)
return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效"); return new ApiResponse(ResponseType.Fail, "参数错误", "文件无效");
if (!ExtractHelper.IsXlsxFile(file.FileName))
return new ApiResponse(ResponseType.Fail, "文件格式错误", "文件暂只支持xlsx文件");
var allot = _allotService.GetAllot(allotid); var allot = _allotService.GetAllot(allotid);
if (allot == null) if (allot == null)
return new ApiResponse(ResponseType.Fail, "allotid不存在"); return new ApiResponse(ResponseType.Fail, "allotid不存在");
var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff"); var name = FileHelper.GetFileNameNoExtension(file.FileName) + DateTime.Now.ToString("yyyyMMddHHmmssfff");
var ext = FileHelper.GetExtension(file.FileName); var ext = FileHelper.GetExtension(file.FileName);
var dpath = Path.Combine(_evn.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}"); var dpath = Path.Combine(_evn.ContentRootPath, "Files", $"{allot.HospitalId}", $"{allot.Year}{allot.Month.ToString().PadLeft(2, '0')}");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
...@@ -257,7 +262,6 @@ public ApiResponse CheckRecord([CustomizeValidator(RuleSet = "Delete"), FromBody ...@@ -257,7 +262,6 @@ public ApiResponse CheckRecord([CustomizeValidator(RuleSet = "Delete"), FromBody
return new ApiResponse(ResponseType.OK, list); return new ApiResponse(ResponseType.OK, list);
} }
/// <summary> /// <summary>
/// 绩效校验结果 /// 绩效校验结果
/// </summary> /// </summary>
...@@ -323,7 +327,6 @@ public ApiResponse UpdateAllotShowFormula([FromBody] AllotRequest request) ...@@ -323,7 +327,6 @@ public ApiResponse UpdateAllotShowFormula([FromBody] AllotRequest request)
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
/// <summary> /// <summary>
/// 获取 /// 获取
/// </summary> /// </summary>
...@@ -340,6 +343,7 @@ public ApiResponse Reserved([FromBody] ReservedRequest request) ...@@ -340,6 +343,7 @@ public ApiResponse Reserved([FromBody] ReservedRequest request)
var reserveds = _allotService.GetReserved(request.HospitalId, request.Year, userid); var reserveds = _allotService.GetReserved(request.HospitalId, request.Year, userid);
#region 格式转换 #region 格式转换
var result = reserveds?.Select(w => new var result = reserveds?.Select(w => new
{ {
w.HospitalId, w.HospitalId,
...@@ -395,7 +399,8 @@ public ApiResponse Reserved([FromBody] ReservedRequest request) ...@@ -395,7 +399,8 @@ public ApiResponse Reserved([FromBody] ReservedRequest request)
+ (w.JulFee * (1 - w.JulRatio) ?? 0) + (w.AugFee * (1 - w.AugRatio) ?? 0) + (w.SepFee * (1 - w.SepRatio) ?? 0) + (w.JulFee * (1 - w.JulRatio) ?? 0) + (w.AugFee * (1 - w.AugRatio) ?? 0) + (w.SepFee * (1 - w.SepRatio) ?? 0)
+ (w.OctFee * (1 - w.OctRatio) ?? 0) + (w.NovFee * (1 - w.NovRatio) ?? 0) + (w.DecFee * (1 - w.DecRatio) ?? 0), + (w.OctFee * (1 - w.OctRatio) ?? 0) + (w.NovFee * (1 - w.NovRatio) ?? 0) + (w.DecFee * (1 - w.DecRatio) ?? 0),
}); });
#endregion
#endregion 格式转换
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
......
...@@ -79,7 +79,7 @@ public IActionResult DownFile(int type = 1) ...@@ -79,7 +79,7 @@ public IActionResult DownFile(int type = 1)
switch (type) switch (type)
{ {
case 1: case 1:
path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板.xls"); path = Path.Combine(env.ContentRootPath, "Template", "医院绩效模板.xlsx");
break; break;
case 2: case 2:
...@@ -91,11 +91,11 @@ public IActionResult DownFile(int type = 1) ...@@ -91,11 +91,11 @@ public IActionResult DownFile(int type = 1)
break; break;
case 4: case 4:
path = Path.Combine(env.ContentRootPath, "Template", "医院人员绩效模板.xls"); path = Path.Combine(env.ContentRootPath, "Template", "医院人员绩效模板.xlsx");
break; break;
case 5: case 5:
path = Path.Combine(env.ContentRootPath, "Template", "工作量数据导入模板.xls"); path = Path.Combine(env.ContentRootPath, "Template", "工作量数据导入模板.xlsx");
break; break;
} }
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
} }
}, },
"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_yubei;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_yubei;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;",
"HangfireConnectionString": "server=192.168.18.166;database=db_hangfire;uid=root;pwd=1234qwer;port=3306;allow user variables=true;", "HangfireConnectionString": "server=192.168.18.166;database=db_hangfire;uid=root;pwd=1234qwer;port=3306;allow user variables=true;",
"RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2" "RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2"
}, },
......
...@@ -16,7 +16,7 @@ public class ExtractHelper ...@@ -16,7 +16,7 @@ public class ExtractHelper
public static string GetExtractFile(int hospitalId, ref string newFilePath, string allotFilePath = "") public static string GetExtractFile(int hospitalId, ref string newFilePath, string allotFilePath = "")
{ {
string originalPath = string.IsNullOrEmpty(allotFilePath) string originalPath = string.IsNullOrEmpty(allotFilePath)
? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "医院绩效模板.xls") ? Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template", "医院绩效模板.xlsx")
: allotFilePath; : allotFilePath;
CloseAutoFilter(originalPath); CloseAutoFilter(originalPath);
var (tempPath, filePath) = CopyOriginalFile(hospitalId, originalPath); var (tempPath, filePath) = CopyOriginalFile(hospitalId, originalPath);
...@@ -28,7 +28,7 @@ public static string GetExtractFile(int hospitalId, string prefix = "绩效提 ...@@ -28,7 +28,7 @@ public static string GetExtractFile(int hospitalId, string prefix = "绩效提
{ {
var dpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", $"{hospitalId}", "autoextract"); var dpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files", $"{hospitalId}", "autoextract");
FileHelper.CreateDirectory(dpath); FileHelper.CreateDirectory(dpath);
return Path.Combine(dpath, $"{prefix}{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xls"); return Path.Combine(dpath, $"{prefix}{DateTime.Now.ToString("yyyyMMddHHmmssfff")}.xlsx");
} }
private static (string TempPath, string FilePath) CopyOriginalFile(int hospitalId, string originalPath) private static (string TempPath, string FilePath) CopyOriginalFile(int hospitalId, string originalPath)
...@@ -180,5 +180,23 @@ public static void CloseAutoFilter(string path) ...@@ -180,5 +180,23 @@ public static void CloseAutoFilter(string path)
{ {
} }
} }
/// <summary>
/// 判断文件是否是xlsx文件
/// </summary>
/// <param name="filename">文件名称、文件扩展名</param>
/// <returns></returns>
public static bool IsXlsxFile(string filename)
{
if (string.IsNullOrEmpty(filename)) return false;
string ext = filename;
if (ext.Contains("."))
{
int start = filename.LastIndexOf('.') + 1;
ext = filename.Substring(start, filename.Length - start);
}
return ext == ExcelVersion.xlsx.ToString();
}
} }
} }
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