@dssp/supervision 0.0.9 → 0.0.11

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 (224) hide show
  1. package/client/pages/building-inspection/building-inspection-detail-checklist.ts +227 -0
  2. package/client/pages/building-inspection/building-inspection-detail-drawing.ts +160 -0
  3. package/client/pages/building-inspection/building-inspection-list.ts +430 -0
  4. package/client/pages/building-inspection/component/building-inspection-detail-header.ts +94 -0
  5. package/client/pages/building-inspection/inspection-create-popup.ts +696 -0
  6. package/client/pages/checklist/checklist-view.ts +463 -0
  7. package/client/pages/checklist-template/checklist-template-item.ts +240 -0
  8. package/client/pages/checklist-template/checklist-template-list.ts +271 -0
  9. package/client/pages/checklist-template/checklist-type-management.ts +242 -0
  10. package/client/route.ts +14 -18
  11. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.d.ts +22 -0
  12. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js +228 -0
  13. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js.map +1 -0
  14. package/dist-client/pages/building-inspection/building-inspection-detail-drawing.d.ts +21 -0
  15. package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js +169 -0
  16. package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js.map +1 -0
  17. package/dist-client/pages/building-inspection/building-inspection-list.d.ts +67 -0
  18. package/dist-client/pages/building-inspection/building-inspection-list.js +434 -0
  19. package/dist-client/pages/building-inspection/building-inspection-list.js.map +1 -0
  20. package/dist-client/pages/building-inspection/component/building-inspection-detail-header.d.ts +1 -0
  21. package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js +118 -0
  22. package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js.map +1 -0
  23. package/dist-client/pages/building-inspection/inspection-create-popup.d.ts +3 -0
  24. package/dist-client/pages/building-inspection/inspection-create-popup.js +735 -0
  25. package/dist-client/pages/building-inspection/inspection-create-popup.js.map +1 -0
  26. package/dist-client/pages/checklist/checklist-view.d.ts +6 -0
  27. package/dist-client/pages/checklist/checklist-view.js +468 -0
  28. package/dist-client/pages/checklist/checklist-view.js.map +1 -0
  29. package/dist-client/pages/checklist-template/checklist-template-item.d.ts +2 -0
  30. package/dist-client/pages/checklist-template/checklist-template-item.js +237 -0
  31. package/dist-client/pages/checklist-template/checklist-template-item.js.map +1 -0
  32. package/dist-client/pages/{check-item/check-item-list-page.d.ts → checklist-template/checklist-template-list.d.ts} +8 -27
  33. package/dist-client/pages/checklist-template/checklist-template-list.js +259 -0
  34. package/dist-client/pages/checklist-template/checklist-template-list.js.map +1 -0
  35. package/dist-client/pages/checklist-template/checklist-type-management.d.ts +48 -0
  36. package/dist-client/pages/checklist-template/checklist-type-management.js +229 -0
  37. package/dist-client/pages/checklist-template/checklist-type-management.js.map +1 -0
  38. package/dist-client/route.d.ts +1 -1
  39. package/dist-client/route.js +10 -13
  40. package/dist-client/route.js.map +1 -1
  41. package/dist-client/tsconfig.tsbuildinfo +1 -1
  42. package/dist-server/index.d.ts +1 -1
  43. package/dist-server/index.js +1 -1
  44. package/dist-server/index.js.map +1 -1
  45. package/dist-server/service/building-inspection/building-inspection-history.d.ts +17 -0
  46. package/dist-server/service/building-inspection/building-inspection-history.js +85 -0
  47. package/dist-server/service/building-inspection/building-inspection-history.js.map +1 -0
  48. package/dist-server/service/building-inspection/building-inspection-mutation.d.ts +9 -0
  49. package/dist-server/service/building-inspection/building-inspection-mutation.js +227 -0
  50. package/dist-server/service/building-inspection/building-inspection-mutation.js.map +1 -0
  51. package/dist-server/service/building-inspection/building-inspection-query.d.ts +20 -0
  52. package/dist-server/service/building-inspection/building-inspection-query.js +235 -0
  53. package/dist-server/service/building-inspection/building-inspection-query.js.map +1 -0
  54. package/dist-server/service/building-inspection/building-inspection-type.d.ts +60 -0
  55. package/dist-server/service/building-inspection/building-inspection-type.js +213 -0
  56. package/dist-server/service/building-inspection/building-inspection-type.js.map +1 -0
  57. package/dist-server/service/building-inspection/building-inspection.d.ts +26 -0
  58. package/dist-server/service/building-inspection/building-inspection.js +113 -0
  59. package/dist-server/service/building-inspection/building-inspection.js.map +1 -0
  60. package/dist-server/service/building-inspection/event-subscriber.d.ts +7 -0
  61. package/dist-server/service/building-inspection/event-subscriber.js +21 -0
  62. package/dist-server/service/building-inspection/event-subscriber.js.map +1 -0
  63. package/dist-server/service/building-inspection/index.d.ts +10 -0
  64. package/dist-server/service/building-inspection/index.js +14 -0
  65. package/dist-server/service/building-inspection/index.js.map +1 -0
  66. package/dist-server/service/checklist/checklist-history.d.ts +24 -0
  67. package/dist-server/service/checklist/checklist-history.js +120 -0
  68. package/dist-server/service/checklist/checklist-history.js.map +1 -0
  69. package/dist-server/service/checklist/checklist-mutation.d.ts +8 -0
  70. package/dist-server/service/checklist/checklist-mutation.js +96 -0
  71. package/dist-server/service/checklist/checklist-mutation.js.map +1 -0
  72. package/dist-server/service/checklist/checklist-query.d.ts +12 -0
  73. package/dist-server/service/checklist/checklist-query.js +83 -0
  74. package/dist-server/service/checklist/checklist-query.js.map +1 -0
  75. package/dist-server/service/checklist/checklist-type.d.ts +18 -0
  76. package/dist-server/service/checklist/checklist-type.js +69 -0
  77. package/dist-server/service/checklist/checklist-type.js.map +1 -0
  78. package/dist-server/service/checklist/checklist.d.ts +31 -0
  79. package/dist-server/service/checklist/checklist.js +143 -0
  80. package/dist-server/service/checklist/checklist.js.map +1 -0
  81. package/dist-server/service/checklist/event-subscriber.d.ts +7 -0
  82. package/dist-server/service/checklist/event-subscriber.js +21 -0
  83. package/dist-server/service/checklist/event-subscriber.js.map +1 -0
  84. package/dist-server/service/checklist/index.d.ts +8 -0
  85. package/dist-server/service/checklist/index.js +12 -0
  86. package/dist-server/service/checklist/index.js.map +1 -0
  87. package/dist-server/service/checklist-item/checklist-item-mutation.d.ts +2 -0
  88. package/dist-server/service/checklist-item/checklist-item-mutation.js +13 -0
  89. package/dist-server/service/checklist-item/checklist-item-mutation.js.map +1 -0
  90. package/dist-server/service/checklist-item/checklist-item-query.d.ts +10 -0
  91. package/dist-server/service/checklist-item/checklist-item-query.js +68 -0
  92. package/dist-server/service/checklist-item/checklist-item-query.js.map +1 -0
  93. package/dist-server/service/checklist-item/checklist-item-type.d.ts +5 -0
  94. package/dist-server/service/checklist-item/checklist-item-type.js +21 -0
  95. package/dist-server/service/checklist-item/checklist-item-type.js.map +1 -0
  96. package/dist-server/service/checklist-item/checklist-item.d.ts +26 -0
  97. package/dist-server/service/checklist-item/checklist-item.js +113 -0
  98. package/dist-server/service/checklist-item/checklist-item.js.map +1 -0
  99. package/dist-server/service/checklist-item/index.d.ts +5 -0
  100. package/dist-server/service/checklist-item/index.js +10 -0
  101. package/dist-server/service/checklist-item/index.js.map +1 -0
  102. package/dist-server/service/checklist-template/checklist-template-mutation.d.ts +6 -0
  103. package/dist-server/service/checklist-template/checklist-template-mutation.js +64 -0
  104. package/dist-server/service/checklist-template/checklist-template-mutation.js.map +1 -0
  105. package/dist-server/service/checklist-template/checklist-template-query.d.ts +10 -0
  106. package/dist-server/service/checklist-template/checklist-template-query.js +65 -0
  107. package/dist-server/service/checklist-template/checklist-template-query.js.map +1 -0
  108. package/dist-server/service/checklist-template/checklist-template-type.d.ts +10 -0
  109. package/dist-server/service/checklist-template/checklist-template-type.js +39 -0
  110. package/dist-server/service/checklist-template/checklist-template-type.js.map +1 -0
  111. package/dist-server/service/checklist-template/checklist-template.d.ts +17 -0
  112. package/dist-server/service/checklist-template/checklist-template.js +78 -0
  113. package/dist-server/service/checklist-template/checklist-template.js.map +1 -0
  114. package/dist-server/service/checklist-template/index.d.ts +5 -0
  115. package/dist-server/service/checklist-template/index.js +9 -0
  116. package/dist-server/service/checklist-template/index.js.map +1 -0
  117. package/dist-server/service/checklist-template-item/checklist-template-item-mutation.d.ts +7 -0
  118. package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js +68 -0
  119. package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js.map +1 -0
  120. package/dist-server/service/checklist-template-item/checklist-template-item-query.d.ts +10 -0
  121. package/dist-server/service/checklist-template-item/checklist-template-item-query.js +66 -0
  122. package/dist-server/service/checklist-template-item/checklist-template-item-query.js.map +1 -0
  123. package/dist-server/service/checklist-template-item/checklist-template-item-type.d.ts +16 -0
  124. package/dist-server/service/checklist-template-item/checklist-template-item-type.js +60 -0
  125. package/dist-server/service/checklist-template-item/checklist-template-item-type.js.map +1 -0
  126. package/dist-server/service/checklist-template-item/checklist-template-item.d.ts +19 -0
  127. package/dist-server/service/checklist-template-item/checklist-template-item.js +87 -0
  128. package/dist-server/service/checklist-template-item/checklist-template-item.js.map +1 -0
  129. package/dist-server/service/checklist-template-item/index.d.ts +5 -0
  130. package/dist-server/service/checklist-template-item/index.js +9 -0
  131. package/dist-server/service/checklist-template-item/index.js.map +1 -0
  132. package/dist-server/service/checklist-type/checklist-type-mutation.d.ts +6 -0
  133. package/dist-server/service/checklist-type/checklist-type-mutation.js +64 -0
  134. package/dist-server/service/checklist-type/checklist-type-mutation.js.map +1 -0
  135. package/dist-server/service/checklist-type/checklist-type-query.d.ts +10 -0
  136. package/dist-server/service/checklist-type/checklist-type-query.js +65 -0
  137. package/dist-server/service/checklist-type/checklist-type-query.js.map +1 -0
  138. package/dist-server/service/checklist-type/checklist-type-type.d.ts +11 -0
  139. package/dist-server/service/checklist-type/checklist-type-type.js +43 -0
  140. package/dist-server/service/checklist-type/checklist-type-type.js.map +1 -0
  141. package/dist-server/service/checklist-type/checklist-type.d.ts +19 -0
  142. package/dist-server/service/checklist-type/checklist-type.js +78 -0
  143. package/dist-server/service/checklist-type/checklist-type.js.map +1 -0
  144. package/dist-server/service/checklist-type/index.d.ts +5 -0
  145. package/dist-server/service/checklist-type/index.js +9 -0
  146. package/dist-server/service/checklist-type/index.js.map +1 -0
  147. package/dist-server/service/index.d.ts +8 -3
  148. package/dist-server/service/index.js +26 -5
  149. package/dist-server/service/index.js.map +1 -1
  150. package/dist-server/service/issue/issue.d.ts +1 -3
  151. package/dist-server/service/issue/issue.js +1 -7
  152. package/dist-server/service/issue/issue.js.map +1 -1
  153. package/dist-server/service/supervisor/supervisor.d.ts +1 -3
  154. package/dist-server/service/supervisor/supervisor.js +1 -7
  155. package/dist-server/service/supervisor/supervisor.js.map +1 -1
  156. package/dist-server/tsconfig.tsbuildinfo +1 -1
  157. package/helps/supervision/checklist-item.md +160 -0
  158. package/helps/supervision/checklist.md +160 -0
  159. package/package.json +11 -7
  160. package/server/index.ts +1 -1
  161. package/server/service/building-inspection/building-inspection-history.ts +70 -0
  162. package/server/service/building-inspection/building-inspection-mutation.ts +239 -0
  163. package/server/service/building-inspection/building-inspection-query.ts +202 -0
  164. package/server/service/building-inspection/building-inspection-type.ts +142 -0
  165. package/server/service/building-inspection/building-inspection.ts +106 -0
  166. package/server/service/building-inspection/event-subscriber.ts +20 -0
  167. package/server/service/building-inspection/index.ts +11 -0
  168. package/server/service/checklist/checklist-history.ts +96 -0
  169. package/server/service/checklist/checklist-mutation.ts +103 -0
  170. package/server/service/checklist/checklist-query.ts +52 -0
  171. package/server/service/{check-item/check-item-type.ts → checklist/checklist-type.ts} +6 -18
  172. package/server/service/checklist/checklist.ts +127 -0
  173. package/server/service/checklist/event-subscriber.ts +17 -0
  174. package/server/service/checklist/index.ts +9 -0
  175. package/server/service/checklist-item/checklist-item-mutation.ts +5 -0
  176. package/server/service/checklist-item/checklist-item-query.ts +43 -0
  177. package/server/service/checklist-item/checklist-item-type.ts +12 -0
  178. package/server/service/checklist-item/checklist-item.ts +100 -0
  179. package/server/service/checklist-item/index.ts +7 -0
  180. package/server/service/checklist-template/checklist-template-mutation.ts +66 -0
  181. package/server/service/checklist-template/checklist-template-query.ts +39 -0
  182. package/server/service/checklist-template/checklist-template-type.ts +23 -0
  183. package/server/service/checklist-template/checklist-template.ts +71 -0
  184. package/server/service/checklist-template/index.ts +6 -0
  185. package/server/service/checklist-template-item/checklist-template-item-mutation.ts +64 -0
  186. package/server/service/checklist-template-item/checklist-template-item-query.ts +39 -0
  187. package/server/service/checklist-template-item/checklist-template-item-type.ts +39 -0
  188. package/server/service/checklist-template-item/checklist-template-item.ts +67 -0
  189. package/server/service/checklist-template-item/index.ts +6 -0
  190. package/server/service/checklist-type/checklist-type-mutation.ts +66 -0
  191. package/server/service/checklist-type/checklist-type-query.ts +39 -0
  192. package/server/service/checklist-type/checklist-type-type.ts +26 -0
  193. package/server/service/checklist-type/checklist-type.ts +64 -0
  194. package/server/service/checklist-type/index.ts +6 -0
  195. package/server/service/index.ts +60 -23
  196. package/server/service/issue/issue.ts +1 -6
  197. package/server/service/supervisor/supervisor.ts +1 -6
  198. package/things-factory.config.js +11 -7
  199. package/client/pages/check-item/check-item-importer.ts +0 -94
  200. package/client/pages/check-item/check-item-list-page.ts +0 -340
  201. package/dist-client/pages/check-item/check-item-importer.d.ts +0 -10
  202. package/dist-client/pages/check-item/check-item-importer.js +0 -101
  203. package/dist-client/pages/check-item/check-item-importer.js.map +0 -1
  204. package/dist-client/pages/check-item/check-item-list-page.js +0 -323
  205. package/dist-client/pages/check-item/check-item-list-page.js.map +0 -1
  206. package/dist-server/service/check-item/check-item-mutation.d.ts +0 -10
  207. package/dist-server/service/check-item/check-item-mutation.js +0 -168
  208. package/dist-server/service/check-item/check-item-mutation.js.map +0 -1
  209. package/dist-server/service/check-item/check-item-query.d.ts +0 -12
  210. package/dist-server/service/check-item/check-item-query.js +0 -97
  211. package/dist-server/service/check-item/check-item-query.js.map +0 -1
  212. package/dist-server/service/check-item/check-item-type.d.ts +0 -23
  213. package/dist-server/service/check-item/check-item-type.js +0 -86
  214. package/dist-server/service/check-item/check-item-type.js.map +0 -1
  215. package/dist-server/service/check-item/check-item.d.ts +0 -28
  216. package/dist-server/service/check-item/check-item.js +0 -117
  217. package/dist-server/service/check-item/check-item.js.map +0 -1
  218. package/dist-server/service/check-item/index.d.ts +0 -6
  219. package/dist-server/service/check-item/index.js +0 -10
  220. package/dist-server/service/check-item/index.js.map +0 -1
  221. package/server/service/check-item/check-item-mutation.ts +0 -198
  222. package/server/service/check-item/check-item-query.ts +0 -62
  223. package/server/service/check-item/check-item.ts +0 -111
  224. package/server/service/check-item/index.ts +0 -7
