Commit ed9bf788 by lcx

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

parent 352a09da
......@@ -176,7 +176,7 @@ public ApiResponse Generate([CustomizeValidator(RuleSet = "Delete"), FromBody] A
return new ApiResponse(ResponseType.OK, "当前绩效正在等待生成");
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"))
_allotService.Generate(allot, email);
else
......
......@@ -37,6 +37,9 @@ public class OriginalController : Controller
[HttpPost]
public ApiResponse FactorEdit([FromBody] OriginalRequest request)
{
if (request.Cell.Id <= 0)
return new ApiResponse(ResponseType.Fail, "暂不支持修改");
var result = originalService.EditFactorData(claim.GetUserId(), request);
return result ? new ApiResponse(ResponseType.OK, "修改成功") : new ApiResponse(ResponseType.Fail, "修改失败");
}
......@@ -62,7 +65,7 @@ public ApiResponse HeaderEdit([FromBody] OriginalRequest request)
[HttpPost]
public ApiResponse SheetEdit([FromBody] OriginalRequest request)
{
var result = originalService.EditSheetData(claim.GetUserId(), request);
var result = originalService.EditSheetData(claim.GetUserId(), request);
return result ? new ApiResponse(ResponseType.OK, "修改成功") : new ApiResponse(ResponseType.Fail, "修改失败");
}
}
......
......@@ -2843,6 +2843,11 @@
数据库字段名称
</summary>
</member>
<member name="P:Performance.DtoModels.Cell.CellType">
<summary>
单元格数据分类
</summary>
</member>
<member name="P:Performance.DtoModels.SheetResponse.SheetID">
<summary>
SheetID
......
......@@ -10,6 +10,14 @@ public class OriginalRequest
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
/// 数据库字段名称
/// </summary>
public string FieldName { get; set; }
/// <summary>
/// 单元格数据分类
/// </summary>
public string CellType { get; set; }
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;
CellValue = cellValue;
......@@ -111,6 +116,7 @@ public Cell(int pointCell, object cellValue, int mergeRow, int mergeCell, bool i
Annotation = annotation;
Id = id;
FieldName = fieldName;
CellType = cellType;
}
}
}
......@@ -90,10 +90,19 @@ public int SupplementaryData(int allotid)
distinct @allotid allotid,typename charge
from per_sheet sheet
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
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);
}
......
......@@ -274,12 +274,15 @@ public void Generate(per_allot allot, string mail)
int generate = 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;
configService.ClearResData(allot.ID);
excel = queryDataService.QueryDataAndHeader(allot);
}
else
{
logManageService.WriteMsg("绩效开始执行", $"数据来源:用户上传的Excel。", 1, allot.ID, "ReceiveMessage", true);
configService.Clear(allot.ID);
// 导出数据
excel = importDataService.ReadDataAndSave(allot);
......
......@@ -549,10 +549,11 @@ public void Copy(per_allot allot)
var cofDepttype = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allot.ID);
if (cofDepttype == null || cofDepttype.Count == 0)
{
var depttype = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId)
var depttype = perforCofdepttypeRepository.GetEntities(t => t.AllotID == allotId)
?? perforCofdepttypeRepository.GetEntities(t => t.AllotID == -1);
var newAgains = depttype.Select(t => new cof_depttype { AllotID = allot.ID, Charge = t.Charge, ChargeType = t.ChargeType });
perforCofdepttypeRepository.AddRange(newAgains.ToArray());
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());
}
var workItem = _workitemRepository.GetEntities(t => t.AllotID == allot.ID);
......
......@@ -109,6 +109,10 @@ public bool EditSheetData(int userId, OriginalRequest request)
break;
}
}
catch (InvalidCastException ex)
{
throw new PerformanceException("提交参数不合规范");
}
catch (ArgumentException ex)
{
throw new PerformanceException("提交参数不合规范");
......@@ -160,12 +164,47 @@ private bool EditSpecialUnit(int userId, OriginalRequest request)
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 property = typeof(TEntity).GetProperty(cell.FieldName);
if (value.ToString().IndexOf("%") > -1)
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
......@@ -190,17 +229,18 @@ private bool EditFeeData(int userId, OriginalRequest request)
{
if (request.Cell.Id > 0)
{
var type = request.Cell.CellValue.GetType();
if (type.Name != "String")
try
{
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.UpdateUser = userId;
result = imdataRepository.Update(entity);
}
else
throw new ArgumentException("提交参数不合规范");
catch (Exception ex)
{
throw new PerformanceException("提交参数不合规范");
}
}
else
result = ImDataInsert(userId, request, header);
......@@ -266,8 +306,10 @@ private bool ImDataInsert(int userId, OriginalRequest request, im_header header)
{
t.Key.UnitType,
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 newData = factor.Select(t => new im_data
{
......
......@@ -132,18 +132,18 @@ private void CommonExport(int sheetID, SheetExportResponse response)
var factorhead = new Row(0);
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);
}
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.护理组);
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.医生组);
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.医技组);
}
......@@ -171,7 +171,7 @@ private void CommonExport(int sheetID, SheetExportResponse response)
response.Header.Add(rowhead);
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))
{
......@@ -179,7 +179,7 @@ private void CommonExport(int sheetID, SheetExportResponse response)
response.Header.Add(rowhead2);
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>();
......@@ -436,7 +436,7 @@ private void EmployeeExport(int sheetID, SheetExportResponse response)
int index = 1;
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;
}
response.Header.Add(row);
......@@ -480,7 +480,7 @@ private void ClinicEmployeeExport(int sheetID, SheetExportResponse response)
int index = 1;
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;
}
response.Header.Add(row);
......@@ -493,9 +493,9 @@ private void ClinicEmployeeExport(int sheetID, SheetExportResponse response)
foreach (var item in pairs)
{
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
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;
}
response.Row.Add(rowbody);
......@@ -514,7 +514,7 @@ private void SpecialUnitExport(int sheetID, SheetExportResponse response)
int index = 1;
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;
}
response.Header.Add(row);
......@@ -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
&& 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
{
var value = dataList.FirstOrDefault(t => t.AllotID == header.AllotID && t.SheetID == header.SheetID && t.IsFactor == 1
&& 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