@dssp/supervision 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/pages/building-inspection/building-inspection-detail-checklist.ts +186 -0
- package/client/pages/building-inspection/building-inspection-detail-drawing.ts +160 -0
- package/client/pages/building-inspection/building-inspection-list.ts +430 -0
- package/client/pages/building-inspection/component/building-inspection-detail-header.ts +94 -0
- package/client/pages/building-inspection/inspection-create-popup.ts +696 -0
- package/client/pages/checklist/checklist-view.ts +443 -0
- package/client/pages/checklist-template/checklist-template-item.ts +240 -0
- package/client/pages/checklist-template/checklist-template-list.ts +271 -0
- package/client/pages/checklist-template/checklist-type-management.ts +242 -0
- package/client/route.ts +14 -18
- package/dist-client/pages/building-inspection/building-inspection-detail-checklist.d.ts +21 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js +187 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js.map +1 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-drawing.d.ts +21 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js +169 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js.map +1 -0
- package/dist-client/pages/building-inspection/building-inspection-list.d.ts +67 -0
- package/dist-client/pages/building-inspection/building-inspection-list.js +434 -0
- package/dist-client/pages/building-inspection/building-inspection-list.js.map +1 -0
- package/dist-client/pages/building-inspection/component/building-inspection-detail-header.d.ts +1 -0
- package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js +118 -0
- package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js.map +1 -0
- package/dist-client/pages/building-inspection/inspection-create-popup.d.ts +3 -0
- package/dist-client/pages/building-inspection/inspection-create-popup.js +735 -0
- package/dist-client/pages/building-inspection/inspection-create-popup.js.map +1 -0
- package/dist-client/pages/checklist/checklist-view.d.ts +6 -0
- package/dist-client/pages/checklist/checklist-view.js +434 -0
- package/dist-client/pages/checklist/checklist-view.js.map +1 -0
- package/dist-client/pages/checklist-template/checklist-template-item.d.ts +2 -0
- package/dist-client/pages/checklist-template/checklist-template-item.js +237 -0
- package/dist-client/pages/checklist-template/checklist-template-item.js.map +1 -0
- package/dist-client/pages/{check-item/check-item-list-page.d.ts → checklist-template/checklist-template-list.d.ts} +8 -27
- package/dist-client/pages/checklist-template/checklist-template-list.js +259 -0
- package/dist-client/pages/checklist-template/checklist-template-list.js.map +1 -0
- package/dist-client/pages/checklist-template/checklist-type-management.d.ts +48 -0
- package/dist-client/pages/checklist-template/checklist-type-management.js +229 -0
- package/dist-client/pages/checklist-template/checklist-type-management.js.map +1 -0
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +10 -13
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/index.d.ts +1 -1
- package/dist-server/index.js +1 -1
- package/dist-server/index.js.map +1 -1
- package/dist-server/service/building-inspection/building-inspection-history.d.ts +17 -0
- package/dist-server/service/building-inspection/building-inspection-history.js +85 -0
- package/dist-server/service/building-inspection/building-inspection-history.js.map +1 -0
- package/dist-server/service/building-inspection/building-inspection-mutation.d.ts +8 -0
- package/dist-server/service/building-inspection/building-inspection-mutation.js +148 -0
- package/dist-server/service/building-inspection/building-inspection-mutation.js.map +1 -0
- package/dist-server/service/building-inspection/building-inspection-query.d.ts +20 -0
- package/dist-server/service/building-inspection/building-inspection-query.js +235 -0
- package/dist-server/service/building-inspection/building-inspection-query.js.map +1 -0
- package/dist-server/service/building-inspection/building-inspection-type.d.ts +43 -0
- package/dist-server/service/building-inspection/building-inspection-type.js +153 -0
- package/dist-server/service/building-inspection/building-inspection-type.js.map +1 -0
- package/dist-server/service/building-inspection/building-inspection.d.ts +26 -0
- package/dist-server/service/building-inspection/building-inspection.js +113 -0
- package/dist-server/service/building-inspection/building-inspection.js.map +1 -0
- package/dist-server/service/building-inspection/event-subscriber.d.ts +7 -0
- package/dist-server/service/building-inspection/event-subscriber.js +21 -0
- package/dist-server/service/building-inspection/event-subscriber.js.map +1 -0
- package/dist-server/service/building-inspection/index.d.ts +10 -0
- package/dist-server/service/building-inspection/index.js +14 -0
- package/dist-server/service/building-inspection/index.js.map +1 -0
- package/dist-server/service/checklist/checklist-history.d.ts +24 -0
- package/dist-server/service/checklist/checklist-history.js +120 -0
- package/dist-server/service/checklist/checklist-history.js.map +1 -0
- package/dist-server/service/checklist/checklist-mutation.d.ts +8 -0
- package/dist-server/service/checklist/checklist-mutation.js +96 -0
- package/dist-server/service/checklist/checklist-mutation.js.map +1 -0
- package/dist-server/service/checklist/checklist-query.d.ts +12 -0
- package/dist-server/service/checklist/checklist-query.js +83 -0
- package/dist-server/service/checklist/checklist-query.js.map +1 -0
- package/dist-server/service/checklist/checklist-type.d.ts +18 -0
- package/dist-server/service/checklist/checklist-type.js +69 -0
- package/dist-server/service/checklist/checklist-type.js.map +1 -0
- package/dist-server/service/checklist/checklist.d.ts +31 -0
- package/dist-server/service/checklist/checklist.js +143 -0
- package/dist-server/service/checklist/checklist.js.map +1 -0
- package/dist-server/service/checklist/event-subscriber.d.ts +7 -0
- package/dist-server/service/checklist/event-subscriber.js +21 -0
- package/dist-server/service/checklist/event-subscriber.js.map +1 -0
- package/dist-server/service/checklist/index.d.ts +8 -0
- package/dist-server/service/checklist/index.js +12 -0
- package/dist-server/service/checklist/index.js.map +1 -0
- package/dist-server/service/checklist-item/checklist-item-mutation.d.ts +2 -0
- package/dist-server/service/checklist-item/checklist-item-mutation.js +13 -0
- package/dist-server/service/checklist-item/checklist-item-mutation.js.map +1 -0
- package/dist-server/service/checklist-item/checklist-item-query.d.ts +10 -0
- package/dist-server/service/checklist-item/checklist-item-query.js +68 -0
- package/dist-server/service/checklist-item/checklist-item-query.js.map +1 -0
- package/dist-server/service/checklist-item/checklist-item-type.d.ts +5 -0
- package/dist-server/service/checklist-item/checklist-item-type.js +21 -0
- package/dist-server/service/checklist-item/checklist-item-type.js.map +1 -0
- package/dist-server/service/checklist-item/checklist-item.d.ts +26 -0
- package/dist-server/service/checklist-item/checklist-item.js +113 -0
- package/dist-server/service/checklist-item/checklist-item.js.map +1 -0
- package/dist-server/service/checklist-item/index.d.ts +5 -0
- package/dist-server/service/checklist-item/index.js +10 -0
- package/dist-server/service/checklist-item/index.js.map +1 -0
- package/dist-server/service/checklist-template/checklist-template-mutation.d.ts +6 -0
- package/dist-server/service/checklist-template/checklist-template-mutation.js +64 -0
- package/dist-server/service/checklist-template/checklist-template-mutation.js.map +1 -0
- package/dist-server/service/checklist-template/checklist-template-query.d.ts +10 -0
- package/dist-server/service/checklist-template/checklist-template-query.js +65 -0
- package/dist-server/service/checklist-template/checklist-template-query.js.map +1 -0
- package/dist-server/service/checklist-template/checklist-template-type.d.ts +10 -0
- package/dist-server/service/checklist-template/checklist-template-type.js +39 -0
- package/dist-server/service/checklist-template/checklist-template-type.js.map +1 -0
- package/dist-server/service/checklist-template/checklist-template.d.ts +17 -0
- package/dist-server/service/checklist-template/checklist-template.js +78 -0
- package/dist-server/service/checklist-template/checklist-template.js.map +1 -0
- package/dist-server/service/checklist-template/index.d.ts +5 -0
- package/dist-server/service/checklist-template/index.js +9 -0
- package/dist-server/service/checklist-template/index.js.map +1 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-mutation.d.ts +7 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js +68 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js.map +1 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-query.d.ts +10 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-query.js +66 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-query.js.map +1 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-type.d.ts +16 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-type.js +60 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-type.js.map +1 -0
- package/dist-server/service/checklist-template-item/checklist-template-item.d.ts +19 -0
- package/dist-server/service/checklist-template-item/checklist-template-item.js +87 -0
- package/dist-server/service/checklist-template-item/checklist-template-item.js.map +1 -0
- package/dist-server/service/checklist-template-item/index.d.ts +5 -0
- package/dist-server/service/checklist-template-item/index.js +9 -0
- package/dist-server/service/checklist-template-item/index.js.map +1 -0
- package/dist-server/service/checklist-type/checklist-type-mutation.d.ts +6 -0
- package/dist-server/service/checklist-type/checklist-type-mutation.js +64 -0
- package/dist-server/service/checklist-type/checklist-type-mutation.js.map +1 -0
- package/dist-server/service/checklist-type/checklist-type-query.d.ts +10 -0
- package/dist-server/service/checklist-type/checklist-type-query.js +65 -0
- package/dist-server/service/checklist-type/checklist-type-query.js.map +1 -0
- package/dist-server/service/checklist-type/checklist-type-type.d.ts +11 -0
- package/dist-server/service/checklist-type/checklist-type-type.js +43 -0
- package/dist-server/service/checklist-type/checklist-type-type.js.map +1 -0
- package/dist-server/service/checklist-type/checklist-type.d.ts +19 -0
- package/dist-server/service/checklist-type/checklist-type.js +78 -0
- package/dist-server/service/checklist-type/checklist-type.js.map +1 -0
- package/dist-server/service/checklist-type/index.d.ts +5 -0
- package/dist-server/service/checklist-type/index.js +9 -0
- package/dist-server/service/checklist-type/index.js.map +1 -0
- package/dist-server/service/index.d.ts +8 -3
- package/dist-server/service/index.js +25 -5
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/issue/issue.d.ts +1 -3
- package/dist-server/service/issue/issue.js +1 -7
- package/dist-server/service/issue/issue.js.map +1 -1
- package/dist-server/service/supervisor/supervisor.d.ts +1 -3
- package/dist-server/service/supervisor/supervisor.js +1 -7
- package/dist-server/service/supervisor/supervisor.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/supervision/checklist-item.md +160 -0
- package/helps/supervision/checklist.md +160 -0
- package/package.json +11 -7
- package/server/index.ts +1 -1
- package/server/service/building-inspection/building-inspection-history.ts +70 -0
- package/server/service/building-inspection/building-inspection-mutation.ts +147 -0
- package/server/service/building-inspection/building-inspection-query.ts +202 -0
- package/server/service/building-inspection/building-inspection-type.ts +101 -0
- package/server/service/building-inspection/building-inspection.ts +106 -0
- package/server/service/building-inspection/event-subscriber.ts +20 -0
- package/server/service/building-inspection/index.ts +11 -0
- package/server/service/checklist/checklist-history.ts +96 -0
- package/server/service/checklist/checklist-mutation.ts +103 -0
- package/server/service/checklist/checklist-query.ts +52 -0
- package/server/service/{check-item/check-item-type.ts → checklist/checklist-type.ts} +6 -18
- package/server/service/checklist/checklist.ts +127 -0
- package/server/service/checklist/event-subscriber.ts +17 -0
- package/server/service/checklist/index.ts +9 -0
- package/server/service/checklist-item/checklist-item-mutation.ts +5 -0
- package/server/service/checklist-item/checklist-item-query.ts +43 -0
- package/server/service/checklist-item/checklist-item-type.ts +12 -0
- package/server/service/checklist-item/checklist-item.ts +100 -0
- package/server/service/checklist-item/index.ts +7 -0
- package/server/service/checklist-template/checklist-template-mutation.ts +66 -0
- package/server/service/checklist-template/checklist-template-query.ts +39 -0
- package/server/service/checklist-template/checklist-template-type.ts +23 -0
- package/server/service/checklist-template/checklist-template.ts +71 -0
- package/server/service/checklist-template/index.ts +6 -0
- package/server/service/checklist-template-item/checklist-template-item-mutation.ts +64 -0
- package/server/service/checklist-template-item/checklist-template-item-query.ts +39 -0
- package/server/service/checklist-template-item/checklist-template-item-type.ts +39 -0
- package/server/service/checklist-template-item/checklist-template-item.ts +67 -0
- package/server/service/checklist-template-item/index.ts +6 -0
- package/server/service/checklist-type/checklist-type-mutation.ts +66 -0
- package/server/service/checklist-type/checklist-type-query.ts +39 -0
- package/server/service/checklist-type/checklist-type-type.ts +26 -0
- package/server/service/checklist-type/checklist-type.ts +64 -0
- package/server/service/checklist-type/index.ts +6 -0
- package/server/service/index.ts +59 -23
- package/server/service/issue/issue.ts +1 -6
- package/server/service/supervisor/supervisor.ts +1 -6
- package/things-factory.config.js +11 -7
- package/client/pages/check-item/check-item-importer.ts +0 -94
- package/client/pages/check-item/check-item-list-page.ts +0 -340
- package/dist-client/pages/check-item/check-item-importer.d.ts +0 -10
- package/dist-client/pages/check-item/check-item-importer.js +0 -101
- package/dist-client/pages/check-item/check-item-importer.js.map +0 -1
- package/dist-client/pages/check-item/check-item-list-page.js +0 -323
- package/dist-client/pages/check-item/check-item-list-page.js.map +0 -1
- package/dist-server/service/check-item/check-item-mutation.d.ts +0 -10
- package/dist-server/service/check-item/check-item-mutation.js +0 -168
- package/dist-server/service/check-item/check-item-mutation.js.map +0 -1
- package/dist-server/service/check-item/check-item-query.d.ts +0 -12
- package/dist-server/service/check-item/check-item-query.js +0 -97
- package/dist-server/service/check-item/check-item-query.js.map +0 -1
- package/dist-server/service/check-item/check-item-type.d.ts +0 -23
- package/dist-server/service/check-item/check-item-type.js +0 -86
- package/dist-server/service/check-item/check-item-type.js.map +0 -1
- package/dist-server/service/check-item/check-item.d.ts +0 -28
- package/dist-server/service/check-item/check-item.js +0 -117
- package/dist-server/service/check-item/check-item.js.map +0 -1
- package/dist-server/service/check-item/index.d.ts +0 -6
- package/dist-server/service/check-item/index.js +0 -10
- package/dist-server/service/check-item/index.js.map +0 -1
- package/server/service/check-item/check-item-mutation.ts +0 -198
- package/server/service/check-item/check-item-query.ts +0 -62
- package/server/service/check-item/check-item.ts +0 -111
- package/server/service/check-item/index.ts +0 -7
package/dist-server/index.d.ts
CHANGED
package/dist-server/index.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
4
|
tslib_1.__exportStar(require("./migrations"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./
|
|
5
|
+
tslib_1.__exportStar(require("./service"), exports);
|
|
6
6
|
require("./routes");
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist-server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;;AAAA,uDAA4B;AAC5B,oDAAyB;AAEzB,oBAAiB","sourcesContent":["export * from './migrations'\nexport * from './service'\n\nimport './routes'\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HistoryActionType, HistoryEntityInterface } from '@operato/typeorm-history';
|
|
2
|
+
import { User } from '@things-factory/auth-base';
|
|
3
|
+
import { BuildingInspection, BuildingInspectionStatus } from './building-inspection';
|
|
4
|
+
import { BuildingLevel } from '@dssp/building-complex';
|
|
5
|
+
export declare class BuildingInspectionHistory implements HistoryEntityInterface<BuildingInspection> {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
status?: BuildingInspectionStatus;
|
|
8
|
+
buildingLevel?: BuildingLevel;
|
|
9
|
+
buildingLevelId?: string;
|
|
10
|
+
requestDate?: Date;
|
|
11
|
+
checklistId: string;
|
|
12
|
+
createdAt?: Date;
|
|
13
|
+
creator?: User;
|
|
14
|
+
creatorId?: string;
|
|
15
|
+
originalId: string;
|
|
16
|
+
action: HistoryActionType;
|
|
17
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildingInspectionHistory = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const typeorm_history_1 = require("@operato/typeorm-history");
|
|
8
|
+
const auth_base_1 = require("@things-factory/auth-base");
|
|
9
|
+
const env_1 = require("@things-factory/env");
|
|
10
|
+
const building_inspection_1 = require("./building-inspection");
|
|
11
|
+
const building_complex_1 = require("@dssp/building-complex");
|
|
12
|
+
const ORMCONFIG = env_1.config.get('ormconfig', {});
|
|
13
|
+
const DATABASE_TYPE = ORMCONFIG.type;
|
|
14
|
+
let BuildingInspectionHistory = class BuildingInspectionHistory {
|
|
15
|
+
};
|
|
16
|
+
tslib_1.__decorate([
|
|
17
|
+
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
18
|
+
(0, type_graphql_1.Field)(type => type_graphql_1.ID),
|
|
19
|
+
tslib_1.__metadata("design:type", String)
|
|
20
|
+
], BuildingInspectionHistory.prototype, "id", void 0);
|
|
21
|
+
tslib_1.__decorate([
|
|
22
|
+
(0, typeorm_1.Column)({ nullable: false, comment: '상태(REQUEST: 요청, PASS: 합격, FAIL: 불합격)' }),
|
|
23
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
24
|
+
tslib_1.__metadata("design:type", String)
|
|
25
|
+
], BuildingInspectionHistory.prototype, "status", void 0);
|
|
26
|
+
tslib_1.__decorate([
|
|
27
|
+
(0, typeorm_1.ManyToOne)(type => building_complex_1.BuildingLevel),
|
|
28
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
29
|
+
tslib_1.__metadata("design:type", building_complex_1.BuildingLevel)
|
|
30
|
+
], BuildingInspectionHistory.prototype, "buildingLevel", void 0);
|
|
31
|
+
tslib_1.__decorate([
|
|
32
|
+
(0, typeorm_1.RelationId)((buildingInspection) => buildingInspection.buildingLevel),
|
|
33
|
+
tslib_1.__metadata("design:type", String)
|
|
34
|
+
], BuildingInspectionHistory.prototype, "buildingLevelId", void 0);
|
|
35
|
+
tslib_1.__decorate([
|
|
36
|
+
(0, typeorm_1.Column)({ nullable: false, comment: '검측 요청일' }),
|
|
37
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
38
|
+
tslib_1.__metadata("design:type", Date
|
|
39
|
+
// 체크리스트 ID (1:1 테이블 참조)
|
|
40
|
+
)
|
|
41
|
+
], BuildingInspectionHistory.prototype, "requestDate", void 0);
|
|
42
|
+
tslib_1.__decorate([
|
|
43
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
44
|
+
(0, typeorm_1.Column)({ nullable: true, comment: '체크리스트 ID' }),
|
|
45
|
+
tslib_1.__metadata("design:type", String)
|
|
46
|
+
], BuildingInspectionHistory.prototype, "checklistId", void 0);
|
|
47
|
+
tslib_1.__decorate([
|
|
48
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
49
|
+
(0, type_graphql_1.Field)({ nullable: true }),
|
|
50
|
+
tslib_1.__metadata("design:type", Date)
|
|
51
|
+
], BuildingInspectionHistory.prototype, "createdAt", void 0);
|
|
52
|
+
tslib_1.__decorate([
|
|
53
|
+
(0, typeorm_1.ManyToOne)(type => auth_base_1.User, { nullable: true }),
|
|
54
|
+
(0, type_graphql_1.Field)(type => auth_base_1.User, { nullable: true }),
|
|
55
|
+
tslib_1.__metadata("design:type", auth_base_1.User)
|
|
56
|
+
], BuildingInspectionHistory.prototype, "creator", void 0);
|
|
57
|
+
tslib_1.__decorate([
|
|
58
|
+
(0, typeorm_1.RelationId)((buildingInspection) => buildingInspection.creator),
|
|
59
|
+
tslib_1.__metadata("design:type", String)
|
|
60
|
+
], BuildingInspectionHistory.prototype, "creatorId", void 0);
|
|
61
|
+
tslib_1.__decorate([
|
|
62
|
+
(0, typeorm_history_1.HistoryOriginalIdColumn)(),
|
|
63
|
+
tslib_1.__metadata("design:type", String)
|
|
64
|
+
], BuildingInspectionHistory.prototype, "originalId", void 0);
|
|
65
|
+
tslib_1.__decorate([
|
|
66
|
+
(0, typeorm_history_1.HistoryActionColumn)({
|
|
67
|
+
nullable: false,
|
|
68
|
+
type: DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
|
|
69
|
+
? 'enum'
|
|
70
|
+
: DATABASE_TYPE == 'oracle'
|
|
71
|
+
? 'varchar2'
|
|
72
|
+
: 'smallint',
|
|
73
|
+
enum: typeorm_history_1.HistoryActionType
|
|
74
|
+
}),
|
|
75
|
+
tslib_1.__metadata("design:type", String)
|
|
76
|
+
], BuildingInspectionHistory.prototype, "action", void 0);
|
|
77
|
+
BuildingInspectionHistory = tslib_1.__decorate([
|
|
78
|
+
(0, typeorm_1.Entity)(),
|
|
79
|
+
(0, typeorm_1.Index)('ix_buildingInspection_history_0', (buildingInspectionHistory) => [
|
|
80
|
+
buildingInspectionHistory.originalId
|
|
81
|
+
]),
|
|
82
|
+
(0, type_graphql_1.ObjectType)({ description: 'History Entity of BuildingInspection' })
|
|
83
|
+
], BuildingInspectionHistory);
|
|
84
|
+
exports.BuildingInspectionHistory = BuildingInspectionHistory;
|
|
85
|
+
//# sourceMappingURL=building-inspection-history.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"building-inspection-history.js","sourceRoot":"","sources":["../../../server/service/building-inspection/building-inspection-history.ts"],"names":[],"mappings":";;;;AAAA,+CAAoD;AACpD,qCAA8F;AAE9F,8DAAkI;AAClI,yDAAgD;AAChD,6CAA4C;AAE5C,+DAAoF;AACpF,6DAAsD;AAEtD,MAAM,SAAS,GAAG,YAAM,CAAC,GAAG,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAC7C,MAAM,aAAa,GAAG,SAAS,CAAC,IAAI,CAAA;AAO7B,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;CAmDrC,CAAA;AAlDC;IAAC,IAAA,gCAAsB,EAAC,MAAM,CAAC;IAC9B,IAAA,oBAAK,EAAC,IAAI,CAAC,EAAE,CAAC,iBAAE,CAAC;;qDACC;AAEnB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,sCAAsC,EAAE,CAAC;IAC5E,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;yDACO;AAGjC;IAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,gCAAa,CAAC;IAChC,IAAA,oBAAK,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;sCACV,gCAAa;gEAAA;AAE7B;IAAC,IAAA,oBAAU,EAAC,CAAC,kBAAsC,EAAE,EAAE,CAAC,kBAAkB,CAAC,aAAa,CAAC;;kEACjE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AA,eAAK,EAAC,iCAAiC,EAAE,CAAC,yBAAoD,EAAE,EAAE,CAAC;QAClG,yBAAyB,CAAC,UAAU;KACrC,CAAC;IACD,IAAA,yBAAU,EAAC,EAAE,WAAW,EAAE,sCAAsC,EAAE,CAAC;GACvD,yBAAyB,CAmDrC;AAnDY,8DAAyB","sourcesContent":["import { Field, ID, ObjectType } from 'type-graphql'\nimport { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'\n\nimport { HistoryActionColumn, HistoryActionType, HistoryEntityInterface, HistoryOriginalIdColumn } from '@operato/typeorm-history'\nimport { User } from '@things-factory/auth-base'\nimport { config } from '@things-factory/env'\n\nimport { BuildingInspection, BuildingInspectionStatus } from './building-inspection'\nimport { BuildingLevel } from '@dssp/building-complex'\n\nconst ORMCONFIG = config.get('ormconfig', {})\nconst DATABASE_TYPE = ORMCONFIG.type\n\n@Entity()\n@Index('ix_buildingInspection_history_0', (buildingInspectionHistory: BuildingInspectionHistory) => [\n buildingInspectionHistory.originalId\n])\n@ObjectType({ description: 'History Entity of BuildingInspection' })\nexport class BuildingInspectionHistory implements HistoryEntityInterface<BuildingInspection> {\n @PrimaryGeneratedColumn('uuid')\n @Field(type => ID)\n readonly id: string\n\n @Column({ nullable: false, comment: '상태(REQUEST: 요청, PASS: 합격, FAIL: 불합격)' })\n @Field({ nullable: true })\n status?: BuildingInspectionStatus\n\n // 층 정보 (1:1 테이블 참조)\n @ManyToOne(type => BuildingLevel)\n @Field({ nullable: true })\n buildingLevel?: BuildingLevel\n\n @RelationId((buildingInspection: BuildingInspection) => buildingInspection.buildingLevel)\n buildingLevelId?: string\n\n @Column({ nullable: false, comment: '검측 요청일' })\n @Field({ nullable: true })\n requestDate?: Date\n\n // 체크리스트 ID (1:1 테이블 참조)\n @Field({ nullable: true })\n @Column({ nullable: true, comment: '체크리스트 ID' })\n checklistId: string\n\n @Column({ nullable: true })\n @Field({ nullable: true })\n createdAt?: Date\n\n @ManyToOne(type => User, { nullable: true })\n @Field(type => User, { nullable: true })\n creator?: User\n\n @RelationId((buildingInspection: BuildingInspection) => buildingInspection.creator)\n creatorId?: string\n\n @HistoryOriginalIdColumn()\n public originalId!: string\n\n @HistoryActionColumn({\n nullable: false,\n type:\n DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'\n ? 'enum'\n : DATABASE_TYPE == 'oracle'\n ? 'varchar2'\n : 'smallint',\n enum: HistoryActionType\n })\n public action!: HistoryActionType\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { BuildingInspection } from './building-inspection';
|
|
2
|
+
import { NewBuildingInspection, UpdateBuildingInspection } from './building-inspection-type';
|
|
3
|
+
export declare class BuildingInspectionMutation {
|
|
4
|
+
createBuildingInspection(patch: NewBuildingInspection, context: ResolverContext): Promise<BuildingInspection>;
|
|
5
|
+
updateBuildingInspection(patch: UpdateBuildingInspection, context: ResolverContext): Promise<BuildingInspection>;
|
|
6
|
+
deleteBuildingInspections(ids: string[], context: ResolverContext): Promise<boolean>;
|
|
7
|
+
getRecentDocumentNoByBuildingLevelId(buildingLevelId: string): Promise<string>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildingInspectionMutation = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const typeorm_1 = require("typeorm");
|
|
7
|
+
const building_inspection_1 = require("./building-inspection");
|
|
8
|
+
const building_inspection_type_1 = require("./building-inspection-type");
|
|
9
|
+
const building_inspection_2 = require("./building-inspection");
|
|
10
|
+
const checklist_1 = require("../checklist/checklist");
|
|
11
|
+
const checklist_item_1 = require("../checklist-item/checklist-item");
|
|
12
|
+
const shell_1 = require("@things-factory/shell");
|
|
13
|
+
const building_complex_1 = require("@dssp/building-complex");
|
|
14
|
+
let BuildingInspectionMutation = class BuildingInspectionMutation {
|
|
15
|
+
async createBuildingInspection(patch, context) {
|
|
16
|
+
const { user, tx } = context.state;
|
|
17
|
+
const { buildingLevelId, checklist, checklistItem } = patch;
|
|
18
|
+
const buildingInspectionRepository = tx.getRepository(building_inspection_1.BuildingInspection);
|
|
19
|
+
const checklistRepository = tx.getRepository(checklist_1.Checklist);
|
|
20
|
+
const checklistItemRepository = tx.getRepository(checklist_item_1.ChecklistItem);
|
|
21
|
+
// 1. 벨리데이션
|
|
22
|
+
if (!buildingLevelId)
|
|
23
|
+
throw new Error('층 아이디가 없습니다.');
|
|
24
|
+
if (!checklist.name)
|
|
25
|
+
throw new Error('체크리스트 이름이 없습니다.');
|
|
26
|
+
if (!checklist.constructionType)
|
|
27
|
+
throw new Error('공종 타입이 없습니다.');
|
|
28
|
+
if (!checklist.constructionDetailType)
|
|
29
|
+
throw new Error('상세 공종 타입이 없습니다.');
|
|
30
|
+
if (!checklist.location)
|
|
31
|
+
throw new Error('위치가 없습니다.');
|
|
32
|
+
if (!checklist.inspectionDrawingType)
|
|
33
|
+
throw new Error('검측 도면 타입이 없습니다.');
|
|
34
|
+
if (checklist.inspectionParts.length === 0)
|
|
35
|
+
throw new Error('검측 부위가 없습니다.');
|
|
36
|
+
if (checklistItem.length === 0)
|
|
37
|
+
throw new Error('체크리스트 아이템이 없습니다.');
|
|
38
|
+
// 2. checklist 저장
|
|
39
|
+
const documentNo = await this.getRecentDocumentNoByBuildingLevelId(buildingLevelId);
|
|
40
|
+
const savedChecklist = await checklistRepository.save(Object.assign(Object.assign({}, checklist), { documentNo, creator: user, updater: user }));
|
|
41
|
+
// 3. checklistItem 저장
|
|
42
|
+
const checklistItems = checklistItem.map((item, idx) => ({
|
|
43
|
+
name: item.name,
|
|
44
|
+
mainType: item.mainType,
|
|
45
|
+
detailType: item.detailType,
|
|
46
|
+
inspctionCriteria: item.inspctionCriteria,
|
|
47
|
+
sequence: idx,
|
|
48
|
+
checklist: savedChecklist,
|
|
49
|
+
creator: user,
|
|
50
|
+
updater: user
|
|
51
|
+
}));
|
|
52
|
+
await checklistItemRepository.save(checklistItems);
|
|
53
|
+
// 4. buildingInspection 저장
|
|
54
|
+
const result = await buildingInspectionRepository.save({
|
|
55
|
+
status: building_inspection_2.BuildingInspectionStatus.WAIT,
|
|
56
|
+
buildingLevel: { id: buildingLevelId },
|
|
57
|
+
requestDate: new Date(),
|
|
58
|
+
checklist: savedChecklist,
|
|
59
|
+
creator: user,
|
|
60
|
+
updater: user
|
|
61
|
+
});
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
async updateBuildingInspection(patch, context) {
|
|
65
|
+
const { user, tx } = context.state;
|
|
66
|
+
const buildingInspectionRepo = tx.getRepository(building_inspection_1.BuildingInspection);
|
|
67
|
+
// 벨리데이션
|
|
68
|
+
if (!patch.id)
|
|
69
|
+
throw new Error('검측 아이디가 없습니다.');
|
|
70
|
+
const buildingInspection = await buildingInspectionRepo.findOneBy({ id: patch.id });
|
|
71
|
+
const result = await buildingInspectionRepo.save(Object.assign(Object.assign(Object.assign({}, buildingInspection), patch), { updater: user }));
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
async deleteBuildingInspections(ids, context) {
|
|
75
|
+
const { domain, tx } = context.state;
|
|
76
|
+
const buildingInspectionRepository = tx.getRepository(building_inspection_1.BuildingInspection);
|
|
77
|
+
const checklistRepository = tx.getRepository(checklist_1.Checklist);
|
|
78
|
+
const checklistItemRepository = tx.getRepository(checklist_item_1.ChecklistItem);
|
|
79
|
+
// 검측 데이터 제거
|
|
80
|
+
const buildingInspections = await buildingInspectionRepository.createQueryBuilder('bi').whereInIds(ids).getMany();
|
|
81
|
+
await buildingInspectionRepository.softDelete({
|
|
82
|
+
id: (0, typeorm_1.In)(ids)
|
|
83
|
+
});
|
|
84
|
+
// 검측 데이터의 체크 리스트 제거
|
|
85
|
+
const checklistIds = buildingInspections.map(bi => bi.checklistId);
|
|
86
|
+
await checklistRepository.softDelete({
|
|
87
|
+
id: (0, typeorm_1.In)(checklistIds)
|
|
88
|
+
});
|
|
89
|
+
// 검측 데이터의 체크 리스트 아이템 제거
|
|
90
|
+
await checklistItemRepository
|
|
91
|
+
.createQueryBuilder()
|
|
92
|
+
.softDelete()
|
|
93
|
+
.where('checklist_id IN (:...checklistIds)', { checklistIds })
|
|
94
|
+
.execute();
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
async getRecentDocumentNoByBuildingLevelId(buildingLevelId) {
|
|
98
|
+
const buildingLevel = await (0, shell_1.getRepository)(building_complex_1.BuildingLevel).findOne({
|
|
99
|
+
where: { id: buildingLevelId },
|
|
100
|
+
relations: ['building']
|
|
101
|
+
});
|
|
102
|
+
const buildingName = buildingLevel.building.name.match(/\d+/g).join('').padStart(4, '0');
|
|
103
|
+
const floorName = buildingLevel.floor.toString().padStart(3, '0');
|
|
104
|
+
const latestChecklist = await (0, shell_1.getRepository)(checklist_1.Checklist)
|
|
105
|
+
.createQueryBuilder('c')
|
|
106
|
+
.where('c.document_no LIKE :pattern', { pattern: `${buildingName}-${floorName}-%` })
|
|
107
|
+
.orderBy('c.created_at', 'DESC')
|
|
108
|
+
.getOne();
|
|
109
|
+
let documentNo = '000001';
|
|
110
|
+
if (latestChecklist) {
|
|
111
|
+
const lastNo = latestChecklist.documentNo.split('-')[2];
|
|
112
|
+
documentNo = (Number(lastNo) + 1).toString().padStart(6, '0');
|
|
113
|
+
}
|
|
114
|
+
return `${buildingName}-${floorName}-${documentNo}`;
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
tslib_1.__decorate([
|
|
118
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
119
|
+
(0, type_graphql_1.Mutation)(returns => building_inspection_1.BuildingInspection, { description: 'To create Building Inspection information' }),
|
|
120
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patch')),
|
|
121
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
122
|
+
tslib_1.__metadata("design:type", Function),
|
|
123
|
+
tslib_1.__metadata("design:paramtypes", [building_inspection_type_1.NewBuildingInspection, Object]),
|
|
124
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
125
|
+
], BuildingInspectionMutation.prototype, "createBuildingInspection", null);
|
|
126
|
+
tslib_1.__decorate([
|
|
127
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
128
|
+
(0, type_graphql_1.Mutation)(returns => building_inspection_1.BuildingInspection, { description: 'To update Building Inspection information' }),
|
|
129
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('patch')),
|
|
130
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
131
|
+
tslib_1.__metadata("design:type", Function),
|
|
132
|
+
tslib_1.__metadata("design:paramtypes", [building_inspection_type_1.UpdateBuildingInspection, Object]),
|
|
133
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
134
|
+
], BuildingInspectionMutation.prototype, "updateBuildingInspection", null);
|
|
135
|
+
tslib_1.__decorate([
|
|
136
|
+
(0, type_graphql_1.Directive)('@transaction'),
|
|
137
|
+
(0, type_graphql_1.Mutation)(returns => Boolean, { description: 'To delete multiple Checklists' }),
|
|
138
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('ids', type => [String])),
|
|
139
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
140
|
+
tslib_1.__metadata("design:type", Function),
|
|
141
|
+
tslib_1.__metadata("design:paramtypes", [Array, Object]),
|
|
142
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
143
|
+
], BuildingInspectionMutation.prototype, "deleteBuildingInspections", null);
|
|
144
|
+
BuildingInspectionMutation = tslib_1.__decorate([
|
|
145
|
+
(0, type_graphql_1.Resolver)(building_inspection_1.BuildingInspection)
|
|
146
|
+
], BuildingInspectionMutation);
|
|
147
|
+
exports.BuildingInspectionMutation = BuildingInspectionMutation;
|
|
148
|
+
//# sourceMappingURL=building-inspection-mutation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"building-inspection-mutation.js","sourceRoot":"","sources":["../../../server/service/building-inspection/building-inspection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,+DAA0D;AAC1D,yEAA4F;AAC5F,+DAAgE;AAChE,sDAAkD;AAClD,qEAAgE;AAChE,iDAAqD;AACrD,6DAAsD;AAG/C,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAG/B,AAAN,KAAK,CAAC,wBAAwB,CACd,KAA4B,EACnC,OAAwB;QAE/B,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAClC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,KAAK,CAAA;QAC3D,MAAM,4BAA4B,GAAG,EAAE,CAAC,aAAa,CAAC,wCAAkB,CAAC,CAAA;QACzE,MAAM,mBAAmB,GAAG,EAAE,CAAC,aAAa,CAAC,qBAAS,CAAC,CAAA;QACvD,MAAM,uBAAuB,GAAG,EAAE,CAAC,aAAa,CAAC,8BAAa,CAAC,CAAA;QAE/D,WAAW;QACX,IAAI,CAAC,eAAe;YAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;QACrD,IAAI,CAAC,SAAS,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACvD,IAAI,CAAC,SAAS,CAAC,gBAAgB;YAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;QAChE,IAAI,CAAC,SAAS,CAAC,sBAAsB;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACzE,IAAI,CAAC,SAAS,CAAC,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;QACrD,IAAI,CAAC,SAAS,CAAC,qBAAqB;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CA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AAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;SAC9D;QAED,OAAO,GAAG,YAAY,IAAI,SAAS,IAAI,UAAU,EAAE,CAAA;IACrD,CAAC;CACF,CAAA;AApIO;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,wCAAkB,EAAE,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;IAEnG,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADe,gDAAqB;;0EAoD3C;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,wCAAkB,EAAE,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;IAEnG,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADe,mDAAwB;;0EAiB9C;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAE5E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EA2BP;AA/GU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAuItC;AAvIY,gEAA0B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { BuildingInspection } from './building-inspection'\nimport { NewBuildingInspection, UpdateBuildingInspection } from './building-inspection-type'\nimport { BuildingInspectionStatus } from './building-inspection'\nimport { Checklist } from '../checklist/checklist'\nimport { ChecklistItem } from '../checklist-item/checklist-item'\nimport { getRepository } from '@things-factory/shell'\nimport { BuildingLevel } from '@dssp/building-complex'\n\n@Resolver(BuildingInspection)\nexport class BuildingInspectionMutation {\n @Directive('@transaction')\n @Mutation(returns => BuildingInspection, { description: 'To create Building Inspection information' })\n async createBuildingInspection(\n @Arg('patch') patch: NewBuildingInspection,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspection> {\n const { user, tx } = context.state\n const { buildingLevelId, checklist, checklistItem } = patch\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n const checklistRepository = tx.getRepository(Checklist)\n const checklistItemRepository = tx.getRepository(ChecklistItem)\n\n // 1. 벨리데이션\n if (!buildingLevelId) throw new Error('층 아이디가 없습니다.')\n if (!checklist.name) throw new Error('체크리스트 이름이 없습니다.')\n if (!checklist.constructionType) throw new Error('공종 타입이 없습니다.')\n if (!checklist.constructionDetailType) throw new Error('상세 공종 타입이 없습니다.')\n if (!checklist.location) throw new Error('위치가 없습니다.')\n if (!checklist.inspectionDrawingType) throw new Error('검측 도면 타입이 없습니다.')\n if (checklist.inspectionParts.length === 0) throw new Error('검측 부위가 없습니다.')\n if (checklistItem.length === 0) throw new Error('체크리스트 아이템이 없습니다.')\n\n // 2. checklist 저장\n const documentNo = await this.getRecentDocumentNoByBuildingLevelId(buildingLevelId)\n const savedChecklist = await checklistRepository.save({\n ...checklist,\n documentNo,\n creator: user,\n updater: user\n })\n\n // 3. checklistItem 저장\n const checklistItems = checklistItem.map((item, idx) => ({\n name: item.name,\n mainType: item.mainType,\n detailType: item.detailType,\n inspctionCriteria: item.inspctionCriteria,\n sequence: idx,\n checklist: savedChecklist,\n creator: user,\n updater: user\n }))\n await checklistItemRepository.save(checklistItems)\n\n // 4. buildingInspection 저장\n const result = await buildingInspectionRepository.save({\n status: BuildingInspectionStatus.WAIT,\n buildingLevel: { id: buildingLevelId },\n requestDate: new Date(),\n checklist: savedChecklist,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => BuildingInspection, { description: 'To update Building Inspection information' })\n async updateBuildingInspection(\n @Arg('patch') patch: UpdateBuildingInspection,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspection> {\n const { user, tx } = context.state\n const buildingInspectionRepo = tx.getRepository(BuildingInspection)\n\n // 벨리데이션\n if (!patch.id) throw new Error('검측 아이디가 없습니다.')\n\n const buildingInspection = await buildingInspectionRepo.findOneBy({ id: patch.id })\n const result = await buildingInspectionRepo.save({\n ...buildingInspection,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple Checklists' })\n async deleteBuildingInspections(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n const checklistRepository = tx.getRepository(Checklist)\n const checklistItemRepository = tx.getRepository(ChecklistItem)\n\n // 검측 데이터 제거\n const buildingInspections = await buildingInspectionRepository.createQueryBuilder('bi').whereInIds(ids).getMany()\n await buildingInspectionRepository.softDelete({\n id: In(ids)\n })\n\n // 검측 데이터의 체크 리스트 제거\n const checklistIds = buildingInspections.map(bi => bi.checklistId)\n await checklistRepository.softDelete({\n id: In(checklistIds)\n })\n\n // 검측 데이터의 체크 리스트 아이템 제거\n await checklistItemRepository\n .createQueryBuilder()\n .softDelete()\n .where('checklist_id IN (:...checklistIds)', { checklistIds })\n .execute()\n\n return true\n }\n\n async getRecentDocumentNoByBuildingLevelId(buildingLevelId: string): Promise<string> {\n const buildingLevel = await getRepository(BuildingLevel).findOne({\n where: { id: buildingLevelId },\n relations: ['building']\n })\n\n const buildingName = buildingLevel.building.name.match(/\\d+/g).join('').padStart(4, '0')\n const floorName = buildingLevel.floor.toString().padStart(3, '0')\n const latestChecklist = await getRepository(Checklist)\n .createQueryBuilder('c')\n .where('c.document_no LIKE :pattern', { pattern: `${buildingName}-${floorName}-%` })\n .orderBy('c.created_at', 'DESC')\n .getOne()\n\n let documentNo = '000001'\n if (latestChecklist) {\n const lastNo = latestChecklist.documentNo.split('-')[2]\n documentNo = (Number(lastNo) + 1).toString().padStart(6, '0')\n }\n\n return `${buildingName}-${floorName}-${documentNo}`\n }\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Attachment } from '@things-factory/attachment-base';
|
|
2
|
+
import { ListParam } from '@things-factory/shell';
|
|
3
|
+
import { BuildingInspection } from './building-inspection';
|
|
4
|
+
import { BuildingInspectionList, BuildingInspectionsOfBuildingLevel, BuildingInspectionsOfProject, BuildingInspectionSummary } from './building-inspection-type';
|
|
5
|
+
import { BuildingLevel } from '@dssp/building-complex';
|
|
6
|
+
import { Checklist } from '../checklist/checklist';
|
|
7
|
+
import { Project } from '@dssp/project';
|
|
8
|
+
export declare class BuildingInspectionQuery {
|
|
9
|
+
buildingInspection(id: string, context: ResolverContext): Promise<BuildingInspection>;
|
|
10
|
+
buildingInspections(params: ListParam, context: ResolverContext): Promise<BuildingInspectionList>;
|
|
11
|
+
buildingInspectionsOfProject(params: BuildingInspectionsOfProject, context: ResolverContext): Promise<BuildingInspectionList>;
|
|
12
|
+
projectByBuildingLevelId(buildingLevelId: string, context: ResolverContext): Promise<Project>;
|
|
13
|
+
buildingInspectionsOfBuildingLevel(params: BuildingInspectionsOfBuildingLevel, context: ResolverContext): Promise<BuildingInspectionList>;
|
|
14
|
+
buildingInspectionSummaryOfBuildingLevel(buildingLevelId: string, context: ResolverContext): Promise<BuildingInspectionSummary>;
|
|
15
|
+
buildingInspectionSummary(buildingLevel: BuildingLevel): Promise<BuildingInspectionSummary>;
|
|
16
|
+
buildingInspectionSummaryOfProject(projectId: string, context: ResolverContext): Promise<BuildingInspectionSummary>;
|
|
17
|
+
checklist(buildingInspection: BuildingInspection): Promise<Checklist>;
|
|
18
|
+
buildingLevel(buildingInspection: BuildingInspection): Promise<BuildingLevel>;
|
|
19
|
+
attatchments(buildingInspection: BuildingInspection): Promise<Attachment[] | undefined>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BuildingInspectionQuery = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const type_graphql_1 = require("type-graphql");
|
|
6
|
+
const attachment_base_1 = require("@things-factory/attachment-base");
|
|
7
|
+
const shell_1 = require("@things-factory/shell");
|
|
8
|
+
const building_inspection_1 = require("./building-inspection");
|
|
9
|
+
const building_inspection_type_1 = require("./building-inspection-type");
|
|
10
|
+
const building_complex_1 = require("@dssp/building-complex");
|
|
11
|
+
const checklist_1 = require("../checklist/checklist");
|
|
12
|
+
const project_1 = require("@dssp/project");
|
|
13
|
+
let BuildingInspectionQuery = class BuildingInspectionQuery {
|
|
14
|
+
async buildingInspection(id, context) {
|
|
15
|
+
return await (0, shell_1.getRepository)(building_inspection_1.BuildingInspection).findOne({
|
|
16
|
+
where: { id }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
async buildingInspections(params, context) {
|
|
20
|
+
const { domain } = context.state;
|
|
21
|
+
const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
|
|
22
|
+
params,
|
|
23
|
+
repository: await (0, shell_1.getRepository)(building_inspection_1.BuildingInspection),
|
|
24
|
+
searchables: ['name']
|
|
25
|
+
});
|
|
26
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
27
|
+
return { items, total };
|
|
28
|
+
}
|
|
29
|
+
async buildingInspectionsOfProject(params, context) {
|
|
30
|
+
const { domain } = context.state;
|
|
31
|
+
const { projectId, limit } = params;
|
|
32
|
+
const queryBuilder = (0, shell_1.getRepository)(building_inspection_1.BuildingInspection)
|
|
33
|
+
.createQueryBuilder('bi')
|
|
34
|
+
.innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')
|
|
35
|
+
.innerJoin('buildings', 'b', 'bl.building_id = b.id')
|
|
36
|
+
.innerJoin('building_complexes', 'bc', 'b.building_complex_id = bc.id')
|
|
37
|
+
.innerJoin('projects', 'p', 'bc.id = p.building_complex_id')
|
|
38
|
+
.innerJoin('checklists', 'c', 'bi.checklist_id = c.id')
|
|
39
|
+
.where('p.domain = :domain', { domain: domain.id })
|
|
40
|
+
.andWhere('p.id = :projectId', { projectId })
|
|
41
|
+
.orderBy('bi.created_at', 'DESC');
|
|
42
|
+
if (limit) {
|
|
43
|
+
queryBuilder.limit(limit);
|
|
44
|
+
}
|
|
45
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
46
|
+
return { items, total };
|
|
47
|
+
}
|
|
48
|
+
async projectByBuildingLevelId(buildingLevelId, context) {
|
|
49
|
+
const queryBuilder = (0, shell_1.getRepository)(project_1.Project)
|
|
50
|
+
.createQueryBuilder('p')
|
|
51
|
+
.innerJoin('building_complexes', 'bc', 'p.building_complex_id = bc.id')
|
|
52
|
+
.innerJoin('buildings', 'b', 'b.building_complex_id = bc.id')
|
|
53
|
+
.innerJoin('building_levels', 'bl', 'bl.building_id = b.id')
|
|
54
|
+
.where('bl.id = :buildingLevelId', { buildingLevelId });
|
|
55
|
+
const result = await queryBuilder.getOne();
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
async buildingInspectionsOfBuildingLevel(params, context) {
|
|
59
|
+
const { buildingLevelId, limit } = params;
|
|
60
|
+
const queryBuilder = (0, shell_1.getRepository)(building_inspection_1.BuildingInspection)
|
|
61
|
+
.createQueryBuilder('bi')
|
|
62
|
+
.innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')
|
|
63
|
+
.innerJoin('checklists', 'c', 'bi.checklist_id = c.id')
|
|
64
|
+
.where('bl.id = :buildingLevelId', { buildingLevelId })
|
|
65
|
+
.orderBy('bi.updated_at', 'DESC');
|
|
66
|
+
if (limit) {
|
|
67
|
+
queryBuilder.limit(limit);
|
|
68
|
+
}
|
|
69
|
+
const [items, total] = await queryBuilder.getManyAndCount();
|
|
70
|
+
return { items, total };
|
|
71
|
+
}
|
|
72
|
+
// 층 별로 검수 개수 써머리
|
|
73
|
+
async buildingInspectionSummaryOfBuildingLevel(buildingLevelId, context) {
|
|
74
|
+
const buildingInspectionSummary = await (0, shell_1.getRepository)(building_inspection_1.BuildingInspection)
|
|
75
|
+
.createQueryBuilder('bi')
|
|
76
|
+
.select(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)
|
|
77
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)
|
|
78
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
|
|
79
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
|
|
80
|
+
.where('bi.building_level_id = :buildingLevelId', { buildingLevelId })
|
|
81
|
+
.groupBy('bi.building_level_id')
|
|
82
|
+
.getRawOne();
|
|
83
|
+
return {
|
|
84
|
+
wait: (buildingInspectionSummary === null || buildingInspectionSummary === void 0 ? void 0 : buildingInspectionSummary.wait) || 0,
|
|
85
|
+
request: (buildingInspectionSummary === null || buildingInspectionSummary === void 0 ? void 0 : buildingInspectionSummary.request) || 0,
|
|
86
|
+
pass: (buildingInspectionSummary === null || buildingInspectionSummary === void 0 ? void 0 : buildingInspectionSummary.pass) || 0,
|
|
87
|
+
fail: (buildingInspectionSummary === null || buildingInspectionSummary === void 0 ? void 0 : buildingInspectionSummary.fail) || 0
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// 층 별로 검수 개수 써머리
|
|
91
|
+
async buildingInspectionSummary(buildingLevel) {
|
|
92
|
+
const buildingInspectionSummary = await (0, shell_1.getRepository)(building_inspection_1.BuildingInspection)
|
|
93
|
+
.createQueryBuilder('bi')
|
|
94
|
+
.select(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)
|
|
95
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)
|
|
96
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
|
|
97
|
+
.addSelect(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
|
|
98
|
+
.where('bi.building_level_id = :buildingLevelId', { buildingLevelId: buildingLevel.id })
|
|
99
|
+
.groupBy('bi.building_level_id')
|
|
100
|
+
.getRawOne();
|
|
101
|
+
return {
|
|
102
|
+
wait: (buildingInspectionSummary === null || buildingInspectionSummary === void 0 ? void 0 : buildingInspectionSummary.wait) || 0,
|
|
103
|
+
request: (buildingInspectionSummary === null || buildingInspectionSummary === void 0 ? void 0 : buildingInspectionSummary.request) || 0,
|
|
104
|
+
pass: (buildingInspectionSummary === null || buildingInspectionSummary === void 0 ? void 0 : buildingInspectionSummary.pass) || 0,
|
|
105
|
+
fail: (buildingInspectionSummary === null || buildingInspectionSummary === void 0 ? void 0 : buildingInspectionSummary.fail) || 0
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
async buildingInspectionSummaryOfProject(projectId, context) {
|
|
109
|
+
const { domain } = context.state;
|
|
110
|
+
const result = await (0, shell_1.getRepository)(project_1.Project)
|
|
111
|
+
.createQueryBuilder('p')
|
|
112
|
+
.select(`COUNT(CASE WHEN bi.status = '${building_inspection_1.BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)
|
|
113
|
+
.addSelect(`COUNT(CASE WHEN bi.status = '${building_inspection_1.BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)
|
|
114
|
+
.addSelect(`COUNT(CASE WHEN bi.status = '${building_inspection_1.BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
|
|
115
|
+
.addSelect(`COUNT(CASE WHEN bi.status = '${building_inspection_1.BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
|
|
116
|
+
.innerJoin('p.buildingComplex', 'bc')
|
|
117
|
+
.innerJoin('bc.buildings', 'b')
|
|
118
|
+
.innerJoin('b.buildingLevels', 'bl')
|
|
119
|
+
.leftJoin('building_inspections', 'bi', 'bi.building_level_id = bl.id AND bi.deleted_at IS NULL')
|
|
120
|
+
.where('p.domain = :domain', { domain: domain.id })
|
|
121
|
+
.andWhere('p.id = :projectId', { projectId })
|
|
122
|
+
.groupBy('p.id')
|
|
123
|
+
.getRawOne();
|
|
124
|
+
return {
|
|
125
|
+
wait: result.wait || 0,
|
|
126
|
+
request: result.request || 0,
|
|
127
|
+
pass: result.pass || 0,
|
|
128
|
+
fail: result.fail || 0
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
async checklist(buildingInspection) {
|
|
132
|
+
return await (0, shell_1.getRepository)(checklist_1.Checklist).findOneBy({ id: buildingInspection.checklistId });
|
|
133
|
+
}
|
|
134
|
+
async buildingLevel(buildingInspection) {
|
|
135
|
+
return await (0, shell_1.getRepository)(building_complex_1.BuildingLevel).findOneBy({ id: buildingInspection.buildingLevelId });
|
|
136
|
+
}
|
|
137
|
+
async attatchments(buildingInspection) {
|
|
138
|
+
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).find({
|
|
139
|
+
where: {
|
|
140
|
+
refType: building_inspection_1.BuildingInspection.name,
|
|
141
|
+
refBy: buildingInspection.id
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
return attachment;
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
tslib_1.__decorate([
|
|
148
|
+
(0, type_graphql_1.Query)(returns => building_inspection_1.BuildingInspection, { nullable: true, description: 'To fetch a BuildingInspection' }),
|
|
149
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
|
|
150
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
151
|
+
tslib_1.__metadata("design:type", Function),
|
|
152
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
153
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
154
|
+
], BuildingInspectionQuery.prototype, "buildingInspection", null);
|
|
155
|
+
tslib_1.__decorate([
|
|
156
|
+
(0, type_graphql_1.Query)(returns => building_inspection_type_1.BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' }),
|
|
157
|
+
tslib_1.__param(0, (0, type_graphql_1.Args)()),
|
|
158
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
159
|
+
tslib_1.__metadata("design:type", Function),
|
|
160
|
+
tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
|
|
161
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
162
|
+
], BuildingInspectionQuery.prototype, "buildingInspections", null);
|
|
163
|
+
tslib_1.__decorate([
|
|
164
|
+
(0, type_graphql_1.Query)(returns => building_inspection_type_1.BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' }),
|
|
165
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('params')),
|
|
166
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
167
|
+
tslib_1.__metadata("design:type", Function),
|
|
168
|
+
tslib_1.__metadata("design:paramtypes", [building_inspection_type_1.BuildingInspectionsOfProject, Object]),
|
|
169
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
170
|
+
], BuildingInspectionQuery.prototype, "buildingInspectionsOfProject", null);
|
|
171
|
+
tslib_1.__decorate([
|
|
172
|
+
(0, type_graphql_1.Query)(returns => project_1.Project, { description: 'To fetch Project' }),
|
|
173
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('buildingLevelId')),
|
|
174
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
175
|
+
tslib_1.__metadata("design:type", Function),
|
|
176
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
177
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
178
|
+
], BuildingInspectionQuery.prototype, "projectByBuildingLevelId", null);
|
|
179
|
+
tslib_1.__decorate([
|
|
180
|
+
(0, type_graphql_1.Query)(returns => building_inspection_type_1.BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' }),
|
|
181
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('params')),
|
|
182
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
183
|
+
tslib_1.__metadata("design:type", Function),
|
|
184
|
+
tslib_1.__metadata("design:paramtypes", [building_inspection_type_1.BuildingInspectionsOfBuildingLevel, Object]),
|
|
185
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
186
|
+
], BuildingInspectionQuery.prototype, "buildingInspectionsOfBuildingLevel", null);
|
|
187
|
+
tslib_1.__decorate([
|
|
188
|
+
(0, type_graphql_1.Query)(returns => building_inspection_type_1.BuildingInspectionSummary, { nullable: true, description: 'To fetch a BuildingInspection Summary' }),
|
|
189
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('buildingLevelId')),
|
|
190
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
191
|
+
tslib_1.__metadata("design:type", Function),
|
|
192
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
193
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
194
|
+
], BuildingInspectionQuery.prototype, "buildingInspectionSummaryOfBuildingLevel", null);
|
|
195
|
+
tslib_1.__decorate([
|
|
196
|
+
(0, type_graphql_1.FieldResolver)(type => building_inspection_type_1.BuildingInspectionSummary),
|
|
197
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
198
|
+
tslib_1.__metadata("design:type", Function),
|
|
199
|
+
tslib_1.__metadata("design:paramtypes", [building_complex_1.BuildingLevel]),
|
|
200
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
201
|
+
], BuildingInspectionQuery.prototype, "buildingInspectionSummary", null);
|
|
202
|
+
tslib_1.__decorate([
|
|
203
|
+
(0, type_graphql_1.Query)(returns => building_inspection_type_1.BuildingInspectionSummary, { description: '프로젝트의 검측상태 별 카운트' }),
|
|
204
|
+
tslib_1.__param(0, (0, type_graphql_1.Arg)('projectId')),
|
|
205
|
+
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
206
|
+
tslib_1.__metadata("design:type", Function),
|
|
207
|
+
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
208
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
209
|
+
], BuildingInspectionQuery.prototype, "buildingInspectionSummaryOfProject", null);
|
|
210
|
+
tslib_1.__decorate([
|
|
211
|
+
(0, type_graphql_1.FieldResolver)(type => checklist_1.Checklist),
|
|
212
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
213
|
+
tslib_1.__metadata("design:type", Function),
|
|
214
|
+
tslib_1.__metadata("design:paramtypes", [building_inspection_1.BuildingInspection]),
|
|
215
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
216
|
+
], BuildingInspectionQuery.prototype, "checklist", null);
|
|
217
|
+
tslib_1.__decorate([
|
|
218
|
+
(0, type_graphql_1.FieldResolver)(type => building_complex_1.BuildingLevel),
|
|
219
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
220
|
+
tslib_1.__metadata("design:type", Function),
|
|
221
|
+
tslib_1.__metadata("design:paramtypes", [building_inspection_1.BuildingInspection]),
|
|
222
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
223
|
+
], BuildingInspectionQuery.prototype, "buildingLevel", null);
|
|
224
|
+
tslib_1.__decorate([
|
|
225
|
+
(0, type_graphql_1.FieldResolver)(type => [attachment_base_1.Attachment]),
|
|
226
|
+
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
227
|
+
tslib_1.__metadata("design:type", Function),
|
|
228
|
+
tslib_1.__metadata("design:paramtypes", [building_inspection_1.BuildingInspection]),
|
|
229
|
+
tslib_1.__metadata("design:returntype", Promise)
|
|
230
|
+
], BuildingInspectionQuery.prototype, "attatchments", null);
|
|
231
|
+
BuildingInspectionQuery = tslib_1.__decorate([
|
|
232
|
+
(0, type_graphql_1.Resolver)(building_inspection_1.BuildingInspection)
|
|
233
|
+
], BuildingInspectionQuery);
|
|
234
|
+
exports.BuildingInspectionQuery = BuildingInspectionQuery;
|
|
235
|
+
//# sourceMappingURL=building-inspection-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"building-inspection-query.js","sourceRoot":"","sources":["../../../server/service/building-inspection/building-inspection-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AACnF,qEAA4D;AAC5D,iDAA+F;AAC/F,+DAAoF;AACpF,yEAKmC;AACnC,6DAAsD;AACtD,sDAAkD;AAClD,2CAAuC;AAGhC,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAE5B,AAAN,KAAK,CAAC,kBAAkB,CAAY,EAAU,EAAS,OAAwB;QAC7E,OAAO,MAAM,IAAA,qBAAa,EAAC,wCAAkB,CAAC,CAAC,OAAO,CAAC;YACrD,KAAK,EAAE,EAAE,EAAE,EAAE;SACd,CAAC,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,mBAAmB,CAAS,MAAiB,EAAS,OAAwB;QAClF,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,UAAU,EAAE,MAAM,IAAA,qBAAa,EAAC,wCAAkB,CAAC;YACnD,WAAW,EAAE,CAAC,MAAM,CAAC;SACtB,CAAC,CAAA;QAEF,MAAM,CAAC,KA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WAAW,EAAE,kBAAkB,EAAE,CAAC;IAE9E,mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iFAyBP;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,qBAAS,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;wDAE7D;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gCAAa,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;4DAEjE;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC,4BAAU,CAAC,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;2DAQhE;AAzLU,uBAAuB;IADnC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,uBAAuB,CA0LnC;AA1LY,0DAAuB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Arg, Args, Ctx } from 'type-graphql'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { getRepository, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'\nimport { BuildingInspection, BuildingInspectionStatus } from './building-inspection'\nimport {\n BuildingInspectionList,\n BuildingInspectionsOfBuildingLevel,\n BuildingInspectionsOfProject,\n BuildingInspectionSummary\n} from './building-inspection-type'\nimport { BuildingLevel } from '@dssp/building-complex'\nimport { Checklist } from '../checklist/checklist'\nimport { Project } from '@dssp/project'\n\n@Resolver(BuildingInspection)\nexport class BuildingInspectionQuery {\n @Query(returns => BuildingInspection!, { nullable: true, description: 'To fetch a BuildingInspection' })\n async buildingInspection(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<BuildingInspection> {\n return await getRepository(BuildingInspection).findOne({\n where: { id }\n })\n }\n\n @Query(returns => BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' })\n async buildingInspections(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<BuildingInspectionList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n params,\n repository: await getRepository(BuildingInspection),\n searchables: ['name']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' })\n async buildingInspectionsOfProject(\n @Arg('params') params: BuildingInspectionsOfProject,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionList> {\n const { domain } = context.state\n const { projectId, limit } = params\n\n const queryBuilder = getRepository(BuildingInspection)\n .createQueryBuilder('bi')\n .innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')\n .innerJoin('buildings', 'b', 'bl.building_id = b.id')\n .innerJoin('building_complexes', 'bc', 'b.building_complex_id = bc.id')\n .innerJoin('projects', 'p', 'bc.id = p.building_complex_id')\n .innerJoin('checklists', 'c', 'bi.checklist_id = c.id')\n .where('p.domain = :domain', { domain: domain.id })\n .andWhere('p.id = :projectId', { projectId })\n .orderBy('bi.created_at', 'DESC')\n\n if (limit) {\n queryBuilder.limit(limit)\n }\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => Project!, { description: 'To fetch Project' })\n async projectByBuildingLevelId(\n @Arg('buildingLevelId') buildingLevelId: string,\n @Ctx() context: ResolverContext\n ): Promise<Project> {\n const queryBuilder = getRepository(Project)\n .createQueryBuilder('p')\n .innerJoin('building_complexes', 'bc', 'p.building_complex_id = bc.id')\n .innerJoin('buildings', 'b', 'b.building_complex_id = bc.id')\n .innerJoin('building_levels', 'bl', 'bl.building_id = b.id')\n .where('bl.id = :buildingLevelId', { buildingLevelId })\n\n const result = await queryBuilder.getOne()\n\n return result\n }\n\n @Query(returns => BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' })\n async buildingInspectionsOfBuildingLevel(\n @Arg('params') params: BuildingInspectionsOfBuildingLevel,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionList> {\n const { buildingLevelId, limit } = params\n\n const queryBuilder = getRepository(BuildingInspection)\n .createQueryBuilder('bi')\n .innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')\n .innerJoin('checklists', 'c', 'bi.checklist_id = c.id')\n .where('bl.id = :buildingLevelId', { buildingLevelId })\n .orderBy('bi.updated_at', 'DESC')\n\n if (limit) {\n queryBuilder.limit(limit)\n }\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n // 층 별로 검수 개수 써머리\n @Query(returns => BuildingInspectionSummary!, { nullable: true, description: 'To fetch a BuildingInspection Summary' })\n async buildingInspectionSummaryOfBuildingLevel(\n @Arg('buildingLevelId') buildingLevelId: string,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionSummary> {\n const buildingInspectionSummary = await getRepository(BuildingInspection)\n .createQueryBuilder('bi')\n .select(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)\n .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)\n .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)\n .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)\n .where('bi.building_level_id = :buildingLevelId', { buildingLevelId })\n .groupBy('bi.building_level_id')\n .getRawOne()\n\n return {\n wait: buildingInspectionSummary?.wait || 0,\n request: buildingInspectionSummary?.request || 0,\n pass: buildingInspectionSummary?.pass || 0,\n fail: buildingInspectionSummary?.fail || 0\n }\n }\n\n // 층 별로 검수 개수 써머리\n @FieldResolver(type => BuildingInspectionSummary)\n async buildingInspectionSummary(@Root() buildingLevel: BuildingLevel): Promise<BuildingInspectionSummary> {\n const buildingInspectionSummary = await getRepository(BuildingInspection)\n .createQueryBuilder('bi')\n .select(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)\n .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)\n .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)\n .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)\n .where('bi.building_level_id = :buildingLevelId', { buildingLevelId: buildingLevel.id })\n .groupBy('bi.building_level_id')\n .getRawOne()\n\n return {\n wait: buildingInspectionSummary?.wait || 0,\n request: buildingInspectionSummary?.request || 0,\n pass: buildingInspectionSummary?.pass || 0,\n fail: buildingInspectionSummary?.fail || 0\n }\n }\n\n @Query(returns => BuildingInspectionSummary, { description: '프로젝트의 검측상태 별 카운트' })\n async buildingInspectionSummaryOfProject(\n @Arg('projectId') projectId: string,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionSummary> {\n const { domain } = context.state\n\n const result = await getRepository(Project)\n .createQueryBuilder('p')\n .select(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)\n .addSelect(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)\n .addSelect(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)\n .addSelect(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)\n .innerJoin('p.buildingComplex', 'bc')\n .innerJoin('bc.buildings', 'b')\n .innerJoin('b.buildingLevels', 'bl')\n .leftJoin('building_inspections', 'bi', 'bi.building_level_id = bl.id AND bi.deleted_at IS NULL')\n .where('p.domain = :domain', { domain: domain.id })\n .andWhere('p.id = :projectId', { projectId })\n .groupBy('p.id')\n .getRawOne()\n\n return {\n wait: result.wait || 0,\n request: result.request || 0,\n pass: result.pass || 0,\n fail: result.fail || 0\n }\n }\n\n @FieldResolver(type => Checklist)\n async checklist(@Root() buildingInspection: BuildingInspection): Promise<Checklist> {\n return await getRepository(Checklist).findOneBy({ id: buildingInspection.checklistId })\n }\n\n @FieldResolver(type => BuildingLevel)\n async buildingLevel(@Root() buildingInspection: BuildingInspection): Promise<BuildingLevel> {\n return await getRepository(BuildingLevel).findOneBy({ id: buildingInspection.buildingLevelId })\n }\n\n @FieldResolver(type => [Attachment])\n async attatchments(@Root() buildingInspection: BuildingInspection): Promise<Attachment[] | undefined> {\n const attachment: Attachment[] = await getRepository(Attachment).find({\n where: {\n refType: BuildingInspection.name,\n refBy: buildingInspection.id\n }\n })\n return attachment\n }\n}\n"]}
|