自定义提取完善

parent 34af787e
......@@ -171,7 +171,7 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
if (deptIndex > -1)
{
string atDepartment = temp.ElementAt(deptIndex).Value?.ToString() ?? ""; // 当前行“科室名称”
string atUnitType = (unitIndex > -1) ? headers.ElementAt(unitIndex) : ""; // 当前行“核算单元类别”
string atUnitType = (unitIndex > -1) ? temp.ElementAt(unitIndex).Value?.ToString() : ""; // 当前行“核算单元类别”
// 如果是科主任护士长 则取角色的 核算单元类别
// 如果是核算办 则取数据中 核算单元类别
......@@ -180,22 +180,25 @@ private void WriteDataToFile(int userId, per_allot allot, List<cust_script> scri
atUnitTypeList = unitType;
else if (unitIndex > -1)
atUnitTypeList = new string[] { atUnitType };
// 替换原始科室名称
if (atUnitTypeList.Any() && !string.IsNullOrEmpty(atDepartment))
{
var tempDepts = depts.Where(w => atUnitTypeList.Contains(w.UnitType) && w.HISDeptName == atDepartment);
string atSource = headers.ElementAt(sourceIndex); // 当前行“来源”
if (isSecondAdmin && unitType.Any(w => w == UnitType.特殊核算组.ToString() || w == UnitType.行政后勤.ToString()))
{
accountUnit = tempDepts.FirstOrDefault()?.AccountingUnit ?? "";
}
else
{
string atSource = temp.ElementAt(sourceIndex).Value?.ToString() ?? ""; // 当前行“来源”
accountUnit = tempDepts.FirstOrDefault(w => w.Source == atSource)?.AccountingUnit ?? "";
}
}
// 跳过写入EXCEL逻辑
if (isSecondAdmin)
{
if (!string.IsNullOrEmpty(accountUnit) && accountUnit != department) continue;
if (!string.IsNullOrEmpty(atUnitType) && !atUnitTypeList.Contains(atUnitType)) continue;
if (string.IsNullOrEmpty(accountUnit) || accountUnit != department) continue;
if (string.IsNullOrEmpty(atUnitType) || !atUnitTypeList.Contains(atUnitType)) continue;
}
}
#endregion
......@@ -309,7 +312,7 @@ private bool IsSecondAdmin(int userId, out string[] unitType)
var user = _userService.GetUser(userId)
?? throw new PerformanceException("当前用户信息无效");
var isSecondAdmin = IsSecondAdmin(userId, out string[] unitType);
var department = isSecondAdmin ? string.Empty : (user.Department ?? "");
var department = isSecondAdmin ? (user.Department ?? "") : string.Empty;
return (isSecondAdmin, department, unitType);
}
}
......
......@@ -90,14 +90,17 @@ public static void SetCellValue<T>(this ICell cell, object value, T defaultValue
public static void SetValue(this ISheet sheet, int row, int column, object value)
{
var icell = sheet.GetOrCreate(row).GetOrCreate(column);
switch (value)
if (value != null && !string.IsNullOrEmpty(value.ToString()))
{
case string reg when Regex.IsMatch(reg, @"^[+-]?\d*[.]?\d*$"):
value = ConvertHelper.To<double>(value);
break;
case string reg when Regex.IsMatch(reg, @"^[+-]?\d*$"):
value = ConvertHelper.To<int>(value);
break;
switch (value)
{
case string reg when Regex.IsMatch(reg, @"^[+-]?\d*[.]?\d*$"):
value = ConvertHelper.To<double>(value);
break;
case string reg when Regex.IsMatch(reg, @"^[+-]?\d*$"):
value = ConvertHelper.To<int>(value);
break;
}
}
SetCellOValue(icell, value);
......
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