ChangeReviewerReviewer.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using Microsoft.EntityFrameworkCore;
  2. using System;
  3. using System.Linq;
  4. using wispro.sp.entity;
  5. using wispro.sp.share;
  6. namespace wispro.sp.api.AppealHandler
  7. {
  8. public class ChangeReviewerReviewer : IDoAppealObject
  9. {
  10. public void DoAppeal(AppealObject appeal, int appealRecordId, DbContext spContext)
  11. {
  12. bool isAggree = false;
  13. foreach (var iv in appeal.inputFieldValues)
  14. {
  15. if (iv.InputField == null)
  16. {
  17. iv.InputField = ((spDbContext)spContext).InputFields.FirstOrDefault(s => s.Id == iv.InputFieldId);
  18. }
  19. if (iv.InputField.FieldName == "审核意见" && iv.Value == "确认变更")
  20. {
  21. isAggree = true;
  22. break;
  23. }
  24. }
  25. if (isAggree)
  26. {
  27. var result = ((spDbContext)spContext).InputFieldValues.Where<InputFieldValue>(f =>
  28. f.AppealRecordId == appealRecordId && f.InputField.AppealState == 0)
  29. .ToList();
  30. string strReviewerName = "";
  31. foreach (var iv in result)
  32. {
  33. if (iv.InputField == null)
  34. {
  35. iv.InputField = ((spDbContext)spContext).InputFields.FirstOrDefault(s => s.Id == iv.InputFieldId);
  36. }
  37. if (iv.InputField.FieldName == "实际核稿人")
  38. {
  39. strReviewerName = iv.Value;
  40. break;
  41. }
  42. }
  43. var appRecord = ((spDbContext)spContext).AppealRecords.Include(a=>a.Item).FirstOrDefault(f => f.Id == appealRecordId);
  44. if (appRecord != null && appRecord.Item != null)
  45. {
  46. var newStaff = ((spDbContext)spContext).Staffs.FirstOrDefault(s => s.Name == strReviewerName.Trim());
  47. if(newStaff != null)
  48. {
  49. appRecord.Item.ReviewerId = newStaff.Id;
  50. }
  51. else
  52. {
  53. throw new ApplicationException("输入的【实际核稿人】不存在!");
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }