PMCORE-1160

This commit is contained in:
Paula Quispe
2020-02-14 15:33:28 -04:00
parent 84b04e7a94
commit eb182466d8
11 changed files with 206 additions and 71 deletions

View File

@@ -4374,7 +4374,7 @@ class Cases
/** Create a register in APP_DELAY */
$delay = new AppDelay();
foreach ($indexesClosed as $value){
foreach ($indexesClosed as $value) {
$dataList = [];
$rowDelay = AppDelay::buildAppDelayRow(
$caseFields['PRO_UID'],
@@ -4402,6 +4402,7 @@ class Cases
$dataList = array_merge($caseFields, $dataList);
$listCanceled = new ListCanceled();
// This action requires interaction with IndicatorsCalculator class
$listCanceled->create($dataList);
/*----------------------------------********---------------------------------*/
}

View File

@@ -766,32 +766,32 @@ class IndicatorsCalculator
return $returnVal;
}
public function suggestedTimeForTask($taskId)
/**
* Get some calculations related to the specific task
* Returns population standard deviation of the expression from timeByTask/totalCase
* Return the average from timeByTask/totalCase
*
* @param string $tasUid
*
* @return array
* @throws Exception
*/
public function suggestedTimeForTask($tasUid)
{
$qryParams = array();
$qryParams[':taskId'] = $taskId;
$sqlString = 'select
ROUND(AVG(TOTAL_TIME_BY_TASK/TOTAL_CASES_OUT), 2) as average,
ROUND(STDDEV(TOTAL_TIME_BY_TASK/TOTAL_CASES_OUT), 2) as sdv
from USR_REPORTING where TAS_UID = :taskId';
$retval = $this->pdoExecutor($sqlString, $qryParams);
return $retval[0];
}
try {
$criteria = new Criteria('workflow');
$criteria->addSelectColumn(UsrReportingPeer::TOTAL_CASES_OUT);
$criteria->addAsColumn('average', 'ROUND(AVG(TOTAL_TIME_BY_TASK/TOTAL_CASES_OUT), 2)');
$criteria->addAsColumn('sdv', 'ROUND(STDDEV(TOTAL_TIME_BY_TASK/TOTAL_CASES_OUT), 2)');
$criteria->add(UsrReportingPeer::TAS_UID, $tasUid);
$dataset = UsrReportingPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
$result = $dataset->getRow();
/* For debug only:
* public function interpolateQuery($query, $params) {
$keys = array();
# build a regular expression for each parameter
foreach ($params as $key => $value) {
echo "<br>key", $key, " -- value", $value;
if (is_string($key)) {
$keys[] = '/:'.$key.'/';
} else {
$keys[] = '/[?]/';
}
return $result;
} catch (Exception $error) {
throw $error;
}
$query = preg_replace($keys, $params, $query, 1, $count);
return $query;
}*/
}
}

View File

@@ -152,6 +152,7 @@ class AppDelay extends BaseAppDelay
/**
* Build the row for the appDelay to be inserted
* This function check the instance of RBAC
*
* @param string $proUid
* @param integer $proId

View File

@@ -111,6 +111,7 @@ class ListCanceled extends BaseListCanceled implements ListInterface
}
if (!empty($data['TAS_UID'])) {
$t = new Task();
// The load task gets some calculations related to the Indicators
$data['TAS_ID'] = $t->load($data['TAS_UID'])['TAS_ID'];
}
$con = Propel::getConnection(ListCanceledPeer::DATABASE_NAME);

View File

@@ -487,32 +487,38 @@ class Task extends BaseTask
return $row;
}
public function load($TasUid)
/**
* Load the properties related to the task
*
* @param string $tasUid
*
* @return array
* @throws Exception
*/
public function load($tasUid)
{
try {
$oRow = TaskPeer::retrieveByPK($TasUid);
$rows = TaskPeer::retrieveByPK($tasUid);
if (!is_null($oRow)) {
$aFields = $oRow->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($aFields, BasePeer::TYPE_FIELDNAME); //Populating an object from of the array
//Populating attributes
if (!is_null($rows)) {
$fields = $rows->toArray(BasePeer::TYPE_FIELDNAME);
$this->fromArray($fields, BasePeer::TYPE_FIELDNAME); //Populating an object from of the array
//Populating attributes
$this->setNew(false);
/*----------------------------------********---------------------------------*/
$indicator = new IndicatorsCalculator();
$data = $indicator->suggestedTimeForTask($TasUid);
$aFields["TAS_AVERAGE"] = $data['average'];
$aFields["TAS_SDV"] = $data['sdv'];
$data = $indicator->suggestedTimeForTask($tasUid);
$fields["TAS_AVERAGE"] = $data['average'];
$fields["TAS_SDV"] = $data['sdv'];
/*----------------------------------********---------------------------------*/
///////
return $aFields;
return $fields;
} else {
throw (new Exception("The row '" . $TasUid . "' in table TASK doesn't exist!"));
throw new Exception("The row '" . $tasUid . "' in table TASK doesn't exist!");
}
} catch (Exception $oError) {
throw ($oError);
} catch (Exception $error) {
throw $error;
}
}

View File

@@ -0,0 +1,11 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class AppDelay extends Model
{
protected $table = 'APP_DELAY';
public $timestamps = false;
}

View File

@@ -0,0 +1,13 @@
<?php
namespace ProcessMaker\Model;
use Illuminate\Database\Eloquent\Model;
class UserReporting extends Model
{
protected $table = "USR_REPORTING";
public $timestamps = false;
}