@dssp/supervision 0.0.36 → 1.0.0-alpha.1

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.
Files changed (106) hide show
  1. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js +1 -1
  2. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js.map +1 -1
  3. package/dist-client/pages/checklist/checklist-view.js +2 -5
  4. package/dist-client/pages/checklist/checklist-view.js.map +1 -1
  5. package/dist-client/route.d.ts +1 -1
  6. package/dist-client/tsconfig.tsbuildinfo +1 -1
  7. package/dist-server/service/index.d.ts +1 -1
  8. package/dist-server/tsconfig.tsbuildinfo +1 -1
  9. package/package.json +13 -13
  10. package/client/bootstrap.ts +0 -1
  11. package/client/index.ts +0 -0
  12. package/client/pages/action-plan/action-plan-importer.ts +0 -94
  13. package/client/pages/action-plan/action-plan-list-page.ts +0 -340
  14. package/client/pages/building-inspection/building-inspection-detail-camera.ts +0 -277
  15. package/client/pages/building-inspection/building-inspection-detail-checklist.ts +0 -258
  16. package/client/pages/building-inspection/building-inspection-detail-drawing.ts +0 -288
  17. package/client/pages/building-inspection/building-inspection-list.ts +0 -565
  18. package/client/pages/building-inspection/component/building-inspection-detail-header.ts +0 -123
  19. package/client/pages/building-inspection/component/inspection-event-provider.ts +0 -81
  20. package/client/pages/building-inspection/inspection-create-popup.ts +0 -785
  21. package/client/pages/checklist/attachment-list-popup.ts +0 -301
  22. package/client/pages/checklist/checklist-view.ts +0 -581
  23. package/client/pages/checklist/comment-list-popup.ts +0 -328
  24. package/client/pages/checklist/file-preview-popup.ts +0 -70
  25. package/client/pages/checklist-template/checklist-template-item.ts +0 -240
  26. package/client/pages/checklist-template/checklist-template-list.ts +0 -368
  27. package/client/pages/checklist-template/checklist-type-management.ts +0 -262
  28. package/client/pages/issue/issue-importer.ts +0 -94
  29. package/client/pages/issue/issue-list-page.ts +0 -340
  30. package/client/pages/project-report/project-report-importer.ts +0 -94
  31. package/client/pages/project-report/project-report-list-page.ts +0 -340
  32. package/client/pages/supervisor/supervisor-importer.ts +0 -94
  33. package/client/pages/supervisor/supervisor-list-page.ts +0 -340
  34. package/client/route.ts +0 -27
  35. package/client/tsconfig.json +0 -11
  36. package/dist-client/pages/checklist/comment-list-popup copy.d.ts +0 -2
  37. package/dist-client/pages/checklist/comment-list-popup copy.js +0 -344
  38. package/dist-client/pages/checklist/comment-list-popup copy.js.map +0 -1
  39. package/server/controllers/index.ts +0 -0
  40. package/server/index.ts +0 -4
  41. package/server/middlewares/index.ts +0 -3
  42. package/server/migrations/index.ts +0 -9
  43. package/server/routes.ts +0 -28
  44. package/server/service/action-plan/action-plan-mutation.ts +0 -198
  45. package/server/service/action-plan/action-plan-query.ts +0 -62
  46. package/server/service/action-plan/action-plan-type.ts +0 -61
  47. package/server/service/action-plan/action-plan.ts +0 -103
  48. package/server/service/action-plan/index.ts +0 -7
  49. package/server/service/building-inspection/building-inspection-history.ts +0 -72
  50. package/server/service/building-inspection/building-inspection-mutation.ts +0 -276
  51. package/server/service/building-inspection/building-inspection-query.ts +0 -242
  52. package/server/service/building-inspection/building-inspection-type.ts +0 -145
  53. package/server/service/building-inspection/building-inspection.ts +0 -108
  54. package/server/service/building-inspection/event-subscriber.ts +0 -20
  55. package/server/service/building-inspection/index.ts +0 -11
  56. package/server/service/checklist/checklist-history.ts +0 -96
  57. package/server/service/checklist/checklist-mutation.ts +0 -103
  58. package/server/service/checklist/checklist-query.ts +0 -58
  59. package/server/service/checklist/checklist-type.ts +0 -49
  60. package/server/service/checklist/checklist.ts +0 -127
  61. package/server/service/checklist/event-subscriber.ts +0 -17
  62. package/server/service/checklist/index.ts +0 -9
  63. package/server/service/checklist-item/checklist-item-mutation.ts +0 -5
  64. package/server/service/checklist-item/checklist-item-query.ts +0 -84
  65. package/server/service/checklist-item/checklist-item-type.ts +0 -12
  66. package/server/service/checklist-item/checklist-item.ts +0 -103
  67. package/server/service/checklist-item/index.ts +0 -7
  68. package/server/service/checklist-item-comment/checklist-item-comment-history.ts +0 -69
  69. package/server/service/checklist-item-comment/checklist-item-comment-mutation.ts +0 -80
  70. package/server/service/checklist-item-comment/checklist-item-comment-query.ts +0 -36
  71. package/server/service/checklist-item-comment/checklist-item-comment-type.ts +0 -32
  72. package/server/service/checklist-item-comment/checklist-item-comment.ts +0 -56
  73. package/server/service/checklist-item-comment/event-subscriber.ts +0 -17
  74. package/server/service/checklist-item-comment/index.ts +0 -9
  75. package/server/service/checklist-template/checklist-template-mutation.ts +0 -66
  76. package/server/service/checklist-template/checklist-template-query.ts +0 -39
  77. package/server/service/checklist-template/checklist-template-type.ts +0 -23
  78. package/server/service/checklist-template/checklist-template.ts +0 -71
  79. package/server/service/checklist-template/index.ts +0 -6
  80. package/server/service/checklist-template-item/checklist-template-item-mutation.ts +0 -64
  81. package/server/service/checklist-template-item/checklist-template-item-query.ts +0 -44
  82. package/server/service/checklist-template-item/checklist-template-item-type.ts +0 -39
  83. package/server/service/checklist-template-item/checklist-template-item.ts +0 -68
  84. package/server/service/checklist-template-item/index.ts +0 -6
  85. package/server/service/checklist-type/checklist-type-mutation.ts +0 -66
  86. package/server/service/checklist-type/checklist-type-query.ts +0 -39
  87. package/server/service/checklist-type/checklist-type-type.ts +0 -26
  88. package/server/service/checklist-type/checklist-type.ts +0 -64
  89. package/server/service/checklist-type/index.ts +0 -6
  90. package/server/service/index.ts +0 -88
  91. package/server/service/issue/index.ts +0 -7
  92. package/server/service/issue/issue-mutation.ts +0 -198
  93. package/server/service/issue/issue-query.ts +0 -62
  94. package/server/service/issue/issue-type.ts +0 -61
  95. package/server/service/issue/issue.ts +0 -100
  96. package/server/service/project-report/index.ts +0 -7
  97. package/server/service/project-report/project-report-mutation.ts +0 -198
  98. package/server/service/project-report/project-report-query.ts +0 -62
  99. package/server/service/project-report/project-report-type.ts +0 -61
  100. package/server/service/project-report/project-report.ts +0 -113
  101. package/server/service/supervisor/index.ts +0 -7
  102. package/server/service/supervisor/supervisor-mutation.ts +0 -198
  103. package/server/service/supervisor/supervisor-query.ts +0 -62
  104. package/server/service/supervisor/supervisor-type.ts +0 -61
  105. package/server/service/supervisor/supervisor.ts +0 -108
  106. package/server/tsconfig.json +0 -10
