@dssp/project 1.0.0-alpha.5 → 1.0.0-alpha.51

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 (114) 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 +35 -35
  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 +309 -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 +357 -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 +681 -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 +32 -0
  28. package/dist-client/pages/project/popup/checklist/task-checklist-view.js +621 -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-schedule-upload.d.ts → popup-task-upload.d.ts} +1 -1
  37. package/dist-client/pages/project/popup/{popup-schedule-upload.js → popup-task-upload.js} +9 -9
  38. package/dist-client/pages/project/popup/popup-task-upload.js.map +1 -0
  39. package/dist-client/pages/project/project-completed-list.d.ts +5 -0
  40. package/dist-client/pages/project/project-completed-list.js +32 -3
  41. package/dist-client/pages/project/project-completed-list.js.map +1 -1
  42. package/dist-client/pages/project/project-detail.d.ts +2 -1
  43. package/dist-client/pages/project/project-detail.js +316 -97
  44. package/dist-client/pages/project/project-detail.js.map +1 -1
  45. package/dist-client/pages/project/project-list.d.ts +53 -0
  46. package/dist-client/pages/project/project-list.js +72 -3
  47. package/dist-client/pages/project/project-list.js.map +1 -1
  48. package/dist-client/pages/project/project-plan-management.js +29 -13
  49. package/dist-client/pages/project/project-plan-management.js.map +1 -1
  50. package/dist-client/pages/project/project-setting-list.d.ts +5 -0
  51. package/dist-client/pages/project/project-setting-list.js +32 -3
  52. package/dist-client/pages/project/project-setting-list.js.map +1 -1
  53. package/dist-client/pages/project/{project-schedule-list.d.ts → project-task-list.d.ts} +2 -2
  54. package/dist-client/pages/project/{project-schedule-list.js → project-task-list.js} +11 -11
  55. package/dist-client/pages/project/project-task-list.js.map +1 -0
  56. package/dist-client/pages/project/{project-schedule.d.ts → project-task.d.ts} +17 -4
  57. package/dist-client/pages/project/project-task.js +686 -0
  58. package/dist-client/pages/project/project-task.js.map +1 -0
  59. package/dist-client/pages/project/project-update.d.ts +1 -0
  60. package/dist-client/pages/project/project-update.js +346 -42
  61. package/dist-client/pages/project/project-update.js.map +1 -1
  62. package/dist-client/route.d.ts +1 -1
  63. package/dist-client/route.js +4 -4
  64. package/dist-client/route.js.map +1 -1
  65. package/dist-client/tsconfig.tsbuildinfo +1 -1
  66. package/dist-server/controllers/parse-excel.js.map +1 -1
  67. package/dist-server/service/index.d.ts +2 -2
  68. package/dist-server/service/index.js +5 -2
  69. package/dist-server/service/index.js.map +1 -1
  70. package/dist-server/service/project/project-mutation.d.ts +1 -0
  71. package/dist-server/service/project/project-mutation.js +107 -4
  72. package/dist-server/service/project/project-mutation.js.map +1 -1
  73. package/dist-server/service/project/project-query.d.ts +3 -0
  74. package/dist-server/service/project/project-query.js +52 -0
  75. package/dist-server/service/project/project-query.js.map +1 -1
  76. package/dist-server/service/project/project-type.d.ts +6 -0
  77. package/dist-server/service/project/project-type.js +24 -2
  78. package/dist-server/service/project/project-type.js.map +1 -1
  79. package/dist-server/service/project/project.d.ts +14 -1
  80. package/dist-server/service/project/project.js +49 -2
  81. package/dist-server/service/project/project.js.map +1 -1
  82. package/dist-server/service/task/task-query.d.ts +2 -0
  83. package/dist-server/service/task/task-query.js +11 -0
  84. package/dist-server/service/task/task-query.js.map +1 -1
  85. package/dist-server/service/task/task.d.ts +2 -0
  86. package/dist-server/service/task/task.js +6 -0
  87. package/dist-server/service/task/task.js.map +1 -1
  88. package/dist-server/service/task-checklist-binding/index.d.ts +5 -0
  89. package/dist-server/service/task-checklist-binding/index.js +9 -0
  90. package/dist-server/service/task-checklist-binding/index.js.map +1 -0
  91. package/dist-server/service/task-checklist-binding/task-checklist-binding-mutation.d.ts +5 -0
  92. package/dist-server/service/task-checklist-binding/task-checklist-binding-mutation.js +186 -0
  93. package/dist-server/service/task-checklist-binding/task-checklist-binding-mutation.js.map +1 -0
  94. package/dist-server/service/task-checklist-binding/task-checklist-binding-query.d.ts +8 -0
  95. package/dist-server/service/task-checklist-binding/task-checklist-binding-query.js +61 -0
  96. package/dist-server/service/task-checklist-binding/task-checklist-binding-query.js.map +1 -0
  97. package/dist-server/service/task-checklist-binding/task-checklist-binding-type.d.ts +15 -0
  98. package/dist-server/service/task-checklist-binding/task-checklist-binding-type.js +57 -0
  99. package/dist-server/service/task-checklist-binding/task-checklist-binding-type.js.map +1 -0
  100. package/dist-server/service/task-checklist-binding/task-checklist-binding.d.ts +22 -0
  101. package/dist-server/service/task-checklist-binding/task-checklist-binding.js +106 -0
  102. package/dist-server/service/task-checklist-binding/task-checklist-binding.js.map +1 -0
  103. package/dist-server/tsconfig.tsbuildinfo +1 -1
  104. package/package.json +15 -12
  105. package/things-factory.config.js +3 -3
  106. package/translations/en.json +10 -9
  107. package/translations/ja.json +15 -1
  108. package/translations/ko.json +3 -0
  109. package/translations/ms.json +15 -1
  110. package/translations/zh.json +15 -1
  111. package/dist-client/pages/project/popup/popup-schedule-upload.js.map +0 -1
  112. package/dist-client/pages/project/project-schedule-list.js.map +0 -1
  113. package/dist-client/pages/project/project-schedule.js +0 -407
  114. package/dist-client/pages/project/project-schedule.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"parse-excel.js","sourceRoot":"","sources":["../../server/controllers/parse-excel.ts"],"names":[],"mappings":";;AAKA,4DAgFC;;AArFD,8DAA6B;AAG7B,+CAA2C;AAEpC,KAAK,UAAU,wBAAwB,CAAC,MAAc,EAAE,OAAgB,EAAE,OAAwB;IACvG,oBAAoB;IACpB,MAAM,QAAQ,GAAG,IAAI,iBAAO,CAAC,QAAQ,EAAE,CAAA;IACvC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAEhC,uBAAuB;IACvB,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA,CAAC,kCAAkC;IAE7E,8BAA8B;IAC9B,MAAM,OAAO,GAAa,E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AC,CAAC,EAAE;YACzE,KAAK,EAAE,OAAO;YACd,QAAQ,EAAE,EAAE;SACb,CAAA;QAED,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClB,CAAC;IACH,CAAC;IAED,qCAAqC;IACrC,MAAM,IAAA,yBAAW,EAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC","sourcesContent":["import ExcelJS from 'exceljs'\nimport { RawTask } from './types'\nimport { Project } from '../service/project/project'\nimport { importTasks } from './import-task'\n\nexport async function parseExcelAndImportTasks(buffer: Buffer, project: Project, context: ResolverContext) {\n // 1. 엑셀 파일을 읽어들입니다.\n const workbook = new ExcelJS.Workbook()\n await workbook.xlsx.load(buffer)\n\n // 2. 첫 번째 워크시트를 가져옵니다.\n const worksheet = workbook.getWorksheet(1) // Index or sheet name can be used\n\n // 3. 첫 번째 row를 header로 사용합니다.\n const headers: string[] = []\n let taskCodeColumnIndex = -1\n\n const headerRow = worksheet.getRow(1)\n headerRow.eachCell((cell, colNumber) => {\n const headerText = cell.text.toString()\n headers[colNumber - 1] = headerText // Store headers in an array\n\n if (headerText === '작업코드') {\n taskCodeColumnIndex = colNumber // Store the column index for \"작업코드\"\n }\n })\n\n if (taskCodeColumnIndex === -1) {\n throw new Error('작업코드 column not found')\n }\n\n // 4. 엑셀 데이터를 RawTask 형식으로 변환합니다.\n const tasks: RawTask[] = []\n\n // Start processing from the second row onward to skip the header\n for (let rowIndex = 2; rowIndex <= worksheet.rowCount; rowIndex++) {\n const row = worksheet.getRow(rowIndex)\n const taskData: any = {}\n\n row.eachCell((cell, colNumber) => {\n const header = headers[colNumber - 1]\n\n // Check if the cell has a formula(or sharedFormula) and use the formula result\n let cellValue: any = cell.value\n if (cellValue && typeof cellValue === 'object' && ('formula' in cellValue || 'sharedFormula' in cellValue)) {\n // Cell contains a formula, use the calculated result if available\n cellValue = cellValue.result ?? cellValue.value // Use the result, or fallback to value if result is not calculated\n }\n\n taskData[header] = cellValue\n })\n\n const taskCodeCell = row.getCell(taskCodeColumnIndex)\n let bgColor = '#FFFFFF'\n const fill = taskCodeCell.style.fill\n\n if (fill && fill.type === 'pattern' && fill.pattern === 'solid') {\n const fgColor = fill.fgColor\n if (fgColor && fgColor.argb) {\n // ARGB is a color in the format AARRGGBB, remove the alpha channel (first two characters)\n bgColor = `#${fgColor.argb.slice(2)}`\n }\n }\n\n const task: RawTask = {\n code: taskData['작업코드'],\n title: taskData['작업명'],\n type: taskData['세부공종'],\n duration: taskData['기간'],\n startDate: taskData['시작일'],\n dependsOn: taskData['선행작업코드'],\n progress: taskData['진척율'],\n tags: taskData['Tags'] ? taskData['Tags'].split(',') : [],\n resources: taskData['Resources'] ? JSON.parse(taskData['Resources']) : [],\n style: bgColor,\n children: []\n }\n\n if (task.code && task.type) {\n tasks.push(task)\n }\n }\n\n // 5. 변환된 데이터를 importTasks 함수로 전달합니다.\n await importTasks(project, tasks, context)\n}\n"]}
