Commit dab5dc27 by wyc

科室绩效详情——加载

parent 6bd61862
using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Newtonsoft.Json;
using Performance.DtoModels;
using Performance.DtoModels.Request;
using Performance.EntityModels;
......@@ -211,6 +212,37 @@ public ApiResponse UniteDeptDetail([FromBody] UniteDeptDetailRequest request)
return new ApiResponse(ResponseType.OK, response);
}
/// <summary>
/// 科室绩效详情下载
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
[HttpPost]
[Route("download/unite/deptdetail")]
//public IActionResult DownloadUniteDeptdetail([FromBody] UniteDeptDetailRequest request)
//{
// request.UnitType = request.UnitType.Replace("行政后勤", "行政工勤");
// if (!Enum.TryParse(request.UnitType, ignoreCase: true, out UnitType unitType))
// return BadRequest("核算组别错误");
// var userid = _claim.GetUserId();
// var result = _computeService.UniteDeptDetail(request.AllotId, unitType, request.AccountingUnit, userid);
// var ser = JsonConvert.SerializeObject(result);
// var rows = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(ser);
// return BadRequest("核算组别错误");
// //var filepath = _computeService.ExcelDownload(rows, "科室绩效详情", request.AllotId);
// //var memoryStream = new MemoryStream();
// //using (var stream = new FileStream(filepath, FileMode.Open))
// //{
// // stream.CopyToAsync(memoryStream).Wait();
// //}
// //memoryStream.Seek(0, SeekOrigin.Begin);
// //var provider = new FileExtensionContentTypeProvider();
// //FileInfo fileInfo = new FileInfo(filepath);
// //var memi = provider.Mappings[".xlsx"];
// //return File(memoryStream, memi, Path.GetFileName(fileInfo.Name));
//}
......
......@@ -1069,7 +1069,7 @@
</member>
<member name="M:Performance.Api.Controllers.ComputeController.DeptDetail(Performance.DtoModels.DeptDetailRequest)">
<summary>
科室绩效详情
科室绩效详情下载
</summary>
<param name="request"></param>
<returns></returns>
......
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
using Masuit.Tools;
using Newtonsoft.Json;
using NPOI.Util;
using OfficeOpenXml;
using OfficeOpenXml.Style;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Infrastructure;
......@@ -540,14 +544,20 @@ public List<UniteDeptDetailItem> GetUniteDeptDetailSetting(int allotId)
detail.Display = temp1.Display;
foreach (var item in detail.Children)
{
var temp2 = cofDeptDetail.FirstOrDefault(w => w.Title == item.Title);
if (temp2 == null) continue;
detail.SheetType = temp2.SheetType;
detail.Remark = temp2.Remark;
detail.Title = temp2.Title;
detail.Format = temp2.Format;
detail.Sort = temp2.Sort;
detail.Display = temp2.Display;
var temp1children = temp1.Children.FirstOrDefault(w => w.Title == item.Title);
if (temp1children == null) continue;
item.SheetType = temp1children.SheetType;
item.Remark = temp1children.Remark;
item.Title = temp1children.Title;
item.Format = temp1children.Format;
item.Sort = temp1children.Sort;
item.Display = temp1children.Display;
}
foreach (var item2 in temp1.Children)
{
var detailChildren = detail.Children.FirstOrDefault(w => w.Title == item2.Title);
if (detailChildren == null)
detail.Children.Add(item2);
}
}
......@@ -569,5 +579,108 @@ public void SaveUniteDeptDetailSetting(int allotId, List<UniteDeptDetailItem> re
_perforCofDeptDetailRepository.Update(entity);
}
}
#region 科室详情下载
//public string ExcelDownload(List<Dictionary<string, object>> rows, string name, int allotId)
//{
// var perAllot = perforPerallotRepository.GetEntity(t => t.ID == allotId);
// string title = $"{perAllot.Year}年{perAllot.Month}月{name}";
// var data = new List<Dictionary<string, object>>();
// foreach (var obj in rows)
// {
// Dictionary<string, object> nobj = new Dictionary<string, object>();
// foreach (var item in obj)
// {
// var lower = item.Key.ToLower();
// if (lower.Contains("date"))
// nobj[lower] = Convert.ToDateTime(item.Value).ToString("d");
// else if (lower.Contains("detial"))
// {
// var detRows = JsonConvert.DeserializeObject<List<Dictionary<string, object>>>(item.Value.ToString());
// foreach (var detlist in detRows)
// {
// object value = null;
// foreach (var detitem in detlist)
// {
// if (detitem.Key.Equals("Value", StringComparison.OrdinalIgnoreCase))
// value = detitem.Value;
// if (detitem.Key.Equals("Title", StringComparison.OrdinalIgnoreCase))
// nobj[detitem.Value.ToString()] = value;
// }
// }
// }
// else
// nobj[lower] = item.Value;
// }
// data.Add(nobj);
// }
// var dpath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Files");
// if (!Directory.Exists(dpath)) Directory.CreateDirectory(dpath);
// string filepath = Path.Combine(dpath, $"{name}{DateTime.Now:yyyy年MM月dd日}");
// if (File.Exists(filepath)) File.Delete(filepath);
// using (FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate))
// using (ExcelPackage package = new ExcelPackage(fs))
// {
// var worksheet = package.Workbook.Worksheets.Add(name);
// if (rows != null && rows.Count() > 0)
// {
// worksheet.SetValue(1, 1, title);
// for (int col = 0; col < headList.Count; col++)
// {
// worksheet.SetValue(2, col + 1, headList[col].Alias);
// }
// for (int col = 0; col < headList.Count; col++)
// {
// for (int row = 0; row < data.Count(); row++)
// {
// var temp = data.ElementAt(row);
// var key = headList[col].Name;
// if (!temp.ContainsKey(key))
// key = key.ToLower();
// temp.TryGetValue(key, out object value);
// worksheet.Cells[row + 3, col + 1].Value = value ?? "";
// }
// }
// #region 样式设置
// for (int row = worksheet.Dimension.Start.Row; row <= worksheet.Dimension.End.Row; row++)
// {
// worksheet.Row(row).Height = 20;
// for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
// {
// worksheet.Cells[row, col].Style.Border.BorderAround(ExcelBorderStyle.Thin);
// worksheet.Cells[row, col].Style.VerticalAlignment = ExcelVerticalAlignment.Center;
// worksheet.Cells[row, col].Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
// }
// }
// //worksheet.Cells[1, 1, 1, headList.Count].Merge = true;
// //worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Bold = true;
// //worksheet.Cells[1, 1, 1, headList.Count].Style.Font.Size = 16;
// //worksheet.Row(1).Height = 24;
// //worksheet.Cells[2, 1, 2, headList.Count].Style.Font.Bold = true;
// worksheet.View.FreezePanes(3, 1);
// worksheet.Cells.AutoFitColumns();
// for (int col = worksheet.Dimension.Start.Column; col <= worksheet.Dimension.End.Column; col++)
// {
// worksheet.Column(col).Width = worksheet.Column(col).Width > 20 ? 20 : worksheet.Column(col).Width;
// }
// #endregion
// }
// package.Save();
// }
// return filepath;
//}
#endregion
}
}
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