@@ -1,62 +0,0 @@
1
- import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'
2
- import { Attachment } from '@things-factory/attachment-base'
3
- import { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'
4
- import { User } from '@things-factory/auth-base'
5
- import { ActionPlan } from './action-plan'
6
- import { ActionPlanList } from './action-plan-type'
7
-
8
- @Resolver(ActionPlan)
9
- export class ActionPlanQuery {
10
- @Query(returns => ActionPlan!, { nullable: true, description: 'To fetch a ActionPlan' })
11
- async actionPlan(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ActionPlan> {
12
- const { domain } = context.state
13
-
14
- return await getRepository(ActionPlan).findOne({
15
- where: { domain: { id: domain.id }, id }
16
- })
17
- }
18
-
19
- @Query(returns => ActionPlanList, { description: 'To fetch multiple ActionPlans' })
20
- async actionPlans(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActionPlanList> {
21
- const { domain } = context.state
22
-
23
- const queryBuilder = getQueryBuilderFromListParams({
24
- domain,
25
- params,
26
- repository: await getRepository(ActionPlan),
27
- searchables: ['name', 'description']
28
- })
29
-
30
- const [items, total] = await queryBuilder.getManyAndCount()
31
-
32
- return { items, total }
33
- }
34
-
35
- @FieldResolver(type => String)
36
- async thumbnail(@Root() actionPlan: ActionPlan): Promise<string | undefined> {
37
- const attachment: Attachment = await getRepository(Attachment).findOne({
38
- where: {
39
- domain: { id: actionPlan.domainId },
40
- refType: ActionPlan.name,
41
- refBy: actionPlan.id
42
- }
43
- })
44
-
45
- return attachment?.fullpath
46
- }
47
-
48
- @FieldResolver(type => Domain)
49
- async domain(@Root() actionPlan: ActionPlan): Promise<Domain> {
50
- return await getRepository(Domain).findOneBy({ id: actionPlan.domainId })
51
- }
52
-
53
- @FieldResolver(type => User)
54
- async updater(@Root() actionPlan: ActionPlan): Promise<User> {
55
- return await getRepository(User).findOneBy({ id: actionPlan.updaterId })
56
- }
57
-
58
- @FieldResolver(type => User)
59
- async creator(@Root() actionPlan: ActionPlan): Promise<User> {
60
- return await getRepository(User).findOneBy({ id: actionPlan.creatorId })
61
- }
62
- }
@@ -1,61 +0,0 @@
1
- import type { FileUpload } from 'graphql-upload/GraphQLUpload.js'
2
- import GraphQLUpload from 'graphql-upload/GraphQLUpload.js'
3
- import { ObjectType, Field, InputType, Int, ID, registerEnumType } from 'type-graphql'
4
-
5
- import { ObjectRef, ScalarObject } from '@things-factory/shell'
6
-
7
- import { ActionPlan, ActionPlanStatus } from './action-plan'
8
-
9
- @InputType()
10
- export class NewActionPlan {
11
- @Field()
12
- name: string
13
-
14
- @Field({ nullable: true })
15
- description?: string
16
-
17
- @Field(type => ActionPlanStatus, { nullable: true })
18
- state?: ActionPlanStatus
19
-
20
- @Field({ nullable: true })
21
- active?: boolean
22
-
23
- @Field({ nullable: true })
24
- params?: string
25
-
26
- @Field(type => GraphQLUpload, { nullable: true })
27
- thumbnail?: FileUpload
28
- }
29
-
30
- @InputType()
31
- export class ActionPlanPatch {
32
- @Field(type => ID, { nullable: true })
33
- id?: string
34
-
35
- @Field({ nullable: true })
36
- name?: string
37
-
38
- @Field({ nullable: true })
39
- description?: string
40
-
41
- @Field(type => ActionPlanStatus, { nullable: true })
42
- state?: ActionPlanStatus
43
-
44
- @Field({ nullable: true })
45
- active?: boolean
46
-
47
- @Field(type => GraphQLUpload, { nullable: true })
48
- thumbnail?: FileUpload
49
-
50
- @Field({ nullable: true })
51
- cuFlag?: string
52
- }
53
-
54
- @ObjectType()
55
- export class ActionPlanList {
56
- @Field(type => [ActionPlan])
57
- items: ActionPlan[]
58
-
59
- @Field(type => Int)
60
- total: number
61
- }
@@ -1,103 +0,0 @@
1
- import {
2
- CreateDateColumn,
3
- UpdateDateColumn,
4
- DeleteDateColumn,
5
- Entity,
6
- Index,
7
- Column,
8
- RelationId,
9
- ManyToOne,
10
- PrimaryGeneratedColumn,
11
- VersionColumn
12
- } from 'typeorm'
13
- import { ObjectType, Field, Int, ID, registerEnumType } from 'type-graphql'
14
-
15
- import { Domain } from '@things-factory/shell'
16
- import { User } from '@things-factory/auth-base'
17
- import { Issue } from '../issue/issue'
18
-
19
- export enum ActionPlanStatus {
20
- STATUS_A = 'STATUS_A',
21
- STATUS_B = 'STATUS_B'
22
- }
23
-
24
- registerEnumType(ActionPlanStatus, {
25
- name: 'ActionPlanStatus',
26
- description: 'state enumeration of a actionPlan'
27
- })
28
-
29
- @Entity()
30
- @Index('ix_action_plan_0', (actionPlan: ActionPlan) => [actionPlan.domain, actionPlan.name], {
31
- unique: true,
32
- where: '"deleted_at" IS NULL'
33
- })
34
- @ObjectType({ description: 'Entity for ActionPlan' })
35
- export class ActionPlan {
36
- @PrimaryGeneratedColumn('uuid')
37
- @Field(type => ID)
38
- readonly id: string
39
-
40
- @ManyToOne(type => Domain)
41
- @Field({ nullable: true })
42
- domain?: Domain
43
-
44
- @RelationId((actionPlan: ActionPlan) => actionPlan.domain)
45
- domainId?: string
46
-
47
- @Column()
48
- @Field({ nullable: true })
49
- name?: string
50
-
51
- @Column({ nullable: true })
52
- @Field({ nullable: true })
53
- description?: string
54
-
55
- @Column({ nullable: true })
56
- @Field({ nullable: true })
57
- active?: boolean
58
-
59
- @Column({ nullable: true })
60
- @Field({ nullable: true })
61
- state?: ActionPlanStatus
62
-
63
- @Column({ nullable: true })
64
- @Field({ nullable: true })
65
- params?: string
66
-
67
- @Field(() => Issue)
68
- @ManyToOne(() => Issue, issue => issue.actionPlans)
69
- issue: Issue
70
-
71
- @Column({ nullable: true })
72
- @Field({ nullable: true })
73
- content: string
74
-
75
- @CreateDateColumn()
76
- @Field({ nullable: true })
77
- createdAt?: Date
78
-
79
- @UpdateDateColumn()
80
- @Field({ nullable: true })
81
- updatedAt?: Date
82
-
83
- @DeleteDateColumn()
84
- @Field({ nullable: true })
85
- deletedAt?: Date
86
-
87
- @ManyToOne(type => User, { nullable: true })
88
- @Field(type => User, { nullable: true })
89
- creator?: User
90
-
91
- @RelationId((actionPlan: ActionPlan) => actionPlan.creator)
92
- creatorId?: string
93
-
94
- @ManyToOne(type => User, { nullable: true })
95
- @Field(type => User, { nullable: true })
96
- updater?: User
97
-
98
- @RelationId((actionPlan: ActionPlan) => actionPlan.updater)
99
- updaterId?: string
100
-
101
- @Field(type => String, { nullable: true })
102
- thumbnail?: string
103
- }
@@ -1,7 +0,0 @@
1
- import { ActionPlan } from './action-plan'
2
- import { ActionPlanQuery } from './action-plan-query'
3
- import { ActionPlanMutation } from './action-plan-mutation'
4
-
5
- export const entities = [ActionPlan]
6
- export const resolvers = [ActionPlanQuery, ActionPlanMutation]
7
- export const subscribers = []
@@ -1,72 +0,0 @@
1
- import { Field, ID, ObjectType } from 'type-graphql'
2
- import { Column, Entity, Index, ManyToOne, PrimaryGeneratedColumn, RelationId } from 'typeorm'
3
- import { HistoryActionColumn, HistoryActionType, HistoryEntityInterface, HistoryOriginalIdColumn } from '@operato/typeorm-history'
4
- import { User } from '@things-factory/auth-base'
5
- import { config } from '@things-factory/env'
6
- import { BuildingInspection, BuildingInspectionStatus } from './building-inspection'
7
- import { BuildingLevel } from '@dssp/building-complex'
8
-
9
- const ORMCONFIG = config.get('ormconfig', {})
10
- const DATABASE_TYPE = ORMCONFIG.type
11
-
12
- @Entity()
13
- @Index('ix_buildingInspection_history_0', (buildingInspectionHistory: BuildingInspectionHistory) => [
14
- buildingInspectionHistory.originalId
15
- ])
16
- @ObjectType({ description: 'History Entity of BuildingInspection' })
17
- export class BuildingInspectionHistory implements HistoryEntityInterface<BuildingInspection> {
18
- @PrimaryGeneratedColumn('uuid')
19
- @Field(type => ID)
20
- readonly id: string
21
-
22
- @HistoryOriginalIdColumn()
23
- public originalId!: string
24
-
25
- @Column({
26
- nullable: false,
27
- comment:
28
- '상태(WAIT: 검측 대기, OVERALL_WAIT: 총괄자 검측 대기, REQUEST: 검측 요청, OVERALL_REQUEST: 총괄자 검측 요청, PASS: 합격, FAIL: 불합격)'
29
- })
30
- @Field({ nullable: true })
31
- status?: BuildingInspectionStatus
32
-
33
- // 층 정보 (1:1 테이블 참조)
34
- @ManyToOne(type => BuildingLevel)
35
- @Field({ nullable: true })
36
- buildingLevel?: BuildingLevel
37
-
38
- @RelationId((buildingInspectionHistory: BuildingInspectionHistory) => buildingInspectionHistory.buildingLevel)
39
- buildingLevelId?: string
40
-
41
- @Column({ type: 'date', nullable: true, comment: '검측 요청일' })
42
- @Field(type => String, { nullable: true })
43
- requestDate?: string
44
-
45
- // 체크리스트 ID (1:1 테이블 참조)
46
- @Field({ nullable: true })
47
- @Column({ nullable: true, comment: '체크리스트 ID' })
48
- checklistId: string
49
-
50
- @Column({ nullable: true })
51
- @Field({ nullable: true })
52
- createdAt?: Date
53
-
54
- @ManyToOne(type => User, { nullable: true })
55
- @Field(type => User, { nullable: true })
56
- creator?: User
57
-
58
- @RelationId((buildingInspectionHistory: BuildingInspectionHistory) => buildingInspectionHistory.creator)
59
- creatorId?: string
60
-
61
- @HistoryActionColumn({
62
- nullable: false,
63
- type:
64
- DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
65
- ? 'enum'
66
- : DATABASE_TYPE == 'oracle'
67
- ? 'varchar2'
68
- : 'smallint',
69
- enum: HistoryActionType
70
- })
71
- public action!: HistoryActionType
72
- }
@@ -1,276 +0,0 @@
1
- import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
- import { In } from 'typeorm'
3
- import { BuildingInspection } from './building-inspection'
4
- import {
5
- NewBuildingInspection,
6
- UpdateBuildingInspectionDrawingMarker,
7
- UpdateBuildingInspectionSubmitType
8
- } from './building-inspection-type'
9
- import { BuildingInspectionStatus } from './building-inspection'
10
- import { Checklist } from '../checklist/checklist'
11
- import { ChecklistItem } from '../checklist-item/checklist-item'
12
- import { getRepository } from '@things-factory/shell'
13
- import { BuildingLevel } from '@dssp/building-complex'
14
-
15
- @Resolver(BuildingInspection)
16
- export class BuildingInspectionMutation {
17
- @Directive('@transaction')
18
- @Mutation(returns => BuildingInspection, { description: 'To create Building Inspection information' })
19
- async createBuildingInspection(
20
- @Arg('patch') patch: NewBuildingInspection,
21
- @Ctx() context: ResolverContext
22
- ): Promise<BuildingInspection> {
23
- const { user, tx } = context.state
24
- const { buildingLevelId, checklist, checklistItem } = patch
25
- const buildingInspectionRepository = tx.getRepository(BuildingInspection)
26
- const checklistRepository = tx.getRepository(Checklist)
27
- const checklistItemRepository = tx.getRepository(ChecklistItem)
28
-
29
- // 1. 벨리데이션
30
- if (!buildingLevelId) throw new Error('층 아이디가 없습니다.')
31
- if (!checklist.name) throw new Error('체크리스트 이름이 없습니다.')
32
- if (!checklist.constructionType) throw new Error('공종 타입이 없습니다.')
33
- if (!checklist.constructionDetailType) throw new Error('상세 공종 타입이 없습니다.')
34
- if (!checklist.location) throw new Error('위치가 없습니다.')
35
- if (!checklist.inspectionDrawingType) throw new Error('검측 도면 타입이 없습니다.')
36
- if (checklist.inspectionParts.length === 0) throw new Error('검측 부위가 없습니다.')
37
- if (checklistItem.length === 0) throw new Error('체크리스트 아이템이 없습니다.')
38
-
39
- // 2. checklist 저장
40
- const documentNo = await this.getRecentDocumentNoByBuildingLevelId(buildingLevelId)
41
- const savedChecklist = await checklistRepository.save({
42
- ...checklist,
43
- documentNo,
44
- creator: user,
45
- updater: user
46
- })
47
-
48
- // 3. checklistItem 저장
49
- const checklistItems = checklistItem.map((item, idx) => ({
50
- name: item.name,
51
- mainType: item.mainType,
52
- detailType: item.detailType,
53
- inspctionCriteria: item.inspctionCriteria,
54
- sequence: idx,
55
- checklist: savedChecklist,
56
- creator: user,
57
- updater: user
58
- }))
59
- await checklistItemRepository.save(checklistItems)
60
-
61
- // 4. buildingInspection 저장
62
- const result = await buildingInspectionRepository.save({
63
- status: BuildingInspectionStatus.WAIT,
64
- buildingLevel: { id: buildingLevelId },
65
- checklist: savedChecklist,
66
- creator: user,
67
- updater: user
68
- })
69
-
70
- return result
71
- }
72
-
73
- // 검측 상태 변경 & 체크리스트 갱신
74
- @Directive('@transaction')
75
- @Mutation(returns => Boolean, { description: 'To create Building Inspection And Checklist information' })
76
- async updateBuildingInspectionChecklist(
77
- @Arg('buildingInspection') buildingInspection: UpdateBuildingInspectionSubmitType,
78
- @Ctx() context: ResolverContext
79
- ): Promise<boolean> {
80
- const { user, tx } = context.state
81
- const { id: buildingInspectionId, checklist, checklistItem } = buildingInspection
82
- const buildingInspectionRepo = tx.getRepository(BuildingInspection)
83
- const checklistRepo = tx.getRepository(Checklist)
84
- const checklistItemRepo = tx.getRepository(ChecklistItem)
85
- const oldBuildingInspection = await buildingInspectionRepo.findOneBy({ id: buildingInspectionId })
86
- const status = oldBuildingInspection.status
87
- const isConstructor: boolean =
88
- status == BuildingInspectionStatus.WAIT ||
89
- status == BuildingInspectionStatus.OVERALL_WAIT ||
90
- status == BuildingInspectionStatus.FAIL
91
- let inspectionStatus = null
92
-
93
- // 1. 벨리데이션
94
- if (!buildingInspectionId) throw new Error('검측 아이디가 없습니다.')
95
- if (!status) throw new Error('검측 상태가 없습니다.')
96
- if (status == BuildingInspectionStatus.PASS) throw new Error('검측 상태가 수정할 수 있는 상태가 아닙니다.')
97
-
98
- if (isConstructor) {
99
- // 시공자 타입별 밸리데이션
100
- if (checklistItem.length !== checklistItem.filter(v => v.constructionConfirmStatus).length) {
101
- throw new Error('아이템을 모두 체크해야 합니다.')
102
- }
103
- if (status == BuildingInspectionStatus.OVERALL_WAIT && !checklist.overallConstructorSignature) {
104
- throw new Error('총괄 시공책임자 사인이 없습니다.')
105
- }
106
- if (status == BuildingInspectionStatus.WAIT && !checklist.taskConstructorSignature) {
107
- throw new Error('공종별 시공관리자 사인이 없습니다.')
108
- }
109
-
110
- // 시공자 상태 데이터
111
- const isPassed = checklistItem.length === checklistItem.filter(v => v.constructionConfirmStatus === 'T').length
112
-
113
- if (!isPassed) {
114
- // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화
115
- inspectionStatus = BuildingInspectionStatus.FAIL
116
- checklist.overallConstructorSignature = null
117
- checklist.taskConstructorSignature = null
118
- } else if (isPassed && (status === BuildingInspectionStatus.WAIT || status === BuildingInspectionStatus.FAIL)) {
119
- // 2. 검측이 합격이면서 공종 시공자 스탭 = 상태는 총괄 시공자 스탭으로
120
- inspectionStatus = BuildingInspectionStatus.OVERALL_WAIT
121
- } else if (isPassed && status === BuildingInspectionStatus.OVERALL_WAIT) {
122
- // 3. 검측이 합격이면서 총괄 시공자 스탭 = 상태는 공종 감리자 스탭으로, 감리자 싸인은 모두 초기화
123
- inspectionStatus = BuildingInspectionStatus.REQUEST
124
- checklist.overallSupervisorySignature = null
125
- checklist.taskSupervisorySignature = null
126
- }
127
- } else {
128
- // 감리자 타입별 밸리데이션
129
- if (checklistItem.length !== checklistItem.filter(v => v.supervisoryConfirmStatus).length) {
130
- throw new Error('아이템을 모두 체크해야 합니다.')
131
- }
132
- if (status == BuildingInspectionStatus.OVERALL_REQUEST && !checklist.overallSupervisorySignature) {
133
- throw new Error('총괄 감리책임자 사인이 없습니다.')
134
- }
135
- if (status == BuildingInspectionStatus.REQUEST && !checklist.taskSupervisorySignature) {
136
- throw new Error('공종별 감리 책임자 사인이 없습니다.')
137
- }
138
-
139
- // 감리자 상태 데이터
140
- const isPassed = checklistItem.length === checklistItem.filter(v => v.supervisoryConfirmStatus === 'T').length
141
- if (!isPassed) {
142
- // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화
143
- inspectionStatus = BuildingInspectionStatus.FAIL
144
- checklist.overallConstructorSignature = null
145
- checklist.taskConstructorSignature = null
146
- } else if (isPassed && status === BuildingInspectionStatus.REQUEST) {
147
- // 2. 검측이 합격이면서 공종 감리자 스탭 = 상태는 총괄 감리자 스탭으로
148
- inspectionStatus = BuildingInspectionStatus.OVERALL_REQUEST
149
- } else if (isPassed && status === BuildingInspectionStatus.OVERALL_REQUEST) {
150
- // 3. 검측이 합격이면서 총괄 감리자 스탭 = 상태는 합격으로
151
- inspectionStatus = BuildingInspectionStatus.PASS
152
- }
153
- }
154
-
155
- // 2. buildingInspection 저장
156
- await buildingInspectionRepo.save({
157
- ...oldBuildingInspection,
158
- status: inspectionStatus,
159
- updater: user
160
- })
161
-
162
- // 3. checklist 저장
163
- const oldChecklist = await checklistRepo.findOneBy({ id: checklist.id })
164
- const inspectionDateField = isConstructor ? 'constructionInspectionDate' : 'supervisorInspectionDate'
165
- await checklistRepo.save({
166
- ...oldChecklist,
167
- [inspectionDateField]: new Date(),
168
- overallConstructorSignature: checklist.overallConstructorSignature,
169
- taskConstructorSignature: checklist.taskConstructorSignature,
170
- overallSupervisorySignature: checklist.overallSupervisorySignature,
171
- taskSupervisorySignature: checklist.taskSupervisorySignature,
172
- updater: user
173
- })
174
-
175
- // 4. checklistItem 저장
176
- for (let item of checklistItem) {
177
- const confirmStatusField = isConstructor ? 'constructionConfirmStatus' : 'supervisoryConfirmStatus'
178
- await checklistItemRepo.update(item.id, {
179
- [confirmStatusField]: item[confirmStatusField],
180
- updater: user
181
- })
182
- }
183
-
184
- return true
185
- }
186
-
187
- @Directive('@transaction')
188
- @Mutation(returns => BuildingInspection, { description: 'To update Building Inspection information' })
189
- async updateBuildingInspection(
190
- @Arg('patch') patch: UpdateBuildingInspectionDrawingMarker,
191
- @Ctx() context: ResolverContext
192
- ): Promise<BuildingInspection> {
193
- const { user, tx } = context.state
194
- const buildingInspectionRepo = tx.getRepository(BuildingInspection)
195
-
196
- // 벨리데이션
197
- if (!patch.id) throw new Error('검측 아이디가 없습니다.')
198
-
199
- const buildingInspection = await buildingInspectionRepo.findOneBy({ id: patch.id })
200
-
201
- // 완료 상태인 검측데이터면 삭제 못함
202
- if (buildingInspection.status === BuildingInspectionStatus.PASS) {
203
- throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')
204
- }
205
-
206
- const result = await buildingInspectionRepo.save({
207
- ...buildingInspection,
208
- ...patch,
209
- updater: user
210
- })
211
-
212
- return result
213
- }
214
-
215
- @Directive('@transaction')
216
- @Mutation(returns => Boolean, { description: 'To delete multiple Checklists' })
217
- async deleteBuildingInspections(
218
- @Arg('ids', type => [String]) ids: string[],
219
- @Ctx() context: ResolverContext
220
- ): Promise<boolean> {
221
- const { tx } = context.state
222
- const buildingInspectionRepository = tx.getRepository(BuildingInspection)
223
- const checklistRepository = tx.getRepository(Checklist)
224
- const checklistItemRepository = tx.getRepository(ChecklistItem)
225
-
226
- const buildingInspections = await buildingInspectionRepository.createQueryBuilder('bi').whereInIds(ids).getMany()
227
-
228
- // 완료 상태인 검측데이터가 한개라도 있으면 삭제 못함
229
- if (buildingInspections.filter(bi => bi.status === BuildingInspectionStatus.PASS).length > 0) {
230
- throw new Error('완료 상태인 검측정보를 변경할 수 없습니다.')
231
- }
232
-
233
- // 검측 데이터 제거
234
- await buildingInspectionRepository.softDelete({
235
- id: In(ids)
236
- })
237
-
238
- // 검측 데이터의 체크 리스트 제거
239
- const checklistIds = buildingInspections.map(bi => bi.checklistId)
240
- await checklistRepository.softDelete({
241
- id: In(checklistIds)
242
- })
243
-
244
- // 검측 데이터의 체크 리스트 아이템 제거
245
- await checklistItemRepository
246
- .createQueryBuilder()
247
- .softDelete()
248
- .where('checklist_id IN (:...checklistIds)', { checklistIds })
249
- .execute()
250
-
251
- return true
252
- }
253
-
254
- async getRecentDocumentNoByBuildingLevelId(buildingLevelId: string): Promise<string> {
255
- const buildingLevel = await getRepository(BuildingLevel).findOne({
256
- where: { id: buildingLevelId },
257
- relations: ['building']
258
- })
259
-
260
- const buildingName = buildingLevel.building.name.match(/\d+/g)?.join('')?.padStart(4, '0') || '0000'
261
- const floorName = buildingLevel.floor.toString().padStart(3, '0')
262
- const latestChecklist = await getRepository(Checklist)
263
- .createQueryBuilder('c')
264
- .where('c.document_no LIKE :pattern', { pattern: `${buildingName}-${floorName}-%` })
265
- .orderBy('c.created_at', 'DESC')
266
- .getOne()
267
-
268
- let documentNo = '000001'
269
- if (latestChecklist) {
270
- const lastNo = latestChecklist.documentNo.split('-')[2]
271
- documentNo = (Number(lastNo) + 1).toString().padStart(6, '0')
272
- }
273
-
274
- return `${buildingName}-${floorName}-${documentNo}`
275
- }
276
- }