1
+ {"version":3,"file":"parse-excel.js","sourceRoot":"","sources":["../../server/controllers/parse-excel.ts"],"names":[],"mappings":";;AAKA,4DAgFC;;AArFD,8DAA6B;AAG7B,+CAA2C;AAEpC,KAAK,UAAU,wBAAwB,CAAC,MAAc,EAAE,OAAgB,EAAE,OAAwB;IACvG,oBAAoB;IACpB,MAAM,QAAQ,GAAG,IAAI,iBAAO,CAAC,QAAQ,EAAE,CAAA;IACvC,MAAM,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAa,CAAC,CAAA;IAEvC,uBAAuB;IACvB,MAAM,SAAS,GAAG,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA,CAAC,kCAAkC;IAE7E,8BAA8B;IAC9B,MAAM,OAAO,GAAa,EAAE,CAAA;IAC5B,IAAI,mBAAmB,GAAG,CAAC,CAAC,CAAA;IAE5B,MAAM,SAAS,GAAG,SAAS,CAAC,MA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,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClB,CAAC;IACH,CAAC;IAED,qCAAqC;IACrC,MAAM,IAAA,yBAAW,EAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA;AAC5C,CAAC","sourcesContent":["import ExcelJS from 'exceljs'\nimport { RawTask } from './types'\nimport { Project } from '../service/project/project'\nimport { importTasks } from './import-task'\n\nexport async function parseExcelAndImportTasks(buffer: Buffer, project: Project, context: ResolverContext) {\n // 1. 엑셀 파일을 읽어들입니다.\n const workbook = new ExcelJS.Workbook()\n await workbook.xlsx.load(buffer as any)\n\n // 2. 첫 번째 워크시트를 가져옵니다.\n const worksheet = workbook.getWorksheet(1) // Index or sheet name can be used\n\n // 3. 첫 번째 row를 header로 사용합니다.\n const headers: string[] = []\n let taskCodeColumnIndex = -1\n\n const headerRow = worksheet.getRow(1)\n headerRow.eachCell((cell, colNumber) => {\n const headerText = cell.text.toString()\n headers[colNumber - 1] = headerText // Store headers in an array\n\n if (headerText === '작업코드') {\n taskCodeColumnIndex = colNumber // Store the column index for \"작업코드\"\n }\n })\n\n if (taskCodeColumnIndex === -1) {\n throw new Error('작업코드 column not found')\n }\n\n // 4. 엑셀 데이터를 RawTask 형식으로 변환합니다.\n const tasks: RawTask[] = []\n\n // Start processing from the second row onward to skip the header\n for (let rowIndex = 2; rowIndex <= worksheet.rowCount; rowIndex++) {\n const row = worksheet.getRow(rowIndex)\n const taskData: any = {}\n\n row.eachCell((cell, colNumber) => {\n const header = headers[colNumber - 1]\n\n // Check if the cell has a formula(or sharedFormula) and use the formula result\n let cellValue: any = cell.value\n if (cellValue && typeof cellValue === 'object' && ('formula' in cellValue || 'sharedFormula' in cellValue)) {\n // Cell contains a formula, use the calculated result if available\n cellValue = cellValue.result ?? cellValue.value // Use the result, or fallback to value if result is not calculated\n }\n\n taskData[header] = cellValue\n })\n\n const taskCodeCell = row.getCell(taskCodeColumnIndex)\n let bgColor = '#FFFFFF'\n const fill = taskCodeCell.style.fill\n\n if (fill && fill.type === 'pattern' && fill.pattern === 'solid') {\n const fgColor = fill.fgColor\n if (fgColor && fgColor.argb) {\n // ARGB is a color in the format AARRGGBB, remove the alpha channel (first two characters)\n bgColor = `#${fgColor.argb.slice(2)}`\n }\n }\n\n const task: RawTask = {\n code: taskData['작업코드'],\n title: taskData['작업명'],\n type: taskData['세부공종'],\n duration: taskData['기간'],\n startDate: taskData['시작일'],\n dependsOn: taskData['선행작업코드'],\n progress: taskData['진척율'],\n tags: taskData['Tags'] ? taskData['Tags'].split(',') : [],\n resources: taskData['Resources'] ? JSON.parse(taskData['Resources']) : [],\n style: bgColor,\n children: []\n }\n\n if (task.code && task.type) {\n tasks.push(task)\n }\n }\n\n // 5. 변환된 데이터를 importTasks 함수로 전달합니다.\n await importTasks(project, tasks, context)\n}\n"]}
@@ -9,7 +9,7 @@ export * from './manager/manager';
9
9
  export * from './manager/manager-type';
10
10
  export * from './task/task';
11
11
  export * from './project/project';
