ReviewerAppealModel.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text.Json;
  6. using System.Threading.Tasks;
  7. using wispro.sp.entity;
  8. using wispro.sp.web.Services;
  9. namespace wispro.sp.web.Models
  10. {
  11. public class ReviewerAppealModel
  12. {
  13. public PerformanceItem Item { get; set; }
  14. public AppealType AppealType { get; set; }
  15. public List<InputField> CreateInputFields { get; set; }
  16. public List<InputFieldValue> CreateAppealFieldValues { get; set; }
  17. public List<InputField> inputFields { get; set; }
  18. public List<InputFieldValue> inputFieldValues { get; set; }
  19. public List<AttachFile> attachFiles { get; set; }
  20. public AppealRecord AppealRecord { get; set; }
  21. public CaseCoefficientStatistics cssObject { get; set; }
  22. public async Task Init(AppealTypeService _atService, int appealRecordId)
  23. {
  24. this.AppealRecord =await _atService.getAppealRecord(appealRecordId);
  25. Item = this.AppealRecord.Item;
  26. CreateInputFields = await _atService.GetInputFields(this.AppealRecord.TypeId, 0);
  27. CreateAppealFieldValues = await _atService.GetInputFieldValues(this.AppealRecord.Id,0);
  28. inputFields = await _atService.GetInputFields(this.AppealRecord.TypeId, 1);
  29. attachFiles = await _atService.GetAppealRecordAttachFiles(this.AppealRecord.Id);
  30. if(AppealRecord.Type.Name == "案件系数复核")
  31. {
  32. cssObject = await _atService.GetCaseCoefficientStatistics(Item.CustomerId, Item.CalMonthId);
  33. }
  34. inputFieldValues = new List<InputFieldValue>();
  35. foreach (var field in inputFields)
  36. {
  37. if (!string.IsNullOrEmpty(field.MapObjectField) && !string.IsNullOrEmpty(field.MapObjectFieldLabel))
  38. {
  39. List<InputFieldValue> temValues = new List<InputFieldValue>();
  40. string[] pList = field.MapObjectField.Split(new char[] { '.' });
  41. string[] plList = field.MapObjectFieldLabel.Split(new char[] { '.' });
  42. var pInfo = Item.GetType().GetProperty(pList[0]);
  43. var o = pInfo.GetValue(Item);
  44. if (Array.IndexOf(o.GetType().GetInterfaces(), typeof(IEnumerable)) > -1)
  45. {
  46. List<string> Values = new List<string>();
  47. List<string> Labels = new List<string>();
  48. var objList = o as IEnumerable;
  49. foreach (var obj in objList)
  50. {
  51. var objValue = obj;
  52. var objLabel = obj;
  53. for (int i = 1; i < pList.Length; i++)
  54. {
  55. objValue = objValue.GetType().GetProperty(pList[i]).GetValue(objValue);
  56. }
  57. for (int i = 1; i < plList.Length; i++)
  58. {
  59. objLabel = objLabel.GetType().GetProperty(plList[i]).GetValue(objLabel);
  60. }
  61. var fValue = new InputFieldValue();
  62. fValue.InputField = field;
  63. fValue.InputFieldId = field.Id;
  64. fValue.Label = objLabel.ToString();
  65. if (objValue != null)
  66. {
  67. fValue.Value = objValue.ToString();
  68. }
  69. inputFieldValues.Add(fValue);
  70. temValues.Add(fValue);
  71. }
  72. }
  73. else
  74. {
  75. var fValue = new InputFieldValue();
  76. fValue.InputField = field;
  77. fValue.InputFieldId = field.Id;
  78. inputFieldValues.Add(fValue);
  79. }
  80. }
  81. else
  82. {
  83. var fValue = new InputFieldValue();
  84. fValue.InputField = field;
  85. fValue.InputFieldId = field.Id;
  86. inputFieldValues.Add(fValue);
  87. }
  88. }
  89. }
  90. }
  91. }