Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
d8e47592
Commit
d8e47592
authored
4 years ago
by
Gerhard Bachmaier
Browse files
Options
Downloads
Patches
Plain Diff
Gebiet: Automatische Zuordnung von Firmen
parent
c1e764ba
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
process/District_lib/process.js
+75
-14
75 additions, 14 deletions
process/District_lib/process.js
process/process_audit/process.js
+7
-0
7 additions, 0 deletions
process/process_audit/process.js
with
82 additions
and
14 deletions
process/District_lib/process.js
+
75
−
14
View file @
d8e47592
import
(
"
system.logging
"
);
import
(
"
Contact_lib
"
);
import
(
"
KeywordRegistry_basic
"
);
import
(
"
system.vars
"
);
import
(
"
system.util
"
);
...
...
@@ -103,25 +105,35 @@ DistrictUtils.assignDistrictOnServer = function (pArrDistrictIds, pUser)
* Id of the district.<br>
* @param {String} pAppliedFilter <p>
* Filter condition to get the assigned companies.<br>
* @param {String} pContactId (opt) <p>
* Only filled when a special contact-ID should assigned to a district.<br>*
* @return {Object} <p>
* Count of new assigned companies and no longer assigned companies.<br>
*/
DistrictUtils
.
assignDistrict
=
function
(
pDistrictId
,
pAppliedFilter
)
DistrictUtils
.
assignDistrict
=
function
(
pDistrictId
,
pAppliedFilter
,
pContactId
)
{
if
(
pContactId
==
undefined
)
pContactId
=
null
;
var
newAssigned
=
0
;
var
unchanged
=
0
;
var
invalid
=
0
;
//Einlesen von allen bereits existierenden automatischen Zuordnungen,
//die nicht auf Status 'zur Prüfung' sthen
var
arrExistingIds
=
new
SqlBuilder
()
.
select
(
"
DISTRICTCONTACT.DISTRICTCONTACTID, DISTRICTCONTACT.CONTACT_ID, DISTRICTCONTACT.ADVISER_CONTACT_ID
"
)
.
from
(
"
DISTRICTCONTACT
"
)
.
where
(
"
DISTRICTCONTACT.DISTRICT_ID
"
,
pDistrictId
)
.
and
(
"
DISTRICTCONTACT.ORIGIN
"
,
$KeywordRegistry
.
districtOrigin
$auto
())
.
and
(
"
DISTRICTCONTACT.STATUS
"
,
$KeywordRegistry
.
contactStatus
$inReview
(),
SqlBuilder
.
NOT_EQUAL
())
.
table
();
//die nicht auf Status 'zur Prüfung' stehen
//Nur notwendig, wenn pContactId leer ist. Ansonsten soll ja gezielt ein neuer Datensatz angelegt werden
var
arrExistingIds
=
[]
if
(
!
pContactId
)
{
arrExistingIds
=
new
SqlBuilder
()
.
select
(
"
DISTRICTCONTACT.DISTRICTCONTACTID, DISTRICTCONTACT.CONTACT_ID, DISTRICTCONTACT.ADVISER_CONTACT_ID
"
)
.
from
(
"
DISTRICTCONTACT
"
)
.
where
(
"
DISTRICTCONTACT.DISTRICT_ID
"
,
pDistrictId
)
.
and
(
"
DISTRICTCONTACT.ORIGIN
"
,
$KeywordRegistry
.
districtOrigin
$auto
())
.
and
(
"
DISTRICTCONTACT.STATUS
"
,
$KeywordRegistry
.
contactStatus
$inReview
(),
SqlBuilder
.
NOT_EQUAL
())
.
table
();
}
//Einlesen aller Betreuer, die dem übergebenen Gebiet zugeordnet sind
var
arrResponsibleIds
=
new
SqlBuilder
()
.
select
(
"
DISTRICTRESPONSIBLE.EMPLOYEE_CONTACT_ID, DISTRICTRESPONSIBLE.ADVISER_ROLE,
"
+
...
...
@@ -129,12 +141,13 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter)
.
from
(
"
DISTRICTRESPONSIBLE
"
)
.
where
(
"
DISTRICTRESPONSIBLE.DISTRICT_ID
"
,
pDistrictId
)
.
table
();
//Aufbereiten des im JSON-Format übergebenen Filters in eine SQL-Condition
var
appliedFilterCondition
=
JSON
.
parse
(
pAppliedFilter
).
filter
;
appliedFilterCondition
=
JSON
.
stringify
(
appliedFilterCondition
);
appliedFilterCondition
=
JSON
.
stringify
(
appliedFilterCondition
);
logging
.
log
(
"
appliedFilterCondition:
"
+
appliedFilterCondition
);
var
sqlCondition
=
db
.
toFilterCondition
(
appliedFilterCondition
,
"
Organisation_entity
"
)
logging
.
log
(
"
sqlCondition:
"
+
sqlCondition
)
//Einlesen der Contact-IDs zu den Firmen, die gemäß Filter diesem Gebiet zugeordnet sind
var
arrOrgContactIds
=
new
SqlBuilder
()
.
selectDistinct
(
"
CONTACT.CONTACTID
"
)
...
...
@@ -143,8 +156,9 @@ DistrictUtils.assignDistrict = function (pDistrictId, pAppliedFilter)
.
leftJoin
(
"
ADDRESS
"
,
"
ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID
"
)
.
leftJoin
(
"
CLASSIFICATIONSTORAGE
"
,
"
CLASSIFICATIONSTORAGE.OBJECT_ROWID = CONTACT.CONTACTID
"
)
.
whereIfSet
(
sqlCondition
)
.
andIfSet
(
"
CONTACT.CONTACTID
"
,
pContactId
)
.
arrayColumn
();
logging
.
log
(
"
arrOrgContactIds.length:
"
+
arrOrgContactIds
.
length
)
var
insertArray
=
[];
var
colsInsert
=
[
"
DISTRICTCONTACTID
"
,
...
...
@@ -347,4 +361,51 @@ DistrictUtils._getParentFilter = function (pParentDistrict_DistrictId, pPrevious
}
return
resFilter
;
}
/**
* This function will assign a new organisation to all districts, which
* - have the property "auto assignment"
* - and are part of the regarding filter
* @param {String} pOrganisationId <p>
* Organisation-ID of the new Organisation<br>
* @param {String} pUserLogin <p>
* login,who created the new organistion<br>
* @return <none> <p>
*/
DistrictUtils
.
assignOrganisationToDistrict
=
function
(
pOrganisationId
,
pUserLogin
)
{
//contactid zur organisationid ermitteln
var
contactId
=
ContactUtils
.
getOrgContactId
(
pOrganisationId
);
//alle Filter ermitteln, die auf auto-assignment gleich true gesetzt sind
var
allAutoDistricts
=
newSelect
(
"
DISTRICTID
"
)
.
from
(
"
DISTRICT
"
)
.
where
(
"
DISTRICT.DISTRICT_AUTOADD
"
,
1
)
.
arrayColumn
();
//TODO: pUserLogin noch bis zum Schreiben von date_new durchschleusen
logging
.
log
(
"
pUerLogin:
"
+
pUserLogin
)
//Variante 1
for
(
var
i
=
0
;
i
<
allAutoDistricts
.
length
;
i
++
)
{
logging
.
log
(
"
allAutoDistricts[i]:
"
+
allAutoDistricts
[
i
]);
//pro District den kompletten Filter ermitteln
var
districtData
=
DistrictUtils
.
getDataFromDistrict
(
allAutoDistricts
[
i
]);
var
completeFilter
=
DistrictUtils
.
getAppliedFilter
(
districtData
[
0
],
districtData
[
1
])
//logging.log("completeFilter: " + completeFilter)
//prüfen, ob die neue contactid im filter enthalten wäre
//und im Erfolgsfall die Daten in der districtcontact anlegen
//TODO: pUserLogin als 4ten Parameter übergeben. Wenn gefüllt, diesen als USER_NEW/EDIT setzen, sonst den sys.user verwenden
var
res
=
DistrictUtils
.
assignDistrict
(
allAutoDistricts
[
i
],
completeFilter
,
contactId
);
}
//Variante 2: Aufruf des Server-Prozessen mit allen Gebieten mit Auto-Zuordnung gleich true
//Wirft den gleichen Fehler wie Variante 1
//TODO: Aus dem pUserLogin noch die Employee-ID ermitteln
//DistrictUtils.assignDistrictOnServer(allAutoDistricts, pUserLogin);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
process/process_audit/process.js
+
7
−
0
View file @
d8e47592
import
(
"
District_lib
"
);
import
(
"
Loghistory_lib
"
);
import
(
"
system.vars
"
);
import
(
"
system.process
"
);
...
...
@@ -15,3 +16,9 @@ if (sqlAction != 'X')
{
(
new
LogHistoryExecutor
(
tableName
,
userLogin
,
columns
,
newvalues
,
oldvalues
,
timestamp
,
sqlAction
,
id
)).
execute
();
}
//Ticketnummer: 1066031
if
(
sqlAction
==
'
I
'
&&
tableName
==
'
ORGANISATION
'
)
{
DistrictUtils
.
assignOrganisationToDistrict
(
id
,
userLogin
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment