save到数据库

parent 457e181a
......@@ -152,13 +152,13 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody]Al
var excel = _perExcelService.Import(allot.Path);
// 保存数据
//service.ImportSave(excel);
_perExcelService.Save(excel.PerSheet, allot.ID, 1);
// 计算合并数据
List<PerSheet> list = _perExcelService.ProcessCompute(excel);
// 保存过程数据
_perExcelService.ProcessSave(list, allot.ID);
_perExcelService.Save(list, allot.ID, 2);
// 计算最总数据
_perExcelService.Compute(excel);
......
......@@ -2,12 +2,34 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<None Remove="appsettings.Development.json" />
<None Remove="appsettings.json" />
</ItemGroup>
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="6.0.0" />
<PackageReference Include="CSRedisCore" Version="3.0.45" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
<PackageReference Include="MySql.Data" Version="8.0.15" />
<PackageReference Include="MySql.Data.EntityFrameworkCore" Version="8.0.15" />
</ItemGroup>
<ItemGroup>
......
using Performance.DtoModels;
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Performance.DtoModels;
using Performance.DtoModels.AppSettings;
using Performance.DtoModels.AutoMapper;
using Performance.EntityModels;
using Performance.Infrastructure;
using Performance.Repository;
using Performance.Services;
......@@ -17,47 +24,69 @@ static void Main(string[] args)
Console.WriteLine("Hello World!");
var builder = new ConfigurationBuilder()
.SetBasePath(AppDomain.CurrentDomain.BaseDirectory)
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile("appsettings.Development.json", optional: true, reloadOnChange: true);
IConfigurationRoot configuration = builder.Build();
ServiceCollection services = new ServiceCollection();
Mapper.Initialize(cfg => cfg.AddProfile<AutoMapperConfigs>());
services.AddAutoMapper();
//service注入 repoitory注入
services
.AddPerformanceService()
.AddPerformanceRepoitory();
var connection = configuration.GetSection("AppConnection:PerformanceConnectionString").Value;
services.AddDbContext<PerformanceDbContext>(options =>
{
options.UseMySQL(connection);
});
//PerHeaderService perHeaderService = new PerHeaderService();
//PerSheetService perSheetService = new PerSheetService(perHeaderService);
//PerExcelService perExcelService = new PerExcelService(perSheetService, perHeaderService);
////var excel = perExcelService.Import(@"E:\code_git\performance\performance\Performance.Api\Files\9\201911\医院绩效分配系统数据收集模板V120190307133444707.xlsx");
//var excel = perExcelService.Import(@"E:\code_git\performance\performance\Performance.Api\Files\9\201911\医院绩效分配系统数据收集模板V120190307133444707.xlsx");
PerExcelService perExcelService = services.BuildServiceProvider().GetService<PerExcelService>();
//// 拷贝配置信息
////perExcelService.Copy(allot.ID);
// 拷贝配置信息
//perExcelService.Copy(allot.ID);
//string path = @"E:\code_git\performance\performance\Performance.Api\Files\9\201911\医院绩效分配系统数据收集模板V120190307133444707.xlsx";
//// 导出数据
//var excel = perExcelService.Import(path);
string path = @"E:\code_git\performance\performance\Performance.Api\Files\9\201911\医院绩效分配系统数据收集模板V120190307133444707.xlsx";
// 导出数据
var excel = perExcelService.Import(path);
//var workbook1 = perExcelService.ExportCompute(excel.PerSheet);
var workbook1 = perExcelService.ExportCompute(excel.PerSheet);
//using (FileStream file = new FileStream($@"F:\myworkbook\org_{DateTime.Now.ToString("yyyyMMddhhmmss")}.xlsx", FileMode.Create))
//{
// workbook1.Write(file);
//}
using (FileStream file = new FileStream($@"F:\myworkbook\org_{DateTime.Now.ToString("yyyyMMddhhmmss")}.xlsx", FileMode.Create))
{
workbook1.Write(file);
}
//// 保存数据
////perExcelService.ImportSave(excel);
// 保存数据
perExcelService.Save(excel.PerSheet, 2, 1);
//// 计算合并数据
//List<PerSheet> list = perExcelService.ProcessCompute(excel);
// 计算合并数据
List<PerSheet> list = perExcelService.ProcessCompute(excel);
//// 保存过程数据
//perExcelService.ProcessSave(excel);
// 保存过程数据
perExcelService.Save(list, 2, 2);
//// 生成结果excel
//var workbook2 = perExcelService.ExportCompute(list);
// 生成结果excel
var workbook2 = perExcelService.ExportCompute(list);
//using (FileStream file = new FileStream($@"F:\myworkbook\comp_{DateTime.Now.ToString("yyyyMMddhhmmss")}.xlsx", FileMode.Create))
//{
// workbook2.Write(file);
//}
using (FileStream file = new FileStream($@"F:\myworkbook\comp_{DateTime.Now.ToString("yyyyMMddhhmmss")}.xlsx", FileMode.Create))
{
workbook2.Write(file);
}
//// 计算最总数据
//perExcelService.Compute(excel);
// 计算最总数据
perExcelService.Compute(excel);
Console.ReadKey();
}
......
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System": "Information",
"Microsoft": "Information"
}
},
"AppConnection": {
"PerformanceConnectionString": "server=192.168.18.166;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;",
"RedisConnectionString": "116.62.245.55:6379,defaultDatabase=1"
},
"Application": {
//登录过期时间
"ExpirationMinutes": "5",
//验证码过期
"SmsCodeMinutes": "5"
}
}
{
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
//连接字符串
"AppConnection": {
"PerformanceConnectionString": "server=116.62.245.55;database=db_performance;uid=suvalue;pwd=suvalue2017;pooling=true;charset=utf8;convert zero datetime=true;port=3306;connection timeout=120;max pool size=512;allow user variables=true;",
"HangfireRedisConnectionString": "116.62.245.55:6379,defaultDatabase=1",
"RedisConnectionString": "116.62.245.55:6379,defaultDatabase=2"
},
//互亿
"HuyiSmsConfig": {
"Url": "http://106.ihuyi.cn/webservice/sms.php?method=Submit",
"Account": "cf_szjk",
"Password": "123456"
},
"Application": {
//登录过期时间
"ExpirationMinutes": "120",
//验证码过期
"SmsCodeMinutes": "30",
//短信模板
"SmsTemplate": "溯直健康提醒您,您的验证码为:[code],当天有效!"
}
}
......@@ -27,7 +27,7 @@ public class SheetExportResponse
/// <summary>
/// sheet数据
/// </summary>
public List<Row> Row { get; set; }
public List<RowData> Row { get; set; }
public SheetExportResponse() { }
......@@ -37,39 +37,43 @@ public SheetExportResponse(int sheetID, string sheetName, int sheetType)
SheetName = sheetName;
SheetType = sheetType;
Header = new List<Row>();
Row = new List<Row>();
Row = new List<RowData>();
}
}
public class Row
{
public int Rownumber { get; set; }
public string AccountingUnit { get; set; }
public List<RowData> Data { get; set; }
public List<Cell> Data { get; set; }
public Row() { }
public Row(int rownumber)
{
Rownumber = rownumber;
Data = new List<RowData>();
Data = new List<Cell>();
}
public Row(int rownumber, string accountingUnit)
}
public class RowData : Row
{
public string AccountingUnit { get; set; }
public RowData(int rownumber, string accountingUnit)
{
Rownumber = rownumber;
AccountingUnit = accountingUnit;
Data = new List<RowData>();
Data = new List<Cell>();
}
}
public class RowData
public class Cell
{
public int PointCell { get; set; }
public object CellValue { get; set; }
public int MergeRow { get; set; }
public int MergeCell { get; set; }
public RowData() { }
public RowData(int pointCell, object cellValue, int mergeRow, int mergeCell)
public Cell() { }
public Cell(int pointCell, object cellValue, int mergeRow, int mergeCell)
{
PointCell = pointCell;
CellValue = cellValue;
......
......@@ -34,5 +34,10 @@ public class im_sheet
///
/// </summary>
public Nullable<int> SheetType { get; set; }
/// <summary>
/// Դ 1 excel 2
/// </summary>
public Nullable<int> Source { get; set; }
}
}
......@@ -77,15 +77,6 @@ public void Copy(int iD)
}
/// <summary>
/// 保存excel导出数据
/// </summary>
/// <param name="excel"></param>
public void ImportSave(PerExcel excel)
{
throw new NotImplementedException();
}
/// <summary>
/// 计算绩效
/// </summary>
/// <param name="excel"></param>
......@@ -97,12 +88,14 @@ public List<PerSheet> ProcessCompute(PerExcel excel)
/// <summary>
/// 保存绩效结果
/// </summary>
/// <param name="excel"></param>
public void ProcessSave(List<PerSheet> perSheets, int allotId)
/// <param name="perSheets"></param>
/// <param name="allotId"></param>
/// <param name="source">数据来源 1 excel 导入 2 计算</param>
public void Save(List<PerSheet> perSheets, int allotId, int source)
{
foreach (var sheet in perSheets)
{
var imsheet = new im_sheet { AllotID = allotId, SheetName = sheet.SheetName, SheetType = (int)sheet.SheetType };
var imsheet = new im_sheet { AllotID = allotId, SheetName = sheet.SheetName, Source = source, SheetType = (int)sheet.SheetType };
_perforImSheetRepository.Add(imsheet);
foreach (var header in sheet.PerHeader)
......
......@@ -65,6 +65,9 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
continue;
if (!string.IsNullOrEmpty(athead?.CellValue) && athead.CellValue.Contains("备注"))
continue;
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell)?.NumericCellValue);
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
PerData data = new PerData
{
......
......@@ -61,13 +61,16 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
if (string.IsNullOrEmpty(accountingUnit))
continue;
var athead = vhead.ElementAt(c);
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell)?.NumericCellValue);
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
PerData data = new PerData
{
RowNumber = r,
AccountingUnit = accountingUnit,
Department = row.GetCell(unit.DeptCellNum.Value)?.ToString(),
TypeName = athead?.CellValue,
CellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell)?.ToString()),
CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = unit.UnitType, //手动匹配
FactorValue = ConvertHelper.To<decimal?>(sheet.GetRow(unit.FactorRow.Value).GetCell(athead.PointCell)?.ToString()),
......
......@@ -49,13 +49,16 @@ public List<IPerData> ReadData(ISheet sheet, List<PerHeader> perHeader)
if (string.IsNullOrEmpty(accountingUnit))
continue;
var athead = vhead.ElementAt(c);
var cellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell)?.NumericCellValue);
if (!cellValue.HasValue || cellValue.Value == 0)
continue;
PerData data = new PerData
{
RowNumber = r,
AccountingUnit = accountingUnit,
Department = row.GetCell(unit.DeptCellNum.Value)?.ToString(),
TypeName = athead?.CellValue,
CellValue = ConvertHelper.To<decimal?>(row.GetCell(athead.PointCell)?.ToString()),
CellValue = cellValue,
Annotation = row.GetCell(athead.PointCell)?.CellComment?.String?.String,
UnitType = GetUnitType(sheet.SheetName, perHeader),
IsFactor = false,
......
......@@ -67,41 +67,41 @@ public SheetExportResponse SheetExport(int sheetID)
if (employeeList != null && employeeList.Count() > 0)
{
var row = new Row(0);
row.Data.Add(new RowData(1, "核算单元", 1, 1));
row.Data.Add(new RowData(2, "科室", 1, 1));
row.Data.Add(new RowData(3, "医生姓名", 1, 1));
row.Data.Add(new RowData(4, "职称", 1, 1));
row.Data.Add(new RowData(5, "绩效基数核算参考对象", 1, 1));
row.Data.Add(new RowData(6, "岗位系数", 1, 1));
row.Data.Add(new RowData(7, "考核得分率", 1, 1));
row.Data.Add(new RowData(8, "医生姓名", 1, 1));
row.Data.Add(new RowData(9, "出勤率", 1, 1));
row.Data.Add(new RowData(10, "核算单元医生数", 1, 1));
row.Data.Add(new RowData(11, "工作量绩效", 1, 1));
row.Data.Add(new RowData(12, "其他绩效", 1, 1));
row.Data.Add(new RowData(13, "医院奖罚", 1, 1));
row.Data.Add(new RowData(14, "调节系数", 1, 1));
row.Data.Add(new RowData(15, "发放系数", 1, 1));
row.Data.Add(new Cell(1, "核算单元", 1, 1));
row.Data.Add(new Cell(2, "科室", 1, 1));
row.Data.Add(new Cell(3, "医生姓名", 1, 1));
row.Data.Add(new Cell(4, "职称", 1, 1));
row.Data.Add(new Cell(5, "绩效基数核算参考对象", 1, 1));
row.Data.Add(new Cell(6, "岗位系数", 1, 1));
row.Data.Add(new Cell(7, "考核得分率", 1, 1));
row.Data.Add(new Cell(8, "医生姓名", 1, 1));
row.Data.Add(new Cell(9, "出勤率", 1, 1));
row.Data.Add(new Cell(10, "核算单元医生数", 1, 1));
row.Data.Add(new Cell(11, "工作量绩效", 1, 1));
row.Data.Add(new Cell(12, "其他绩效", 1, 1));
row.Data.Add(new Cell(13, "医院奖罚", 1, 1));
row.Data.Add(new Cell(14, "调节系数", 1, 1));
row.Data.Add(new Cell(15, "发放系数", 1, 1));
response.Header.Add(row);
for (int i = 0; i < employeeList.Count(); i++)
{
var item = employeeList.ElementAt(i);
var rowbody = new Row(i);
rowbody.Data.Add(new RowData(1, item.AccountingUnit, 1, 1));
rowbody.Data.Add(new RowData(2, item.Department, 1, 1));
rowbody.Data.Add(new RowData(3, item.DoctorName, 1, 1));
rowbody.Data.Add(new RowData(4, item.JobTitle, 1, 1));
rowbody.Data.Add(new RowData(5, item.FitPeople, 1, 1));
rowbody.Data.Add(new RowData(6, item.PostCoefficient, 1, 1));
rowbody.Data.Add(new RowData(7, item.WorkTime, 1, 1));
rowbody.Data.Add(new RowData(8, item.ScoreAverageRate, 1, 1));
rowbody.Data.Add(new RowData(9, item.Attendance, 1, 1));
rowbody.Data.Add(new RowData(10, item.PeopleNumber, 1, 1));
rowbody.Data.Add(new RowData(11, item.Workload, 1, 1));
rowbody.Data.Add(new RowData(12, item.OthePerfor, 1, 1));
rowbody.Data.Add(new RowData(13, item.Punishment, 1, 1));
rowbody.Data.Add(new RowData(14, item.Adjust, 1, 1));
rowbody.Data.Add(new RowData(15, item.Grant, 1, 1));
rowbody.Data.Add(new Cell(1, item.AccountingUnit, 1, 1));
rowbody.Data.Add(new Cell(2, item.Department, 1, 1));
rowbody.Data.Add(new Cell(3, item.DoctorName, 1, 1));
rowbody.Data.Add(new Cell(4, item.JobTitle, 1, 1));
rowbody.Data.Add(new Cell(5, item.FitPeople, 1, 1));
rowbody.Data.Add(new Cell(6, item.PostCoefficient, 1, 1));
rowbody.Data.Add(new Cell(7, item.WorkTime, 1, 1));
rowbody.Data.Add(new Cell(8, item.ScoreAverageRate, 1, 1));
rowbody.Data.Add(new Cell(9, item.Attendance, 1, 1));
rowbody.Data.Add(new Cell(10, item.PeopleNumber, 1, 1));
rowbody.Data.Add(new Cell(11, item.Workload, 1, 1));
rowbody.Data.Add(new Cell(12, item.OthePerfor, 1, 1));
rowbody.Data.Add(new Cell(13, item.Punishment, 1, 1));
rowbody.Data.Add(new Cell(14, item.Adjust, 1, 1));
rowbody.Data.Add(new Cell(15, item.Grant, 1, 1));
response.Header.Add(rowbody);
}
}
......@@ -117,7 +117,7 @@ public SheetExportResponse SheetExport(int sheetID)
response.Header.Add(rowhead);
foreach (var header in headList.Where(t => !t.ParentID.HasValue || t.ParentID.Value == 0))
{
rowhead.Data.Add(new RowData(header.PointCell.Value, header.CellValue, header.MergeRow.Value, header.MergeCell.Value));
rowhead.Data.Add(new Cell(header.PointCell.Value, header.CellValue, header.MergeRow.Value, header.MergeCell.Value));
}
if (headList.Any(t => t.ParentID.HasValue && t.ParentID.Value > 0))
{
......@@ -125,20 +125,20 @@ public SheetExportResponse SheetExport(int sheetID)
response.Header.Add(rowhead2);
foreach (var header in headList.Where(t => t.ParentID.HasValue && t.ParentID.Value > 0))
{
rowhead2.Data.Add(new RowData(header.PointCell.Value, header.CellValue, header.MergeRow.Value, header.MergeCell.Value));
rowhead2.Data.Add(new Cell(header.PointCell.Value, header.CellValue, header.MergeRow.Value, header.MergeCell.Value));
}
}
Row rowbody = null;
//创建数据行
RowData rowbody = null;
foreach (var data in dataList.OrderBy(t => t.RowNumber))
{
var header = headList.Where(t => t.CellValue == data.TypeName).OrderByDescending(t => t.ParentID).FirstOrDefault();
if (rowbody == null || rowbody.Rownumber != data.RowNumber)
{
rowbody = new Row(data.RowNumber.Value, data.AccountingUnit);
rowbody = new RowData(data.RowNumber.Value, data.AccountingUnit);
response.Row.Add(rowbody);
}
rowbody.Data.Add(new RowData(header.PointCell.Value, data.CellValue, 1, 1));
rowbody.Data.Add(new Cell(header.PointCell.Value, data.CellValue, 1, 1));
}
}
......
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