Commit e6ad023d by lcx

划拨写入

parent 986568cb
......@@ -67,6 +67,11 @@ public class cost_transfer_item
public int Status { get; set; }
/// <summary>
/// 绩效办审核状态 0 默认 1 通过 2 驳回 3 下发驳回
/// </summary>
public int AdminStatus { get; set; }
/// <summary>
/// 数据是否被写入
/// </summary>
public int IsWrited { get; set; }
......
using Microsoft.Extensions.Logging;
using NPOI.SS.UserModel;
using Performance.DtoModels;
using Performance.EntityModels;
using Performance.Repository;
using System;
using System.Collections.Generic;
......@@ -35,17 +36,42 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, ExcelStyle style,
var costTransfers = costtransferRepository.GetEntities(t => t.AllotId == allotId);
if (costTransfers == null || !costTransfers.Any()) return;
var costTransferItems = costtransferitemRepository.GetEntities(t => costTransfers.Select(c => c.Id).Contains(t.TransferId));
var costTransferItems = costtransferitemRepository.GetEntities(t => costTransfers.Select(c => c.Id).Contains(t.TransferId) && t.Status == 1 && t.AdminStatus == 1);
if (costTransferItems == null || !costTransferItems.Any()) return;
var columns = SupplySheetHeader(sheet, point);
if (columns == null || !columns.Any()) return;
var departments = costTransfers.Select(t => t.AdoptedDepartment ?? "").Union(costTransfers.Select(t => t.ApplicantDepartment ?? "")).Distinct();
var standardDict = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId) ?? new List<EntityModels.per_dept_dic>();
var departments = costTransfers.Select(t => t.AdoptedDepartment ?? "").Union(costTransfers.Select(t => t.ApplicantDepartment ?? "")).Distinct().ToList();
var standardDict = perdeptdicRepository.GetEntities(t => t.HospitalId == hospitalId) ?? new List<per_dept_dic>();
var unittypes = new string[] { UnitType.护理组.ToString(), UnitType.医生组.ToString(), UnitType.医技组.ToString() };
for (int i = point.DataFirstRowNum.Value; i < sheet.LastRowNum + 1; i++)
{
var row = sheet.GetOrCreate(i);
var department = row.GetOrCreate(point.DataFirstCellNum.Value - 1).GetDecodeEscapes();
foreach (var unittype in unittypes)
{
var key = columns.Keys.FirstOrDefault(t => t.Contains(unittype.Replace("组", "")));
if (string.IsNullOrEmpty(key)) continue;
var index = columns[key];
var cell = row.GetOrCreate(index);
var score = GetTransfersByDeptAndUnittype(costTransfers, costTransferItems, department, unittype);
cell.SetCellOValue(score);
}
departments.Remove(department);
}
if (departments == null || !departments.Any()) return;
foreach (var department in departments)
{
}
}
catch (Exception ex)
{
......@@ -59,7 +85,7 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, ExcelStyle style,
var header = sheet.GetRow(point.HeaderFirstRowNum.Value);
if (header == null) return pairs;
List<string> fixedColumns = new List<string> { "划拨(出)收入", "划拨(入)收入", "划拨收入(医技)", "划拨收入(医生)", "划拨收入(护理)" };
List<string> fixedColumns = new List<string> { "划拨收入(医技)", "划拨收入(医生)", "划拨收入(护理)" };
for (int i = point.HeaderFirstCellNum.Value; i < header.LastCellNum; i++)
{
......@@ -89,5 +115,32 @@ public void WriteSheetData(ISheet sheet, PerSheetPoint point, ExcelStyle style,
return pairs;
}
private decimal GetTransfersByDeptAndUnittype(List<cost_transfer> costTransfers, List<cost_transfer_item> costTransferItems, string department, string unittype)
{
if (costTransfers == null || !costTransfers.Any()) return 0;
var isApplications = new bool[] { true, false };
var scores = new List<decimal>();
foreach (var isApplication in isApplications)
{
var data = isApplication
? costTransfers.Where(t => t.ApplicantDepartment == department && t.ApplicantUnitType == unittype)?.ToList()
: costTransfers.Where(t => t.AdoptedDepartment == department && t.AdoptedUnitType == unittype)?.ToList();
if (data == null || !data.Any()) return 0;
var items = costTransferItems.Where(t => data.Select(s => s.Id).Contains(t.TransferId))?.ToList();
if (items == null || !items.Any()) return 0;
items.ForEach(t => t.IsWrited = 1);
costtransferitemRepository.UpdateRange(items.ToArray());
int sign = isApplication ? 1 : -1;
var value = items.Sum(t => (t.CalculationAmount ?? 0) * sign);
scores.Add(value);
}
return scores.Sum(t => t);
}
}
}
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