@dssp/supervision 1.0.0-alpha.9 → 1.0.0-alpha.93

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 (363) hide show
  1. package/dist-client/graphql/building-inspection.d.ts +1 -0
  2. package/dist-client/graphql/building-inspection.js +102 -0
  3. package/dist-client/graphql/building-inspection.js.map +1 -0
  4. package/dist-client/pages/action-plan/action-plan-list-page.d.ts +1 -2
  5. package/dist-client/pages/action-plan/action-plan-list-page.js +1 -2
  6. package/dist-client/pages/action-plan/action-plan-list-page.js.map +1 -1
  7. package/dist-client/pages/building-inspection/building-inspection-detail-ai-defect.d.ts +22 -0
  8. package/dist-client/pages/building-inspection/building-inspection-detail-ai-defect.js +171 -0
  9. package/dist-client/pages/building-inspection/building-inspection-detail-ai-defect.js.map +1 -0
  10. package/dist-client/pages/building-inspection/building-inspection-detail-ai-measurement.d.ts +59 -0
  11. package/dist-client/pages/building-inspection/building-inspection-detail-ai-measurement.js +868 -0
  12. package/dist-client/pages/building-inspection/building-inspection-detail-ai-measurement.js.map +1 -0
  13. package/dist-client/pages/building-inspection/building-inspection-detail-camera.d.ts +8 -6
  14. package/dist-client/pages/building-inspection/building-inspection-detail-camera.js +116 -65
  15. package/dist-client/pages/building-inspection/building-inspection-detail-camera.js.map +1 -1
  16. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.d.ts +11 -0
  17. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js +147 -72
  18. package/dist-client/pages/building-inspection/building-inspection-detail-checklist.js.map +1 -1
  19. package/dist-client/pages/building-inspection/building-inspection-detail-drawing.d.ts +1 -0
  20. package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js +78 -14
  21. package/dist-client/pages/building-inspection/building-inspection-detail-drawing.js.map +1 -1
  22. package/dist-client/pages/building-inspection/building-inspection-list.d.ts +26 -2
  23. package/dist-client/pages/building-inspection/building-inspection-list.js +375 -34
  24. package/dist-client/pages/building-inspection/building-inspection-list.js.map +1 -1
  25. package/dist-client/pages/building-inspection/building-inspection-management.d.ts +82 -0
  26. package/dist-client/pages/building-inspection/building-inspection-management.js +1527 -0
  27. package/dist-client/pages/building-inspection/building-inspection-management.js.map +1 -0
  28. package/dist-client/pages/building-inspection/component/building-inspection-detail-header.d.ts +3 -0
  29. package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js +112 -20
  30. package/dist-client/pages/building-inspection/component/building-inspection-detail-header.js.map +1 -1
  31. package/dist-client/pages/building-inspection/component/daily-worklog-popup.d.ts +27 -0
  32. package/dist-client/pages/building-inspection/component/daily-worklog-popup.js +542 -0
  33. package/dist-client/pages/building-inspection/component/daily-worklog-popup.js.map +1 -0
  34. package/dist-client/pages/building-inspection/component/field-document/field-document-constants.d.ts +18 -0
  35. package/dist-client/pages/building-inspection/component/field-document/field-document-constants.js +630 -0
  36. package/dist-client/pages/building-inspection/component/field-document/field-document-constants.js.map +1 -0
  37. package/dist-client/pages/building-inspection/component/field-document/field-document-detail-popup.d.ts +10 -0
  38. package/dist-client/pages/building-inspection/component/field-document/field-document-detail-popup.js +219 -0
  39. package/dist-client/pages/building-inspection/component/field-document/field-document-detail-popup.js.map +1 -0
  40. package/dist-client/pages/building-inspection/component/field-document/field-document-list-panel.d.ts +25 -0
  41. package/dist-client/pages/building-inspection/component/field-document/field-document-list-panel.js +546 -0
  42. package/dist-client/pages/building-inspection/component/field-document/field-document-list-panel.js.map +1 -0
  43. package/dist-client/pages/building-inspection/component/field-document/field-document-popup.d.ts +42 -0
  44. package/dist-client/pages/building-inspection/component/field-document/field-document-popup.js +738 -0
  45. package/dist-client/pages/building-inspection/component/field-document/field-document-popup.js.map +1 -0
  46. package/dist-client/pages/building-inspection/component/image-preview-popup.d.ts +15 -0
  47. package/dist-client/pages/building-inspection/component/image-preview-popup.js +348 -0
  48. package/dist-client/pages/building-inspection/component/image-preview-popup.js.map +1 -0
  49. package/dist-client/pages/building-inspection/component/inspection-document/inspection-request-document.d.ts +25 -0
  50. package/dist-client/pages/building-inspection/component/inspection-document/inspection-request-document.js +491 -0
  51. package/dist-client/pages/building-inspection/component/inspection-document/inspection-request-document.js.map +1 -0
  52. package/dist-client/pages/building-inspection/component/inspection-document/inspection-result-notification.d.ts +31 -0
  53. package/dist-client/pages/building-inspection/component/inspection-document/inspection-result-notification.js +485 -0
  54. package/dist-client/pages/building-inspection/component/inspection-document/inspection-result-notification.js.map +1 -0
  55. package/dist-client/pages/building-inspection/component/inspection-document/photo-album-popup.d.ts +27 -0
  56. package/dist-client/pages/building-inspection/component/inspection-document/photo-album-popup.js +416 -0
  57. package/dist-client/pages/building-inspection/component/inspection-document/photo-album-popup.js.map +1 -0
  58. package/dist-client/pages/building-inspection/component/inspection-event-provider.d.ts +4 -2
  59. package/dist-client/pages/building-inspection/component/inspection-event-provider.js +156 -37
  60. package/dist-client/pages/building-inspection/component/inspection-event-provider.js.map +1 -1
  61. package/dist-client/pages/building-inspection/inspection-create-popup.js +23 -12
  62. package/dist-client/pages/building-inspection/inspection-create-popup.js.map +1 -1
  63. package/dist-client/pages/building-inspection/inspection-with-checklist-create-popup.d.ts +3 -0
  64. package/dist-client/pages/building-inspection/inspection-with-checklist-create-popup.js +817 -0
  65. package/dist-client/pages/building-inspection/inspection-with-checklist-create-popup.js.map +1 -0
  66. package/dist-client/pages/building-inspection-grid/building-inspection-grid-detail.d.ts +16 -2
  67. package/dist-client/pages/building-inspection-grid/building-inspection-grid-detail.js +250 -45
  68. package/dist-client/pages/building-inspection-grid/building-inspection-grid-detail.js.map +1 -1
  69. package/dist-client/pages/building-inspection-grid/component/grid-inspection-create-popup.js +10 -6
  70. package/dist-client/pages/building-inspection-grid/component/grid-inspection-create-popup.js.map +1 -1
  71. package/dist-client/pages/building-inspection-grid/component/grid-inspection-list-layer.d.ts +19 -0
  72. package/dist-client/pages/building-inspection-grid/component/grid-inspection-list-layer.js +205 -0
  73. package/dist-client/pages/building-inspection-grid/component/grid-inspection-list-layer.js.map +1 -0
  74. package/dist-client/pages/checklist/attachment-list-popup.d.ts +1 -0
  75. package/dist-client/pages/checklist/attachment-list-popup.js +251 -69
  76. package/dist-client/pages/checklist/attachment-list-popup.js.map +1 -1
  77. package/dist-client/pages/checklist/checklist-view.d.ts +6 -4
  78. package/dist-client/pages/checklist/checklist-view.js +249 -37
  79. package/dist-client/pages/checklist/checklist-view.js.map +1 -1
  80. package/dist-client/pages/checklist/comment-list-popup.js +15 -5
  81. package/dist-client/pages/checklist/comment-list-popup.js.map +1 -1
  82. package/dist-client/pages/checklist/file-preview-popup.js +0 -1
  83. package/dist-client/pages/checklist/file-preview-popup.js.map +1 -1
  84. package/dist-client/pages/checklist/inspection-info-popup.d.ts +49 -0
  85. package/dist-client/pages/checklist/inspection-info-popup.js +683 -0
  86. package/dist-client/pages/checklist/inspection-info-popup.js.map +1 -0
  87. package/dist-client/pages/checklist/inspection-tab-popup.d.ts +18 -0
  88. package/dist-client/pages/checklist/inspection-tab-popup.js +196 -0
  89. package/dist-client/pages/checklist/inspection-tab-popup.js.map +1 -0
  90. package/dist-client/pages/checklist/kcs-criteria-popup.d.ts +15 -0
  91. package/dist-client/pages/checklist/kcs-criteria-popup.js +174 -0
  92. package/dist-client/pages/checklist/kcs-criteria-popup.js.map +1 -0
  93. package/dist-client/pages/checklist-database/checklist-database.d.ts +35 -0
  94. package/dist-client/pages/checklist-database/checklist-database.js +540 -0
  95. package/dist-client/pages/checklist-database/checklist-database.js.map +1 -0
  96. package/dist-client/pages/checklist-template/checklist-template-item.js +39 -3
  97. package/dist-client/pages/checklist-template/checklist-template-item.js.map +1 -1
  98. package/dist-client/pages/checklist-template/checklist-template-list.js +3 -2
  99. package/dist-client/pages/checklist-template/checklist-template-list.js.map +1 -1
  100. package/dist-client/pages/checklist-template/construction-checklist-template-item-popup.d.ts +2 -0
  101. package/dist-client/pages/checklist-template/construction-checklist-template-item-popup.js +223 -0
  102. package/dist-client/pages/checklist-template/construction-checklist-template-item-popup.js.map +1 -0
  103. package/dist-client/pages/checklist-template/construction-checklist-template-list.d.ts +55 -0
  104. package/dist-client/pages/checklist-template/construction-checklist-template-list.js +404 -0
  105. package/dist-client/pages/checklist-template/construction-checklist-template-list.js.map +1 -0
  106. package/dist-client/pages/issue/issue-list-page.d.ts +1 -2
  107. package/dist-client/pages/issue/issue-list-page.js +1 -2
  108. package/dist-client/pages/issue/issue-list-page.js.map +1 -1
  109. package/dist-client/pages/project-checklist/project-checklist-management.d.ts +58 -0
  110. package/dist-client/pages/project-checklist/project-checklist-management.js +1076 -0
  111. package/dist-client/pages/project-checklist/project-checklist-management.js.map +1 -0
  112. package/dist-client/pages/project-report/project-report-list-page.d.ts +1 -2
  113. package/dist-client/pages/project-report/project-report-list-page.js +1 -2
  114. package/dist-client/pages/project-report/project-report-list-page.js.map +1 -1
  115. package/dist-client/pages/supervisor/supervisor-list-page.d.ts +1 -2
  116. package/dist-client/pages/supervisor/supervisor-list-page.js +1 -2
  117. package/dist-client/pages/supervisor/supervisor-list-page.js.map +1 -1
  118. package/dist-client/route.d.ts +1 -1
  119. package/dist-client/route.js +18 -0
  120. package/dist-client/route.js.map +1 -1
  121. package/dist-client/stt/speech-to-text.d.ts +13 -8
  122. package/dist-client/stt/speech-to-text.js +282 -40
  123. package/dist-client/stt/speech-to-text.js.map +1 -1
  124. package/dist-client/tsconfig.tsbuildinfo +1 -1
  125. package/dist-server/service/action-plan/action-plan-mutation.js +5 -6
  126. package/dist-server/service/action-plan/action-plan-mutation.js.map +1 -1
  127. package/dist-server/service/action-plan/action-plan-query.d.ts +2 -2
  128. package/dist-server/service/action-plan/action-plan-query.js +5 -11
  129. package/dist-server/service/action-plan/action-plan-query.js.map +1 -1
  130. package/dist-server/service/building-inspection/building-inspection-mutation.d.ts +2 -3
  131. package/dist-server/service/building-inspection/building-inspection-mutation.js +102 -34
  132. package/dist-server/service/building-inspection/building-inspection-mutation.js.map +1 -1
  133. package/dist-server/service/building-inspection/building-inspection-query.d.ts +9 -7
  134. package/dist-server/service/building-inspection/building-inspection-query.js +168 -52
  135. package/dist-server/service/building-inspection/building-inspection-query.js.map +1 -1
  136. package/dist-server/service/building-inspection/building-inspection-type.d.ts +32 -11
  137. package/dist-server/service/building-inspection/building-inspection-type.js +111 -23
  138. package/dist-server/service/building-inspection/building-inspection-type.js.map +1 -1
  139. package/dist-server/service/building-inspection/building-inspection.d.ts +5 -0
  140. package/dist-server/service/building-inspection/building-inspection.js +37 -4
  141. package/dist-server/service/building-inspection/building-inspection.js.map +1 -1
  142. package/dist-server/service/building-inspection/index.d.ts +3 -4
  143. package/dist-server/service/building-inspection/index.js +10 -3
  144. package/dist-server/service/building-inspection/index.js.map +1 -1
  145. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.d.ts +6 -0
  146. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.js +66 -0
  147. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-mutation.js.map +1 -0
  148. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-query.d.ts +16 -0
  149. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-query.js +171 -0
  150. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-query.js.map +1 -0
  151. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-type.d.ts +23 -0
  152. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-type.js +90 -0
  153. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog-type.js.map +1 -0
  154. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog.d.ts +33 -0
  155. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog.js +132 -0
  156. package/dist-server/service/building-inspection-daily-worklog/building-inspection-daily-worklog.js.map +1 -0
  157. package/dist-server/service/building-inspection-daily-worklog/index.d.ts +5 -0
  158. package/dist-server/service/building-inspection-daily-worklog/index.js +9 -0
  159. package/dist-server/service/building-inspection-daily-worklog/index.js.map +1 -0
  160. package/dist-server/service/building-inspection-history/building-inspection-history-query.d.ts +16 -0
  161. package/dist-server/service/building-inspection-history/building-inspection-history-query.js +120 -0
  162. package/dist-server/service/building-inspection-history/building-inspection-history-query.js.map +1 -0
  163. package/dist-server/service/building-inspection-history/building-inspection-history-type.d.ts +5 -0
  164. package/dist-server/service/building-inspection-history/building-inspection-history-type.js +21 -0
  165. package/dist-server/service/building-inspection-history/building-inspection-history-type.js.map +1 -0
  166. package/dist-server/service/building-inspection-history/building-inspection-history.d.ts +35 -0
  167. package/dist-server/service/building-inspection-history/building-inspection-history.js +162 -0
  168. package/dist-server/service/building-inspection-history/building-inspection-history.js.map +1 -0
  169. package/dist-server/service/building-inspection-history/event-subscriber.d.ts +7 -0
  170. package/dist-server/service/building-inspection-history/event-subscriber.js +21 -0
  171. package/dist-server/service/building-inspection-history/event-subscriber.js.map +1 -0
  172. package/dist-server/service/building-inspection-history/index.d.ts +6 -0
  173. package/dist-server/service/building-inspection-history/index.js +10 -0
  174. package/dist-server/service/building-inspection-history/index.js.map +1 -0
  175. package/dist-server/service/checklist/checklist-mutation.d.ts +0 -5
  176. package/dist-server/service/checklist/checklist-mutation.js +1 -67
  177. package/dist-server/service/checklist/checklist-mutation.js.map +1 -1
  178. package/dist-server/service/checklist/checklist-query.d.ts +7 -0
  179. package/dist-server/service/checklist/checklist-query.js +83 -0
  180. package/dist-server/service/checklist/checklist-query.js.map +1 -1
  181. package/dist-server/service/checklist/checklist-type.d.ts +0 -13
  182. package/dist-server/service/checklist/checklist-type.js +1 -49
  183. package/dist-server/service/checklist/checklist-type.js.map +1 -1
  184. package/dist-server/service/checklist/checklist.d.ts +24 -7
  185. package/dist-server/service/checklist/checklist.js +75 -30
  186. package/dist-server/service/checklist/checklist.js.map +1 -1
  187. package/dist-server/service/checklist/event-subscriber.d.ts +7 -0
  188. package/dist-server/service/checklist/event-subscriber.js +21 -0
  189. package/dist-server/service/checklist/event-subscriber.js.map +1 -0
  190. package/dist-server/service/checklist/index.d.ts +1 -2
  191. package/dist-server/service/checklist/index.js +1 -2
  192. package/dist-server/service/checklist/index.js.map +1 -1
  193. package/dist-server/service/checklist-history/checklist-history-query.d.ts +11 -0
  194. package/dist-server/service/checklist-history/checklist-history-query.js +77 -0
  195. package/dist-server/service/checklist-history/checklist-history-query.js.map +1 -0
  196. package/dist-server/service/checklist-history/checklist-history-type.d.ts +5 -0
  197. package/dist-server/service/checklist-history/checklist-history-type.js +21 -0
  198. package/dist-server/service/checklist-history/checklist-history-type.js.map +1 -0
  199. package/dist-server/service/{checklist → checklist-history}/checklist-history.d.ts +19 -1
  200. package/dist-server/service/{checklist → checklist-history}/checklist-history.js +97 -14
  201. package/dist-server/service/checklist-history/checklist-history.js.map +1 -0
  202. package/dist-server/service/checklist-history/event-subscriber.d.ts +7 -0
  203. package/dist-server/service/checklist-history/event-subscriber.js +21 -0
  204. package/dist-server/service/checklist-history/event-subscriber.js.map +1 -0
  205. package/dist-server/service/checklist-history/index.d.ts +6 -0
  206. package/dist-server/service/checklist-history/index.js +10 -0
  207. package/dist-server/service/checklist-history/index.js.map +1 -0
  208. package/dist-server/service/checklist-item/checklist-item-query.d.ts +1 -1
  209. package/dist-server/service/checklist-item/checklist-item-query.js +5 -3
  210. package/dist-server/service/checklist-item/checklist-item-query.js.map +1 -1
  211. package/dist-server/service/checklist-item/checklist-item.d.ts +2 -0
  212. package/dist-server/service/checklist-item/checklist-item.js +11 -1
  213. package/dist-server/service/checklist-item/checklist-item.js.map +1 -1
  214. package/dist-server/service/checklist-item/index.d.ts +0 -1
  215. package/dist-server/service/checklist-item/index.js +1 -2
  216. package/dist-server/service/checklist-item/index.js.map +1 -1
  217. package/dist-server/service/checklist-item-comment/checklist-item-comment-mutation.d.ts +1 -0
  218. package/dist-server/service/checklist-item-comment/checklist-item-comment-mutation.js +33 -6
  219. package/dist-server/service/checklist-item-comment/checklist-item-comment-mutation.js.map +1 -1
  220. package/dist-server/service/checklist-item-history/checklist-item-history-query.d.ts +16 -0
  221. package/dist-server/service/checklist-item-history/checklist-item-history-query.js +123 -0
  222. package/dist-server/service/checklist-item-history/checklist-item-history-query.js.map +1 -0
  223. package/dist-server/service/checklist-item-history/checklist-item-history-type.d.ts +5 -0
  224. package/dist-server/service/checklist-item-history/checklist-item-history-type.js +21 -0
  225. package/dist-server/service/checklist-item-history/checklist-item-history-type.js.map +1 -0
  226. package/dist-server/service/checklist-item-history/checklist-item-history.d.ts +27 -0
  227. package/dist-server/service/checklist-item-history/checklist-item-history.js +133 -0
  228. package/dist-server/service/checklist-item-history/checklist-item-history.js.map +1 -0
  229. package/dist-server/service/checklist-item-history/event-subscriber.d.ts +7 -0
  230. package/dist-server/service/checklist-item-history/event-subscriber.js +21 -0
  231. package/dist-server/service/checklist-item-history/event-subscriber.js.map +1 -0
  232. package/dist-server/service/checklist-item-history/index.d.ts +6 -0
  233. package/dist-server/service/checklist-item-history/index.js +10 -0
  234. package/dist-server/service/checklist-item-history/index.js.map +1 -0
  235. package/dist-server/service/checklist-template/checklist-template-query.d.ts +1 -1
  236. package/dist-server/service/checklist-template/checklist-template-query.js +2 -5
  237. package/dist-server/service/checklist-template/checklist-template-query.js.map +1 -1
  238. package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js +13 -1
  239. package/dist-server/service/checklist-template-item/checklist-template-item-mutation.js.map +1 -1
  240. package/dist-server/service/checklist-template-item/checklist-template-item-type.d.ts +3 -0
  241. package/dist-server/service/checklist-template-item/checklist-template-item-type.js +9 -0
  242. package/dist-server/service/checklist-template-item/checklist-template-item-type.js.map +1 -1
  243. package/dist-server/service/checklist-template-item/checklist-template-item.d.ts +7 -0
  244. package/dist-server/service/checklist-template-item/checklist-template-item.js +22 -2
  245. package/dist-server/service/checklist-template-item/checklist-template-item.js.map +1 -1
  246. package/dist-server/service/checklist-template-item/spec-matching-service.d.ts +2 -0
  247. package/dist-server/service/checklist-template-item/spec-matching-service.js +51 -0
  248. package/dist-server/service/checklist-template-item/spec-matching-service.js.map +1 -0
  249. package/dist-server/service/checklist-type/checklist-type-query.d.ts +1 -1
  250. package/dist-server/service/checklist-type/checklist-type-query.js +2 -5
  251. package/dist-server/service/checklist-type/checklist-type-query.js.map +1 -1
  252. package/dist-server/service/construction-checklist-template/construction-checklist-template-mutation.d.ts +7 -0
  253. package/dist-server/service/construction-checklist-template/construction-checklist-template-mutation.js +107 -0
  254. package/dist-server/service/construction-checklist-template/construction-checklist-template-mutation.js.map +1 -0
  255. package/dist-server/service/construction-checklist-template/construction-checklist-template-query.d.ts +10 -0
  256. package/dist-server/service/construction-checklist-template/construction-checklist-template-query.js +62 -0
  257. package/dist-server/service/construction-checklist-template/construction-checklist-template-query.js.map +1 -0
  258. package/dist-server/service/construction-checklist-template/construction-checklist-template-type.d.ts +11 -0
  259. package/dist-server/service/construction-checklist-template/construction-checklist-template-type.js +43 -0
  260. package/dist-server/service/construction-checklist-template/construction-checklist-template-type.js.map +1 -0
  261. package/dist-server/service/construction-checklist-template/construction-checklist-template.d.ts +18 -0
  262. package/dist-server/service/construction-checklist-template/construction-checklist-template.js +80 -0
  263. package/dist-server/service/construction-checklist-template/construction-checklist-template.js.map +1 -0
  264. package/dist-server/service/construction-checklist-template/index.d.ts +5 -0
  265. package/dist-server/service/construction-checklist-template/index.js +9 -0
  266. package/dist-server/service/construction-checklist-template/index.js.map +1 -0
  267. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item-mutation.d.ts +6 -0
  268. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item-mutation.js +56 -0
  269. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item-mutation.js.map +1 -0
  270. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item-query.d.ts +9 -0
  271. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item-query.js +53 -0
  272. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item-query.js.map +1 -0
  273. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item-type.d.ts +17 -0
  274. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item-type.js +67 -0
  275. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item-type.js.map +1 -0
  276. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item.d.ts +24 -0
  277. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item.js +113 -0
  278. package/dist-server/service/construction-checklist-template-item/construction-checklist-template-item.js.map +1 -0
  279. package/dist-server/service/construction-checklist-template-item/index.d.ts +5 -0
  280. package/dist-server/service/construction-checklist-template-item/index.js +9 -0
  281. package/dist-server/service/construction-checklist-template-item/index.js.map +1 -0
  282. package/dist-server/service/field-document/field-document-auto-file.d.ts +21 -0
  283. package/dist-server/service/field-document/field-document-auto-file.js +47 -0
  284. package/dist-server/service/field-document/field-document-auto-file.js.map +1 -0
  285. package/dist-server/service/field-document/field-document-mutation.d.ts +9 -0
  286. package/dist-server/service/field-document/field-document-mutation.js +139 -0
  287. package/dist-server/service/field-document/field-document-mutation.js.map +1 -0
  288. package/dist-server/service/field-document/field-document-query.d.ts +14 -0
  289. package/dist-server/service/field-document/field-document-query.js +120 -0
  290. package/dist-server/service/field-document/field-document-query.js.map +1 -0
  291. package/dist-server/service/field-document/field-document-summary-service.d.ts +10 -0
  292. package/dist-server/service/field-document/field-document-summary-service.js +79 -0
  293. package/dist-server/service/field-document/field-document-summary-service.js.map +1 -0
  294. package/dist-server/service/field-document/field-document-type.d.ts +24 -0
  295. package/dist-server/service/field-document/field-document-type.js +88 -0
  296. package/dist-server/service/field-document/field-document-type.js.map +1 -0
  297. package/dist-server/service/field-document/field-document.d.ts +29 -0
  298. package/dist-server/service/field-document/field-document.js +127 -0
  299. package/dist-server/service/field-document/field-document.js.map +1 -0
  300. package/dist-server/service/field-document/index.d.ts +5 -0
  301. package/dist-server/service/field-document/index.js +9 -0
  302. package/dist-server/service/field-document/index.js.map +1 -0
  303. package/dist-server/service/index.d.ts +9 -1
  304. package/dist-server/service/index.js +42 -3
  305. package/dist-server/service/index.js.map +1 -1
  306. package/dist-server/service/issue/issue-mutation.js +5 -6
  307. package/dist-server/service/issue/issue-mutation.js.map +1 -1
  308. package/dist-server/service/issue/issue-query.d.ts +2 -2
  309. package/dist-server/service/issue/issue-query.js +5 -11
  310. package/dist-server/service/issue/issue-query.js.map +1 -1
  311. package/dist-server/service/project-checklist/index.d.ts +5 -0
  312. package/dist-server/service/project-checklist/index.js +9 -0
  313. package/dist-server/service/project-checklist/index.js.map +1 -0
  314. package/dist-server/service/project-checklist/project-checklist-mutation.d.ts +7 -0
  315. package/dist-server/service/project-checklist/project-checklist-mutation.js +118 -0
  316. package/dist-server/service/project-checklist/project-checklist-mutation.js.map +1 -0
  317. package/dist-server/service/project-checklist/project-checklist-query.d.ts +12 -0
  318. package/dist-server/service/project-checklist/project-checklist-query.js +76 -0
  319. package/dist-server/service/project-checklist/project-checklist-query.js.map +1 -0
  320. package/dist-server/service/project-checklist/project-checklist-type.d.ts +18 -0
  321. package/dist-server/service/project-checklist/project-checklist-type.js +69 -0
  322. package/dist-server/service/project-checklist/project-checklist-type.js.map +1 -0
  323. package/dist-server/service/project-checklist/project-checklist.d.ts +20 -0
  324. package/dist-server/service/project-checklist/project-checklist.js +90 -0
  325. package/dist-server/service/project-checklist/project-checklist.js.map +1 -0
  326. package/dist-server/service/project-checklist/spec-matching-service.d.ts +17 -0
  327. package/dist-server/service/project-checklist/spec-matching-service.js +91 -0
  328. package/dist-server/service/project-checklist/spec-matching-service.js.map +1 -0
  329. package/dist-server/service/project-checklist-item/index.d.ts +4 -0
  330. package/dist-server/service/project-checklist-item/index.js +9 -0
  331. package/dist-server/service/project-checklist-item/index.js.map +1 -0
  332. package/dist-server/service/project-checklist-item/project-checklist-item-mutation.d.ts +2 -0
  333. package/dist-server/service/project-checklist-item/project-checklist-item-mutation.js +13 -0
  334. package/dist-server/service/project-checklist-item/project-checklist-item-mutation.js.map +1 -0
  335. package/dist-server/service/project-checklist-item/project-checklist-item-query.d.ts +5 -0
  336. package/dist-server/service/project-checklist-item/project-checklist-item-query.js +34 -0
  337. package/dist-server/service/project-checklist-item/project-checklist-item-query.js.map +1 -0
  338. package/dist-server/service/project-checklist-item/project-checklist-item-type.d.ts +5 -0
  339. package/dist-server/service/project-checklist-item/project-checklist-item-type.js +21 -0
  340. package/dist-server/service/project-checklist-item/project-checklist-item-type.js.map +1 -0
  341. package/dist-server/service/project-checklist-item/project-checklist-item.d.ts +19 -0
  342. package/dist-server/service/project-checklist-item/project-checklist-item.js +92 -0
  343. package/dist-server/service/project-checklist-item/project-checklist-item.js.map +1 -0
  344. package/dist-server/service/project-report/project-report-mutation.js +5 -6
  345. package/dist-server/service/project-report/project-report-mutation.js.map +1 -1
  346. package/dist-server/service/project-report/project-report-query.d.ts +2 -2
  347. package/dist-server/service/project-report/project-report-query.js +5 -11
  348. package/dist-server/service/project-report/project-report-query.js.map +1 -1
  349. package/dist-server/service/project-report/project-report.d.ts +0 -2
  350. package/dist-server/service/project-report/project-report.js +0 -6
  351. package/dist-server/service/project-report/project-report.js.map +1 -1
  352. package/dist-server/service/supervisor/supervisor-mutation.js +5 -6
  353. package/dist-server/service/supervisor/supervisor-mutation.js.map +1 -1
  354. package/dist-server/service/supervisor/supervisor-query.d.ts +2 -2
  355. package/dist-server/service/supervisor/supervisor-query.js +5 -11
  356. package/dist-server/service/supervisor/supervisor-query.js.map +1 -1
  357. package/dist-server/tsconfig.tsbuildinfo +1 -1
  358. package/package.json +14 -13
  359. package/things-factory.config.js +9 -1
  360. package/dist-server/service/building-inspection/building-inspection-history.d.ts +0 -17
  361. package/dist-server/service/building-inspection/building-inspection-history.js +0 -86
  362. package/dist-server/service/building-inspection/building-inspection-history.js.map +0 -1
  363. package/dist-server/service/checklist/checklist-history.js.map +0 -1
@@ -23,10 +23,10 @@ let ActionPlanMutation = class ActionPlanMutation {
23
23
  return result;
24
24
  }
25
25
  async updateActionPlan(id, patch, context) {
26
- const { domain, user, tx } = context.state;
26
+ const { user, tx } = context.state;
27
27
  const repository = tx.getRepository(action_plan_1.ActionPlan);
28
28
  const actionPlan = await repository.findOne({
29
- where: { domain: { id: domain.id }, id }
29
+ where: { id }
30
30
  });
31
31
  const result = await repository.save(Object.assign(Object.assign(Object.assign({}, actionPlan), patch), { updater: user }));
32
32
  if (patch.thumbnail) {
@@ -84,15 +84,14 @@ let ActionPlanMutation = class ActionPlanMutation {
84
84
  return results;
85
85
  }
86
86
  async deleteActionPlan(id, context) {
87
- const { domain, tx } = context.state;
88
- await tx.getRepository(action_plan_1.ActionPlan).delete({ domain: { id: domain.id }, id });
87
+ const { tx } = context.state;
88
+ await tx.getRepository(action_plan_1.ActionPlan).delete({ id });
89
89
  await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
90
90
  return true;
91
91
  }
92
92
  async deleteActionPlans(ids, context) {
93
- const { domain, tx } = context.state;
93
+ const { tx } = context.state;
94
94
  await tx.getRepository(action_plan_1.ActionPlan).delete({
95
- domain: { id: domain.id },
96
95
  id: (0, typeorm_1.In)(ids)
97
96
  });
98
97
  await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: ids }, context);
@@ -1 +1 @@
1
- {"version":3,"file":"action-plan-mutation.js","sourceRoot":"","sources":["../../../server/service/action-plan/action-plan-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,+CAA0C;AAC1C,yDAAmE;AAG5D,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,gBAAgB,CAAoB,UAAyB,EAAS,OAAwB;QAClG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAU,CAAC,CAAC,IAAI,iCACjD,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,IAAI,UAAU,CAAC,SAAS,E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C,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,gCAAgC,EAAE,CAAC;IAE7E,mBAAA,IAAA,kBAAG,EAAC,aAAa,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,kCAAe,CAAC,CAAC,CAAA;IAC7C,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2DAWP;6BA3LU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,wBAAU,CAAC;GACR,kBAAkB,CA4L9B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { ActionPlan } from './action-plan'\nimport { NewActionPlan, ActionPlanPatch } from './action-plan-type'\n\n@Resolver(ActionPlan)\nexport class ActionPlanMutation {\n @Directive('@transaction')\n @Mutation(returns => ActionPlan, { description: 'To create new ActionPlan' })\n async createActionPlan(@Arg('actionPlan') actionPlan: NewActionPlan, @Ctx() context: ResolverContext): Promise<ActionPlan> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(ActionPlan).save({\n ...actionPlan,\n domain,\n creator: user,\n updater: user\n })\n\n if (actionPlan.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: actionPlan.thumbnail,\n refType: ActionPlan.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => ActionPlan, { description: 'To modify ActionPlan information' })\n async updateActionPlan(\n @Arg('id') id: string,\n @Arg('patch') patch: ActionPlanPatch,\n @Ctx() context: ResolverContext\n ): Promise<ActionPlan> {\n const { domain, user, tx } = context.state\n\n const repository = tx.getRepository(ActionPlan)\n const actionPlan = await repository.findOne({\n where: { domain: { id: domain.id }, id }\n })\n\n const result = await repository.save({\n ...actionPlan,\n ...patch,\n updater: user\n })\n\n if (patch.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.thumbnail,\n refType: ActionPlan.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [ActionPlan], { description: \"To modify multiple ActionPlans' information\" })\n async updateMultipleActionPlan(\n @Arg('patches', type => [ActionPlanPatch]) patches: ActionPlanPatch[],\n @Ctx() context: ResolverContext\n ): Promise<ActionPlan[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const actionPlanRepo = tx.getRepository(ActionPlan)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await actionPlanRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: ActionPlan.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const actionPlan = await actionPlanRepo.findOneBy({ id: updateRecord.id })\n\n const result = await actionPlanRepo.save({\n ...actionPlan,\n ...updateRecord,\n updater: user\n })\n\n if (updateRecord.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.thumbnail,\n refType: ActionPlan.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete ActionPlan' })\n async deleteActionPlan(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(ActionPlan).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple ActionPlans' })\n async deleteActionPlans(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await tx.getRepository(ActionPlan).delete({\n domain: { id: domain.id },\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple ActionPlans' })\n async importActionPlans(\n @Arg('actionPlans', type => [ActionPlanPatch]) actionPlans: ActionPlanPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n actionPlans.map(async (actionPlan: ActionPlanPatch) => {\n const createdActionPlan: ActionPlan = await tx.getRepository(ActionPlan).save({ domain, ...actionPlan })\n })\n )\n\n return true\n }\n}\n"]}
1
+ {"version":3,"file":"action-plan-mutation.js","sourceRoot":"","sources":["../../../server/service/action-plan/action-plan-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAE5B,qEAA0F;AAE1F,+CAA0C;AAC1C,yDAAmE;AAG5D,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAGvB,AAAN,KAAK,CAAC,gBAAgB,CAAoB,UAAyB,EAAS,OAAwB;QAClG,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAE1C,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,aAAa,CAAC,wBAAU,CAAC,CAAC,IAAI,iCACjD,UAAU,KACb,MAAM,EACN,OAAO,EAAE,IAAI,EACb,OAAO,EAAE,IAAI,IACb,CAAA;QAEF,IAAI,UAAU,CAAC,SAAS,EAAE,CAAC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,IAAA,kBAAG,GAAE,CAAA;;;;2DAWP;6BA1LU,kBAAkB;IAD9B,IAAA,uBAAQ,EAAC,wBAAU,CAAC;GACR,kBAAkB,CA2L9B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\n\nimport { createAttachment, deleteAttachmentsByRef } from '@things-factory/attachment-base'\n\nimport { ActionPlan } from './action-plan'\nimport { NewActionPlan, ActionPlanPatch } from './action-plan-type'\n\n@Resolver(ActionPlan)\nexport class ActionPlanMutation {\n @Directive('@transaction')\n @Mutation(returns => ActionPlan, { description: 'To create new ActionPlan' })\n async createActionPlan(@Arg('actionPlan') actionPlan: NewActionPlan, @Ctx() context: ResolverContext): Promise<ActionPlan> {\n const { domain, user, tx } = context.state\n\n const result = await tx.getRepository(ActionPlan).save({\n ...actionPlan,\n domain,\n creator: user,\n updater: user\n })\n\n if (actionPlan.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: actionPlan.thumbnail,\n refType: ActionPlan.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => ActionPlan, { description: 'To modify ActionPlan information' })\n async updateActionPlan(\n @Arg('id') id: string,\n @Arg('patch') patch: ActionPlanPatch,\n @Ctx() context: ResolverContext\n ): Promise<ActionPlan> {\n const { user, tx } = context.state\n\n const repository = tx.getRepository(ActionPlan)\n const actionPlan = await repository.findOne({\n where: { id }\n })\n\n const result = await repository.save({\n ...actionPlan,\n ...patch,\n updater: user\n })\n\n if (patch.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: patch.thumbnail,\n refType: ActionPlan.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => [ActionPlan], { description: \"To modify multiple ActionPlans' information\" })\n async updateMultipleActionPlan(\n @Arg('patches', type => [ActionPlanPatch]) patches: ActionPlanPatch[],\n @Ctx() context: ResolverContext\n ): Promise<ActionPlan[]> {\n const { domain, user, tx } = context.state\n\n let results = []\n const _createRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === '+')\n const _updateRecords = patches.filter((patch: any) => patch.cuFlag.toUpperCase() === 'M')\n const actionPlanRepo = tx.getRepository(ActionPlan)\n\n if (_createRecords.length > 0) {\n for (let i = 0; i < _createRecords.length; i++) {\n const newRecord = _createRecords[i]\n\n const result = await actionPlanRepo.save({\n ...newRecord,\n domain,\n creator: user,\n updater: user\n })\n\n if (newRecord.thumbnail) {\n await createAttachment(\n null,\n {\n attachment: {\n file: newRecord.thumbnail,\n refType: ActionPlan.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: '+' })\n }\n }\n\n if (_updateRecords.length > 0) {\n for (let i = 0; i < _updateRecords.length; i++) {\n const updateRecord = _updateRecords[i]\n const actionPlan = await actionPlanRepo.findOneBy({ id: updateRecord.id })\n\n const result = await actionPlanRepo.save({\n ...actionPlan,\n ...updateRecord,\n updater: user\n })\n\n if (updateRecord.thumbnail) {\n await deleteAttachmentsByRef(null, { refBys: [result.id] }, context)\n await createAttachment(\n null,\n {\n attachment: {\n file: updateRecord.thumbnail,\n refType: ActionPlan.name,\n refBy: result.id\n }\n },\n context\n )\n }\n\n results.push({ ...result, cuFlag: 'M' })\n }\n }\n\n return results\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete ActionPlan' })\n async deleteActionPlan(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx } = context.state\n\n await tx.getRepository(ActionPlan).delete({ id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple ActionPlans' })\n async deleteActionPlans(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx } = context.state\n\n await tx.getRepository(ActionPlan).delete({\n id: In(ids)\n })\n\n await deleteAttachmentsByRef(null, { refBys: ids }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To import multiple ActionPlans' })\n async importActionPlans(\n @Arg('actionPlans', type => [ActionPlanPatch]) actionPlans: ActionPlanPatch[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, tx } = context.state\n\n await Promise.all(\n actionPlans.map(async (actionPlan: ActionPlanPatch) => {\n const createdActionPlan: ActionPlan = await tx.getRepository(ActionPlan).save({ domain, ...actionPlan })\n })\n )\n\n return true\n }\n}\n"]}
@@ -3,8 +3,8 @@ import { User } from '@things-factory/auth-base';
3
3
  import { ActionPlan } from './action-plan';
4
4
  import { ActionPlanList } from './action-plan-type';
5
5
  export declare class ActionPlanQuery {
6
- actionPlan(id: string, context: ResolverContext): Promise<ActionPlan>;
7
- actionPlans(params: ListParam, context: ResolverContext): Promise<ActionPlanList>;
6
+ actionPlan(id: string): Promise<ActionPlan>;
7
+ actionPlans(params: ListParam): Promise<ActionPlanList>;
8
8
  thumbnail(actionPlan: ActionPlan): Promise<string | undefined>;
9
9
  domain(actionPlan: ActionPlan): Promise<Domain>;
10
10
  updater(actionPlan: ActionPlan): Promise<User>;
@@ -9,16 +9,13 @@ const auth_base_1 = require("@things-factory/auth-base");
9
9
  const action_plan_1 = require("./action-plan");
10
10
  const action_plan_type_1 = require("./action-plan-type");
11
11
  let ActionPlanQuery = class ActionPlanQuery {
12
- async actionPlan(id, context) {
13
- const { domain } = context.state;
12
+ async actionPlan(id) {
14
13
  return await (0, shell_1.getRepository)(action_plan_1.ActionPlan).findOne({
15
- where: { domain: { id: domain.id }, id }
14
+ where: { id }
16
15
  });
17
16
  }
18
- async actionPlans(params, context) {
19
- const { domain } = context.state;
17
+ async actionPlans(params) {
20
18
  const queryBuilder = (0, shell_1.getQueryBuilderFromListParams)({
21
- domain,
22
19
  params,
23
20
  repository: await (0, shell_1.getRepository)(action_plan_1.ActionPlan),
24
21
  searchables: ['name', 'description']
@@ -29,7 +26,6 @@ let ActionPlanQuery = class ActionPlanQuery {
29
26
  async thumbnail(actionPlan) {
30
27
  const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
31
28
  where: {
32
- domain: { id: actionPlan.domainId },
33
29
  refType: action_plan_1.ActionPlan.name,
34
30
  refBy: actionPlan.id
35
31
  }
@@ -50,17 +46,15 @@ exports.ActionPlanQuery = ActionPlanQuery;
50
46
  tslib_1.__decorate([
51
47
  (0, type_graphql_1.Query)(returns => action_plan_1.ActionPlan, { nullable: true, description: 'To fetch a ActionPlan' }),
52
48
  tslib_1.__param(0, (0, type_graphql_1.Arg)('id')),
53
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
54
49
  tslib_1.__metadata("design:type", Function),
55
- tslib_1.__metadata("design:paramtypes", [String, Object]),
50
+ tslib_1.__metadata("design:paramtypes", [String]),
56
51
  tslib_1.__metadata("design:returntype", Promise)
57
52
  ], ActionPlanQuery.prototype, "actionPlan", null);
58
53
  tslib_1.__decorate([
59
54
  (0, type_graphql_1.Query)(returns => action_plan_type_1.ActionPlanList, { description: 'To fetch multiple ActionPlans' }),
60
55
  tslib_1.__param(0, (0, type_graphql_1.Args)()),
61
- tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
62
56
  tslib_1.__metadata("design:type", Function),
63
- tslib_1.__metadata("design:paramtypes", [shell_1.ListParam, Object]),
57
+ tslib_1.__metadata("design:paramtypes", [shell_1.ListParam]),
64
58
  tslib_1.__metadata("design:returntype", Promise)
65
59
  ], ActionPlanQuery.prototype, "actionPlans", null);
66
60
  tslib_1.__decorate([
@@ -1 +1 @@
1
- {"version":3,"file":"action-plan-query.js","sourceRoot":"","sources":["../../../server/service/action-plan/action-plan-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qEAA4D;AAC5D,iDAAuG;AACvG,yDAAgD;AAChD,+CAA0C;AAC1C,yDAAmD;AAG5C,IAAM,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AAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;0BApDU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,wBAAU,CAAC;GACR,eAAe,CAqD3B","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { ActionPlan } from './action-plan'\nimport { ActionPlanList } from './action-plan-type'\n\n@Resolver(ActionPlan)\nexport class ActionPlanQuery {\n @Query(returns => ActionPlan!, { nullable: true, description: 'To fetch a ActionPlan' })\n async actionPlan(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<ActionPlan> {\n const { domain } = context.state\n\n return await getRepository(ActionPlan).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => ActionPlanList, { description: 'To fetch multiple ActionPlans' })\n async actionPlans(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ActionPlanList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: await getRepository(ActionPlan),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async thumbnail(@Root() actionPlan: ActionPlan): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: actionPlan.domainId },\n refType: ActionPlan.name,\n refBy: actionPlan.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() actionPlan: ActionPlan): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: actionPlan.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() actionPlan: ActionPlan): Promise<User> {\n return await getRepository(User).findOneBy({ id: actionPlan.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() actionPlan: ActionPlan): Promise<User> {\n return await getRepository(User).findOneBy({ id: actionPlan.creatorId })\n }\n}\n"]}
1
+ {"version":3,"file":"action-plan-query.js","sourceRoot":"","sources":["../../../server/service/action-plan/action-plan-query.ts"],"names":[],"mappings":";;;;AAAA,+CAA8F;AAC9F,qEAA4D;AAC5D,iDAAuG;AACvG,yDAAgD;AAChD,+CAA0C;AAC1C,yDAAmD;AAG5C,IAAM,eAAe,GAArB,MAAM,eAAe;IAEpB,AAAN,KAAK,CAAC,UAAU,CAAY,EAAU;QACpC,OAAO,MAAM,IAAA,qBAAa,EAAC,wBAAU,CAAC,CAAC,OAAO,CAAC;YAC7C,KAAK,EAAE,EAAE,EAAE,EAAE;SACd,CAAC,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,WAAW,CAAS,MAAiB;QACzC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,UAAU,EAAE,MAAM,IAAA,qBAAa,EAAC,wBAAU,CAAC;YAC3C,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC;SACrC,CAAC,CAAA;QAEF,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,SAAS,CAAS,UAAsB;QAC5C,MAAM,UAAU,GAAe,MAAM,IAAA,qBAAa,EAAC,4BAAU,CAAC,CAAC,OAAO,CAAC;YACrE,KAAK,EAAE;gBACL,OAAO,EAAE,wBAAU,CAAC,IAAI;gBACxB,KAAK,EAAE,UAAU,CAAC,EAAE;aACr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,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;6CAE1C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAa,wBAAU;;8CAE3C;0BA9CU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,wBAAU,CAAC;GACR,eAAe,CA+C3B","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Args, Arg, Ctx, Directive } from 'type-graphql'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { Domain, getQueryBuilderFromListParams, getRepository, ListParam } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { ActionPlan } from './action-plan'\nimport { ActionPlanList } from './action-plan-type'\n\n@Resolver(ActionPlan)\nexport class ActionPlanQuery {\n @Query(returns => ActionPlan!, { nullable: true, description: 'To fetch a ActionPlan' })\n async actionPlan(@Arg('id') id: string): Promise<ActionPlan> {\n return await getRepository(ActionPlan).findOne({\n where: { id }\n })\n }\n\n @Query(returns => ActionPlanList, { description: 'To fetch multiple ActionPlans' })\n async actionPlans(@Args() params: ListParam): Promise<ActionPlanList> {\n const queryBuilder = getQueryBuilderFromListParams({\n params,\n repository: await getRepository(ActionPlan),\n searchables: ['name', 'description']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @FieldResolver(type => String)\n async thumbnail(@Root() actionPlan: ActionPlan): Promise<string | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n refType: ActionPlan.name,\n refBy: actionPlan.id\n }\n })\n\n return attachment?.fullpath\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() actionPlan: ActionPlan): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: actionPlan.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() actionPlan: ActionPlan): Promise<User> {\n return await getRepository(User).findOneBy({ id: actionPlan.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() actionPlan: ActionPlan): Promise<User> {\n return await getRepository(User).findOneBy({ id: actionPlan.creatorId })\n }\n}\n"]}
@@ -1,10 +1,9 @@
1
1
  import { BuildingInspection } from './building-inspection';
2
- import { NewBuildingInspection, UpdateBuildingInspectionDrawingMarker, UpdateBuildingInspectionSubmitType } from './building-inspection-type';
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: UpdateBuildingInspectionDrawingMarker, context: ResolverContext): Promise<BuildingInspection>;
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,8 @@ 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");
16
+ const field_document_auto_file_1 = require("../field-document/field-document-auto-file");
15
17
  const projectType = env_1.config.get('projectType', building_inspection_1.ProjectType.DSSP);
16
18
  let BuildingInspectionMutation = class BuildingInspectionMutation {
17
19
  async createBuildingInspection(patch, context) {
@@ -20,7 +22,6 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
20
22
  const buildingInspectionRepository = tx.getRepository(building_inspection_1.BuildingInspection);
21
23
  const checklistRepository = tx.getRepository(checklist_1.Checklist);
22
24
  const checklistItemRepository = tx.getRepository(checklist_item_1.ChecklistItem);
23
- const CHECKLIST_REFERENCE_TYPE = checklist.checklistReferenceType || checklist_1.ChecklistReferenceType.INSPECTION;
24
25
  // 1. 벨리데이션
25
26
  if (!checklist.constructionType)
26
27
  throw new Error('공종 타입이 없습니다.');
@@ -30,7 +31,7 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
30
31
  throw new Error('체크리스트 이름이 없습니다.');
31
32
  if (checklistItem.length === 0)
32
33
  throw new Error('체크리스트 아이템이 없습니다.');
33
- if (CHECKLIST_REFERENCE_TYPE === checklist_1.ChecklistReferenceType.INSPECTION && projectType === building_inspection_1.ProjectType.DSSP) {
34
+ if (projectType === building_inspection_1.ProjectType.DSSP) {
34
35
  if (!cellX || !cellY)
35
36
  throw new Error('셀 좌표가 없습니다.');
36
37
  if (!managerId)
@@ -40,7 +41,7 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
40
41
  if (!checklist.location)
41
42
  throw new Error('위치가 없습니다.');
42
43
  }
43
- else if (CHECKLIST_REFERENCE_TYPE === checklist_1.ChecklistReferenceType.INSPECTION && projectType === building_inspection_1.ProjectType.DCSP) {
44
+ else if (projectType === building_inspection_1.ProjectType.DCSP) {
44
45
  if (!checklist.inspectionDrawingType)
45
46
  throw new Error('검측 도면 타입이 없습니다.');
46
47
  if (checklist.inspectionParts.length === 0)
@@ -51,14 +52,19 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
51
52
  throw new Error('위치가 없습니다.');
52
53
  }
53
54
  // 2. checklist 저장
54
- const documentNo = await this.getRecentDocumentNoByBuildingLevelId(buildingLevelId);
55
- const savedChecklist = await checklistRepository.save(Object.assign(Object.assign({}, checklist), { projectType, project: CHECKLIST_REFERENCE_TYPE === checklist_1.ChecklistReferenceType.SCHEDULE ? { id: checklist.projectId } : null, documentNo, creator: user, updater: user }));
55
+ const checklistDocumentNo = await getRecentDocumentNoByBuildingLevelId(buildingLevelId, checklist_1.DocumentNoType.CHECKLIST, tx);
56
+ const inspectionRequestDocumentNo = checklistDocumentNo.replace(`검측 제${checklist_1.DocumentNoType.CHECKLIST}-`, `검측 제${checklist_1.DocumentNoType.INSPECTION_REQUEST}-`);
57
+ const inspectionResultDocumentNo = checklistDocumentNo.replace(`검측 제${checklist_1.DocumentNoType.CHECKLIST}-`, `검측 제${checklist_1.DocumentNoType.INSPECTION_RESULT}-`);
58
+ const savedChecklist = await checklistRepository.save(Object.assign(Object.assign({}, checklist), { projectType, checklistReferenceType: checklist_2.ChecklistReferenceType.INSPECTION, documentNo: checklistDocumentNo, inspectionRequestDocumentNo,
59
+ inspectionResultDocumentNo, creator: user, updater: user }));
56
60
  // 3. checklistItem 저장
57
61
  const checklistItems = checklistItem.map((item, idx) => ({
58
62
  name: item.name,
59
63
  mainType: item.mainType,
60
64
  detailType: item.detailType,
61
65
  inspctionCriteria: item.inspctionCriteria,
66
+ kcsCriteria: item.kcsCriteria,
67
+ siteSpecCriteria: item.siteSpecCriteria,
62
68
  sequence: idx,
63
69
  checklist: savedChecklist,
64
70
  creator: user,
@@ -77,12 +83,24 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
77
83
  creator: user,
78
84
  updater: user
79
85
  });
86
+ // 5. 현장 문서 자동 등록 (040202 검측체크리스트관리)
87
+ const projectId = await (0, field_document_auto_file_1.getProjectIdByBuildingLevelId)(buildingLevelId, tx.getRepository('projects'));
88
+ if (projectId) {
89
+ await (0, field_document_auto_file_1.autoFileDocument)({
90
+ projectId,
91
+ code: '040202',
92
+ name: `체크리스트 - ${savedChecklist.name || ''}`,
93
+ sourceType: 'CHECKLIST',
94
+ sourceRefId: result.id,
95
+ context
96
+ });
97
+ }
80
98
  return result;
81
99
  }
82
100
  // 검측 상태 변경 & 체크리스트 갱신
83
101
  async updateBuildingInspectionChecklist(buildingInspection, context) {
84
102
  const { user, tx } = context.state;
85
- const { id: buildingInspectionId, checklist, checklistItem } = buildingInspection;
103
+ const { id: buildingInspectionId, memo, requestDate, checklist, checklistItem } = buildingInspection;
86
104
  const buildingInspectionRepo = tx.getRepository(building_inspection_1.BuildingInspection);
87
105
  const checklistRepo = tx.getRepository(checklist_1.Checklist);
88
106
  const checklistItemRepo = tx.getRepository(checklist_item_1.ChecklistItem);
@@ -92,6 +110,9 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
92
110
  status == building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT ||
93
111
  status == building_inspection_2.BuildingInspectionStatus.FAIL;
94
112
  let inspectionStatus = null;
113
+ let signedUserType = null; // 싸인을 한 유저 타입
114
+ let inspectionRequestData = {};
115
+ let inspectionResultData = {};
95
116
  // 1. 벨리데이션
96
117
  if (!buildingInspectionId)
97
118
  throw new Error('검측 아이디가 없습니다.');
@@ -121,12 +142,18 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
121
142
  else if (isPassed && (status === building_inspection_2.BuildingInspectionStatus.WAIT || status === building_inspection_2.BuildingInspectionStatus.FAIL)) {
122
143
  // 2. 검측이 합격이면서 공종 시공자 스탭 = 상태는 총괄 시공자 스탭으로
123
144
  inspectionStatus = building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT;
145
+ signedUserType = 'taskConstructor';
124
146
  }
125
147
  else if (isPassed && status === building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT) {
126
148
  // 3. 검측이 합격이면서 총괄 시공자 스탭 = 상태는 공종 감리자 스탭으로, 감리자 싸인은 모두 초기화
127
149
  inspectionStatus = building_inspection_2.BuildingInspectionStatus.REQUEST;
128
150
  checklist.overallSupervisorySignature = null;
129
151
  checklist.taskSupervisorySignature = null;
152
+ signedUserType = 'overallConstructor';
153
+ inspectionRequestData = {
154
+ inspectionRequestMemo: checklist.inspectionRequestMemo,
155
+ inspectionRequestUpdatedAt: new Date()
156
+ };
130
157
  }
131
158
  }
132
159
  else {
@@ -151,25 +178,51 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
151
178
  else if (isPassed && status === building_inspection_2.BuildingInspectionStatus.REQUEST) {
152
179
  // 2. 검측이 합격이면서 공종 감리자 스탭 = 상태는 총괄 감리자 스탭으로
153
180
  inspectionStatus = building_inspection_2.BuildingInspectionStatus.OVERALL_REQUEST;
181
+ signedUserType = 'taskSupervisory';
154
182
  }
155
183
  else if (isPassed && status === building_inspection_2.BuildingInspectionStatus.OVERALL_REQUEST) {
156
184
  // 3. 검측이 합격이면서 총괄 감리자 스탭 = 상태는 합격으로
157
185
  inspectionStatus = building_inspection_2.BuildingInspectionStatus.PASS;
186
+ signedUserType = 'overallSupervisory';
187
+ inspectionResultData = {
188
+ inspectionResultStatus: checklist.inspectionResultStatus,
189
+ inspectionResultMemo: checklist.inspectionResultMemo,
190
+ inspectionResultType: checklist.inspectionResultType,
191
+ inspectionResultUpdatedAt: new Date()
192
+ };
158
193
  }
159
194
  }
160
195
  // 2. buildingInspection 저장
161
- await buildingInspectionRepo.save(Object.assign(Object.assign({}, oldBuildingInspection), { status: inspectionStatus, updater: user }));
196
+ await buildingInspectionRepo.save(Object.assign(Object.assign(Object.assign(Object.assign({}, oldBuildingInspection), { status: inspectionStatus, failCount: inspectionStatus === building_inspection_2.BuildingInspectionStatus.FAIL
197
+ ? (oldBuildingInspection.failCount || 0) + 1
198
+ : oldBuildingInspection.failCount || 0 }), (requestDate !== undefined && { requestDate })), { memo: memo, updater: user }));
199
+ // 현장 문서 자동 등록 (040201 검측요청/결과통보서) - REQUEST 상태 전환 시
200
+ if (inspectionStatus === building_inspection_2.BuildingInspectionStatus.REQUEST) {
201
+ const buildingLevelId = oldBuildingInspection.buildingLevelId;
202
+ if (buildingLevelId) {
203
+ const projectId = await (0, field_document_auto_file_1.getProjectIdByBuildingLevelId)(buildingLevelId, tx.getRepository('projects'));
204
+ if (projectId) {
205
+ await (0, field_document_auto_file_1.autoFileDocument)({
206
+ projectId,
207
+ code: '040201',
208
+ name: `검측요청서 - ${buildingInspectionId}`,
209
+ sourceType: 'INSPECTION_REQUEST',
210
+ sourceRefId: buildingInspectionId,
211
+ context
212
+ });
213
+ }
214
+ }
215
+ }
162
216
  // 3. checklist 저장
163
217
  const oldChecklist = await checklistRepo.findOneBy({ id: checklist.id });
164
218
  const inspectionDateField = isConstructor ? 'constructionInspectionDate' : 'supervisorInspectionDate';
165
- await checklistRepo.save(Object.assign(Object.assign({}, oldChecklist), { [inspectionDateField]: new Date(), overallConstructorSignature: checklist.overallConstructorSignature, taskConstructorSignature: checklist.taskConstructorSignature, overallSupervisorySignature: checklist.overallSupervisorySignature, taskSupervisorySignature: checklist.taskSupervisorySignature, updater: user }));
219
+ const signedUser = signedUserType ? { [signedUserType]: user } : {};
220
+ 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 }));
166
221
  // 4. checklistItem 저장
167
222
  for (let item of checklistItem) {
168
223
  const confirmStatusField = isConstructor ? 'constructionConfirmStatus' : 'supervisoryConfirmStatus';
169
- await checklistItemRepo.update(item.id, {
170
- [confirmStatusField]: item[confirmStatusField],
171
- updater: user
172
- });
224
+ const existingItem = await checklistItemRepo.findOneBy({ id: item.id });
225
+ await checklistItemRepo.save(Object.assign(Object.assign({}, existingItem), { [confirmStatusField]: item[confirmStatusField], updater: user }));
173
226
  }
174
227
  return true;
175
228
  }
@@ -250,7 +303,9 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
250
303
  name: item.name,
251
304
  mainType: item.mainType,
252
305
  detailType: item.detailType,
253
- inspctionCriteria: item.inspctionCriteria
306
+ inspctionCriteria: item.inspctionCriteria,
307
+ kcsCriteria: item.kcsCriteria,
308
+ siteSpecCriteria: item.siteSpecCriteria
254
309
  }));
255
310
  await this.createBuildingInspection({
256
311
  buildingLevelId: buildingLevel.id,
@@ -263,26 +318,6 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
263
318
  }
264
319
  return true;
265
320
  }
266
- async getRecentDocumentNoByBuildingLevelId(buildingLevelId) {
267
- var _a, _b;
268
- const buildingLevel = await (0, shell_1.getRepository)(building_complex_1.BuildingLevel).findOne({
269
- where: { id: buildingLevelId },
270
- relations: ['building']
271
- });
272
- 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';
273
- const floorName = buildingLevel.floor.toString().padStart(3, '0');
274
- const latestChecklist = await (0, shell_1.getRepository)(checklist_1.Checklist)
275
- .createQueryBuilder('c')
276
- .where('c.document_no LIKE :pattern', { pattern: `${buildingName}-${floorName}-%` })
277
- .orderBy('c.created_at', 'DESC')
278
- .getOne();
279
- let documentNo = '000001';
280
- if (latestChecklist) {
281
- const lastNo = latestChecklist.documentNo.split('-')[2];
282
- documentNo = (Number(lastNo) + 1).toString().padStart(6, '0');
283
- }
284
- return `${buildingName}-${floorName}-${documentNo}`;
285
- }
286
321
  };
287
322
  exports.BuildingInspectionMutation = BuildingInspectionMutation;
288
323
  tslib_1.__decorate([
@@ -309,7 +344,7 @@ tslib_1.__decorate([
309
344
  tslib_1.__param(0, (0, type_graphql_1.Arg)('patch')),
310
345
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
311
346
  tslib_1.__metadata("design:type", Function),
312
- tslib_1.__metadata("design:paramtypes", [building_inspection_type_1.UpdateBuildingInspectionDrawingMarker, Object]),
347
+ tslib_1.__metadata("design:paramtypes", [building_inspection_type_1.UpdateBuildingInspection, Object]),
313
348
  tslib_1.__metadata("design:returntype", Promise)
314
349
  ], BuildingInspectionMutation.prototype, "updateBuildingInspection", null);
315
350
  tslib_1.__decorate([
@@ -333,4 +368,37 @@ tslib_1.__decorate([
333
368
  exports.BuildingInspectionMutation = BuildingInspectionMutation = tslib_1.__decorate([
334
369
  (0, type_graphql_1.Resolver)(building_inspection_1.BuildingInspection)
335
370
  ], BuildingInspectionMutation);
371
+ async function getRecentDocumentNoByBuildingLevelId(buildingLevelId, type, tx) {
372
+ const project = await tx
373
+ .createQueryBuilder()
374
+ .select('p.documentNaming', 'documentNaming')
375
+ .addSelect('bc.id', 'buildingComplexId')
376
+ .from('projects', 'p')
377
+ .innerJoin('building_complexes', 'bc', 'bc.id = p.building_complex_id')
378
+ .innerJoin('buildings', 'b', 'b.building_complex_id = bc.id')
379
+ .innerJoin('building_levels', 'bl', 'bl.building_id = b.id')
380
+ .where('bl.id = :buildingLevelId', { buildingLevelId })
381
+ .getRawOne();
382
+ const latestChecklist = await tx
383
+ .getRepository(checklist_1.Checklist)
384
+ .createQueryBuilder('c')
385
+ .innerJoin('c.buildingInspection', 'bi')
386
+ .innerJoin('bi.buildingLevel', 'bl')
387
+ .innerJoin('bl.building', 'b')
388
+ .where('b.building_complex_id = :buildingComplexId', { buildingComplexId: project.buildingComplexId })
389
+ .andWhere('c.document_no LIKE :pattern', { pattern: `${project.documentNaming} 검측 제${type}-%` })
390
+ .orderBy('c.created_at', 'DESC')
391
+ .getOne();
392
+ // 4. 시퀀스 번호 생성 (5자리)
393
+ let sequence = '00001';
394
+ if (latestChecklist) {
395
+ const documentNoPattern = new RegExp(`${project.documentNaming} 검측 제${type}-(\\d{5})호`);
396
+ const match = latestChecklist.documentNo.match(documentNoPattern);
397
+ if (match) {
398
+ sequence = (Number(match[1]) + 1).toString().padStart(5, '0');
399
+ }
400
+ }
401
+ // 5. 최종 문서 번호 생성
402
+ return `${project.documentNaming} 검측 제${type}-${sequence}호`;
403
+ }
336
404
  //# sourceMappingURL=building-inspection-mutation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"building-inspection-mutation.js","sourceRoot":"","sources":["../../../server/service/building-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zB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADyC,6DAAkC;;mFA4GlF;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,wCAAkB,EAAE,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;IAEnG,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADe,gEAAqC;;0EAuB3D;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAE5E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;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;qCA3TU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAmVtC","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, ChecklistReferenceType } 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 const CHECKLIST_REFERENCE_TYPE = checklist.checklistReferenceType || ChecklistReferenceType.INSPECTION\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 (CHECKLIST_REFERENCE_TYPE === ChecklistReferenceType.INSPECTION && 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 (CHECKLIST_REFERENCE_TYPE === ChecklistReferenceType.INSPECTION && 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 documentNo = await this.getRecentDocumentNoByBuildingLevelId(buildingLevelId)\n const savedChecklist = await checklistRepository.save({\n ...checklist,\n projectType,\n project: CHECKLIST_REFERENCE_TYPE === ChecklistReferenceType.SCHEDULE ? { id: checklist.projectId } : null,\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;AAC/D,yFAA4G;AAE5G,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,SAAS,CAAC,gBAAgB;YAAE,MAAM,IAAI,KAAK,CAAC,cAAc,CAAC,CAAA;QAChE,IAAI,CAAC,SAAS,CAAC,sBAAsB;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACzE,IAAI,CAAC,SAAS,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;QACvD,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;YAAE,MAAM,IAAI,KA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C,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'\nimport { autoFileDocument, getProjectIdByBuildingLevelId } from '../field-document/field-document-auto-file'\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 kcsCriteria: item.kcsCriteria,\n siteSpecCriteria: item.siteSpecCriteria,\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 // 5. 현장 문서 자동 등록 (040202 검측체크리스트관리)\n const projectId = await getProjectIdByBuildingLevelId(buildingLevelId, tx.getRepository('projects'))\n if (projectId) {\n await autoFileDocument({\n projectId,\n code: '040202',\n name: `체크리스트 - ${savedChecklist.name || ''}`,\n sourceType: 'CHECKLIST',\n sourceRefId: result.id,\n context\n })\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, requestDate, 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 failCount:\n inspectionStatus === BuildingInspectionStatus.FAIL\n ? (oldBuildingInspection.failCount || 0) + 1\n : oldBuildingInspection.failCount || 0,\n ...(requestDate !== undefined && { requestDate }),\n memo: memo,\n updater: user\n })\n\n // 현장 문서 자동 등록 (040201 검측요청/결과통보서) - REQUEST 상태 전환 시\n if (inspectionStatus === BuildingInspectionStatus.REQUEST) {\n const buildingLevelId = oldBuildingInspection.buildingLevelId\n if (buildingLevelId) {\n const projectId = await getProjectIdByBuildingLevelId(buildingLevelId, tx.getRepository('projects'))\n if (projectId) {\n await autoFileDocument({\n projectId,\n code: '040201',\n name: `검측요청서 - ${buildingInspectionId}`,\n sourceType: 'INSPECTION_REQUEST',\n sourceRefId: buildingInspectionId,\n context\n })\n }\n }\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 const existingItem = await checklistItemRepo.findOneBy({ id: item.id })\n await checklistItemRepo.save({\n ...existingItem,\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 kcsCriteria: item.kcsCriteria,\n siteSpecCriteria: item.siteSpecCriteria\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"]}