@dssp/project 1.0.0-alpha.1 → 1.0.0-alpha.101

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 (235) hide show
  1. package/dist-client/index.d.ts +1 -0
  2. package/dist-client/index.js +1 -1
  3. package/dist-client/index.js.map +1 -1
  4. package/dist-client/pages/lib/chatbot-widget.d.ts +53 -0
  5. package/dist-client/pages/lib/chatbot-widget.js +631 -0
  6. package/dist-client/pages/lib/chatbot-widget.js.map +1 -0
  7. package/dist-client/pages/lib/select2-component.d.ts +1 -1
  8. package/dist-client/pages/lib/select2-component.js +36 -36
  9. package/dist-client/pages/lib/select2-component.js.map +1 -1
  10. package/dist-client/pages/lib/waether.d.ts +2 -1
  11. package/dist-client/pages/lib/waether.js +7 -3
  12. package/dist-client/pages/lib/waether.js.map +1 -1
  13. package/dist-client/pages/project/component/pagenation.d.ts +18 -0
  14. package/dist-client/pages/project/component/pagenation.js +142 -0
  15. package/dist-client/pages/project/component/pagenation.js.map +1 -0
  16. package/dist-client/pages/project/component/project-update-header.js +26 -3
  17. package/dist-client/pages/project/component/project-update-header.js.map +1 -1
  18. package/dist-client/pages/project/popup/checklist/task-checklist-attachment-list-popup.d.ts +1 -0
  19. package/dist-client/pages/project/popup/checklist/task-checklist-attachment-list-popup.js +308 -0
  20. package/dist-client/pages/project/popup/checklist/task-checklist-attachment-list-popup.js.map +1 -0
  21. package/dist-client/pages/project/popup/checklist/task-checklist-comment-list-popup.d.ts +1 -0
  22. package/dist-client/pages/project/popup/checklist/task-checklist-comment-list-popup.js +356 -0
  23. package/dist-client/pages/project/popup/checklist/task-checklist-comment-list-popup.js.map +1 -0
  24. package/dist-client/pages/project/popup/checklist/task-checklist-create-popup.d.ts +1 -0
  25. package/dist-client/pages/project/popup/checklist/task-checklist-create-popup.js +682 -0
  26. package/dist-client/pages/project/popup/checklist/task-checklist-create-popup.js.map +1 -0
  27. package/dist-client/pages/project/popup/checklist/task-checklist-view.d.ts +33 -0
  28. package/dist-client/pages/project/popup/checklist/task-checklist-view.js +676 -0
  29. package/dist-client/pages/project/popup/checklist/task-checklist-view.js.map +1 -0
  30. package/dist-client/pages/project/popup/popup-plan-export.d.ts +10 -0
  31. package/dist-client/pages/project/popup/popup-plan-export.js +242 -0
  32. package/dist-client/pages/project/popup/popup-plan-export.js.map +1 -0
  33. package/dist-client/pages/project/popup/popup-plan-upload.d.ts +3 -0
  34. package/dist-client/pages/project/popup/popup-plan-upload.js +130 -4
  35. package/dist-client/pages/project/popup/popup-plan-upload.js.map +1 -1
  36. package/dist-client/pages/project/popup/popup-project-create.js.map +1 -1
  37. package/dist-client/pages/project/popup/{popup-schedule-upload.d.ts → popup-task-upload.d.ts} +1 -1
  38. package/dist-client/pages/project/popup/{popup-schedule-upload.js → popup-task-upload.js} +9 -9
  39. package/dist-client/pages/project/popup/popup-task-upload.js.map +1 -0
  40. package/dist-client/pages/project/project-completed-list.d.ts +5 -0
  41. package/dist-client/pages/project/project-completed-list.js +32 -4
  42. package/dist-client/pages/project/project-completed-list.js.map +1 -1
  43. package/dist-client/pages/project/project-detail.d.ts +8 -1
  44. package/dist-client/pages/project/project-detail.js +488 -163
  45. package/dist-client/pages/project/project-detail.js.map +1 -1
  46. package/dist-client/pages/project/project-list.d.ts +69 -0
  47. package/dist-client/pages/project/project-list.js +94 -16
  48. package/dist-client/pages/project/project-list.js.map +1 -1
  49. package/dist-client/pages/project/project-plan-management.js +35 -14
  50. package/dist-client/pages/project/project-plan-management.js.map +1 -1
  51. package/dist-client/pages/project/project-setting-list.d.ts +7 -0
  52. package/dist-client/pages/project/project-setting-list.js +82 -27
  53. package/dist-client/pages/project/project-setting-list.js.map +1 -1
  54. package/dist-client/pages/project/{project-schedule-list.d.ts → project-task-list.d.ts} +2 -2
  55. package/dist-client/pages/project/{project-schedule-list.js → project-task-list.js} +11 -11
  56. package/dist-client/pages/project/project-task-list.js.map +1 -0
  57. package/dist-client/pages/project/{project-schedule.d.ts → project-task.d.ts} +17 -4
  58. package/dist-client/pages/project/project-task.js +692 -0
  59. package/dist-client/pages/project/project-task.js.map +1 -0
  60. package/dist-client/pages/project/project-update.d.ts +35 -0
  61. package/dist-client/pages/project/project-update.js +633 -49
  62. package/dist-client/pages/project/project-update.js.map +1 -1
  63. package/dist-client/pages/resource/construction-detail-type-popup.js.map +1 -1
  64. package/dist-client/pages/resource/construction-type-management.js +14 -0
  65. package/dist-client/pages/resource/construction-type-management.js.map +1 -1
  66. package/dist-client/pages/resource/inspection-drawing-type-management.js.map +1 -1
  67. package/dist-client/pages/resource/inspection-part-popup.js.map +1 -1
  68. package/dist-client/pages/resource/resource-importer.js.map +1 -1
  69. package/dist-client/pages/resource/resource-list-page.d.ts +1 -2
  70. package/dist-client/pages/resource/resource-list-page.js +1 -2
  71. package/dist-client/pages/resource/resource-list-page.js.map +1 -1
  72. package/dist-client/pages/resource/worker-type-management.js.map +1 -1
  73. package/dist-client/pages/task/task-importer.js.map +1 -1
  74. package/dist-client/pages/task/task-list-page.d.ts +1 -2
  75. package/dist-client/pages/task/task-list-page.js +1 -2
  76. package/dist-client/pages/task/task-list-page.js.map +1 -1
  77. package/dist-client/pages/task-resource/task-resource-importer.js.map +1 -1
  78. package/dist-client/pages/task-resource/task-resource-list-page.d.ts +1 -2
  79. package/dist-client/pages/task-resource/task-resource-list-page.js +1 -2
  80. package/dist-client/pages/task-resource/task-resource-list-page.js.map +1 -1
  81. package/dist-client/route.d.ts +1 -1
  82. package/dist-client/route.js +4 -4
  83. package/dist-client/route.js.map +1 -1
  84. package/dist-client/shared/domain-context.d.ts +18 -0
  85. package/dist-client/shared/domain-context.js +28 -0
  86. package/dist-client/shared/domain-context.js.map +1 -0
  87. package/dist-client/tsconfig.tsbuildinfo +1 -1
  88. package/dist-client/viewparts/domain-switch.d.ts +19 -0
  89. package/dist-client/viewparts/domain-switch.js +274 -0
  90. package/dist-client/viewparts/domain-switch.js.map +1 -0
  91. package/dist-server/controllers/export-tasks.js +1 -2
  92. package/dist-server/controllers/export-tasks.js.map +1 -1
  93. package/dist-server/controllers/import-task.js +1 -2
  94. package/dist-server/controllers/import-task.js.map +1 -1
  95. package/dist-server/controllers/parse-excel.d.ts +0 -2
  96. package/dist-server/controllers/parse-excel.js +1 -2
  97. package/dist-server/controllers/parse-excel.js.map +1 -1
  98. package/dist-server/middlewares/index.js +1 -2
  99. package/dist-server/middlewares/index.js.map +1 -1
  100. package/dist-server/migrations/1723861466413-seed-roles.js.map +1 -1
  101. package/dist-server/migrations/1723861466414-seed-codes.js +1 -1
  102. package/dist-server/migrations/1723861466414-seed-codes.js.map +1 -1
  103. package/dist-server/migrations/1723861476419-seed-resources.js.map +1 -1
  104. package/dist-server/migrations/1723861478420-seed-/bsample-project.js.map +1 -1
  105. package/dist-server/migrations/1723861478421-seed-/bsample-tasks.js.map +1 -1
  106. package/dist-server/service/construction-detail-type/construction-detail-type-mutation.js +2 -2
  107. package/dist-server/service/construction-detail-type/construction-detail-type-mutation.js.map +1 -1
  108. package/dist-server/service/construction-detail-type/construction-detail-type-query.js +2 -2
  109. package/dist-server/service/construction-detail-type/construction-detail-type-query.js.map +1 -1
  110. package/dist-server/service/construction-detail-type/construction-detail-type-type.js +4 -4
  111. package/dist-server/service/construction-detail-type/construction-detail-type-type.js.map +1 -1
  112. package/dist-server/service/construction-detail-type/construction-detail-type.js +2 -2
  113. package/dist-server/service/construction-detail-type/construction-detail-type.js.map +1 -1
  114. package/dist-server/service/construction-type/construction-type-mutation.js +2 -2
  115. package/dist-server/service/construction-type/construction-type-mutation.js.map +1 -1
  116. package/dist-server/service/construction-type/construction-type-query.d.ts +2 -2
  117. package/dist-server/service/construction-type/construction-type-query.js +7 -12
  118. package/dist-server/service/construction-type/construction-type-query.js.map +1 -1
  119. package/dist-server/service/construction-type/construction-type-type.d.ts +1 -0
  120. package/dist-server/service/construction-type/construction-type-type.js +8 -4
  121. package/dist-server/service/construction-type/construction-type-type.js.map +1 -1
  122. package/dist-server/service/construction-type/construction-type.d.ts +1 -0
  123. package/dist-server/service/construction-type/construction-type.js +7 -2
  124. package/dist-server/service/construction-type/construction-type.js.map +1 -1
  125. package/dist-server/service/index.d.ts +3 -2
  126. package/dist-server/service/index.js +6 -2
  127. package/dist-server/service/index.js.map +1 -1
  128. package/dist-server/service/inspection-drawing-type/inspection-drawing-type-mutation.js +2 -2
  129. package/dist-server/service/inspection-drawing-type/inspection-drawing-type-mutation.js.map +1 -1
  130. package/dist-server/service/inspection-drawing-type/inspection-drawing-type-query.d.ts +2 -2
  131. package/dist-server/service/inspection-drawing-type/inspection-drawing-type-query.js +7 -12
  132. package/dist-server/service/inspection-drawing-type/inspection-drawing-type-query.js.map +1 -1
  133. package/dist-server/service/inspection-drawing-type/inspection-drawing-type-type.js +4 -4
  134. package/dist-server/service/inspection-drawing-type/inspection-drawing-type-type.js.map +1 -1
  135. package/dist-server/service/inspection-drawing-type/inspection-drawing-type.js +2 -2
  136. package/dist-server/service/inspection-drawing-type/inspection-drawing-type.js.map +1 -1
  137. package/dist-server/service/inspection-part/inspection-part-mutation.js +2 -2
  138. package/dist-server/service/inspection-part/inspection-part-mutation.js.map +1 -1
  139. package/dist-server/service/inspection-part/inspection-part-query.js +2 -2
  140. package/dist-server/service/inspection-part/inspection-part-query.js.map +1 -1
  141. package/dist-server/service/inspection-part/inspection-part-type.js +4 -4
  142. package/dist-server/service/inspection-part/inspection-part-type.js.map +1 -1
  143. package/dist-server/service/inspection-part/inspection-part.js +2 -2
  144. package/dist-server/service/inspection-part/inspection-part.js.map +1 -1
  145. package/dist-server/service/manager/index.d.ts +2 -0
  146. package/dist-server/service/manager/index.js +3 -1
  147. package/dist-server/service/manager/index.js.map +1 -1
  148. package/dist-server/service/manager/manager-mutation.js +2 -2
  149. package/dist-server/service/manager/manager-mutation.js.map +1 -1
  150. package/dist-server/service/manager/manager-query.d.ts +1 -1
  151. package/dist-server/service/manager/manager-query.js +5 -9
  152. package/dist-server/service/manager/manager-query.js.map +1 -1
  153. package/dist-server/service/manager/manager-type.js +4 -4
  154. package/dist-server/service/manager/manager-type.js.map +1 -1
  155. package/dist-server/service/manager/manager.js +2 -2
  156. package/dist-server/service/manager/manager.js.map +1 -1
  157. package/dist-server/service/project/issue-project-code.d.ts +7 -0
  158. package/dist-server/service/project/issue-project-code.js +27 -0
  159. package/dist-server/service/project/issue-project-code.js.map +1 -0
  160. package/dist-server/service/project/project-mutation.d.ts +3 -0
  161. package/dist-server/service/project/project-mutation.js +231 -24
  162. package/dist-server/service/project/project-mutation.js.map +1 -1
  163. package/dist-server/service/project/project-query.d.ts +14 -2
  164. package/dist-server/service/project/project-query.js +167 -16
  165. package/dist-server/service/project/project-query.js.map +1 -1
  166. package/dist-server/service/project/project-type.d.ts +14 -2
  167. package/dist-server/service/project/project-type.js +57 -11
  168. package/dist-server/service/project/project-type.js.map +1 -1
  169. package/dist-server/service/project/project.d.ts +29 -0
  170. package/dist-server/service/project/project.js +103 -5
  171. package/dist-server/service/project/project.js.map +1 -1
  172. package/dist-server/service/resource/resource-mutation.js +7 -8
  173. package/dist-server/service/resource/resource-mutation.js.map +1 -1
  174. package/dist-server/service/resource/resource-query.d.ts +2 -2
  175. package/dist-server/service/resource/resource-query.js +7 -12
  176. package/dist-server/service/resource/resource-query.js.map +1 -1
  177. package/dist-server/service/resource/resource-type.js +6 -6
  178. package/dist-server/service/resource/resource-type.js.map +1 -1
  179. package/dist-server/service/resource/resource.js +3 -3
  180. package/dist-server/service/resource/resource.js.map +1 -1
  181. package/dist-server/service/task/task-mutation.js +2 -2
  182. package/dist-server/service/task/task-mutation.js.map +1 -1
  183. package/dist-server/service/task/task-query.d.ts +2 -0
  184. package/dist-server/service/task/task-query.js +15 -4
  185. package/dist-server/service/task/task-query.js.map +1 -1
  186. package/dist-server/service/task/task-type.js +10 -10
  187. package/dist-server/service/task/task-type.js.map +1 -1
  188. package/dist-server/service/task/task.d.ts +2 -0
  189. package/dist-server/service/task/task.js +13 -8
  190. package/dist-server/service/task/task.js.map +1 -1
  191. package/dist-server/service/task-checklist-binding/index.d.ts +5 -0
  192. package/dist-server/service/task-checklist-binding/index.js +9 -0
  193. package/dist-server/service/task-checklist-binding/index.js.map +1 -0
  194. package/dist-server/service/task-checklist-binding/task-checklist-binding-mutation.d.ts +5 -0
  195. package/dist-server/service/task-checklist-binding/task-checklist-binding-mutation.js +188 -0
  196. package/dist-server/service/task-checklist-binding/task-checklist-binding-mutation.js.map +1 -0
  197. package/dist-server/service/task-checklist-binding/task-checklist-binding-query.d.ts +8 -0
  198. package/dist-server/service/task-checklist-binding/task-checklist-binding-query.js +61 -0
  199. package/dist-server/service/task-checklist-binding/task-checklist-binding-query.js.map +1 -0
  200. package/dist-server/service/task-checklist-binding/task-checklist-binding-type.d.ts +15 -0
  201. package/dist-server/service/task-checklist-binding/task-checklist-binding-type.js +57 -0
  202. package/dist-server/service/task-checklist-binding/task-checklist-binding-type.js.map +1 -0
  203. package/dist-server/service/task-checklist-binding/task-checklist-binding.d.ts +22 -0
  204. package/dist-server/service/task-checklist-binding/task-checklist-binding.js +106 -0
  205. package/dist-server/service/task-checklist-binding/task-checklist-binding.js.map +1 -0
  206. package/dist-server/service/task-resource/task-resource-mutation.js +2 -2
  207. package/dist-server/service/task-resource/task-resource-mutation.js.map +1 -1
  208. package/dist-server/service/task-resource/task-resource-query.d.ts +2 -2
  209. package/dist-server/service/task-resource/task-resource-query.js +6 -11
  210. package/dist-server/service/task-resource/task-resource-query.js.map +1 -1
  211. package/dist-server/service/task-resource/task-resource-type.js +6 -6
  212. package/dist-server/service/task-resource/task-resource-type.js.map +1 -1
  213. package/dist-server/service/task-resource/task-resource.js +2 -2
  214. package/dist-server/service/task-resource/task-resource.js.map +1 -1
  215. package/dist-server/service/worker-type/worker-type-mutation.js +2 -2
  216. package/dist-server/service/worker-type/worker-type-mutation.js.map +1 -1
  217. package/dist-server/service/worker-type/worker-type-query.d.ts +2 -2
  218. package/dist-server/service/worker-type/worker-type-query.js +7 -12
  219. package/dist-server/service/worker-type/worker-type-query.js.map +1 -1
  220. package/dist-server/service/worker-type/worker-type-type.js +4 -4
  221. package/dist-server/service/worker-type/worker-type-type.js.map +1 -1
  222. package/dist-server/service/worker-type/worker-type.js +2 -2
  223. package/dist-server/service/worker-type/worker-type.js.map +1 -1
  224. package/dist-server/tsconfig.tsbuildinfo +1 -1
  225. package/package.json +15 -11
  226. package/things-factory.config.js +3 -3
  227. package/translations/en.json +10 -9
  228. package/translations/ja.json +15 -1
  229. package/translations/ko.json +3 -0
  230. package/translations/ms.json +15 -1
  231. package/translations/zh.json +15 -1
  232. package/dist-client/pages/project/popup/popup-schedule-upload.js.map +0 -1
  233. package/dist-client/pages/project/project-schedule-list.js.map +0 -1
  234. package/dist-client/pages/project/project-schedule.js +0 -407
  235. package/dist-client/pages/project/project-schedule.js.map +0 -1
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.issueProjectCode = issueProjectCode;
4
+ const project_1 = require("./project");
5
+ const SEQ_WIDTH = 5;
6
+ const SEQ_MAX = 10 ** SEQ_WIDTH - 1;
7
+ /**
8
+ * 프로젝트 관리번호(YYYY-NNNNN) 를 발번한다.
9
+ * 호출자는 반드시 트랜잭션(EntityManager) 을 넘겨야 한다.
10
+ * 같은 연도 prefix 의 최대값을 pessimistic lock 으로 잠근 뒤 +1 한다.
11
+ */
12
+ async function issueProjectCode(tx, now = new Date()) {
13
+ const yearPrefix = String(now.getFullYear());
14
+ const last = await tx
15
+ .getRepository(project_1.Project)
16
+ .createQueryBuilder('p')
17
+ .where('p.code LIKE :pattern', { pattern: `${yearPrefix}-%` })
18
+ .setLock('pessimistic_write')
19
+ .orderBy('p.code', 'DESC')
20
+ .getOne();
21
+ const nextSeq = (last === null || last === void 0 ? void 0 : last.code) ? Number(last.code.split('-')[1]) + 1 : 1;
22
+ if (nextSeq > SEQ_MAX) {
23
+ throw new Error(`프로젝트 관리번호 일련번호 한계 초과: ${yearPrefix}-${SEQ_MAX} 이미 사용됨`);
24
+ }
25
+ return `${yearPrefix}-${String(nextSeq).padStart(SEQ_WIDTH, '0')}`;
26
+ }
27
+ //# sourceMappingURL=issue-project-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"issue-project-code.js","sourceRoot":"","sources":["../../../server/service/project/issue-project-code.ts"],"names":[],"mappings":";;AAYA,4CAkBC;AA5BD,uCAAmC;AAEnC,MAAM,SAAS,GAAG,CAAC,CAAA;AACnB,MAAM,OAAO,GAAG,EAAE,IAAI,SAAS,GAAG,CAAC,CAAA;AAEnC;;;;GAIG;AACI,KAAK,UAAU,gBAAgB,CAAC,EAAiB,EAAE,MAAY,IAAI,IAAI,EAAE;IAC9E,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAA;IAE5C,MAAM,IAAI,GAAG,MAAM,EAAE;SAClB,aAAa,CAAC,iBAAO,CAAC;SACtB,kBAAkB,CAAC,GAAG,CAAC;SACvB,KAAK,CAAC,sBAAsB,EAAE,EAAE,OAAO,EAAE,GAAG,UAAU,IAAI,EAAE,CAAC;SAC7D,OAAO,CAAC,mBAAmB,CAAC;SAC5B,OAAO,CAAC,QAAQ,EAAE,MAAM,CAAC;SACzB,MAAM,EAAE,CAAA;IAEX,MAAM,OAAO,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,EAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;IAEpE,IAAI,OAAO,GAAG,OAAO,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,yBAAyB,UAAU,IAAI,OAAO,SAAS,CAAC,CAAA;IAC1E,CAAC;IAED,OAAO,GAAG,UAAU,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAA;AACpE,CAAC","sourcesContent":["import { EntityManager } from 'typeorm'\n\nimport { Project } from './project'\n\nconst SEQ_WIDTH = 5\nconst SEQ_MAX = 10 ** SEQ_WIDTH - 1\n\n/**\n * 프로젝트 관리번호(YYYY-NNNNN) 를 발번한다.\n * 호출자는 반드시 트랜잭션(EntityManager) 을 넘겨야 한다.\n * 같은 연도 prefix 의 최대값을 pessimistic lock 으로 잠근 뒤 +1 한다.\n */\nexport async function issueProjectCode(tx: EntityManager, now: Date = new Date()): Promise<string> {\n const yearPrefix = String(now.getFullYear())\n\n const last = await tx\n .getRepository(Project)\n .createQueryBuilder('p')\n .where('p.code LIKE :pattern', { pattern: `${yearPrefix}-%` })\n .setLock('pessimistic_write')\n .orderBy('p.code', 'DESC')\n .getOne()\n\n const nextSeq = last?.code ? Number(last.code.split('-')[1]) + 1 : 1\n\n if (nextSeq > SEQ_MAX) {\n throw new Error(`프로젝트 관리번호 일련번호 한계 초과: ${yearPrefix}-${SEQ_MAX} 이미 사용됨`)\n }\n\n return `${yearPrefix}-${String(nextSeq).padStart(SEQ_WIDTH, '0')}`\n}\n"]}
@@ -7,5 +7,8 @@ export declare class ProjectMutation {
7
7
  updateProjectPlan(project: ProjectPatch, context: ResolverContext): Promise<Project>;
8
8
  uploadProjectScheduleTable(param: UploadProjectScheduleTable, context: ResolverContext): Promise<boolean>;
9
9
  deleteProject(id: string, context: ResolverContext): Promise<boolean>;
10
+ downloadPlanFiles(fileIds: string[], context: ResolverContext): Promise<string>;
11
+ promoteProjectToTenant(projectId: string, context: ResolverContext): Promise<Project>;
12
+ demoteProjectTenant(projectId: string, context: ResolverContext): Promise<boolean>;
10
13
  }
11
14
  export declare function createAttachmentAfterDelete(context: ResolverContext, file: any, refBy: any, refType: any): Promise<Attachment>;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createAttachmentAfterDelete = exports.ProjectMutation = void 0;
3
+ exports.ProjectMutation = void 0;
4
+ exports.createAttachmentAfterDelete = createAttachmentAfterDelete;
4
5
  const tslib_1 = require("tslib");
5
6
  const type_graphql_1 = require("type-graphql");
6
7
  const typeorm_1 = require("typeorm");
@@ -8,9 +9,17 @@ const shell_1 = require("@things-factory/shell");
8
9
  const attachment_base_1 = require("@things-factory/attachment-base");
9
10
  const project_1 = require("./project");
10
11
  const project_type_1 = require("./project-type");
12
+ const issue_project_code_1 = require("./issue-project-code");
11
13
  const building_complex_1 = require("@dssp/building-complex");
12
14
  const headless_pdf_to_image_1 = require("@things-factory/board-service/dist-server/controllers/headless-pdf-to-image");
13
15
  const parse_excel_1 = require("../../controllers/parse-excel");
16
+ const fs = tslib_1.__importStar(require("fs"));
17
+ const path = tslib_1.__importStar(require("path"));
18
+ const archiver_1 = tslib_1.__importDefault(require("archiver"));
19
+ const env_1 = require("@things-factory/env");
20
+ const PROJECT_DOMAIN_EXT_TYPE = 'project';
21
+ const PROJECT_TEMPLATE_SUBDOMAIN = 'project-template';
22
+ const projectType = env_1.config.get('projectType', project_1.ProjectType.DSSP);
14
23
  let ProjectMutation = class ProjectMutation {
15
24
  async createProject(project, context) {
16
25
  const { domain, user, tx } = context.state;
@@ -23,7 +32,9 @@ let ProjectMutation = class ProjectMutation {
23
32
  });
24
33
  const result = await projectRepo.save({
25
34
  name: project.name,
35
+ documentNaming: project.name,
26
36
  buildingComplex: newBuildingComplex,
37
+ projectType,
27
38
  domain,
28
39
  creator: user,
29
40
  updater: user
@@ -40,18 +51,42 @@ let ProjectMutation = class ProjectMutation {
40
51
  const buildingComplex = project.buildingComplex;
41
52
  const buildings = ((_a = project.buildingComplex) === null || _a === void 0 ? void 0 : _a.buildings) || [];
42
53
  // 1. 프로젝트 수정
43
- const projectState = project.totalProgress == 100 ? project_1.ProjectState.COMPLETED : project_1.ProjectState.ONGOING;
44
- const projectResult = await projectRepo.save(Object.assign(Object.assign({}, project), { state: projectState, updater: user }));
54
+ const projectResult = await projectRepo.save(Object.assign(Object.assign({}, project), { updater: user }));
55
+ // 1-1. 프로젝트명이 변경되면 연동된 테넌트 Domain 이름도 함께 동기화.
56
+ // 전용 Domain 은 테넌트 승격(promoteProjectToTenant) 시에만 생성되므로
57
+ // code 를 보유한 프로젝트만 대상. Domain 은 subdomain=code, extType='project' 로 식별.
58
+ if (project.name !== undefined) {
59
+ const domainRepo = (0, shell_1.getRepository)(shell_1.Domain, tx);
60
+ const { code } = (await projectRepo.findOne({ where: { id: project.id }, select: ['code'] })) || {};
61
+ if (code) {
62
+ const linkedDomain = await domainRepo.findOne({
63
+ where: { subdomain: code, extType: PROJECT_DOMAIN_EXT_TYPE }
64
+ });
65
+ if (linkedDomain && linkedDomain.name !== project.name) {
66
+ await domainRepo.save(Object.assign(Object.assign({}, linkedDomain), { name: project.name }));
67
+ }
68
+ }
69
+ }
70
+ // buildingComplex 가 patch 에 없는 경우 (예: state 만 변경하는 부분 patch) 는 단지 정보·
71
+ // 동/층·첨부파일 관련 후속 단계 모두 skip.
72
+ if (!buildingComplex) {
73
+ return projectResult;
74
+ }
45
75
  // 2. 단지 정보 수정
46
76
  await buildingComplexRepo.save(Object.assign(Object.assign({}, buildingComplex), { updater: user }));
47
77
  // 2-1. 프로젝트 메인 이미지 첨부파일 나머지 삭제 후 저장
48
78
  await createAttachmentAfterDelete(context, project === null || project === void 0 ? void 0 : project.mainPhotoUpload, project.id, project_1.Project.name);
49
79
  // 2-2. 단지 BIM 이미지 첨부파일 나머지 삭제 후 저장
50
- await createAttachmentAfterDelete(context, buildingComplex === null || buildingComplex === void 0 ? void 0 : buildingComplex.drawingUpload, buildingComplex.id, building_complex_1.BuildingComplex.name + '_bim');
80
+ if (buildingComplex.id) {
81
+ await createAttachmentAfterDelete(context, buildingComplex === null || buildingComplex === void 0 ? void 0 : buildingComplex.drawingUpload, buildingComplex.id, building_complex_1.BuildingComplex.name + '_bim');
82
+ }
51
83
  // 3. 동의 층 정보가 바뀌었으면 층 초기화 후 다시 생성
52
- const originBuilding = await buildingRepo.findBy({ buildingComplex: { id: buildingComplex.id } }); // 이전 동 정보 가져오기
84
+ const originBuilding = buildingComplex.id
85
+ ? await buildingRepo.findBy({ buildingComplex: { id: buildingComplex.id } })
86
+ : [];
53
87
  const afterBuilding = buildings.reduce((acc, building) => (Object.assign(Object.assign({}, acc), { [building.name]: building.floorCount })), {}); // 비교용으로 수정된 동 정보 데이터 파싱
54
- const isBuidlingChanged = originBuilding.some(building => afterBuilding[building.name] !== building.floorCount); // 개수가 달라진 동이 있는지 확인
88
+ const afterBasement = buildings.reduce((acc, building) => (Object.assign(Object.assign({}, acc), { [building.name]: building.basementFloorCount || 0 })), {}); // 비교용으로 수정된 지하 정보 데이터 파싱
89
+ const isBuidlingChanged = originBuilding.some(building => afterBuilding[building.name] !== building.floorCount || afterBasement[building.name] !== building.basementFloorCount); // 층 개수가 달라진 동이 있는지 확인
55
90
  // 동의 층 개수가 달라지면 모든 층의 데이터 제거 후 생성
56
91
  if (isBuidlingChanged || originBuilding.length !== buildings.length) {
57
92
  // 3-1. 기존 동/층 첨부파일 및 데이터 제거
@@ -68,23 +103,33 @@ let ProjectMutation = class ProjectMutation {
68
103
  buildingComplex: buildingComplex,
69
104
  name: building.name,
70
105
  floorCount: building.floorCount,
106
+ hasBasement: building.hasBasement,
107
+ basementFloorCount: building.hasBasement ? building.basementFloorCount : 0,
108
+ updater: user,
71
109
  creator: user
72
110
  });
73
111
  // 3-3. 동별로 for문 돌면서 층 데이터 개수대로 생성
74
112
  for (let i = 1; i <= building.floorCount; i++) {
75
113
  await buildingLevelRepo.save({ building: newBuilding, floor: i, creator: user });
76
114
  }
115
+ // 3-4. 지하층 층 데이터 생성
116
+ if (building.hasBasement) {
117
+ for (let i = 1; i <= building.basementFloorCount; i++) {
118
+ await buildingLevelRepo.save({ building: newBuilding, floor: -i, creator: user });
119
+ }
120
+ }
77
121
  }
78
122
  }
79
123
  return projectResult;
80
124
  }
81
125
  async updateProjectPlan(project, context) {
82
- var _a;
126
+ var _a, _b;
83
127
  const { user, tx, domain } = context.state;
84
128
  const projectRepo = (0, shell_1.getRepository)(project_1.Project, tx);
85
129
  const buildingComplexRepo = (0, shell_1.getRepository)(building_complex_1.BuildingComplex, tx);
86
130
  const buildingRepo = (0, shell_1.getRepository)(building_complex_1.Building, tx);
87
131
  const buildingLevelRepo = (0, shell_1.getRepository)(building_complex_1.BuildingLevel, tx);
132
+ const attachmentRepo = (0, shell_1.getRepository)(attachment_base_1.Attachment, tx);
88
133
  const buildingComplex = project.buildingComplex;
89
134
  const buildings = ((_a = project.buildingComplex) === null || _a === void 0 ? void 0 : _a.buildings) || [];
90
135
  // 1. 프로젝트 수정 시간 업데이트
@@ -125,7 +170,22 @@ let ProjectMutation = class ProjectMutation {
125
170
  const pngThumbnailFile = await (0, headless_pdf_to_image_1.pdfToImage)({ pdfPath, fileName, defaultViewport: { width: 300, height: 200 } });
126
171
  await createAttachmentAfterDelete(context, pngThumbnailFile, buildingLevel.id, building_complex_1.BuildingLevel.name + '_rebarDistributionDrawing_thumbnail');
127
172
  }
128
- // 3-3. 업데이트 시간 갱신
173
+ // 3-3. 기타 도면 파일 저장
174
+ const etcDrawingRefType = building_complex_1.BuildingLevel.name + '_etcDrawings';
175
+ // 기존 첨부 파일 중 제거된 것들 삭제
176
+ const etcDrawings = await attachmentRepo.find({ where: { refType: etcDrawingRefType, refBy: buildingLevel.id } });
177
+ for (let etcDrawing of etcDrawings) {
178
+ if (!buildingLevel.etcDrawingIds.includes(etcDrawing.id)) {
179
+ await (0, attachment_base_1.deleteAttachment)(null, { id: etcDrawing.id }, context);
180
+ }
181
+ }
182
+ // 업로드
183
+ if (((_b = buildingLevel.etcDrawingsUpload) === null || _b === void 0 ? void 0 : _b.length) > 0) {
184
+ for (let etcDrawing of buildingLevel.etcDrawingsUpload) {
185
+ await (0, attachment_base_1.createAttachment)(null, { attachment: { file: etcDrawing, refType: etcDrawingRefType, refBy: buildingLevel.id } }, context);
186
+ }
187
+ }
188
+ // 3-4. 층 업데이트 시간 갱신
129
189
  await buildingLevelRepo.save(Object.assign(Object.assign({}, buildingLevel), { updater: user }));
130
190
  }
131
191
  // 4. 동별 도면 이미지 저장
@@ -137,26 +197,21 @@ let ProjectMutation = class ProjectMutation {
137
197
  }
138
198
  async uploadProjectScheduleTable(param, context) {
139
199
  var _a, e_1, _b, _c;
140
- const { domain, user, tx } = context.state;
200
+ const { user, tx } = context.state;
141
201
  const { projectId, scheduleTable } = param;
142
202
  const projectRepo = (0, shell_1.getRepository)(project_1.Project, tx);
143
203
  const project = await projectRepo.findOne({
144
- where: { domain: { id: domain.id }, id: projectId }
204
+ where: { id: projectId }
145
205
  });
146
206
  const { createReadStream, filename, mimetype } = await scheduleTable;
147
207
  const stream = createReadStream();
148
208
  const chunks = [];
149
209
  try {
150
- for (var _d = true, stream_1 = tslib_1.__asyncValues(stream), stream_1_1; stream_1_1 = await stream_1.next(), _a = stream_1_1.done, !_a;) {
210
+ for (var _d = true, stream_1 = tslib_1.__asyncValues(stream), stream_1_1; stream_1_1 = await stream_1.next(), _a = stream_1_1.done, !_a; _d = true) {
151
211
  _c = stream_1_1.value;
152
212
  _d = false;
153
- try {
154
- const chunk = _c;
155
- chunks.push(chunk);
156
- }
157
- finally {
158
- _d = true;
159
- }
213
+ const chunk = _c;
214
+ chunks.push(chunk);
160
215
  }
161
216
  }
162
217
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -172,12 +227,139 @@ let ProjectMutation = class ProjectMutation {
172
227
  return true;
173
228
  }
174
229
  async deleteProject(id, context) {
175
- const { domain, tx } = context.state;
176
- await (0, shell_1.getRepository)(project_1.Project, tx).delete({ domain: { id: domain.id }, id });
230
+ const { tx } = context.state;
231
+ await (0, shell_1.getRepository)(project_1.Project, tx).delete({ id });
177
232
  await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
178
233
  return true;
179
234
  }
235
+ async downloadPlanFiles(fileIds, context) {
236
+ const { tx } = context.state;
237
+ if (!fileIds || fileIds.length === 0) {
238
+ throw new Error('다운로드할 파일을 선택해주세요.');
239
+ }
240
+ // 첨부파일 정보 조회
241
+ const attachments = await tx.getRepository(attachment_base_1.Attachment).find({
242
+ where: { id: (0, typeorm_1.In)(fileIds) }
243
+ });
244
+ if (attachments.length === 0) {
245
+ throw new Error('선택된 파일을 찾을 수 없습니다.');
246
+ }
247
+ // ZIP 파일 생성 - 동과 층 정보를 포함한 파일명
248
+ const zipFileName = `download.zip`;
249
+ const tempDir = path.join(process.cwd(), 'temp');
250
+ const zipFilePath = path.join(tempDir, zipFileName);
251
+ // temp 디렉토리 생성
252
+ if (!fs.existsSync(tempDir)) {
253
+ fs.mkdirSync(tempDir, { recursive: true });
254
+ }
255
+ const output = fs.createWriteStream(zipFilePath);
256
+ const archive = (0, archiver_1.default)('zip', {
257
+ zlib: { level: 9 } // 최대 압축
258
+ });
259
+ return new Promise(async (resolve, reject) => {
260
+ output.on('close', () => {
261
+ // ZIP 파일을 Base64로 인코딩하여 반환
262
+ const zipBuffer = fs.readFileSync(zipFilePath);
263
+ const base64Data = zipBuffer.toString('base64');
264
+ const dataUrl = `data:application/zip;base64,${base64Data}`;
265
+ // 임시 파일 삭제
266
+ fs.unlinkSync(zipFilePath);
267
+ resolve(dataUrl);
268
+ });
269
+ archive.on('error', err => {
270
+ reject(err);
271
+ });
272
+ archive.pipe(output);
273
+ try {
274
+ // 각 첨부파일을 ZIP에 추가
275
+ for (const attachment of attachments) {
276
+ try {
277
+ const fileUrl = `http://localhost:3000${attachment.fullpath}`;
278
+ const response = await fetch(fileUrl);
279
+ if (response.ok) {
280
+ const buffer = await response.arrayBuffer();
281
+ const fileName = attachment.name || path.basename(attachment.fullpath);
282
+ archive.append(Buffer.from(buffer), { name: fileName });
283
+ }
284
+ }
285
+ catch (error) {
286
+ console.error('Error processing attachment:', attachment.fullpath, error);
287
+ }
288
+ }
289
+ archive.finalize();
290
+ }
291
+ catch (error) {
292
+ reject(error);
293
+ }
294
+ });
295
+ }
296
+ async promoteProjectToTenant(projectId, context) {
297
+ var _a;
298
+ const { user, tx } = context.state;
299
+ const projectRepo = tx.getRepository(project_1.Project);
300
+ const domainRepo = tx.getRepository(shell_1.Domain);
301
+ const project = await projectRepo.findOne({
302
+ where: { id: projectId }
303
+ });
304
+ if (!project) {
305
+ throw new Error(`프로젝트를 찾을 수 없습니다: ${projectId}`);
306
+ }
307
+ // 이미 활성 테넌트인 경우 차단 (강등 상태는 재승격 허용)
308
+ if (project.code) {
309
+ const existing = await domainRepo.findOne({
310
+ where: { subdomain: project.code, extType: PROJECT_DOMAIN_EXT_TYPE }
311
+ });
312
+ if (existing) {
313
+ throw new Error(`이미 테넌트로 승격된 프로젝트입니다: ${project.code}`);
314
+ }
315
+ }
316
+ // 템플릿 Domain 조회 — 모든 프로젝트 도메인의 parent. Role 상속의 단일 진실.
317
+ // subdomain 만으로 식별 — 어드민에서 수동 생성된 도메인의 extType 이
318
+ // NULL/대소문자 차이로 누락되어 false-negative 가 자주 발생하므로.
319
+ const templateDomain = await domainRepo.findOne({
320
+ where: { subdomain: PROJECT_TEMPLATE_SUBDOMAIN }
321
+ });
322
+ if (!templateDomain) {
323
+ throw new Error(`프로젝트 템플릿 Domain (subdomain='${PROJECT_TEMPLATE_SUBDOMAIN}') 이 존재하지 않습니다. 어드민에서 먼저 생성하세요.`);
324
+ }
325
+ // 코드가 없으면 발번 (재승격 시에는 기존 코드 재사용)
326
+ const code = (_a = project.code) !== null && _a !== void 0 ? _a : (await (0, issue_project_code_1.issueProjectCode)(tx));
327
+ await domainRepo.save({
328
+ name: project.name,
329
+ subdomain: code,
330
+ extType: PROJECT_DOMAIN_EXT_TYPE,
331
+ parent: templateDomain,
332
+ owner: user.id
333
+ });
334
+ if (!project.code) {
335
+ await projectRepo.update({ id: projectId }, { code });
336
+ project.code = code;
337
+ }
338
+ return project;
339
+ }
340
+ async demoteProjectTenant(projectId, context) {
341
+ const { tx } = context.state;
342
+ const project = await tx.getRepository(project_1.Project).findOne({
343
+ where: { id: projectId }
344
+ });
345
+ if (!project) {
346
+ throw new Error(`프로젝트를 찾을 수 없습니다: ${projectId}`);
347
+ }
348
+ if (!project.code) {
349
+ throw new Error('승격된 적이 없는 프로젝트입니다.');
350
+ }
351
+ const domainRepo = tx.getRepository(shell_1.Domain);
352
+ const tenantDomain = await domainRepo.findOne({
353
+ where: { subdomain: project.code, extType: PROJECT_DOMAIN_EXT_TYPE }
354
+ });
355
+ if (!tenantDomain) {
356
+ throw new Error('이미 강등된 프로젝트입니다.');
357
+ }
358
+ await domainRepo.softDelete({ id: tenantDomain.id });
359
+ return true;
360
+ }
180
361
  };
362
+ exports.ProjectMutation = ProjectMutation;
181
363
  tslib_1.__decorate([
182
364
  (0, type_graphql_1.Directive)('@transaction'),
183
365
  (0, type_graphql_1.Mutation)(returns => project_1.Project, { description: '프로젝트 생성' }),
@@ -189,7 +371,7 @@ tslib_1.__decorate([
189
371
  ], ProjectMutation.prototype, "createProject", null);
190
372
  tslib_1.__decorate([
191
373
  (0, type_graphql_1.Directive)('@transaction'),
192
- (0, type_graphql_1.Mutation)(returns => project_1.Project, { description: '프로젝트 업데이트' }),
374
+ (0, type_graphql_1.Mutation)(returns => project_1.Project, { description: '프로젝트 업데이트 (중복 사용 금지)' }),
193
375
  tslib_1.__param(0, (0, type_graphql_1.Arg)('project')),
194
376
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
195
377
  tslib_1.__metadata("design:type", Function),
@@ -223,10 +405,36 @@ tslib_1.__decorate([
223
405
  tslib_1.__metadata("design:paramtypes", [String, Object]),
224
406
  tslib_1.__metadata("design:returntype", Promise)
225
407
  ], ProjectMutation.prototype, "deleteProject", null);
226
- ProjectMutation = tslib_1.__decorate([
408
+ tslib_1.__decorate([
409
+ (0, type_graphql_1.Directive)('@transaction'),
410
+ (0, type_graphql_1.Mutation)(returns => String, { description: '선택된 도면 파일들을 ZIP으로 압축하여 다운로드 URL 반환' }),
411
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('fileIds', type => [String])),
412
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
413
+ tslib_1.__metadata("design:type", Function),
414
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
415
+ tslib_1.__metadata("design:returntype", Promise)
416
+ ], ProjectMutation.prototype, "downloadPlanFiles", null);
417
+ tslib_1.__decorate([
418
+ (0, type_graphql_1.Directive)('@transaction'),
419
+ (0, type_graphql_1.Mutation)(returns => project_1.Project, { description: '프로젝트를 테넌트로 승격 (관리번호 발번 + project 카테고리 Domain 생성)' }),
420
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('projectId')),
421
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
422
+ tslib_1.__metadata("design:type", Function),
423
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
424
+ tslib_1.__metadata("design:returntype", Promise)
425
+ ], ProjectMutation.prototype, "promoteProjectToTenant", null);
426
+ tslib_1.__decorate([
427
+ (0, type_graphql_1.Directive)('@transaction'),
428
+ (0, type_graphql_1.Mutation)(returns => Boolean, { description: '프로젝트 테넌트 강등 (Domain soft-delete, Project.code 보존)' }),
429
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('projectId')),
430
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
431
+ tslib_1.__metadata("design:type", Function),
432
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
433
+ tslib_1.__metadata("design:returntype", Promise)
434
+ ], ProjectMutation.prototype, "demoteProjectTenant", null);
435
+ exports.ProjectMutation = ProjectMutation = tslib_1.__decorate([
227
436
  (0, type_graphql_1.Resolver)(project_1.Project)
228
437
  ], ProjectMutation);
229
- exports.ProjectMutation = ProjectMutation;
230
438
  async function createAttachmentAfterDelete(context, file, refBy, refType) {
231
439
  if (file === undefined) {
232
440
  return null;
@@ -237,5 +445,4 @@ async function createAttachmentAfterDelete(context, file, refBy, refType) {
237
445
  let result = await (0, attachment_base_1.createAttachment)(null, { attachment: { file, refType, refBy } }, context);
238
446
  return await (0, shell_1.getRepository)(attachment_base_1.Attachment, tx).findOne({ where: { id: result.id } });
239
447
  }
240
- exports.createAttachmentAfterDelete = createAttachmentAfterDelete;
241
448
  //# sourceMappingURL=project-mutation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"project-mutation.js","sourceRoot":"","sources":["../../../server/service/project/project-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AACrD,qEAAuH;AACvH,uCAAiD;AACjD,iDAAqF;AACrF,6DAAiF;AACjF,uHAAwG;AAExG,+DAAwE;AAEjE,IAAM,eAAe,GAArB,MAAM,eAAe;IAGpB,AAAN,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,WAAW,GAAG,IAAA,qBAAa,EAAC,iBAAO,EAAE,EAAE,CAAC,CAAA;QAC9C,MAAM,mBAAmB,GAAG,IAAA,qBAAa,EAAC,kCAAe,EAAE,EAAE,CAAC,CAAA;QAE9D,MAAM,kBAAkB,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC;YACxD,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC;YACpC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,eAAe,EAAE,kBAAkB;YACnC,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf,CAAC;IAIK,AAAN,KAAK,CAAC,aAAa,CAAiB,OAAqB,EAAS,OAAwB;;QACxF,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAClC,MAAM,WAAW,GAAG,IAAA,qBAAa,EAAC,iBAAO,EAAE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,EAAE,OAAY;IAC7G,IAAI,IAAI,KAAK,SAAS,EAAE;QACtB,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE5B,mBAAmB;IACnB,MAAM,IAAA,wCAAsB,EAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAA;IAEzE,IAAI,MAAM,GAAG,MAAM,IAAA,kCAAgB,EAAC,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;IAE5F,OAAO,MAAM,IAAA,qBAAa,EAAC,4BAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;AAClF,CAAC;AAbD,kEAaC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { getRepository } from '@things-factory/shell'\nimport { Attachment, createAttachment, deleteAttachmentsByRef, ATTACHMENT_PATH } from '@things-factory/attachment-base'\nimport { Project, ProjectState } from './project'\nimport { NewProject, ProjectPatch, UploadProjectScheduleTable } from './project-type'\nimport { BuildingComplex, Building, BuildingLevel } from '@dssp/building-complex'\nimport { pdfToImage } from '@things-factory/board-service/dist-server/controllers/headless-pdf-to-image'\n\nimport { parseExcelAndImportTasks } from '../../controllers/parse-excel'\n@Resolver(Project)\nexport class ProjectMutation {\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트 생성' })\n async createProject(@Arg('project') project: NewProject, @Ctx() context: ResolverContext): Promise<Project> {\n const { domain, user, tx } = context.state\n const projectRepo = getRepository(Project, tx)\n const buildingComplexRepo = getRepository(BuildingComplex, tx)\n\n const newBuildingComplex = await buildingComplexRepo.save({\n domain,\n creator: user,\n updater: user\n })\n\n const result = await projectRepo.save({\n name: project.name,\n buildingComplex: newBuildingComplex,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트 업데이트' })\n async updateProject(@Arg('project') project: ProjectPatch, @Ctx() context: ResolverContext): Promise<Project> {\n const { user, tx } = context.state\n const projectRepo = getRepository(Project, tx)\n const buildingComplexRepo = getRepository(BuildingComplex, tx)\n const buildingRepo = getRepository(Building, tx)\n const buildingLevelRepo = getRepository(BuildingLevel, tx)\n\n const buildingComplex = project.buildingComplex\n const buildings = project.buildingComplex?.buildings || []\n\n // 1. 프로젝트 수정\n const projectState = project.totalProgress == 100 ? ProjectState.COMPLETED : ProjectState.ONGOING\n const projectResult = await projectRepo.save({ ...project, state: projectState, updater: user })\n\n // 2. 단지 정보 수정\n await buildingComplexRepo.save({ ...buildingComplex, updater: user })\n\n // 2-1. 프로젝트 메인 이미지 첨부파일 나머지 삭제 후 저장\n await createAttachmentAfterDelete(context, project?.mainPhotoUpload, project.id, Project.name)\n\n // 2-2. 단지 BIM 이미지 첨부파일 나머지 삭제 후 저장\n await createAttachmentAfterDelete(context, buildingComplex?.drawingUpload, buildingComplex.id, BuildingComplex.name + '_bim')\n\n // 3. 동의 층 정보가 바뀌었으면 층 초기화 후 다시 생성\n const originBuilding = await buildingRepo.findBy({ buildingComplex: { id: buildingComplex.id } }) // 이전 동 정보 가져오기\n const afterBuilding = buildings.reduce((acc, building) => ({ ...acc, [building.name]: building.floorCount }), {}) // 비교용으로 수정된 동 정보 데이터 파싱\n const isBuidlingChanged = originBuilding.some(building => afterBuilding[building.name] !== building.floorCount) // 층 개수가 달라진 동이 있는지 확인\n\n // 동의 층 개수가 달라지면 모든 층의 데이터 제거 후 생성\n if (isBuidlingChanged || originBuilding.length !== buildings.length) {\n // 3-1. 기존 동/층 첨부파일 및 데이터 제거\n const buildingIds = originBuilding.map((building: Building) => building.id)\n const buildingLevels = await buildingLevelRepo.findBy({ building: { id: In(buildingIds) } })\n const buildingLevelIds = buildingLevels.map((buildingLevel: BuildingLevel) => buildingLevel.id)\n\n await buildingLevelRepo.softDelete({ building: { id: In(buildingIds) } })\n await buildingRepo.softDelete({ id: In(buildingIds) })\n await deleteAttachmentsByRef(null, { refBys: [...buildingIds, ...buildingLevelIds] }, context)\n\n // 3-2. 단지 내 동 정보들 생성\n for (let buildingKey in buildings) {\n const building = buildings[buildingKey]\n const newBuilding = await buildingRepo.save({\n buildingComplex: buildingComplex,\n name: building.name,\n floorCount: building.floorCount,\n creator: user\n })\n\n // 3-3. 동별로 for문 돌면서 층 데이터 개수대로 생성\n for (let i = 1; i <= building.floorCount; i++) {\n await buildingLevelRepo.save({ building: newBuilding, floor: i, creator: user })\n }\n }\n }\n\n return projectResult\n }\n\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트 도면 업데이트' })\n async updateProjectPlan(@Arg('project') project: ProjectPatch, @Ctx() context: ResolverContext): Promise<Project> {\n const { user, tx, domain } = context.state\n const projectRepo = getRepository(Project, tx)\n const buildingComplexRepo = getRepository(BuildingComplex, tx)\n const buildingRepo = getRepository(Building, tx)\n const buildingLevelRepo = getRepository(BuildingLevel, tx)\n const buildingComplex = project.buildingComplex\n const buildings = project.buildingComplex?.buildings || []\n\n // 1. 프로젝트 수정 시간 업데이트\n const projectResult = await projectRepo.save({ ...project, updater: user })\n\n // 2. 단지 축척 정보 수정\n await buildingComplexRepo.save({ ...buildingComplex, updater: user })\n\n for (let buildingKey in buildings) {\n const building = buildings[buildingKey]\n\n for (let buildingLevelKey in building.buildingLevels) {\n const buildingLevel = building.buildingLevels[buildingLevelKey]\n\n // 3. 층별 도면 이미지 저장\n const mainDrawingAttatchment = await createAttachmentAfterDelete(\n context,\n buildingLevel.mainDrawingUpload,\n buildingLevel.id,\n BuildingLevel.name + '_mainDrawing'\n )\n // 첨부된 PDF가 있으면 PDF 파일대로 썸네일 생성\n if (mainDrawingAttatchment) {\n const mainDrawingUpload = await buildingLevel.mainDrawingUpload\n const pdfPath = `/${ATTACHMENT_PATH}/${mainDrawingAttatchment.path}` // TODO ATTACHMENT_PATH 제거, mainDrawingAttachment.fullpath 로 해도 될 것 같은데...\n const fileName = mainDrawingUpload.filename.replace('.pdf', '')\n const pngFile = await pdfToImage({ pdfPath, fileName })\n await createAttachmentAfterDelete(context, pngFile, buildingLevel.id, BuildingLevel.name + '_mainDrawing_image')\n\n const pngThumbnailFile = await pdfToImage({ pdfPath, fileName, defaultViewport: { width: 300, height: 200 } })\n await createAttachmentAfterDelete(\n context,\n pngThumbnailFile,\n buildingLevel.id,\n BuildingLevel.name + '_mainDrawing_thumbnail'\n )\n }\n\n // 3-1. 입면도 파일 저장\n const elevationDrawingAttatchment = await createAttachmentAfterDelete(\n context,\n buildingLevel.elevationDrawingUpload,\n buildingLevel.id,\n BuildingLevel.name + '_elevationDrawing'\n )\n if (elevationDrawingAttatchment) {\n const elevationDrawingUpload = await buildingLevel.elevationDrawingUpload\n const pdfPath = `/${ATTACHMENT_PATH}/${elevationDrawingAttatchment.path}`\n const fileName = elevationDrawingUpload.filename.replace('.pdf', '')\n const pngThumbnailFile = await pdfToImage({ pdfPath, fileName, defaultViewport: { width: 300, height: 200 } })\n await createAttachmentAfterDelete(\n context,\n pngThumbnailFile,\n buildingLevel.id,\n BuildingLevel.name + '_elevationDrawing_thumbnail'\n )\n }\n\n // 3-2. 철근배분도 파일 저장\n const rebarDistributionDrawingAttatchment = await createAttachmentAfterDelete(\n context,\n buildingLevel.rebarDistributionDrawingUpload,\n buildingLevel.id,\n BuildingLevel.name + '_rebarDistributionDrawing'\n )\n if (rebarDistributionDrawingAttatchment) {\n const rebarDistributionDrawingUpload = await buildingLevel.rebarDistributionDrawingUpload\n const pdfPath = `/${ATTACHMENT_PATH}/${rebarDistributionDrawingAttatchment.path}`\n const fileName = rebarDistributionDrawingUpload.filename.replace('.pdf', '')\n const pngThumbnailFile = await pdfToImage({ pdfPath, fileName, defaultViewport: { width: 300, height: 200 } })\n await createAttachmentAfterDelete(\n context,\n pngThumbnailFile,\n buildingLevel.id,\n BuildingLevel.name + '_rebarDistributionDrawing_thumbnail'\n )\n }\n\n // 3-3. 층 업데이트 시간 갱신\n await buildingLevelRepo.save({ ...buildingLevel, updater: user })\n }\n\n // 4. 동별 도면 이미지 저장\n await createAttachmentAfterDelete(context, building?.drawingUpload, building.id, Building.name)\n\n // 4-1. 동 업데이트 시간 갱신\n await buildingRepo.save({ ...building, updater: user })\n }\n\n return projectResult\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: '프로젝트 공정표 업로드' })\n async uploadProjectScheduleTable(\n @Arg('param') param: UploadProjectScheduleTable,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { domain, user, tx } = context.state\n const { projectId, scheduleTable } = param\n\n const projectRepo = getRepository(Project, tx)\n const project = await projectRepo.findOne({\n where: { domain: { id: domain.id }, id: projectId }\n })\n\n const { createReadStream, filename, mimetype } = await scheduleTable\n\n const stream = createReadStream()\n\n const chunks = []\n for await (const chunk of stream) {\n chunks.push(chunk)\n }\n\n const buffer = Buffer.concat(chunks)\n\n await parseExcelAndImportTasks(buffer, project, context)\n // await parseExcelAndImportTasks(attachment.fullpath, project, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Project' })\n async deleteProject(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { domain, tx } = context.state\n\n await getRepository(Project, tx).delete({ domain: { id: domain.id }, id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n}\n\nexport async function createAttachmentAfterDelete(context: ResolverContext, file: any, refBy: any, refType: any) {\n if (file === undefined) {\n return null\n }\n\n const { tx } = context.state\n\n // 기존 첨부 파일이 있으면 삭제\n await deleteAttachmentsByRef(null, { refBys: [refBy], refType }, context)\n\n let result = await createAttachment(null, { attachment: { file, refType, refBy } }, context)\n\n return await getRepository(Attachment, tx).findOne({ where: { id: result.id } })\n}\n"]}
1
+ {"version":3,"file":"project-mutation.js","sourceRoot":"","sources":["../../../server/service/project/project-mutation.ts"],"names":[],"mappings":";;;AAueA,kEAaC;;AApfD,+CAAsE;AACtE,qCAA4B;AAC5B,iDAA6D;AAC7D,qEAMwC;AACxC,uCAAgD;AAChD,iDAAqF;AACrF,6DAAuD;AACvD,6DAAiF;AACjF,uHAAwG;AACxG,+DAAwE;AACxE,+CAAwB;AACxB,mDAA4B;AAC5B,gEAA+B;AAC/B,6CAA4C;AAE5C,MAAM,uBAAuB,GAAG,SAAS,CAAA;AACzC,MAAM,0BAA0B,GAAG,kBAAkB,CAAA;AAErD,MAAM,WAAW,GAAG,YAAM,CAAC,GAAG,CAAC,aAAa,EAAE,qBAAW,CAAC,IAAI,CAAC,CAAA;AAGxD,IAAM,eAAe,GAArB,MAAM,eAAe;IAGpB,AAAN,KAAK,CAAC,aAAa,CAAiB,OAAmB,EAAS,OAAwB;QACtF,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAC1C,MAAM,WAAW,GAAG,IAAA,qBAAa,EAAC,iBAAO,EAAE,EAAE,CAAC,CAAA;QAC9C,MAAM,mBAAmB,GAAG,IAAA,qBAAa,EAAC,kCAAe,EAAE,EAAE,CAAC,CAAA;QAE9D,MAAM,kBAAkB,GAAG,MAAM,mBAAmB,CAAC,IAAI,CAAC;YACxD,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC;YACpC,IAAI,EAAE,OAAO,CAAC,IAAI;YAClB,cAAc,EAAE,OAAO,CAAC,IAAI;YAC5B,eAAe,EAAE,kBAAkB;YACnC,WAAW;YACX,MAAM;YACN,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,IAAI;SACd,CAAC,CAAA;QAEF,OAAO,MAAM,CAAA;IACf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mBAAA,IAAA,kBAAG,EAAC,WAAW,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;0DA2BpE;0BAzcU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,eAAe,CA0c3B;AAEM,KAAK,UAAU,2BAA2B,CAAC,OAAwB,EAAE,IAAS,EAAE,KAAU,EAAE,OAAY;IAC7G,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;IAE5B,mBAAmB;IACnB,MAAM,IAAA,wCAAsB,EAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,EAAE,OAAO,CAAC,CAAA;IAEzE,IAAI,MAAM,GAAG,MAAM,IAAA,kCAAgB,EAAC,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;IAE5F,OAAO,MAAM,IAAA,qBAAa,EAAC,4BAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;AAClF,CAAC","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { Domain, getRepository } from '@things-factory/shell'\nimport {\n Attachment,\n createAttachment,\n deleteAttachmentsByRef,\n ATTACHMENT_PATH,\n deleteAttachment\n} from '@things-factory/attachment-base'\nimport { Project, ProjectType } from './project'\nimport { NewProject, ProjectPatch, UploadProjectScheduleTable } from './project-type'\nimport { issueProjectCode } from './issue-project-code'\nimport { BuildingComplex, Building, BuildingLevel } from '@dssp/building-complex'\nimport { pdfToImage } from '@things-factory/board-service/dist-server/controllers/headless-pdf-to-image'\nimport { parseExcelAndImportTasks } from '../../controllers/parse-excel'\nimport * as fs from 'fs'\nimport * as path from 'path'\nimport archiver from 'archiver'\nimport { config } from '@things-factory/env'\n\nconst PROJECT_DOMAIN_EXT_TYPE = 'project'\nconst PROJECT_TEMPLATE_SUBDOMAIN = 'project-template'\n\nconst projectType = config.get('projectType', ProjectType.DSSP)\n\n@Resolver(Project)\nexport class ProjectMutation {\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트 생성' })\n async createProject(@Arg('project') project: NewProject, @Ctx() context: ResolverContext): Promise<Project> {\n const { domain, user, tx } = context.state\n const projectRepo = getRepository(Project, tx)\n const buildingComplexRepo = getRepository(BuildingComplex, tx)\n\n const newBuildingComplex = await buildingComplexRepo.save({\n domain,\n creator: user,\n updater: user\n })\n\n const result = await projectRepo.save({\n name: project.name,\n documentNaming: project.name,\n buildingComplex: newBuildingComplex,\n projectType,\n domain,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트 업데이트 (중복 사용 금지)' })\n async updateProject(@Arg('project') project: ProjectPatch, @Ctx() context: ResolverContext): Promise<Project> {\n const { user, tx } = context.state\n const projectRepo = getRepository(Project, tx)\n const buildingComplexRepo = getRepository(BuildingComplex, tx)\n const buildingRepo = getRepository(Building, tx)\n const buildingLevelRepo = getRepository(BuildingLevel, tx)\n\n const buildingComplex = project.buildingComplex\n const buildings = project.buildingComplex?.buildings || []\n\n // 1. 프로젝트 수정\n const projectResult = await projectRepo.save({ ...project, updater: user })\n\n // 1-1. 프로젝트명이 변경되면 연동된 테넌트 Domain 이름도 함께 동기화.\n // 전용 Domain 은 테넌트 승격(promoteProjectToTenant) 시에만 생성되므로\n // code 를 보유한 프로젝트만 대상. Domain 은 subdomain=code, extType='project' 로 식별.\n if (project.name !== undefined) {\n const domainRepo = getRepository(Domain, tx)\n const { code } = (await projectRepo.findOne({ where: { id: project.id }, select: ['code'] })) || {}\n if (code) {\n const linkedDomain = await domainRepo.findOne({\n where: { subdomain: code, extType: PROJECT_DOMAIN_EXT_TYPE }\n })\n if (linkedDomain && linkedDomain.name !== project.name) {\n await domainRepo.save({ ...linkedDomain, name: project.name })\n }\n }\n }\n\n // buildingComplex 가 patch 에 없는 경우 (예: state 만 변경하는 부분 patch) 는 단지 정보·\n // 동/층·첨부파일 관련 후속 단계 모두 skip.\n if (!buildingComplex) {\n return projectResult\n }\n\n // 2. 단지 정보 수정\n await buildingComplexRepo.save({ ...buildingComplex, updater: user })\n\n // 2-1. 프로젝트 메인 이미지 첨부파일 나머지 삭제 후 저장\n await createAttachmentAfterDelete(context, project?.mainPhotoUpload, project.id, Project.name)\n\n // 2-2. 단지 BIM 이미지 첨부파일 나머지 삭제 후 저장\n if (buildingComplex.id) {\n await createAttachmentAfterDelete(\n context,\n buildingComplex?.drawingUpload,\n buildingComplex.id,\n BuildingComplex.name + '_bim'\n )\n }\n\n // 3. 동의 층 정보가 바뀌었으면 층 초기화 후 다시 생성\n const originBuilding = buildingComplex.id\n ? await buildingRepo.findBy({ buildingComplex: { id: buildingComplex.id } })\n : []\n const afterBuilding = buildings.reduce((acc, building) => ({ ...acc, [building.name]: building.floorCount }), {}) // 비교용으로 수정된 동 정보 데이터 파싱\n const afterBasement = buildings.reduce((acc, building) => ({ ...acc, [building.name]: building.basementFloorCount || 0 }), {}) // 비교용으로 수정된 지하 정보 데이터 파싱\n const isBuidlingChanged = originBuilding.some(\n building =>\n afterBuilding[building.name] !== building.floorCount || afterBasement[building.name] !== building.basementFloorCount\n ) // 층 개수가 달라진 동이 있는지 확인\n\n // 동의 층 개수가 달라지면 모든 층의 데이터 제거 후 생성\n if (isBuidlingChanged || originBuilding.length !== buildings.length) {\n // 3-1. 기존 동/층 첨부파일 및 데이터 제거\n const buildingIds = originBuilding.map((building: Building) => building.id)\n const buildingLevels = await buildingLevelRepo.findBy({ building: { id: In(buildingIds) } })\n const buildingLevelIds = buildingLevels.map((buildingLevel: BuildingLevel) => buildingLevel.id)\n\n await buildingLevelRepo.softDelete({ building: { id: In(buildingIds) } })\n await buildingRepo.softDelete({ id: In(buildingIds) })\n await deleteAttachmentsByRef(null, { refBys: [...buildingIds, ...buildingLevelIds] }, context)\n\n // 3-2. 단지 내 동 정보들 생성\n for (let buildingKey in buildings) {\n const building = buildings[buildingKey]\n const newBuilding = await buildingRepo.save({\n buildingComplex: buildingComplex,\n name: building.name,\n floorCount: building.floorCount,\n hasBasement: building.hasBasement,\n basementFloorCount: building.hasBasement ? building.basementFloorCount : 0,\n updater: user,\n creator: user\n })\n\n // 3-3. 동별로 for문 돌면서 층 데이터 개수대로 생성\n for (let i = 1; i <= building.floorCount; i++) {\n await buildingLevelRepo.save({ building: newBuilding, floor: i, creator: user })\n }\n\n // 3-4. 지하층 층 데이터 생성\n if (building.hasBasement) {\n for (let i = 1; i <= building.basementFloorCount; i++) {\n await buildingLevelRepo.save({ building: newBuilding, floor: -i, creator: user })\n }\n }\n }\n }\n\n return projectResult\n }\n\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트 도면 업데이트' })\n async updateProjectPlan(@Arg('project') project: ProjectPatch, @Ctx() context: ResolverContext): Promise<Project> {\n const { user, tx, domain } = context.state\n const projectRepo = getRepository(Project, tx)\n const buildingComplexRepo = getRepository(BuildingComplex, tx)\n const buildingRepo = getRepository(Building, tx)\n const buildingLevelRepo = getRepository(BuildingLevel, tx)\n const attachmentRepo = getRepository(Attachment, tx)\n const buildingComplex = project.buildingComplex\n const buildings = project.buildingComplex?.buildings || []\n\n // 1. 프로젝트 수정 시간 업데이트\n const projectResult = await projectRepo.save({ ...project, updater: user })\n\n // 2. 단지 축척 정보 수정\n await buildingComplexRepo.save({ ...buildingComplex, updater: user })\n\n for (let buildingKey in buildings) {\n const building = buildings[buildingKey]\n\n for (let buildingLevelKey in building.buildingLevels) {\n const buildingLevel = building.buildingLevels[buildingLevelKey]\n\n // 3. 층별 도면 이미지 저장\n const mainDrawingAttatchment = await createAttachmentAfterDelete(\n context,\n buildingLevel.mainDrawingUpload,\n buildingLevel.id,\n BuildingLevel.name + '_mainDrawing'\n )\n // 첨부된 PDF가 있으면 PDF 파일대로 썸네일 생성\n if (mainDrawingAttatchment) {\n const mainDrawingUpload = await buildingLevel.mainDrawingUpload\n const pdfPath = `/${ATTACHMENT_PATH}/${mainDrawingAttatchment.path}` // TODO ATTACHMENT_PATH 제거, mainDrawingAttachment.fullpath 로 해도 될 것 같은데...\n const fileName = mainDrawingUpload.filename.replace('.pdf', '')\n const pngFile = await pdfToImage({ pdfPath, fileName })\n await createAttachmentAfterDelete(context, pngFile, buildingLevel.id, BuildingLevel.name + '_mainDrawing_image')\n\n const pngThumbnailFile = await pdfToImage({ pdfPath, fileName, defaultViewport: { width: 300, height: 200 } })\n await createAttachmentAfterDelete(\n context,\n pngThumbnailFile,\n buildingLevel.id,\n BuildingLevel.name + '_mainDrawing_thumbnail'\n )\n }\n\n // 3-1. 입면도 파일 저장\n const elevationDrawingAttatchment = await createAttachmentAfterDelete(\n context,\n buildingLevel.elevationDrawingUpload,\n buildingLevel.id,\n BuildingLevel.name + '_elevationDrawing'\n )\n if (elevationDrawingAttatchment) {\n const elevationDrawingUpload = await buildingLevel.elevationDrawingUpload\n const pdfPath = `/${ATTACHMENT_PATH}/${elevationDrawingAttatchment.path}`\n const fileName = elevationDrawingUpload.filename.replace('.pdf', '')\n const pngThumbnailFile = await pdfToImage({ pdfPath, fileName, defaultViewport: { width: 300, height: 200 } })\n await createAttachmentAfterDelete(\n context,\n pngThumbnailFile,\n buildingLevel.id,\n BuildingLevel.name + '_elevationDrawing_thumbnail'\n )\n }\n\n // 3-2. 철근배분도 파일 저장\n const rebarDistributionDrawingAttatchment = await createAttachmentAfterDelete(\n context,\n buildingLevel.rebarDistributionDrawingUpload,\n buildingLevel.id,\n BuildingLevel.name + '_rebarDistributionDrawing'\n )\n if (rebarDistributionDrawingAttatchment) {\n const rebarDistributionDrawingUpload = await buildingLevel.rebarDistributionDrawingUpload\n const pdfPath = `/${ATTACHMENT_PATH}/${rebarDistributionDrawingAttatchment.path}`\n const fileName = rebarDistributionDrawingUpload.filename.replace('.pdf', '')\n const pngThumbnailFile = await pdfToImage({ pdfPath, fileName, defaultViewport: { width: 300, height: 200 } })\n await createAttachmentAfterDelete(\n context,\n pngThumbnailFile,\n buildingLevel.id,\n BuildingLevel.name + '_rebarDistributionDrawing_thumbnail'\n )\n }\n\n // 3-3. 기타 도면 파일 저장\n const etcDrawingRefType = BuildingLevel.name + '_etcDrawings'\n\n // 기존 첨부 파일 중 제거된 것들 삭제\n const etcDrawings = await attachmentRepo.find({ where: { refType: etcDrawingRefType, refBy: buildingLevel.id } })\n for (let etcDrawing of etcDrawings) {\n if (!buildingLevel.etcDrawingIds.includes(etcDrawing.id)) {\n await deleteAttachment(null, { id: etcDrawing.id }, context)\n }\n }\n\n // 업로드\n if (buildingLevel.etcDrawingsUpload?.length > 0) {\n for (let etcDrawing of buildingLevel.etcDrawingsUpload) {\n await createAttachment(\n null,\n { attachment: { file: etcDrawing, refType: etcDrawingRefType, refBy: buildingLevel.id } },\n context\n )\n }\n }\n\n // 3-4. 층 업데이트 시간 갱신\n await buildingLevelRepo.save({ ...buildingLevel, updater: user })\n }\n\n // 4. 동별 도면 이미지 저장\n await createAttachmentAfterDelete(context, building?.drawingUpload, building.id, Building.name)\n\n // 4-1. 동 업데이트 시간 갱신\n await buildingRepo.save({ ...building, updater: user })\n }\n\n return projectResult\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: '프로젝트 공정표 업로드' })\n async uploadProjectScheduleTable(\n @Arg('param') param: UploadProjectScheduleTable,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { user, tx } = context.state\n const { projectId, scheduleTable } = param\n\n const projectRepo = getRepository(Project, tx)\n const project = await projectRepo.findOne({\n where: { id: projectId }\n })\n\n const { createReadStream, filename, mimetype } = await scheduleTable\n\n const stream = createReadStream()\n\n const chunks = []\n for await (const chunk of stream) {\n chunks.push(chunk)\n }\n\n const buffer = Buffer.concat(chunks)\n\n await parseExcelAndImportTasks(buffer, project, context)\n // await parseExcelAndImportTasks(attachment.fullpath, project, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete Project' })\n async deleteProject(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx } = context.state\n\n await getRepository(Project, tx).delete({ id })\n await deleteAttachmentsByRef(null, { refBys: [id] }, context)\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => String, { description: '선택된 도면 파일들을 ZIP으로 압축하여 다운로드 URL 반환' })\n async downloadPlanFiles(@Arg('fileIds', type => [String]) fileIds: string[], @Ctx() context: ResolverContext): Promise<string> {\n const { tx } = context.state\n\n if (!fileIds || fileIds.length === 0) {\n throw new Error('다운로드할 파일을 선택해주세요.')\n }\n\n // 첨부파일 정보 조회\n const attachments = await tx.getRepository(Attachment).find({\n where: { id: In(fileIds) }\n })\n\n if (attachments.length === 0) {\n throw new Error('선택된 파일을 찾을 수 없습니다.')\n }\n\n // ZIP 파일 생성 - 동과 층 정보를 포함한 파일명\n const zipFileName = `download.zip`\n const tempDir = path.join(process.cwd(), 'temp')\n const zipFilePath = path.join(tempDir, zipFileName)\n\n // temp 디렉토리 생성\n if (!fs.existsSync(tempDir)) {\n fs.mkdirSync(tempDir, { recursive: true })\n }\n\n const output = fs.createWriteStream(zipFilePath)\n const archive = archiver('zip', {\n zlib: { level: 9 } // 최대 압축\n })\n\n return new Promise(async (resolve, reject) => {\n output.on('close', () => {\n // ZIP 파일을 Base64로 인코딩하여 반환\n const zipBuffer = fs.readFileSync(zipFilePath)\n const base64Data = zipBuffer.toString('base64')\n const dataUrl = `data:application/zip;base64,${base64Data}`\n\n // 임시 파일 삭제\n fs.unlinkSync(zipFilePath)\n resolve(dataUrl)\n })\n\n archive.on('error', err => {\n reject(err)\n })\n archive.pipe(output)\n\n try {\n // 각 첨부파일을 ZIP에 추가\n for (const attachment of attachments) {\n try {\n const fileUrl = `http://localhost:3000${attachment.fullpath}`\n const response = await fetch(fileUrl)\n if (response.ok) {\n const buffer = await response.arrayBuffer()\n const fileName = attachment.name || path.basename(attachment.fullpath)\n archive.append(Buffer.from(buffer), { name: fileName })\n }\n } catch (error) {\n console.error('Error processing attachment:', attachment.fullpath, error)\n }\n }\n\n archive.finalize()\n } catch (error) {\n reject(error)\n }\n })\n }\n\n @Directive('@transaction')\n @Mutation(returns => Project, { description: '프로젝트를 테넌트로 승격 (관리번호 발번 + project 카테고리 Domain 생성)' })\n async promoteProjectToTenant(@Arg('projectId') projectId: string, @Ctx() context: ResolverContext): Promise<Project> {\n const { user, tx } = context.state\n\n const projectRepo = tx.getRepository(Project)\n const domainRepo = tx.getRepository(Domain)\n\n const project = await projectRepo.findOne({\n where: { id: projectId }\n })\n\n if (!project) {\n throw new Error(`프로젝트를 찾을 수 없습니다: ${projectId}`)\n }\n\n // 이미 활성 테넌트인 경우 차단 (강등 상태는 재승격 허용)\n if (project.code) {\n const existing = await domainRepo.findOne({\n where: { subdomain: project.code, extType: PROJECT_DOMAIN_EXT_TYPE }\n })\n if (existing) {\n throw new Error(`이미 테넌트로 승격된 프로젝트입니다: ${project.code}`)\n }\n }\n\n // 템플릿 Domain 조회 — 모든 프로젝트 도메인의 parent. Role 상속의 단일 진실.\n // subdomain 만으로 식별 — 어드민에서 수동 생성된 도메인의 extType 이\n // NULL/대소문자 차이로 누락되어 false-negative 가 자주 발생하므로.\n const templateDomain = await domainRepo.findOne({\n where: { subdomain: PROJECT_TEMPLATE_SUBDOMAIN }\n })\n if (!templateDomain) {\n throw new Error(\n `프로젝트 템플릿 Domain (subdomain='${PROJECT_TEMPLATE_SUBDOMAIN}') 이 존재하지 않습니다. 어드민에서 먼저 생성하세요.`\n )\n }\n\n // 코드가 없으면 발번 (재승격 시에는 기존 코드 재사용)\n const code = project.code ?? (await issueProjectCode(tx))\n\n await domainRepo.save({\n name: project.name,\n subdomain: code,\n extType: PROJECT_DOMAIN_EXT_TYPE,\n parent: templateDomain,\n owner: user.id\n })\n\n if (!project.code) {\n await projectRepo.update({ id: projectId }, { code })\n project.code = code\n }\n\n return project\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: '프로젝트 테넌트 강등 (Domain soft-delete, Project.code 보존)' })\n async demoteProjectTenant(@Arg('projectId') projectId: string, @Ctx() context: ResolverContext): Promise<boolean> {\n const { tx } = context.state\n\n const project = await tx.getRepository(Project).findOne({\n where: { id: projectId }\n })\n\n if (!project) {\n throw new Error(`프로젝트를 찾을 수 없습니다: ${projectId}`)\n }\n\n if (!project.code) {\n throw new Error('승격된 적이 없는 프로젝트입니다.')\n }\n\n const domainRepo = tx.getRepository(Domain)\n const tenantDomain = await domainRepo.findOne({\n where: { subdomain: project.code, extType: PROJECT_DOMAIN_EXT_TYPE }\n })\n\n if (!tenantDomain) {\n throw new Error('이미 강등된 프로젝트입니다.')\n }\n\n await domainRepo.softDelete({ id: tenantDomain.id })\n\n return true\n }\n}\n\nexport async function createAttachmentAfterDelete(context: ResolverContext, file: any, refBy: any, refType: any) {\n if (file === undefined) {\n return null\n }\n\n const { tx } = context.state\n\n // 기존 첨부 파일이 있으면 삭제\n await deleteAttachmentsByRef(null, { refBys: [refBy], refType }, context)\n\n let result = await createAttachment(null, { attachment: { file, refType, refBy } }, context)\n\n return await getRepository(Attachment, tx).findOne({ where: { id: result.id } })\n}\n"]}
@@ -7,13 +7,25 @@ import { Attachment } from '@things-factory/attachment-base';
7
7
  import { BuildingComplex } from '@dssp/building-complex';
8
8
  export declare class ProjectQuery {
9
9
  project(id: string, context: ResolverContext): Promise<Project>;
10
- projects(params: ListParam, context: ResolverContext): Promise<ProjectList>;
11
- projectByBuildingComplexId(buildingComplexId: string, context: ResolverContext): Promise<Project>;
10
+ currentProject(context: ResolverContext): Promise<Project>;
11
+ projects(params: ListParam): Promise<ProjectList>;
12
+ projectByBuildingComplexId(buildingComplexId: string): Promise<Project>;
13
+ projectByBuildingLevelId(buildingLevelId: string, context: ResolverContext): Promise<Project>;
14
+ currentProjectType(): Promise<string>;
12
15
  rootTasks(project: Project): Promise<Task[]>;
13
16
  mainPhoto(project: Project): Promise<string | Attachment>;
14
17
  scheduleTable(project: Project): Promise<Attachment | undefined>;
18
+ completeReport(project: Project): Promise<Attachment | undefined>;
15
19
  buildingComplex(project: Project): Promise<BuildingComplex>;
16
20
  domain(project: Project): Promise<Domain>;
21
+ tenantDomain(project: Project): Promise<Domain | null>;
17
22
  updater(project: Project): Promise<User>;
18
23
  creator(project: Project): Promise<User>;
24
+ projectType(project: Project): Promise<string>;
25
+ kpi(project: Project): Promise<number>;
26
+ kpiValues(project: Project): Promise<KpiValuesObject[]>;
27
+ }
28
+ export declare class KpiValuesObject {
29
+ kpiName: string;
30
+ value: number;
19
31
  }