12
- export declare const entities: (typeof import("./project/project").Project | typeof import("./task/task").Task | typeof import("./task-resource/task-resource").TaskResource | typeof import("./resource/resource").Resource | typeof import("./construction-type/construction-type").ConstructionType | typeof import("./construction-detail-type/construction-detail-type").ConstructionDetailType | typeof import("./inspection-part/inspection-part").InspectionPart | typeof import("./inspection-drawing-type/inspection-drawing-type").InspectionDrawingType | typeof import("./worker-type/worker-type").WorkerType | typeof import("./manager/manager").Manager)[];
12
+ export declare const entities: (typeof import("./project/project").Project | typeof import("./task/task").Task | typeof import("./task-resource/task-resource").TaskResource | typeof import("./resource/resource").Resource | typeof import("./construction-detail-type/construction-detail-type").ConstructionDetailType | typeof import("./construction-type/construction-type").ConstructionType | typeof import("./inspection-drawing-type/inspection-drawing-type").InspectionDrawingType | typeof import("./inspection-part/inspection-part").InspectionPart | typeof import("./worker-type/worker-type").WorkerType | typeof import("./manager/manager").Manager | typeof import("./task-checklist-binding/task-checklist-binding").TaskChecklistBinding)[];
13
13
  export declare const schema: {
14
- resolverClasses: (typeof import("./task-resource/task-resource-query").TaskResourceQuery | typeof import("./task-resource/task-resource-mutation").TaskResourceMutation | typeof import("./resource/resource-query").ResourceQuery | typeof import("./resource/resource-mutation").ResourceMutation | typeof import("./construction-detail-type/construction-detail-type-query").ConstructionDetailTypeQuery | typeof import("./construction-detail-type/construction-detail-type-mutation").ConstructionDetailTypeMutation | typeof import("./construction-type/construction-type-query").ConstructionTypeQuery | typeof import("./construction-type/construction-type-mutation").ConstructionTypeMutation | typeof import("./inspection-drawing-type/inspection-drawing-type-query").InspectionDrawingTypeQuery | typeof import("./inspection-drawing-type/inspection-drawing-type-mutation").InspectionDrawingTypeMutation | typeof import("./inspection-part/inspection-part-query").InspectionPartQuery | typeof import("./inspection-part/inspection-part-mutation").InspectionPartMutation | typeof import("./worker-type/worker-type-query").WorkerTypeQuery | typeof import("./worker-type/worker-type-mutation").WorkerTypeMutation | typeof import("./manager/manager-query").ManagerQuery | typeof import("./manager/manager-mutation").ManagerMutation | typeof import("./task/task-query").TaskQuery | typeof import("./task/task-mutation").TaskMutation | typeof import("./project/project-query").ProjectQuery | typeof import("./project/project-mutation").ProjectMutation)[];
14
+ resolverClasses: (typeof import("./project/project-query").ProjectQuery | typeof import("./project/project-mutation").ProjectMutation | typeof import("./task-resource/task-resource-query").TaskResourceQuery | typeof import("./task-resource/task-resource-mutation").TaskResourceMutation | typeof import("./resource/resource-query").ResourceQuery | typeof import("./resource/resource-mutation").ResourceMutation | typeof import("./construction-detail-type/construction-detail-type-query").ConstructionDetailTypeQuery | typeof import("./construction-detail-type/construction-detail-type-mutation").ConstructionDetailTypeMutation | typeof import("./construction-type/construction-type-query").ConstructionTypeQuery | typeof import("./construction-type/construction-type-mutation").ConstructionTypeMutation | typeof import("./inspection-drawing-type/inspection-drawing-type-query").InspectionDrawingTypeQuery | typeof import("./inspection-drawing-type/inspection-drawing-type-mutation").InspectionDrawingTypeMutation | typeof import("./inspection-part/inspection-part-query").InspectionPartQuery | typeof import("./inspection-part/inspection-part-mutation").InspectionPartMutation | typeof import("./worker-type/worker-type-query").WorkerTypeQuery | typeof import("./worker-type/worker-type-mutation").WorkerTypeMutation | typeof import("./manager/manager-query").ManagerQuery | typeof import("./manager/manager-mutation").ManagerMutation | typeof import("./task/task-query").TaskQuery | typeof import("./task/task-mutation").TaskMutation | typeof import("./task-checklist-binding/task-checklist-binding-query").TaskChecklistBindingQuery | typeof import("./task-checklist-binding/task-checklist-binding-mutation").TaskChecklistBindingMutation)[];
15
15
  };
@@ -25,6 +25,7 @@ const worker_type_1 = require("./worker-type");
25
25
  const manager_1 = require("./manager");
26
26
  const task_1 = require("./task");
27
27
  const project_1 = require("./project");
28
+ const task_checklist_binding_1 = require("./task-checklist-binding");
28
29
  exports.entities = [
29
30
  /* ENTITIES */
30
31
  ...task_resource_1.entities,
@@ -36,7 +37,8 @@ exports.entities = [
36
37
  ...worker_type_1.entities,
37
38
  ...manager_1.entities,
38
39
  ...task_1.entities,
39
- ...project_1.entities
40
+ ...project_1.entities,
41
+ ...task_checklist_binding_1.entities
40
42
  ];
41
43
  exports.schema = {
42
44
  resolverClasses: [
@@ -50,7 +52,8 @@ exports.schema = {
50
52
  ...worker_type_1.resolvers,
51
53
  ...manager_1.resolvers,
52
54
  ...task_1.resolvers,
53
- ...project_1.resolvers
55
+ ...project_1.resolvers,
56
+ ...task_checklist_binding_1.resolvers
54
57
  ]
55
58
  };
56
59
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,wEAA6C;AAC7C,8DAAmC;AACnC,8FAAmE;AACnE,gFAAqD;AACrD,4FAAiE;AACjE,4EAAiD;AACjD,oEAAyC;AACzC,4DAAiC;AACjC,iEAAsC;AACtC,sDAA2B;AAC3B,4DAAiC;AAEjC,mCAAmC;AACnC,mDAAsG;AACtG,yCAAyF;AACzF,yEAGmC;AACnC,2DAAkH;AAClH,uEAAkI;AAClI,uDAA4G;AAC5G,+CAAgG;AAChG,uCAAsF;AACtF,iCAA6E;AAC7E,uCAAsF;AAEzE,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,wBAAoB;IACvB,GAAG,mBAAgB;IACnB,GAAG,mCAA8B;IACjC,GAAG,4BAAwB;IAC3B,GAAG,kCAA6B;IAChC,GAAG,0BAAsB;IACzB,GAAG,sBAAkB;IACrB,GAAG,kBAAe;IAClB,GAAG,eAAY;IACf,GAAG,kBAAe;CACnB,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,yBAAqB;QACxB,GAAG,oBAAiB;QACpB,GAAG,oCAA+B;QAClC,GAAG,6BAAyB;QAC5B,GAAG,mCAA8B;QACjC,GAAG,2BAAuB;QAC1B,GAAG,uBAAmB;QACtB,GAAG,mBAAgB;QACnB,GAAG,gBAAa;QAChB,GAAG,mBAAgB;KACpB;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './task-resource/task-resource'\nexport * from './resource/resource'\nexport * from './construction-detail-type/construction-detail-type'\nexport * from './construction-type/construction-type'\nexport * from './inspection-drawing-type/inspection-drawing-type'\nexport * from './inspection-part/inspection-part'\nexport * from './worker-type/worker-type'\nexport * from './manager/manager'\nexport * from './manager/manager-type'\nexport * from './task/task'\nexport * from './project/project'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport { entities as TaskResourceEntities, resolvers as TaskResourceResolvers } from './task-resource'\nimport { entities as ResourceEntities, resolvers as ResourceResolvers } from './resource'\nimport {\n entities as ConstructionDetailTypeEntities,\n resolvers as ConstructionDetailTypeResolvers\n} from './construction-detail-type'\nimport { entities as ConstructionTypeEntities, resolvers as ConstructionTypeResolvers } from './construction-type'\nimport { entities as InspectionDrawingTypeEntities, resolvers as InspectionDrawingTypeResolvers } from './inspection-drawing-type'\nimport { entities as InspectionPartEntities, resolvers as InspectionPartResolvers } from './inspection-part'\nimport { entities as WorkerTypeEntities, resolvers as WorkerTypeResolvers } from './worker-type'\nimport { entities as ManagerEntities, resolvers as ManagerResolvers } from './manager'\nimport { entities as TaskEntities, resolvers as TaskResolvers } from './task'\nimport { entities as ProjectEntities, resolvers as ProjectResolvers } from './project'\n\nexport const entities = [\n /* ENTITIES */\n ...TaskResourceEntities,\n ...ResourceEntities,\n ...ConstructionDetailTypeEntities,\n ...ConstructionTypeEntities,\n ...InspectionDrawingTypeEntities,\n ...InspectionPartEntities,\n ...WorkerTypeEntities,\n ...ManagerEntities,\n ...TaskEntities,\n ...ProjectEntities\n]\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...TaskResourceResolvers,\n ...ResourceResolvers,\n ...ConstructionDetailTypeResolvers,\n ...ConstructionTypeResolvers,\n ...InspectionDrawingTypeResolvers,\n ...InspectionPartResolvers,\n ...WorkerTypeResolvers,\n ...ManagerResolvers,\n ...TaskResolvers,\n ...ProjectResolvers\n ]\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/service/index.ts"],"names":[],"mappings":";;;;AAAA,yBAAyB;AACzB,wEAA6C;AAC7C,8DAAmC;AACnC,8FAAmE;AACnE,gFAAqD;AACrD,4FAAiE;AACjE,4EAAiD;AACjD,oEAAyC;AACzC,4DAAiC;AACjC,iEAAsC;AACtC,sDAA2B;AAC3B,4DAAiC;AAEjC,mCAAmC;AACnC,mDAAsG;AACtG,yCAAyF;AACzF,yEAGmC;AACnC,2DAAkH;AAClH,uEAAkI;AAClI,uDAA4G;AAC5G,+CAAgG;AAChG,uCAAsF;AACtF,iCAA6E;AAC7E,uCAAsF;AACtF,qEAA+H;AAElH,QAAA,QAAQ,GAAG;IACtB,cAAc;IACd,GAAG,wBAAoB;IACvB,GAAG,mBAAgB;IACnB,GAAG,mCAA8B;IACjC,GAAG,4BAAwB;IAC3B,GAAG,kCAA6B;IAChC,GAAG,0BAAsB;IACzB,GAAG,sBAAkB;IACrB,GAAG,kBAAe;IAClB,GAAG,eAAY;IACf,GAAG,kBAAe;IAClB,GAAG,iCAA4B;CAChC,CAAA;AAEY,QAAA,MAAM,GAAG;IACpB,eAAe,EAAE;QACf,sBAAsB;QACtB,GAAG,yBAAqB;QACxB,GAAG,oBAAiB;QACpB,GAAG,oCAA+B;QAClC,GAAG,6BAAyB;QAC5B,GAAG,mCAA8B;QACjC,GAAG,2BAAuB;QAC1B,GAAG,uBAAmB;QACtB,GAAG,mBAAgB;QACnB,GAAG,gBAAa;QAChB,GAAG,mBAAgB;QACnB,GAAG,kCAA6B;KACjC;CACF,CAAA","sourcesContent":["/* EXPORT ENTITY TYPES */\nexport * from './task-resource/task-resource'\nexport * from './resource/resource'\nexport * from './construction-detail-type/construction-detail-type'\nexport * from './construction-type/construction-type'\nexport * from './inspection-drawing-type/inspection-drawing-type'\nexport * from './inspection-part/inspection-part'\nexport * from './worker-type/worker-type'\nexport * from './manager/manager'\nexport * from './manager/manager-type'\nexport * from './task/task'\nexport * from './project/project'\n\n/* IMPORT ENTITIES AND RESOLVERS */\nimport { entities as TaskResourceEntities, resolvers as TaskResourceResolvers } from './task-resource'\nimport { entities as ResourceEntities, resolvers as ResourceResolvers } from './resource'\nimport {\n entities as ConstructionDetailTypeEntities,\n resolvers as ConstructionDetailTypeResolvers\n} from './construction-detail-type'\nimport { entities as ConstructionTypeEntities, resolvers as ConstructionTypeResolvers } from './construction-type'\nimport { entities as InspectionDrawingTypeEntities, resolvers as InspectionDrawingTypeResolvers } from './inspection-drawing-type'\nimport { entities as InspectionPartEntities, resolvers as InspectionPartResolvers } from './inspection-part'\nimport { entities as WorkerTypeEntities, resolvers as WorkerTypeResolvers } from './worker-type'\nimport { entities as ManagerEntities, resolvers as ManagerResolvers } from './manager'\nimport { entities as TaskEntities, resolvers as TaskResolvers } from './task'\nimport { entities as ProjectEntities, resolvers as ProjectResolvers } from './project'\nimport { entities as TaskChecklistBindingEntities, resolvers as TaskChecklistBindingResolvers } from './task-checklist-binding'\n\nexport const entities = [\n /* ENTITIES */\n ...TaskResourceEntities,\n ...ResourceEntities,\n ...ConstructionDetailTypeEntities,\n ...ConstructionTypeEntities,\n ...InspectionDrawingTypeEntities,\n ...InspectionPartEntities,\n ...WorkerTypeEntities,\n ...ManagerEntities,\n ...TaskEntities,\n ...ProjectEntities,\n ...TaskChecklistBindingEntities\n]\n\nexport const schema = {\n resolverClasses: [\n /* RESOLVER CLASSES */\n ...TaskResourceResolvers,\n ...ResourceResolvers,\n ...ConstructionDetailTypeResolvers,\n ...ConstructionTypeResolvers,\n ...InspectionDrawingTypeResolvers,\n ...InspectionPartResolvers,\n ...WorkerTypeResolvers,\n ...ManagerResolvers,\n ...TaskResolvers,\n ...ProjectResolvers,\n ...TaskChecklistBindingResolvers\n ]\n}\n"]}
@@ -7,5 +7,6 @@ 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>;
10
11
  }
11
12
  export declare function createAttachmentAfterDelete(context: ResolverContext, file: any, refBy: any, refType: any): Promise<Attachment>;
@@ -12,6 +12,11 @@ const project_type_1 = require("./project-type");
12
12
  const building_complex_1 = require("@dssp/building-complex");
13
13
  const headless_pdf_to_image_1 = require("@things-factory/board-service/dist-server/controllers/headless-pdf-to-image");
14
14
  const parse_excel_1 = require("../../controllers/parse-excel");
15
+ const fs = tslib_1.__importStar(require("fs"));
16
+ const path = tslib_1.__importStar(require("path"));
17
+ const archiver_1 = tslib_1.__importDefault(require("archiver"));
18
+ const env_1 = require("@things-factory/env");
19
+ const projectType = env_1.config.get('projectType', project_1.ProjectType.DSSP);
15
20
  let ProjectMutation = class ProjectMutation {
16
21
  async createProject(project, context) {
17
22
  const { domain, user, tx } = context.state;
@@ -24,7 +29,9 @@ let ProjectMutation = class ProjectMutation {
24
29
  });
25
30
  const result = await projectRepo.save({
26
31
  name: project.name,
32
+ documentNaming: project.name,
27
33
  buildingComplex: newBuildingComplex,
34
+ projectType,
28
35
  domain,
29
36
  creator: user,
30
37
  updater: user
@@ -52,7 +59,8 @@ let ProjectMutation = class ProjectMutation {
52
59
  // 3. 동의 층 정보가 바뀌었으면 층 초기화 후 다시 생성
53
60
  const originBuilding = await buildingRepo.findBy({ buildingComplex: { id: buildingComplex.id } }); // 이전 동 정보 가져오기
54
61
  const afterBuilding = buildings.reduce((acc, building) => (Object.assign(Object.assign({}, acc), { [building.name]: building.floorCount })), {}); // 비교용으로 수정된 동 정보 데이터 파싱
55
- const isBuidlingChanged = originBuilding.some(building => afterBuilding[building.name] !== building.floorCount); // 개수가 달라진 동이 있는지 확인
62
+ const afterBasement = buildings.reduce((acc, building) => (Object.assign(Object.assign({}, acc), { [building.name]: building.basementFloorCount || 0 })), {}); // 비교용으로 수정된 지하 정보 데이터 파싱
63
+ const isBuidlingChanged = originBuilding.some(building => afterBuilding[building.name] !== building.floorCount || afterBasement[building.name] !== building.basementFloorCount); // 층 개수가 달라진 동이 있는지 확인
56
64
  // 동의 층 개수가 달라지면 모든 층의 데이터 제거 후 생성
57
65
  if (isBuidlingChanged || originBuilding.length !== buildings.length) {
58
66
  // 3-1. 기존 동/층 첨부파일 및 데이터 제거
@@ -69,23 +77,33 @@ let ProjectMutation = class ProjectMutation {
69
77
  buildingComplex: buildingComplex,
70
78
  name: building.name,
71
79
  floorCount: building.floorCount,
80
+ hasBasement: building.hasBasement,
81
+ basementFloorCount: building.hasBasement ? building.basementFloorCount : 0,
82
+ updater: user,
72
83
  creator: user
73
84
  });
74
85
  // 3-3. 동별로 for문 돌면서 층 데이터 개수대로 생성
75
86
  for (let i = 1; i <= building.floorCount; i++) {
76
87
  await buildingLevelRepo.save({ building: newBuilding, floor: i, creator: user });
77
88
  }
89
+ // 3-4. 지하층 층 데이터 생성
90
+ if (building.hasBasement) {
91
+ for (let i = 1; i <= building.basementFloorCount; i++) {
92
+ await buildingLevelRepo.save({ building: newBuilding, floor: -i, creator: user });
93
+ }
94
+ }
78
95
  }
79
96
  }
80
97
  return projectResult;
81
98
  }
82
99
  async updateProjectPlan(project, context) {
83
- var _a;
100
+ var _a, _b;
84
101
  const { user, tx, domain } = context.state;
85
102
  const projectRepo = (0, shell_1.getRepository)(project_1.Project, tx);
86
103
  const buildingComplexRepo = (0, shell_1.getRepository)(building_complex_1.BuildingComplex, tx);
87
104
  const buildingRepo = (0, shell_1.getRepository)(building_complex_1.Building, tx);
88
105
  const buildingLevelRepo = (0, shell_1.getRepository)(building_complex_1.BuildingLevel, tx);
106
+ const attachmentRepo = (0, shell_1.getRepository)(attachment_base_1.Attachment, tx);
89
107
  const buildingComplex = project.buildingComplex;
90
108
  const buildings = ((_a = project.buildingComplex) === null || _a === void 0 ? void 0 : _a.buildings) || [];
91
109
  // 1. 프로젝트 수정 시간 업데이트
@@ -126,7 +144,22 @@ let ProjectMutation = class ProjectMutation {
126
144
  const pngThumbnailFile = await (0, headless_pdf_to_image_1.pdfToImage)({ pdfPath, fileName, defaultViewport: { width: 300, height: 200 } });
127
145
  await createAttachmentAfterDelete(context, pngThumbnailFile, buildingLevel.id, building_complex_1.BuildingLevel.name + '_rebarDistributionDrawing_thumbnail');
128
146
  }
129
- // 3-3. 업데이트 시간 갱신
147
+ // 3-3. 기타 도면 파일 저장
148
+ const etcDrawingRefType = building_complex_1.BuildingLevel.name + '_etcDrawings';
149
+ // 기존 첨부 파일 중 제거된 것들 삭제
150
+ const etcDrawings = await attachmentRepo.find({ where: { refType: etcDrawingRefType, refBy: buildingLevel.id } });
151
+ for (let etcDrawing of etcDrawings) {
152
+ if (!buildingLevel.etcDrawingIds.includes(etcDrawing.id)) {
153
+ await (0, attachment_base_1.deleteAttachment)(null, { id: etcDrawing.id }, context);
154
+ }
155
+ }
156
+ // 업로드
157
+ if (((_b = buildingLevel.etcDrawingsUpload) === null || _b === void 0 ? void 0 : _b.length) > 0) {
158
+ for (let etcDrawing of buildingLevel.etcDrawingsUpload) {
159
+ await (0, attachment_base_1.createAttachment)(null, { attachment: { file: etcDrawing, refType: etcDrawingRefType, refBy: buildingLevel.id } }, context);
160
+ }
161
+ }
162
+ // 3-4. 층 업데이트 시간 갱신
130
163
  await buildingLevelRepo.save(Object.assign(Object.assign({}, buildingLevel), { updater: user }));
131
164
  }
132
165
  // 4. 동별 도면 이미지 저장
@@ -173,6 +206,67 @@ let ProjectMutation = class ProjectMutation {
173
206
  await (0, attachment_base_1.deleteAttachmentsByRef)(null, { refBys: [id] }, context);
174
207
  return true;
175
208
  }
209
+ async downloadPlanFiles(fileIds, context) {
210
+ const { domain, tx } = context.state;
211
+ if (!fileIds || fileIds.length === 0) {
212
+ throw new Error('다운로드할 파일을 선택해주세요.');
213
+ }
214
+ // 첨부파일 정보 조회
215
+ const attachments = await tx.getRepository(attachment_base_1.Attachment).find({
216
+ where: { domain: { id: domain.id }, id: (0, typeorm_1.In)(fileIds) }
217
+ });
218
+ if (attachments.length === 0) {
219
+ throw new Error('선택된 파일을 찾을 수 없습니다.');
220
+ }
221
+ // ZIP 파일 생성 - 동과 층 정보를 포함한 파일명
222
+ const zipFileName = `download.zip`;
223
+ const tempDir = path.join(process.cwd(), 'temp');
224
+ const zipFilePath = path.join(tempDir, zipFileName);
225
+ // temp 디렉토리 생성
226
+ if (!fs.existsSync(tempDir)) {
227
+ fs.mkdirSync(tempDir, { recursive: true });
228
+ }
229
+ const output = fs.createWriteStream(zipFilePath);
230
+ const archive = (0, archiver_1.default)('zip', {
231
+ zlib: { level: 9 } // 최대 압축
232
+ });
233
+ return new Promise(async (resolve, reject) => {
234
+ output.on('close', () => {
235
+ // ZIP 파일을 Base64로 인코딩하여 반환
236
+ const zipBuffer = fs.readFileSync(zipFilePath);
237
+ const base64Data = zipBuffer.toString('base64');
238
+ const dataUrl = `data:application/zip;base64,${base64Data}`;
239
+ // 임시 파일 삭제
240
+ fs.unlinkSync(zipFilePath);
241
+ resolve(dataUrl);
242
+ });
243
+ archive.on('error', err => {
244
+ reject(err);
245
+ });
246
+ archive.pipe(output);
247
+ try {
248
+ // 각 첨부파일을 ZIP에 추가
249
+ for (const attachment of attachments) {
250
+ try {
251
+ const fileUrl = `http://localhost:3000${attachment.fullpath}`;
252
+ const response = await fetch(fileUrl);
253
+ if (response.ok) {
254
+ const buffer = await response.arrayBuffer();
255
+ const fileName = attachment.name || path.basename(attachment.fullpath);
256
+ archive.append(Buffer.from(buffer), { name: fileName });
257
+ }
258
+ }
259
+ catch (error) {
260
+ console.error('Error processing attachment:', attachment.fullpath, error);
261
+ }
262
+ }
263
+ archive.finalize();
264
+ }
265
+ catch (error) {
266
+ reject(error);
267
+ }
268
+ });
269
+ }
176
270
  };
