123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- <?php
- namespace common\util;
- class CalculateTotalScoreObj
- {
- public AccidentCasesScoreObj $_0; //1
- public AccidentCasesScoreObj $_247; //2
- public AccidentCasesScoreObj $_248; //3
- public AccidentCasesScoreObj $_249; //3
- public AccidentCasesScoreObj $_250; //3
- public AccidentCasesScoreObj $_251; //3
- public AccidentCasesScoreObj $_252; //3
- public AccidentCasesScoreObj $_253; //3
- public AccidentCasesScoreObj $_346; //4
- public AccidentCasesScoreObj $_347; //5
- public AccidentCasesScoreObj $_348; //5
- public function calculate($quanZhong)
- {
- //如果分数不设置,计算时扣除未设置项目
- //计算1
- $_247_fenzi = 0;
- $_247_fenmu = 0;
- if ($this->_248->score >= 0) {
- $_247_fenzi += $this->_248->score * $quanZhong[248];
- $_247_fenmu += $quanZhong[248];
- }
- if ($this->_249->score >= 0) {
- $_247_fenzi += $this->_249->score * $quanZhong[249];
- $_247_fenmu += $quanZhong[249];
- }
- if ($this->_250->score >= 0) {
- $_247_fenzi += $this->_250->score * $quanZhong[250];
- $_247_fenmu += $quanZhong[250];
- }
- if ($this->_251->score >= 0) {
- $_247_fenzi += $this->_251->score * $quanZhong[251];
- $_247_fenmu += $quanZhong[251];
- }
- if ($this->_252->score >= 0) {
- $_247_fenzi += $this->_252->score * $quanZhong[252];
- $_247_fenmu += $quanZhong[252];
- }
- if ($this->_253->score >= 0) {
- $_247_fenzi += $this->_253->score * $quanZhong[253];
- $_247_fenmu += $quanZhong[253];
- }
- //计算分数
- if ($_247_fenmu === 0) {
- $this->_247->score = -1;
- } else {
- $this->_247->score = $_247_fenzi / $_247_fenmu;
- }
- // $this->_247->score = ($this->_248->score * $quanZhong[248] + $this->_249->score * $quanZhong[249] + $this->_250->score * $quanZhong[250]
- // + $this->_251->score * $quanZhong[251] + $this->_252->score * $quanZhong[252] + $this->_253->score * $quanZhong[253])
- // / ($quanZhong[248] + $quanZhong[249] + $quanZhong[250] + $quanZhong[251] + $quanZhong[252] + $quanZhong[253]);
- //计算4
- $_346_fenzi = 0;
- $_346_fenmu = 0;
- if ($this->_347->score >= 0) {
- $_346_fenzi += $this->_347->score * $quanZhong[347];
- $_346_fenmu += $quanZhong[347];
- }
- if ($this->_348->score >= 0) {
- $_346_fenzi += $this->_348->score * $quanZhong[348];
- $_346_fenmu += $quanZhong[348];
- }
- if ($_346_fenmu === 0) {
- $this->_346->score = -1;
- } else {
- $this->_346->score = $_346_fenzi / $_346_fenmu;
- }
- // $this->_346->score = ($this->_347->score * $quanZhong[347] + $this->_348->score * $quanZhong[348])
- // / ($quanZhong[347] + $quanZhong[348]);
- //计算1
- $_0_fenzi = 0;
- $_0_fenmu = 0;
- if ($this->_247->score >= 0) {
- $_0_fenzi += $this->_247->score * $quanZhong[247];
- $_0_fenmu += $quanZhong[247];
- }
- if ($this->_346->score >= 0) {
- $_0_fenzi += $this->_346->score * $quanZhong[346];
- $_0_fenmu += $quanZhong[346];
- }
- if ($_0_fenmu === 0) {
- $this->_0->score = -1;
- } else {
- $this->_0->score = $_0_fenzi / $_0_fenmu;
- }
- // $this->_0->score = ($this->_247->score * $quanZhong[247] + $this->_346->score * $quanZhong[346])
- // / ($quanZhong[247] + $quanZhong[346]);
- //结果保留两位小数
- $this->_247->score = round($this->_247->score, 2);
- $this->_346->score = round($this->_346->score, 2);
- $this->_0->score = round($this->_0->score, 2);
- }
- }
|