SpecialPointsHandler.cs 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using Microsoft.EntityFrameworkCore;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Threading.Tasks;
  6. using wispro.sp.share;
  7. namespace wispro.sp.api.AppealHandler
  8. {
  9. public class SpecialPointsHandler : IDoAppealObject
  10. {
  11. public void DoAppeal(AppealObject appeal, int appealRecordId, DbContext spContext)
  12. {
  13. bool isAggree = true;
  14. foreach (var iv in appeal.inputFieldValues)
  15. {
  16. if (iv.InputField == null)
  17. {
  18. iv.InputField = ((spDbContext)spContext).InputFields.FirstOrDefault(s => s.Id == iv.InputFieldId);
  19. }
  20. }
  21. var temField = appeal.inputFieldValues.FirstOrDefault(iv => iv.InputField.FieldName == "审核意见" && iv.Value == "同意");
  22. isAggree = (temField != null);
  23. if (isAggree)
  24. {
  25. var apRecord = ((spDbContext)spContext).AppealRecords.FirstOrDefault(p => p.Id == appealRecordId);
  26. if (apRecord != null)
  27. {
  28. var Item = ((spDbContext)spContext).PerformanceItems.FirstOrDefault(p=>p.Id == apRecord.ItemId);
  29. foreach (var iv in appeal.inputFieldValues)
  30. {
  31. if (iv.InputField.FieldName == "给定点数")
  32. {
  33. Item.BasePoint = double.Parse(iv.Value);
  34. }
  35. if (iv.InputField.FieldName == "绩效类型")
  36. {
  37. Item.Type = iv.Value;
  38. }
  39. }
  40. Item.AgentFeedbackMemo = "特殊点数申诉";
  41. }
  42. else
  43. {
  44. throw new ApplicationException("没找到指定的申诉记录!");
  45. }
  46. }
  47. }
  48. }
  49. }