177
271
  exports.ProjectMutation = ProjectMutation;
178
272
  tslib_1.__decorate([
@@ -186,7 +280,7 @@ tslib_1.__decorate([
186
280
  ], ProjectMutation.prototype, "createProject", null);
187
281
  tslib_1.__decorate([
188
282
  (0, type_graphql_1.Directive)('@transaction'),
189
- (0, type_graphql_1.Mutation)(returns => project_1.Project, { description: '프로젝트 업데이트' }),
283
+ (0, type_graphql_1.Mutation)(returns => project_1.Project, { description: '프로젝트 업데이트 (중복 사용 금지)' }),
190
284
  tslib_1.__param(0, (0, type_graphql_1.Arg)('project')),
191
285
  tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
192
286
  tslib_1.__metadata("design:type", Function),
@@ -220,6 +314,15 @@ tslib_1.__decorate([
220
314
  tslib_1.__metadata("design:paramtypes", [String, Object]),
221
315
  tslib_1.__metadata("design:returntype", Promise)
222
316
  ], ProjectMutation.prototype, "deleteProject", null);
317
+ tslib_1.__decorate([
318
+ (0, type_graphql_1.Directive)('@transaction'),
319
+ (0, type_graphql_1.Mutation)(returns => String, { description: '선택된 도면 파일들을 ZIP으로 압축하여 다운로드 URL 반환' }),
320
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('fileIds', type => [String])),
321
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
322
+ tslib_1.__metadata("design:type", Function),
323
+ tslib_1.__metadata("design:paramtypes", [Array, Object]),
324
+ tslib_1.__metadata("design:returntype", Promise)
325
+ ], ProjectMutation.prototype, "downloadPlanFiles", null);
223
326
  exports.ProjectMutation = ProjectMutation = tslib_1.__decorate([
224
327
  (0, type_graphql_1.Resolver)(project_1.Project)
225
328
  ], ProjectMutation);
@@ -1 +1 @@
1
- {"version":3,"file":"project-mutation.js","sourceRoot":"","sources":["../../../server/service/project/project-mutation.ts"],"names":[],"mappings":";;;AAiPA,kEAaC;;AA9PD,+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,OAA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AAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,mBAAmB,EAAE,CAAC;IAC9C,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;IAAc,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;oDAOhD;0BAnOU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,eAAe,CAoO3B;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 { 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":";;;AA6WA,kEAaC;;AA1XD,+CAAsE;AACtE,qCAA4B;AAC5B,iDAAqD;AACrD,qEAMwC;AACxC,uCAA8D;AAC9D,iDAAgH;AAChH,6DAAiF;AACjF,uHAAwG;AACxG,+DAAwE;AACxE,+CAAwB;AACxB,mDAA4B;AAC5B,gEAA+B;AAC/B,6CAA4C;AAE5C,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,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IK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,WAAW,EAAE,oCAAoC,EAAE,CAAC;IAC1D,mBAAA,IAAA,kBAAG,EAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAAqB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;wDAqElF;0BAnVU,eAAe;IAD3B,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,eAAe,CAoV3B;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 { 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, ProjectState, ProjectType } from './project'\nimport { NewProject, ProjectCompleteStep1Patch, 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'\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 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 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 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 { 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 @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 { domain, 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: { domain: { id: domain.id }, 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\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"]}
@@ -9,12 +9,15 @@ export declare class ProjectQuery {
9
9
  project(id: string, context: ResolverContext): Promise<Project>;
10
10
  projects(params: ListParam, context: ResolverContext): Promise<ProjectList>;
11
11
  projectByBuildingComplexId(buildingComplexId: string, context: ResolverContext): Promise<Project>;
12
+ projectByBuildingLevelId(buildingLevelId: string, context: ResolverContext): Promise<Project>;
12
13
  rootTasks(project: Project): Promise<Task[]>;
13
14
  mainPhoto(project: Project): Promise<string | Attachment>;
14
15
  scheduleTable(project: Project): Promise<Attachment | undefined>;
16
+ completeReport(project: Project): Promise<Attachment | undefined>;
15
17
  buildingComplex(project: Project): Promise<BuildingComplex>;
16
18
  domain(project: Project): Promise<Domain>;
17
19
  updater(project: Project): Promise<User>;
18
20
  creator(project: Project): Promise<User>;
19
21
  projectType(project: Project): Promise<string>;
22
+ kpi(project: Project): Promise<number>;
20
23
  }
@@ -12,6 +12,8 @@ const project_type_1 = require("./project-type");
12
12
  const attachment_base_1 = require("@things-factory/attachment-base");
13
13
  const building_complex_1 = require("@dssp/building-complex");
14
14
  const env_1 = require("@things-factory/env");
15
+ const kpi_1 = require("@things-factory/kpi");
16
+ const projectType = env_1.config.get('projectType', project_1.ProjectType.DSSP);
15
17
  let ProjectQuery = class ProjectQuery {
16
18
  async project(id, context) {
17
19
  const { domain } = context.state;
@@ -25,8 +27,12 @@ let ProjectQuery = class ProjectQuery {
25
27
  domain,
26
28
  params,
27
29
  repository: (0, shell_1.getRepository)(project_1.Project),
30
+ alias: 'p',
28
31
  searchables: ['name', 'description', 'state']
29
32
  });
33
+ if (projectType !== project_1.ProjectType.DKPI) {
34
+ queryBuilder.andWhere('p.building_complex_id IS NOT NULL');
35
+ }
30
36
  const [items, total] = await queryBuilder.getManyAndCount();
31
37
  return { items, total };
32
38
  }
@@ -36,6 +42,16 @@ let ProjectQuery = class ProjectQuery {
36
42
  where: { domain: { id: domain.id }, buildingComplex: { id: buildingComplexId } }
37
43
  });
38
44
  }
