CalculateTotalScoreObj.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace common\util;
  3. class CalculateTotalScoreObj
  4. {
  5. public AccidentCasesScoreObj $_0; //1
  6. public AccidentCasesScoreObj $_247; //2
  7. public AccidentCasesScoreObj $_248; //3
  8. public AccidentCasesScoreObj $_249; //3
  9. public AccidentCasesScoreObj $_250; //3
  10. public AccidentCasesScoreObj $_251; //3
  11. public AccidentCasesScoreObj $_252; //3
  12. public AccidentCasesScoreObj $_253; //3
  13. public AccidentCasesScoreObj $_346; //4
  14. public AccidentCasesScoreObj $_347; //5
  15. public AccidentCasesScoreObj $_348; //5
  16. public function calculate($quanZhong)
  17. {
  18. //如果分数不设置,计算时扣除未设置项目
  19. //计算1
  20. $_247_fenzi = 0;
  21. $_247_fenmu = 0;
  22. if ($this->_248->score >= 0) {
  23. $_247_fenzi += $this->_248->score * $quanZhong[248];
  24. $_247_fenmu += $quanZhong[248];
  25. }
  26. if ($this->_249->score >= 0) {
  27. $_247_fenzi += $this->_249->score * $quanZhong[249];
  28. $_247_fenmu += $quanZhong[249];
  29. }
  30. if ($this->_250->score >= 0) {
  31. $_247_fenzi += $this->_250->score * $quanZhong[250];
  32. $_247_fenmu += $quanZhong[250];
  33. }
  34. if ($this->_251->score >= 0) {
  35. $_247_fenzi += $this->_251->score * $quanZhong[251];
  36. $_247_fenmu += $quanZhong[251];
  37. }
  38. if ($this->_252->score >= 0) {
  39. $_247_fenzi += $this->_252->score * $quanZhong[252];
  40. $_247_fenmu += $quanZhong[252];
  41. }
  42. if ($this->_253->score >= 0) {
  43. $_247_fenzi += $this->_253->score * $quanZhong[253];
  44. $_247_fenmu += $quanZhong[253];
  45. }
  46. //计算分数
  47. if ($_247_fenmu === 0) {
  48. $this->_247->score = -1;
  49. } else {
  50. $this->_247->score = $_247_fenzi / $_247_fenmu;
  51. }
  52. // $this->_247->score = ($this->_248->score * $quanZhong[248] + $this->_249->score * $quanZhong[249] + $this->_250->score * $quanZhong[250]
  53. // + $this->_251->score * $quanZhong[251] + $this->_252->score * $quanZhong[252] + $this->_253->score * $quanZhong[253])
  54. // / ($quanZhong[248] + $quanZhong[249] + $quanZhong[250] + $quanZhong[251] + $quanZhong[252] + $quanZhong[253]);
  55. //计算4
  56. $_346_fenzi = 0;
  57. $_346_fenmu = 0;
  58. if ($this->_347->score >= 0) {
  59. $_346_fenzi += $this->_347->score * $quanZhong[347];
  60. $_346_fenmu += $quanZhong[347];
  61. }
  62. if ($this->_348->score >= 0) {
  63. $_346_fenzi += $this->_348->score * $quanZhong[348];
  64. $_346_fenmu += $quanZhong[348];
  65. }
  66. if ($_346_fenmu === 0) {
  67. $this->_346->score = -1;
  68. } else {
  69. $this->_346->score = $_346_fenzi / $_346_fenmu;
  70. }
  71. // $this->_346->score = ($this->_347->score * $quanZhong[347] + $this->_348->score * $quanZhong[348])
  72. // / ($quanZhong[347] + $quanZhong[348]);
  73. //计算1
  74. $_0_fenzi = 0;
  75. $_0_fenmu = 0;
  76. if ($this->_247->score >= 0) {
  77. $_0_fenzi += $this->_247->score * $quanZhong[247];
  78. $_0_fenmu += $quanZhong[247];
  79. }
  80. if ($this->_346->score >= 0) {
  81. $_0_fenzi += $this->_346->score * $quanZhong[346];
  82. $_0_fenmu += $quanZhong[346];
  83. }
  84. if ($_0_fenmu === 0) {
  85. $this->_0->score = -1;
  86. } else {
  87. $this->_0->score = $_0_fenzi / $_0_fenmu;
  88. }
  89. // $this->_0->score = ($this->_247->score * $quanZhong[247] + $this->_346->score * $quanZhong[346])
  90. // / ($quanZhong[247] + $quanZhong[346]);
  91. //结果保留两位小数
  92. $this->_247->score = round($this->_247->score, 2);
  93. $this->_346->score = round($this->_346->score, 2);
  94. $this->_0->score = round($this->_0->score, 2);
  95. }
  96. }