Commit c4f1eb96 by zry

excel developing

parent 1c51f19b
......@@ -12,6 +12,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
......@@ -23,19 +24,19 @@ public class AllotController : Controller
{
private AllotService _allotService;
private HospitalService _hospitalService;
//private PerExcelService _perExcelService;
private PerExcelService _perExcelService;
private IHostingEnvironment _evn;
private ILogger<AllotController> _logger;
public AllotController(AllotService allotService,
HospitalService hospitalService,
//PerExcelService perExcelService,
PerExcelService perExcelService,
ILogger<AllotController> logger,
IHostingEnvironment evn)
{
_allotService = allotService;
_hospitalService = hospitalService;
//_perExcelService = perExcelService;
_perExcelService = perExcelService;
_logger = logger;
_evn = evn;
}
......@@ -141,7 +142,31 @@ public ApiResponse Import([FromForm] IFormCollection form)
public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody]AllotRequest request)
{
var allot = _allotService.GetAllot(request.ID);
BackgroundJob.Enqueue<PerExcelService>(p => p.Analyze(allot.Path));
if (null == allot || string.IsNullOrEmpty(allot.Path))
throw new PerformanceException("当前绩效记录不存在或没有上传数据文件");
Action<PerExcelService> action = (service) =>
{
// 拷贝配置信息
service.Copy(allot.ID);
// 导出数据
var excel = service.Import(allot.Path);
// 保存数据
service.ImportSave(excel);
// 计算合并数据
service.ProcessCompute(excel);
// 保存过程数据
service.ProcessSave(excel);
// 计算最总数据
service.Compute(excel);
};
BackgroundJob.Enqueue<PerExcelService>(p => action.Invoke(p));
return new ApiResponse(ResponseType.OK);
}
}
......
......@@ -10,7 +10,7 @@ static void Main(string[] args)
Console.WriteLine("Hello World!");
PerSheetService perSheetService = new PerSheetService();
PerExcelService perExcelService = new PerExcelService(perSheetService);
var excel = perExcelService.Analyze(@"C:\Users\ry\Desktop\文件\测试.xlsx");
var excel = perExcelService.Import(@"C:\Users\ry\Desktop\文件\测试.xlsx");
Console.ReadKey();
}
......
......@@ -32,7 +32,7 @@ public class PerSheetPoint
/// <summary>
/// 核算单元列
/// </summary>
public int? StandardCellNum { get; set; }
public int? AccountingUnitCellNum { get; set; }
/// <summary>
/// 科室名称
/// </summary>
......
......@@ -18,7 +18,7 @@ public PerExcelService(PerSheetService perSheetService)
{
_perSheetService = perSheetService;
}
public PerExcel Analyze(string path)
public PerExcel Import(string path)
{
PerExcel excel = new PerExcel
{
......@@ -41,20 +41,10 @@ public PerExcel Analyze(string path)
excel.PerSheet.Add(st);
}
}
Save(excel);
return excel;
}
}
private bool Save(PerExcel excel)
{
foreach (var item in excel.PerSheet.Where(t => t.SheetType == SheetType.Employee))
{
var result = C(item.PerData);
}
return true;
}
private List<im_employee> C(List<PerData> dataList)
{
List<im_employee> result = new List<im_employee>();
......@@ -85,5 +75,30 @@ private List<im_employee> C(List<PerData> dataList)
return result;
}
public void Copy(int iD)
{
throw new NotImplementedException();
}
public void ImportSave(PerExcel excel)
{
throw new NotImplementedException();
}
public void ProcessCompute(PerExcel excel)
{
throw new NotImplementedException();
}
public void ProcessSave(PerExcel excel)
{
throw new NotImplementedException();
}
public void Compute(PerExcel excel)
{
throw new NotImplementedException();
}
}
}
......@@ -20,7 +20,7 @@ public PerSheet Sheet(ISheet sheet)
if (perSheet.SheetType == SheetType.Unidentifiable)
return null;
IPerSheetDataRead sheetRead = PerSheetDataFactory.GetAnalyze(perSheet.SheetType);
var sheetRead = PerSheetDataFactory.GetDataRead(perSheet.SheetType);
perSheet.PerData = AnalyzeData(sheet, sheetRead);
return perSheet;
......@@ -30,9 +30,11 @@ public SheetType GetSheetType(string sheetName)
{
if (sheetName.StartsWith("医院人员名单"))
return SheetType.Employee;
else if (sheetName.StartsWith("工作量"))
else if (sheetName.StartsWith("1."))
return SheetType.Income;
else if (sheetName.StartsWith("2."))
return SheetType.Expend;
else if (sheetName.StartsWith("生成成本"))
else if (sheetName.StartsWith("3."))
return SheetType.Workload;
return SheetType.Unidentifiable;
}
......@@ -42,7 +44,7 @@ public List<PerData> AnalyzeData(ISheet sheet, IPerSheetDataRead sheetRead)
List<PerData> dataList = new List<PerData>();
PerHeaderService perHeader = new PerHeaderService();
var headList = perHeader.GetPerHeaderReverse(sheet, sheetRead.Point);
var vhead = headList.Where(t => t.PointCell != sheetRead.Point.StandardCellNum && t.PointCell != sheetRead.Point.DeptCellNum)
var vhead = headList.Where(t => t.PointCell != sheetRead.Point.AccountingUnitCellNum && t.PointCell != sheetRead.Point.DeptCellNum)
.OrderBy(t => t.PointCell);
for (int r = sheetRead.Point.DataFirstRowNum.Value; r < sheet.LastRowNum + 1; r++)
......
......@@ -7,28 +7,28 @@ namespace Performance.Services
{
public class PerSheetDataFactory
{
public static IPerSheetDataRead GetAnalyze(SheetType sheetType)
public static IPerSheetDataRead GetDataRead(SheetType sheetType)
{
IPerSheetDataRead analyze = null;
IPerSheetDataRead dataread = null;
switch (sheetType)
{
case SheetType.Employee:
analyze = new PerSheetDataReadEmployee();
dataread = new PerSheetDataReadEmployee();
break;
case SheetType.Income:
dataread = new PerSheetDataReadIncome();
break;
case SheetType.Expend:
analyze = new PerSheetDataReadExpend();
dataread = new PerSheetDataReadExpend();
break;
case SheetType.Overtime:
dataread = new PerSheetDataReadOvertime();
break;
case SheetType.Workload:
analyze = new PerSheetDataReadWorkload();
break;
default:
dataread = new PerSheetDataReadWorkload();
break;
}
return analyze;
return dataread;
}
}
}
......@@ -14,7 +14,7 @@ public class PerSheetDataReadEmployee : IPerSheetDataRead
HeaderLastRowNum = 0,
HeaderFirstCellNum = 0,
DataFirstRowNum = 1,
StandardCellNum = 0,
AccountingUnitCellNum = 0,
DeptCellNum = 1
};
......@@ -22,7 +22,7 @@ public PerData GetPerData(IRow row, PerHeader perHeader)
{
return new PerDataEmployee
{
AccountingUnit = row.GetCell(Point.StandardCellNum.Value)?.ToString(),
AccountingUnit = row.GetCell(Point.AccountingUnitCellNum.Value)?.ToString(),
Department = row.GetCell(Point.DeptCellNum.Value)?.ToString(),
TypeName = perHeader?.CellName,
CellValue = row.GetCell(perHeader.PointCell)?.ToString(),
......
......@@ -16,7 +16,7 @@ public class PerSheetDataReadExpend : IPerSheetDataRead
HeaderFirstCellNum = 3,
DataFirstRowNum = 6,
FactorRow = 5,
StandardCellNum = 3,
AccountingUnitCellNum = 3,
DeptCellNum = 4
};
......@@ -24,7 +24,7 @@ public PerData GetPerData(IRow row, PerHeader perHeader)
{
return new PerDataExpend
{
AccountingUnit = row.GetCell(Point.StandardCellNum.Value).ToString(),
AccountingUnit = row.GetCell(Point.AccountingUnitCellNum.Value).ToString(),
Department = row.GetCell(Point.DeptCellNum.Value).ToString(),
ParentType = perHeader.Parent?.CellName,
TypeName = perHeader.CellName,
......
using NPOI.SS.UserModel;
using Performance.DtoModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace Performance.Services
{
public class PerSheetDataReadIncome : IPerSheetDataRead
{
public PerSheetPoint Point => new PerSheetPoint
{
HeaderFirstRowNum = 1,
HeaderLastRowNum = 1,
HeaderFirstCellNum = 0,
DataFirstRowNum = 4,
AccountingUnitCellNum = 0,
DeptCellNum = 1,
FactorRow = 1,
};
public PerData GetPerData(IRow row, PerHeader perHeader)
{
throw new NotImplementedException();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
using NPOI.SS.UserModel;
using Performance.DtoModels;
namespace Performance.Services
{
public class PerSheetDataReadOvertime : IPerSheetDataRead
{
public PerSheetPoint Point => throw new NotImplementedException();
public PerData GetPerData(IRow row, PerHeader perHeader)
{
throw new NotImplementedException();
}
}
}
......@@ -15,7 +15,7 @@ public class PerSheetDataReadWorkload : IPerSheetDataRead
HeaderLastRowNum = 2,
HeaderFirstCellNum = 1,
DataFirstRowNum = 3,
StandardCellNum = 1,
AccountingUnitCellNum = 1,
DeptCellNum = 2
};
......@@ -23,7 +23,7 @@ public PerData GetPerData(IRow row, PerHeader perHeader)
{
return new PerDataWorkload
{
AccountingUnit = row.GetCell(Point.StandardCellNum.Value).ToString(),
AccountingUnit = row.GetCell(Point.AccountingUnitCellNum.Value).ToString(),
Department = row.GetCell(Point.DeptCellNum.Value).ToString(),
ParentType = perHeader.Parent?.CellName,
TypeName = perHeader.CellName,
......
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