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));
}