@dssp/supervision 0.0.25 → 0.0.26

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.
@@ -69,7 +69,9 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
69
69
  const checklistItemRepo = tx.getRepository(checklist_item_1.ChecklistItem);
70
70
  const oldBuildingInspection = await buildingInspectionRepo.findOneBy({ id: buildingInspectionId });
71
71
  const status = oldBuildingInspection.status;
72
- const isConstructor = status == building_inspection_2.BuildingInspectionStatus.WAIT || status == building_inspection_2.BuildingInspectionStatus.FAIL;
72
+ const isConstructor = status == building_inspection_2.BuildingInspectionStatus.WAIT ||
73
+ status == building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT ||
74
+ status == building_inspection_2.BuildingInspectionStatus.FAIL;
73
75
  let inspectionStatus = null;
74
76
  // 1. 벨리데이션
75
77
  if (!buildingInspectionId)
@@ -83,15 +85,27 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
83
85
  if (checklistItem.length !== checklistItem.filter(v => v.constructionConfirmStatus).length) {
84
86
  throw new Error('아이템을 모두 체크해야 합니다.');
85
87
  }
86
- if (!checklist.overallConstructorSignature)
88
+ if (status == building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT && !checklist.overallConstructorSignature) {
87
89
  throw new Error('총괄 시공책임자 사인이 없습니다.');
88
- if (!checklist.taskConstructorSignature)
89
- throw new Error('공종별 시공관리자 사인이 없습니다.');
90
+ }
91
+ if (status == building_inspection_2.BuildingInspectionStatus.WAIT && !checklist.taskConstructorSignature) {
92
+ throw new Error('공종별 시공관리자 사인이 없습니다.');
93
+ }
90
94
  // 시공자 상태 데이터
91
95
  const isPassed = checklistItem.length === checklistItem.filter(v => v.constructionConfirmStatus === 'T').length;
