Commit ed9bf788 by lcx

保存数据类型错误,新增绩效,生成绩效插入科室bug修复

parent 352a09da
...@@ -176,7 +176,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A ...@@ -176,7 +176,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成"); return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成");
logManageService.WriteMsg("生成绩效准备中", $"准备生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效,请稍等!", 1, allot.ID, "ReceiveMessage", true); logManageService.WriteMsg("生成绩效准备中", $"准备生成{allot.Year}-{allot.Month.ToString().PadLeft(2, '0')}月份绩效,请稍等!", 1, allot.ID, "ReceiveMessage", true);
_allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait)); _allotService.UpdateAllotStates(allot.ID, (int)AllotStates.Wait, EnumHelper.GetDescription(AllotStates.Wait), allot.Generate);
if (_evn.IsEnvironment("Localhost")) if (_evn.IsEnvironment("Localhost"))
_allotService.Generate(allot, email); _allotService.Generate(allot, email);
else else
......
...@@ -37,6 +37,9 @@ public class OriginalController : Controller ...@@ -37,6 +37,9 @@ public class OriginalController : Controller
[HttpPost] [HttpPost]
public ApiResponse FactorEdit([FromBody] OriginalRequest request) public ApiResponse FactorEdit([FromBody] OriginalRequest request)
{ {
if (request.Cell.Id <= 0)
return new ApiResponse(ResponseType.Fail, "暂不支持修改");
var result = originalService.EditFactorData(claim.GetUserId(), request); var result = originalService.EditFactorData(claim.GetUserId(), request);
return result ? new ApiResponse(ResponseType.OK, "修改成功") : new ApiResponse(ResponseType.Fail, "修改失败"); return result ? new ApiResponse(ResponseType.OK, "修改成功") : new ApiResponse(ResponseType.Fail, "修改失败");
} }
......
...@@ -2843,6 +2843,11 @@ ...@@ -2843,6 +2843,11 @@
数据库字段名称 数据库字段名称
</summary> </summary>
</member> </member>
<member name="P:Performance.DtoModels.Cell.CellType">
<summary>
单元格数据分类
</summary>
</member>
<member name="P:Performance.DtoModels.SheetResponse.SheetID"> <member name="P:Performance.DtoModels.SheetResponse.SheetID">
<summary> <summary>
SheetID SheetID
......
...@@ -10,6 +10,14 @@ public class OriginalRequest ...@@ -10,6 +10,14 @@ public class OriginalRequest
public int RowNumber { get; set; } public int RowNumber { get; set; }
public Cell Cell { get; set; } public CellRequest Cell { get; set; }
}
public class CellRequest
{
public int PointCell { get; set; }
public object CellValue { get; set; }
public int Id { get; set; }
public string FieldName { get; set; }
} }
} }
...@@ -98,9 +98,14 @@ public object CellValue ...@@ -98,9 +98,14 @@ public object CellValue
/// 数据库字段名称 /// 数据库字段名称
/// </summary> /// </summary>
public string FieldName { get; set; } public string FieldName { get; set; }
/// <summary>
/// 单元格数据分类
/// </summary>
public string CellType { get; set; }
public Cell() { } public Cell() { }
public Cell(int pointCell, object cellValue, int mergeRow, int mergeCell, bool isTotal, bool isNumValue, string annotation = "", int id = 0, string fieldName = "") public Cell(int pointCell, object cellValue, int mergeRow, int mergeCell, bool isTotal, bool isNumValue, string annotation = "", int id = 0, string fieldName = "", string cellType = "body")
{ {
PointCell = pointCell; PointCell = pointCell;
CellValue = cellValue; CellValue = cellValue;
...@@ -111,6 +116,7 @@ public Cell(int pointCell, object cellValue, int mergeRow, int mergeCell, bool i ...@@ -111,6 +116,7 @@ public Cell(int pointCell, object cellValue, int mergeRow, int mergeCell, bool i
Annotation = annotation; Annotation = annotation;
Id = id; Id = id;
FieldName = fieldName; FieldName = fieldName;
CellType = cellType;
} }
} }
} }
...@@ -90,10 +90,19 @@ public int SupplementaryData(int allotid) ...@@ -90,10 +90,19 @@ public int SupplementaryData(int allotid)
distinct @allotid allotid,typename charge distinct @allotid allotid,typename charge
from per_sheet sheet from per_sheet sheet
inner join im_data im on sheet.id = im.sheetid inner join im_data im on sheet.id = im.sheetid
inner join cof_drugtype dtype on sheet.allotid = dtype.allotid left join cof_drugtype dtype on sheet.allotid = dtype.allotid
and im.typename != dtype.charge and im.typename != dtype.charge
where sheet.allotid = @allotid and sheet.sheettype = 3 and im.typename not in where sheet.allotid = @allotid and sheet.sheettype = 3 and im.typename not in
(select charge from cof_drugtype where allotid = @allotid)"; (select charge from cof_drugtype where allotid = @allotid);
insert into cof_depttype(allotid,charge) select
distinct @allotid allotid,department charge
from per_sheet sheet
inner join im_data im on sheet.id = im.sheetid
left join cof_depttype dtype on sheet.allotid = dtype.allotid
and im.department != dtype.charge
where sheet.allotid = @allotid and sheet.sheettype = 9 and im.department not in
(select charge from cof_depttype where allotid = @allotid);";
return connection.Execute(sql, new { allotid }, commandTimeout: 60 * 60); return connection.Execute(sql, new { allotid }, commandTimeout: 60 * 60);
} }
......
...@@ -274,12 +274,15 @@ public void Generate(per_allot allot, string mail) ...@@ -274,12 +274,15 @@ public void Generate(per_allot allot, string mail)
int generate = allot.Generate; int generate = allot.Generate;
if (new int[] { (int)AllotGenerate.OriginalDataEdited, (int)AllotGenerate.PersonnelOffice }.Contains(allot.Generate)) if (new int[] { (int)AllotGenerate.OriginalDataEdited, (int)AllotGenerate.PersonnelOffice }.Contains(allot.Generate))
{ {
logManageService.WriteMsg("绩效开始执行", $"数据来源:生成成功后被修改的原数据。", 1, allot.ID, "ReceiveMessage", true);
generate = (int)AllotGenerate.Success; generate = (int)AllotGenerate.Success;
configService.ClearResData(allot.ID); configService.ClearResData(allot.ID);
excel = queryDataService.QueryDataAndHeader(allot); excel = queryDataService.QueryDataAndHeader(allot);
} }
else else
{ {
logManageService.WriteMsg("绩效开始执行", $"数据来源:用户上传的Excel。", 1, allot.ID, "ReceiveMessage", true);
configService.Clear(allot.ID); configService.Clear(allot.ID);
// 导出数据 // 导出数据
excel = importDataService.ReadDataAndSave(allot); excel = importDataService.ReadDataAndSave(allot);
......
...@@ -551,7 +551,8 @@ public void Copy(per_allot allot) ...@@ -551,7 +551,8 @@ public void Copy(per_allot allot)
{ {
var depttype = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId) var depttype = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId)
?? perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1); ?? perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
var newAgains = depttype.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType }); var newAgains = depttype?.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
if (newAgains != null && newAgains.Any())
perforCofdepttypeRepository.AddRange(newAgains.ToArray()); perforCofdepttypeRepository.AddRange(newAgains.ToArray());
} }
......
...@@ -109,6 +109,10 @@ public bool EditSheetData(int userId, OriginalRequest request) ...@@ -109,6 +109,10 @@ public bool EditSheetData(int userId, OriginalRequest request)
break; break;
} }
} }
catch (InvalidCastException ex)
{
throw new PerformanceException("提交参数不合规范");
}
catch (ArgumentException ex) catch (ArgumentException ex)
{ {
throw new PerformanceException("提交参数不合规范"); throw new PerformanceException("提交参数不合规范");
...@@ -160,12 +164,47 @@ private bool EditSpecialUnit(int userId, OriginalRequest request) ...@@ -160,12 +164,47 @@ private bool EditSpecialUnit(int userId, OriginalRequest request)
return imspecialunitRepository.Update(specialUnit); return imspecialunitRepository.Update(specialUnit);
} }
private void SetValue<TEntity>(TEntity entity, Cell cell) private void SetValue<TEntity>(TEntity entity, CellRequest cell)
{ {
var value = cell.CellValue; var value = cell.CellValue;
var property = typeof(TEntity).GetProperty(cell.FieldName);
if (value.ToString().IndexOf("%") > -1) if (value.ToString().IndexOf("%") > -1)
value = ConvertHelper.To<decimal>(value.ToString().Replace("%", "")) / 100; value = ConvertHelper.To<decimal>(value.ToString().Replace("%", "")) / 100;
typeof(TEntity).GetProperty(cell.FieldName).SetValue(entity, value); else if (cell.FieldName == "FitPeople")
{
var fit = EnumHelper.GetItems<PerforType>();
if (!fit.Select(t => t.Description).Contains(cell.CellValue.ToString()))
throw new PerformanceException("'绩效基数核算参考对象'提交值无效");
}
else if (cell.FieldName == "UnitType")
{
var fit = EnumHelper.GetItems<UnitType>();
if (!fit.Select(t => t.Description).Contains(cell.CellValue.ToString()))
throw new PerformanceException("'核算单元分类'提交值无效");
}
else
{
if (property == null)
throw new PerformanceException("提交参数信息无效");
if (value != null && value.ToString() != "")
{
string type = property.PropertyType.FullName.ToLower();
if (type.IndexOf("int") > -1)
value = Convert.ToInt32(value);
else if (type.IndexOf("decimal") > -1)
value = Convert.ToDecimal(value);
else if (type.IndexOf("datetime") > -1)
value = Convert.ToDateTime(value);
else if (type.IndexOf("datetime") > -1)
value = Convert.ToDateTime(value);
else if (type.IndexOf("string") > -1)
value = cell.CellValue.ToString();
}
else
value = null;
}
property.SetValue(entity, value);
} }
#endregion #endregion
...@@ -190,17 +229,18 @@ private bool EditFeeData(int userId, OriginalRequest request) ...@@ -190,17 +229,18 @@ private bool EditFeeData(int userId, OriginalRequest request)
{ {
if (request.Cell.Id > 0) if (request.Cell.Id > 0)
{ {
var type = request.Cell.CellValue.GetType(); try
if (type.Name != "String")
{ {
var entity = imdataRepository.GetEntity(w => w.ID == request.Cell.Id); var entity = imdataRepository.GetEntity(w => w.ID == request.Cell.Id);
entity.CellValue = ConvertHelper.To<decimal?>(request.Cell.CellValue); entity.CellValue = Convert.ToDecimal(request.Cell.CellValue);
entity.UpdateDate = DateTime.Now; entity.UpdateDate = DateTime.Now;
entity.UpdateUser = userId; entity.UpdateUser = userId;
result = imdataRepository.Update(entity); result = imdataRepository.Update(entity);
} }
else catch (Exception ex)
throw new ArgumentException("提交参数不合规范"); {
throw new PerformanceException("提交参数不合规范");
}
} }
else else
result = ImDataInsert(userId, request, header); result = ImDataInsert(userId, request, header);
...@@ -266,8 +306,10 @@ private bool ImDataInsert(int userId, OriginalRequest request, im_header header) ...@@ -266,8 +306,10 @@ private bool ImDataInsert(int userId, OriginalRequest request, im_header header)
{ {
t.Key.UnitType, t.Key.UnitType,
t.Key.TypeName, t.Key.TypeName,
FactorValue = t.Max(group => group.FactorValue) FactorValue = t.Max(group => group.FactorValue) ?? 0
}); });
if (factor == null || !factor.Any())
factor = unittype.Select(t => new { UnitType = t, TypeName = request.Cell.FieldName, FactorValue = 0m });
var allotid = allData.First().AllotID; var allotid = allData.First().AllotID;
var newData = factor.Select(t => new im_data var newData = factor.Select(t => new im_data
{ {
......
...@@ -132,18 +132,18 @@ private void CommonExport(int sheetID, SheetExportResponse response) ...@@ -132,18 +132,18 @@ private void CommonExport(int sheetID, SheetExportResponse response)
var factorhead = new Row(0); var factorhead = new Row(0);
if (sheet.SheetType == (int)SheetType.Workload) if (sheet.SheetType == (int)SheetType.Workload)
{ {
factorhead.Data.Add(new Cell(0, "单元工作量绩效标准:", 1, 2, false, false)); factorhead.Data.Add(new Cell(0, "单元工作量绩效标准:", 1, 2, false, false, cellType: "factor"));
response = AddFactor(response, factorhead, headList.ToList(), dataList); response = AddFactor(response, factorhead, headList.ToList(), dataList);
} }
else if (sheet.SheetType == (int)SheetType.OtherIncome || sheet.SheetType == (int)SheetType.Income || sheet.SheetType == (int)SheetType.Expend) else if (sheet.SheetType == (int)SheetType.OtherIncome || sheet.SheetType == (int)SheetType.Income || sheet.SheetType == (int)SheetType.Expend)
{ {
factorhead.Data.Add(new Cell(0, "护理组分割比例", 1, merge, false, false)); factorhead.Data.Add(new Cell(0, "护理组分割比例", 1, merge, false, false, cellType: "factor"));
response = AddFactor(response, factorhead, headList.ToList(), dataList, UnitType.护理组); response = AddFactor(response, factorhead, headList.ToList(), dataList, UnitType.护理组);
var factorhead1 = new Row(1); var factorhead1 = new Row(1);
factorhead1.Data.Add(new Cell(0, "医生组分割比例", 1, merge, false, false)); factorhead1.Data.Add(new Cell(0, "医生组分割比例", 1, merge, false, false, cellType: "factor"));
response = AddFactor(response, factorhead1, headList.ToList(), dataList, UnitType.医生组); response = AddFactor(response, factorhead1, headList.ToList(), dataList, UnitType.医生组);
var factorhead2 = new Row(2); var factorhead2 = new Row(2);
factorhead2.Data.Add(new Cell(0, "医技组分割比例", 1, merge, false, false)); factorhead2.Data.Add(new Cell(0, "医技组分割比例", 1, merge, false, false, cellType: "factor"));
response = AddFactor(response, factorhead2, headList.ToList(), dataList, UnitType.医技组); response = AddFactor(response, factorhead2, headList.ToList(), dataList, UnitType.医技组);
} }
...@@ -171,7 +171,7 @@ private void CommonExport(int sheetID, SheetExportResponse response) ...@@ -171,7 +171,7 @@ private void CommonExport(int sheetID, SheetExportResponse response)
response.Header.Add(rowhead); response.Header.Add(rowhead);
foreach (var header in headList.Where(t => !t.ParentID.HasValue || t.ParentID.Value == 0)) foreach (var header in headList.Where(t => !t.ParentID.HasValue || t.ParentID.Value == 0))
{ {
rowhead.Data.Add(new Cell(header.PointCell.Value, header.CellValue, header.MergeRow.Value, header.MergeCell.Value, header.IsTotal == 1, false, id: header.ID, fieldName: header.CellValue)); rowhead.Data.Add(new Cell(header.PointCell.Value, header.CellValue, header.MergeRow.Value, header.MergeCell.Value, header.IsTotal == 1, false, id: header.ID, fieldName: header.CellValue, cellType: "header"));
} }
if (headList.Any(t => t.ParentID.HasValue && t.ParentID.Value > 0)) if (headList.Any(t => t.ParentID.HasValue && t.ParentID.Value > 0))
{ {
...@@ -179,7 +179,7 @@ private void CommonExport(int sheetID, SheetExportResponse response) ...@@ -179,7 +179,7 @@ private void CommonExport(int sheetID, SheetExportResponse response)
response.Header.Add(rowhead2); response.Header.Add(rowhead2);
foreach (var header in headList.Where(t => t.ParentID.HasValue && t.ParentID.Value > 0)) foreach (var header in headList.Where(t => t.ParentID.HasValue && t.ParentID.Value > 0))
{ {
rowhead2.Data.Add(new Cell(header.PointCell.Value, header.CellValue, header.MergeRow.Value, header.MergeCell.Value, header.IsTotal == 1, false, id: header.ID, fieldName: header.CellValue)); rowhead2.Data.Add(new Cell(header.PointCell.Value, header.CellValue, header.MergeRow.Value, header.MergeCell.Value, header.IsTotal == 1, false, id: header.ID, fieldName: header.CellValue, cellType: "header"));
} }
} }
List<im_header> headers = new List<im_header>(); List<im_header> headers = new List<im_header>();
...@@ -436,7 +436,7 @@ private void EmployeeExport(int sheetID, SheetExportResponse response) ...@@ -436,7 +436,7 @@ private void EmployeeExport(int sheetID, SheetExportResponse response)
int index = 1; int index = 1;
foreach (var item in pairs) foreach (var item in pairs)
{ {
row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6, fieldName: item.Item8)); row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6, fieldName: item.Item8, cellType: "header"));
index += 1; index += 1;
} }
response.Header.Add(row); response.Header.Add(row);
...@@ -480,7 +480,7 @@ private void ClinicEmployeeExport(int sheetID, SheetExportResponse response) ...@@ -480,7 +480,7 @@ private void ClinicEmployeeExport(int sheetID, SheetExportResponse response)
int index = 1; int index = 1;
foreach (var item in pairs) foreach (var item in pairs)
{ {
row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6, fieldName: item.Item8)); row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6, fieldName: item.Item8, cellType: "header"));
index += 1; index += 1;
} }
response.Header.Add(row); response.Header.Add(row);
...@@ -493,9 +493,9 @@ private void ClinicEmployeeExport(int sheetID, SheetExportResponse response) ...@@ -493,9 +493,9 @@ private void ClinicEmployeeExport(int sheetID, SheetExportResponse response)
foreach (var item in pairs) foreach (var item in pairs)
{ {
if (item.Item7) if (item.Item7)
rowbody.Data.Add(new Cell(index, $"{item.Item2.Invoke(employee)}%", item.Item3, item.Item4, item.Item5, item.Item6, id: employee.ID)); rowbody.Data.Add(new Cell(index, $"{item.Item2.Invoke(employee)}%", item.Item3, item.Item4, item.Item5, item.Item6, id: employee.ID, fieldName: item.Item8));
else else
rowbody.Data.Add(new Cell(index, item.Item2.Invoke(employee), item.Item3, item.Item4, item.Item5, item.Item6, id: employee.ID)); rowbody.Data.Add(new Cell(index, item.Item2.Invoke(employee), item.Item3, item.Item4, item.Item5, item.Item6, id: employee.ID, fieldName: item.Item8));
index += 1; index += 1;
} }
response.Row.Add(rowbody); response.Row.Add(rowbody);
...@@ -514,7 +514,7 @@ private void SpecialUnitExport(int sheetID, SheetExportResponse response) ...@@ -514,7 +514,7 @@ private void SpecialUnitExport(int sheetID, SheetExportResponse response)
int index = 1; int index = 1;
foreach (var item in pairs) foreach (var item in pairs)
{ {
row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6, fieldName: item.Item8)); row.Data.Add(new Cell(index, item.Item1, item.Item3, item.Item4, item.Item5, item.Item6, fieldName: item.Item8, cellType: "header"));
index += 1; index += 1;
} }
response.Header.Add(row); response.Header.Add(row);
...@@ -558,7 +558,7 @@ private SheetExportResponse AddFactor(SheetExportResponse response, Row row, Lis ...@@ -558,7 +558,7 @@ private SheetExportResponse AddFactor(SheetExportResponse response, Row row, Lis
{ {
var value = dataList.FirstOrDefault(t => t.AllotID == header.AllotID && t.SheetID == header.SheetID && t.IsFactor == 1 var value = dataList.FirstOrDefault(t => t.AllotID == header.AllotID && t.SheetID == header.SheetID && t.IsFactor == 1
&& t.TypeName == header.CellValue); && t.TypeName == header.CellValue);
row.Data.Add(new Cell(header.PointCell.Value, value?.FactorValue, 1, 1, header.IsTotal == 1, false, id: value?.ID ?? 0, fieldName: header.CellValue)); row.Data.Add(new Cell(header.PointCell.Value, value?.FactorValue, 1, 1, header.IsTotal == 1, false, id: value?.ID ?? 0, fieldName: header.CellValue, cellType: "factor"));
} }
} }
} }
...@@ -571,7 +571,7 @@ private SheetExportResponse AddFactor(SheetExportResponse response, Row row, Lis ...@@ -571,7 +571,7 @@ private SheetExportResponse AddFactor(SheetExportResponse response, Row row, Lis
{ {
var value = dataList.FirstOrDefault(t => t.AllotID == header.AllotID && t.SheetID == header.SheetID && t.IsFactor == 1 var value = dataList.FirstOrDefault(t => t.AllotID == header.AllotID && t.SheetID == header.SheetID && t.IsFactor == 1
&& t.TypeName == header.CellValue && t.UnitType == (int)unitType); && t.TypeName == header.CellValue && t.UnitType == (int)unitType);
row.Data.Add(new Cell(header.PointCell.Value, value?.FactorValue, 1, 1, header.IsTotal == 1, false, id: value?.ID ?? 0, fieldName: header.CellValue)); row.Data.Add(new Cell(header.PointCell.Value, value?.FactorValue, 1, 1, header.IsTotal == 1, false, id: value?.ID ?? 0, fieldName: header.CellValue, cellType: "factor"));
} }
} }
} }
......
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