45
+ async projectByBuildingLevelId(buildingLevelId, context) {
46
+ const queryBuilder = (0, shell_1.getRepository)(project_1.Project)
47
+ .createQueryBuilder('p')
48
+ .innerJoin('building_complexes', 'bc', 'p.building_complex_id = bc.id')
49
+ .innerJoin('buildings', 'b', 'b.building_complex_id = bc.id')
50
+ .innerJoin('building_levels', 'bl', 'bl.building_id = b.id')
51
+ .where('bl.id = :buildingLevelId', { buildingLevelId });
52
+ const result = await queryBuilder.getOne();
53
+ return result;
54
+ }
39
55
  async rootTasks(project) {
40
56
  return await (0, shell_1.getRepository)(task_1.Task).find({
41
57
  where: {
@@ -64,6 +80,15 @@ let ProjectQuery = class ProjectQuery {
64
80
  });
65
81
  return attachment;
66
82
  }
83
+ async completeReport(project) {
84
+ if (!project.completeReportId) {
85
+ return undefined;
86
+ }
87
+ const attachment = await (0, shell_1.getRepository)(attachment_base_1.Attachment).findOne({
88
+ where: { id: project.completeReportId }
89
+ });
90
+ return attachment;
91
+ }
67
92
  async buildingComplex(project) {
68
93
  return await (0, shell_1.getRepository)(building_complex_1.BuildingComplex).findOneBy({ id: project.buildingComplexId });
69
94
  }
@@ -79,6 +104,11 @@ let ProjectQuery = class ProjectQuery {
79
104
  async projectType(project) {
80
105
  return env_1.config.get('projectType', project_1.ProjectType.DSSP);
81
106
  }
107
+ async kpi(project) {
108
+ const kpi = await (0, shell_1.getRepository)(kpi_1.Kpi).findOneBy({ domain: { id: project.domainId }, name: 'Z. 전체스코어' });
109
+ const kpiValue = await (0, shell_1.getRepository)(kpi_1.KpiValue).findOneBy({ group: project.id, kpi: { id: kpi.id } });
110
+ return kpiValue ? (kpiValue.value || 0) * 20 : project.kpi;
111
+ }
82
112
  };
83
113
  exports.ProjectQuery = ProjectQuery;
84
114
  tslib_1.__decorate([
@@ -105,6 +135,14 @@ tslib_1.__decorate([
105
135
  tslib_1.__metadata("design:paramtypes", [String, Object]),
106
136
  tslib_1.__metadata("design:returntype", Promise)
107
137
  ], ProjectQuery.prototype, "projectByBuildingComplexId", null);
138
+ tslib_1.__decorate([
139
+ (0, type_graphql_1.Query)(returns => project_1.Project, { description: 'To fetch Project' }),
140
+ tslib_1.__param(0, (0, type_graphql_1.Arg)('buildingLevelId')),
141
+ tslib_1.__param(1, (0, type_graphql_1.Ctx)()),
142
+ tslib_1.__metadata("design:type", Function),
143
+ tslib_1.__metadata("design:paramtypes", [String, Object]),
144
+ tslib_1.__metadata("design:returntype", Promise)
145
+ ], ProjectQuery.prototype, "projectByBuildingLevelId", null);
108
146
  tslib_1.__decorate([
109
147
  (0, type_graphql_1.FieldResolver)(type => [task_1.Task], { nullable: true }),
110
148
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -126,6 +164,13 @@ tslib_1.__decorate([
126
164
  tslib_1.__metadata("design:paramtypes", [project_1.Project]),
127
165
  tslib_1.__metadata("design:returntype", Promise)
128
166
  ], ProjectQuery.prototype, "scheduleTable", null);
167
+ tslib_1.__decorate([
168
+ (0, type_graphql_1.FieldResolver)(type => attachment_base_1.Attachment),
169
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
170
+ tslib_1.__metadata("design:type", Function),
171
+ tslib_1.__metadata("design:paramtypes", [project_1.Project]),
172
+ tslib_1.__metadata("design:returntype", Promise)
173
+ ], ProjectQuery.prototype, "completeReport", null);
129
174
  tslib_1.__decorate([
130
175
  (0, type_graphql_1.FieldResolver)(type => building_complex_1.BuildingComplex),
131
176
  tslib_1.__param(0, (0, type_graphql_1.Root)()),
@@ -161,6 +206,13 @@ tslib_1.__decorate([
161
206
  tslib_1.__metadata("design:paramtypes", [project_1.Project]),
162
207
  tslib_1.__metadata("design:returntype", Promise)
163
208
  ], ProjectQuery.prototype, "projectType", null);
209
+ tslib_1.__decorate([
210
+ (0, type_graphql_1.FieldResolver)(type => Number),
211
+ tslib_1.__param(0, (0, type_graphql_1.Root)()),
212
+ tslib_1.__metadata("design:type", Function),
213
+ tslib_1.__metadata("design:paramtypes", [project_1.Project]),
214
+ tslib_1.__metadata("design:returntype", Promise)
215
+ ], ProjectQuery.prototype, "kpi", null);
164
216
  exports.ProjectQuery = ProjectQuery = tslib_1.__decorate([
165
217
  (0, type_graphql_1.Resolver)(project_1.Project)
166
218
  ], ProjectQuery);
@@ -1 +1 @@
1
- {"version":3,"file":"project-query.js","sourceRoot":"","sources":["../../../server/service/project/project-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AACnF,qCAAgC;AAChC,iDAAuG;AACvG,yDAAgD;AAChD,uCAAgD;AAChD,uCAAmC;AACnC,iDAA4C;AAC5C,qEAA4D;AAC5D,6DAAwD;AACxD,6CAA4C;AAGrC,IAAM,YAAY,GAAlB,MAAM,YAAY;IAEjB,AAAN,KAAK,CAAC,OAAO,CAAY,EAAU,EAAS,OAAwB;QAClE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,OAAO,MAAM,IAAA,qBAAa,EAAC,iBAAO,CAAC,CAAC,OAAO,CAAC;YAC1C,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE;SACzC,CAAC,CAAA;IACJ,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ,CAAS,MAAiB,EAAS,OAAwB;QACvE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAEhC,MAAM,YAAY,GAAG,IAAA,qCAA6B,EAAC;YACjD,MAAM;YACN,MAAM;YACN,UAAU,EAAE,IAAA,qBAAa,EAAC,iBAAO,CAAC;YAClC,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,OAAO,CAAC;SAC9C,CAAC,CAAA;QAEF,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM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Aa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACX,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;+CAEzC;uBAjGU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CAkGxB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Arg, Args, Ctx } from 'type-graphql'\nimport { IsNull } from 'typeorm'\nimport { Domain, getRepository, ListParam, getQueryBuilderFromListParams } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Project, ProjectType } from './project'\nimport { Task } from '../task/task'\nimport { ProjectList } from './project-type'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { BuildingComplex } from '@dssp/building-complex'\nimport { config } from '@things-factory/env'\n\n@Resolver(Project)\nexport class ProjectQuery {\n @Query(returns => Project!, { nullable: true, description: 'To fetch a Project' })\n async project(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Project> {\n const { domain } = context.state\n\n return await getRepository(Project).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => ProjectList, { description: '프로젝트 리스트' })\n async projects(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ProjectList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(Project),\n searchables: ['name', 'description', 'state']\n })\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => Project!, { nullable: true, description: 'To fetch a Project' })\n async projectByBuildingComplexId(\n @Arg('buildingComplexId') buildingComplexId: string,\n @Ctx() context: ResolverContext\n ): Promise<Project> {\n const { domain } = context.state\n\n return await getRepository(Project).findOne({\n where: { domain: { id: domain.id }, buildingComplex: { id: buildingComplexId } }\n })\n }\n\n @FieldResolver(type => [Task], { nullable: true })\n async rootTasks(@Root() project: Project): Promise<Task[]> {\n return await getRepository(Task).find({\n where: {\n project: { id: project.id },\n parent: IsNull()\n }\n })\n }\n\n @FieldResolver(type => Attachment)\n async mainPhoto(@Root() project: Project): Promise<string | Attachment> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: project.domainId },\n refBy: project.id\n },\n order: { createdAt: 'ASC' }\n })\n\n return attachment\n }\n\n @FieldResolver(type => Attachment)\n async scheduleTable(@Root() project: Project): Promise<Attachment | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: project.domainId },\n refBy: project.id,\n refType: Project.name + '_schedule_table'\n }\n })\n\n return attachment\n }\n\n @FieldResolver(type => BuildingComplex)\n async buildingComplex(@Root() project: Project): Promise<BuildingComplex> {\n return await getRepository(BuildingComplex).findOneBy({ id: project.buildingComplexId })\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() project: Project): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: project.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() project: Project): Promise<User> {\n return await getRepository(User).findOneBy({ id: project.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() project: Project): Promise<User> {\n return await getRepository(User).findOneBy({ id: project.creatorId })\n }\n\n @FieldResolver(type => String)\n async projectType(@Root() project: Project): Promise<string> {\n return config.get('projectType', ProjectType.DSSP)\n }\n}\n"]}
1
+ {"version":3,"file":"project-query.js","sourceRoot":"","sources":["../../../server/service/project/project-query.ts"],"names":[],"mappings":";;;;AAAA,+CAAmF;AACnF,qCAAgC;AAChC,iDAAuG;AACvG,yDAAgD;AAChD,uCAAgD;AAChD,uCAAmC;AACnC,iDAA4C;AAC5C,qE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L,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,kCAAe,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;mDAE7C;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,cAAM,CAAC;IAChB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;0CAEpC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,gBAAI,CAAC;IACb,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;2CAErC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACX,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;+CAEzC;AAGK;IADL,IAAA,4BAAa,EAAC,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC;IACnB,mBAAA,IAAA,mBAAI,GAAE,CAAA;;6CAAU,iBAAO;;uCAKjC;uBA5IU,YAAY;IADxB,IAAA,uBAAQ,EAAC,iBAAO,CAAC;GACL,YAAY,CA6IxB","sourcesContent":["import { Resolver, Query, FieldResolver, Root, Arg, Args, Ctx } from 'type-graphql'\nimport { IsNull } from 'typeorm'\nimport { Domain, getRepository, ListParam, getQueryBuilderFromListParams } from '@things-factory/shell'\nimport { User } from '@things-factory/auth-base'\nimport { Project, ProjectType } from './project'\nimport { Task } from '../task/task'\nimport { ProjectList } from './project-type'\nimport { Attachment } from '@things-factory/attachment-base'\nimport { BuildingComplex } from '@dssp/building-complex'\nimport { config } from '@things-factory/env'\nimport { Kpi, KpiValue } from '@things-factory/kpi'\nconst projectType = config.get('projectType', ProjectType.DSSP)\n\n@Resolver(Project)\nexport class ProjectQuery {\n @Query(returns => Project!, { nullable: true, description: 'To fetch a Project' })\n async project(@Arg('id') id: string, @Ctx() context: ResolverContext): Promise<Project> {\n const { domain } = context.state\n\n return await getRepository(Project).findOne({\n where: { domain: { id: domain.id }, id }\n })\n }\n\n @Query(returns => ProjectList, { description: '프로젝트 리스트' })\n async projects(@Args() params: ListParam, @Ctx() context: ResolverContext): Promise<ProjectList> {\n const { domain } = context.state\n\n const queryBuilder = getQueryBuilderFromListParams({\n domain,\n params,\n repository: getRepository(Project),\n alias: 'p',\n searchables: ['name', 'description', 'state']\n })\n\n if (projectType !== ProjectType.DKPI) {\n queryBuilder.andWhere('p.building_complex_id IS NOT NULL')\n }\n\n const [items, total] = await queryBuilder.getManyAndCount()\n\n return { items, total }\n }\n\n @Query(returns => Project!, { nullable: true, description: 'To fetch a Project' })\n async projectByBuildingComplexId(\n @Arg('buildingComplexId') buildingComplexId: string,\n @Ctx() context: ResolverContext\n ): Promise<Project> {\n const { domain } = context.state\n\n return await getRepository(Project).findOne({\n where: { domain: { id: domain.id }, buildingComplex: { id: buildingComplexId } }\n })\n }\n\n @Query(returns => Project!, { description: 'To fetch Project' })\n async projectByBuildingLevelId(\n @Arg('buildingLevelId') buildingLevelId: string,\n @Ctx() context: ResolverContext\n ): Promise<Project> {\n const queryBuilder = getRepository(Project)\n .createQueryBuilder('p')\n .innerJoin('building_complexes', 'bc', 'p.building_complex_id = bc.id')\n .innerJoin('buildings', 'b', 'b.building_complex_id = bc.id')\n .innerJoin('building_levels', 'bl', 'bl.building_id = b.id')\n .where('bl.id = :buildingLevelId', { buildingLevelId })\n\n const result = await queryBuilder.getOne()\n\n return result\n }\n\n @FieldResolver(type => [Task], { nullable: true })\n async rootTasks(@Root() project: Project): Promise<Task[]> {\n return await getRepository<Task>(Task).find({\n where: {\n project: { id: project.id },\n parent: IsNull()\n }\n })\n }\n\n @FieldResolver(type => Attachment)\n async mainPhoto(@Root() project: Project): Promise<string | Attachment> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: project.domainId },\n refBy: project.id\n },\n order: { createdAt: 'ASC' }\n })\n\n return attachment\n }\n\n @FieldResolver(type => Attachment)\n async scheduleTable(@Root() project: Project): Promise<Attachment | undefined> {\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: {\n domain: { id: project.domainId },\n refBy: project.id,\n refType: Project.name + '_schedule_table'\n }\n })\n\n return attachment\n }\n\n @FieldResolver(type => Attachment)\n async completeReport(@Root() project: Project): Promise<Attachment | undefined> {\n if (!project.completeReportId) {\n return undefined\n }\n\n const attachment: Attachment = await getRepository(Attachment).findOne({\n where: { id: project.completeReportId }\n })\n\n return attachment\n }\n\n @FieldResolver(type => BuildingComplex)\n async buildingComplex(@Root() project: Project): Promise<BuildingComplex> {\n return await getRepository(BuildingComplex).findOneBy({ id: project.buildingComplexId })\n }\n\n @FieldResolver(type => Domain)\n async domain(@Root() project: Project): Promise<Domain> {\n return await getRepository(Domain).findOneBy({ id: project.domainId })\n }\n\n @FieldResolver(type => User)\n async updater(@Root() project: Project): Promise<User> {\n return await getRepository(User).findOneBy({ id: project.updaterId })\n }\n\n @FieldResolver(type => User)\n async creator(@Root() project: Project): Promise<User> {\n return await getRepository(User).findOneBy({ id: project.creatorId })\n }\n\n @FieldResolver(type => String)\n async projectType(@Root() project: Project): Promise<string> {\n return config.get('projectType', ProjectType.DSSP)\n }\n\n @FieldResolver(type => Number)\n async kpi(@Root() project: Project): Promise<number> {\n const kpi = await getRepository(Kpi).findOneBy({ domain: { id: project.domainId }, name: 'Z. 전체스코어' })\n const kpiValue = await getRepository(KpiValue).findOneBy({ group: project.id, kpi: { id: kpi.id } })\n\n return kpiValue ? (kpiValue.value || 0) * 20 : project.kpi\n }\n}\n"]}
@@ -9,6 +9,7 @@ export declare class NewProject {
9
9
  export declare class ProjectPatch {
10
10
  id: string;
11
11
  name: string;
12
+ documentNaming?: string;
12
13
  startDate?: string;
13
14
  endDate?: string;
14
15
  mainPhotoUpload?: FileUpload;
@@ -18,6 +19,11 @@ export declare class ProjectPatch {
18
19
  inspPassRate?: number;
19
20
  robotProgressRate?: number;
20
21
  structuralSafetyRate?: number;
22
+ robotCount?: number;
23
+ buildingComplex?: BuildingComplexPatch;
24
+ }
25
+ export declare class ProjectCompleteStep1Patch {
26
+ id: string;
21
27
  buildingComplex?: BuildingComplexPatch;
22
28
  }
23
29
  export declare class UploadProjectScheduleTable {