Commit 5b751ceb by lcx

数据抽取过滤空格换行、医院其他绩效根据角色显示对应的数据及上传文件

parent 8dd90516
...@@ -20,6 +20,7 @@ public class EmployeeController : Controller ...@@ -20,6 +20,7 @@ public class EmployeeController : Controller
private AllotService allotService; private AllotService allotService;
private ClaimService claim; private ClaimService claim;
private IHostingEnvironment evn; private IHostingEnvironment evn;
public EmployeeController(EmployeeService employeeService, AllotService allotService, public EmployeeController(EmployeeService employeeService, AllotService allotService,
ClaimService claim, IHostingEnvironment evn) ClaimService claim, IHostingEnvironment evn)
{ {
...@@ -46,7 +47,7 @@ public ApiResponse GetEmployeeList([CustomizeValidator(RuleSet = "Select"), From ...@@ -46,7 +47,7 @@ public ApiResponse GetEmployeeList([CustomizeValidator(RuleSet = "Select"), From
/// 新增人员 /// 新增人员
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[Route("insert")] [Route("insert")]
[HttpPost] [HttpPost]
public ApiResponse Insert([CustomizeValidator(RuleSet = "Insert"), FromBody] EmployeeRequest request) public ApiResponse Insert([CustomizeValidator(RuleSet = "Insert"), FromBody] EmployeeRequest request)
...@@ -102,7 +103,7 @@ public ApiResponse GetEmployeeClinicList([FromBody] im_employee_clinic request) ...@@ -102,7 +103,7 @@ public ApiResponse GetEmployeeClinicList([FromBody] im_employee_clinic request)
/// 新增临床人员 /// 新增临床人员
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[Route("clinic/insert")] [Route("clinic/insert")]
[HttpPost] [HttpPost]
public ApiResponse InsertClinic([FromBody] im_employee_clinic request) public ApiResponse InsertClinic([FromBody] im_employee_clinic request)
...@@ -180,7 +181,7 @@ public ApiResponse GetEmployeeLogisticsList([FromBody] im_employee_clinic reques ...@@ -180,7 +181,7 @@ public ApiResponse GetEmployeeLogisticsList([FromBody] im_employee_clinic reques
/// 新增临床人员 /// 新增临床人员
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[Route("logistics/insert")] [Route("logistics/insert")]
[HttpPost] [HttpPost]
public ApiResponse InsertLogistics([FromBody] im_employee_logistics request) public ApiResponse InsertLogistics([FromBody] im_employee_logistics request)
...@@ -236,7 +237,7 @@ public ApiResponse DeleteLogistics([FromBody] im_employee_clinic request) ...@@ -236,7 +237,7 @@ public ApiResponse DeleteLogistics([FromBody] im_employee_clinic request)
return new ApiResponse(ResponseType.OK); return new ApiResponse(ResponseType.OK);
} }
#endregion #endregion 行政后勤
/// <summary> /// <summary>
/// 人事科修改参数后提交 /// 人事科修改参数后提交
...@@ -263,7 +264,7 @@ public ApiResponse GetAprList([FromBody] per_apr_amount request) ...@@ -263,7 +264,7 @@ public ApiResponse GetAprList([FromBody] per_apr_amount request)
if (request.AllotId == 0) if (request.AllotId == 0)
return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!"); return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!");
var employee = employeeService.GetAprList(request.AllotId); var employee = employeeService.GetAprList(request.AllotId, claim.GetUserId());
return new ApiResponse(ResponseType.OK, "ok", employee); return new ApiResponse(ResponseType.OK, "ok", employee);
} }
...@@ -279,7 +280,7 @@ public ApiResponse GetAprGroupList([FromBody] per_apr_amount request) ...@@ -279,7 +280,7 @@ public ApiResponse GetAprGroupList([FromBody] per_apr_amount request)
if (request.AllotId == 0) if (request.AllotId == 0)
return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!"); return new ApiResponse(ResponseType.ParameterError, "参数AllotId无效!");
var employee = employeeService.GetAprList(request.AllotId); var employee = employeeService.GetAprList(request.AllotId, claim.GetUserId());
if (employee == null || !employee.Any()) if (employee == null || !employee.Any())
return new ApiResponse(ResponseType.OK, "ok", employee); return new ApiResponse(ResponseType.OK, "ok", employee);
...@@ -328,7 +329,7 @@ public ApiResponse GetAprDetail([FromBody] per_apr_amount request) ...@@ -328,7 +329,7 @@ public ApiResponse GetAprDetail([FromBody] per_apr_amount request)
/// 新增人员补充绩效 /// 新增人员补充绩效
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
[Route("apr/insert")] [Route("apr/insert")]
[HttpPost] [HttpPost]
public ApiResponse InsertApr([FromBody] per_apr_amount request) public ApiResponse InsertApr([FromBody] per_apr_amount request)
......
...@@ -28,6 +28,7 @@ public class ExtractController : Controller ...@@ -28,6 +28,7 @@ public class ExtractController : Controller
private readonly WebapiUrl url; private readonly WebapiUrl url;
private readonly ILogger<ExtractController> logger; private readonly ILogger<ExtractController> logger;
private readonly IHostingEnvironment evn; private readonly IHostingEnvironment evn;
public ExtractController(DFExtractService extractService, public ExtractController(DFExtractService extractService,
HospitalService hospitalService, HospitalService hospitalService,
ExtractService extractService1, ExtractService extractService1,
...@@ -123,7 +124,9 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit ...@@ -123,7 +124,9 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
return; return;
var path = string.Empty; var path = string.Empty;
#region 保存历史绩效文件 #region 保存历史绩效文件
if (form.Files == null || !form.Files.Any() || ((FormFileCollection)form.Files).FirstOrDefault() == null) if (form.Files == null || !form.Files.Any() || ((FormFileCollection)form.Files).FirstOrDefault() == null)
logger.LogInformation($"文件为空!"); logger.LogInformation($"文件为空!");
else else
...@@ -150,11 +153,13 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit ...@@ -150,11 +153,13 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
} }
} }
} }
#endregion
#endregion 保存历史绩效文件
//string filePath = newExtractService.ExtractData(allotId, request.Email, hospitalId); //string filePath = newExtractService.ExtractData(allotId, request.Email, hospitalId);
//string filePath = extractService.ExtractData(allotId, email, hospitalId, "User" + userId, path); //抽取 //string filePath = extractService.ExtractData(allotId, email, hospitalId, "User" + userId, path); //抽取
string filePath = extractService1.Main(allotId, hospitalId, email, "User" + userId, path); string filePath = extractService1.Main(allotId, hospitalId, email, "User" + userId, path);
logger.LogInformation($"抽取文件地址: {filePath}");
#region 保存文件到网站下 #region 保存文件到网站下
...@@ -191,9 +196,9 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit ...@@ -191,9 +196,9 @@ public void ExtractData([FromForm] IFormCollection form, int allotId, int hospit
else else
logger.LogInformation($"保存提取文件提取文件不存在!"); logger.LogInformation($"保存提取文件提取文件不存在!");
#endregion #endregion 保存文件到网站下
} }
#endregion
#endregion 新版提取
} }
} }
\ No newline at end of file
...@@ -23,10 +23,13 @@ public static IDbConnection Create(DatabaseType type, string connectionString) ...@@ -23,10 +23,13 @@ public static IDbConnection Create(DatabaseType type, string connectionString)
{ {
case DatabaseType.MySql: case DatabaseType.MySql:
return new MySqlConnection(connectionString); return new MySqlConnection(connectionString);
case DatabaseType.SqlServer: case DatabaseType.SqlServer:
return new SqlConnection(connectionString); return new SqlConnection(connectionString);
case DatabaseType.Oracle: case DatabaseType.Oracle:
return new OracleConnection(connectionString); return new OracleConnection(connectionString);
default: default:
throw new Exception($"nonsupport {DatabaseType.MySql}"); throw new Exception($"nonsupport {DatabaseType.MySql}");
} }
...@@ -47,14 +50,17 @@ public static string GetConnectionString(DatabaseType type, string ip, string da ...@@ -47,14 +50,17 @@ public static string GetConnectionString(DatabaseType type, string ip, string da
switch (type) switch (type)
{ {
case DatabaseType.MySql: case DatabaseType.MySql:
connectionString = $"Server={ip};Database={database};Uid={uid};Pwd={pwd};connection timeout=12000;pooling=true;charset=utf8;Convert Zero Datetime=True;port=3306;Allow User Variables=True;;"; connectionString = $"Server={ip};Database={database};Uid={uid};Pwd={pwd};connection timeout=12000;pooling=true;charset=utf8;Convert Zero Datetime=True;port=3306;Allow User Variables=True;";
break; break;
case DatabaseType.SqlServer: case DatabaseType.SqlServer:
connectionString = $"data source={ip};initial catalog={database};user id={uid};password={pwd};connection timeout=12000;"; connectionString = $"data source={ip};initial catalog={database};user id={uid};password={pwd};connection timeout=12000;";
break; break;
case DatabaseType.Oracle: case DatabaseType.Oracle:
connectionString = $"Password={pwd};User ID={uid};Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={ip})(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME={database})));"; connectionString = $"Password={pwd};User ID={uid};Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST={ip})(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME={database})));";
break; break;
default: default:
throw new Exception($"nonsupport {DatabaseType.MySql}"); throw new Exception($"nonsupport {DatabaseType.MySql}");
} }
...@@ -75,7 +81,5 @@ public static IDbConnection Create(DatabaseType type, string ip, string database ...@@ -75,7 +81,5 @@ public static IDbConnection Create(DatabaseType type, string ip, string database
string connectionString = GetConnectionString(type, ip, database, uid, pwd); string connectionString = GetConnectionString(type, ip, database, uid, pwd);
return Create(type, connectionString); return Create(type, connectionString);
} }
} }
}
} \ No newline at end of file
...@@ -27,6 +27,7 @@ public class EmployeeService : IAutoInjection ...@@ -27,6 +27,7 @@ public class EmployeeService : IAutoInjection
private PerforPerallotRepository perallotRepository; private PerforPerallotRepository perallotRepository;
private PerforPerapramountRepository perapramountRepository; private PerforPerapramountRepository perapramountRepository;
private PerforImemployeelogisticsRepository perforImemployeelogisticsRepository; private PerforImemployeelogisticsRepository perforImemployeelogisticsRepository;
private PerforUserroleRepository userroleRepository;
private ILogger<EmployeeService> logger; private ILogger<EmployeeService> logger;
public EmployeeService(PerforImemployeeRepository perforImemployeeRepository, public EmployeeService(PerforImemployeeRepository perforImemployeeRepository,
...@@ -37,6 +38,7 @@ public class EmployeeService : IAutoInjection ...@@ -37,6 +38,7 @@ public class EmployeeService : IAutoInjection
PerforPerallotRepository perallotRepository, PerforPerallotRepository perallotRepository,
PerforPerapramountRepository perapramountRepository, PerforPerapramountRepository perapramountRepository,
PerforImemployeelogisticsRepository perforImemployeelogisticsRepository, PerforImemployeelogisticsRepository perforImemployeelogisticsRepository,
PerforUserroleRepository userroleRepository,
ILogger<EmployeeService> logger) ILogger<EmployeeService> logger)
{ {
this.perforImemployeeRepository = perforImemployeeRepository; this.perforImemployeeRepository = perforImemployeeRepository;
...@@ -47,6 +49,7 @@ public class EmployeeService : IAutoInjection ...@@ -47,6 +49,7 @@ public class EmployeeService : IAutoInjection
this.perallotRepository = perallotRepository; this.perallotRepository = perallotRepository;
this.perapramountRepository = perapramountRepository; this.perapramountRepository = perapramountRepository;
this.perforImemployeelogisticsRepository = perforImemployeelogisticsRepository; this.perforImemployeelogisticsRepository = perforImemployeelogisticsRepository;
this.userroleRepository = userroleRepository;
this.logger = logger; this.logger = logger;
} }
...@@ -160,7 +163,7 @@ public bool Delete(EmployeeRequest request) ...@@ -160,7 +163,7 @@ public bool Delete(EmployeeRequest request)
return perforImemployeeRepository.Remove(employee); return perforImemployeeRepository.Remove(employee);
} }
#endregion #endregion 行政人员
#region 临床人员 #region 临床人员
...@@ -258,7 +261,7 @@ public bool DeleteClinic(im_employee_clinic request) ...@@ -258,7 +261,7 @@ public bool DeleteClinic(im_employee_clinic request)
return perforImemployeeclinicRepository.Remove(employee); return perforImemployeeclinicRepository.Remove(employee);
} }
#endregion #endregion 临床人员
#region 行政后勤 #region 行政后勤
...@@ -355,7 +358,7 @@ public bool DeleteLogistics(im_employee_clinic request) ...@@ -355,7 +358,7 @@ public bool DeleteLogistics(im_employee_clinic request)
return perforImemployeelogisticsRepository.Remove(employee); return perforImemployeelogisticsRepository.Remove(employee);
} }
#endregion #endregion 行政后勤
/// <summary> /// <summary>
/// 人事科修改后提交状态 /// 人事科修改后提交状态
...@@ -374,9 +377,16 @@ public bool Audit(int allotId) ...@@ -374,9 +377,16 @@ public bool Audit(int allotId)
return perforPerallotRepository.Update(allot); return perforPerallotRepository.Update(allot);
} }
public List<per_apr_amount> GetAprList(int allotId) public List<per_apr_amount> GetAprList(int allotId, int userId)
{ {
var list = perapramountRepository.GetEntities(t => t.AllotId == allotId && t.Amount.HasValue && t.Amount != 0); var userrole = userroleRepository.GetEntity(t => t.UserID == userId);
if (userrole == null) throw new PerformanceException("用户未绑定角色");
var list = new List<per_apr_amount>();
if (new int[] { 1, 2, 5 }.Contains(userrole.RoleID)) // 绩效管理员、医院管理员、绩效核算办查看所有科室的数据
list = perapramountRepository.GetEntities(t => t.AllotId == allotId && (t.Amount ?? 0) != 0);
else
list = perapramountRepository.GetEntities(t => t.AllotId == allotId && (t.Amount ?? 0) != 0 && t.CreateUser == userId);
if (list != null && list.Any()) if (list != null && list.Any())
list = list.OrderBy(t => t.DoctorName).ToList(); list = list.OrderBy(t => t.DoctorName).ToList();
...@@ -473,7 +483,15 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request) ...@@ -473,7 +483,15 @@ public bool ConfirmAudit(int userid, AprAmountAuditRequest request)
public void ImpoerAprEmployees(int allotid, string path, int userid) public void ImpoerAprEmployees(int allotid, string path, int userid)
{ {
var data = perapramountRepository.GetEntities(t => t.AllotId == allotid); var userrole = userroleRepository.GetEntity(t => t.UserID == userid);
if (userrole == null) throw new PerformanceException("用户未绑定角色");
var data = new List<per_apr_amount>();
if (new int[] { 1, 2, 5 }.Contains(userrole.RoleID)) // 绩效管理员、医院管理员、绩效核算办查看所有科室的数据
data = perapramountRepository.GetEntities(t => t.AllotId == allotid && (t.Amount ?? 0) != 0);
else
data = perapramountRepository.GetEntities(t => t.AllotId == allotid && (t.Amount ?? 0) != 0 && t.CreateUser == userid);
if (data != null && data.Any()) if (data != null && data.Any())
perapramountRepository.RemoveRange(data.ToArray()); perapramountRepository.RemoveRange(data.ToArray());
...@@ -513,7 +531,6 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -513,7 +531,6 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
List<string> errorHeaders = new List<string>(); List<string> errorHeaders = new List<string>();
foreach (var key in dict.Keys.ToList()) foreach (var key in dict.Keys.ToList())
{ {
if (!excelheader.Select(t => t.Item1).Contains(key)) errorHeaders.Add(key); if (!excelheader.Select(t => t.Item1).Contains(key)) errorHeaders.Add(key);
else dict[key] = excelheader.First(t => t.Item1 == key).Item2; else dict[key] = excelheader.First(t => t.Item1 == key).Item2;
} }
...@@ -552,4 +569,4 @@ public void ImpoerAprEmployees(int allotid, string path, int userid) ...@@ -552,4 +569,4 @@ public void ImpoerAprEmployees(int allotid, string path, int userid)
} }
} }
} }
} }
\ No newline at end of file
...@@ -208,7 +208,7 @@ public void DelModule(int moduleId) ...@@ -208,7 +208,7 @@ public void DelModule(int moduleId)
} }
} }
#endregion #endregion Modules
#region Items #region Items
...@@ -263,7 +263,7 @@ public void DelItem(int itemId) ...@@ -263,7 +263,7 @@ public void DelItem(int itemId)
exitemRepository.Remove(item); exitemRepository.Remove(item);
} }
#endregion #endregion Items
#region 特殊科室 #region 特殊科室
...@@ -326,7 +326,7 @@ public void DelSpecial(int specialId) ...@@ -326,7 +326,7 @@ public void DelSpecial(int specialId)
exspecialRepository.Remove(special); exspecialRepository.Remove(special);
} }
#endregion #endregion 特殊科室
public bool QueryHosConfigs(int moduleId, out int sheetType) public bool QueryHosConfigs(int moduleId, out int sheetType)
{ {
...@@ -393,6 +393,7 @@ private bool QueryAndAddItem(List<sys_hospitalconfig> hospitalconfigs, string sq ...@@ -393,6 +393,7 @@ private bool QueryAndAddItem(List<sys_hospitalconfig> hospitalconfigs, string sq
logger.LogInformation($"执行sql:{sql}"); logger.LogInformation($"执行sql:{sql}");
try try
{ {
logger.LogInformation($"ConnectionString: {connection?.ConnectionString}");
var dataList = extractRepository.ExecuteScript(connection, sql, null); var dataList = extractRepository.ExecuteScript(connection, sql, null);
logger.LogInformation($"获取数据{dataList?.Count ?? 0}条"); logger.LogInformation($"获取数据{dataList?.Count ?? 0}条");
if (dataList != null && dataList.Any()) if (dataList != null && dataList.Any())
...@@ -563,4 +564,4 @@ public ModFeeResponse FeeSource(ModModuleRequest request) ...@@ -563,4 +564,4 @@ public ModFeeResponse FeeSource(ModModuleRequest request)
return new ModFeeResponse(); return new ModFeeResponse();
} }
} }
} }
\ No newline at end of file
...@@ -49,31 +49,36 @@ public static void SetCellValue<T>(this ICell cell, object value, T defaultValue ...@@ -49,31 +49,36 @@ public static void SetCellValue<T>(this ICell cell, object value, T defaultValue
{ {
#region SetValue #region SetValue
case "System.String"://字符串类型 case "System.String"://字符串类型
cell.SetCellValue(ConvertHelper.To<string>(value)); cell.SetCellValue(ConvertHelper.To<string>(value));
break; break;
case "System.DateTime"://日期类型
case "System.DateTime"://日期类型
cell.SetCellValue(ConvertHelper.To<DateTime>(value).ToString("yyyy/M/d")); cell.SetCellValue(ConvertHelper.To<DateTime>(value).ToString("yyyy/M/d"));
break; break;
case "System.Boolean"://布尔型
case "System.Boolean"://布尔型
cell.SetCellValue(ConvertHelper.To<bool>(value)); cell.SetCellValue(ConvertHelper.To<bool>(value));
break; break;
case "System.Int16"://整型
case "System.Int16"://整型
case "System.Int32": case "System.Int32":
case "System.Int64": case "System.Int64":
case "System.Byte": case "System.Byte":
cell.SetCellValue(ConvertHelper.To<int>(value)); cell.SetCellValue(ConvertHelper.To<int>(value));
break; break;
case "System.Decimal"://浮点型
case "System.Decimal"://浮点型
case "System.Double": case "System.Double":
cell.SetCellValue(ConvertHelper.To<double>(value)); cell.SetCellValue(ConvertHelper.To<double>(value));
break; break;
case "System.DBNull"://空值处理
case "System.DBNull"://空值处理
default: default:
cell.SetCellValue(""); cell.SetCellValue("");
break; break;
#endregion #endregion SetValue
} }
} }
catch catch
...@@ -100,20 +105,23 @@ public static void SetCellOValue(this ICell cell, object value) ...@@ -100,20 +105,23 @@ public static void SetCellOValue(this ICell cell, object value)
{ {
#region SetValue #region SetValue
case "System.String"://字符串类型 case "System.String"://字符串类型
cell.SetCellValue(stringV); cell.SetCellValue(stringV);
break; break;
case "System.DateTime"://日期类型
case "System.DateTime"://日期类型
DateTime dateV; DateTime dateV;
DateTime.TryParse(stringV, out dateV); DateTime.TryParse(stringV, out dateV);
cell.SetCellValue(dateV.ToString("yyyy/M/d")); cell.SetCellValue(dateV.ToString("yyyy/M/d"));
break; break;
case "System.Boolean"://布尔型
case "System.Boolean"://布尔型
bool boolV = false; bool boolV = false;
bool.TryParse(stringV, out boolV); bool.TryParse(stringV, out boolV);
cell.SetCellValue(boolV); cell.SetCellValue(boolV);
break; break;
case "System.Int16"://整型
case "System.Int16"://整型
case "System.Int32": case "System.Int32":
case "System.Int64": case "System.Int64":
case "System.Byte": case "System.Byte":
...@@ -121,20 +129,23 @@ public static void SetCellOValue(this ICell cell, object value) ...@@ -121,20 +129,23 @@ public static void SetCellOValue(this ICell cell, object value)
int.TryParse(stringV, out intV); int.TryParse(stringV, out intV);
cell.SetCellValue(intV); cell.SetCellValue(intV);
break; break;
case "System.Decimal"://浮点型
case "System.Decimal"://浮点型
case "System.Double": case "System.Double":
double doubV = 0; double doubV = 0;
double.TryParse(stringV, out doubV); double.TryParse(stringV, out doubV);
cell.SetCellValue(doubV); cell.SetCellValue(doubV);
break; break;
case "System.DBNull"://空值处理
case "System.DBNull"://空值处理
cell.SetCellValue(""); cell.SetCellValue("");
break; break;
default: default:
cell.SetCellValue(""); cell.SetCellValue("");
break; break;
#endregion #endregion SetValue
} }
} }
catch catch
...@@ -171,7 +182,7 @@ public static string GetDecodeEscapes(this ICell cell) ...@@ -171,7 +182,7 @@ public static string GetDecodeEscapes(this ICell cell)
cell.SetCellType(CellType.String); cell.SetCellType(CellType.String);
string value = cell.StringCellValue; string value = cell.StringCellValue;
if (!string.IsNullOrEmpty(value)) if (!string.IsNullOrEmpty(value))
value = value.Replace("\n", "").Replace(" ", "").Trim(); value = value.Replace("\n", "").Replace("\r", "").Replace(" ", "").Trim();
return value; return value;
} }
...@@ -185,7 +196,7 @@ public static string NoBlank(this string @string) ...@@ -185,7 +196,7 @@ public static string NoBlank(this string @string)
{ {
if (string.IsNullOrEmpty(@string)) if (string.IsNullOrEmpty(@string))
return ""; return "";
return @string.Replace("\n", "").Replace(" ", "").Trim(); return @string.Replace("\n", "").Replace("\r", "").Replace(" ", "").Trim();
} }
public static IWorkbook GetWorkbook(string filePath) public static IWorkbook GetWorkbook(string filePath)
...@@ -237,4 +248,4 @@ public static List<string> GetCellValues(this IRow row) ...@@ -237,4 +248,4 @@ public static List<string> GetCellValues(this IRow row)
return pairs; return pairs;
} }
} }
} }
\ No newline at end of file
...@@ -41,7 +41,7 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType ...@@ -41,7 +41,7 @@ public static void WriteSheetHeader(ISheet sheet, PerSheetPoint point, SheetType
var column = columnHeader.GetCell(index).GetDecodeEscapes(); var column = columnHeader.GetCell(index).GetDecodeEscapes();
if (string.IsNullOrEmpty(column)) continue; if (string.IsNullOrEmpty(column)) continue;
columns.RemoveAll(t => t.ColumnName == column); columns.RemoveAll(t => t.ColumnName.NoBlank() == column);
if (index > headerFirstCellNum) if (index > headerFirstCellNum)
headerFirstCellNum = index + 1; headerFirstCellNum = index + 1;
} }
...@@ -106,6 +106,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -106,6 +106,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据); var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据);
headers = headers.Select(t => t.NoBlank()).ToList();
int dataFirstCellNum = point.DataFirstCellNum.Value; int dataFirstCellNum = point.DataFirstCellNum.Value;
for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++) for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++)
...@@ -124,7 +126,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -124,7 +126,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
var column = columnHeader.GetOrCreate(cellIndex).GetDecodeEscapes(); var column = columnHeader.GetOrCreate(cellIndex).GetDecodeEscapes();
var cell = row.GetOrCreate(cellIndex); var cell = row.GetOrCreate(cellIndex);
var value = deptData.FirstOrDefault(t => t.Category == column)?.Value; var value = deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value;
var notWrite = !value.HasValue && !string.IsNullOrEmpty(cell.ToString()); var notWrite = !value.HasValue && !string.IsNullOrEmpty(cell.ToString());
if (sheetType == SheetType.Income) if (sheetType == SheetType.Income)
...@@ -161,6 +163,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -161,6 +163,8 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
var deptStyle = style.GetCellStyle(); var deptStyle = style.GetCellStyle();
var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据); var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据);
headers = headers.Select(t => t.NoBlank()).ToList();
dataFirstRowNum += 1; dataFirstRowNum += 1;
foreach (string department in departments) foreach (string department in departments)
{ {
...@@ -180,7 +184,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s ...@@ -180,7 +184,7 @@ public static void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType s
} }
else if (sheetType == SheetType.Income || (headers != null && headers.Contains(column))) else if (sheetType == SheetType.Income || (headers != null && headers.Contains(column)))
{ {
var value = deptData.FirstOrDefault(t => t.Category == column)?.Value; var value = deptData.FirstOrDefault(t => t.Category.NoBlank() == column)?.Value;
cell.SetCellValue<decimal>(value); cell.SetCellValue<decimal>(value);
cell.CellStyle = cellStyle; cell.CellStyle = cellStyle;
} }
...@@ -234,7 +238,7 @@ public static string HasValue(params string[] list) ...@@ -234,7 +238,7 @@ public static string HasValue(params string[] list)
{ "核算单元", (dto) => new string []{ dto.OutNurseAccounting, dto.InpatNurseAccounting }.FirstOrDefault(t => !string.IsNullOrEmpty(t)) }, { "核算单元", (dto) => new string []{ dto.OutNurseAccounting, dto.InpatNurseAccounting }.FirstOrDefault(t => !string.IsNullOrEmpty(t)) },
}; };
#endregion #endregion ExtractData
#region CollectData #region CollectData
...@@ -257,6 +261,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -257,6 +261,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据); var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据);
headers = headers.Select(t => t.NoBlank()).ToList();
int dataFirstCellNum = point.DataFirstCellNum.Value; int dataFirstCellNum = point.DataFirstCellNum.Value;
for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++) for (int rowIndex = dataFirstRowNum; rowIndex < sheet.LastRowNum + 1; rowIndex++)
...@@ -275,7 +281,7 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -275,7 +281,7 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
var column = columnHeader.GetOrCreate(cellIndex).GetDecodeEscapes(); var column = columnHeader.GetOrCreate(cellIndex).GetDecodeEscapes();
var cell = row.GetOrCreate(cellIndex); var cell = row.GetOrCreate(cellIndex);
var value = deptData.FirstOrDefault(t => t.TypeName == column)?.CellValue; var value = deptData.FirstOrDefault(t => t.TypeName.NoBlank() == column)?.CellValue;
if (sheetType == SheetType.Income) if (sheetType == SheetType.Income)
{ {
...@@ -307,6 +313,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -307,6 +313,8 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
var deptStyle = style.GetCellStyle(); var deptStyle = style.GetCellStyle();
var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据); var cellStyle = style.SetBgkColorAndFormat(style.GetCellStyle(), StyleType.数据);
headers = headers.Select(t => t.NoBlank()).ToList();
dataFirstRowNum += 1; dataFirstRowNum += 1;
foreach (string department in departments) foreach (string department in departments)
{ {
...@@ -326,7 +334,7 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -326,7 +334,7 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
} }
else if (sheetType == SheetType.Income || (headers != null && headers.Contains(column))) else if (sheetType == SheetType.Income || (headers != null && headers.Contains(column)))
{ {
var value = deptData.FirstOrDefault(t => t.TypeName == column)?.CellValue; var value = deptData.FirstOrDefault(t => t.TypeName.NoBlank() == column)?.CellValue;
cell.SetCellValue<decimal>(value); cell.SetCellValue<decimal>(value);
cell.CellStyle = cellStyle; cell.CellStyle = cellStyle;
} }
...@@ -358,6 +366,6 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType ...@@ -358,6 +366,6 @@ public static void WriteCollectData(ISheet sheet, PerSheetPoint point, SheetType
{ "核算单元类型", (dto) => dto.UnitType }, { "核算单元类型", (dto) => dto.UnitType },
}; };
#endregion #endregion CollectData
} }
} }
\ No newline at end of file
...@@ -131,6 +131,8 @@ private void WriteDataToFile(IWorkbook workbook, int allotId, Dictionary<ExDataD ...@@ -131,6 +131,8 @@ private void WriteDataToFile(IWorkbook workbook, int allotId, Dictionary<ExDataD
var employeeDict = peremployeeRepository.GetEntities(t => t.AllotId == allotId); var employeeDict = peremployeeRepository.GetEntities(t => t.AllotId == allotId);
var collectData = collectdataRepository.GetEntities(t => t.AllotID == allotId); var collectData = collectdataRepository.GetEntities(t => t.AllotID == allotId);
logger.LogInformation($"allotId: {allotId}: 总金额 - {extractDto?.Sum(s => s.Value ?? 0)}");
WriteDataFactory factory = new WriteDataFactory(); WriteDataFactory factory = new WriteDataFactory();
var types = new List<SheetType> { SheetType.OtherIncome, SheetType.Income, SheetType.Expend, SheetType.Workload, SheetType.OtherWorkload }; var types = new List<SheetType> { SheetType.OtherIncome, SheetType.Income, SheetType.Expend, SheetType.Workload, SheetType.OtherWorkload };
decimal ratio = 60m; decimal ratio = 60m;
...@@ -180,6 +182,7 @@ private object GetDataBySheetType(SheetType sheetType, List<ExtractTransDto> ext ...@@ -180,6 +182,7 @@ private object GetDataBySheetType(SheetType sheetType, List<ExtractTransDto> ext
case SheetType.ClinicEmployee: case SheetType.ClinicEmployee:
case SheetType.AccountBasic: case SheetType.AccountBasic:
return employeeDict; return employeeDict;
default: default:
return extractDto; return extractDto;
} }
...@@ -250,4 +253,4 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, List<ex_result> re ...@@ -250,4 +253,4 @@ private List<ExtractTransDto> StandDataFormat(int hospitalId, List<ex_result> re
return groupdata.ToList(); return groupdata.ToList();
} }
} }
} }
\ No newline at end of file
...@@ -34,24 +34,20 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp ...@@ -34,24 +34,20 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, SheetType sheetTyp
var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType && t.ModuleName.NoBlank() == sheet.SheetName.NoBlank()); var module = modules?.FirstOrDefault(t => t.SheetType == (int)sheetType && t.ModuleName.NoBlank() == sheet.SheetName.NoBlank());
if (module == null) return; if (module == null) return;
var items = exdict[ExDataDict.ExItem] as List<ex_item>;
var modelItems = items?.Where(t => t.ModuleId == module.Id);
if (modelItems == null || !modelItems.Any()) return;
var headers = modelItems.Select(t => new ExcelHeader
{
ColumnName = t.ItemName.Trim(),
DoctorFactor = t.FactorValue1 ?? 0,
NurseFactor = t.FactorValue2 ?? 0,
TechnicianFactor = t.FactorValue3 ?? 0
}).ToList();
WriteDataHelper.WriteSheetHeader(sheet, point, sheetType, style, headers);
if (data is List<ExtractTransDto> extractDto && extractDto.Any()) if (data is List<ExtractTransDto> extractDto && extractDto.Any())
{ {
var headers = extractDto.Select(t => new ExcelHeader
{
ColumnName = t.Category.Trim(),
DoctorFactor = 0,
NurseFactor = 0,
TechnicianFactor = 0
}).ToList();
WriteDataHelper.WriteSheetHeader(sheet, point, sheetType, style, headers);
var columns = headers.Select(t => t.ColumnName).ToList(); var columns = headers.Select(t => t.ColumnName).ToList();
WriteDataHelper.WriteSheetData(sheet, point, sheetType, style, columns, extractDto); WriteDataHelper.WriteSheetData(sheet, point, sheetType, style, columns, extractDto);
} }
} }
} }
} }
\ No newline at end of file
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