@@ -0,0 +1,202 @@
1
+ import { Resolver, Query, FieldResolver, Root, Arg, Args, Ctx } from 'type-graphql'
2
+ import { Attachment } from '@things-factory/attachment-base'
3
+ import { getRepository, getQueryBuilderFromListParams, ListParam } from '@things-factory/shell'
4
+ import { BuildingInspection, BuildingInspectionStatus } from './building-inspection'
5
+ import {
6
+ BuildingInspectionList,
7
+ BuildingInspectionsOfBuildingLevel,
8
+ BuildingInspectionsOfProject,
9
+ BuildingInspectionSummary
10
+ } from './building-inspection-type'
11
+ import { BuildingLevel } from '@dssp/building-complex'
12
+ import { Checklist } from '../checklist/checklist'
13
+ import { Project } from '@dssp/project'
14
+
15
+ @Resolver(BuildingInspection)
16
+ export class BuildingInspectionQuery {
17
+ @Query(returns => BuildingInspection!, { nullable: true, description: 'To fetch a BuildingInspection' })
18
+ async buildingInspection(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<BuildingInspection> {
19
+ return await getRepository(BuildingInspection).findOne({
20
+ where: { id }
21
+ })
22
+ }
23
+
24
+ @Query(returns => BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' })
25
+ async buildingInspections(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<BuildingInspectionList> {
26
+ const { domain } = context.state
27
+
28
+ const queryBuilder = getQueryBuilderFromListParams({
29
+ params,
30
+ repository: await getRepository(BuildingInspection),
31
+ searchables: ['name']
32
+ })
33
+
34
+ const [items, total] = await queryBuilder.getManyAndCount()
35
+
36
+ return { items, total }
37
+ }
38
+
39
+ @Query(returns => BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' })
40
+ async buildingInspectionsOfProject(
41
+ @Arg('params') params: BuildingInspectionsOfProject,
42
+ @Ctx() context: ResolverContext
43
+ ): Promise<BuildingInspectionList> {
44
+ const { domain } = context.state
45
+ const { projectId, limit } = params
46
+
47
+ const queryBuilder = getRepository(BuildingInspection)
48
+ .createQueryBuilder('bi')
49
+ .innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')
50
+ .innerJoin('buildings', 'b', 'bl.building_id = b.id')
51
+ .innerJoin('building_complexes', 'bc', 'b.building_complex_id = bc.id')
52
+ .innerJoin('projects', 'p', 'bc.id = p.building_complex_id')
53
+ .innerJoin('checklists', 'c', 'bi.checklist_id = c.id')
54
+ .where('p.domain = :domain', { domain: domain.id })
55
+ .andWhere('p.id = :projectId', { projectId })
56
+ .orderBy('bi.created_at', 'DESC')
57
+
58
+ if (limit) {
59
+ queryBuilder.limit(limit)
60
+ }
61
+
62
+ const [items, total] = await queryBuilder.getManyAndCount()
63
+
64
+ return { items, total }
65
+ }
66
+
67
+ @Query(returns => Project!, { description: 'To fetch Project' })
68
+ async projectByBuildingLevelId(
69
+ @Arg('buildingLevelId') buildingLevelId: string,
70
+ @Ctx() context: ResolverContext
71
+ ): Promise<Project> {
72
+ const queryBuilder = getRepository(Project)
73
+ .createQueryBuilder('p')
74
+ .innerJoin('building_complexes', 'bc', 'p.building_complex_id = bc.id')
75
+ .innerJoin('buildings', 'b', 'b.building_complex_id = bc.id')
76
+ .innerJoin('building_levels', 'bl', 'bl.building_id = b.id')
77
+ .where('bl.id = :buildingLevelId', { buildingLevelId })
78
+
79
+ const result = await queryBuilder.getOne()
80
+
81
+ return result
82
+ }
83
+
84
+ @Query(returns => BuildingInspectionList, { description: 'To fetch multiple BuildingInspections' })
85
+ async buildingInspectionsOfBuildingLevel(
86
+ @Arg('params') params: BuildingInspectionsOfBuildingLevel,
87
+ @Ctx() context: ResolverContext
88
+ ): Promise<BuildingInspectionList> {
89
+ const { buildingLevelId, limit } = params
90
+
91
+ const queryBuilder = getRepository(BuildingInspection)
92
+ .createQueryBuilder('bi')
93
+ .innerJoin('building_levels', 'bl', 'bi.building_level_id = bl.id')
94
+ .innerJoin('checklists', 'c', 'bi.checklist_id = c.id')
95
+ .where('bl.id = :buildingLevelId', { buildingLevelId })
96
+ .orderBy('bi.updated_at', 'DESC')
97
+
98
+ if (limit) {
99
+ queryBuilder.limit(limit)
100
+ }
101
+
102
+ const [items, total] = await queryBuilder.getManyAndCount()
103
+
104
+ return { items, total }
105
+ }
106
+
107
+ // 층 별로 검수 개수 써머리
108
+ @Query(returns => BuildingInspectionSummary!, { nullable: true, description: 'To fetch a BuildingInspection Summary' })
109
+ async buildingInspectionSummaryOfBuildingLevel(
110
+ @Arg('buildingLevelId') buildingLevelId: string,
111
+ @Ctx() context: ResolverContext
112
+ ): Promise<BuildingInspectionSummary> {
113
+ const buildingInspectionSummary = await getRepository(BuildingInspection)
114
+ .createQueryBuilder('bi')
115
+ .select(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)
116
+ .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)
117
+ .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
118
+ .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
119
+ .where('bi.building_level_id = :buildingLevelId', { buildingLevelId })
120
+ .groupBy('bi.building_level_id')
121
+ .getRawOne()
122
+
123
+ return {
124
+ wait: buildingInspectionSummary?.wait || 0,
125
+ request: buildingInspectionSummary?.request || 0,
126
+ pass: buildingInspectionSummary?.pass || 0,
127
+ fail: buildingInspectionSummary?.fail || 0
128
+ }
129
+ }
130
+
131
+ // 층 별로 검수 개수 써머리
132
+ @FieldResolver(type => BuildingInspectionSummary)
133
+ async buildingInspectionSummary(@Root() buildingLevel: BuildingLevel): Promise<BuildingInspectionSummary> {
134
+ const buildingInspectionSummary = await getRepository(BuildingInspection)
135
+ .createQueryBuilder('bi')
136
+ .select(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)
137
+ .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)
138
+ .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
139
+ .addSelect(`COUNT(CASE WHEN bi.status='${BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
140
+ .where('bi.building_level_id = :buildingLevelId', { buildingLevelId: buildingLevel.id })
141
+ .groupBy('bi.building_level_id')
142
+ .getRawOne()
143
+
144
+ return {
145
+ wait: buildingInspectionSummary?.wait || 0,
146
+ request: buildingInspectionSummary?.request || 0,
147
+ pass: buildingInspectionSummary?.pass || 0,
148
+ fail: buildingInspectionSummary?.fail || 0
149
+ }
150
+ }
151
+
152
+ @Query(returns => BuildingInspectionSummary, { description: '프로젝트의 검측상태 별 카운트' })
153
+ async buildingInspectionSummaryOfProject(
154
+ @Arg('projectId') projectId: string,
155
+ @Ctx() context: ResolverContext
156
+ ): Promise<BuildingInspectionSummary> {
157
+ const { domain } = context.state
158
+
159
+ const result = await getRepository(Project)
160
+ .createQueryBuilder('p')
161
+ .select(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.WAIT}' THEN 1 ELSE NULL END) AS wait`)
162
+ .addSelect(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.REQUEST}' THEN 1 ELSE NULL END) AS request`)
163
+ .addSelect(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.PASS}' THEN 1 ELSE NULL END) AS pass`)
164
+ .addSelect(`COUNT(CASE WHEN bi.status = '${BuildingInspectionStatus.FAIL}' THEN 1 ELSE NULL END) AS fail`)
165
+ .innerJoin('p.buildingComplex', 'bc')
166
+ .innerJoin('bc.buildings', 'b')
167
+ .innerJoin('b.buildingLevels', 'bl')
168
+ .leftJoin('building_inspections', 'bi', 'bi.building_level_id = bl.id AND bi.deleted_at IS NULL')
169
+ .where('p.domain = :domain', { domain: domain.id })
170
+ .andWhere('p.id = :projectId', { projectId })
171
+ .groupBy('p.id')
172
+ .getRawOne()
173
+
174
+ return {
175
+ wait: result.wait || 0,
176
+ request: result.request || 0,
177
+ pass: result.pass || 0,
178
+ fail: result.fail || 0
179
+ }
180
+ }
181
+
182
+ @FieldResolver(type => Checklist)
183
+ async checklist(@Root() buildingInspection: BuildingInspection): Promise<Checklist> {
184
+ return await getRepository(Checklist).findOneBy({ id: buildingInspection.checklistId })
185
+ }
186
+
187
+ @FieldResolver(type => BuildingLevel)
188
+ async buildingLevel(@Root() buildingInspection: BuildingInspection): Promise<BuildingLevel> {
189
+ return await getRepository(BuildingLevel).findOneBy({ id: buildingInspection.buildingLevelId })
190
+ }
191
+
192
+ @FieldResolver(type => [Attachment])
193
+ async attatchments(@Root() buildingInspection: BuildingInspection): Promise<Attachment[] | undefined> {
194
+ const attachment: Attachment[] = await getRepository(Attachment).find({
195
+ where: {
196
+ refType: BuildingInspection.name,
197
+ refBy: buildingInspection.id
198
+ }
199
+ })
200
+ return attachment
201
+ }
202
+ }
@@ -0,0 +1,142 @@
1
+ import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
2
+ import { BuildingInspection, BuildingInspectionStatus } from './building-inspection'
3
+
4
+ @InputType()
5
+ class ChecklistInputType {
6
+ @Field({ nullable: false })
7
+ name: string
8
+
9
+ @Field({ nullable: false })
10
+ constructionType: string
11
+
12
+ @Field({ nullable: false })
13
+ constructionDetailType: string
14
+
15
+ @Field({ nullable: false })
16
+ location?: string
17
+
18
+ @Field({ nullable: false })
19
+ inspectionDrawingType?: string
20
+
21
+ @Field(type => [String], { nullable: false })
22
+ inspectionParts?: string[]
23
+ }
24
+
25
+ @InputType()
26
+ class ChecklistItemInputType {
27
+ @Field({ nullable: false })
28
+ name: string
29
+
30
+ @Field({ nullable: false })
31
+ mainType: string
32
+
33
+ @Field({ nullable: false })
34
+ detailType: string
35
+
36
+ @Field({ nullable: true })
37
+ inspctionCriteria: string
38
+ }
39
+
40
+ @InputType()
41
+ export class NewBuildingInspection {
42
+ @Field({ nullable: false })
43
+ buildingLevelId: string
44
+
45
+ @Field(type => ChecklistInputType, { nullable: false })
46
+ checklist: ChecklistInputType
47
+
48
+ @Field(type => [ChecklistItemInputType], { nullable: false })
49
+ checklistItem: ChecklistItemInputType[]
50
+ }
51
+
52
+ @InputType()
53
+ class ChecklistSubmitInputType {
54
+ @Field({ nullable: false })
55
+ id: string
56
+
57
+ @Field({ nullable: true })
58
+ overallConstructorSignature?: string
59
+
60
+ @Field({ nullable: true })
61
+ taskConstructorSignature?: string
62
+
63
+ @Field({ nullable: true })
64
+ overallSupervisorySignature?: string
65
+
66
+ @Field({ nullable: true })
67
+ taskSupervisorySignature?: string
68
+ }
69
+
70
+ @InputType()
71
+ class ChecklistItemSubmitInputType {
72
+ @Field({ nullable: false })
73
+ id: string
74
+
75
+ @Field({ nullable: true })
76
+ constructionConfirmStatus?: string
77
+
78
+ @Field({ nullable: true })
79
+ supervisoryConfirmStatus?: string
80
+ }
81
+
82
+ @InputType()
83
+ export class UpdateBuildingInspectionSubmitType {
84
+ @Field({ nullable: false })
85
+ id: string
86
+
87
+ @Field(type => ChecklistSubmitInputType, { nullable: false })
88
+ checklist: ChecklistSubmitInputType
89
+
90
+ @Field(type => [ChecklistItemSubmitInputType], { nullable: false })
91
+ checklistItem: ChecklistItemSubmitInputType[]
92
+ }
93
+ @InputType()
94
+ export class UpdateBuildingInspectionDrawingMarker {
95
+ @Field({ nullable: false })
96
+ id: string
97
+
98
+ @Field(type => String, { nullable: true })
99
+ drawingMarker?: string
100
+ }
101
+
102
+ @InputType()
103
+ export class BuildingInspectionsOfProject {
104
+ @Field({ nullable: false })
105
+ projectId: string
106
+
107
+ @Field({ nullable: true })
108
+ limit: number
109
+ }
110
+
111
+ @InputType()
112
+ export class BuildingInspectionsOfBuildingLevel {
113
+ @Field({ nullable: false })
114
+ buildingLevelId: string
115
+
116
+ @Field({ nullable: true })
117
+ limit: number
118
+ }
119
+
120
+ @ObjectType()
121
+ export class BuildingInspectionSummary {
122
+ @Field(type => Int, { description: '검측 대기 수' })
123
+ wait: number
124
+
125
+ @Field(type => Int, { description: '검측 요청 수' })
126
+ request: number
127
+
128
+ @Field(type => Int, { description: '검측 통과 수' })
129
+ pass: number
130
+
131
+ @Field(type => Int, { description: '검측 실패 수' })
132
+ fail: number
133
+ }
134
+
135
+ @ObjectType()
136
+ export class BuildingInspectionList {
137
+ @Field(type => [BuildingInspection])
138
+ items: BuildingInspection[]
139
+
140
+ @Field(type => Int)
141
+ total: number
142
+ }
@@ -0,0 +1,106 @@
1
+ import {
2
+ CreateDateColumn,
3
+ UpdateDateColumn,
4
+ DeleteDateColumn,
5
+ Entity,
6
+ Index,
7
+ Column,
8
+ RelationId,
9
+ ManyToOne,
10
+ OneToOne,
11
+ PrimaryGeneratedColumn,
12
+ JoinColumn
13
+ } from 'typeorm'
14
+ import { ObjectType, Field, ID, registerEnumType } from 'type-graphql'
15
+
16
+ import { User } from '@things-factory/auth-base'
17
+ import { BuildingLevel } from '@dssp/building-complex'
18
+ import { Checklist } from '../checklist/checklist'
19
+
20
+ export enum BuildingInspectionStatus {
21
+ WAIT = 'WAIT',
22
+ REQUEST = 'REQUEST',
23
+ PASS = 'PASS',
24
+ FAIL = 'FAIL'
25
+ }
26
+
27
+ registerEnumType(BuildingInspectionStatus, {
28
+ name: 'BuildingInspectionStatus',
29
+ description: '검측 상태'
30
+ })
31
+
32
+ @Entity({ comment: '시공 검측 (층별 도면의 검측 리스트)' })
33
+ @Index('ix_building_inspection_0', (buildingInspection: BuildingInspection) => [buildingInspection.buildingLevel], {
34
+ where: '"deleted_at" IS NULL'
35
+ })
36
+ @Index('ix_building_inspection_1', (buildingInspection: BuildingInspection) => [buildingInspection.checklist], {
37
+ where: '"deleted_at" IS NULL'
38
+ })
39
+ @Index('ix_building_inspection_2', (buildingInspection: BuildingInspection) => [buildingInspection.requestDate], {
40
+ where: '"deleted_at" IS NULL'
41
+ })
42
+ @ObjectType()
43
+ export class BuildingInspection {
44
+ @PrimaryGeneratedColumn('uuid')
45
+ @Field(type => ID)
46
+ readonly id: string
47
+
48
+ @Column({
49
+ nullable: false,
50
+ comment: '상태(WAIT: 검측 대기, REQUEST: 검측 요청, PASS: 합격, FAIL: 불합격)',
51
+ default: 'WAIT'
52
+ })
53
+ @Field({ nullable: true })
54
+ status?: BuildingInspectionStatus
55
+
56
+ @Column({ nullable: false, comment: '검측 요청일' })
57
+ @Field({ nullable: true })
58
+ requestDate?: Date
59
+
60
+ @Column({ type: 'simple-json', nullable: true, comment: '도면 마커' })
61
+ @Field(type => String, { nullable: true })
62
+ drawingMarker?: string
63
+
64
+ // 층 정보 (1:1 상위 테이블 참조)
65
+ @ManyToOne(type => BuildingLevel)
66
+ @Field(() => BuildingLevel, { nullable: true })
67
+ buildingLevel?: BuildingLevel
68
+
69
+ @RelationId((buildingInspection: BuildingInspection) => buildingInspection.buildingLevel)
70
+ buildingLevelId?: string
71
+
72
+ // 체크리스트 (1:1 상위 테이블 참조)
73
+ @OneToOne(type => Checklist)
74
+ @JoinColumn()
75
+ @Field(() => Checklist, { nullable: true })
76
+ checklist?: Checklist
77
+
78
+ @RelationId((buildingInspection: BuildingInspection) => buildingInspection.checklist)
79
+ checklistId?: string
80
+
81
+ @CreateDateColumn()
82
+ @Field({ nullable: true })
83
+ createdAt?: Date
84
+
85
+ @UpdateDateColumn()
86
+ @Field({ nullable: true })
87
+ updatedAt?: Date
88
+
89
+ @DeleteDateColumn()
90
+ @Field({ nullable: true })
91
+ deletedAt?: Date
92
+
93
+ @ManyToOne(type => User, { nullable: true })
94
+ @Field(type => User, { nullable: true })
95
+ creator?: User
96
+
97
+ @RelationId((buildingInspection: BuildingInspection) => buildingInspection.creator)
98
+ creatorId?: string
99
+
100
+ @ManyToOne(type => User, { nullable: true })
101
+ @Field(type => User, { nullable: true })
102
+ updater?: User
103
+
104
+ @RelationId((buildingInspection: BuildingInspection) => buildingInspection.updater)
105
+ updaterId?: string
106
+ }
@@ -0,0 +1,20 @@
1
+ import { EventSubscriber } from 'typeorm'
2
+
3
+ import { HistoryEntitySubscriber } from '@operato/typeorm-history'
4
+
5
+ import { BuildingInspection } from './building-inspection'
6
+ import { BuildingInspectionHistory } from './building-inspection-history'
7
+
8
+ @EventSubscriber()
9
+ export class BuildingInspectionHistoryEntitySubscriber extends HistoryEntitySubscriber<
10
+ BuildingInspection,
11
+ BuildingInspectionHistory
12
+ > {
13
+ public get entity() {
14
+ return BuildingInspection
15
+ }
16
+
17
+ public get historyEntity() {
18
+ return BuildingInspectionHistory
19
+ }
20
+ }
@@ -0,0 +1,11 @@
1
+ import { BuildingInspection, BuildingInspectionStatus } from './building-inspection'
2
+ import { BuildingInspectionQuery } from './building-inspection-query'
3
+ import { BuildingInspectionMutation } from './building-inspection-mutation'
4
+ import { BuildingInspectionSummary } from './building-inspection-type'
5
+ import { BuildingInspectionHistory } from './building-inspection-history'
6
+ import { BuildingInspectionHistoryEntitySubscriber } from './event-subscriber'
7
+
8
+ export const entities = [BuildingInspection, BuildingInspectionHistory]
9
+ export const resolvers = [BuildingInspectionQuery, BuildingInspectionMutation]
10
+ export const subscribers = [BuildingInspectionHistoryEntitySubscriber]
11
+ export const types = [BuildingInspectionStatus, BuildingInspectionSummary]
@@ -0,0 +1,96 @@
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 { Checklist } from './checklist'
7
+
8
+ const ORMCONFIG = config.get('ormconfig', {})
9
+ const DATABASE_TYPE = ORMCONFIG.type
10
+
11
+ @Entity()
12
+ @Index('ix_checklist_history_0', (checklistHistory: ChecklistHistory) => [checklistHistory.originalId])
13
+ @ObjectType({ description: 'History Entity of Checklist' })
14
+ export class ChecklistHistory implements HistoryEntityInterface<Checklist> {
15
+ @PrimaryGeneratedColumn('uuid')
16
+ @Field(type => ID)
17
+ readonly id: string
18
+
19
+ @Column({ nullable: true, comment: '이름' })
20
+ @Field({ nullable: true })
21
+ name?: string
22
+
23
+ @Column({ nullable: true, comment: '문서 번호 동(4자리)-층(3자리)-시퀀스(6자리)' })
24
+ @Field({ nullable: true })
25
+ documentNo?: string
26
+
27
+ @Column({ nullable: false, comment: '공종' })
28
+ @Field({ nullable: true })
29
+ constructionType?: string
30
+
31
+ @Column({ nullable: false, comment: '세부 공종' })
32
+ @Field({ nullable: true })
33
+ constructionDetailType?: string
34
+
35
+ @Column({ nullable: false, comment: '위치 (x동 x층)' })
36
+ @Field({ nullable: true })
37
+ location?: string
38
+
39
+ @Column({ nullable: false, comment: '검측 도면 타입', default: '' })
40
+ @Field({ nullable: true })
41
+ inspectionDrawingType?: string
42
+
43
+ @Column('simple-array', { nullable: true, comment: '검측 부위' })
44
+ @Field(() => [String], { nullable: true })
45
+ inspectionParts?: string[]
46
+
47
+ @Column({ nullable: true, comment: '시공자 점검일' })
48
+ @Field({ nullable: true })
49
+ constructionInspectionDate?: Date
50
+
51
+ @Column({ nullable: true, comment: '감리자 점검일' })
52
+ @Field({ nullable: true })
53
+ supervisorInspectionDate?: Date
54
+
55
+ @Column({ nullable: true, comment: '총괄 시공 책임자 사인' })
56
+ @Field({ nullable: true })
57
+ overallConstructorSignature?: string
58
+
59
+ @Column({ nullable: true, comment: '공종별 시공 관리자 사인' })
60
+ @Field({ nullable: true })
61
+ taskConstructorSignature?: string
62
+
63
+ @Column({ nullable: true, comment: '총괄 감리 책임자 사인' })
64
+ @Field({ nullable: true })
65
+ overallSupervisorySignature?: string
66
+
67
+ @Column({ nullable: true, comment: '건축사보 (공종별 감리 관리자) 사인' })
68
+ @Field({ nullable: true })
69
+ taskSupervisorySignature?: string
70
+
71
+ @Column({ nullable: true })
72
+ @Field({ nullable: true })
73
+ createdAt?: Date
74
+
75
+ @ManyToOne(type => User, { nullable: true })
76
+ @Field(type => User, { nullable: true })
77
+ creator?: User
78
+
79
+ @RelationId((checklistHistory: ChecklistHistory) => checklistHistory.creator)
80
+ creatorId?: string
81
+
82
+ @HistoryOriginalIdColumn()
83
+ public originalId!: string
84
+
85
+ @HistoryActionColumn({
86
+ nullable: false,
87
+ type:
88
+ DATABASE_TYPE == 'postgres' || DATABASE_TYPE == 'mysql' || DATABASE_TYPE == 'mariadb'
89
+ ? 'enum'
90
+ : DATABASE_TYPE == 'oracle'
91
+ ? 'varchar2'
92
+ : 'smallint',
93
+ enum: HistoryActionType
94
+ })
95
+ public action!: HistoryActionType
96
+ }
@@ -0,0 +1,103 @@
1
+ import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'
2
+ import { In } from 'typeorm'
3
+ import { Checklist } from './checklist'
4
+ import { NewChecklist, ChecklistPatch } from './checklist-type'
5
+
6
+ @Resolver(Checklist)
7
+ export class ChecklistMutation {
8
+ @Directive('@transaction')
9
+ @Mutation(returns => Checklist, { description: 'To create new Checklist' })
10
+ async createChecklist(@Arg('checklist') checklist: NewChecklist, @Ctx() context: ResolverContext): Promise<Checklist> {
11
+ const { domain, user, tx } = context.state
12
+
13
+ const result = await tx.getRepository(Checklist).save({
14
+ ...checklist,
15
+ domain,
16
+ creator: user,
17
+ updater: user
18
+ })
19
+
20
+ return result
21
+ }
22
+
23
+ @Directive('@transaction')
24
+ @Mutation(returns => Checklist, { description: 'To modify Checklist information' })
25
+ async updateChecklist(
26
+ @Arg('id') id: string,
27
+ @Arg('patch') patch: ChecklistPatch,
28
+ @Ctx() context: ResolverContext
29
+ ): Promise<Checklist> {
30
+ const { domain, user, tx } = context.state
31
+
32
+ const repository = tx.getRepository(Checklist)
33
+ const checklist = await repository.findOne({
34
+ where: { id }
35
+ })
36
+
37
+ const result = await repository.save({
38
+ ...checklist,
39
+ ...patch,
40
+ updater: user
41
+ })
42
+
43
+ return result
44
+ }
45
+
46
+ @Directive('@transaction')
47
+ @Mutation(returns => [Checklist], { description: "To modify multiple Checklists' information" })
48
+ async updateMultipleChecklist(
49
+ @Arg('patches', type => [ChecklistPatch]) patches: ChecklistPatch[],
50
+ @Ctx() context: ResolverContext
51
+ ): Promise<Checklist[]> {
52
+ const { domain, user, tx } = context.state
53
+
54
+ let results = []
55
+ const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')
56
+ const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')
57
+ const checklistRepo = tx.getRepository(Checklist)
58
+
59
+ if (_createRecords.length > 0) {
60
+ for (let i = 0; i < _createRecords.length; i++) {
61
+ const newRecord = _createRecords[i]
62
+
63
+ const result = await checklistRepo.save({
64
+ ...newRecord,
65
+ domain,
66
+ creator: user,
67
+ updater: user
68
+ })
69
+
70
+ results.push({ ...result, cuFlag: '+' })
71
+ }
72
+ }
73
+
74
+ if (_updateRecords.length > 0) {
75
+ for (let i = 0; i < _updateRecords.length; i++) {
76
+ const updateRecord = _updateRecords[i]
77
+ const checklist = await checklistRepo.findOneBy({ id: updateRecord.id })
78
+
79
+ const result = await checklistRepo.save({
80
+ ...checklist,
81
+ ...updateRecord,
82
+ updater: user
83
+ })
84
+
85
+ results.push({ ...result, cuFlag: 'M' })
86
+ }
87
+ }
88
+
89
+ return results
90
+ }
91
+
92
+ @Directive('@transaction')
93
+ @Mutation(returns => Boolean, { description: 'To delete multiple Checklists' })
94
+ async deleteChecklists(@Arg('ids', type => [String]) ids: string[], @Ctx() context: ResolverContext): Promise<boolean> {
95
+ const { domain, tx } = context.state
96
+
97
+ await tx.getRepository(Checklist).softDelete({
98
+ id: In(ids)
99
+ })
100
+
101
+ return true
102
+ }
103
+ }