@dssp/supervision 1.0.0-alpha.8 → 1.0.0-y.0
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/dist-client/graphql/building-inspection.d.ts +1 -0
- package/dist-client/graphql/building-inspection.js +100 -0
- package/dist-client/graphql/building-inspection.js.map +1 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-ai-defect.d.ts +22 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-ai-defect.js +169 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-ai-defect.js.map +1 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-ai-measurement.d.ts +57 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-ai-measurement.js +825 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-ai-measurement.js.map +1 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-camera.d.ts +8 -6
- package/dist-client/pages/building-inspection/building-inspection-detail-camera.js +115 -65
- package/dist-client/pages/building-inspection/building-inspection-detail-camera.js.map +1 -1
- package/dist-client/pages/building-inspection/building-inspection-detail-checklist.d.ts +9 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js +130 -72
- package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js.map +1 -1
- package/dist-client/pages/building-inspection/building-inspection-detail-drawing.d.ts +1 -0
- package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js +77 -14
- package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js.map +1 -1
- package/dist-client/pages/building-inspection/building-inspection-list.d.ts +18 -2
- package/dist-client/pages/building-inspection/building-inspection-list.js +358 -27
- package/dist-client/pages/building-inspection/building-inspection-list.js.map +1 -1
- package/dist-client/pages/building-inspection/component/building-inspection-detail-header.d.ts +3 -0
- package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js +104 -17
- package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js.map +1 -1
- package/dist-client/pages/building-inspection/component/daily-worklog-popup.d.ts +27 -0
- package/dist-client/pages/building-inspection/component/daily-worklog-popup.js +542 -0
- package/dist-client/pages/building-inspection/component/daily-worklog-popup.js.map +1 -0
- package/dist-client/pages/building-inspection/component/image-preview-popup.d.ts +15 -0
- package/dist-client/pages/building-inspection/component/image-preview-popup.js +351 -0
- package/dist-client/pages/building-inspection/component/image-preview-popup.js.map +1 -0
- package/dist-client/pages/building-inspection/component/inspection-document/inspection-request-document.d.ts +20 -0
- package/dist-client/pages/building-inspection/component/inspection-document/inspection-request-document.js +432 -0
- package/dist-client/pages/building-inspection/component/inspection-document/inspection-request-document.js.map +1 -0
- package/dist-client/pages/building-inspection/component/inspection-document/inspection-result-notification.d.ts +30 -0
- package/dist-client/pages/building-inspection/component/inspection-document/inspection-result-notification.js +479 -0
- package/dist-client/pages/building-inspection/component/inspection-document/inspection-result-notification.js.map +1 -0
- package/dist-client/pages/building-inspection/component/inspection-document/photo-album-popup.d.ts +27 -0
- package/dist-client/pages/building-inspection/component/inspection-document/photo-album-popup.js +416 -0
- package/dist-client/pages/building-inspection/component/inspection-document/photo-album-popup.js.map +1 -0
- package/dist-client/pages/building-inspection/component/inspection-event-provider.d.ts +2 -1
- package/dist-client/pages/building-inspection/component/inspection-event-provider.js +39 -17
- package/dist-client/pages/building-inspection/component/inspection-event-provider.js.map +1 -1
- package/dist-client/pages/building-inspection/inspection-create-popup.js +17 -5
- package/dist-client/pages/building-inspection/inspection-create-popup.js.map +1 -1
- package/dist-client/pages/building-inspection-grid/building-inspection-grid-detail.d.ts +16 -2
- package/dist-client/pages/building-inspection-grid/building-inspection-grid-detail.js +245 -43
- package/dist-client/pages/building-inspection-grid/building-inspection-grid-detail.js.map +1 -1
- package/dist-client/pages/building-inspection-grid/component/grid-inspection-create-popup.js +8 -2
- package/dist-client/pages/building-inspection-grid/component/grid-inspection-create-popup.js.map +1 -1
- package/dist-client/pages/building-inspection-grid/component/grid-inspection-list-layer.d.ts +19 -0
- package/dist-client/pages/building-inspection-grid/component/grid-inspection-list-layer.js +205 -0
- package/dist-client/pages/building-inspection-grid/component/grid-inspection-list-layer.js.map +1 -0
- package/dist-client/pages/checklist/attachment-list-popup.d.ts +1 -0
- package/dist-client/pages/checklist/attachment-list-popup.js +250 -67
- package/dist-client/pages/checklist/attachment-list-popup.js.map +1 -1
- package/dist-client/pages/checklist/checklist-view.d.ts +5 -0
- package/dist-client/pages/checklist/checklist-view.js +95 -18
- package/dist-client/pages/checklist/checklist-view.js.map +1 -1
- package/dist-client/pages/checklist/comment-list-popup.js +14 -3
- package/dist-client/pages/checklist/comment-list-popup.js.map +1 -1
- package/dist-client/pages/checklist/file-preview-popup.js +0 -1
- package/dist-client/pages/checklist/file-preview-popup.js.map +1 -1
- package/dist-client/pages/checklist/inspection-info-popup.d.ts +50 -0
- package/dist-client/pages/checklist/inspection-info-popup.js +684 -0
- package/dist-client/pages/checklist/inspection-info-popup.js.map +1 -0
- package/dist-client/pages/checklist/inspection-tab-popup.d.ts +18 -0
- package/dist-client/pages/checklist/inspection-tab-popup.js +196 -0
- package/dist-client/pages/checklist/inspection-tab-popup.js.map +1 -0
- package/dist-client/pages/checklist-template/checklist-template-item.js +14 -3
- package/dist-client/pages/checklist-template/checklist-template-item.js.map +1 -1
- package/dist-client/pages/checklist-template/checklist-template-list.js +1 -1
- package/dist-client/pages/checklist-template/checklist-template-list.js.map +1 -1
- package/dist-client/route.d.ts +1 -1
- package/dist-client/route.js +6 -0
- package/dist-client/route.js.map +1 -1
- package/dist-client/tsconfig.tsbuildinfo +1 -1
- package/dist-server/service/building-inspection/building-inspection-mutation.d.ts +2 -3
- package/dist-server/service/building-inspection/building-inspection-mutation.js +73 -35
- package/dist-server/service/building-inspection/building-inspection-mutation.js.map +1 -1
- package/dist-server/service/building-inspection/building-inspection-query.d.ts +3 -5
- package/dist-server/service/building-inspection/building-inspection-query.js +16 -29
- package/dist-server/service/building-inspection/building-inspection-query.js.map +1 -1
- package/dist-server/service/building-inspection/building-inspection-type.d.ts +23 -7
- package/dist-server/service/building-inspection/building-inspection-type.js +80 -13
- package/dist-server/service/building-inspection/building-inspection-type.js.map +1 -1
- package/dist-server/service/building-inspection/building-inspection.d.ts +4 -0
- package/dist-server/service/building-inspection/building-inspection.js +17 -2
- package/dist-server/service/building-inspection/building-inspection.js.map +1 -1
- package/dist-server/service/building-inspection/index.d.ts +3 -4
- package/dist-server/service/building-inspection/index.js +10 -3
- package/dist-server/service/building-inspection/index.js.map +1 -1
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.d.ts +6 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.js +56 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.js.map +1 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-query.d.ts +16 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-query.js +171 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-query.js.map +1 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-type.d.ts +23 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-type.js +90 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-type.js.map +1 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog.d.ts +33 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog.js +132 -0
- package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog.js.map +1 -0
- package/dist-server/service/building-inspection-daily-worklog/index.d.ts +5 -0
- package/dist-server/service/building-inspection-daily-worklog/index.js +9 -0
- package/dist-server/service/building-inspection-daily-worklog/index.js.map +1 -0
- package/dist-server/service/building-inspection-history/building-inspection-history-query.d.ts +16 -0
- package/dist-server/service/building-inspection-history/building-inspection-history-query.js +120 -0
- package/dist-server/service/building-inspection-history/building-inspection-history-query.js.map +1 -0
- package/dist-server/service/building-inspection-history/building-inspection-history-type.d.ts +5 -0
- package/dist-server/service/building-inspection-history/building-inspection-history-type.js +21 -0
- package/dist-server/service/building-inspection-history/building-inspection-history-type.js.map +1 -0
- package/dist-server/service/building-inspection-history/building-inspection-history.d.ts +34 -0
- package/dist-server/service/building-inspection-history/building-inspection-history.js +157 -0
- package/dist-server/service/building-inspection-history/building-inspection-history.js.map +1 -0
- package/dist-server/service/building-inspection-history/event-subscriber.d.ts +7 -0
- package/dist-server/service/building-inspection-history/event-subscriber.js +21 -0
- package/dist-server/service/building-inspection-history/event-subscriber.js.map +1 -0
- package/dist-server/service/building-inspection-history/index.d.ts +6 -0
- package/dist-server/service/building-inspection-history/index.js +10 -0
- package/dist-server/service/building-inspection-history/index.js.map +1 -0
- package/dist-server/service/checklist/checklist-mutation.d.ts +0 -5
- package/dist-server/service/checklist/checklist-mutation.js +1 -67
- package/dist-server/service/checklist/checklist-mutation.js.map +1 -1
- package/dist-server/service/checklist/checklist-query.d.ts +7 -0
- package/dist-server/service/checklist/checklist-query.js +83 -0
- package/dist-server/service/checklist/checklist-query.js.map +1 -1
- package/dist-server/service/checklist/checklist-type.d.ts +0 -13
- package/dist-server/service/checklist/checklist-type.js +1 -49
- package/dist-server/service/checklist/checklist-type.js.map +1 -1
- package/dist-server/service/checklist/checklist.d.ts +28 -3
- package/dist-server/service/checklist/checklist.js +89 -15
- package/dist-server/service/checklist/checklist.js.map +1 -1
- 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 +1 -2
- package/dist-server/service/checklist/index.js +1 -2
- package/dist-server/service/checklist/index.js.map +1 -1
- package/dist-server/service/checklist-history/checklist-history-query.d.ts +11 -0
- package/dist-server/service/checklist-history/checklist-history-query.js +77 -0
- package/dist-server/service/checklist-history/checklist-history-query.js.map +1 -0
- package/dist-server/service/checklist-history/checklist-history-type.d.ts +5 -0
- package/dist-server/service/checklist-history/checklist-history-type.js +21 -0
- package/dist-server/service/checklist-history/checklist-history-type.js.map +1 -0
- package/dist-server/service/{checklist → checklist-history}/checklist-history.d.ts +19 -1
- package/dist-server/service/{checklist → checklist-history}/checklist-history.js +97 -14
- package/dist-server/service/checklist-history/checklist-history.js.map +1 -0
- package/dist-server/service/checklist-history/event-subscriber.d.ts +7 -0
- package/dist-server/service/checklist-history/event-subscriber.js +21 -0
- package/dist-server/service/checklist-history/event-subscriber.js.map +1 -0
- package/dist-server/service/checklist-history/index.d.ts +6 -0
- package/dist-server/service/checklist-history/index.js +10 -0
- package/dist-server/service/checklist-history/index.js.map +1 -0
- package/dist-server/service/checklist-item/checklist-item-query.d.ts +1 -1
- package/dist-server/service/checklist-item/checklist-item-query.js +5 -3
- package/dist-server/service/checklist-item/checklist-item-query.js.map +1 -1
- package/dist-server/service/checklist-item/index.d.ts +0 -1
- package/dist-server/service/checklist-item/index.js +1 -2
- package/dist-server/service/checklist-item/index.js.map +1 -1
- package/dist-server/service/checklist-item-comment/checklist-item-comment-mutation.d.ts +1 -0
- package/dist-server/service/checklist-item-comment/checklist-item-comment-mutation.js +33 -6
- package/dist-server/service/checklist-item-comment/checklist-item-comment-mutation.js.map +1 -1
- package/dist-server/service/checklist-item-history/checklist-item-history-query.d.ts +16 -0
- package/dist-server/service/checklist-item-history/checklist-item-history-query.js +123 -0
- package/dist-server/service/checklist-item-history/checklist-item-history-query.js.map +1 -0
- package/dist-server/service/checklist-item-history/checklist-item-history-type.d.ts +5 -0
- package/dist-server/service/checklist-item-history/checklist-item-history-type.js +21 -0
- package/dist-server/service/checklist-item-history/checklist-item-history-type.js.map +1 -0
- package/dist-server/service/checklist-item-history/checklist-item-history.d.ts +25 -0
- package/dist-server/service/checklist-item-history/checklist-item-history.js +123 -0
- package/dist-server/service/checklist-item-history/checklist-item-history.js.map +1 -0
- package/dist-server/service/checklist-item-history/event-subscriber.d.ts +7 -0
- package/dist-server/service/checklist-item-history/event-subscriber.js +21 -0
- package/dist-server/service/checklist-item-history/event-subscriber.js.map +1 -0
- package/dist-server/service/checklist-item-history/index.d.ts +6 -0
- package/dist-server/service/checklist-item-history/index.js +10 -0
- package/dist-server/service/checklist-item-history/index.js.map +1 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js +4 -1
- package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js.map +1 -1
- package/dist-server/service/checklist-template-item/checklist-template-item-type.d.ts +2 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-type.js +5 -0
- package/dist-server/service/checklist-template-item/checklist-template-item-type.js.map +1 -1
- package/dist-server/service/checklist-template-item/checklist-template-item.d.ts +6 -0
- package/dist-server/service/checklist-template-item/checklist-template-item.js +16 -1
- package/dist-server/service/checklist-template-item/checklist-template-item.js.map +1 -1
- package/dist-server/service/checklist-template-item/spec-matching-service.d.ts +2 -0
- package/dist-server/service/checklist-template-item/spec-matching-service.js +50 -0
- package/dist-server/service/checklist-template-item/spec-matching-service.js.map +1 -0
- package/dist-server/service/index.d.ts +4 -1
- package/dist-server/service/index.js +22 -3
- package/dist-server/service/index.js.map +1 -1
- package/dist-server/service/project-report/project-report.d.ts +0 -2
- package/dist-server/service/project-report/project-report.js +0 -6
- package/dist-server/service/project-report/project-report.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/things-factory.config.js +2 -0
- package/dist-server/service/building-inspection/building-inspection-history.d.ts +0 -17
- package/dist-server/service/building-inspection/building-inspection-history.js +0 -86
- package/dist-server/service/building-inspection/building-inspection-history.js.map +0 -1
- package/dist-server/service/checklist/checklist-history.js.map +0 -1
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { BuildingInspection } from './building-inspection';
|
|
2
|
-
import { NewBuildingInspection,
|
|
2
|
+
import { NewBuildingInspection, UpdateBuildingInspection, UpdateBuildingInspectionSubmitType } from './building-inspection-type';
|
|
3
3
|
export declare class BuildingInspectionMutation {
|
|
4
4
|
createBuildingInspection(patch: NewBuildingInspection, context: ResolverContext): Promise<BuildingInspection>;
|
|
5
5
|
updateBuildingInspectionChecklist(buildingInspection: UpdateBuildingInspectionSubmitType, context: ResolverContext): Promise<boolean>;
|
|
6
|
-
updateBuildingInspection(patch:
|
|
6
|
+
updateBuildingInspection(patch: UpdateBuildingInspection, context: ResolverContext): Promise<BuildingInspection>;
|
|
7
7
|
deleteBuildingInspections(ids: string[], context: ResolverContext): Promise<boolean>;
|
|
8
8
|
applyToAllBuildingInspection(buildingInspectionId: string, context: ResolverContext): Promise<boolean>;
|
|
9
|
-
getRecentDocumentNoByBuildingLevelId(buildingLevelId: string): Promise<string>;
|
|
10
9
|
}
|
|
@@ -12,6 +12,7 @@ const checklist_item_1 = require("../checklist-item/checklist-item");
|
|
|
12
12
|
const shell_1 = require("@things-factory/shell");
|
|
13
13
|
const building_complex_1 = require("@dssp/building-complex");
|
|
14
14
|
const env_1 = require("@things-factory/env");
|
|
15
|
+
const checklist_2 = require("../checklist/checklist");
|
|
15
16
|
const projectType = env_1.config.get('projectType', building_inspection_1.ProjectType.DSSP);
|
|
16
17
|
let BuildingInspectionMutation = class BuildingInspectionMutation {
|
|
17
18
|
async createBuildingInspection(patch, context) {
|
|
@@ -21,12 +22,12 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
|
|
|
21
22
|
const checklistRepository = tx.getRepository(checklist_1.Checklist);
|
|
22
23
|
const checklistItemRepository = tx.getRepository(checklist_item_1.ChecklistItem);
|
|
23
24
|
// 1. 벨리데이션
|
|
24
|
-
if (!
|
|
25
|
-
throw new Error('
|
|
25
|
+
if (!checklist.constructionType)
|
|
26
|
+
throw new Error('공종 타입이 없습니다.');
|
|
27
|
+
if (!checklist.constructionDetailType)
|
|
28
|
+
throw new Error('상세 공종 타입이 없습니다.');
|
|
26
29
|
if (!checklist.name)
|
|
27
30
|
throw new Error('체크리스트 이름이 없습니다.');
|
|
28
|
-
if (!checklist.location)
|
|
29
|
-
throw new Error('위치가 없습니다.');
|
|
30
31
|
if (checklistItem.length === 0)
|
|
31
32
|
throw new Error('체크리스트 아이템이 없습니다.');
|
|
32
33
|
if (projectType === building_inspection_1.ProjectType.DSSP) {
|
|
@@ -34,21 +35,27 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
|
|
|
34
35
|
throw new Error('셀 좌표가 없습니다.');
|
|
35
36
|
if (!managerId)
|
|
36
37
|
throw new Error('담당자가 없습니다.');
|
|
38
|
+
if (!buildingLevelId)
|
|
39
|
+
throw new Error('층 아이디가 없습니다.');
|
|
40
|
+
if (!checklist.location)
|
|
41
|
+
throw new Error('위치가 없습니다.');
|
|
37
42
|
}
|
|
38
43
|
else if (projectType === building_inspection_1.ProjectType.DCSP) {
|
|
39
|
-
if (!checklist.constructionType)
|
|
40
|
-
throw new Error('공종 타입이 없습니다.');
|
|
41
|
-
if (!checklist.constructionDetailType)
|
|
42
|
-
throw new Error('상세 공종 타입이 없습니다.');
|
|
43
44
|
if (!checklist.inspectionDrawingType)
|
|
44
45
|
throw new Error('검측 도면 타입이 없습니다.');
|
|
45
46
|
if (checklist.inspectionParts.length === 0)
|
|
46
47
|
throw new Error('검측 부위가 없습니다.');
|
|
48
|
+
if (!buildingLevelId)
|
|
49
|
+
throw new Error('층 아이디가 없습니다.');
|
|
50
|
+
if (!checklist.location)
|
|
51
|
+
throw new Error('위치가 없습니다.');
|
|
47
52
|
}
|
|
48
53
|
// 2. checklist 저장
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
54
|
+
const checklistDocumentNo = await getRecentDocumentNoByBuildingLevelId(buildingLevelId, checklist_1.DocumentNoType.CHECKLIST, tx);
|
|
55
|
+
const inspectionRequestDocumentNo = checklistDocumentNo.replace(`검측 제${checklist_1.DocumentNoType.CHECKLIST}-`, `검측 제${checklist_1.DocumentNoType.INSPECTION_REQUEST}-`);
|
|
56
|
+
const inspectionResultDocumentNo = checklistDocumentNo.replace(`검측 제${checklist_1.DocumentNoType.CHECKLIST}-`, `검측 제${checklist_1.DocumentNoType.INSPECTION_RESULT}-`);
|
|
57
|
+
const savedChecklist = await checklistRepository.save(Object.assign(Object.assign({}, checklist), { projectType, checklistReferenceType: checklist_2.ChecklistReferenceType.INSPECTION, documentNo: checklistDocumentNo, inspectionRequestDocumentNo,
|
|
58
|
+
inspectionResultDocumentNo, creator: user, updater: user }));
|
|
52
59
|
// 3. checklistItem 저장
|
|
53
60
|
const checklistItems = checklistItem.map((item, idx) => ({
|
|
54
61
|
name: item.name,
|
|
@@ -78,7 +85,7 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
|
|
|
78
85
|
// 검측 상태 변경 & 체크리스트 갱신
|
|
79
86
|
async updateBuildingInspectionChecklist(buildingInspection, context) {
|
|
80
87
|
const { user, tx } = context.state;
|
|
81
|
-
const { id: buildingInspectionId, checklist, checklistItem } = buildingInspection;
|
|
88
|
+
const { id: buildingInspectionId, memo, checklist, checklistItem } = buildingInspection;
|
|
82
89
|
const buildingInspectionRepo = tx.getRepository(building_inspection_1.BuildingInspection);
|
|
83
90
|
const checklistRepo = tx.getRepository(checklist_1.Checklist);
|
|
84
91
|
const checklistItemRepo = tx.getRepository(checklist_item_1.ChecklistItem);
|
|
@@ -88,6 +95,9 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
|
|
|
88
95
|
status == building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT ||
|
|
89
96
|
status == building_inspection_2.BuildingInspectionStatus.FAIL;
|
|
90
97
|
let inspectionStatus = null;
|
|
98
|
+
let signedUserType = null; // 싸인을 한 유저 타입
|
|
99
|
+
let inspectionRequestData = {};
|
|
100
|
+
let inspectionResultData = {};
|
|
91
101
|
// 1. 벨리데이션
|
|
92
102
|
if (!buildingInspectionId)
|
|
93
103
|
throw new Error('검측 아이디가 없습니다.');
|
|
@@ -117,12 +127,18 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
|
|
|
117
127
|
else if (isPassed && (status === building_inspection_2.BuildingInspectionStatus.WAIT || status === building_inspection_2.BuildingInspectionStatus.FAIL)) {
|
|
118
128
|
// 2. 검측이 합격이면서 공종 시공자 스탭 = 상태는 총괄 시공자 스탭으로
|
|
119
129
|
inspectionStatus = building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT;
|
|
130
|
+
signedUserType = 'taskConstructor';
|
|
120
131
|
}
|
|
121
132
|
else if (isPassed && status === building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT) {
|
|
122
133
|
// 3. 검측이 합격이면서 총괄 시공자 스탭 = 상태는 공종 감리자 스탭으로, 감리자 싸인은 모두 초기화
|
|
123
134
|
inspectionStatus = building_inspection_2.BuildingInspectionStatus.REQUEST;
|
|
124
135
|
checklist.overallSupervisorySignature = null;
|
|
125
136
|
checklist.taskSupervisorySignature = null;
|
|
137
|
+
signedUserType = 'overallConstructor';
|
|
138
|
+
inspectionRequestData = {
|
|
139
|
+
inspectionRequestMemo: checklist.inspectionRequestMemo,
|
|
140
|
+
inspectionRequestUpdatedAt: new Date()
|
|
141
|
+
};
|
|
126
142
|
}
|
|
127
143
|
}
|
|
128
144
|
else {
|
|
@@ -147,18 +163,27 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
|
|
|
147
163
|
else if (isPassed && status === building_inspection_2.BuildingInspectionStatus.REQUEST) {
|
|
148
164
|
// 2. 검측이 합격이면서 공종 감리자 스탭 = 상태는 총괄 감리자 스탭으로
|
|
149
165
|
inspectionStatus = building_inspection_2.BuildingInspectionStatus.OVERALL_REQUEST;
|
|
166
|
+
signedUserType = 'taskSupervisory';
|
|
150
167
|
}
|
|
151
168
|
else if (isPassed && status === building_inspection_2.BuildingInspectionStatus.OVERALL_REQUEST) {
|
|
152
169
|
// 3. 검측이 합격이면서 총괄 감리자 스탭 = 상태는 합격으로
|
|
153
170
|
inspectionStatus = building_inspection_2.BuildingInspectionStatus.PASS;
|
|
171
|
+
signedUserType = 'overallSupervisory';
|
|
172
|
+
inspectionResultData = {
|
|
173
|
+
inspectionResultStatus: checklist.inspectionResultStatus,
|
|
174
|
+
inspectionResultMemo: checklist.inspectionResultMemo,
|
|
175
|
+
inspectionResultType: checklist.inspectionResultType,
|
|
176
|
+
inspectionResultUpdatedAt: new Date()
|
|
177
|
+
};
|
|
154
178
|
}
|
|
155
179
|
}
|
|
156
180
|
// 2. buildingInspection 저장
|
|
157
|
-
await buildingInspectionRepo.save(Object.assign(Object.assign({}, oldBuildingInspection), { status: inspectionStatus, updater: user }));
|
|
181
|
+
await buildingInspectionRepo.save(Object.assign(Object.assign({}, oldBuildingInspection), { status: inspectionStatus, memo: memo, updater: user }));
|
|
158
182
|
// 3. checklist 저장
|
|
159
183
|
const oldChecklist = await checklistRepo.findOneBy({ id: checklist.id });
|
|
160
184
|
const inspectionDateField = isConstructor ? 'constructionInspectionDate' : 'supervisorInspectionDate';
|
|
161
|
-
|
|
185
|
+
const signedUser = signedUserType ? { [signedUserType]: user } : {};
|
|
186
|
+
await checklistRepo.save(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, oldChecklist), { [inspectionDateField]: new Date(), overallConstructorSignature: checklist.overallConstructorSignature, taskConstructorSignature: checklist.taskConstructorSignature, overallSupervisorySignature: checklist.overallSupervisorySignature, taskSupervisorySignature: checklist.taskSupervisorySignature }), signedUser), inspectionRequestData), inspectionResultData), { updater: user }));
|
|
162
187
|
// 4. checklistItem 저장
|
|
163
188
|
for (let item of checklistItem) {
|
|
164
189
|
const confirmStatusField = isConstructor ? 'constructionConfirmStatus' : 'supervisoryConfirmStatus';
|
|
@@ -259,26 +284,6 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
|
|
|
259
284
|
}
|
|
260
285
|
return true;
|
|
261
286
|
}
|
|
262
|
-
async getRecentDocumentNoByBuildingLevelId(buildingLevelId) {
|
|
263
|
-
var _a, _b;
|
|
264
|
-
const buildingLevel = await (0, shell_1.getRepository)(building_complex_1.BuildingLevel).findOne({
|
|
265
|
-
where: { id: buildingLevelId },
|
|
266
|
-
relations: ['building']
|
|
267
|
-
});
|
|
268
|
-
const buildingName = ((_b = (_a = buildingLevel.building.name.match(/\d+/g)) === null || _a === void 0 ? void 0 : _a.join('')) === null || _b === void 0 ? void 0 : _b.padStart(4, '0')) || '0000';
|
|
269
|
-
const floorName = buildingLevel.floor.toString().padStart(3, '0');
|
|
270
|
-
const latestChecklist = await (0, shell_1.getRepository)(checklist_1.Checklist)
|
|
271
|
-
.createQueryBuilder('c')
|
|
272
|
-
.where('c.document_no LIKE :pattern', { pattern: `${buildingName}-${floorName}-%` })
|
|
273
|
-
.orderBy('c.created_at', 'DESC')
|
|
274
|
-
.getOne();
|
|
275
|
-
let documentNo = '000001';
|
|
276
|
-
if (latestChecklist) {
|
|
277
|
-
const lastNo = latestChecklist.documentNo.split('-')[2];
|
|
278
|
-
documentNo = (Number(lastNo) + 1).toString().padStart(6, '0');
|
|
279
|
-
}
|
|
280
|
-
return `${buildingName}-${floorName}-${documentNo}`;
|
|
281
|
-
}
|
|
282
287
|
};
|
|
283
288
|
exports.BuildingInspectionMutation = BuildingInspectionMutation;
|
|
284
289
|
tslib_1.__decorate([
|
|
@@ -305,7 +310,7 @@ tslib_1.__decorate([
|
|
|
305
310
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('patch')),
|
|
306
311
|
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
307
312
|
tslib_1.__metadata("design:type", Function),
|
|
308
|
-
tslib_1.__metadata("design:paramtypes", [building_inspection_type_1.
|
|
313
|
+
tslib_1.__metadata("design:paramtypes", [building_inspection_type_1.UpdateBuildingInspection, Object]),
|
|
309
314
|
tslib_1.__metadata("design:returntype", Promise)
|
|
310
315
|
], BuildingInspectionMutation.prototype, "updateBuildingInspection", null);
|
|
311
316
|
tslib_1.__decorate([
|
|
@@ -329,4 +334,37 @@ tslib_1.__decorate([
|
|
|
329
334
|
exports.BuildingInspectionMutation = BuildingInspectionMutation = tslib_1.__decorate([
|
|
330
335
|
(0, type_graphql_1.Resolver)(building_inspection_1.BuildingInspection)
|
|
331
336
|
], BuildingInspectionMutation);
|
|
337
|
+
async function getRecentDocumentNoByBuildingLevelId(buildingLevelId, type, tx) {
|
|
338
|
+
const project = await tx
|
|
339
|
+
.createQueryBuilder()
|
|
340
|
+
.select('p.documentNaming', 'documentNaming')
|
|
341
|
+
.addSelect('bc.id', 'buildingComplexId')
|
|
342
|
+
.from('projects', 'p')
|
|
343
|
+
.innerJoin('building_complexes', 'bc', 'bc.id = p.building_complex_id')
|
|
344
|
+
.innerJoin('buildings', 'b', 'b.building_complex_id = bc.id')
|
|
345
|
+
.innerJoin('building_levels', 'bl', 'bl.building_id = b.id')
|
|
346
|
+
.where('bl.id = :buildingLevelId', { buildingLevelId })
|
|
347
|
+
.getRawOne();
|
|
348
|
+
const latestChecklist = await tx
|
|
349
|
+
.getRepository(checklist_1.Checklist)
|
|
350
|
+
.createQueryBuilder('c')
|
|
351
|
+
.innerJoin('c.buildingInspection', 'bi')
|
|
352
|
+
.innerJoin('bi.buildingLevel', 'bl')
|
|
353
|
+
.innerJoin('bl.building', 'b')
|
|
354
|
+
.where('b.building_complex_id = :buildingComplexId', { buildingComplexId: project.buildingComplexId })
|
|
355
|
+
.andWhere('c.document_no LIKE :pattern', { pattern: `${project.documentNaming} 검측 제${type}-%` })
|
|
356
|
+
.orderBy('c.created_at', 'DESC')
|
|
357
|
+
.getOne();
|
|
358
|
+
// 4. 시퀀스 번호 생성 (5자리)
|
|
359
|
+
let sequence = '00001';
|
|
360
|
+
if (latestChecklist) {
|
|
361
|
+
const documentNoPattern = new RegExp(`${project.documentNaming} 검측 제${type}-(\\d{5})호`);
|
|
362
|
+
const match = latestChecklist.documentNo.match(documentNoPattern);
|
|
363
|
+
if (match) {
|
|
364
|
+
sequence = (Number(match[1]) + 1).toString().padStart(5, '0');
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
// 5. 최종 문서 번호 생성
|
|
368
|
+
return `${project.documentNaming} 검측 제${type}-${sequence}호`;
|
|
369
|
+
}
|
|
332
370
|
//# sourceMappingURL=building-inspection-mutation.js.map
|
|
@@ -1 +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,+DAAuE;AACvE,yEAImC;AACnC,+DAAgE;AAChE,sDAAkD;AAClD,qEAAgE;AAChE,iDAAqD;AACrD,6DAAsD;AACtD,6CAA4C;AAC5C,MAAM,WAAW,GAAG,YAAM,CAAC,GAAG,CAAC,aAAa,EAAE,iCAAW,CAAC,IAAI,CAAC,CAAA;AAGxD,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,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;QACpF,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,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAA;QACrD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAA;QA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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;;;;2EAiCP;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,qCAAqC,EAAE,CAAC;IAElF,mBAAA,IAAA,kBAAG,EAAC,sBAAsB,CAAC,CAAA;IAC3B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;8EA0DP;qCAvTU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CA+UtC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { BuildingInspection, ProjectType } from './building-inspection'\nimport {\n NewBuildingInspection,\n UpdateBuildingInspectionDrawingMarker,\n UpdateBuildingInspectionSubmitType\n} 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'\nimport { config } from '@things-factory/env'\nconst projectType = config.get('projectType', ProjectType.DSSP)\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, cellX, cellY, managerId } = 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.location) throw new Error('위치가 없습니다.')\n if (checklistItem.length === 0) throw new Error('체크리스트 아이템이 없습니다.')\n\n if (projectType === ProjectType.DSSP) {\n if (!cellX || !cellY) throw new Error('셀 좌표가 없습니다.')\n if (!managerId) throw new Error('담당자가 없습니다.')\n } else if (projectType === ProjectType.DCSP) {\n if (!checklist.constructionType) throw new Error('공종 타입이 없습니다.')\n if (!checklist.constructionDetailType) throw new Error('상세 공종 타입이 없습니다.')\n if (!checklist.inspectionDrawingType) throw new Error('검측 도면 타입이 없습니다.')\n if (checklist.inspectionParts.length === 0) throw new Error('검측 부위가 없습니다.')\n }\n\n // 2. checklist 저장\n const documentNo = await this.getRecentDocumentNoByBuildingLevelId(buildingLevelId)\n const savedChecklist = await checklistRepository.save({\n ...checklist,\n projectType,\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 checklist: savedChecklist,\n projectType,\n manager: managerId ? { id: managerId } : null,\n cellX,\n cellY,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n // 검측 상태 변경 & 체크리스트 갱신\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To create Building Inspection And Checklist information' })\n async updateBuildingInspectionChecklist(\n @Arg('buildingInspection') buildingInspection: UpdateBuildingInspectionSubmitType,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { user, tx } = context.state\n const { id: buildingInspectionId, checklist, checklistItem } = buildingInspection\n const buildingInspectionRepo = tx.getRepository(BuildingInspection)\n const checklistRepo = tx.getRepository(Checklist)\n const checklistItemRepo = tx.getRepository(ChecklistItem)\n const oldBuildingInspection = await buildingInspectionRepo.findOneBy({ id: buildingInspectionId })\n const status = oldBuildingInspection.status\n const isConstructor: boolean =\n status == BuildingInspectionStatus.WAIT ||\n status == BuildingInspectionStatus.OVERALL_WAIT ||\n status == BuildingInspectionStatus.FAIL\n let inspectionStatus = null\n\n // 1. 벨리데이션\n if (!buildingInspectionId) throw new Error('검측 아이디가 없습니다.')\n if (!status) throw new Error('검측 상태가 없습니다.')\n if (status == BuildingInspectionStatus.PASS) throw new Error('검측 상태가 수정할 수 있는 상태가 아닙니다.')\n\n if (isConstructor) {\n // 시공자 타입별 밸리데이션\n if (checklistItem.length !== checklistItem.filter(v => v.constructionConfirmStatus).length) {\n throw new Error('아이템을 모두 체크해야 합니다.')\n }\n if (status == BuildingInspectionStatus.OVERALL_WAIT && !checklist.overallConstructorSignature) {\n throw new Error('총괄 시공책임자 사인이 없습니다.')\n }\n if (status == BuildingInspectionStatus.WAIT && !checklist.taskConstructorSignature) {\n throw new Error('공종별 시공관리자 사인이 없습니다.')\n }\n\n // 시공자 상태 데이터\n const isPassed = checklistItem.length === checklistItem.filter(v => v.constructionConfirmStatus === 'T').length\n\n if (!isPassed) {\n // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화\n inspectionStatus = BuildingInspectionStatus.FAIL\n checklist.overallConstructorSignature = null\n checklist.taskConstructorSignature = null\n } else if (isPassed && (status === BuildingInspectionStatus.WAIT || status === BuildingInspectionStatus.FAIL)) {\n // 2. 검측이 합격이면서 공종 시공자 스탭 = 상태는 총괄 시공자 스탭으로\n inspectionStatus = BuildingInspectionStatus.OVERALL_WAIT\n } else if (isPassed && status === BuildingInspectionStatus.OVERALL_WAIT) {\n // 3. 검측이 합격이면서 총괄 시공자 스탭 = 상태는 공종 감리자 스탭으로, 감리자 싸인은 모두 초기화\n inspectionStatus = BuildingInspectionStatus.REQUEST\n checklist.overallSupervisorySignature = null\n checklist.taskSupervisorySignature = null\n }\n } else {\n // 감리자 타입별 밸리데이션\n if (checklistItem.length !== checklistItem.filter(v => v.supervisoryConfirmStatus).length) {\n throw new Error('아이템을 모두 체크해야 합니다.')\n }\n if (status == BuildingInspectionStatus.OVERALL_REQUEST && !checklist.overallSupervisorySignature) {\n throw new Error('총괄 감리책임자 사인이 없습니다.')\n }\n if (status == BuildingInspectionStatus.REQUEST && !checklist.taskSupervisorySignature) {\n throw new Error('공종별 감리 책임자 사인이 없습니다.')\n }\n\n // 감리자 상태 데이터\n const isPassed = checklistItem.length === checklistItem.filter(v => v.supervisoryConfirmStatus === 'T').length\n if (!isPassed) {\n // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화\n inspectionStatus = BuildingInspectionStatus.FAIL\n checklist.overallConstructorSignature = null\n checklist.taskConstructorSignature = null\n } else if (isPassed && status === BuildingInspectionStatus.REQUEST) {\n // 2. 검측이 합격이면서 공종 감리자 스탭 = 상태는 총괄 감리자 스탭으로\n inspectionStatus = BuildingInspectionStatus.OVERALL_REQUEST\n } else if (isPassed && status === BuildingInspectionStatus.OVERALL_REQUEST) {\n // 3. 검측이 합격이면서 총괄 감리자 스탭 = 상태는 합격으로\n inspectionStatus = BuildingInspectionStatus.PASS\n }\n }\n\n // 2. buildingInspection 저장\n await buildingInspectionRepo.save({\n ...oldBuildingInspection,\n status: inspectionStatus,\n updater: user\n })\n\n // 3. checklist 저장\n const oldChecklist = await checklistRepo.findOneBy({ id: checklist.id })\n const inspectionDateField = isConstructor ? 'constructionInspectionDate' : 'supervisorInspectionDate'\n await checklistRepo.save({\n ...oldChecklist,\n [inspectionDateField]: new Date(),\n overallConstructorSignature: checklist.overallConstructorSignature,\n taskConstructorSignature: checklist.taskConstructorSignature,\n overallSupervisorySignature: checklist.overallSupervisorySignature,\n taskSupervisorySignature: checklist.taskSupervisorySignature,\n updater: user\n })\n\n // 4. checklistItem 저장\n for (let item of checklistItem) {\n const confirmStatusField = isConstructor ? 'constructionConfirmStatus' : 'supervisoryConfirmStatus'\n await checklistItemRepo.update(item.id, {\n [confirmStatusField]: item[confirmStatusField],\n updater: user\n })\n }\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => BuildingInspection, { description: 'To update Building Inspection information' })\n async updateBuildingInspection(\n @Arg('patch') patch: UpdateBuildingInspectionDrawingMarker,\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\n // 완료 상태인 검측데이터면 삭제 못함\n if (buildingInspection.status === BuildingInspectionStatus.PASS) {\n throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')\n }\n\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 { tx } = context.state\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n const checklistRepository = tx.getRepository(Checklist)\n const checklistItemRepository = tx.getRepository(ChecklistItem)\n\n const buildingInspections = await buildingInspectionRepository.createQueryBuilder('bi').whereInIds(ids).getMany()\n\n // 완료 상태인 검측데이터가 한개라도 있으면 삭제 못함\n if (buildingInspections.filter(bi => bi.status === BuildingInspectionStatus.PASS).length > 0) {\n throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')\n }\n\n // 검측 데이터 제거\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 @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To apply to all building inspection' })\n async applyToAllBuildingInspection(\n @Arg('buildingInspectionId') buildingInspectionId: string,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { user, tx } = context.state\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n\n const buildingInspection = await buildingInspectionRepository.findOne({\n where: { id: buildingInspectionId },\n relations: ['buildingLevel', 'buildingLevel.building', 'checklist', 'checklist.checklistItems']\n })\n\n const checklist = buildingInspection.checklist\n const checklistItems = checklist.checklistItems\n const buildingLevels = await getRepository(BuildingLevel).find({\n where: { building: { id: buildingInspection.buildingLevel.building.id } }\n })\n\n // 해당 검측 정보가 속한 동의 모든 층에 같은 검측 데이터 등록\n for (let buildingLevel of buildingLevels) {\n // 같은 셀에 이미 검측 정보가 있으면 패스\n const existInspection = await buildingInspectionRepository.findOneBy({\n buildingLevel: { id: buildingLevel.id },\n cellX: buildingInspection.cellX,\n cellY: buildingInspection.cellY\n })\n if (existInspection) continue\n\n // 새로운 체크리스트 데이터\n const newChecklist = {\n name: checklist.name,\n location: `${buildingInspection.buildingLevel.building.name} ${buildingLevel.floor}층`,\n constructionType: checklist.constructionType,\n constructionDetailType: checklist.constructionDetailType,\n inspectionDrawingType: checklist.inspectionDrawingType,\n inspectionParts: checklist.inspectionParts\n }\n\n // 새로운 체크리스트 아이템 데이터\n const newChecklistItems = checklistItems.map(item => ({\n name: item.name,\n mainType: item.mainType,\n detailType: item.detailType,\n inspctionCriteria: item.inspctionCriteria\n }))\n\n await this.createBuildingInspection(\n {\n buildingLevelId: buildingLevel.id,\n checklist: newChecklist,\n checklistItem: newChecklistItems,\n cellX: buildingInspection.cellX,\n cellY: buildingInspection.cellY,\n managerId: buildingInspection.managerId\n },\n context\n )\n }\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') || '0000'\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"]}
|
|
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,+DAAuE;AACvE,yEAAgI;AAChI,+DAAgE;AAChE,sDAAkE;AAClE,qEAAgE;AAChE,iDAAqD;AACrD,6DAAsD;AACtD,6CAA4C;AAC5C,sDAA+D;AAE/D,MAAM,WAAW,GAAG,YAAM,CAAC,GAAG,CAAC,aAAa,EAAE,iCAAW,CAAC,IAAI,CAAC,CAAA;AAGxD,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,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,GAA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G,OAAO,CAAC,cAAc,QAAQ,IAAI,YAAY,CAAC,CAAA;QACvF,MAAM,KAAK,GAAG,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACjE,IAAI,KAAK,EAAE,CAAC;YACV,QAAQ,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;QAC/D,CAAC;IACH,CAAC;IAED,iBAAiB;IACjB,OAAO,GAAG,OAAO,CAAC,cAAc,QAAQ,IAAI,IAAI,QAAQ,GAAG,CAAA;AAC7D,CAAC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { BuildingInspection, ProjectType } from './building-inspection'\nimport { NewBuildingInspection, UpdateBuildingInspection, UpdateBuildingInspectionSubmitType } from './building-inspection-type'\nimport { BuildingInspectionStatus } from './building-inspection'\nimport { Checklist, DocumentNoType } from '../checklist/checklist'\nimport { ChecklistItem } from '../checklist-item/checklist-item'\nimport { getRepository } from '@things-factory/shell'\nimport { BuildingLevel } from '@dssp/building-complex'\nimport { config } from '@things-factory/env'\nimport { ChecklistReferenceType } from '../checklist/checklist'\n\nconst projectType = config.get('projectType', ProjectType.DSSP)\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, cellX, cellY, managerId } = patch\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n const checklistRepository = tx.getRepository(Checklist)\n const checklistItemRepository = tx.getRepository(ChecklistItem)\n\n // 1. 벨리데이션\n if (!checklist.constructionType) throw new Error('공종 타입이 없습니다.')\n if (!checklist.constructionDetailType) throw new Error('상세 공종 타입이 없습니다.')\n if (!checklist.name) throw new Error('체크리스트 이름이 없습니다.')\n if (checklistItem.length === 0) throw new Error('체크리스트 아이템이 없습니다.')\n\n if (projectType === ProjectType.DSSP) {\n if (!cellX || !cellY) throw new Error('셀 좌표가 없습니다.')\n if (!managerId) throw new Error('담당자가 없습니다.')\n if (!buildingLevelId) throw new Error('층 아이디가 없습니다.')\n if (!checklist.location) throw new Error('위치가 없습니다.')\n } else if (projectType === ProjectType.DCSP) {\n if (!checklist.inspectionDrawingType) throw new Error('검측 도면 타입이 없습니다.')\n if (checklist.inspectionParts.length === 0) throw new Error('검측 부위가 없습니다.')\n if (!buildingLevelId) throw new Error('층 아이디가 없습니다.')\n if (!checklist.location) throw new Error('위치가 없습니다.')\n }\n\n // 2. checklist 저장\n const checklistDocumentNo = await getRecentDocumentNoByBuildingLevelId(buildingLevelId, DocumentNoType.CHECKLIST, tx)\n const inspectionRequestDocumentNo = checklistDocumentNo.replace(\n `검측 제${DocumentNoType.CHECKLIST}-`,\n `검측 제${DocumentNoType.INSPECTION_REQUEST}-`\n )\n const inspectionResultDocumentNo = checklistDocumentNo.replace(\n `검측 제${DocumentNoType.CHECKLIST}-`,\n `검측 제${DocumentNoType.INSPECTION_RESULT}-`\n )\n\n const savedChecklist = await checklistRepository.save({\n ...checklist,\n projectType,\n checklistReferenceType: ChecklistReferenceType.INSPECTION,\n documentNo: checklistDocumentNo,\n inspectionRequestDocumentNo,\n inspectionResultDocumentNo,\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 checklist: savedChecklist,\n projectType,\n manager: managerId ? { id: managerId } : null,\n cellX,\n cellY,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n // 검측 상태 변경 & 체크리스트 갱신\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To create Building Inspection And Checklist information' })\n async updateBuildingInspectionChecklist(\n @Arg('buildingInspection') buildingInspection: UpdateBuildingInspectionSubmitType,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { user, tx } = context.state\n const { id: buildingInspectionId, memo, checklist, checklistItem } = buildingInspection\n const buildingInspectionRepo = tx.getRepository(BuildingInspection)\n const checklistRepo = tx.getRepository(Checklist)\n const checklistItemRepo = tx.getRepository(ChecklistItem)\n const oldBuildingInspection = await buildingInspectionRepo.findOneBy({ id: buildingInspectionId })\n const status = oldBuildingInspection.status\n const isConstructor: boolean =\n status == BuildingInspectionStatus.WAIT ||\n status == BuildingInspectionStatus.OVERALL_WAIT ||\n status == BuildingInspectionStatus.FAIL\n let inspectionStatus = null\n let signedUserType = null // 싸인을 한 유저 타입\n let inspectionRequestData = {}\n let inspectionResultData = {}\n\n // 1. 벨리데이션\n if (!buildingInspectionId) throw new Error('검측 아이디가 없습니다.')\n if (!status) throw new Error('검측 상태가 없습니다.')\n if (status == BuildingInspectionStatus.PASS) throw new Error('검측 상태가 수정할 수 있는 상태가 아닙니다.')\n\n if (isConstructor) {\n // 시공자 타입별 밸리데이션\n if (checklistItem.length !== checklistItem.filter(v => v.constructionConfirmStatus).length) {\n throw new Error('아이템을 모두 체크해야 합니다.')\n }\n if (status == BuildingInspectionStatus.OVERALL_WAIT && !checklist.overallConstructorSignature) {\n throw new Error('총괄 시공책임자 사인이 없습니다.')\n }\n if (status == BuildingInspectionStatus.WAIT && !checklist.taskConstructorSignature) {\n throw new Error('공종별 시공관리자 사인이 없습니다.')\n }\n\n // 시공자 상태 데이터\n const isPassed = checklistItem.length === checklistItem.filter(v => v.constructionConfirmStatus === 'T').length\n\n if (!isPassed) {\n // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화\n inspectionStatus = BuildingInspectionStatus.FAIL\n checklist.overallConstructorSignature = null\n checklist.taskConstructorSignature = null\n } else if (isPassed && (status === BuildingInspectionStatus.WAIT || status === BuildingInspectionStatus.FAIL)) {\n // 2. 검측이 합격이면서 공종 시공자 스탭 = 상태는 총괄 시공자 스탭으로\n inspectionStatus = BuildingInspectionStatus.OVERALL_WAIT\n signedUserType = 'taskConstructor'\n } else if (isPassed && status === BuildingInspectionStatus.OVERALL_WAIT) {\n // 3. 검측이 합격이면서 총괄 시공자 스탭 = 상태는 공종 감리자 스탭으로, 감리자 싸인은 모두 초기화\n inspectionStatus = BuildingInspectionStatus.REQUEST\n checklist.overallSupervisorySignature = null\n checklist.taskSupervisorySignature = null\n signedUserType = 'overallConstructor'\n inspectionRequestData = {\n inspectionRequestMemo: checklist.inspectionRequestMemo,\n inspectionRequestUpdatedAt: new Date()\n }\n }\n } else {\n // 감리자 타입별 밸리데이션\n if (checklistItem.length !== checklistItem.filter(v => v.supervisoryConfirmStatus).length) {\n throw new Error('아이템을 모두 체크해야 합니다.')\n }\n if (status == BuildingInspectionStatus.OVERALL_REQUEST && !checklist.overallSupervisorySignature) {\n throw new Error('총괄 감리책임자 사인이 없습니다.')\n }\n if (status == BuildingInspectionStatus.REQUEST && !checklist.taskSupervisorySignature) {\n throw new Error('공종별 감리 책임자 사인이 없습니다.')\n }\n\n // 감리자 상태 데이터\n const isPassed = checklistItem.length === checklistItem.filter(v => v.supervisoryConfirmStatus === 'T').length\n if (!isPassed) {\n // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화\n inspectionStatus = BuildingInspectionStatus.FAIL\n checklist.overallConstructorSignature = null\n checklist.taskConstructorSignature = null\n } else if (isPassed && status === BuildingInspectionStatus.REQUEST) {\n // 2. 검측이 합격이면서 공종 감리자 스탭 = 상태는 총괄 감리자 스탭으로\n inspectionStatus = BuildingInspectionStatus.OVERALL_REQUEST\n signedUserType = 'taskSupervisory'\n } else if (isPassed && status === BuildingInspectionStatus.OVERALL_REQUEST) {\n // 3. 검측이 합격이면서 총괄 감리자 스탭 = 상태는 합격으로\n inspectionStatus = BuildingInspectionStatus.PASS\n signedUserType = 'overallSupervisory'\n inspectionResultData = {\n inspectionResultStatus: checklist.inspectionResultStatus,\n inspectionResultMemo: checklist.inspectionResultMemo,\n inspectionResultType: checklist.inspectionResultType,\n inspectionResultUpdatedAt: new Date()\n }\n }\n }\n\n // 2. buildingInspection 저장\n await buildingInspectionRepo.save({\n ...oldBuildingInspection,\n status: inspectionStatus,\n memo: memo,\n updater: user\n })\n\n // 3. checklist 저장\n const oldChecklist = await checklistRepo.findOneBy({ id: checklist.id })\n const inspectionDateField = isConstructor ? 'constructionInspectionDate' : 'supervisorInspectionDate'\n const signedUser = signedUserType ? { [signedUserType]: user } : {}\n\n await checklistRepo.save({\n ...oldChecklist,\n [inspectionDateField]: new Date(),\n overallConstructorSignature: checklist.overallConstructorSignature,\n taskConstructorSignature: checklist.taskConstructorSignature,\n overallSupervisorySignature: checklist.overallSupervisorySignature,\n taskSupervisorySignature: checklist.taskSupervisorySignature,\n ...signedUser,\n ...inspectionRequestData,\n ...inspectionResultData,\n updater: user\n })\n\n // 4. checklistItem 저장\n for (let item of checklistItem) {\n const confirmStatusField = isConstructor ? 'constructionConfirmStatus' : 'supervisoryConfirmStatus'\n await checklistItemRepo.update(item.id, {\n [confirmStatusField]: item[confirmStatusField],\n updater: user\n })\n }\n\n return true\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\n // 완료 상태인 검측데이터면 삭제 못함\n if (buildingInspection.status === BuildingInspectionStatus.PASS) {\n throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')\n }\n\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 { tx } = context.state\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n const checklistRepository = tx.getRepository(Checklist)\n const checklistItemRepository = tx.getRepository(ChecklistItem)\n\n const buildingInspections = await buildingInspectionRepository.createQueryBuilder('bi').whereInIds(ids).getMany()\n\n // 완료 상태인 검측데이터가 한개라도 있으면 삭제 못함\n if (buildingInspections.filter(bi => bi.status === BuildingInspectionStatus.PASS).length > 0) {\n throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')\n }\n\n // 검측 데이터 제거\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 @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To apply to all building inspection' })\n async applyToAllBuildingInspection(\n @Arg('buildingInspectionId') buildingInspectionId: string,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { user, tx } = context.state\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n\n const buildingInspection = await buildingInspectionRepository.findOne({\n where: { id: buildingInspectionId },\n relations: ['buildingLevel', 'buildingLevel.building', 'checklist', 'checklist.checklistItems']\n })\n\n const checklist = buildingInspection.checklist\n const checklistItems = checklist.checklistItems\n const buildingLevels = await getRepository(BuildingLevel).find({\n where: { building: { id: buildingInspection.buildingLevel.building.id } }\n })\n\n // 해당 검측 정보가 속한 동의 모든 층에 같은 검측 데이터 등록\n for (let buildingLevel of buildingLevels) {\n // 같은 셀에 이미 검측 정보가 있으면 패스\n const existInspection = await buildingInspectionRepository.findOneBy({\n buildingLevel: { id: buildingLevel.id },\n cellX: buildingInspection.cellX,\n cellY: buildingInspection.cellY\n })\n if (existInspection) continue\n\n // 새로운 체크리스트 데이터\n const newChecklist = {\n name: checklist.name,\n location: `${buildingInspection.buildingLevel.building.name} ${buildingLevel.floor}층`,\n constructionType: checklist.constructionType,\n constructionDetailType: checklist.constructionDetailType,\n inspectionDrawingType: checklist.inspectionDrawingType,\n inspectionParts: checklist.inspectionParts\n }\n\n // 새로운 체크리스트 아이템 데이터\n const newChecklistItems = checklistItems.map(item => ({\n name: item.name,\n mainType: item.mainType,\n detailType: item.detailType,\n inspctionCriteria: item.inspctionCriteria\n }))\n\n await this.createBuildingInspection(\n {\n buildingLevelId: buildingLevel.id,\n checklist: newChecklist,\n checklistItem: newChecklistItems,\n cellX: buildingInspection.cellX,\n cellY: buildingInspection.cellY,\n managerId: buildingInspection.managerId\n },\n context\n )\n }\n\n return true\n }\n}\n\nasync function getRecentDocumentNoByBuildingLevelId(buildingLevelId: string, type: DocumentNoType, tx: any): Promise<string> {\n const project = await tx\n .createQueryBuilder()\n .select('p.documentNaming', 'documentNaming')\n .addSelect('bc.id', 'buildingComplexId')\n .from('projects', 'p')\n .innerJoin('building_complexes', 'bc', 'bc.id = p.building_complex_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 .getRawOne()\n\n const latestChecklist = await tx\n .getRepository(Checklist)\n .createQueryBuilder('c')\n .innerJoin('c.buildingInspection', 'bi')\n .innerJoin('bi.buildingLevel', 'bl')\n .innerJoin('bl.building', 'b')\n .where('b.building_complex_id = :buildingComplexId', { buildingComplexId: project.buildingComplexId })\n .andWhere('c.document_no LIKE :pattern', { pattern: `${project.documentNaming} 검측 제${type}-%` })\n .orderBy('c.created_at', 'DESC')\n .getOne()\n\n // 4. 시퀀스 번호 생성 (5자리)\n let sequence = '00001'\n if (latestChecklist) {\n const documentNoPattern = new RegExp(`${project.documentNaming} 검측 제${type}-(\\\\d{5})호`)\n const match = latestChecklist.documentNo.match(documentNoPattern)\n if (match) {\n sequence = (Number(match[1]) + 1).toString().padStart(5, '0')\n }\n }\n\n // 5. 최종 문서 번호 생성\n return `${project.documentNaming} 검측 제${type}-${sequence}호`\n}\n"]}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import { Attachment } from '@things-factory/attachment-base';
|
|
2
2
|
import { ListParam } from '@things-factory/shell';
|
|
3
3
|
import { BuildingInspection } from './building-inspection';
|
|
4
|
-
import { BuildingInspectionList, BuildingInspectionsOfBuildingLevel, BuildingInspectionsOfProject, BuildingInspectionSummary } from './building-inspection-type';
|
|
4
|
+
import { BuildingInspectionList, BuildingInspectionsOfBuildingLevel, BuildingInspectionsOfProject, BuildingInspectionSummary, ProjectManagerOutput } from './building-inspection-type';
|
|
5
5
|
import { BuildingLevel } from '@dssp/building-complex';
|
|
6
6
|
import { Checklist } from '../checklist/checklist';
|
|
7
|
-
import { Project, ManagerOutput } from '@dssp/project';
|
|
8
7
|
export declare class BuildingInspectionQuery {
|
|
9
8
|
buildingInspection(id: string, context: ResolverContext): Promise<BuildingInspection>;
|
|
10
9
|
buildingInspections(params: ListParam, context: ResolverContext): Promise<BuildingInspectionList>;
|
|
11
10
|
buildingInspectionsOfProject(params: BuildingInspectionsOfProject, context: ResolverContext): Promise<BuildingInspectionList>;
|
|
12
|
-
projectByBuildingLevelId(buildingLevelId: string, context: ResolverContext): Promise<Project>;
|
|
13
11
|
buildingInspectionsOfBuildingLevel(params: BuildingInspectionsOfBuildingLevel, context: ResolverContext): Promise<BuildingInspectionList>;
|
|
14
12
|
buildingInspectionSummaryOfBuildingLevel(buildingLevelId: string, context: ResolverContext): Promise<BuildingInspectionSummary>;
|
|
15
13
|
buildingInspectionDateSummaryOfLevelAndPeriod(buildingLevelId: string, startDate: string, endDate: string, context: ResolverContext): Promise<BuildingInspectionSummary[]>;
|
|
@@ -17,6 +15,6 @@ export declare class BuildingInspectionQuery {
|
|
|
17
15
|
buildingInspectionSummaryOfProject(projectId: string, context: ResolverContext): Promise<BuildingInspectionSummary>;
|
|
18
16
|
checklist(buildingInspection: BuildingInspection): Promise<Checklist>;
|
|
19
17
|
buildingLevel(buildingInspection: BuildingInspection): Promise<BuildingLevel>;
|
|
20
|
-
|
|
21
|
-
manager(buildingInspection: BuildingInspection): Promise<
|
|
18
|
+
attachments(buildingInspection: BuildingInspection): Promise<Attachment[] | undefined>;
|
|
19
|
+
manager(buildingInspection: BuildingInspection): Promise<ProjectManagerOutput>;
|
|
22
20
|
}
|
|
@@ -9,7 +9,6 @@ const building_inspection_1 = require("./building-inspection");
|
|
|
9
9
|
const building_inspection_type_1 = require("./building-inspection-type");
|
|
10
10
|
const building_complex_1 = require("@dssp/building-complex");
|
|
11
11
|
const checklist_1 = require("../checklist/checklist");
|
|
12
|
-
const project_1 = require("@dssp/project");
|
|
13
12
|
const env_1 = require("@things-factory/env");
|
|
14
13
|
const auth_base_1 = require("@things-factory/auth-base");
|
|
15
14
|
const projectType = env_1.config.get('projectType', building_inspection_1.ProjectType.DSSP);
|
|
@@ -49,18 +48,8 @@ let BuildingInspectionQuery = class BuildingInspectionQuery {
|
|
|
49
48
|
const [items, total] = await queryBuilder.getManyAndCount();
|
|
50
49
|
return { items, total };
|
|
51
50
|
}
|
|
52
|
-
async projectByBuildingLevelId(buildingLevelId, context) {
|
|
53
|
-
const queryBuilder = (0, shell_1.getRepository)(project_1.Project)
|
|
54
|
-
.createQueryBuilder('p')
|
|
55
|
-
.innerJoin('building_complexes', 'bc', 'p.building_complex_id = bc.id')
|
|
56
|
-
.innerJoin('buildings', 'b', 'b.building_complex_id = bc.id')
|
|
57
|
-
.innerJoin('building_levels', 'bl', 'bl.building_id = b.id')
|
|
58
|
-
.where('bl.id = :buildingLevelId', { buildingLevelId });
|
|
59
|
-
const result = await queryBuilder.getOne();
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
51
|
async buildingInspectionsOfBuildingLevel(params, context) {
|
|
63
|
-
const { buildingLevelId, limit } = params;
|
|
52
|
+
const { buildingLevelId, limit, startDate, endDate } = params;
|
|
64
53
|
const queryBuilder = (0, shell_1.getRepository)(building_inspection_1.BuildingInspection)
|
|
65
54
|
.createQueryBuilder('bi')
|
|
66
55
|
.innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')
|
|
@@ -68,6 +57,12 @@ let BuildingInspectionQuery = class BuildingInspectionQuery {
|
|
|
68
57
|
.where('bl.id = :buildingLevelId', { buildingLevelId })
|
|
69
58
|
.andWhere('bi.project_type = :projectType', { projectType })
|
|
70
59
|
.orderBy('bi.updated_at', 'DESC');
|
|
60
|
+
if (startDate) {
|
|
61
|
+
queryBuilder.andWhere('bi.request_date >= :startDate', { startDate });
|
|
62
|
+
}
|
|
63
|
+
if (endDate) {
|
|
64
|
+
queryBuilder.andWhere('bi.request_date <= :endDate', { endDate });
|
|
65
|
+
}
|
|
71
66
|
if (limit) {
|
|
72
67
|
queryBuilder.limit(limit);
|
|
73
68
|
}
|
|
@@ -131,16 +126,16 @@ let BuildingInspectionQuery = class BuildingInspectionQuery {
|
|
|
131
126
|
}
|
|
132
127
|
async buildingInspectionSummaryOfProject(projectId, context) {
|
|
133
128
|
const { domain } = context.state;
|
|
134
|
-
const result = await (0, shell_1.getRepository)(
|
|
135
|
-
.createQueryBuilder('
|
|
129
|
+
const result = await (0, shell_1.getRepository)(building_inspection_1.BuildingInspection)
|
|
130
|
+
.createQueryBuilder('bi')
|
|
136
131
|
.select(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.WAIT}' OR bi.status='${building_inspection_1.BuildingInspectionStatus.OVERALL_WAIT}' THEN 1 ELSE NULL END) AS wait`)
|
|
137
132
|
.addSelect(`COUNT(CASE WHEN bi.status='${building_inspection_1.BuildingInspectionStatus.REQUEST}' OR bi.status='${building_inspection_1.BuildingInspectionStatus.OVERALL_REQUEST}' THEN 1 ELSE NULL END) AS request`)
|
|
138
133
|
.addSelect(`COUNT(CASE WHEN bi.status = '${building_inspection_1.BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
|
|
139
134
|
.addSelect(`COUNT(CASE WHEN bi.status = '${building_inspection_1.BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
|
|
140
|
-
.innerJoin('
|
|
141
|
-
.innerJoin('
|
|
142
|
-
.innerJoin('
|
|
143
|
-
.
|
|
135
|
+
.innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')
|
|
136
|
+
.innerJoin('buildings', 'b', 'bl.building_id = b.id')
|
|
137
|
+
.innerJoin('building_complexes', 'bc', 'b.building_complex_id = bc.id')
|
|
138
|
+
.innerJoin('projects', 'p', 'bc.id = p.building_complex_id')
|
|
144
139
|
.where('p.domain = :domain', { domain: domain.id })
|
|
145
140
|
.andWhere('p.id = :projectId', { projectId })
|
|
146
141
|
.andWhere('bi.project_type = :projectType', { projectType })
|
|
@@ -159,7 +154,7 @@ let BuildingInspectionQuery = class BuildingInspectionQuery {
|
|
|
159
154
|
async buildingLevel(buildingInspection) {
|
|
160
155
|
return await (0, shell_1.getRepository)(building_complex_1.BuildingLevel).findOneBy({ id: buildingInspection.buildingLevelId });
|
|
161
156
|
}
|
|
162
|
-
async
|
|
157
|
+
async attachments(buildingInspection) {
|
|
163
158
|
const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).find({
|
|
164
159
|
where: {
|
|
165
160
|
refType: building_inspection_1.BuildingInspection.name,
|
|
@@ -207,14 +202,6 @@ tslib_1.__decorate([
|
|
|
207
202
|
tslib_1.__metadata("design:paramtypes", [building_inspection_type_1.BuildingInspectionsOfProject, Object]),
|
|
208
203
|
tslib_1.__metadata("design:returntype", Promise)
|
|
209
204
|
], BuildingInspectionQuery.prototype, "buildingInspectionsOfProject", null);
|
|
210
|
-
tslib_1.__decorate([
|
|
211
|
-
(0, type_graphql_1.Query)(returns => project_1.Project, { description: 'To fetch Project' }),
|
|
212
|
-
tslib_1.__param(0, (0, type_graphql_1.Arg)('buildingLevelId')),
|
|
213
|
-
tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
|
|
214
|
-
tslib_1.__metadata("design:type", Function),
|
|
215
|
-
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
216
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
217
|
-
], BuildingInspectionQuery.prototype, "projectByBuildingLevelId", null);
|
|
218
205
|
tslib_1.__decorate([
|
|
219
206
|
(0, type_graphql_1.Query)(returns => building_inspection_type_1.BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' }),
|
|
220
207
|
tslib_1.__param(0, (0, type_graphql_1.Arg)('params')),
|
|
@@ -276,9 +263,9 @@ tslib_1.__decorate([
|
|
|
276
263
|
tslib_1.__metadata("design:type", Function),
|
|
277
264
|
tslib_1.__metadata("design:paramtypes", [building_inspection_1.BuildingInspection]),
|
|
278
265
|
tslib_1.__metadata("design:returntype", Promise)
|
|
279
|
-
], BuildingInspectionQuery.prototype, "
|
|
266
|
+
], BuildingInspectionQuery.prototype, "attachments", null);
|
|
280
267
|
tslib_1.__decorate([
|
|
281
|
-
(0, type_graphql_1.FieldResolver)(type =>
|
|
268
|
+
(0, type_graphql_1.FieldResolver)(type => building_inspection_type_1.ProjectManagerOutput),
|
|
282
269
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
283
270
|
tslib_1.__metadata("design:type", Function),
|
|
284
271
|
tslib_1.__metadata("design:paramtypes", [building_inspection_1.BuildingInspection]),
|
|
@@ -1 +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,+DAAiG;AACjG,yEAKmC;AACnC,6DAAsD;AACtD,sDAAkD;AAClD,2CAAsD;AACtD,6CAA4C;AAC5C,yDAAgD;AAEhD,MAAM,WAAW,GAAG,YAAM,CAAC,GAAG,CAAC,aAAa,EAAE,iCAAW,CAAC,IAAI,CAAC,CAAA;AAGxD,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,WAAW,EAAE;SAC3B,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,CAAC,QAAQ,CAAC,6BAA6B,EAAE,EAAE,WAAW,EAAE,CAAC,CAAA;QAE3D,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,YAAY,CAAC,eAAe,EAAE,CAAA;QAE3D,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAA;IACzB,CAAC;IAGK,AAAN,KAAK,CAAC,4BAA4B,CACjB,MAAoC,EAC5C,OAAwB;QAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAChC,MAAM,EAAE,SAAS,EAAE,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AC,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;;2DAShE;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,uBAAa,CAAC;IACtB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;sDAa3D;kCAxPU,uBAAuB;IADnC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,uBAAuB,CAyPnC","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, ProjectType } 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, ManagerOutput } from '@dssp/project'\nimport { config } from '@things-factory/env'\nimport { User } from '@things-factory/auth-base'\n\nconst projectType = config.get('projectType', ProjectType.DSSP)\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, projectType }\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 }).andWhere('project_type = :projectType', { projectType })\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('bi.project_type = :projectType', { projectType })\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 .andWhere('bi.project_type = :projectType', { projectType })\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(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' OR bi.status='${BuildingInspectionStatus.OVERALL_WAIT}' THEN 1 ELSE NULL END) AS wait`\n )\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' OR bi.status='${BuildingInspectionStatus.OVERALL_REQUEST}' THEN 1 ELSE NULL END) AS request`\n )\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 .andWhere('bi.project_type = :projectType', { projectType })\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 @Query(returns => [BuildingInspectionSummary]!, { nullable: true, description: 'To fetch a BuildingInspection Summary' })\n async buildingInspectionDateSummaryOfLevelAndPeriod(\n @Arg('buildingLevelId') buildingLevelId: string,\n @Arg('startDate') startDate: string,\n @Arg('endDate') endDate: string,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionSummary[]> {\n const buildingInspectionSummary = await getRepository(BuildingInspection)\n .createQueryBuilder('bi')\n .select(`TO_CHAR(bi.request_date, 'YYYY-MM-DD') AS \"requestDate\"`)\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' OR bi.status='${BuildingInspectionStatus.OVERALL_WAIT}' THEN 1 ELSE NULL END) AS wait`\n )\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' OR bi.status='${BuildingInspectionStatus.OVERALL_REQUEST}' THEN 1 ELSE NULL END) AS request`\n )\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 .andWhere('bi.request_date BETWEEN :startDate AND :endDate', { startDate, endDate })\n .andWhere('bi.project_type = :projectType', { projectType })\n .groupBy('bi.building_level_id')\n .addGroupBy('bi.request_date')\n .getRawMany()\n\n return buildingInspectionSummary\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(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' OR bi.status='${BuildingInspectionStatus.OVERALL_WAIT}' THEN 1 ELSE NULL END) AS wait`\n )\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' OR bi.status='${BuildingInspectionStatus.OVERALL_REQUEST}' THEN 1 ELSE NULL END) AS request`\n )\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 .andWhere('bi.project_type = :projectType', { projectType })\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(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' OR bi.status='${BuildingInspectionStatus.OVERALL_WAIT}' THEN 1 ELSE NULL END) AS wait`\n )\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' OR bi.status='${BuildingInspectionStatus.OVERALL_REQUEST}' THEN 1 ELSE NULL END) AS request`\n )\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 .andWhere('bi.project_type = :projectType', { projectType })\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\n return attachment\n }\n\n @FieldResolver(type => ManagerOutput)\n async manager(@Root() buildingInspection: BuildingInspection): Promise<ManagerOutput> {\n const queryBuilder = getRepository(User)\n .createQueryBuilder('u')\n .select('m.id', 'id')\n .addSelect('m.phone', 'phone')\n .addSelect('m.position', 'position')\n .addSelect('u.id', 'userId')\n .addSelect('u.name', 'name')\n .addSelect('u.updated_at', 'updatedAt')\n .leftJoin('managers', 'm', 'u.id = m.user_id')\n .where('u.id = :userId', { userId: buildingInspection.managerId })\n\n return await queryBuilder.getRawOne()\n }\n}\n"]}
|
|
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,+DAAiG;AACjG,yEAMmC;AACnC,6DAAsD;AACtD,sDAAkD;AAClD,6CAA4C;AAC5C,yDAAgD;AAEhD,MAAM,WAAW,GAAG,YAAM,CAAC,GAAG,CAAC,aAAa,EAAE,iCAAW,CAAC,IAAI,CAAC,CAAA;AAGxD,IAAM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AAE,CAAC,oDAAyB,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAgB,gCAAa;;wEAsBnE;AAGK;IADL,IAAA,oBAAK,EAAC,OAAO,CAAC,EAAE,CAAC,oDAAyB,EAAE,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAE9E,mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAChB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;iFA8BP;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;IACjB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;0DAS/D;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,+CAAoB,CAAC;IAC7B,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAqB,wCAAkB;;sDAa3D;kCA/OU,uBAAuB;IADnC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,uBAAuB,CAgPnC","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, ProjectType } from './building-inspection'\nimport {\n BuildingInspectionList,\n BuildingInspectionsOfBuildingLevel,\n BuildingInspectionsOfProject,\n BuildingInspectionSummary,\n ProjectManagerOutput\n} from './building-inspection-type'\nimport { BuildingLevel } from '@dssp/building-complex'\nimport { Checklist } from '../checklist/checklist'\nimport { config } from '@things-factory/env'\nimport { User } from '@things-factory/auth-base'\n\nconst projectType = config.get('projectType', ProjectType.DSSP)\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, projectType }\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 }).andWhere('project_type = :projectType', { projectType })\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('bi.project_type = :projectType', { projectType })\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 => 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, startDate, endDate } = 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 .andWhere('bi.project_type = :projectType', { projectType })\n .orderBy('bi.updated_at', 'DESC')\n\n if (startDate) {\n queryBuilder.andWhere('bi.request_date >= :startDate', { startDate })\n }\n\n if (endDate) {\n queryBuilder.andWhere('bi.request_date <= :endDate', { endDate })\n }\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(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' OR bi.status='${BuildingInspectionStatus.OVERALL_WAIT}' THEN 1 ELSE NULL END) AS wait`\n )\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' OR bi.status='${BuildingInspectionStatus.OVERALL_REQUEST}' THEN 1 ELSE NULL END) AS request`\n )\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 .andWhere('bi.project_type = :projectType', { projectType })\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 @Query(returns => [BuildingInspectionSummary]!, { nullable: true, description: 'To fetch a BuildingInspection Summary' })\n async buildingInspectionDateSummaryOfLevelAndPeriod(\n @Arg('buildingLevelId') buildingLevelId: string,\n @Arg('startDate') startDate: string,\n @Arg('endDate') endDate: string,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspectionSummary[]> {\n const buildingInspectionSummary = await getRepository(BuildingInspection)\n .createQueryBuilder('bi')\n .select(`TO_CHAR(bi.request_date, 'YYYY-MM-DD') AS \"requestDate\"`)\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' OR bi.status='${BuildingInspectionStatus.OVERALL_WAIT}' THEN 1 ELSE NULL END) AS wait`\n )\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' OR bi.status='${BuildingInspectionStatus.OVERALL_REQUEST}' THEN 1 ELSE NULL END) AS request`\n )\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 .andWhere('bi.request_date BETWEEN :startDate AND :endDate', { startDate, endDate })\n .andWhere('bi.project_type = :projectType', { projectType })\n .groupBy('bi.building_level_id')\n .addGroupBy('bi.request_date')\n .getRawMany()\n\n return buildingInspectionSummary\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(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' OR bi.status='${BuildingInspectionStatus.OVERALL_WAIT}' THEN 1 ELSE NULL END) AS wait`\n )\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' OR bi.status='${BuildingInspectionStatus.OVERALL_REQUEST}' THEN 1 ELSE NULL END) AS request`\n )\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 .andWhere('bi.project_type = :projectType', { projectType })\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(BuildingInspection)\n .createQueryBuilder('bi')\n .select(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' OR bi.status='${BuildingInspectionStatus.OVERALL_WAIT}' THEN 1 ELSE NULL END) AS wait`\n )\n .addSelect(\n `COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' OR bi.status='${BuildingInspectionStatus.OVERALL_REQUEST}' THEN 1 ELSE NULL END) AS request`\n )\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('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 .where('p.domain = :domain', { domain: domain.id })\n .andWhere('p.id = :projectId', { projectId })\n .andWhere('bi.project_type = :projectType', { projectType })\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 attachments(@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\n return attachment\n }\n\n @FieldResolver(type => ProjectManagerOutput)\n async manager(@Root() buildingInspection: BuildingInspection): Promise<ProjectManagerOutput> {\n const queryBuilder = getRepository(User)\n .createQueryBuilder('u')\n .select('m.id', 'id')\n .addSelect('m.phone', 'phone')\n .addSelect('m.position', 'position')\n .addSelect('u.id', 'userId')\n .addSelect('u.name', 'name')\n .addSelect('u.updated_at', 'updatedAt')\n .leftJoin('managers', 'm', 'u.id = m.user_id')\n .where('u.id = :userId', { userId: buildingInspection.managerId })\n\n return await queryBuilder.getRawOne()\n }\n}\n"]}
|