Merge branch 'main' of ssh://hrms-git.bangkok.go.th:6611/BMA-HRMS/hrms-api-org
* 'main' of ssh://hrms-git.bangkok.go.th:6611/BMA-HRMS/hrms-api-org: (38 commits) fix bug: report time record (rollback code group) fix group by profile test(2) #2160 migrate table posMaster fix bug return profile id test #2160 update search update search dna comment ออกก่อนเพราะยังไม่ได้ใช้ #2154 fix #2153 search dna update search org old migration: add field dnaId and profileId no message fix issue #1831, #2086, #2126, #2146 fix ค้นหารายชื่อผู้ยื่นอุธรณ์/ร้องทุกข์ fix brother privilage ...
This commit is contained in:
commit
77824bb04f
36 changed files with 101407 additions and 698 deletions
593
package-lock.json
generated
593
package-lock.json
generated
|
|
@ -18,8 +18,10 @@
|
|||
"cors": "^2.8.5",
|
||||
"csv-parser": "^3.0.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"express": "^4.21.2",
|
||||
"fast-jwt": "^3.3.2",
|
||||
"fast-levenshtein": "^3.0.0",
|
||||
"fuse.js": "^7.1.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"moment": "^2.30.1",
|
||||
"mysql2": "^3.9.1",
|
||||
|
|
@ -308,6 +310,141 @@
|
|||
"@nestjs/core": "^10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/platform-express/node_modules/cookie": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
|
||||
"integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/platform-express/node_modules/encodeurl": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
|
||||
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/platform-express/node_modules/express": {
|
||||
"version": "4.19.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz",
|
||||
"integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "1.20.2",
|
||||
"content-disposition": "0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.6.0",
|
||||
"cookie-signature": "1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "1.2.0",
|
||||
"fresh": "0.5.2",
|
||||
"http-errors": "2.0.0",
|
||||
"merge-descriptors": "1.0.1",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "0.1.7",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "6.11.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.2.1",
|
||||
"send": "0.18.0",
|
||||
"serve-static": "1.15.0",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "2.0.1",
|
||||
"type-is": "~1.6.18",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/platform-express/node_modules/finalhandler": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
|
||||
"integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"on-finished": "2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"statuses": "2.0.1",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/platform-express/node_modules/merge-descriptors": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
|
||||
"integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@nestjs/platform-express/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@nestjs/platform-express/node_modules/path-to-regexp": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
|
||||
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@nestjs/platform-express/node_modules/send": {
|
||||
"version": "0.18.0",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
|
||||
"integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"fresh": "0.5.2",
|
||||
"http-errors": "2.0.0",
|
||||
"mime": "1.6.0",
|
||||
"ms": "2.1.3",
|
||||
"on-finished": "2.4.1",
|
||||
"range-parser": "~1.2.1",
|
||||
"statuses": "2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nestjs/platform-express/node_modules/serve-static": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
|
||||
"integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"parseurl": "~1.3.3",
|
||||
"send": "0.18.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@nuxtjs/opencollective": {
|
||||
"version": "0.3.2",
|
||||
"resolved": "https://registry.npmjs.org/@nuxtjs/opencollective/-/opencollective-0.3.2.tgz",
|
||||
|
|
@ -1024,6 +1161,35 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bound": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
|
||||
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"get-intrinsic": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/camelcase": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-1.2.1.tgz",
|
||||
|
|
@ -1391,9 +1557,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "0.6.0",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
|
||||
"integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==",
|
||||
"version": "0.7.1",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
|
||||
"integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
|
|
@ -1412,6 +1579,7 @@
|
|||
"version": "2.8.5",
|
||||
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
|
||||
"integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"object-assign": "^4",
|
||||
"vary": "^1"
|
||||
|
|
@ -1563,6 +1731,20 @@
|
|||
"url": "https://github.com/motdotla/dotenv?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/eastasianwidth": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz",
|
||||
|
|
@ -1634,9 +1816,10 @@
|
|||
"integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg=="
|
||||
},
|
||||
"node_modules/encodeurl": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
|
||||
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
|
||||
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
|
|
@ -1801,6 +1984,24 @@
|
|||
"resolved": "https://registry.npmjs.org/es-array-method-boxes-properly/-/es-array-method-boxes-properly-1.0.0.tgz",
|
||||
"integrity": "sha512-wd6JXUmyHmt8T5a2xreUwKcGPq6f1f+WwIJkijUqiGcJz1qqnZgP6XIK+QyIWU5lT7imeNxUll48bziG+TSYcA=="
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-get-iterator": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/es-get-iterator/-/es-get-iterator-1.1.3.tgz",
|
||||
|
|
@ -1820,6 +2021,18 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
|
||||
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-set-tostringtag": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.0.2.tgz",
|
||||
|
|
@ -1860,7 +2073,8 @@
|
|||
"node_modules/escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow=="
|
||||
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
|
|
@ -1874,41 +2088,43 @@
|
|||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "4.19.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz",
|
||||
"integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==",
|
||||
"version": "4.21.2",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.21.2.tgz",
|
||||
"integrity": "sha512-28HqgMZAmih1Czt9ny7qr6ek2qddF4FclbMzwhCREB6OFfH+rXAnuNCwo1/wFvrtbgsQDb4kSbX9de9lFbrXnA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "1.20.2",
|
||||
"body-parser": "1.20.3",
|
||||
"content-disposition": "0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.6.0",
|
||||
"cookie": "0.7.1",
|
||||
"cookie-signature": "1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"encodeurl": "~1.0.2",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "1.2.0",
|
||||
"finalhandler": "1.3.1",
|
||||
"fresh": "0.5.2",
|
||||
"http-errors": "2.0.0",
|
||||
"merge-descriptors": "1.0.1",
|
||||
"merge-descriptors": "1.0.3",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "0.1.7",
|
||||
"path-to-regexp": "0.1.12",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "6.11.0",
|
||||
"qs": "6.13.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.2.1",
|
||||
"send": "0.18.0",
|
||||
"serve-static": "1.15.0",
|
||||
"send": "0.19.0",
|
||||
"serve-static": "1.16.2",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "2.0.1",
|
||||
"type-is": "~1.6.18",
|
||||
|
|
@ -1917,6 +2133,49 @@
|
|||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/express/node_modules/body-parser": {
|
||||
"version": "1.20.3",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz",
|
||||
"integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "3.1.2",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
"http-errors": "2.0.0",
|
||||
"iconv-lite": "0.4.24",
|
||||
"on-finished": "2.4.1",
|
||||
"qs": "6.13.0",
|
||||
"raw-body": "2.5.2",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/express/node_modules/qs": {
|
||||
"version": "6.13.0",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz",
|
||||
"integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"side-channel": "^1.0.6"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/external-editor": {
|
||||
|
|
@ -1946,12 +2205,30 @@
|
|||
"node": ">=16 <22"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-levenshtein": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-3.0.0.tgz",
|
||||
"integrity": "sha512-hKKNajm46uNmTlhHSyZkmToAc56uZJwYq7yrciZjqOxnlfQwERDQJmHPUp7m1m9wx8vgOe8IaCKZ5Kv2k1DdCQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fastest-levenshtein": "^1.0.7"
|
||||
}
|
||||
},
|
||||
"node_modules/fast-safe-stringify": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz",
|
||||
"integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/fastest-levenshtein": {
|
||||
"version": "1.0.16",
|
||||
"resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz",
|
||||
"integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 4.9.1"
|
||||
}
|
||||
},
|
||||
"node_modules/figures": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/figures/-/figures-2.0.0.tgz",
|
||||
|
|
@ -1976,12 +2253,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/finalhandler": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz",
|
||||
"integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==",
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz",
|
||||
"integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"encodeurl": "~1.0.2",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"on-finished": "2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
|
|
@ -2059,6 +2337,7 @@
|
|||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
|
|
@ -2128,6 +2407,15 @@
|
|||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/fuse.js": {
|
||||
"version": "7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.1.0.tgz",
|
||||
"integrity": "sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/generate-function": {
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/generate-function/-/generate-function-2.3.1.tgz",
|
||||
|
|
@ -2145,19 +2433,42 @@
|
|||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.2.tgz",
|
||||
"integrity": "sha512-0gSo4ml/0j98Y3lngkFEot/zhiCeWsbYIlZ+uZOVgzLyLaUw7wxUL+nCTP0XJvJg1AXulJRI3UJi8GsbDuxdGA==",
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"has-proto": "^1.0.1",
|
||||
"has-symbols": "^1.0.3",
|
||||
"hasown": "^2.0.0"
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"math-intrinsics": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
"es-object-atoms": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/get-symbol-description": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz",
|
||||
|
|
@ -2243,11 +2554,12 @@
|
|||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
|
||||
"integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
|
||||
"dependencies": {
|
||||
"get-intrinsic": "^1.1.3"
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
|
|
@ -2317,9 +2629,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz",
|
||||
"integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
|
|
@ -2342,9 +2655,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.0.tgz",
|
||||
"integrity": "sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==",
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
|
||||
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
|
|
@ -3133,6 +3447,15 @@
|
|||
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
|
||||
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw=="
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
|
|
@ -3156,9 +3479,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/merge-descriptors": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz",
|
||||
"integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w=="
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
|
||||
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/methods": {
|
||||
"version": "1.1.2",
|
||||
|
|
@ -3172,6 +3499,7 @@
|
|||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
|
|
@ -3541,9 +3869,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.13.1",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
|
||||
"integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==",
|
||||
"version": "1.13.4",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
||||
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
|
|
@ -3660,6 +3992,7 @@
|
|||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
|
|
@ -3704,9 +4037,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/path-to-regexp": {
|
||||
"version": "0.1.7",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz",
|
||||
"integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ=="
|
||||
"version": "0.1.12",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.12.tgz",
|
||||
"integrity": "sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/picomatch": {
|
||||
"version": "2.3.1",
|
||||
|
|
@ -3820,6 +4154,7 @@
|
|||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
||||
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
|
|
@ -4104,9 +4439,10 @@
|
|||
}
|
||||
},
|
||||
"node_modules/send": {
|
||||
"version": "0.18.0",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz",
|
||||
"integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==",
|
||||
"version": "0.19.0",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz",
|
||||
"integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
|
|
@ -4126,10 +4462,20 @@
|
|||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/send/node_modules/encodeurl": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz",
|
||||
"integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/send/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/seq-queue": {
|
||||
"version": "0.0.5",
|
||||
|
|
@ -4137,14 +4483,15 @@
|
|||
"integrity": "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q=="
|
||||
},
|
||||
"node_modules/serve-static": {
|
||||
"version": "1.15.0",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz",
|
||||
"integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==",
|
||||
"version": "1.16.2",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz",
|
||||
"integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encodeurl": "~1.0.2",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"parseurl": "~1.3.3",
|
||||
"send": "0.18.0"
|
||||
"send": "0.19.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
|
|
@ -4215,13 +4562,72 @@
|
|||
}
|
||||
},
|
||||
"node_modules/side-channel": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
|
||||
"integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
|
||||
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind": "^1.0.0",
|
||||
"get-intrinsic": "^1.0.2",
|
||||
"object-inspect": "^1.9.0"
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-list": "^1.0.0",
|
||||
"side-channel-map": "^1.0.1",
|
||||
"side-channel-weakmap": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-list": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
|
||||
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-map": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
|
||||
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-weakmap": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
|
||||
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-map": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
|
|
@ -5072,6 +5478,42 @@
|
|||
"url": "https://github.com/sponsors/isaacs"
|
||||
}
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/iconv-lite": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz",
|
||||
"integrity": "sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/long": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz",
|
||||
"integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==",
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/lru-cache": {
|
||||
"version": "6.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz",
|
||||
"integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==",
|
||||
"license": "ISC",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"yallist": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/mkdirp": {
|
||||
"version": "0.5.6",
|
||||
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
|
||||
|
|
@ -5088,6 +5530,27 @@
|
|||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/mysql2": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/mysql2/-/mysql2-2.3.3.tgz",
|
||||
"integrity": "sha512-wxJUev6LgMSgACDkb/InIFxDprRa6T95+VEoR+xPvtngtccNH2dGjEB/fVZ8yg1gWv1510c9CvXuJHi5zUm0ZA==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"denque": "^2.0.1",
|
||||
"generate-function": "^2.3.1",
|
||||
"iconv-lite": "^0.6.3",
|
||||
"long": "^4.0.0",
|
||||
"lru-cache": "^6.0.0",
|
||||
"named-placeholders": "^1.1.2",
|
||||
"seq-queue": "^0.0.5",
|
||||
"sqlstring": "^2.3.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/typeorm-cli/node_modules/reflect-metadata": {
|
||||
"version": "0.1.14",
|
||||
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.1.14.tgz",
|
||||
|
|
|
|||
|
|
@ -38,8 +38,10 @@
|
|||
"cors": "^2.8.5",
|
||||
"csv-parser": "^3.0.0",
|
||||
"dotenv": "^16.3.1",
|
||||
"express": "^4.18.2",
|
||||
"express": "^4.21.2",
|
||||
"fast-jwt": "^3.3.2",
|
||||
"fast-levenshtein": "^3.0.0",
|
||||
"fuse.js": "^7.1.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"moment": "^2.30.1",
|
||||
"mysql2": "^3.9.1",
|
||||
|
|
|
|||
|
|
@ -649,6 +649,54 @@ export class CommandController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API แก้ไขเงินเดือนทั้งกลุ่ม
|
||||
*
|
||||
* @summary API แก้ไขเงินเดือนทั้งกลุ่ม
|
||||
*
|
||||
* @param {string} id Id คำสั่ง
|
||||
*/
|
||||
@Post("tab2/edit-salary")
|
||||
async EditSalary(
|
||||
@Body()
|
||||
requestBody: {
|
||||
id: string;
|
||||
mouthSalaryAmount?: Double | null;
|
||||
positionSalaryAmount?: Double | null;
|
||||
amount?: Double | null;
|
||||
amountSpecial?: Double | null;
|
||||
remarkVertical?: string | null;
|
||||
remarkHorizontal?: string | null;
|
||||
}[],
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "COMMAND");
|
||||
|
||||
if (!Array.isArray(requestBody)) {
|
||||
throw new HttpError(HttpStatusCode.BAD_REQUEST, "รูปแบบข้อมูลไม่ถูกต้อง");
|
||||
}
|
||||
|
||||
for (const item of requestBody) {
|
||||
if (!item.id) continue;
|
||||
|
||||
const rec = await this.commandReciveRepository.findOne({
|
||||
where: { id: item.id },
|
||||
});
|
||||
|
||||
if (!rec) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ได้รับคำสั่ง");
|
||||
}
|
||||
|
||||
const updated = Object.assign(rec, item);
|
||||
updated.lastUpdateUserId = request.user.sub;
|
||||
updated.lastUpdateFullName = request.user.name;
|
||||
updated.lastUpdatedAt = new Date();
|
||||
|
||||
await this.commandReciveRepository.save(updated);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบรายการผู้ได้รับคำสั่ง
|
||||
*
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ export class CommandTypeController extends Controller {
|
|||
"detailBody",
|
||||
"detailFooter",
|
||||
"subtitle",
|
||||
"isSalary",
|
||||
"isAttachment",
|
||||
"isUploadAttachment",
|
||||
"createdAt",
|
||||
|
|
|
|||
|
|
@ -1021,12 +1021,12 @@ export class EmployeePositionController extends Controller {
|
|||
let typeCondition: any = {};
|
||||
let checkChildConditions: any = {};
|
||||
let keywordAsInt: any;
|
||||
let searchShortName = "";
|
||||
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName = "1=1";
|
||||
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo)`;
|
||||
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo)`;
|
||||
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo)`;
|
||||
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo)`;
|
||||
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo)`;
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_ORG_EMP");
|
||||
if (body.type === 0) {
|
||||
typeCondition = {
|
||||
|
|
@ -1036,7 +1036,7 @@ export class EmployeePositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild1Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
} else {
|
||||
}
|
||||
} else if (body.type === 1) {
|
||||
|
|
@ -1047,7 +1047,7 @@ export class EmployeePositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild2Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
} else {
|
||||
}
|
||||
} else if (body.type === 2) {
|
||||
|
|
@ -1058,7 +1058,7 @@ export class EmployeePositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild3Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
} else {
|
||||
}
|
||||
} else if (body.type === 3) {
|
||||
|
|
@ -1069,14 +1069,14 @@ export class EmployeePositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild4Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
} else {
|
||||
}
|
||||
} else if (body.type === 4) {
|
||||
typeCondition = {
|
||||
orgChild4Id: body.id,
|
||||
};
|
||||
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
}
|
||||
let findPosition: any;
|
||||
let masterId = new Array();
|
||||
|
|
@ -1126,7 +1126,7 @@ export class EmployeePositionController extends Controller {
|
|||
},
|
||||
];
|
||||
|
||||
const [posMaster, total] = await AppDataSource.getRepository(EmployeePosMaster)
|
||||
let query = AppDataSource.getRepository(EmployeePosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||
|
|
@ -1154,7 +1154,7 @@ export class EmployeePositionController extends Controller {
|
|||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `posMaster.orgChild1Id IN (:...child1)`
|
||||
: `posMaster.orgChild1Id is null`
|
||||
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
|
|
@ -1190,7 +1190,9 @@ export class EmployeePositionController extends Controller {
|
|||
child4: _data.child4,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
|
||||
if (body.keyword != null && body.keyword != "") {
|
||||
query.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
|
|
@ -1204,51 +1206,54 @@ export class EmployeePositionController extends Controller {
|
|||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
let [posMaster, total] = await query
|
||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||
|
|
@ -1381,24 +1386,22 @@ export class EmployeePositionController extends Controller {
|
|||
};
|
||||
}),
|
||||
);
|
||||
|
||||
if(_data.privilege === 'NORMAL'|| _data.privilege === 'PARENT'|| _data.privilege === 'CHILD'){ //PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||
const nextChildMap:any = { //เอาไวเช็ค CHILD ถัดไป
|
||||
|
||||
if (_data.privilege === "NORMAL" || _data.privilege === "CHILD") {
|
||||
//PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||
const nextChildMap: any = {
|
||||
//เอาไวเช็ค CHILD ถัดไป
|
||||
0: _data.child1,
|
||||
1: _data.child2,
|
||||
2: _data.child3,
|
||||
3: _data.child4,
|
||||
};
|
||||
const childValue = nextChildMap[body.type];
|
||||
if(_data.privilege === 'NORMAL'){
|
||||
if (Array.isArray(childValue) && childValue.some(item => item != null)) {
|
||||
if (_data.privilege === "NORMAL") {
|
||||
if (Array.isArray(childValue) && childValue.some((item) => item != null)) {
|
||||
return new HttpSuccess({ data: [], total: 0 });
|
||||
}
|
||||
}else if(_data.privilege === 'PARENT'){
|
||||
if (body.type == 0){
|
||||
return new HttpSuccess({ data: [], total: 0 });
|
||||
}
|
||||
} else if (_data.privilege === 'CHILD') {
|
||||
} else if (_data.privilege === "CHILD") {
|
||||
const higherChildChecks = [
|
||||
{ type: [0], child: _data.child1, next: _data.child2 },
|
||||
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
||||
|
|
@ -1663,50 +1666,50 @@ export class EmployeePositionController extends Controller {
|
|||
const type0LastPosMasterNo =
|
||||
requestBody.type == 0
|
||||
? await this.employeePosMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type1LastPosMasterNo =
|
||||
requestBody.type == 1
|
||||
? await this.employeePosMasterRepository.find({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type2LastPosMasterNo =
|
||||
requestBody.type == 2
|
||||
? await this.employeePosMasterRepository.find({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type3LastPosMasterNo =
|
||||
requestBody.type == 3
|
||||
? await this.employeePosMasterRepository.find({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type4LastPosMasterNo =
|
||||
requestBody.type == 4
|
||||
? await this.employeePosMasterRepository.find({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const allLastPosMasterNo = [
|
||||
|
|
|
|||
|
|
@ -769,12 +769,12 @@ export class EmployeeTempPositionController extends Controller {
|
|||
let typeCondition: any = {};
|
||||
let checkChildConditions: any = {};
|
||||
let keywordAsInt: any;
|
||||
let searchShortName = "";
|
||||
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix)`;
|
||||
let searchShortName = "1=1";
|
||||
let searchShortName0 = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo)`;
|
||||
let searchShortName1 = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo)`;
|
||||
let searchShortName2 = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo)`;
|
||||
let searchShortName3 = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo)`;
|
||||
let searchShortName4 = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo)`;
|
||||
let _data = await new permission().PermissionOrgList(request, "SYS_ORG_TEMP");
|
||||
if (body.type === 0) {
|
||||
typeCondition = {
|
||||
|
|
@ -784,7 +784,7 @@ export class EmployeeTempPositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild1Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgRoot.orgRootShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
} else {
|
||||
}
|
||||
} else if (body.type === 1) {
|
||||
|
|
@ -795,7 +795,7 @@ export class EmployeeTempPositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild2Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgChild1.orgChild1ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
} else {
|
||||
}
|
||||
} else if (body.type === 2) {
|
||||
|
|
@ -806,7 +806,7 @@ export class EmployeeTempPositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild3Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgChild2.orgChild2ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
} else {
|
||||
}
|
||||
} else if (body.type === 3) {
|
||||
|
|
@ -817,14 +817,14 @@ export class EmployeeTempPositionController extends Controller {
|
|||
checkChildConditions = {
|
||||
orgChild4Id: IsNull(),
|
||||
};
|
||||
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgChild3.orgChild3ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
} else {
|
||||
}
|
||||
} else if (body.type === 4) {
|
||||
typeCondition = {
|
||||
orgChild4Id: body.id,
|
||||
};
|
||||
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNoPrefix,posMaster.posMasterNo,posMaster.posMasterNoSuffix) like '%${body.keyword}%'`;
|
||||
searchShortName = `CONCAT(orgChild4.orgChild4ShortName," ",posMaster.posMasterNo) like '%${body.keyword}%'`;
|
||||
}
|
||||
let findPosition: any;
|
||||
let masterId = new Array();
|
||||
|
|
@ -873,8 +873,7 @@ export class EmployeeTempPositionController extends Controller {
|
|||
: { posMasterNo: Like(`%${body.keyword}%`) })),
|
||||
},
|
||||
];
|
||||
|
||||
const [posMaster, total] = await AppDataSource.getRepository(EmployeeTempPosMaster)
|
||||
let query = AppDataSource.getRepository(EmployeeTempPosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||
|
|
@ -902,7 +901,7 @@ export class EmployeeTempPositionController extends Controller {
|
|||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `posMaster.orgChild1Id IN (:...child1)`
|
||||
: `posMaster.orgChild1Id is null`
|
||||
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
|
|
@ -938,7 +937,9 @@ export class EmployeeTempPositionController extends Controller {
|
|||
child4: _data.child4,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
|
||||
if (body.keyword != null && body.keyword != "") {
|
||||
query.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
|
|
@ -952,51 +953,54 @@ export class EmployeeTempPositionController extends Controller {
|
|||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(posType.posTypeShortName,' ',posLevel.posLevelName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
let [posMaster, total] = await query
|
||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||
|
|
@ -1129,23 +1133,21 @@ export class EmployeeTempPositionController extends Controller {
|
|||
};
|
||||
}),
|
||||
);
|
||||
if(_data.privilege === 'NORMAL'|| _data.privilege === 'PARENT'|| _data.privilege === 'CHILD'){ //PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||
const nextChildMap:any = { //เอาไวเช็ค CHILD ถัดไป
|
||||
if (_data.privilege === "NORMAL" || _data.privilege === "CHILD") {
|
||||
//PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||
const nextChildMap: any = {
|
||||
//เอาไวเช็ค CHILD ถัดไป
|
||||
0: _data.child1,
|
||||
1: _data.child2,
|
||||
2: _data.child3,
|
||||
3: _data.child4,
|
||||
};
|
||||
const childValue = nextChildMap[body.type];
|
||||
if(_data.privilege === 'NORMAL'){
|
||||
if (Array.isArray(childValue) && childValue.some(item => item != null)) {
|
||||
if (_data.privilege === "NORMAL") {
|
||||
if (Array.isArray(childValue) && childValue.some((item) => item != null)) {
|
||||
return new HttpSuccess({ data: [], total: 0 });
|
||||
}
|
||||
}else if(_data.privilege === 'PARENT'){
|
||||
if (body.type == 0){
|
||||
return new HttpSuccess({ data: [], total: 0 });
|
||||
}
|
||||
} else if (_data.privilege === 'CHILD') {
|
||||
} else if (_data.privilege === "CHILD") {
|
||||
const higherChildChecks = [
|
||||
{ type: [0], child: _data.child1, next: _data.child2 },
|
||||
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
||||
|
|
@ -1410,50 +1412,50 @@ export class EmployeeTempPositionController extends Controller {
|
|||
const type0LastPosMasterNo =
|
||||
requestBody.type == 0
|
||||
? await this.employeeTempPosMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type1LastPosMasterNo =
|
||||
requestBody.type == 1
|
||||
? await this.employeeTempPosMasterRepository.find({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type2LastPosMasterNo =
|
||||
requestBody.type == 2
|
||||
? await this.employeeTempPosMasterRepository.find({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type3LastPosMasterNo =
|
||||
requestBody.type == 3
|
||||
? await this.employeeTempPosMasterRepository.find({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type4LastPosMasterNo =
|
||||
requestBody.type == 4
|
||||
? await this.employeeTempPosMasterRepository.find({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const allLastPosMasterNo = [
|
||||
|
|
|
|||
|
|
@ -102,6 +102,9 @@ import { HR_PERSONAL_EMPTEMP_ADDRESS } from "../entities/mis/HR_PERSONAL_EMPTEMP
|
|||
import { HR_PERSONAL_EMPTEMP_FAMILY } from "../entities/mis/HR_PERSONAL_EMPTEMP_FAMILY";
|
||||
import { HR_POSITION_EMPLOYEETEMP } from "../entities/mis/HR_POSITION_EMPLOYEETEMP";
|
||||
import { positionOfficer } from "../entities/mis/positionOfficer";
|
||||
import { ProvinceMaster } from "../entities/ProvinceMaster";
|
||||
import { SubDistrictMaster } from "../entities/SubDistrictMaster";
|
||||
import { DistrictMaster } from "../entities/DistrictMaster";
|
||||
@Route("api/v1/org/upload")
|
||||
@Tags("UPLOAD")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -6362,4 +6365,448 @@ export class ImportDataController extends Controller {
|
|||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @summary Update importUpdate for provinces matching JSON
|
||||
// */
|
||||
// @Post("updateProvinceImportOld")
|
||||
// async updateProvinceImportOld() {
|
||||
// const fs = require("fs");
|
||||
// const path = require("path");
|
||||
// const filePath = path.join(__dirname, "../data/provinces.json");
|
||||
// const provinceJson = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
// let num = 0;
|
||||
// const Fuse = require("fuse.js");
|
||||
// const fuse = new Fuse(
|
||||
// provinceJson.map((x: any) => x.name_th),
|
||||
// {
|
||||
// includeScore: true,
|
||||
// threshold: 0.2, // ยิ่งต่ำยิ่งเข้มงวด
|
||||
// },
|
||||
// );
|
||||
// const provinces = await this.provinceIdRepo.find({ where: { importUpdate: IsNull() } });
|
||||
// for (const prov of provinces) {
|
||||
// console.log("11");
|
||||
// const result = fuse.search(prov.name);
|
||||
// const repoProvince = AppDataSource.getRepository(ProvinceMaster);
|
||||
// console.log("1221");
|
||||
// if (result.length > 0) {
|
||||
// let foundItem = result[0];
|
||||
// if (result.length > 1) {
|
||||
// foundItem = result.filter((x: any) => x.score == 0)[0];
|
||||
// if (foundItem == null) {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// const province = await repoProvince.findOne({
|
||||
// where: { name_th: foundItem.item },
|
||||
// });
|
||||
// if (province == null) {
|
||||
// console.log(foundItem.item);
|
||||
// num += 1;
|
||||
// continue;
|
||||
// }
|
||||
// console.log("1441");
|
||||
// prov.importUpdate = 1;
|
||||
// prov.refId = province.id;
|
||||
// prov.name = province.name_th;
|
||||
// await this.provinceIdRepo.save(prov);
|
||||
// } else {
|
||||
// console.log("qqqqq");
|
||||
// console.log(prov.name);
|
||||
// console.log(result);
|
||||
// num += 1;
|
||||
// }
|
||||
// }
|
||||
// console.log("not found province count:", num);
|
||||
// return new HttpSuccess();
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @summary Update importUpdate for districts matching JSON
|
||||
// */
|
||||
// @Post("updateDistrictImportOld")
|
||||
// async updateDistrictImportOld() {
|
||||
// const fs = require("fs");
|
||||
// const path = require("path");
|
||||
// const filePath = path.join(__dirname, "../data/tambons.json");
|
||||
// const districtJson = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
// let num = 0;
|
||||
// const Fuse = require("fuse.js");
|
||||
// const districts = await this.districtIdRepo.find({
|
||||
// relations: ["province"],
|
||||
// where: { province: { refId: Not(IsNull()) }, importUpdate: IsNull() },
|
||||
// });
|
||||
// for (const prov of districts) {
|
||||
// const fuse = new Fuse(
|
||||
// districtJson
|
||||
// .filter((x: any) => x.province_id === prov.province?.refId)
|
||||
// .map((x: any) => x.name_th),
|
||||
// {
|
||||
// includeScore: true,
|
||||
// threshold: 0.2, // ยิ่งต่ำยิ่งเข้มงวด
|
||||
// },
|
||||
// );
|
||||
// const result = fuse.search(prov.name);
|
||||
// const repoDistrict = AppDataSource.getRepository(DistrictMaster);
|
||||
// if (result.length > 0) {
|
||||
// let foundItem = result[0];
|
||||
// if (result.length > 1) {
|
||||
// foundItem = result.filter((x: any) => x.score == 0)[0];
|
||||
// if (foundItem == null) {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// const district = await repoDistrict.findOne({
|
||||
// where: { name_th: foundItem.item, province_id: prov.province?.refId },
|
||||
// });
|
||||
// if (district == null) {
|
||||
// num += 1;
|
||||
// continue;
|
||||
// }
|
||||
// prov.importUpdate = 1;
|
||||
// prov.refId = district.id;
|
||||
// prov.name = district.name_th;
|
||||
// await this.districtIdRepo.save(prov);
|
||||
// } else {
|
||||
// num += 1;
|
||||
// }
|
||||
// }
|
||||
// console.log("not found district count:", num);
|
||||
// return new HttpSuccess();
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @summary Update importUpdate for subdistricts matching JSON
|
||||
// */
|
||||
// @Post("updateSubDistrictImportOld")
|
||||
// async updateSubDistrictImportOld() {
|
||||
// const fs = require("fs");
|
||||
// const path = require("path");
|
||||
// const filePath = path.join(__dirname, "../data/amphures.json");
|
||||
// const subDistrictJson = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
// let num = 0;
|
||||
// const Fuse = require("fuse.js");
|
||||
// const subDistricts = await this.subDistrictIdRepo.find({
|
||||
// relations: ["district"],
|
||||
// where: { district: { refId: Not(IsNull()) }, importUpdate: IsNull() },
|
||||
// });
|
||||
// for (const prov of subDistricts) {
|
||||
// const fuse = new Fuse(
|
||||
// subDistrictJson
|
||||
// .filter((x: any) => x.district_id === prov.district?.refId)
|
||||
// .map((x: any) => x.name_th),
|
||||
// {
|
||||
// includeScore: true,
|
||||
// threshold: 0.2, // ยิ่งต่ำยิ่งเข้มงวด
|
||||
// },
|
||||
// );
|
||||
// const result = fuse.search(prov.name);
|
||||
// const repoSubDistrict = AppDataSource.getRepository(SubDistrictMaster);
|
||||
// if (result.length > 0) {
|
||||
// let foundItem = result[0];
|
||||
// if (result.length > 1) {
|
||||
// foundItem = result.filter((x: any) => x.score == 0)[0];
|
||||
// if (foundItem == null) {
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// const subdistrict = await repoSubDistrict.findOne({
|
||||
// where: { name_th: foundItem.item, district_id: prov.district?.refId },
|
||||
// });
|
||||
// if (subdistrict == null) {
|
||||
// num += 1;
|
||||
// continue;
|
||||
// }
|
||||
// prov.importUpdate = 1;
|
||||
// prov.refId = subdistrict.id;
|
||||
// prov.name = subdistrict.name_th;
|
||||
// prov.zipCode = subdistrict.zip_code.toString();
|
||||
// await this.subDistrictIdRepo.save(prov);
|
||||
// } else {
|
||||
// num += 1;
|
||||
// }
|
||||
// }
|
||||
// console.log("not found subdistrict count:", num);
|
||||
// return new HttpSuccess();
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @summary Update importUpdate for provinces matching JSON
|
||||
// */
|
||||
// @Post("updateProvinceImportFlag")
|
||||
// async updateProvinceImportFlag() {
|
||||
// const fs = require("fs");
|
||||
// const path = require("path");
|
||||
// const filePath = path.join(__dirname, "../data/provinces.json");
|
||||
// const provinceJson = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
// let num = 0;
|
||||
// for (const province of provinceJson) {
|
||||
// const dbProvince = await this.provinceIdRepo.findOne({
|
||||
// where: {
|
||||
// name: province.name_th,
|
||||
// importUpdate: IsNull(),
|
||||
// },
|
||||
// });
|
||||
// if (dbProvince) {
|
||||
// dbProvince.importUpdate = 1;
|
||||
// dbProvince.refId = province.id;
|
||||
// await this.provinceIdRepo.save(dbProvince);
|
||||
// } else {
|
||||
// num += 1;
|
||||
// }
|
||||
// }
|
||||
// console.log("not found province count:", num);
|
||||
// return new HttpSuccess();
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @summary Update importUpdate for districts matching JSON
|
||||
// */
|
||||
// @Post("updateDistrictImportFlag")
|
||||
// async updateDistrictImportFlag() {
|
||||
// const meta = {
|
||||
// createdUserId: "",
|
||||
// createdFullName: "system",
|
||||
// lastUpdateUserId: "",
|
||||
// lastUpdateFullName: "system",
|
||||
// createdAt: new Date(),
|
||||
// lastUpdatedAt: new Date(),
|
||||
// };
|
||||
// const fs = require("fs");
|
||||
// const path = require("path");
|
||||
// const filePath = path.join(__dirname, "../data/tambons.json");
|
||||
// const tambonJson = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
// let num = 0;
|
||||
// for (const tambon of tambonJson) {
|
||||
// const dbDistrict = await this.districtIdRepo.findOne({
|
||||
// where: {
|
||||
// name: tambon.name_th,
|
||||
// province: { refId: Not(tambon.province_id) },
|
||||
// importUpdate: IsNull(),
|
||||
// },
|
||||
// });
|
||||
// if (dbDistrict) {
|
||||
// const dbProvince = await this.provinceIdRepo.findOne({
|
||||
// where: {
|
||||
// refId: tambon.province_id,
|
||||
// importUpdate: Not(IsNull()),
|
||||
// },
|
||||
// });
|
||||
// if (dbProvince) {
|
||||
// const checkOld = await this.districtIdRepo.findOne({
|
||||
// where: {
|
||||
// name: tambon.name_th,
|
||||
// provinceId: dbProvince.id,
|
||||
// },
|
||||
// });
|
||||
// if (!checkOld) {
|
||||
// let districtId = new District();
|
||||
// Object.assign(districtId, {
|
||||
// ...meta,
|
||||
// name: tambon.name_th,
|
||||
// provinceId: dbProvince.id,
|
||||
// importUpdate: 2,
|
||||
// refId: tambon.id,
|
||||
// });
|
||||
// await this.districtIdRepo.save(districtId);
|
||||
// num += 1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// console.log("not found province count:", num);
|
||||
// return new HttpSuccess();
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @summary Update importUpdate for subdistricts matching JSON
|
||||
// */
|
||||
// @Post("updateSubDistrictImportFlag")
|
||||
// async updateSubDistrictImportFlag() {
|
||||
// const meta = {
|
||||
// createdUserId: "",
|
||||
// createdFullName: "system",
|
||||
// lastUpdateUserId: "",
|
||||
// lastUpdateFullName: "system",
|
||||
// createdAt: new Date(),
|
||||
// lastUpdatedAt: new Date(),
|
||||
// };
|
||||
// const fs = require("fs");
|
||||
// const path = require("path");
|
||||
// const filePath = path.join(__dirname, "../data/amphures.json");
|
||||
// const amphureJson = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
// let num = 0;
|
||||
// for (const amphure of amphureJson) {
|
||||
// const dbSubDistrict = await this.subDistrictIdRepo.findOne({
|
||||
// where: {
|
||||
// name: amphure.name_th,
|
||||
// district: { refId: Not(amphure.district_id) },
|
||||
// importUpdate: IsNull(),
|
||||
// },
|
||||
// });
|
||||
// if (dbSubDistrict) {
|
||||
// const dbDistrict = await this.districtIdRepo.findOne({
|
||||
// where: {
|
||||
// refId: amphure.district_id,
|
||||
// importUpdate: Not(IsNull()),
|
||||
// },
|
||||
// });
|
||||
// if (dbDistrict) {
|
||||
// const checkOld = await this.subDistrictIdRepo.findOne({
|
||||
// where: {
|
||||
// name: amphure.name_th,
|
||||
// districtId: dbDistrict.id,
|
||||
// },
|
||||
// });
|
||||
// if (!checkOld) {
|
||||
// let districtId = new District();
|
||||
// Object.assign(districtId, {
|
||||
// ...meta,
|
||||
// name: amphure.name_th,
|
||||
// districtId: dbDistrict.id,
|
||||
// zipCode: amphure.zip_code,
|
||||
// importUpdate: 2,
|
||||
// refId: amphure.id,
|
||||
// });
|
||||
// await this.subDistrictIdRepo.save(districtId);
|
||||
// num += 1;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// console.log("not found province count:", num);
|
||||
// return new HttpSuccess();
|
||||
// }
|
||||
// /**
|
||||
// * @summary ตรวจสอบ district ใน profile ว่าตรงกับ tambons.json หรือไม่
|
||||
// */
|
||||
// @Post("checkProfileDistrictMismatch")
|
||||
// async checkProfileDistrictMismatch() {
|
||||
// const mismatches = [];
|
||||
// const profiles = await this.profileRepo.find({
|
||||
// relations: ["registrationProvince", "registrationDistrict", "registrationSubDistrict"],
|
||||
// where: {
|
||||
// registrationProvince: Not(IsNull()),
|
||||
// },
|
||||
// });
|
||||
// for (const profile of profiles) {
|
||||
// console.log("profile count:", profiles.indexOf(profile) + 1);
|
||||
// console.log("mismatches count:", mismatches.length);
|
||||
// // if (mismatches.length >= 10) {
|
||||
// // break;
|
||||
// // }
|
||||
// const repoProvince = AppDataSource.getRepository(ProvinceMaster);
|
||||
// const repoDistrict = AppDataSource.getRepository(DistrictMaster);
|
||||
// const repoSubDistrict = AppDataSource.getRepository(SubDistrictMaster);
|
||||
|
||||
// const registrationProvince = profile.registrationProvince?.name;
|
||||
// const registrationDistrict = profile.registrationDistrict?.name;
|
||||
// const registrationSubDistrict = profile.registrationSubDistrict?.name;
|
||||
|
||||
// const province = await repoProvince.findOne({
|
||||
// where: { name_th: registrationProvince },
|
||||
// });
|
||||
// if (province == null) {
|
||||
// mismatches.push({ profileId: profile.id });
|
||||
// continue;
|
||||
// }
|
||||
// const district = await repoDistrict.findOne({
|
||||
// where: { name_th: registrationDistrict, province_id: province.id },
|
||||
// });
|
||||
// if (district == null) {
|
||||
// mismatches.push({ profileId: profile.id });
|
||||
// continue;
|
||||
// }
|
||||
// const subdistrict = await repoSubDistrict.findOne({
|
||||
// where: { name_th: registrationSubDistrict, district_id: district.id },
|
||||
// });
|
||||
// if (subdistrict == null) {
|
||||
// mismatches.push({ profileId: profile.id });
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
// return mismatches.map((x) => x.profileId);
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @summary Import provinces.json into ProvinceMaster table
|
||||
// */
|
||||
// @Post("importProvinceMaster")
|
||||
// async importProvinceMaster() {
|
||||
// const fs = require("fs");
|
||||
// const path = require("path");
|
||||
// const filePath = path.join(__dirname, "../data/provinces.json");
|
||||
// const provinceJson = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
// const repo = AppDataSource.getRepository(ProvinceMaster);
|
||||
// let imported = [];
|
||||
// for (const prov of provinceJson) {
|
||||
// const newProv = repo.create({
|
||||
// id: prov.id,
|
||||
// name_th: prov.name_th,
|
||||
// name_en: prov.name_en,
|
||||
// geography_id: prov.geography_id,
|
||||
// created_at: prov.created_at,
|
||||
// updated_at: prov.updated_at,
|
||||
// });
|
||||
// await repo.save(newProv);
|
||||
// imported.push(newProv);
|
||||
// }
|
||||
// return imported;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @summary Import tambons.json into DistrictMaster table
|
||||
// */
|
||||
// @Post("importDistrictMaster")
|
||||
// async importDistrictMaster() {
|
||||
// const fs = require("fs");
|
||||
// const path = require("path");
|
||||
// const filePath = path.join(__dirname, "../data/tambons.json");
|
||||
// const tambonJson = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
// const repo = AppDataSource.getRepository(DistrictMaster);
|
||||
// let imported = [];
|
||||
// for (const tambon of tambonJson) {
|
||||
// const newSub = repo.create({
|
||||
// id: tambon.id,
|
||||
// name_th: tambon.name_th,
|
||||
// name_en: tambon.name_en,
|
||||
// province_id: tambon.province_id,
|
||||
// created_at: tambon.created_at,
|
||||
// updated_at: tambon.updated_at,
|
||||
// });
|
||||
// await repo.save(newSub);
|
||||
// imported.push(newSub);
|
||||
// }
|
||||
// return imported;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @summary Import amphures.json into SubDistrictMaster table
|
||||
// */
|
||||
// @Post("importSubDistrictMaster")
|
||||
// async importSubDistrictMaster() {
|
||||
// const fs = require("fs");
|
||||
// const path = require("path");
|
||||
// const filePath = path.join(__dirname, "../data/amphures.json");
|
||||
// const amphureJson = JSON.parse(fs.readFileSync(filePath, "utf8"));
|
||||
// const repo = AppDataSource.getRepository(SubDistrictMaster);
|
||||
// // Prepare all entities first
|
||||
// const entities = amphureJson.map((amphure: any) =>
|
||||
// repo.create({
|
||||
// id: amphure.id,
|
||||
// zip_code: amphure.zip_code,
|
||||
// name_th: amphure.name_th,
|
||||
// name_en: amphure.name_en,
|
||||
// district_id: amphure.district_id,
|
||||
// lat: amphure.lat,
|
||||
// long: amphure.long,
|
||||
// created_at: amphure.created_at,
|
||||
// updated_at: amphure.updated_at,
|
||||
// }),
|
||||
// );
|
||||
// // Bulk insert for performance
|
||||
// await repo.save(entities);
|
||||
// return entities;
|
||||
// }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2036,7 +2036,7 @@ export class OrganizationController extends Controller {
|
|||
_data.child2 = [holder.orgChild2Id];
|
||||
_data.child3 = [holder.orgChild3Id];
|
||||
_data.child4 = [holder.orgChild4Id];
|
||||
} else if (_privilege.privilege == "CHILD") {
|
||||
} else if (_privilege.privilege == "CHILD" || _privilege.privilege == "BROTHER") {
|
||||
const holder = profile.current_holders.find((x) => x.orgRevisionId === id);
|
||||
if (!holder) return;
|
||||
_data.root = [holder.orgRootId];
|
||||
|
|
@ -5484,6 +5484,153 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API เช็ค node detail
|
||||
*
|
||||
* @summary เช็ค node detail (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Post("find/allv2")
|
||||
async findNodeAllDetailV2(@Body() requestBody: { node: number; nodeId: string }) {
|
||||
switch (requestBody.node) {
|
||||
case 0: {
|
||||
const data = await this.orgRootRepository.findOne({
|
||||
where: { ancestorDNA: requestBody.nodeId },
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found rootId.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.id,
|
||||
rootDnaId: data.ancestorDNA,
|
||||
root: data.orgRootName,
|
||||
rootShortName: data.orgRootShortName,
|
||||
});
|
||||
}
|
||||
case 1: {
|
||||
const data = await this.child1Repository.findOne({
|
||||
where: { ancestorDNA: requestBody.nodeId },
|
||||
relations: {
|
||||
orgRoot: true,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child1.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.orgRootId,
|
||||
rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA,
|
||||
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
|
||||
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
|
||||
child1Id: data.id,
|
||||
child1DnaId: data.ancestorDNA,
|
||||
child1: data.orgChild1Name,
|
||||
child1ShortName: data.orgChild1ShortName,
|
||||
});
|
||||
}
|
||||
case 2: {
|
||||
const data = await this.child2Repository.findOne({
|
||||
where: { ancestorDNA: requestBody.nodeId },
|
||||
relations: {
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child2.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.orgRootId,
|
||||
rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA,
|
||||
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
|
||||
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
|
||||
child1Id: data.orgChild1Id,
|
||||
child1DnaId: data.orgChild1 == null ? null : data.orgChild1.ancestorDNA,
|
||||
child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name,
|
||||
child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName,
|
||||
child2Id: data.id,
|
||||
child2DnaId: data.ancestorDNA,
|
||||
child2: data.orgChild2Name,
|
||||
child2ShortName: data.orgChild2ShortName,
|
||||
});
|
||||
}
|
||||
case 3: {
|
||||
const data = await this.child3Repository.findOne({
|
||||
where: { ancestorDNA: requestBody.nodeId },
|
||||
relations: {
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
orgChild2: true,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child3.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.orgRootId,
|
||||
rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA,
|
||||
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
|
||||
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
|
||||
child1Id: data.orgChild1Id,
|
||||
child1DnaId: data.orgChild1 == null ? null : data.orgChild1.ancestorDNA,
|
||||
child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name,
|
||||
child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName,
|
||||
child2Id: data.orgChild2Id,
|
||||
child2DnaId: data.orgChild2 == null ? null : data.orgChild2.ancestorDNA,
|
||||
child2: data.orgChild2 == null ? null : data.orgChild2.orgChild2Name,
|
||||
child2ShortName: data.orgChild2 == null ? null : data.orgChild2.orgChild2ShortName,
|
||||
child3Id: data.id,
|
||||
child3DnaId: data.ancestorDNA,
|
||||
child3: data.orgChild3Name,
|
||||
child3ShortName: data.orgChild3ShortName,
|
||||
});
|
||||
}
|
||||
case 4: {
|
||||
const data = await this.child4Repository.findOne({
|
||||
where: { ancestorDNA: requestBody.nodeId },
|
||||
relations: {
|
||||
orgRoot: true,
|
||||
orgChild1: true,
|
||||
orgChild2: true,
|
||||
orgChild3: true,
|
||||
},
|
||||
order: { createdAt: "DESC" },
|
||||
});
|
||||
if (data == null) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found child4.");
|
||||
}
|
||||
return new HttpSuccess({
|
||||
rootId: data.orgRootId,
|
||||
rootDnaId: data.orgRoot == null ? null : data.orgRoot.ancestorDNA,
|
||||
root: data.orgRoot == null ? null : data.orgRoot.orgRootName,
|
||||
rootShortName: data.orgRoot == null ? null : data.orgRoot.orgRootShortName,
|
||||
child1Id: data.orgChild1Id,
|
||||
child1DnaId: data.orgChild1 == null ? null : data.orgChild1.ancestorDNA,
|
||||
child1: data.orgChild1 == null ? null : data.orgChild1.orgChild1Name,
|
||||
child1ShortName: data.orgChild1 == null ? null : data.orgChild1.orgChild1ShortName,
|
||||
child2Id: data.orgChild2Id,
|
||||
child2DnaId: data.orgChild2 == null ? null : data.orgChild2.ancestorDNA,
|
||||
child2: data.orgChild2 == null ? null : data.orgChild2.orgChild2Name,
|
||||
child2ShortName: data.orgChild2 == null ? null : data.orgChild2.orgChild2ShortName,
|
||||
child3Id: data.orgChild3Id,
|
||||
child3DnaId: data.orgChild3 == null ? null : data.orgChild3.ancestorDNA,
|
||||
child3: data.orgChild3 == null ? null : data.orgChild3.orgChild3Name,
|
||||
child3ShortName: data.orgChild3 == null ? null : data.orgChild3.orgChild3ShortName,
|
||||
child4Id: data.id,
|
||||
child4DnaId: data.ancestorDNA,
|
||||
child4: data.orgChild4Name,
|
||||
child4ShortName: data.orgChild4ShortName,
|
||||
});
|
||||
}
|
||||
default:
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found type: " + requestBody.node);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API หาสำนักทั้งหมด
|
||||
*
|
||||
|
|
@ -6128,7 +6275,7 @@ export class OrganizationController extends Controller {
|
|||
if (!orgRevision) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
let _data:any = {
|
||||
let _data: any = {
|
||||
root: null,
|
||||
child1: null,
|
||||
child2: null,
|
||||
|
|
@ -6141,7 +6288,7 @@ export class OrganizationController extends Controller {
|
|||
) {
|
||||
_data = await new permission().PermissionOrgList(request, system.trim().toUpperCase());
|
||||
}
|
||||
|
||||
|
||||
const profile = await this.profileRepo.findOne({
|
||||
where: { keycloak: request.user.sub },
|
||||
relations: ["permissionProfiles", "current_holders"],
|
||||
|
|
@ -6150,32 +6297,32 @@ export class OrganizationController extends Controller {
|
|||
if (!profile) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งานในทะเบียนประวัติ");
|
||||
}
|
||||
|
||||
|
||||
let _privilege = await new permission().PermissionOrgList(request, system);
|
||||
const attrOwnership = _privilege.root === null ? true : false;
|
||||
|
||||
if (orgRevision.orgRevisionIsDraft && !orgRevision.orgRevisionIsCurrent && !attrOwnership) {
|
||||
if(Array.isArray(profile.permissionProfiles) && profile.permissionProfiles.length > 0){
|
||||
if (Array.isArray(profile.permissionProfiles) && profile.permissionProfiles.length > 0) {
|
||||
_data.root = profile.permissionProfiles.map((x) => x.orgRootId);
|
||||
}else{
|
||||
} else {
|
||||
return new HttpSuccess({ remark: "", data: [] });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// กำหนดการเข้าถึงข้อมูลตามสถานะและสิทธิ์
|
||||
const isCurrentActive = !orgRevision.orgRevisionIsDraft && orgRevision.orgRevisionIsCurrent;
|
||||
if (isCurrentActive) {
|
||||
if(_privilege.privilege !== "OWNER"){
|
||||
if(_privilege.privilege == "NORMAL"){
|
||||
const holder = profile.current_holders.find(x => x.orgRevisionId === id);
|
||||
if (_privilege.privilege !== "OWNER") {
|
||||
if (_privilege.privilege == "NORMAL") {
|
||||
const holder = profile.current_holders.find((x) => x.orgRevisionId === id);
|
||||
if (!holder) return;
|
||||
_data.root = [holder.orgRootId];
|
||||
_data.child1 = [holder.orgChild1Id];
|
||||
_data.child2 = [holder.orgChild2Id];
|
||||
_data.child3 = [holder.orgChild3Id];
|
||||
_data.child4 = [holder.orgChild4Id];
|
||||
}else if(_privilege.privilege == "CHILD"){
|
||||
const holder = profile.current_holders.find(x => x.orgRevisionId === id);
|
||||
} else if (_privilege.privilege == "CHILD" || _privilege.privilege == "BROTHER") {
|
||||
const holder = profile.current_holders.find((x) => x.orgRevisionId === id);
|
||||
if (!holder) return;
|
||||
_data.root = [holder.orgRootId];
|
||||
if (_privilege.root && _privilege.child1 === null) {
|
||||
|
|
@ -6190,7 +6337,7 @@ export class OrganizationController extends Controller {
|
|||
_data.child3 = [holder.orgChild3Id];
|
||||
_data.child4 = [holder.orgChild4Id];
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
_data.root = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgRootId];
|
||||
}
|
||||
} else {
|
||||
|
|
@ -6242,7 +6389,7 @@ export class OrganizationController extends Controller {
|
|||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `orgChild1.id IN (:...node)`
|
||||
: `orgChild1.id is null`
|
||||
: `orgChild1.id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
node: _data.child1,
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ import HttpStatus from "../interfaces/http-status";
|
|||
import HttpError from "../interfaces/http-error";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import { Profile } from "../entities/Profile";
|
||||
import { And, Between, Brackets, In, IsNull, Not } from "typeorm";
|
||||
import { And, Between, Brackets, In, IsNull, LessThanOrEqual, Not } from "typeorm";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
import { OrgChild1 } from "../entities/OrgChild1";
|
||||
|
|
@ -34,6 +34,7 @@ import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
|||
import { EmployeePosDict } from "../entities/EmployeePosDict";
|
||||
import { calculateRetireLaw } from "../interfaces/utils";
|
||||
import Extension from "../interfaces/extension";
|
||||
import { PosMasterHistory } from "../entities/PosMasterHistory";
|
||||
@Route("api/v1/org/dotnet")
|
||||
@Tags("Dotnet")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -53,10 +54,28 @@ export class OrganizationDotnetController extends Controller {
|
|||
private profileEmpRepo = AppDataSource.getRepository(ProfileEmployee);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private posMasterHistoryRepository = AppDataSource.getRepository(PosMasterHistory);
|
||||
private empPosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||
private insigniaRepo = AppDataSource.getRepository(ProfileInsignia);
|
||||
private employeePosDictRepository = AppDataSource.getRepository(EmployeePosDict);
|
||||
|
||||
/**
|
||||
* ทำไว้ให้ service อื่นๆ ภายในระบบ call มาตรวจสอบเลขบัตรประจำตัวประชาชน
|
||||
*
|
||||
* @summary API ตรวจสอบเช็คเลขบัตรประจำตัวประชาชน
|
||||
*
|
||||
*/
|
||||
@Post("check-citizen")
|
||||
public async CheckCitizen(
|
||||
@Body()
|
||||
body: {
|
||||
citizenId: string;
|
||||
},
|
||||
) {
|
||||
let citizen = Extension.CheckCitizen(body.citizenId);
|
||||
return new HttpSuccess(citizen);
|
||||
}
|
||||
|
||||
/**
|
||||
* 1. API Search Profile
|
||||
*
|
||||
|
|
@ -101,6 +120,28 @@ export class OrganizationDotnetController extends Controller {
|
|||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
} else if (body.role === "BROTHER") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 1:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 2:
|
||||
condition = "orgChild1.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 3:
|
||||
condition = "orgChild2.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 4:
|
||||
condition = "orgChild3.ancestorDNA = :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
} else if (body.role === "ROOT") {
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
|
|
@ -220,6 +261,28 @@ export class OrganizationDotnetController extends Controller {
|
|||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
} else if (body.role === "BROTHER") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 1:
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 2:
|
||||
condition = "orgChild1.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 3:
|
||||
condition = "orgChild2.ancestorDNA = :nodeId";
|
||||
break;
|
||||
case 4:
|
||||
condition = "orgChild3.ancestorDNA = :nodeId";
|
||||
break;
|
||||
default:
|
||||
condition = "1=1";
|
||||
break;
|
||||
}
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
} else if (body.role === "ROOT") {
|
||||
condition = "orgRoot.ancestorDNA = :nodeId";
|
||||
conditionParams = { nodeId: body.nodeId };
|
||||
|
|
@ -439,7 +502,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
x.orgRevision?.orgRevisionIsCurrent == true,
|
||||
)?.orgChild4?.id ?? null,
|
||||
};
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -465,7 +528,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
commanderId = pos.current_holder?.id;
|
||||
commanderKeycloak = pos.current_holder?.keycloak;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -490,7 +553,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
commanderId = pos.current_holder?.id;
|
||||
commanderKeycloak = pos.current_holder?.keycloak;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -515,7 +578,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
commanderId = pos.current_holder?.id;
|
||||
commanderKeycloak = pos.current_holder?.keycloak;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -540,7 +603,7 @@ export class OrganizationDotnetController extends Controller {
|
|||
commanderId = pos.current_holder?.id;
|
||||
commanderKeycloak = pos.current_holder?.keycloak;
|
||||
} else {
|
||||
let pos = await this.posMasterRepository.findOne({
|
||||
let pos = await this.empPosMasterRepository.findOne({
|
||||
relations: ["current_holder"],
|
||||
where: {
|
||||
orgRevision: {
|
||||
|
|
@ -2596,10 +2659,21 @@ export class OrganizationDotnetController extends Controller {
|
|||
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
|
||||
posLevel: profile.posLevel?.posLevelName ?? "",
|
||||
posType: profile.posType?.posTypeName ?? "",
|
||||
profileSalary: profile.profileSalary,
|
||||
profileInsignia: profile.profileInsignias.map((x) => {
|
||||
return { ...x, insignia: x.insignia.name };
|
||||
}),
|
||||
// profileSalary: profile.profileSalary,
|
||||
profileSalary:
|
||||
profile.profileSalary?.map((x) => ({
|
||||
...x,
|
||||
date: x.commandDateAffect ?? new Date(),
|
||||
})) ?? [],
|
||||
// profileInsignia: profile.profileInsignias.map((x) => {
|
||||
// return { ...x, insignia: x.insignia.name };
|
||||
// }),
|
||||
profileInsignia:
|
||||
profile.profileInsignias?.map((x) => ({
|
||||
...x,
|
||||
insigniaId: x.insignia?.id ?? null,
|
||||
insignia: x.insignia?.name ?? null,
|
||||
})) ?? [],
|
||||
amount: profile.amount,
|
||||
positionSalaryAmount: profile.positionSalaryAmount,
|
||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||
|
|
@ -2897,9 +2971,15 @@ export class OrganizationDotnetController extends Controller {
|
|||
: profile.posType?.posTypeShortName + " ") + (profile.posLevel?.posLevelName ?? ""),
|
||||
posType: profile.posType?.posTypeName ?? "",
|
||||
profileSalary: profile.profileSalary,
|
||||
profileInsignia: profile.profileInsignias.map((x) => {
|
||||
return { ...x, insignia: x.insignia.name };
|
||||
}),
|
||||
// profileInsignia: profile.profileInsignias.map((x) => {
|
||||
// return { ...x, insignia: x.insignia.name };
|
||||
// }),
|
||||
profileInsignia:
|
||||
profile.profileInsignias?.map((x) => ({
|
||||
...x,
|
||||
insigniaId: x.insignia?.id ?? null,
|
||||
insignia: x.insignia?.name ?? null,
|
||||
})) ?? [],
|
||||
amount: profile.amount,
|
||||
positionSalaryAmount: profile.positionSalaryAmount,
|
||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||
|
|
@ -3111,12 +3191,23 @@ export class OrganizationDotnetController extends Controller {
|
|||
? ""
|
||||
: profile.posType?.posTypeShortName + " ") + (profile.posLevel?.posLevelName ?? ""),
|
||||
posType: profile.posType?.posTypeName ?? "",
|
||||
profileSalary: profile.profileSalary.map((x) => {
|
||||
return { ...x, date: x.commandDateAffect ?? new Date() };
|
||||
}),
|
||||
profileInsignia: profile.profileInsignias.map((x) => {
|
||||
return { ...x, insignia: x.insignia.name };
|
||||
}),
|
||||
// profileSalary: profile.profileSalary.map((x) => {
|
||||
// return { ...x, date: x.commandDateAffect ?? new Date() };
|
||||
// }),
|
||||
profileSalary:
|
||||
profile.profileSalary?.map((x) => ({
|
||||
...x,
|
||||
date: x.commandDateAffect ?? new Date(),
|
||||
})) ?? [],
|
||||
// profileInsignia: profile.profileInsignias.map((x) => {
|
||||
// return { ...x, insignia: x.insignia.name };
|
||||
// }),
|
||||
profileInsignia:
|
||||
profile.profileInsignias?.map((x) => ({
|
||||
...x,
|
||||
insigniaId: x.insignia?.id ?? null,
|
||||
insignia: x.insignia?.name ?? null,
|
||||
})) ?? [],
|
||||
amount: profile.amount,
|
||||
positionSalaryAmount: profile.positionSalaryAmount,
|
||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||
|
|
@ -4399,46 +4490,96 @@ export class OrganizationDotnetController extends Controller {
|
|||
},
|
||||
) {
|
||||
let typeCondition: any = {};
|
||||
if (body.role === "CHILD" || body.role === "PARENT") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
orgChild1: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
orgChild2: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
orgChild3: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
orgChild4: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
if (body.role === "CHILD" || body.role === "PARENT" || body.role === "BROTHER") {
|
||||
if (body.role === "CHILD") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
orgChild1: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
orgChild2: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
orgChild3: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
orgChild4: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
} else if (body.role === "BROTHER") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
orgChild1: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
orgChild2: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
orgChild3: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
} else if (body.role === "PARENT") {
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
orgChild1: Not(IsNull()),
|
||||
};
|
||||
}
|
||||
} else if (body.role === "OWNER" || body.role === "ROOT") {
|
||||
switch (body.reqNode) {
|
||||
|
|
@ -4994,49 +5135,96 @@ export class OrganizationDotnetController extends Controller {
|
|||
},
|
||||
) {
|
||||
let typeCondition: any = {};
|
||||
if (body.role === "CHILD" || body.role === "PARENT") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
orgChild1: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
orgChild2: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
orgChild3: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
orgChild4: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case null:
|
||||
typeCondition = {};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
if (body.role === "CHILD" || body.role === "PARENT" || body.role === "BROTHER") {
|
||||
if (body.role === "CHILD") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
orgChild1: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
orgChild2: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
orgChild3: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
orgChild4: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
} else if (body.role === "BROTHER") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
orgChild1: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
orgChild2: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
orgChild3: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
} else if (body.role === "PARENT") {
|
||||
typeCondition = {
|
||||
orgRoot: {
|
||||
ancestorDNA: body.nodeId,
|
||||
},
|
||||
orgChild1: Not(IsNull()),
|
||||
};
|
||||
}
|
||||
} else if (body.role === "OWNER" || body.role === "ROOT") {
|
||||
switch (body.reqNode) {
|
||||
|
|
@ -5807,4 +5995,228 @@ export class OrganizationDotnetController extends Controller {
|
|||
});
|
||||
return new HttpSuccess(mapProfile);
|
||||
}
|
||||
|
||||
/**
|
||||
* รายชื่อขรก. ตามสิทธิ์ admin
|
||||
*
|
||||
* @summary รายชื่อขรก. ตามสิทธิ์ admin
|
||||
*
|
||||
*/
|
||||
@Post("officer-by-admin-rolev2")
|
||||
async GetOfficersByAdminRoleV2(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body()
|
||||
body: {
|
||||
node: number;
|
||||
nodeId: string;
|
||||
role: string;
|
||||
isRetirement?: boolean;
|
||||
reqNode?: number;
|
||||
reqNodeId?: string;
|
||||
date?: Date;
|
||||
},
|
||||
) {
|
||||
let typeCondition: any = {};
|
||||
if (body.role === "CHILD" || body.role === "PARENT" || body.role === "BROTHER") {
|
||||
if (body.role === "CHILD") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
rootDnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
child1DnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
child2DnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
child3DnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
child4DnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
} else if (body.role === "BROTHER") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
rootDnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
rootDnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
child1DnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
child2DnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
child3DnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
} else if (body.role === "PARENT") {
|
||||
typeCondition = {
|
||||
rootDnaId: body.nodeId,
|
||||
child1DnaId: Not(IsNull()),
|
||||
};
|
||||
}
|
||||
} else if (body.role === "OWNER" || body.role === "ROOT") {
|
||||
switch (body.reqNode) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
rootDnaId: body.reqNodeId,
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
child1DnaId: body.reqNodeId,
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
child2DnaId: body.reqNodeId,
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
child3DnaId: body.reqNodeId,
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
child4DnaId: body.reqNodeId,
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
} else if (body.role === "NORMAL") {
|
||||
switch (body.node) {
|
||||
case 0:
|
||||
typeCondition = {
|
||||
rootDnaId: body.nodeId,
|
||||
child1DnaId: IsNull(),
|
||||
};
|
||||
break;
|
||||
case 1:
|
||||
typeCondition = {
|
||||
child1DnaId: body.nodeId,
|
||||
child2DnaId: IsNull(),
|
||||
};
|
||||
break;
|
||||
case 2:
|
||||
typeCondition = {
|
||||
child2DnaId: body.nodeId,
|
||||
child3DnaId: IsNull(),
|
||||
};
|
||||
break;
|
||||
case 3:
|
||||
typeCondition = {
|
||||
child3DnaId: body.nodeId,
|
||||
child4DnaId: IsNull(),
|
||||
};
|
||||
break;
|
||||
case 4:
|
||||
typeCondition = {
|
||||
child4DnaId: body.nodeId,
|
||||
};
|
||||
break;
|
||||
default:
|
||||
typeCondition = {};
|
||||
break;
|
||||
}
|
||||
}
|
||||
const date = body.date ? new Date(body.date) : new Date();
|
||||
// set เวลาเป็น 23:59:59 ของวันนั้น
|
||||
date.setHours(23, 59, 59, 999);
|
||||
|
||||
let profile = await this.posMasterHistoryRepository.find({
|
||||
where: {
|
||||
...typeCondition,
|
||||
createdAt: LessThanOrEqual(date),
|
||||
// firstName: Not("") && Not(IsNull()),
|
||||
// lastName: Not("") && Not(IsNull()),
|
||||
},
|
||||
order: {
|
||||
firstName: "ASC",
|
||||
lastName: "ASC",
|
||||
createdAt: "DESC", // ให้ createdAt ล่าสุดอยู่ข้างบน
|
||||
},
|
||||
});
|
||||
|
||||
// group by ancestorDNA แล้วเลือก create_at ล่าสุด
|
||||
const grouped = new Map<string, PosMasterHistory>();
|
||||
for (const item of profile) {
|
||||
const key = `${item.ancestorDNA}`;
|
||||
if (!grouped.has(key)) {
|
||||
grouped.set(key, item);
|
||||
} else {
|
||||
// ถ้าเจอซ้ำ ให้เลือก createdAt ล่าสุด
|
||||
const exist = grouped.get(key);
|
||||
if (exist && item.createdAt > exist.createdAt) {
|
||||
grouped.set(key, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const profile_ = await Promise.all(
|
||||
Array.from(grouped.values())
|
||||
.filter((x) => x.profileId != null)
|
||||
.map(async (item: PosMasterHistory) => {
|
||||
let profile = await this.profileRepo.findOne({
|
||||
where: { id: item.profileId },
|
||||
});
|
||||
|
||||
return {
|
||||
id: item.profileId,
|
||||
prefix: item.prefix,
|
||||
firstName: item.firstName,
|
||||
lastName: item.lastName,
|
||||
citizenId: profile?.citizenId ?? null,
|
||||
dateStart: profile?.dateStart ?? null,
|
||||
dateAppoint: profile?.dateAppoint ?? null,
|
||||
keycloak: profile?.keycloak ?? null,
|
||||
posNo: item.shortName,
|
||||
position: item.position,
|
||||
positionLevel: item.posLevel,
|
||||
positionType: item.posType,
|
||||
// oc: Oc,
|
||||
orgRootId: item.rootDnaId,
|
||||
orgChild1Id: item.child1DnaId,
|
||||
orgChild2Id: item.child2DnaId,
|
||||
orgChild3Id: item.child3DnaId,
|
||||
orgChild4Id: item.child4DnaId,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess(profile_);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1663,10 +1663,19 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
dutyTimeEffectiveDate: profile.dutyTimeEffectiveDate,
|
||||
posLevel: profile.posLevel?.posLevelName ?? "",
|
||||
posType: profile.posType?.posTypeName ?? "",
|
||||
profileSalary: profile.profileSalary,
|
||||
profileInsignia: profile.profileInsignias.map((x) => {
|
||||
return { ...x, insignia: x.insignia.name };
|
||||
}),
|
||||
// profileSalary: profile.profileSalary,
|
||||
profileSalary: profile.profileSalary?.map((x) => ({
|
||||
...x,
|
||||
date: x.commandDateAffect ?? new Date()
|
||||
})) ?? [],
|
||||
// profileInsignia: profile.profileInsignias.map((x) => {
|
||||
// return { ...x, insignia: x.insignia.name };
|
||||
// }),
|
||||
profileInsignia: profile.profileInsignias?.map((x) => ({
|
||||
...x,
|
||||
insigniaId: x.insignia?.id ?? null,
|
||||
insignia: x.insignia?.name ?? null,
|
||||
})) ?? [],
|
||||
amount: profile.amount,
|
||||
positionSalaryAmount: profile.positionSalaryAmount,
|
||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||
|
|
@ -1875,7 +1884,12 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
posLevel: profile.posLevel ? profile.posLevel : null,
|
||||
posType: profile.posType ? profile.posType : null,
|
||||
profileSalary: profile.profileSalary,
|
||||
profileInsignia: profile.profileInsignias,
|
||||
// profileInsignia: profile.profileInsignias,
|
||||
profileInsignia: profile.profileInsignias?.map((x) => ({
|
||||
...x,
|
||||
insigniaId: x.insignia?.id ?? null,
|
||||
insignia: x.insignia?.name ?? null,
|
||||
})) ?? [],
|
||||
}));
|
||||
|
||||
return new HttpSuccess(mapProfile);
|
||||
|
|
@ -2049,12 +2063,21 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
? ""
|
||||
: profile.posType?.posTypeShortName + " ") + (profile.posLevel?.posLevelName ?? ""),
|
||||
posType: profile.posType?.posTypeName ?? "",
|
||||
profileSalary: profile.profileSalary.map((x) => {
|
||||
return { ...x, date: x.commandDateAffect ?? new Date() };
|
||||
}),
|
||||
profileInsignia: profile.profileInsignias.map((x) => {
|
||||
return { ...x, insignia: x.insignia.name };
|
||||
}),
|
||||
// profileSalary: profile.profileSalary.map((x) => {
|
||||
// return { ...x, date: x.commandDateAffect ?? new Date() };
|
||||
// }),
|
||||
profileSalary: profile.profileSalary?.map((x) => ({
|
||||
...x,
|
||||
date: x.commandDateAffect ?? new Date()
|
||||
})) ?? [],
|
||||
// profileInsignia: profile.profileInsignias.map((x) => {
|
||||
// return { ...x, insignia: x.insignia.name };
|
||||
// }),
|
||||
profileInsignia: profile.profileInsignias?.map((x) => ({
|
||||
...x,
|
||||
insigniaId: x.insignia?.id ?? null,
|
||||
insignia: x.insignia?.name ?? null,
|
||||
})) ?? [],
|
||||
amount: profile.amount,
|
||||
positionSalaryAmount: profile.positionSalaryAmount,
|
||||
mouthSalaryAmount: profile.mouthSalaryAmount,
|
||||
|
|
|
|||
|
|
@ -735,7 +735,7 @@ export class PermissionController extends Controller {
|
|||
} else if (privilege == "PARENT") {
|
||||
data = {
|
||||
root: [x.orgRootId],
|
||||
child1: null,
|
||||
child1: [null],
|
||||
child2: null,
|
||||
child3: null,
|
||||
child4: null,
|
||||
|
|
@ -748,6 +748,14 @@ export class PermissionController extends Controller {
|
|||
child3: node >= 3 ? [x.orgChild3Id] : null,
|
||||
child4: node >= 4 ? [x.orgChild4Id] : null,
|
||||
};
|
||||
} else if (privilege == "BROTHER") {
|
||||
data = {
|
||||
// root: node >= 0 ? null : null,
|
||||
root: node >= 0 ? [x.orgRootId] : null,
|
||||
child1: node >= 2 ? [x.orgChild1Id] : null,
|
||||
child2: node >= 3 ? [x.orgChild2Id] : null,
|
||||
child3: node >= 4 ? [x.orgChild3Id] : null,
|
||||
};
|
||||
} else if (privilege == "NORMAL") {
|
||||
data = {
|
||||
root: [x.orgRootId],
|
||||
|
|
|
|||
|
|
@ -963,40 +963,40 @@ export class PositionController extends Controller {
|
|||
}
|
||||
let orgRoot: any = null;
|
||||
let SName: any = null;
|
||||
let revisionId:any = null;
|
||||
let revisionId: any = null;
|
||||
if (requestBody.orgRootId != null)
|
||||
orgRoot = await this.orgRootRepository.findOne({
|
||||
where: { id: requestBody.orgRootId },
|
||||
});
|
||||
revisionId = orgRoot?.orgRevisionId;
|
||||
revisionId = orgRoot?.orgRevisionId;
|
||||
if (!orgRoot) {
|
||||
let orgChild1: any = null;
|
||||
if (requestBody.orgChild1Id != null)
|
||||
orgChild1 = await this.child1Repository.findOne({
|
||||
where: { id: requestBody.orgChild1Id },
|
||||
});
|
||||
revisionId = orgChild1?.orgRevisionId;
|
||||
revisionId = orgChild1?.orgRevisionId;
|
||||
if (!orgChild1) {
|
||||
let orgChild2: any = null;
|
||||
if (requestBody.orgChild2Id != null)
|
||||
orgChild2 = await this.child2Repository.findOne({
|
||||
where: { id: requestBody.orgChild2Id },
|
||||
});
|
||||
revisionId = orgChild2?.orgRevisionId;
|
||||
revisionId = orgChild2?.orgRevisionId;
|
||||
if (!orgChild2) {
|
||||
let orgChild3: any = null;
|
||||
if (requestBody.orgChild3Id != null)
|
||||
orgChild3 = await this.child3Repository.findOne({
|
||||
where: { id: requestBody.orgChild3Id },
|
||||
});
|
||||
revisionId = orgChild3?.orgRevisionId;
|
||||
revisionId = orgChild3?.orgRevisionId;
|
||||
if (!orgChild3) {
|
||||
let orgChild4: any = null;
|
||||
if (requestBody.orgChild4Id != null)
|
||||
orgChild4 = await this.child4Repository.findOne({
|
||||
where: { id: requestBody.orgChild4Id },
|
||||
});
|
||||
revisionId = orgChild4?.orgRevisionId;
|
||||
revisionId = orgChild4?.orgRevisionId;
|
||||
if (!orgChild4) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง");
|
||||
} else {
|
||||
|
|
@ -1169,9 +1169,9 @@ export class PositionController extends Controller {
|
|||
);
|
||||
}
|
||||
const before = null;
|
||||
let chkRevision:any = null;
|
||||
if(revisionId){
|
||||
chkRevision = await this.orgRevisionRepository.findOne({
|
||||
let chkRevision: any = null;
|
||||
if (revisionId) {
|
||||
chkRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: revisionId },
|
||||
});
|
||||
}
|
||||
|
|
@ -2240,7 +2240,129 @@ export class PositionController extends Controller {
|
|||
},
|
||||
];
|
||||
|
||||
let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||
//Old
|
||||
// let [posMaster, total] = await AppDataSource.getRepository(PosMaster)
|
||||
// .createQueryBuilder("posMaster")
|
||||
// .leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||
// .leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||
// .leftJoinAndSelect("posMaster.orgChild2", "orgChild2")
|
||||
// .leftJoinAndSelect("posMaster.orgChild3", "orgChild3")
|
||||
// .leftJoinAndSelect("posMaster.orgChild4", "orgChild4")
|
||||
// .leftJoinAndSelect("posMaster.current_holder", "current_holder")
|
||||
// .leftJoinAndSelect("posMaster.next_holder", "next_holder")
|
||||
// .leftJoinAndSelect("posMaster.orgRevision", "orgRevision")
|
||||
// .where(conditions)
|
||||
// .andWhere(
|
||||
// _data.root != undefined && _data.root != null
|
||||
// ? _data.root[0] != null
|
||||
// ? `posMaster.orgRootId IN (:...root)`
|
||||
// : `posMaster.orgRootId is null`
|
||||
// : "1=1",
|
||||
// {
|
||||
// root: _data.root,
|
||||
// },
|
||||
// )
|
||||
// .andWhere(
|
||||
// _data.child1 != undefined && _data.child1 != null
|
||||
// ? _data.child1[0] != null
|
||||
// ? `posMaster.orgChild1Id IN (:...child1)`
|
||||
// : `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
// : "1=1",
|
||||
// {
|
||||
// child1: _data.child1,
|
||||
// },
|
||||
// )
|
||||
// .andWhere(
|
||||
// _data.child2 != undefined && _data.child2 != null
|
||||
// ? _data.child2[0] != null
|
||||
// ? `posMaster.orgChild2Id IN (:...child2)`
|
||||
// : `posMaster.orgChild2Id is null`
|
||||
// : "1=1",
|
||||
// {
|
||||
// child2: _data.child2,
|
||||
// },
|
||||
// )
|
||||
// .andWhere(
|
||||
// _data.child3 != undefined && _data.child3 != null
|
||||
// ? _data.child3[0] != null
|
||||
// ? `posMaster.orgChild3Id IN (:...child3)`
|
||||
// : `posMaster.orgChild3Id is null`
|
||||
// : "1=1",
|
||||
// {
|
||||
// child3: _data.child3,
|
||||
// },
|
||||
// )
|
||||
// .andWhere(
|
||||
// _data.child4 != undefined && _data.child4 != null
|
||||
// ? _data.child4[0] != null
|
||||
// ? `posMaster.orgChild4Id IN (:...child4)`
|
||||
// : `posMaster.orgChild4Id is null`
|
||||
// : "1=1",
|
||||
// {
|
||||
// child4: _data.child4,
|
||||
// },
|
||||
// )
|
||||
// .andWhere(
|
||||
// new Brackets((qb) => {
|
||||
// qb.orWhere(
|
||||
// new Brackets((qb) => {
|
||||
// qb.andWhere(
|
||||
// body.keyword != null && body.keyword != ""
|
||||
// ? body.isAll == false
|
||||
// ? searchShortName
|
||||
// : `CASE WHEN posMaster.orgChild1 is null THEN ${searchShortName0} WHEN posMaster.orgChild2 is null THEN ${searchShortName1} WHEN posMaster.orgChild3 is null THEN ${searchShortName2} WHEN posMaster.orgChild4 is null THEN ${searchShortName3} ELSE ${searchShortName4} END LIKE '%${body.keyword}%'`
|
||||
// : "1=1",
|
||||
// )
|
||||
// .andWhere(checkChildConditions)
|
||||
// .andWhere(typeCondition)
|
||||
// .andWhere(revisionCondition);
|
||||
// }),
|
||||
// )
|
||||
// .orWhere(
|
||||
// new Brackets((qb) => {
|
||||
// qb.andWhere(
|
||||
// body.keyword != null && body.keyword != ""
|
||||
// ? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||
// : "1=1",
|
||||
// {
|
||||
// keyword: `%${body.keyword}%`,
|
||||
// },
|
||||
// )
|
||||
// .andWhere(checkChildConditions)
|
||||
// .andWhere(typeCondition)
|
||||
// .andWhere(revisionCondition);
|
||||
// }),
|
||||
// )
|
||||
// .orWhere(
|
||||
// new Brackets((qb) => {
|
||||
// qb.andWhere(
|
||||
// body.keyword != null && body.keyword != ""
|
||||
// ? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
|
||||
// : "1=1",
|
||||
// {
|
||||
// keyword: `%${body.keyword}%`,
|
||||
// },
|
||||
// )
|
||||
// .andWhere(checkChildConditions)
|
||||
// .andWhere(typeCondition)
|
||||
// .andWhere(revisionCondition);
|
||||
// }),
|
||||
// );
|
||||
// }),
|
||||
// )
|
||||
// .orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
// .addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||
// .addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||
// .addOrderBy("orgChild3.orgChild3Order", "ASC")
|
||||
// .addOrderBy("orgChild4.orgChild4Order", "ASC")
|
||||
// .addOrderBy("posMaster.posMasterOrder", "ASC")
|
||||
// .addOrderBy("posMaster.posMasterCreatedAt", "ASC")
|
||||
// .skip((body.page - 1) * body.pageSize)
|
||||
// .take(body.pageSize)
|
||||
// .getManyAndCount();
|
||||
|
||||
//New
|
||||
let query = AppDataSource.getRepository(PosMaster)
|
||||
.createQueryBuilder("posMaster")
|
||||
.leftJoinAndSelect("posMaster.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("posMaster.orgChild1", "orgChild1")
|
||||
|
|
@ -2254,22 +2376,18 @@ export class PositionController extends Controller {
|
|||
.andWhere(
|
||||
_data.root != undefined && _data.root != null
|
||||
? _data.root[0] != null
|
||||
? `posMaster.orgRootId IN (:...root)`
|
||||
: `posMaster.orgRootId is null`
|
||||
? "posMaster.orgRootId IN (:...root)"
|
||||
: "posMaster.orgRootId is null"
|
||||
: "1=1",
|
||||
{
|
||||
root: _data.root,
|
||||
},
|
||||
{ root: _data.root }
|
||||
)
|
||||
.andWhere(
|
||||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `posMaster.orgChild1Id IN (:...child1)`
|
||||
: `posMaster.orgChild1Id is null`
|
||||
? "posMaster.orgChild1Id IN (:...child1)"
|
||||
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
},
|
||||
{ child1: _data.child1 }
|
||||
)
|
||||
.andWhere(
|
||||
_data.child2 != undefined && _data.child2 != null
|
||||
|
|
@ -2301,7 +2419,12 @@ export class PositionController extends Controller {
|
|||
child4: _data.child4,
|
||||
},
|
||||
)
|
||||
.orWhere(
|
||||
// .andWhere(checkChildConditions)
|
||||
// .andWhere(typeCondition)
|
||||
// .andWhere(revisionCondition);
|
||||
|
||||
if (body.keyword != null && body.keyword != "") {
|
||||
query.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
|
|
@ -2315,36 +2438,39 @@ export class PositionController extends Controller {
|
|||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CONCAT(current_holder.prefix, current_holder.firstName," ",current_holder.lastName) like '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
)
|
||||
.orWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.andWhere(
|
||||
body.keyword != null && body.keyword != ""
|
||||
? `CASE WHEN orgRevision.orgRevisionIsDraft = true THEN CONCAT(next_holder.prefix, next_holder.firstName,' ', next_holder.lastName) ELSE CONCAT(current_holder.prefix, current_holder.firstName,' ' , current_holder.lastName) END LIKE '%${body.keyword}%'`
|
||||
: "1=1",
|
||||
{
|
||||
keyword: `%${body.keyword}%`,
|
||||
},
|
||||
)
|
||||
.andWhere(checkChildConditions)
|
||||
.andWhere(typeCondition)
|
||||
.andWhere(revisionCondition);
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
let [posMaster, total] = await query
|
||||
.orderBy("orgRoot.orgRootOrder", "ASC")
|
||||
.addOrderBy("orgChild1.orgChild1Order", "ASC")
|
||||
.addOrderBy("orgChild2.orgChild2Order", "ASC")
|
||||
|
|
@ -2520,24 +2646,26 @@ export class PositionController extends Controller {
|
|||
};
|
||||
}),
|
||||
);
|
||||
|
||||
if(_data.privilege === 'NORMAL'|| _data.privilege === 'PARENT'|| _data.privilege === 'CHILD'){ //PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||
const nextChildMap:any = { //เอาไวเช็ค CHILD ถัดไป
|
||||
|
||||
if (
|
||||
_data.privilege === "NORMAL" ||
|
||||
_data.privilege === "CHILD" ||
|
||||
_data.privilege === "BROTHER"
|
||||
) {
|
||||
//PARENT จะไม่มีทางเห็น ROOT , CHILD ยึดจาก CHILD ที่อยู่ลงไปข้างล่างและจะไม่เห็น CHILD ที่อยู่เหนือกว่า
|
||||
const nextChildMap: any = {
|
||||
//เอาไวเช็ค CHILD ถัดไป
|
||||
0: _data.child1,
|
||||
1: _data.child2,
|
||||
2: _data.child3,
|
||||
3: _data.child4,
|
||||
};
|
||||
const childValue = nextChildMap[body.type];
|
||||
if(_data.privilege === 'NORMAL'){
|
||||
if (Array.isArray(childValue) && childValue.some(item => item != null)) {
|
||||
if (_data.privilege === "NORMAL") {
|
||||
if (Array.isArray(childValue) && childValue.some((item) => item != null)) {
|
||||
return new HttpSuccess({ data: [], total: 0 });
|
||||
}
|
||||
}else if(_data.privilege === 'PARENT'){
|
||||
if (body.type == 0){
|
||||
return new HttpSuccess({ data: [], total: 0 });
|
||||
}
|
||||
} else if (_data.privilege === 'CHILD') {
|
||||
} else if (_data.privilege === "CHILD" || _data.privilege === "BROTHER") {
|
||||
const higherChildChecks = [
|
||||
{ type: [0], child: _data.child1, next: _data.child2 },
|
||||
{ type: [0, 1], child: _data.child2, next: _data.child3 },
|
||||
|
|
@ -2818,50 +2946,50 @@ export class PositionController extends Controller {
|
|||
const type0LastPosMasterNo =
|
||||
requestBody.type == 0
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgRootId: requestBody.id,
|
||||
orgChild1Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type1LastPosMasterNo =
|
||||
requestBody.type == 1
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild1Id: requestBody.id,
|
||||
orgChild2Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type2LastPosMasterNo =
|
||||
requestBody.type == 2
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild2Id: requestBody.id,
|
||||
orgChild3Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type3LastPosMasterNo =
|
||||
requestBody.type == 3
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild3Id: requestBody.id,
|
||||
orgChild4Id: IsNull(),
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const type4LastPosMasterNo =
|
||||
requestBody.type == 4
|
||||
? await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
where: {
|
||||
orgChild4Id: requestBody.id,
|
||||
},
|
||||
})
|
||||
: [];
|
||||
|
||||
const allLastPosMasterNo = [
|
||||
|
|
@ -3751,7 +3879,6 @@ export class PositionController extends Controller {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
// //เช็คถ้า revision ปัจจุบันให้ปั๊มที่ profile
|
||||
// const chkRevision = await this.orgRevisionRepository.findOne({
|
||||
// where: { id: dataMaster.orgRevisionId },
|
||||
|
|
@ -5290,7 +5417,7 @@ export class PositionController extends Controller {
|
|||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `posMaster.orgChild1Id IN (:...child1)`
|
||||
: `posMaster.orgChild1Id is null`
|
||||
: `posMaster.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
|
|
|
|||
|
|
@ -10800,67 +10800,21 @@ export class ProfileController extends Controller {
|
|||
*/
|
||||
@Post("search-personal-no-keycloak")
|
||||
async getProfileBySearchKeywordNoKeyCloak(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Body()
|
||||
body: {
|
||||
fieldName: string;
|
||||
keyword?: string;
|
||||
system?: string;
|
||||
},
|
||||
) {
|
||||
let findProfile: any;
|
||||
let total: any;
|
||||
const skip = (page - 1) * pageSize;
|
||||
const take = pageSize;
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
citizenId: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
case "firstname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
firstName: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
case "lastname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
lastName: Like(`%${body.keyword}%`),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
// comment ออกก่อนเพราะยังไม่ได้ใช้
|
||||
// // ค้นหารายชื่อถ้าไม่ส่ง system มาให้ default ตามทะเบียนประวัติ
|
||||
// let _system: string = "SYS_REGISTRY_OFFICER";
|
||||
// if (body.system) _system = body.system;
|
||||
// let _data = await new permission().PermissionOrgList(request, _system);
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
|
|
@ -10868,45 +10822,127 @@ export class ProfileController extends Controller {
|
|||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
|
||||
let queryLike = "1=1";
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
queryLike = "profile.citizenId LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "fullname":
|
||||
case "fullName":
|
||||
queryLike =
|
||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "firstname":
|
||||
case "firstName":
|
||||
queryLike = "profile.firstName LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "lastname":
|
||||
case "lastName":
|
||||
queryLike = "profile.lastName LIKE :keyword";
|
||||
break;
|
||||
|
||||
default:
|
||||
queryLike = "1=1";
|
||||
break;
|
||||
}
|
||||
|
||||
let query = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.where("profile.keycloak IS NULL")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||
}),
|
||||
);
|
||||
|
||||
const [findProfile, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapDataProfile = await Promise.all(
|
||||
findProfile.map(async (item: Profile) => {
|
||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||
const shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
let shortName = null;
|
||||
let root = null;
|
||||
let posMasterNo = null;
|
||||
if (item.isLeave == false) {
|
||||
shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
const root =
|
||||
item.current_holders.length == 0 ||
|
||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
const posMasterNo = item.current_holders?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.posMasterNo;
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
root =
|
||||
item.current_holders.length == 0 ||
|
||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
root = root == null ? null : root.orgRootName;
|
||||
posMasterNo = item.current_holders?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.posMasterNo;
|
||||
}
|
||||
else {
|
||||
const profileSalary = await this.salaryRepo
|
||||
.createQueryBuilder("s")
|
||||
.where("s.profileId = :profileId", { profileId: item.id })
|
||||
.andWhere("s.commandCode IN (:...codes)", {
|
||||
codes: ["0","9","1","2","3","4","8","10","11","12","13","14","15","16"],
|
||||
})
|
||||
.orderBy("s.order", "DESC")
|
||||
.addOrderBy("s.createdAt", "DESC")
|
||||
.take(2)
|
||||
.getMany();
|
||||
if (profileSalary.length > 0) {
|
||||
shortName = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
||||
posMasterNo = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? profileSalary[1]?.posNo
|
||||
: profileSalary[0]?.posNo
|
||||
: profileSalary[0]?.posNo;
|
||||
root = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? profileSalary[1]?.orgRoot
|
||||
: profileSalary[0]?.orgRoot
|
||||
: profileSalary[0]?.orgRoot;
|
||||
}
|
||||
}
|
||||
|
||||
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
||||
where: { profileId: item.id },
|
||||
|
|
@ -10930,7 +10966,7 @@ export class ProfileController extends Controller {
|
|||
positionType: item.posTypeId,
|
||||
positionTypeName: item.posType?.posTypeName,
|
||||
posNo: shortName,
|
||||
organization: root == null ? null : root.orgRootName,
|
||||
organization: root,
|
||||
salary: item.amount,
|
||||
posMasterNo: posMasterNo ?? null,
|
||||
posTypeId: item.posTypeId,
|
||||
|
|
|
|||
|
|
@ -5726,111 +5726,139 @@ export class ProfileEmployeeController extends Controller {
|
|||
body: {
|
||||
fieldName: string;
|
||||
keyword?: string;
|
||||
system?: string;
|
||||
},
|
||||
) {
|
||||
let findProfile: any;
|
||||
let total: any;
|
||||
const skip = (page - 1) * pageSize;
|
||||
const take = pageSize;
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
citizenId: Like(`%${body.keyword}%`),
|
||||
employeeClass: "PERM",
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
case "firstname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
firstName: Like(`%${body.keyword}%`),
|
||||
employeeClass: "PERM",
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
case "lastname":
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
lastName: Like(`%${body.keyword}%`),
|
||||
employeeClass: "PERM",
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
|
||||
default:
|
||||
[findProfile, total] = await this.profileRepo.findAndCount({
|
||||
where: {
|
||||
keycloak: IsNull(),
|
||||
employeeClass: "PERM",
|
||||
},
|
||||
relations: ["posType", "posLevel", "current_holders"],
|
||||
skip,
|
||||
take,
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
const findRevision = await this.orgRevisionRepo.findOne({
|
||||
where: { orgRevisionIsCurrent: true },
|
||||
});
|
||||
if (!findRevision) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "not found. OrgRevision");
|
||||
}
|
||||
|
||||
let queryLike = "1=1";
|
||||
switch (body.fieldName) {
|
||||
case "citizenId":
|
||||
queryLike = "profile.citizenId LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "fullname":
|
||||
case "fullName":
|
||||
queryLike =
|
||||
"CONCAT(profile.prefix, profile.firstName, ' ', profile.lastName) LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "firstname":
|
||||
case "firstName":
|
||||
queryLike = "profile.firstName LIKE :keyword";
|
||||
break;
|
||||
|
||||
case "lastname":
|
||||
case "lastName":
|
||||
queryLike = "profile.lastName LIKE :keyword";
|
||||
break;
|
||||
|
||||
default:
|
||||
queryLike = "1=1";
|
||||
break;
|
||||
}
|
||||
|
||||
let query = await this.profileRepo
|
||||
.createQueryBuilder("profile")
|
||||
.leftJoinAndSelect("profile.posType", "posType")
|
||||
.leftJoinAndSelect("profile.posLevel", "posLevel")
|
||||
.leftJoinAndSelect("profile.current_holders", "current_holders")
|
||||
.leftJoinAndSelect("current_holders.orgRoot", "orgRoot")
|
||||
.leftJoinAndSelect("current_holders.orgChild1", "orgChild1")
|
||||
.leftJoinAndSelect("current_holders.orgChild2", "orgChild2")
|
||||
.leftJoinAndSelect("current_holders.orgChild3", "orgChild3")
|
||||
.leftJoinAndSelect("current_holders.orgChild4", "orgChild4")
|
||||
.where("profile.keycloak IS NULL")
|
||||
.andWhere(
|
||||
new Brackets((qb) => {
|
||||
qb.orWhere(body.keyword ? queryLike : "1=1", { keyword: `%${body.keyword}%` });
|
||||
}),
|
||||
);
|
||||
|
||||
const [findProfile, total] = await query
|
||||
.skip((page - 1) * pageSize)
|
||||
.take(pageSize)
|
||||
.getManyAndCount();
|
||||
|
||||
const mapDataProfile = await Promise.all(
|
||||
findProfile.map(async (item: ProfileEmployee) => {
|
||||
const fullName = `${item.prefix} ${item.firstName} ${item.lastName}`;
|
||||
const shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
let shortName = null;
|
||||
let root = null;
|
||||
let posMasterNo = null;
|
||||
if (item.isLeave == false) {
|
||||
shortName =
|
||||
item.current_holders.length == 0
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild4.orgChild4ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3 !=
|
||||
null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild3.orgChild3ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
?.orgChild2 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild2.orgChild2ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
?.orgChild1 != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgChild1.orgChild1ShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id) !=
|
||||
null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)
|
||||
?.orgRoot != null
|
||||
? `${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot.orgRootShortName} ${item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.posMasterNo}`
|
||||
: null;
|
||||
|
||||
const root =
|
||||
item.current_holders.length == 0 ||
|
||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
|
||||
const posMasterNo = item.current_holders?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.posMasterNo;
|
||||
root =
|
||||
item.current_holders.length == 0 ||
|
||||
(item.current_holders.find((x) => x.orgRevisionId == findRevision.id) != null &&
|
||||
item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot == null)
|
||||
? null
|
||||
: item.current_holders.find((x) => x.orgRevisionId == findRevision.id)?.orgRoot;
|
||||
root = root == null ? null : root.orgRootName;
|
||||
posMasterNo = item.current_holders?.find(
|
||||
(x) => x.orgRevisionId == findRevision.id,
|
||||
)?.posMasterNo;
|
||||
}
|
||||
else {
|
||||
const profileSalary = await this.salaryRepo
|
||||
.createQueryBuilder("s")
|
||||
.where("s.profileEmployeeId = :profileId", { profileId: item.id })
|
||||
.andWhere("s.commandCode IN (:...codes)", {
|
||||
codes: ["0","9","1","2","3","4","8","10","11","12","13","14","15","16"],
|
||||
})
|
||||
.orderBy("s.order", "DESC")
|
||||
.addOrderBy("s.createdAt", "DESC")
|
||||
.take(2)
|
||||
.getMany();
|
||||
if (profileSalary.length > 0) {
|
||||
shortName = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? `${profileSalary[1]?.posNoAbb} ${profileSalary[1]?.posNo}`
|
||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`
|
||||
: `${profileSalary[0]?.posNoAbb} ${profileSalary[0]?.posNo}`;
|
||||
posMasterNo = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? profileSalary[1]?.posNo
|
||||
: profileSalary[0]?.posNo
|
||||
: profileSalary[0]?.posNo;
|
||||
root = item.isRetirement
|
||||
? profileSalary.length > 1
|
||||
? profileSalary[1]?.orgRoot
|
||||
: profileSalary[0]?.orgRoot
|
||||
: profileSalary[0]?.orgRoot;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const latestProfileEducation = await this.profileEducationRepo.findOne({
|
||||
where: { profileEmployeeId: item.id },
|
||||
|
|
@ -5854,7 +5882,7 @@ export class ProfileEmployeeController extends Controller {
|
|||
positionType: item.posTypeId,
|
||||
positionTypeName: item.posType?.posTypeName,
|
||||
posNo: shortName,
|
||||
organization: root == null ? null : root.orgRootName,
|
||||
organization: root,
|
||||
salary: item.amount,
|
||||
posMasterNo: posMasterNo ?? null,
|
||||
posTypeId: item.posTypeId,
|
||||
|
|
|
|||
|
|
@ -1028,12 +1028,15 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
if (!result) {
|
||||
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
}
|
||||
|
||||
try{
|
||||
|
||||
try {
|
||||
await this.informationHistoryRepository.delete({ profileEmployeeId: id });
|
||||
await this.profileRepo.remove(result);
|
||||
} catch {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น");
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถลบข้อมูลได้ เนื่องจากข้อมูลนี้ถูกใช้งานในระบบอื่น",
|
||||
);
|
||||
}
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -1106,7 +1109,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
_dataOrg.child1 != undefined && _dataOrg.child1 != null
|
||||
? _dataOrg.child1[0] != null
|
||||
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||
: `current_holderTemps.orgChild1Id is null`
|
||||
: `current_holderTemps.orgChild1Id is ${_dataOrg.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _dataOrg.child1,
|
||||
|
|
@ -1561,7 +1564,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||
: `current_holderTemps.orgChild1Id is null`
|
||||
: `current_holderTemps.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{
|
||||
child1: _data.child1,
|
||||
|
|
@ -2270,7 +2273,7 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
_data.child1 != undefined && _data.child1 != null
|
||||
? _data.child1[0] != null
|
||||
? `current_holderTemps.orgChild1Id IN (:...child1)`
|
||||
: `current_holderTemps.orgChild1Id is null`
|
||||
: `current_holderTemps.orgChild1Id is ${_data.privilege == "PARENT" ? "not null" : "null"}`
|
||||
: "1=1",
|
||||
{ child1: _data.child1 },
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1030,7 +1030,7 @@ export class WorkflowController extends Controller {
|
|||
: data.map((x: any) => ({
|
||||
...x,
|
||||
posExecutiveNameOrg:
|
||||
x.posExecutiveName +
|
||||
x.posExecutiveName ?? "" +
|
||||
(x.orgChild4 ?? x.orgChild3 ?? x.orgChild2 ?? x.orgChild1 ?? x.orgRoot ?? ""),
|
||||
}));
|
||||
|
||||
|
|
@ -1227,7 +1227,7 @@ export class WorkflowController extends Controller {
|
|||
const processedData = data.map((x: any) => ({
|
||||
...x,
|
||||
posExecutiveNameOrg:
|
||||
x.posExecutiveName +
|
||||
x.posExecutiveName ?? "" +
|
||||
(x.orgChild4 ?? x.orgChild3 ?? x.orgChild2 ?? x.orgChild1 ?? x.orgRoot ?? ""),
|
||||
}));
|
||||
|
||||
|
|
|
|||
89414
src/data/amphures.json
Normal file
89414
src/data/amphures.json
Normal file
File diff suppressed because it is too large
Load diff
695
src/data/provinces.json
Normal file
695
src/data/provinces.json
Normal file
|
|
@ -0,0 +1,695 @@
|
|||
[
|
||||
{
|
||||
"id": 1,
|
||||
"name_th": "กรุงเทพมหานคร",
|
||||
"name_en": "Bangkok",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"name_th": "สมุทรปราการ",
|
||||
"name_en": "Samut Prakan",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"name_th": "นนทบุรี",
|
||||
"name_en": "Nonthaburi",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 4,
|
||||
"name_th": "ปทุมธานี",
|
||||
"name_en": "Pathum Thani",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 5,
|
||||
"name_th": "พระนครศรีอยุธยา",
|
||||
"name_en": "Phra Nakhon Si Ayutthaya",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 6,
|
||||
"name_th": "อ่างทอง",
|
||||
"name_en": "Ang Thong",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 7,
|
||||
"name_th": "ลพบุรี",
|
||||
"name_en": "Lopburi",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 8,
|
||||
"name_th": "สิงห์บุรี",
|
||||
"name_en": "Sing Buri",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 9,
|
||||
"name_th": "ชัยนาท",
|
||||
"name_en": "Chai Nat",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 10,
|
||||
"name_th": "สระบุรี",
|
||||
"name_en": "Saraburi",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 11,
|
||||
"name_th": "ชลบุรี",
|
||||
"name_en": "Chon Buri",
|
||||
"geography_id": 5,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 12,
|
||||
"name_th": "ระยอง",
|
||||
"name_en": "Rayong",
|
||||
"geography_id": 5,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 13,
|
||||
"name_th": "จันทบุรี",
|
||||
"name_en": "Chanthaburi",
|
||||
"geography_id": 5,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 14,
|
||||
"name_th": "ตราด",
|
||||
"name_en": "Trat",
|
||||
"geography_id": 5,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 15,
|
||||
"name_th": "ฉะเชิงเทรา",
|
||||
"name_en": "Chachoengsao",
|
||||
"geography_id": 5,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 16,
|
||||
"name_th": "ปราจีนบุรี",
|
||||
"name_en": "Prachin Buri",
|
||||
"geography_id": 5,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 17,
|
||||
"name_th": "นครนายก",
|
||||
"name_en": "Nakhon Nayok",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 18,
|
||||
"name_th": "สระแก้ว",
|
||||
"name_en": "Sa Kaeo",
|
||||
"geography_id": 5,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 19,
|
||||
"name_th": "นครราชสีมา",
|
||||
"name_en": "Nakhon Ratchasima",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 20,
|
||||
"name_th": "บุรีรัมย์",
|
||||
"name_en": "Buri Ram",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 21,
|
||||
"name_th": "สุรินทร์",
|
||||
"name_en": "Surin",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 22,
|
||||
"name_th": "ศรีสะเกษ",
|
||||
"name_en": "Si Sa Ket",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 23,
|
||||
"name_th": "อุบลราชธานี",
|
||||
"name_en": "Ubon Ratchathani",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 24,
|
||||
"name_th": "ยโสธร",
|
||||
"name_en": "Yasothon",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 25,
|
||||
"name_th": "ชัยภูมิ",
|
||||
"name_en": "Chaiyaphum",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 26,
|
||||
"name_th": "อำนาจเจริญ",
|
||||
"name_en": "Amnat Charoen",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 27,
|
||||
"name_th": "หนองบัวลำภู",
|
||||
"name_en": "Nong Bua Lam Phu",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 28,
|
||||
"name_th": "ขอนแก่น",
|
||||
"name_en": "Khon Kaen",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 29,
|
||||
"name_th": "อุดรธานี",
|
||||
"name_en": "Udon Thani",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 30,
|
||||
"name_th": "เลย",
|
||||
"name_en": "Loei",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 31,
|
||||
"name_th": "หนองคาย",
|
||||
"name_en": "Nong Khai",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 32,
|
||||
"name_th": "มหาสารคาม",
|
||||
"name_en": "Maha Sarakham",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 33,
|
||||
"name_th": "ร้อยเอ็ด",
|
||||
"name_en": "Roi Et",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 34,
|
||||
"name_th": "กาฬสินธุ์",
|
||||
"name_en": "Kalasin",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 35,
|
||||
"name_th": "สกลนคร",
|
||||
"name_en": "Sakon Nakhon",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 36,
|
||||
"name_th": "นครพนม",
|
||||
"name_en": "Nakhon Phanom",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 37,
|
||||
"name_th": "มุกดาหาร",
|
||||
"name_en": "Mukdahan",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 38,
|
||||
"name_th": "เชียงใหม่",
|
||||
"name_en": "Chiang Mai",
|
||||
"geography_id": 1,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 39,
|
||||
"name_th": "ลำพูน",
|
||||
"name_en": "Lamphun",
|
||||
"geography_id": 1,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 40,
|
||||
"name_th": "ลำปาง",
|
||||
"name_en": "Lampang",
|
||||
"geography_id": 1,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 41,
|
||||
"name_th": "อุตรดิตถ์",
|
||||
"name_en": "Uttaradit",
|
||||
"geography_id": 1,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 42,
|
||||
"name_th": "แพร่",
|
||||
"name_en": "Phrae",
|
||||
"geography_id": 1,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 43,
|
||||
"name_th": "น่าน",
|
||||
"name_en": "Nan",
|
||||
"geography_id": 1,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 44,
|
||||
"name_th": "พะเยา",
|
||||
"name_en": "Phayao",
|
||||
"geography_id": 1,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 45,
|
||||
"name_th": "เชียงราย",
|
||||
"name_en": "Chiang Rai",
|
||||
"geography_id": 1,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 46,
|
||||
"name_th": "แม่ฮ่องสอน",
|
||||
"name_en": "Mae Hong Son",
|
||||
"geography_id": 1,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 47,
|
||||
"name_th": "นครสวรรค์",
|
||||
"name_en": "Nakhon Sawan",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 48,
|
||||
"name_th": "อุทัยธานี",
|
||||
"name_en": "Uthai Thani",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 49,
|
||||
"name_th": "กำแพงเพชร",
|
||||
"name_en": "Kamphaeng Phet",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 50,
|
||||
"name_th": "ตาก",
|
||||
"name_en": "Tak",
|
||||
"geography_id": 4,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 51,
|
||||
"name_th": "สุโขทัย",
|
||||
"name_en": "Sukhothai",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 52,
|
||||
"name_th": "พิษณุโลก",
|
||||
"name_en": "Phitsanulok",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 53,
|
||||
"name_th": "พิจิตร",
|
||||
"name_en": "Phichit",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 54,
|
||||
"name_th": "เพชรบูรณ์",
|
||||
"name_en": "Phetchabun",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 55,
|
||||
"name_th": "ราชบุรี",
|
||||
"name_en": "Ratchaburi",
|
||||
"geography_id": 4,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 56,
|
||||
"name_th": "กาญจนบุรี",
|
||||
"name_en": "Kanchanaburi",
|
||||
"geography_id": 4,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 57,
|
||||
"name_th": "สุพรรณบุรี",
|
||||
"name_en": "Suphan Buri",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 58,
|
||||
"name_th": "นครปฐม",
|
||||
"name_en": "Nakhon Pathom",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 59,
|
||||
"name_th": "สมุทรสาคร",
|
||||
"name_en": "Samut Sakhon",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 60,
|
||||
"name_th": "สมุทรสงคราม",
|
||||
"name_en": "Samut Songkhram",
|
||||
"geography_id": 2,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 61,
|
||||
"name_th": "เพชรบุรี",
|
||||
"name_en": "Phetchaburi",
|
||||
"geography_id": 4,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 62,
|
||||
"name_th": "ประจวบคีรีขันธ์",
|
||||
"name_en": "Prachuap Khiri Khan",
|
||||
"geography_id": 4,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 63,
|
||||
"name_th": "นครศรีธรรมราช",
|
||||
"name_en": "Nakhon Si Thammarat",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 64,
|
||||
"name_th": "กระบี่",
|
||||
"name_en": "Krabi",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 65,
|
||||
"name_th": "พังงา",
|
||||
"name_en": "Phangnga",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 66,
|
||||
"name_th": "ภูเก็ต",
|
||||
"name_en": "Phuket",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 67,
|
||||
"name_th": "สุราษฎร์ธานี",
|
||||
"name_en": "Surat Thani",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 68,
|
||||
"name_th": "ระนอง",
|
||||
"name_en": "Ranong",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 69,
|
||||
"name_th": "ชุมพร",
|
||||
"name_en": "Chumphon",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 70,
|
||||
"name_th": "สงขลา",
|
||||
"name_en": "Songkhla",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 71,
|
||||
"name_th": "สตูล",
|
||||
"name_en": "Satun",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 72,
|
||||
"name_th": "ตรัง",
|
||||
"name_en": "Trang",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 73,
|
||||
"name_th": "พัทลุง",
|
||||
"name_en": "Phatthalung",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 74,
|
||||
"name_th": "ปัตตานี",
|
||||
"name_en": "Pattani",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 75,
|
||||
"name_th": "ยะลา",
|
||||
"name_en": "Yala",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 76,
|
||||
"name_th": "นราธิวาส",
|
||||
"name_en": "Narathiwat",
|
||||
"geography_id": 6,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
},
|
||||
{
|
||||
"id": 77,
|
||||
"name_th": "บึงกาฬ",
|
||||
"name_en": "Bueng Kan",
|
||||
"geography_id": 3,
|
||||
"created_at": "2019-08-09T03:33:09.000+07:00",
|
||||
"updated_at": "2025-09-20T06:31:26.000+07:00",
|
||||
"deleted_at": null
|
||||
}
|
||||
]
|
||||
8372
src/data/tambons.json
Normal file
8372
src/data/tambons.json
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -19,6 +19,18 @@ export class District extends EntityBase {
|
|||
})
|
||||
provinceId: string;
|
||||
|
||||
// @Column({
|
||||
// comment: "mark",
|
||||
// default: null,
|
||||
// })
|
||||
// importUpdate: number;
|
||||
|
||||
// @Column({
|
||||
// comment: "refId",
|
||||
// default: null,
|
||||
// })
|
||||
// refId: number;
|
||||
|
||||
@ManyToOne(() => Province, (province) => province.districts)
|
||||
@JoinColumn({ name: "provinceId" })
|
||||
province: Province;
|
||||
|
|
|
|||
22
src/entities/DistrictMaster.ts
Normal file
22
src/entities/DistrictMaster.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity("district_master")
|
||||
export class DistrictMaster {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({ length: 255 })
|
||||
name_th: string;
|
||||
|
||||
@Column({ length: 255 })
|
||||
name_en: string;
|
||||
|
||||
@Column()
|
||||
province_id: number;
|
||||
|
||||
@Column({ nullable: true })
|
||||
created_at: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
updated_at: string;
|
||||
}
|
||||
|
|
@ -98,4 +98,52 @@ export class PosMasterHistory extends EntityBase {
|
|||
default: null,
|
||||
})
|
||||
ancestorDNA: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "คีย์นอก(FK)ของตาราง profile",
|
||||
default: null,
|
||||
})
|
||||
profileId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "dna ของตาราง orgRoot",
|
||||
default: null,
|
||||
})
|
||||
rootDnaId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "dna ของตาราง orgChild1",
|
||||
default: null,
|
||||
})
|
||||
child1DnaId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "dna ของตาราง orgChild2",
|
||||
default: null,
|
||||
})
|
||||
child2DnaId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "dna ของตาราง orgChild3",
|
||||
default: null,
|
||||
})
|
||||
child3DnaId: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
length: 40,
|
||||
comment: "dna ของตาราง orgChild4",
|
||||
default: null,
|
||||
})
|
||||
child4DnaId: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,6 +12,18 @@ export class Province extends EntityBase {
|
|||
})
|
||||
name: string;
|
||||
|
||||
// @Column({
|
||||
// comment: "mark",
|
||||
// default: null,
|
||||
// })
|
||||
// importUpdate: number;
|
||||
|
||||
// @Column({
|
||||
// comment: "refId",
|
||||
// default: null,
|
||||
// })
|
||||
// refId: number;
|
||||
|
||||
@OneToMany(() => District, (district) => district.province)
|
||||
districts: District[];
|
||||
|
||||
|
|
|
|||
22
src/entities/ProvinceMaster.ts
Normal file
22
src/entities/ProvinceMaster.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity("province_master")
|
||||
export class ProvinceMaster {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column({ length: 255 })
|
||||
name_th: string;
|
||||
|
||||
@Column({ length: 255 })
|
||||
name_en: string;
|
||||
|
||||
@Column()
|
||||
geography_id: number;
|
||||
|
||||
@Column({ nullable: true })
|
||||
created_at: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
updated_at: string;
|
||||
}
|
||||
|
|
@ -26,6 +26,18 @@ export class SubDistrict extends EntityBase {
|
|||
})
|
||||
districtId: string;
|
||||
|
||||
// @Column({
|
||||
// comment: "mark",
|
||||
// default: null,
|
||||
// })
|
||||
// importUpdate: number;
|
||||
|
||||
// @Column({
|
||||
// comment: "refId",
|
||||
// default: null,
|
||||
// })
|
||||
// refId: number;
|
||||
|
||||
@ManyToOne(() => District, (district) => district.subDistricts)
|
||||
@JoinColumn({ name: "districtId" })
|
||||
district: District;
|
||||
|
|
|
|||
31
src/entities/SubDistrictMaster.ts
Normal file
31
src/entities/SubDistrictMaster.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
import { Entity, Column, PrimaryGeneratedColumn } from "typeorm";
|
||||
|
||||
@Entity("subdistrict_master")
|
||||
export class SubDistrictMaster {
|
||||
@PrimaryGeneratedColumn()
|
||||
id: number;
|
||||
|
||||
@Column()
|
||||
zip_code: number;
|
||||
|
||||
@Column({ length: 255 })
|
||||
name_th: string;
|
||||
|
||||
@Column({ length: 255 })
|
||||
name_en: string;
|
||||
|
||||
@Column()
|
||||
district_id: number;
|
||||
|
||||
@Column({ type: "float", nullable: true })
|
||||
lat: number | null;
|
||||
|
||||
@Column({ type: "float", nullable: true })
|
||||
long: number | null;
|
||||
|
||||
@Column({ type: "timestamp", nullable: true })
|
||||
created_at: string;
|
||||
|
||||
@Column({ type: "timestamp", nullable: true })
|
||||
updated_at: string;
|
||||
}
|
||||
|
|
@ -32,6 +32,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
|||
posMaster.orgChild2Id AS orgChild2Id,
|
||||
posMaster.orgChild3Id AS orgChild3Id,
|
||||
posMaster.orgChild4Id AS orgChild4Id,
|
||||
posMaster.positionSign AS positionSign,
|
||||
CONCAT(posMaster.id, profile.id) AS \`key\`,
|
||||
(
|
||||
SELECT hrms_organization.acting.actFullNameKeycloakId
|
||||
|
|
@ -147,4 +148,6 @@ export class viewDirector {
|
|||
actFullName: string;
|
||||
@ViewColumn()
|
||||
key: string;
|
||||
@ViewColumn()
|
||||
positionSign: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ import { ViewColumn, ViewEntity } from "typeorm";
|
|||
\`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`,
|
||||
\`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`,
|
||||
\`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`,
|
||||
\`posMaster\`.\`positionSign\` AS \`positionSign\`,
|
||||
CONCAT(\`hrms_organization\`.\`posMaster\`.\`id\`,
|
||||
\`profileChild\`.\`id\`) AS \`key\`,
|
||||
\`hrms_organization\`.\`profile\`.\`id\` AS \`actFullNameId\`,
|
||||
|
|
@ -123,4 +124,6 @@ export class viewDirectorActing {
|
|||
actFullName: string;
|
||||
@ViewColumn()
|
||||
key: string;
|
||||
@ViewColumn()
|
||||
positionSign: string;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,8 +251,11 @@ class Extension {
|
|||
|
||||
public static CheckCitizen(value: string) {
|
||||
let citizen = value;
|
||||
if (citizen == null || citizen == "") {
|
||||
return citizen;
|
||||
if (citizen == null || citizen == "" || citizen == undefined) {
|
||||
throw new HttpError(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"กรุณากรอกข้อมูลรหัสบัตรประจำตัวประชาชน",
|
||||
);
|
||||
}
|
||||
if (citizen.length !== 13) {
|
||||
throw new HttpError(
|
||||
|
|
@ -277,9 +280,12 @@ class Extension {
|
|||
const calStp2 = cal % 11;
|
||||
const chkDigit = (11 - calStp2) % 10;
|
||||
|
||||
// if (citizenIdDigits[12] !== chkDigit) {
|
||||
// throw new HttpError(HttpStatus.NOT_FOUND, "ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง");
|
||||
// }
|
||||
if (citizenIdDigits[12] !== chkDigit) {
|
||||
throw new HttpError(
|
||||
HttpStatus.NOT_FOUND,
|
||||
"ข้อมูลรหัสบัตรประจำตัวประชาชนไม่ถูกต้อง"
|
||||
);
|
||||
}
|
||||
return citizen;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -112,6 +112,15 @@ class CheckAuth {
|
|||
child4: node >= 4 ? [x.orgChild4Id] : null,
|
||||
privilege: "CHILD",
|
||||
};
|
||||
} else if (privilege == "BROTHER") {
|
||||
data = {
|
||||
// root: node >= 0 ? [x.orgRootId] : null,
|
||||
root: node >= 0 ? [x.orgRootId] : null,
|
||||
child1: node >= 2 ? [x.orgChild1Id] : null,
|
||||
child2: node >= 3 ? [x.orgChild2Id] : null,
|
||||
child3: node >= 4 ? [x.orgChild3Id] : null,
|
||||
privilege: "BROTHER",
|
||||
};
|
||||
} else if (privilege == "NORMAL") {
|
||||
data = {
|
||||
root: [x.orgRootId],
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ async function logMiddleware(req: Request, res: Response, next: NextFunction) {
|
|||
if (req.url.startsWith("/api/v1/org/apiKey/")) system = "admin";
|
||||
if (req.url.startsWith("/api/v1/org/api-manage/")) system = "admin";
|
||||
|
||||
if (req.url.startsWith("/api/v1/org/keycloak/")) system = "registry";
|
||||
|
||||
const level = LOG_LEVEL_MAP[process.env.LOG_LEVEL ?? "debug"] || 4;
|
||||
const profileByKeycloak = await repoProfile.findOne({
|
||||
where: { keycloak: req.app.locals.logData.userId },
|
||||
|
|
|
|||
|
|
@ -0,0 +1,159 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateViewDirectorAddPositionSign1765275494909 implements MigrationInterface {
|
||||
name = 'UpdateViewDirectorAddPositionSign1765275494909'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
// await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT
|
||||
// profile.id AS Id,
|
||||
// profile.prefix AS prefix,
|
||||
// profile.firstName AS firstName,
|
||||
// profile.lastName AS lastName,
|
||||
// profile.citizenId AS citizenId,
|
||||
// profile.position AS position,
|
||||
// profile.keycloak AS keycloakId,
|
||||
// profile.isProbation AS isProbation,
|
||||
// CONCAT(
|
||||
// CASE
|
||||
// WHEN posMaster.orgChild1Id IS NULL THEN orgRoot.orgRootShortName
|
||||
// WHEN posMaster.orgChild2Id IS NULL THEN orgChild1.orgChild1ShortName
|
||||
// WHEN posMaster.orgChild3Id IS NULL THEN orgChild2.orgChild2ShortName
|
||||
// WHEN posMaster.orgChild4Id IS NULL THEN orgChild3.orgChild3ShortName
|
||||
// ELSE orgChild4.orgChild4ShortName
|
||||
// END,
|
||||
// posMaster.posMasterNo
|
||||
// ) AS posNo,
|
||||
// posMaster.isDirector AS isDirector,
|
||||
// posLevel.posLevelName AS posLevel,
|
||||
// posType.posTypeName AS posType,
|
||||
// posExecutive.posExecutiveName AS posExecutiveName,
|
||||
// orgRoot.isDeputy AS isDeputy,
|
||||
// orgChild1.isOfficer AS isOfficer,
|
||||
// posMaster.orgRevisionId AS orgRevisionId,
|
||||
// posMaster.orgRootId AS orgRootId,
|
||||
// posMaster.orgChild1Id AS orgChild1Id,
|
||||
// posMaster.orgChild2Id AS orgChild2Id,
|
||||
// posMaster.orgChild3Id AS orgChild3Id,
|
||||
// posMaster.orgChild4Id AS orgChild4Id,
|
||||
// posMaster.positionSign AS positionSign,
|
||||
// CONCAT(posMaster.id, profile.id) AS \`key\`,
|
||||
// (
|
||||
// SELECT hrms_organization.acting.actFullNameKeycloakId
|
||||
// FROM hrms_organization.view_director_acting acting
|
||||
// WHERE ((hrms_organization.acting.Id = hrms_organization.posMaster.current_holderId)
|
||||
// AND (hrms_organization.acting.orgRootId = hrms_organization.posMaster.orgRootId)
|
||||
// AND ((hrms_organization.acting.orgChild1Id = hrms_organization.posMaster.orgChild1Id)
|
||||
// OR (hrms_organization.acting.orgChild1Id IS NULL))
|
||||
// AND ((hrms_organization.acting.orgChild2Id = hrms_organization.posMaster.orgChild2Id)
|
||||
// OR (hrms_organization.acting.orgChild2Id IS NULL))
|
||||
// AND ((hrms_organization.acting.orgChild3Id = hrms_organization.posMaster.orgChild3Id)
|
||||
// OR (hrms_organization.acting.orgChild3Id IS NULL))
|
||||
// AND ((hrms_organization.acting.orgChild4Id = hrms_organization.posMaster.orgChild4Id)
|
||||
// OR (hrms_organization.acting.orgChild4Id IS NULL)))
|
||||
// LIMIT 1
|
||||
// ) AS actFullNameKeycloakId,
|
||||
// (
|
||||
// SELECT actFullNameId
|
||||
// FROM view_director_acting AS acting
|
||||
// WHERE acting.Id = posMaster.current_holderId
|
||||
// AND acting.orgRootId = posMaster.orgRootId
|
||||
// AND (acting.orgChild1Id = posMaster.orgChild1Id OR acting.orgChild1Id IS NULL)
|
||||
// AND (acting.orgChild2Id = posMaster.orgChild2Id OR acting.orgChild2Id IS NULL)
|
||||
// AND (acting.orgChild3Id = posMaster.orgChild3Id OR acting.orgChild3Id IS NULL)
|
||||
// AND (acting.orgChild4Id = posMaster.orgChild4Id OR acting.orgChild4Id IS NULL)
|
||||
// LIMIT 1
|
||||
// ) AS actFullNameId,
|
||||
// (
|
||||
// SELECT actFullName
|
||||
// FROM view_director_acting AS acting
|
||||
// WHERE acting.Id = posMaster.current_holderId
|
||||
// AND acting.orgRootId = posMaster.orgRootId
|
||||
// AND (acting.orgChild1Id = posMaster.orgChild1Id OR acting.orgChild1Id IS NULL)
|
||||
// AND (acting.orgChild2Id = posMaster.orgChild2Id OR acting.orgChild2Id IS NULL)
|
||||
// AND (acting.orgChild3Id = posMaster.orgChild3Id OR acting.orgChild3Id IS NULL)
|
||||
// AND (acting.orgChild4Id = posMaster.orgChild4Id OR acting.orgChild4Id IS NULL)
|
||||
// LIMIT 1
|
||||
// ) AS actFullName
|
||||
// FROM
|
||||
// posMaster
|
||||
// JOIN profile ON posMaster.current_holderId = profile.id
|
||||
// LEFT JOIN orgRoot ON posMaster.orgRootId = orgRoot.id
|
||||
// LEFT JOIN orgChild1 ON posMaster.orgChild1Id = orgChild1.id
|
||||
// LEFT JOIN orgChild2 ON posMaster.orgChild2Id = orgChild2.id
|
||||
// LEFT JOIN orgChild3 ON posMaster.orgChild3Id = orgChild3.id
|
||||
// LEFT JOIN orgChild4 ON posMaster.orgChild4Id = orgChild4.id
|
||||
// JOIN posLevel ON profile.posLevelId = posLevel.id
|
||||
// JOIN posType ON profile.posTypeId = posType.id
|
||||
// LEFT JOIN position ON posMaster.id = position.posMasterId
|
||||
// LEFT JOIN posExecutive ON position.posExecutiveId = posExecutive.id
|
||||
// INNER JOIN orgRevision ON posMaster.orgRevisionId = orgRevision.id
|
||||
// WHERE
|
||||
// (position.positionIsSelected = TRUE)
|
||||
// AND (orgRevision.orgRevisionIsCurrent = TRUE
|
||||
// AND orgRevision.orgRevisionIsDraft = FALSE)`);
|
||||
// await queryRunner.query(`CREATE VIEW \`view_director_acting\` AS SELECT
|
||||
// \`profileChild\`.\`id\` AS \`Id\`,
|
||||
// \`profileChild\`.\`prefix\` AS \`prefix\`,
|
||||
// \`profileChild\`.\`firstName\` AS \`firstName\`,
|
||||
// \`profileChild\`.\`lastName\` AS \`lastName\`,
|
||||
// \`profileChild\`.\`citizenId\` AS \`citizenId\`,
|
||||
// \`profileChild\`.\`position\` AS \`position\`,
|
||||
// \`profile\`.\`isProbation\` AS \`isProbation\`,
|
||||
// CONCAT((CASE
|
||||
// WHEN (\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRootChild\`.\`orgRootShortName\`
|
||||
// WHEN (\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1Child\`.\`orgChild1ShortName\`
|
||||
// WHEN (\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2Child\`.\`orgChild2ShortName\`
|
||||
// WHEN (\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3Child\`.\`orgChild3ShortName\`
|
||||
// ELSE \`orgChild4Child\`.\`orgChild4ShortName\`
|
||||
// END),
|
||||
// \`posMaster\`.\`posMasterNo\`) AS \`posNo\`,
|
||||
// \`posMasterChild\`.\`isDirector\` AS \`isDirectorChild\`,
|
||||
// \`posMaster\`.\`isDirector\` AS \`isDirector\`,
|
||||
// \`posLevel\`.\`posLevelName\` AS \`posLevel\`,
|
||||
// \`posType\`.\`posTypeName\` AS \`posType\`,
|
||||
// \`posExecutive\`.\`posExecutiveName\` AS \`posExecutiveName\`,
|
||||
// \`orgRoot\`.\`isDeputy\` AS \`isDeputy\`,
|
||||
// \`orgChild1\`.\`isOfficer\` AS \`isOfficer\`,
|
||||
// \`posMaster\`.\`orgRevisionId\` AS \`orgRevisionId\`,
|
||||
// \`posMaster\`.\`orgRootId\` AS \`orgRootId\`,
|
||||
// \`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`,
|
||||
// \`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`,
|
||||
// \`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`,
|
||||
// \`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`,
|
||||
// \`posMaster\`.\`positionSign\` AS \`positionSign\`,
|
||||
// CONCAT(\`hrms_organization\`.\`posMaster\`.\`id\`,
|
||||
// \`profileChild\`.\`id\`) AS \`key\`,
|
||||
// \`hrms_organization\`.\`profile\`.\`id\` AS \`actFullNameId\`,
|
||||
// \`hrms_organization\`.\`profile\`.\`keycloak\` AS \`actFullNameKeycloakId\`,
|
||||
// CONCAT(\`posMaster\`.\`id\`, \`profileChild\`.\`id\`) AS \`key\`,
|
||||
// \`profile\`.\`id\` AS \`actFullNameId\`,
|
||||
// CONCAT(\`profile\`.\`prefix\`,
|
||||
// \`profile\`.\`firstName\`,
|
||||
// ' ',
|
||||
// \`profile\`.\`lastName\`) AS \`actFullName\`
|
||||
// FROM
|
||||
// (((((((((((((((\`posMasterAct\`
|
||||
// JOIN \`posMaster\` \`posMasterChild\` ON ((\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`)))
|
||||
// JOIN \`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`)))
|
||||
// LEFT JOIN \`orgRoot\` \`orgRootChild\` ON ((\`posMasterChild\`.\`orgRootId\` = \`orgRootChild\`.\`id\`)))
|
||||
// LEFT JOIN \`orgChild1\` \`orgChild1Child\` ON ((\`posMasterChild\`.\`orgChild1Id\` = \`orgChild1Child\`.\`id\`)))
|
||||
// LEFT JOIN \`orgChild2\` \`orgChild2Child\` ON ((\`posMasterChild\`.\`orgChild2Id\` = \`orgChild2Child\`.\`id\`)))
|
||||
// LEFT JOIN \`orgChild3\` \`orgChild3Child\` ON ((\`posMasterChild\`.\`orgChild3Id\` = \`orgChild3Child\`.\`id\`)))
|
||||
// LEFT JOIN \`orgChild4\` \`orgChild4Child\` ON ((\`posMasterChild\`.\`orgChild4Id\` = \`orgChild4Child\`.\`id\`)))
|
||||
// JOIN \`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`posLevel\`.\`id\`)))
|
||||
// JOIN \`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`posType\`.\`id\`)))
|
||||
// JOIN \`posMaster\` ON ((\`posMasterAct\`.\`posMasterId\` = \`posMaster\`.\`id\`)))
|
||||
// LEFT JOIN \`orgRoot\` ON ((\`posMaster\`.\`orgRootId\` = \`orgRoot\`.\`id\`)))
|
||||
// LEFT JOIN \`orgChild1\` ON ((\`posMaster\`.\`orgChild1Id\` = \`orgChild1\`.\`id\`)))
|
||||
// JOIN \`profile\` ON ((\`posMaster\`.\`current_holderId\` = \`profile\`.\`id\`)))
|
||||
// LEFT JOIN \`position\` ON ((\`posMasterChild\`.\`id\` = \`position\`.\`posMasterId\`)))
|
||||
// LEFT JOIN \`posExecutive\` ON ((\`position\`.\`posExecutiveId\` = \`posExecutive\`.\`id\`)))
|
||||
// WHERE
|
||||
// (\`position\`.\`positionIsSelected\` = TRUE)`);
|
||||
}
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
// await queryRunner.query(`DROP VIEW \`view_director\``);
|
||||
// await queryRunner.query(`DROP VIEW \`view_director_acting\``);
|
||||
}
|
||||
|
||||
}
|
||||
24
src/migration/1766760828376-add_field_dnaid_and_prodileid.ts
Normal file
24
src/migration/1766760828376-add_field_dnaid_and_prodileid.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class AddFieldDnaidAndProdileid1766760828376 implements MigrationInterface {
|
||||
name = 'AddFieldDnaidAndProdileid1766760828376'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profile'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`rootDnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgRoot'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child1DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild1'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child2DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild2'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child3DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild3'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child4DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild4'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`child4DnaId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`child3DnaId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`child2DnaId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`child1DnaId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`rootDnaId\``);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` DROP COLUMN \`profileId\``);
|
||||
}
|
||||
|
||||
}
|
||||
18
src/migration/1767930614165-update_table_posMasterHistory.ts
Normal file
18
src/migration/1767930614165-update_table_posMasterHistory.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTablePosMasterHistory1767930614165 implements MigrationInterface {
|
||||
name = 'UpdateTablePosMasterHistory1767930614165'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`profileId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง profile'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`rootDnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgRoot'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child1DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild1'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child2DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild2'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child3DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild3'`);
|
||||
await queryRunner.query(`ALTER TABLE \`posMasterHistory\` ADD \`child4DnaId\` varchar(40) NULL COMMENT 'dna ของตาราง orgChild4'`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ export async function CreatePosMasterHistoryOfficer(
|
|||
if (!pm.ancestorDNA) return false;
|
||||
|
||||
const checkCurrentRevision = await repoOrgRevision.findOne({
|
||||
where:{
|
||||
where: {
|
||||
id: pm.orgRevisionId,
|
||||
orgRevisionIsCurrent: true,
|
||||
orgRevisionIsDraft: false
|
||||
|
|
@ -54,12 +54,18 @@ export async function CreatePosMasterHistoryOfficer(
|
|||
? pm.positions.find((p) => p.positionIsSelected === true) ?? null
|
||||
: null;
|
||||
h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null;
|
||||
if(!type || type != "DELETE"){
|
||||
if(checkCurrentRevision){
|
||||
if (!type || type != "DELETE") {
|
||||
if (checkCurrentRevision) {
|
||||
h.prefix = pm.current_holder?.prefix || _null;
|
||||
h.firstName = pm.current_holder?.firstName || _null;
|
||||
h.lastName = pm.current_holder?.lastName || _null;
|
||||
}else{
|
||||
h.profileId = pm.current_holder?.id || _null;
|
||||
h.rootDnaId = pm.orgRoot?.ancestorDNA || _null;
|
||||
h.child1DnaId = pm.orgChild1?.ancestorDNA || _null;
|
||||
h.child2DnaId = pm.orgChild2?.ancestorDNA || _null;
|
||||
h.child3DnaId = pm.orgChild3?.ancestorDNA || _null;
|
||||
h.child4DnaId = pm.orgChild4?.ancestorDNA || _null;
|
||||
} else {
|
||||
h.prefix = pm.next_holder?.prefix || _null;
|
||||
h.firstName = pm.next_holder?.firstName || _null;
|
||||
h.lastName = pm.next_holder?.lastName || _null;
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ import { PermissionOrg } from "../entities/PermissionOrg";
|
|||
import { sendWebSocket } from "./webSocket";
|
||||
import { CreatePosMasterHistoryOfficer } from "./PositionService";
|
||||
import { PayloadSendNoti } from "../interfaces/utils";
|
||||
import { PermissionProfile } from "../entities/PermissionProfile";
|
||||
|
||||
export let sendToQueue: (payload: any) => void;
|
||||
export let sendToQueueOrg: (payload: any) => void;
|
||||
|
|
@ -402,7 +403,9 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise<boolean>
|
|||
const { profiles, command } = data;
|
||||
|
||||
try {
|
||||
const profilesNotiRequest = new CallAPI()
|
||||
let profilesNotiRequest: Promise<any> | undefined;
|
||||
if (!(["C-PM-10"].includes(command.commandType.code))) {
|
||||
profilesNotiRequest = new CallAPI()
|
||||
.PostData(
|
||||
{ headers: { authorization: token } },
|
||||
"/placement/noti/profiles",
|
||||
|
|
@ -432,6 +435,7 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise<boolean>
|
|||
}
|
||||
console.error("Full error object:", error);
|
||||
});
|
||||
}
|
||||
|
||||
let profilesSend =
|
||||
command && command.commandSends.length > 0
|
||||
|
|
@ -475,13 +479,12 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise<boolean>
|
|||
});
|
||||
|
||||
/*เฉพาะคำสั่ง C-PM-10 ให้ตัด profilesNotiRequest ที่ส่ง noti ครั้งแรกออก*/
|
||||
if (command && command.commandType && ["C-PM-10"].includes(command.commandType.code)) {
|
||||
if (["C-PM-10"].includes(command.commandType.code)) {
|
||||
await Promise.all([profilesSendRequest]);
|
||||
}
|
||||
else {
|
||||
await Promise.all([profilesNotiRequest, profilesSendRequest]);
|
||||
await Promise.all([profilesNotiRequest!, profilesSendRequest]);
|
||||
}
|
||||
|
||||
|
||||
console.log("[AMQ] Send Notification Success");
|
||||
return true;
|
||||
|
|
@ -494,6 +497,8 @@ async function handler_command_noti(msg: amqp.ConsumeMessage): Promise<boolean>
|
|||
async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
||||
//----> condition before process consume
|
||||
const repoPosmaster = AppDataSource.getRepository(PosMaster);
|
||||
const posMasterAssignRepository = AppDataSource.getRepository(PosMasterAssign);
|
||||
const permissionProfilesRepository = AppDataSource.getRepository(PermissionProfile);
|
||||
const repoEmployeePosmaster = AppDataSource.getRepository(EmployeePosMaster);
|
||||
const repoEmployeeTempPosmaster = AppDataSource.getRepository(EmployeeTempPosMaster);
|
||||
const repoProfile = AppDataSource.getRepository(Profile);
|
||||
|
|
@ -555,8 +560,71 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
"positions.posExecutive",
|
||||
],
|
||||
});
|
||||
// ดึง posMasterAssign ของ revision เดิม xxx
|
||||
const oldposMasterAssigns = await posMasterAssignRepository.find({
|
||||
relations: ["posMaster"],
|
||||
where: {
|
||||
posMaster: {
|
||||
orgRevisionId: orgRevisionPublish?.id,
|
||||
},
|
||||
},
|
||||
});
|
||||
// สร้าง Map: ancestorDNA → posMasterAssign[]
|
||||
const assignMap = new Map<string, PosMasterAssign[]>();
|
||||
for (const posmasterAssign of oldposMasterAssigns) {
|
||||
const dna = posmasterAssign.posMaster.ancestorDNA;
|
||||
if (!assignMap.has(dna)) {
|
||||
assignMap.set(dna, []);
|
||||
}
|
||||
assignMap.get(dna)!.push(posmasterAssign);
|
||||
}
|
||||
// ดึง permissionProfiles ของ revision เดิม
|
||||
const oldPermissionProfiles = await permissionProfilesRepository.find({
|
||||
relations: ["orgRootTree"],
|
||||
where: {
|
||||
orgRootTree: {
|
||||
orgRevisionId: orgRevisionPublish?.id,
|
||||
}
|
||||
}
|
||||
});
|
||||
// สร้าง Map: ancestorDNA → permissionProfiles[]
|
||||
const permissionMap = new Map<string, PermissionProfile[]>();
|
||||
for (const permissionProfile of oldPermissionProfiles) {
|
||||
const dna = permissionProfile.orgRootTree.ancestorDNA;
|
||||
if (!permissionMap.has(dna)) {
|
||||
permissionMap.set(dna, []);
|
||||
}
|
||||
permissionMap.get(dna)!.push(permissionProfile);
|
||||
}
|
||||
const newRoots = await orgRootRepository.find({
|
||||
where: { orgRevisionId: orgRevisionDraft?.id },
|
||||
});
|
||||
const newRootMap = new Map(
|
||||
newRoots.map(r => [r.ancestorDNA, r.id])
|
||||
);
|
||||
const _null: any = null;
|
||||
for (const item of posMaster) {
|
||||
|
||||
// Clone posMasterAssign xxx
|
||||
const assigns = assignMap.get(item.ancestorDNA);
|
||||
if (assigns && assigns.length > 0) {
|
||||
const newAssigns = assigns.map(({ id, ...fields }) => ({
|
||||
...fields, // copy ทุก field ยกเว้น id
|
||||
posMasterId: item.id, // ผูกกับ posMasterId ใหม่
|
||||
}));
|
||||
await posMasterAssignRepository.save(newAssigns);
|
||||
}
|
||||
// Clone permissionProfiles
|
||||
const perms = permissionMap.get(item.orgRoot.ancestorDNA);
|
||||
const newRootId = newRootMap.get(item.orgRoot.ancestorDNA);
|
||||
if (perms && perms.length > 0 && newRootId) {
|
||||
const newPerms = perms.map(({ id, ...fields }) => ({
|
||||
...fields,
|
||||
orgRootId: newRootId,
|
||||
}));
|
||||
await permissionProfilesRepository.save(newPerms);
|
||||
}
|
||||
|
||||
if (item.next_holderId != null) {
|
||||
const profile = await repoProfile.findOne({
|
||||
where: { id: item.next_holderId == null ? "" : item.next_holderId },
|
||||
|
|
@ -1796,13 +1864,13 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
posMaster.lastUpdatedAt = new Date();
|
||||
await posMasterRepository.save(posMaster);
|
||||
|
||||
// Copy assignments
|
||||
await posMasterAssignRepository.save(
|
||||
posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
...rest,
|
||||
posMasterId: posMaster.id,
|
||||
})),
|
||||
);
|
||||
// // Copy assignments
|
||||
// await posMasterAssignRepository.save(
|
||||
// posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
// ...rest,
|
||||
// posMasterId: posMaster.id,
|
||||
// })),
|
||||
// );
|
||||
|
||||
// Create positions
|
||||
for await (const pos of item.positions) {
|
||||
|
|
@ -1893,13 +1961,13 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
posMaster.lastUpdatedAt = new Date();
|
||||
await posMasterRepository.save(posMaster);
|
||||
|
||||
// Copy assignments
|
||||
await posMasterAssignRepository.save(
|
||||
posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
...rest,
|
||||
posMasterId: posMaster.id,
|
||||
})),
|
||||
);
|
||||
// // Copy assignments
|
||||
// await posMasterAssignRepository.save(
|
||||
// posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
// ...rest,
|
||||
// posMasterId: posMaster.id,
|
||||
// })),
|
||||
// );
|
||||
|
||||
// Create positions
|
||||
for await (const pos of item.positions) {
|
||||
|
|
@ -1992,13 +2060,13 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
posMaster.lastUpdatedAt = new Date();
|
||||
await posMasterRepository.save(posMaster);
|
||||
|
||||
// Copy assignments
|
||||
await posMasterAssignRepository.save(
|
||||
posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
...rest,
|
||||
posMasterId: posMaster.id,
|
||||
})),
|
||||
);
|
||||
// // Copy assignments
|
||||
// await posMasterAssignRepository.save(
|
||||
// posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
// ...rest,
|
||||
// posMasterId: posMaster.id,
|
||||
// })),
|
||||
// );
|
||||
|
||||
// Create positions
|
||||
for await (const pos of item.positions) {
|
||||
|
|
@ -2093,13 +2161,13 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
posMaster.lastUpdatedAt = new Date();
|
||||
await posMasterRepository.save(posMaster);
|
||||
|
||||
// Copy assignments
|
||||
await posMasterAssignRepository.save(
|
||||
posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
...rest,
|
||||
posMasterId: posMaster.id,
|
||||
})),
|
||||
);
|
||||
// // Copy assignments
|
||||
// await posMasterAssignRepository.save(
|
||||
// posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
// ...rest,
|
||||
// posMasterId: posMaster.id,
|
||||
// })),
|
||||
// );
|
||||
|
||||
// Create positions
|
||||
for await (const pos of item.positions) {
|
||||
|
|
@ -2197,13 +2265,13 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
posMaster.lastUpdatedAt = new Date();
|
||||
await posMasterRepository.save(posMaster);
|
||||
|
||||
// Copy assignments
|
||||
await posMasterAssignRepository.save(
|
||||
posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
...rest,
|
||||
posMasterId: posMaster.id,
|
||||
})),
|
||||
);
|
||||
// // Copy assignments
|
||||
// await posMasterAssignRepository.save(
|
||||
// posMasterAssign.map(({ id, ...rest }: PosMasterAssign) => ({
|
||||
// ...rest,
|
||||
// posMasterId: posMaster.id,
|
||||
// })),
|
||||
// );
|
||||
|
||||
// Create positions
|
||||
for await (const pos of item.positions) {
|
||||
|
|
@ -2285,9 +2353,30 @@ async function handler_org_draft(msg: amqp.ConsumeMessage): Promise<boolean> {
|
|||
await child3Repository.delete({ orgRevisionId: In(_orgRevisions.map((x) => x.id)) });
|
||||
await child2Repository.delete({ orgRevisionId: In(_orgRevisions.map((x) => x.id)) });
|
||||
await child1Repository.delete({ orgRevisionId: In(_orgRevisions.map((x) => x.id)) });
|
||||
await permissionOrgRepository.delete({
|
||||
orgRootId: In(_roots.map((x) => x.id)),
|
||||
});
|
||||
// ถ้าเลือกทำสำเนาให้อัพเดทจากแบบร่างเดิมไปแบบร่างใหม่แทนการลบ xxx
|
||||
if (["ORG", "ORG_POSITION", "ORG_POSITION_PERSON", "ORG_POSITION_ROLE", "ORG_POSITION_PERSON_ROLE"].includes(requestBody.typeDraft?.toUpperCase()))
|
||||
{
|
||||
const _newRoots = await orgRootRepository.find({
|
||||
where: { orgRevisionId: revision.id}
|
||||
});
|
||||
const newRootMap = new Map(
|
||||
_newRoots.map(r => [r.ancestorDNA, r.id])
|
||||
);
|
||||
for (const oldRoot of _roots) {
|
||||
const newRootId = newRootMap.get(oldRoot.ancestorDNA);
|
||||
if (!newRootId) continue;
|
||||
// อัพเดท orgRootId ที่อยู่ภายใต้ orgRevision แบบร่างเดิมเป็นของ orgRevision แบบร่างใหม่
|
||||
await permissionOrgRepository.update(
|
||||
{ orgRootId: oldRoot.id },
|
||||
{ orgRootId: newRootId }
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
await permissionOrgRepository.delete({
|
||||
orgRootId: In(_roots.map((x) => x.id)),
|
||||
});
|
||||
}
|
||||
await orgRootRepository.delete({ orgRevisionId: In(_orgRevisions.map((x) => x.id)) });
|
||||
await orgRevisionRepository.remove(_orgRevisions);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue