fehler/issue monitoring: enabled resolving/producing by app only, improved error messages, code layout, removed error: fehler to produce is not defined in config

This commit is contained in:
Alexei Karpenko
2026-02-12 14:46:49 +01:00
parent 4c03668082
commit 43811d5724
5 changed files with 91 additions and 62 deletions
@@ -8,7 +8,7 @@ class IssueChecker extends FHCAPI_Controller
protected $person_id;
protected $_extensionName = null;
protected $_fehlercodes = [];
//protected $_app = null; TODO possible to check for all fehler of app?
protected $_apps = [];
protected $errors = [];
protected $infos = [];
@@ -33,31 +33,53 @@ class IssueChecker extends FHCAPI_Controller
$this->load->model('system/Fehler_model', 'FehlerModel');
$this->load->model('person/Person_model', 'PersonModel');
// get fehler kurzbz from fehlercodes
$this->FehlerModel->addSelect('fehler_kurzbz');
if (!isEmptyArray($this->_fehlercodes)) $this->FehlerModel->db->where_in('tbl_fehler.fehlercode', $this->_fehlercodes);
$fehlerKurzbzRes = $this->FehlerModel->load();
$producerArgs = [];
$resolverArgs = [];
if (isError($fehlerKurzbzRes)) $this->terminateWithError(getError($fehlerKurzbzRes), self::ERROR_TYPE_GENERAL);
// get fehler kurzbz from fehlercodes, if fehlercodes provided
if (!isEmptyArray($this->_fehlercodes))
{
$this->FehlerModel->addSelect('fehlercode, fehler_kurzbz');
$this->FehlerModel->db->where_in('tbl_fehler.fehlercode', $this->_fehlercodes);
$fehlerKurzbzRes = $this->FehlerModel->load();
$fehlerKurzbz = hasData($fehlerKurzbzRes) ? array_column(getData($fehlerKurzbzRes), 'fehler_kurzbz') : [];
if (isError($fehlerKurzbzRes)) $this->terminateWithError(getError($fehlerKurzbzRes), self::ERROR_TYPE_GENERAL);
if (hasData($fehlerKurzbzRes))
{
$producerArgs['fehlerKurzbz'] = array_column(getData($fehlerKurzbzRes), 'fehler_kurzbz');
$resolverArgs['fehlercode'] = array_column(getData($fehlerKurzbzRes), 'fehlercode');
}
}
elseif (!isEmptyArray($this->_apps)) // if apps are provided
{
// get fehlercodes for the apps
$fehlerRes = $this->FehlerModel->getByApps($this->_apps);
if (hasData($fehlerRes)) $this->_fehlercodes = array_column(getData($fehlerRes), 'fehlercode');
$producerArgs['apps'] = $this->_apps;
$resolverArgs['apps'] = $this->_apps;
}
// load producer and checker libraries with fehler kurbz and fehlercode list
$this->load->library(
'issues/PlausicheckProducerLib',
array(
'fehlerKurzbz' => $fehlerKurzbz
),
$producerArgs,
'PlausicheckProducerLib'
);
$this->load->library(
'issues/PlausicheckResolverLib',
array(
'fehlercodes' => $this->_fehlercodes
),
$resolverArgs,
'PlausicheckResolverLib'
);
$this->load->library('PhrasesLib');
$this->loadPhrases(
array(
'ui'
)
);
}
public function checkPerson()
@@ -6,11 +6,9 @@ defined('BASEPATH') || exit('No direct script access allowed');
class Issues extends FHCAPI_Controller
{
const DEFAULT_PERMISSION = 'system/issues_verwalten:r';
// code igniter
protected $CI;
public function __construct() {
parent::__construct(
array(
'getOpenIssuesByProperties' => Self::DEFAULT_PERMISSION,
@@ -26,9 +24,6 @@ class Issues extends FHCAPI_Controller
$this->load->model('system/Fehler_model','FehlerModel');
$this->load->model('system/Issue_model', 'IssueModel');
$this->load->model('person/Benutzer_model', 'BenutzerModel');
// get CI for transaction management
$this->CI = &get_instance();
}
public function getOpenIssuesByProperties()
@@ -46,8 +41,6 @@ class Issues extends FHCAPI_Controller
if (isset($behebung_parameter) && !is_array($behebung_parameter))
$this->terminateWithError('Behebung parameter invalid');
$this->addMeta("vorher", $hauptzustaendig);
$issueRes = $this->IssueModel->getOpenIssuesByProperties(
$person_id,
$oe_kurzbz,
@@ -67,39 +60,39 @@ class Issues extends FHCAPI_Controller
public function getPersonenMitOffenenIssues()
{
$sql = <<<EOSQL
SELECT
person_id, uid, vorname, nachname, count(*) AS openissues ,
(select count(*) anz_aktiv
from hr.tbl_dienstverhaeltnis dv
where dv.mitarbeiter_uid=uid and dv.von<=now() and
(select count(*) anz_aktiv
from hr.tbl_dienstverhaeltnis dv
where dv.mitarbeiter_uid=uid and dv.von<=now() and
(dv.bis is null OR dv.bis>=now())
) aktiv
FROM
system.tbl_issue
JOIN
system.tbl_fehler USING (fehlercode)
JOIN
public.tbl_person USING (person_id)
JOIN
public.tbl_benutzer USING (person_id)
JOIN
public.tbl_mitarbeiter ON uid = mitarbeiter_uid
WHERE
app = 'personalverwaltung' AND verarbeitetamum IS NULL
GROUP BY
person_id, uid, vorname, nachname
HAVING
count(*) > 0
ORDER BY
FROM
system.tbl_issue
JOIN
system.tbl_fehler USING (fehlercode)
JOIN
public.tbl_person USING (person_id)
JOIN
public.tbl_benutzer USING (person_id)
JOIN
public.tbl_mitarbeiter ON uid = mitarbeiter_uid
WHERE
app = 'personalverwaltung' AND verarbeitetamum IS NULL
GROUP BY
person_id, uid, vorname, nachname
HAVING
count(*) > 0
ORDER BY
count(*) DESC;
EOSQL;
$personenmitissues = $this->IssueModel->execReadOnlyQuery($sql);
if( hasData($personenmitissues) )
if( hasData($personenmitissues) )
{
$this->terminateWithSuccess(getData($personenmitissues));
}
+2 -2
View File
@@ -243,7 +243,7 @@ class IssuesLib
$inhalt_extern = null
) {
if (isEmptyString($person_id) && isEmptyString($oe_kurzbz))
return error("Person_id or oe_kurzbz must be set.");
return error("Person_id or oe_kurzbz must be set, fehlercode: $fehlercode");
// get fehlertextVorlage and replace it with params
$fehlerRes = $this->_ci->FehlerModel->loadWhere(['fehlercode' => $fehlercode]);
@@ -256,7 +256,7 @@ class IssuesLib
if (!isEmptyArray($fehlertext_params))
{
if (count($fehlertext_params) != substr_count($fehlertextVorlage, '%s'))
return error('Wrong number of parameters for Fehlertext, fehler_kurzbz ' . $fehlercode);
return error('Wrong number of parameters for Fehlertext, fehlercode ' . $fehlercode);
$fehlertext = vsprintf($fehlertextVorlage, $fehlertext_params);
}
@@ -61,14 +61,10 @@ class PlausicheckProducerLib
}
else
{
$this->_ci->FehlerModel->addSelect('fehler_kurzbz');
if (!isEmptyArray($this->_apps)) $this->_ci->FehlerModel->db->where_in('app', $this->_apps);
$fehlerRes = $this->_ci->FehlerModel->load();
// get fehler by apps
$fehlerRes = $this->_ci->FehlerModel->getByApps($this->_apps);
if (hasData($fehlerRes))
{
$this->_fehlerKurzbz = array_column(getData($fehlerRes), 'fehler_kurzbz');
}
if (hasData($fehlerRes)) $this->_fehlerKurzbz = array_column(getData($fehlerRes), 'fehler_kurzbz');
}
// get producer file paths for the fehler
@@ -151,10 +147,10 @@ class PlausicheckProducerLib
$mappingFehlerKurbz = array_keys($this->_fehlerLibMappings);
// check if all issues to produce could be found in database
$notFoundFehlerKurzbz = array_diff($this->_fehlerKurzbz, $mappingFehlerKurbz);
//~ $notFoundFehlerKurzbz = array_diff($this->_fehlerKurzbz, $mappingFehlerKurbz);
if (!isEmptyArray($notFoundFehlerKurzbz))
$result->errors[] = error('Fehler to produce not defined in config: '.implode(', ', $notFoundFehlerKurzbz));
//~ if (!isEmptyArray($notFoundFehlerKurzbz))
//~ $result->errors[] = error('Fehler to produce not defined in config: '.implode(', ', $notFoundFehlerKurzbz));
foreach ($mappingFehlerKurbz as $fehler_kurzbz)
{
@@ -20,18 +20,36 @@ class PlausicheckResolverLib
private $_ci; // ci instance
private $_extensionName; // name of extension
private $_fehlercodes = []; // name of extension
private $_apps = []; // apps for which issues should be resolved
private $_codeLibMappings = []; // mappings for issues which explicitly defined resolver
private $_defaultIssueParams = ['issue_id' => 'issue_id', 'issue_person_id' => 'person_id', 'issue_oe_kurzbz' => 'oe_kurzbz'];
public function __construct($params = null)
{
// set application(s))
if (isset($params['apps']))
{
if (is_string($params['apps'])) $params['apps'] = [$params['apps']];
if (is_array($params['apps'])) $this->_apps = $params['apps'];
}
$this->_ci =& get_instance(); // get ci instance
// get all fehler to be produced (by kurzbz array or app)
if (isset($params['fehlercodes']) && !isEmptyArray($params['fehlercodes']))
{
$this->_fehlercodes = $params['fehlercodes'];
}
elseif (isset($params['apps']) && !isEmptyArray($params['apps']))
{
$this->_ci->load->model('system/Fehler_model', 'FehlerModel');
$fehlerRes = $this->_ci->FehlerModel->getByApps($this->_apps);
$this->_ci =& get_instance(); // get ci instance
if (hasData($fehlerRes))
{
$this->_fehlercodes = array_column(getData($fehlerRes), 'fehlercode');
}
}
$this->_ci->load->library('IssuesLib');
$this->_ci->load->library('ExtensionsLib');
@@ -144,11 +162,11 @@ class PlausicheckResolverLib
$result->infos = [];
// check if all issues to resolve could be found in database
$mappingFehlerCodes = array_keys($this->_codeLibMappings);
$notFoundFehlerCodes = array_diff($this->_fehlercodes, $mappingFehlerCodes);
//~ $mappingFehlerCodes = array_keys($this->_codeLibMappings);
//~ $notFoundFehlerCodes = array_diff($this->_fehlercodes, $mappingFehlerCodes);
if (!isEmptyArray($notFoundFehlerCodes))
$result->errors[] = error('Fehler to resolve not defined in config: '.implode(', ', $notFoundFehlerCodes));
//~ if (!isEmptyArray($notFoundFehlerCodes))
//~ $result->errors[] = error('Fehler to resolve not defined in config: '.implode(', ', $notFoundFehlerCodes));
foreach ($openIssues as $issue)
{