92
- inspectionStatus = isPassed ? building_inspection_2.BuildingInspectionStatus.REQUEST : building_inspection_2.BuildingInspectionStatus.FAIL;
93
- // 시공자가 검측 요청시 검측자 사인은 초기화
94
- if (inspectionStatus === building_inspection_2.BuildingInspectionStatus.REQUEST) {
96
+ if (!isPassed) {
97
+ // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화
98
+ inspectionStatus = building_inspection_2.BuildingInspectionStatus.FAIL;
99
+ checklist.overallConstructorSignature = null;
100
+ checklist.taskConstructorSignature = null;
101
+ }
102
+ else if (isPassed && (status === building_inspection_2.BuildingInspectionStatus.WAIT || status === building_inspection_2.BuildingInspectionStatus.FAIL)) {
103
+ // 2. 검측이 합격이면서 공종 시공자 스탭 = 상태는 총괄 시공자 스탭으로
104
+ inspectionStatus = building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT;
105
+ }
106
+ else if (isPassed && status === building_inspection_2.BuildingInspectionStatus.OVERALL_WAIT) {
107
+ // 3. 검측이 합격이면서 총괄 시공자 스탭 = 상태는 공종 감리자 스탭으로, 감리자 싸인은 모두 초기화
108
+ inspectionStatus = building_inspection_2.BuildingInspectionStatus.REQUEST;
95
109
  checklist.overallSupervisorySignature = null;
96
110
  checklist.taskSupervisorySignature = null;
97
111
  }
@@ -101,18 +115,28 @@ let BuildingInspectionMutation = class BuildingInspectionMutation {
101
115
  if (checklistItem.length !== checklistItem.filter(v => v.supervisoryConfirmStatus).length) {
102
116
  throw new Error('아이템을 모두 체크해야 합니다.');
103
117
  }
104
- if (!checklist.overallSupervisorySignature)
118
+ if (status == building_inspection_2.BuildingInspectionStatus.OVERALL_REQUEST && !checklist.overallSupervisorySignature) {
105
119
  throw new Error('총괄 감리책임자 사인이 없습니다.');
106
- if (!checklist.taskSupervisorySignature)
120
+ }
121
+ if (status == building_inspection_2.BuildingInspectionStatus.REQUEST && !checklist.taskSupervisorySignature) {
107
122
  throw new Error('공종별 감리 책임자 사인이 없습니다.');
123
+ }
108
124
  // 감리자 상태 데이터
109
125
  const isPassed = checklistItem.length === checklistItem.filter(v => v.supervisoryConfirmStatus === 'T').length;
110
- inspectionStatus = isPassed ? building_inspection_2.BuildingInspectionStatus.PASS : building_inspection_2.BuildingInspectionStatus.FAIL;
111
- // 감리사가 검측 불합격으로 재검측 요청시 시공자 사인은 초기화
112
- if (inspectionStatus === building_inspection_2.BuildingInspectionStatus.FAIL) {
126
+ if (!isPassed) {
127
+ // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화
128
+ inspectionStatus = building_inspection_2.BuildingInspectionStatus.FAIL;
113
129
  checklist.overallConstructorSignature = null;
114
130
  checklist.taskConstructorSignature = null;
115
131
  }
132
+ else if (isPassed && status === building_inspection_2.BuildingInspectionStatus.REQUEST) {
133
+ // 2. 검측이 합격이면서 공종 감리자 스탭 = 상태는 총괄 감리자 스탭으로
134
+ inspectionStatus = building_inspection_2.BuildingInspectionStatus.OVERALL_REQUEST;
135
+ }
136
+ else if (isPassed && status === building_inspection_2.BuildingInspectionStatus.OVERALL_REQUEST) {
137
+ // 3. 검측이 합격이면서 총괄 감리자 스탭 = 상태는 합격으로
138
+ inspectionStatus = building_inspection_2.BuildingInspectionStatus.PASS;
139
+ }
116
140
  }
117
141
  // 2. buildingInspection 저장
118
142
  await buildingInspectionRepo.save(Object.assign(Object.assign({}, oldBuildingInspection), { status: inspectionStatus, updater: user }));
@@ -1 +1 @@
1
- {"version":3,"file":"building-inspection-mutation.js","sourceRoot":"","sources":["../../../server/service/building-inspection/building-inspection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,+DAA0D;AAC1D,yEAImC;AACnC,+DAAgE;AAChE,sDAAkD;AAClD,qEAAgE;AAChE,iDAAqD;AACrD,6DAAsD;AAG/C,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAG/B,AAAN,KAAK,CAAC,wBAAwB,CACd,KAA4B,EACnC,OAAwB;QAE/B,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;QAClC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,aAAa,EAAE,GAAG,KAAK,CAAA;QA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DAAyD,EAAE,CAAC;IAEtG,mBAAA,IAAA,kBAAG,EAAC,oBAAoB,CAAC,CAAA;IACzB,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADyC,6DAAkC;;mFAkFlF;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,wCAAkB,EAAE,EAAE,WAAW,EAAE,2CAA2C,EAAE,CAAC;IAEnG,mBAAA,IAAA,kBAAG,EAAC,OAAO,CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADe,gEAAqC;;0EAiB3D;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAE5E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EA2BP;AAtMU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CA8NtC;AA9NY,gEAA0B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { BuildingInspection } from './building-inspection'\nimport {\n NewBuildingInspection,\n UpdateBuildingInspectionDrawingMarker,\n UpdateBuildingInspectionSubmitType\n} from './building-inspection-type'\nimport { BuildingInspectionStatus } from './building-inspection'\nimport { Checklist } from '../checklist/checklist'\nimport { ChecklistItem } from '../checklist-item/checklist-item'\nimport { getRepository } from '@things-factory/shell'\nimport { BuildingLevel } from '@dssp/building-complex'\n\n@Resolver(BuildingInspection)\nexport class BuildingInspectionMutation {\n @Directive('@transaction')\n @Mutation(returns => BuildingInspection, { description: 'To create Building Inspection information' })\n async createBuildingInspection(\n @Arg('patch') patch: NewBuildingInspection,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspection> {\n const { user, tx } = context.state\n const { buildingLevelId, checklist, checklistItem } = patch\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n const checklistRepository = tx.getRepository(Checklist)\n const checklistItemRepository = tx.getRepository(ChecklistItem)\n\n // 1. 벨리데이션\n if (!buildingLevelId) throw new Error('층 아이디가 없습니다.')\n if (!checklist.name) throw new Error('체크리스트 이름이 없습니다.')\n if (!checklist.constructionType) throw new Error('공종 타입이 없습니다.')\n if (!checklist.constructionDetailType) throw new Error('상세 공종 타입이 없습니다.')\n if (!checklist.location) throw new Error('위치가 없습니다.')\n if (!checklist.inspectionDrawingType) throw new Error('검측 도면 타입이 없습니다.')\n if (checklist.inspectionParts.length === 0) throw new Error('검측 부위가 없습니다.')\n if (checklistItem.length === 0) throw new Error('체크리스트 아이템이 없습니다.')\n\n // 2. checklist 저장\n const documentNo = await this.getRecentDocumentNoByBuildingLevelId(buildingLevelId)\n const savedChecklist = await checklistRepository.save({\n ...checklist,\n documentNo,\n creator: user,\n updater: user\n })\n\n // 3. checklistItem 저장\n const checklistItems = checklistItem.map((item, idx) => ({\n name: item.name,\n mainType: item.mainType,\n detailType: item.detailType,\n inspctionCriteria: item.inspctionCriteria,\n sequence: idx,\n checklist: savedChecklist,\n creator: user,\n updater: user\n }))\n await checklistItemRepository.save(checklistItems)\n\n // 4. buildingInspection 저장\n const result = await buildingInspectionRepository.save({\n status: BuildingInspectionStatus.WAIT,\n buildingLevel: { id: buildingLevelId },\n checklist: savedChecklist,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n // 검측 상태 변경 & 체크리스트 갱신\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To create Building Inspection And Checklist information' })\n async updateBuildingInspectionChecklist(\n @Arg('buildingInspection') buildingInspection: UpdateBuildingInspectionSubmitType,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { user, tx } = context.state\n const { id: buildingInspectionId, checklist, checklistItem } = buildingInspection\n const buildingInspectionRepo = tx.getRepository(BuildingInspection)\n const checklistRepo = tx.getRepository(Checklist)\n const checklistItemRepo = tx.getRepository(ChecklistItem)\n const oldBuildingInspection = await buildingInspectionRepo.findOneBy({ id: buildingInspectionId })\n const status = oldBuildingInspection.status\n const isConstructor: boolean = status == BuildingInspectionStatus.WAIT || status == BuildingInspectionStatus.FAIL\n let inspectionStatus = null\n\n // 1. 벨리데이션\n if (!buildingInspectionId) throw new Error('검측 아이디가 없습니다.')\n if (!status) throw new Error('검측 상태가 없습니다.')\n if (status == BuildingInspectionStatus.PASS) throw new Error('검측 상태가 수정할 수 있는 상태가 아닙니다.')\n\n if (isConstructor) {\n // 시공자 타입별 밸리데이션\n if (checklistItem.length !== checklistItem.filter(v => v.constructionConfirmStatus).length) {\n throw new Error('아이템을 모두 체크해야 합니다.')\n }\n if (!checklist.overallConstructorSignature) throw new Error('총괄 시공책임자 사인이 없습니다.')\n if (!checklist.taskConstructorSignature) throw new Error('공종별 시공관리자\t사인이 없습니다.')\n\n // 시공자 상태 데이터\n const isPassed = checklistItem.length === checklistItem.filter(v => v.constructionConfirmStatus === 'T').length\n inspectionStatus = isPassed ? BuildingInspectionStatus.REQUEST : BuildingInspectionStatus.FAIL\n // 시공자가 검측 요청시 검측자 사인은 초기화\n if (inspectionStatus === BuildingInspectionStatus.REQUEST) {\n checklist.overallSupervisorySignature = null\n checklist.taskSupervisorySignature = null\n }\n } else {\n // 감리자 타입별 밸리데이션\n if (checklistItem.length !== checklistItem.filter(v => v.supervisoryConfirmStatus).length) {\n throw new Error('아이템을 모두 체크해야 합니다.')\n }\n if (!checklist.overallSupervisorySignature) throw new Error('총괄 감리책임자 사인이 없습니다.')\n if (!checklist.taskSupervisorySignature) throw new Error('공종별 감리 책임자 사인이 없습니다.')\n\n // 감리자 상태 데이터\n const isPassed = checklistItem.length === checklistItem.filter(v => v.supervisoryConfirmStatus === 'T').length\n inspectionStatus = isPassed ? BuildingInspectionStatus.PASS : BuildingInspectionStatus.FAIL\n // 감리사가 검측 불합격으로 재검측 요청시 시공자 사인은 초기화\n if (inspectionStatus === BuildingInspectionStatus.FAIL) {\n checklist.overallConstructorSignature = null\n checklist.taskConstructorSignature = null\n }\n }\n\n // 2. buildingInspection 저장\n await buildingInspectionRepo.save({\n ...oldBuildingInspection,\n status: inspectionStatus,\n updater: user\n })\n\n // 3. checklist 저장\n const oldChecklist = await checklistRepo.findOneBy({ id: checklist.id })\n const inspectionDateField = isConstructor ? 'constructionInspectionDate' : 'supervisorInspectionDate'\n await checklistRepo.save({\n ...oldChecklist,\n [inspectionDateField]: new Date(),\n overallConstructorSignature: checklist.overallConstructorSignature,\n taskConstructorSignature: checklist.taskConstructorSignature,\n overallSupervisorySignature: checklist.overallSupervisorySignature,\n taskSupervisorySignature: checklist.taskSupervisorySignature,\n updater: user\n })\n\n // 4. checklistItem 저장\n for (let item of checklistItem) {\n const confirmStatusField = isConstructor ? 'constructionConfirmStatus' : 'supervisoryConfirmStatus'\n await checklistItemRepo.update(item.id, {\n [confirmStatusField]: item[confirmStatusField],\n updater: user\n })\n }\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => BuildingInspection, { description: 'To update Building Inspection information' })\n async updateBuildingInspection(\n @Arg('patch') patch: UpdateBuildingInspectionDrawingMarker,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspection> {\n const { user, tx } = context.state\n const buildingInspectionRepo = tx.getRepository(BuildingInspection)\n\n // 벨리데이션\n if (!patch.id) throw new Error('검측 아이디가 없습니다.')\n\n const buildingInspection = await buildingInspectionRepo.findOneBy({ id: patch.id })\n const result = await buildingInspectionRepo.save({\n ...buildingInspection,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple Checklists' })\n async deleteBuildingInspections(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx } = context.state\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n const checklistRepository = tx.getRepository(Checklist)\n const checklistItemRepository = tx.getRepository(ChecklistItem)\n\n // 검측 데이터 제거\n const buildingInspections = await buildingInspectionRepository.createQueryBuilder('bi').whereInIds(ids).getMany()\n await buildingInspectionRepository.softDelete({\n id: In(ids)\n })\n\n // 검측 데이터의 체크 리스트 제거\n const checklistIds = buildingInspections.map(bi => bi.checklistId)\n await checklistRepository.softDelete({\n id: In(checklistIds)\n })\n\n // 검측 데이터의 체크 리스트 아이템 제거\n await checklistItemRepository\n .createQueryBuilder()\n .softDelete()\n .where('checklist_id IN (:...checklistIds)', { checklistIds })\n .execute()\n\n return true\n }\n\n async getRecentDocumentNoByBuildingLevelId(buildingLevelId: string): Promise<string> {\n const buildingLevel = await getRepository(BuildingLevel).findOne({\n where: { id: buildingLevelId },\n relations: ['building']\n })\n\n const buildingName = buildingLevel.building.name.match(/\\d+/g).join('').padStart(4, '0')\n const floorName = buildingLevel.floor.toString().padStart(3, '0')\n const latestChecklist = await getRepository(Checklist)\n .createQueryBuilder('c')\n .where('c.document_no LIKE :pattern', { pattern: `${buildingName}-${floorName}-%` })\n .orderBy('c.created_at', 'DESC')\n .getOne()\n\n let documentNo = '000001'\n if (latestChecklist) {\n const lastNo = latestChecklist.documentNo.split('-')[2]\n documentNo = (Number(lastNo) + 1).toString().padStart(6, '0')\n }\n\n return `${buildingName}-${floorName}-${documentNo}`\n }\n}\n"]}
1
+ {"version":3,"file":"building-inspection-mutation.js","sourceRoot":"","sources":["../../../server/service/building-inspection/building-inspection-mutation.ts"],"names":[],"mappings":";;;;AAAA,+CAAsE;AACtE,qCAA4B;AAC5B,+DAA0D;AAC1D,yEAImC;AACnC,+DAAgE;AAChE,sDAAkD;AAClD,qEAAgE;AAChE,iDAAqD;AACrD,6DAAsD;AAG/C,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IAG/B,AAAN,KAAK,CAAC,wBAAwB,CACd,KAA4B,EACnC,OA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CAAC,CAAA;IACZ,mBAAA,IAAA,kBAAG,GAAE,CAAA;;6CADe,gEAAqC;;0EAiB3D;AAIK;IAFL,IAAA,wBAAS,EAAC,cAAc,CAAC;IACzB,IAAA,uBAAQ,EAAC,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,+BAA+B,EAAE,CAAC;IAE5E,mBAAA,IAAA,kBAAG,EAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;IAC5B,mBAAA,IAAA,kBAAG,GAAE,CAAA;;;;2EA2BP;AAhOU,0BAA0B;IADtC,IAAA,uBAAQ,EAAC,wCAAkB,CAAC;GAChB,0BAA0B,CAwPtC;AAxPY,gEAA0B","sourcesContent":["import { Resolver, Mutation, Arg, Ctx, Directive } from 'type-graphql'\nimport { In } from 'typeorm'\nimport { BuildingInspection } from './building-inspection'\nimport {\n NewBuildingInspection,\n UpdateBuildingInspectionDrawingMarker,\n UpdateBuildingInspectionSubmitType\n} from './building-inspection-type'\nimport { BuildingInspectionStatus } from './building-inspection'\nimport { Checklist } from '../checklist/checklist'\nimport { ChecklistItem } from '../checklist-item/checklist-item'\nimport { getRepository } from '@things-factory/shell'\nimport { BuildingLevel } from '@dssp/building-complex'\n\n@Resolver(BuildingInspection)\nexport class BuildingInspectionMutation {\n @Directive('@transaction')\n @Mutation(returns => BuildingInspection, { description: 'To create Building Inspection information' })\n async createBuildingInspection(\n @Arg('patch') patch: NewBuildingInspection,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspection> {\n const { user, tx } = context.state\n const { buildingLevelId, checklist, checklistItem } = patch\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n const checklistRepository = tx.getRepository(Checklist)\n const checklistItemRepository = tx.getRepository(ChecklistItem)\n\n // 1. 벨리데이션\n if (!buildingLevelId) throw new Error('층 아이디가 없습니다.')\n if (!checklist.name) throw new Error('체크리스트 이름이 없습니다.')\n if (!checklist.constructionType) throw new Error('공종 타입이 없습니다.')\n if (!checklist.constructionDetailType) throw new Error('상세 공종 타입이 없습니다.')\n if (!checklist.location) throw new Error('위치가 없습니다.')\n if (!checklist.inspectionDrawingType) throw new Error('검측 도면 타입이 없습니다.')\n if (checklist.inspectionParts.length === 0) throw new Error('검측 부위가 없습니다.')\n if (checklistItem.length === 0) throw new Error('체크리스트 아이템이 없습니다.')\n\n // 2. checklist 저장\n const documentNo = await this.getRecentDocumentNoByBuildingLevelId(buildingLevelId)\n const savedChecklist = await checklistRepository.save({\n ...checklist,\n documentNo,\n creator: user,\n updater: user\n })\n\n // 3. checklistItem 저장\n const checklistItems = checklistItem.map((item, idx) => ({\n name: item.name,\n mainType: item.mainType,\n detailType: item.detailType,\n inspctionCriteria: item.inspctionCriteria,\n sequence: idx,\n checklist: savedChecklist,\n creator: user,\n updater: user\n }))\n await checklistItemRepository.save(checklistItems)\n\n // 4. buildingInspection 저장\n const result = await buildingInspectionRepository.save({\n status: BuildingInspectionStatus.WAIT,\n buildingLevel: { id: buildingLevelId },\n checklist: savedChecklist,\n creator: user,\n updater: user\n })\n\n return result\n }\n\n // 검측 상태 변경 & 체크리스트 갱신\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To create Building Inspection And Checklist information' })\n async updateBuildingInspectionChecklist(\n @Arg('buildingInspection') buildingInspection: UpdateBuildingInspectionSubmitType,\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { user, tx } = context.state\n const { id: buildingInspectionId, checklist, checklistItem } = buildingInspection\n const buildingInspectionRepo = tx.getRepository(BuildingInspection)\n const checklistRepo = tx.getRepository(Checklist)\n const checklistItemRepo = tx.getRepository(ChecklistItem)\n const oldBuildingInspection = await buildingInspectionRepo.findOneBy({ id: buildingInspectionId })\n const status = oldBuildingInspection.status\n const isConstructor: boolean =\n status == BuildingInspectionStatus.WAIT ||\n status == BuildingInspectionStatus.OVERALL_WAIT ||\n status == BuildingInspectionStatus.FAIL\n let inspectionStatus = null\n\n // 1. 벨리데이션\n if (!buildingInspectionId) throw new Error('검측 아이디가 없습니다.')\n if (!status) throw new Error('검측 상태가 없습니다.')\n if (status == BuildingInspectionStatus.PASS) throw new Error('검측 상태가 수정할 수 있는 상태가 아닙니다.')\n\n if (isConstructor) {\n // 시공자 타입별 밸리데이션\n if (checklistItem.length !== checklistItem.filter(v => v.constructionConfirmStatus).length) {\n throw new Error('아이템을 모두 체크해야 합니다.')\n }\n if (status == BuildingInspectionStatus.OVERALL_WAIT && !checklist.overallConstructorSignature) {\n throw new Error('총괄 시공책임자 사인이 없습니다.')\n }\n if (status == BuildingInspectionStatus.WAIT && !checklist.taskConstructorSignature) {\n throw new Error('공종별 시공관리자 사인이 없습니다.')\n }\n\n // 시공자 상태 데이터\n const isPassed = checklistItem.length === checklistItem.filter(v => v.constructionConfirmStatus === 'T').length\n\n if (!isPassed) {\n // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화\n inspectionStatus = BuildingInspectionStatus.FAIL\n checklist.overallConstructorSignature = null\n checklist.taskConstructorSignature = null\n } else if (isPassed && (status === BuildingInspectionStatus.WAIT || status === BuildingInspectionStatus.FAIL)) {\n // 2. 검측이 합격이면서 공종 시공자 스탭 = 상태는 총괄 시공자 스탭으로\n inspectionStatus = BuildingInspectionStatus.OVERALL_WAIT\n } else if (isPassed && status === BuildingInspectionStatus.OVERALL_WAIT) {\n // 3. 검측이 합격이면서 총괄 시공자 스탭 = 상태는 공종 감리자 스탭으로, 감리자 싸인은 모두 초기화\n inspectionStatus = BuildingInspectionStatus.REQUEST\n checklist.overallSupervisorySignature = null\n checklist.taskSupervisorySignature = null\n }\n } else {\n // 감리자 타입별 밸리데이션\n if (checklistItem.length !== checklistItem.filter(v => v.supervisoryConfirmStatus).length) {\n throw new Error('아이템을 모두 체크해야 합니다.')\n }\n if (status == BuildingInspectionStatus.OVERALL_REQUEST && !checklist.overallSupervisorySignature) {\n throw new Error('총괄 감리책임자 사인이 없습니다.')\n }\n if (status == BuildingInspectionStatus.REQUEST && !checklist.taskSupervisorySignature) {\n throw new Error('공종별 감리 책임자 사인이 없습니다.')\n }\n\n // 감리자 상태 데이터\n const isPassed = checklistItem.length === checklistItem.filter(v => v.supervisoryConfirmStatus === 'T').length\n if (!isPassed) {\n // 1. 검측이 불햡격 = 상태는 불합격으로, 시공자 싸인은 모두 초기화\n inspectionStatus = BuildingInspectionStatus.FAIL\n checklist.overallConstructorSignature = null\n checklist.taskConstructorSignature = null\n } else if (isPassed && status === BuildingInspectionStatus.REQUEST) {\n // 2. 검측이 합격이면서 공종 감리자 스탭 = 상태는 총괄 감리자 스탭으로\n inspectionStatus = BuildingInspectionStatus.OVERALL_REQUEST\n } else if (isPassed && status === BuildingInspectionStatus.OVERALL_REQUEST) {\n // 3. 검측이 합격이면서 총괄 감리자 스탭 = 상태는 합격으로\n inspectionStatus = BuildingInspectionStatus.PASS\n }\n }\n\n // 2. buildingInspection 저장\n await buildingInspectionRepo.save({\n ...oldBuildingInspection,\n status: inspectionStatus,\n updater: user\n })\n\n // 3. checklist 저장\n const oldChecklist = await checklistRepo.findOneBy({ id: checklist.id })\n const inspectionDateField = isConstructor ? 'constructionInspectionDate' : 'supervisorInspectionDate'\n await checklistRepo.save({\n ...oldChecklist,\n [inspectionDateField]: new Date(),\n overallConstructorSignature: checklist.overallConstructorSignature,\n taskConstructorSignature: checklist.taskConstructorSignature,\n overallSupervisorySignature: checklist.overallSupervisorySignature,\n taskSupervisorySignature: checklist.taskSupervisorySignature,\n updater: user\n })\n\n // 4. checklistItem 저장\n for (let item of checklistItem) {\n const confirmStatusField = isConstructor ? 'constructionConfirmStatus' : 'supervisoryConfirmStatus'\n await checklistItemRepo.update(item.id, {\n [confirmStatusField]: item[confirmStatusField],\n updater: user\n })\n }\n\n return true\n }\n\n @Directive('@transaction')\n @Mutation(returns => BuildingInspection, { description: 'To update Building Inspection information' })\n async updateBuildingInspection(\n @Arg('patch') patch: UpdateBuildingInspectionDrawingMarker,\n @Ctx() context: ResolverContext\n ): Promise<BuildingInspection> {\n const { user, tx } = context.state\n const buildingInspectionRepo = tx.getRepository(BuildingInspection)\n\n // 벨리데이션\n if (!patch.id) throw new Error('검측 아이디가 없습니다.')\n\n const buildingInspection = await buildingInspectionRepo.findOneBy({ id: patch.id })\n const result = await buildingInspectionRepo.save({\n ...buildingInspection,\n ...patch,\n updater: user\n })\n\n return result\n }\n\n @Directive('@transaction')\n @Mutation(returns => Boolean, { description: 'To delete multiple Checklists' })\n async deleteBuildingInspections(\n @Arg('ids', type => [String]) ids: string[],\n @Ctx() context: ResolverContext\n ): Promise<boolean> {\n const { tx } = context.state\n const buildingInspectionRepository = tx.getRepository(BuildingInspection)\n const checklistRepository = tx.getRepository(Checklist)\n const checklistItemRepository = tx.getRepository(ChecklistItem)\n\n // 검측 데이터 제거\n const buildingInspections = await buildingInspectionRepository.createQueryBuilder('bi').whereInIds(ids).getMany()\n await buildingInspectionRepository.softDelete({\n id: In(ids)\n })\n\n // 검측 데이터의 체크 리스트 제거\n const checklistIds = buildingInspections.map(bi => bi.checklistId)\n await checklistRepository.softDelete({\n id: In(checklistIds)\n })\n\n // 검측 데이터의 체크 리스트 아이템 제거\n await checklistItemRepository\n .createQueryBuilder()\n .softDelete()\n .where('checklist_id IN (:...checklistIds)', { checklistIds })\n .execute()\n\n return true\n }\n\n async getRecentDocumentNoByBuildingLevelId(buildingLevelId: string): Promise<string> {\n const buildingLevel = await getRepository(BuildingLevel).findOne({\n where: { id: buildingLevelId },\n relations: ['building']\n })\n\n const buildingName = buildingLevel.building.name.match(/\\d+/g).join('').padStart(4, '0')\n const floorName = buildingLevel.floor.toString().padStart(3, '0')\n const latestChecklist = await getRepository(Checklist)\n .createQueryBuilder('c')\n .where('c.document_no LIKE :pattern', { pattern: `${buildingName}-${floorName}-%` })\n .orderBy('c.created_at', 'DESC')\n .getOne()\n\n let documentNo = '000001'\n if (latestChecklist) {\n const lastNo = latestChecklist.documentNo.split('-')[2]\n documentNo = (Number(lastNo) + 1).toString().padStart(6, '0')\n }\n\n return `${buildingName}-${floorName}-${documentNo}`\n }\n}\n"]}
@@ -8,7 +8,7 @@ export * from './checklist-item/checklist-item';
8
8
  export * from './checklist-template/checklist-template';
9
9
  export * from './checklist-template-item/checklist-template-item';
10
10
  export * from './building-inspection/building-inspection';
11
- export declare const entities: (typeof import("./issue/issue").Issue | typeof import("./action-plan/action-plan").ActionPlan | typeof import("./supervisor/supervisor").Supervisor | typeof import("./project-report/project-report").ProjectReport | typeof import("./checklist-type/checklist-type").ChecklistType | typeof import("./checklist-item/checklist-item").ChecklistItem | typeof import("./checklist/checklist").Checklist | typeof import("./building-inspection/building-inspection").BuildingInspection | typeof import("./checklist-template-item/checklist-template-item").ChecklistTemplateItem | typeof import("./checklist-template/checklist-template").ChecklistTemplate | typeof import("./checklist/checklist-history").ChecklistHistory | typeof import("./building-inspection/building-inspection-history").BuildingInspectionHistory)[];
11
+ export declare const entities: (typeof import("./supervisor/supervisor").Supervisor | typeof import("./project-report/project-report").ProjectReport | typeof import("./checklist-item/checklist-item").ChecklistItem | typeof import("./checklist/checklist").Checklist | typeof import("./building-inspection/building-inspection").BuildingInspection | typeof import("./checklist/checklist-history").ChecklistHistory | typeof import("./building-inspection/building-inspection-history").BuildingInspectionHistory | typeof import("./action-plan/action-plan").ActionPlan | typeof import("./issue/issue").Issue | typeof import("./checklist-type/checklist-type").ChecklistType | typeof import("./checklist-template-item/checklist-template-item").ChecklistTemplateItem | typeof import("./checklist-template/checklist-template").ChecklistTemplate)[];
12
12
  export declare const subscribers: any[];
13
13
  export declare const schema: {
14
14
  resolverClasses: typeof import("./checklist-item/checklist-item-mutation").ChecklistItemMutation[];