@dssp/supervision 1.0.19 → 1.0.20

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.
@@ -77,6 +77,8 @@ export declare class BuildingInspectionAiMeasurement extends PageView {
77
77
  item_id: any;
78
78
  category: string;
79
79
  text: any;
80
+ criteria_kcs: string;
81
+ criteria_site: any;
80
82
  }[];
81
83
  get uploadedSets(): SetInfo[];
82
84
  render(): import("lit-html").TemplateResult<1>;
@@ -99,6 +101,8 @@ export declare class BuildingInspectionAiMeasurement extends PageView {
99
101
  private _callMeasure;
100
102
  private _fetchMeasureImage;
101
103
  private _loadShotGuide;
104
+ private _shotItemsMap;
105
+ private _itemsAwaitingShot;
102
106
  private _shotTag;
103
107
  private _shotTechnique;
104
108
  private _shotAppLink;
@@ -37,6 +37,21 @@ const SET_FILES = ['video.mov', 'poses.jsonl', 'meta.json'];
37
37
  function appCaptureLink(tech) {
38
38
  return `gamri://${tech}?server=${encodeURIComponent(MEASURE_BASE_URL)}`;
39
39
  }
40
+ /* KCS 기준은 매칭 결과 JSON(kcs_matches[0])으로 저장돼 있다 → 엔진에 보낼 조문 텍스트로 편다.
41
+ 문서/조항 라벨을 앞에 붙여야 모델이 어느 기준을 인용하는지 reason 에 쓸 수 있다. */
42
+ function _kcsCriteriaText(raw) {
43
+ if (!raw)
44
+ return '';
45
+ try {
46
+ const kcs = JSON.parse(raw);
47
+ const label = [kcs.file_label, kcs.clause_no, kcs.clause_title].filter(Boolean).join(' ');
48
+ const body = (kcs.matched_item || kcs.text || '').trim();
49
+ return body ? `${label}\n${body}`.trim() : label;
50
+ }
51
+ catch (_a) {
52
+ return raw.trim(); // 구형 데이터(문자열 그대로 저장된 경우)
53
+ }
54
+ }
40
55
  /* set_id(YYYYmmdd-HHMMSS_xxxxxx) → "9/11 14:30" 표기 */
41
56
  function _setTimeLabel(setId) {
42
57
  const m = /^(\d{4})(\d{2})(\d{2})-(\d{2})(\d{2})/.exec(setId || '');
@@ -158,7 +173,11 @@ let BuildingInspectionAiMeasurement = class BuildingInspectionAiMeasurement exte
158
173
  .map(item => ({
159
174
  item_id: item.id,
160
175
  category: [item.mainType, item.detailType].filter(Boolean).join(' · '),
161
- text: item.name || ''
176
+ text: item.name || '',
177
+ // 검사 기준은 조문 '번호'가 아니라 본문을 보내야 판정 근거가 실제 기준에 붙는다.
178
+ // (조문 번호만 주면 모델이 그 내용을 모르는 상태로 판단한다 — 엔진 안내)
179
+ criteria_kcs: _kcsCriteriaText(item.kcsCriteria),
180
+ criteria_site: (item.siteSpecCriteria || '').trim()
162
181
  }));
163
182
  }
164
183
  get uploadedSets() {
@@ -747,6 +766,8 @@ let BuildingInspectionAiMeasurement = class BuildingInspectionAiMeasurement exte
747
766
  mainType
748
767
  detailType
749
768
  name
769
+ kcsCriteria
770
+ siteSpecCriteria
750
771
  }
751
772
  }
752
773
  buildingLevel {
@@ -833,7 +854,7 @@ let BuildingInspectionAiMeasurement = class BuildingInspectionAiMeasurement exte
833
854
  }
834
855
  /* [1단계] 촬영 가이드 생성 (plan-shots) */
835
856
  async _loadShotGuide() {
836
- var _a;
857
+ var _a, _b;
837
858
  const checklist = this.engineChecklist;
838
859
  if (!checklist.length) {
839
860
  notify({ message: '체크리스트 항목이 없습니다.', level: 'warn' });
@@ -844,6 +865,14 @@ let BuildingInspectionAiMeasurement = class BuildingInspectionAiMeasurement exte
844
865
  this.loadingText = 'AI 촬영 가이드 생성 중...';
845
866
  this.guide = await this._callEngine({ action: 'plan-shots', checklist });
846
867
  this.sets = new Array((((_a = this.guide) === null || _a === void 0 ? void 0 : _a.shots) || []).length).fill(null);
868
+ // 어느 촬영에도 배정되지 않은 항목이 있으면 그 항목은 판정 근거가 없다 → 재생성 권고
869
+ const unassigned = ((_b = this.guide) === null || _b === void 0 ? void 0 : _b.unassigned_items) || [];
870
+ if (unassigned.length) {
871
+ notify({
872
+ message: `촬영에 배정되지 않은 검사항목이 ${unassigned.length}건 있습니다. 촬영 가이드를 다시 생성해보세요.`,
873
+ level: 'warn'
874
+ });
875
+ }
847
876
  // 자동 등록 기준 시각 — 이 시점 이후 올라온 세트만 자동으로 붙인다.
848
877
  // (예전 테스트 세트가 태그만 같다고 채워지면 "찍지도 않았는데 완료"로 보인다)
849
878
  this.autoAttachSince = Date.now() / 1000;
@@ -856,6 +885,33 @@ let BuildingInspectionAiMeasurement = class BuildingInspectionAiMeasurement exte
856
885
  this.loading = false;
857
886
  }
858
887
  }
888
+ /* plan-shots가 준 촬영별 항목 배정 → {촬영번호: [항목ID]} (엔진 inspect 의 shot_items).
889
+ 배정 정보가 없는 구버전 응답이면 null 을 돌려 종전대로(전 항목이 전 사진) 동작시킨다. */
890
+ _shotItemsMap() {
891
+ var _a, _b, _c;
892
+ const shots = ((_a = this.guide) === null || _a === void 0 ? void 0 : _a.shots) || [];
893
+ const map = {};
894
+ for (let i = 0; i < shots.length; i++) {
895
+ const items = (_b = shots[i]) === null || _b === void 0 ? void 0 : _b.items;
896
+ if (!Array.isArray(items) || !items.length)
897
+ continue;
898
+ map[String(((_c = shots[i]) === null || _c === void 0 ? void 0 : _c.shot_no) || i + 1)] = items;
899
+ }
900
+ return Object.keys(map).length ? map : null;
901
+ }
902
+ /* 세트가 아직 안 올라온 촬영에 배정된 항목 ID 집합 (그 항목은 판정할 사진이 없다) */
903
+ _itemsAwaitingShot() {
904
+ var _a, _b;
905
+ const pending = new Set();
906
+ const shots = ((_a = this.guide) === null || _a === void 0 ? void 0 : _a.shots) || [];
907
+ for (let i = 0; i < shots.length; i++) {
908
+ if (this.sets[i])
909
+ continue;
910
+ for (const id of ((_b = shots[i]) === null || _b === void 0 ? void 0 : _b.items) || [])
911
+ pending.add(id);
912
+ }
913
+ return pending;
914
+ }
859
915
  /* 촬영 칸마다 고유 태그 — 앱에 부재 ID로 넘겨 두면, 올라온 세트의 member_id로
860
916
  "어느 촬영 칸의 것인지" 되찾을 수 있다 (앱↔플랫폼 왕복에 식별자가 없어서 쓰는 방법) */
861
917
  _shotTag(shotNo) {
@@ -1044,11 +1100,13 @@ let BuildingInspectionAiMeasurement = class BuildingInspectionAiMeasurement exte
1044
1100
  * - 최초 판정: 업로드된 모든 세트의 대표 3프레임 + 전체 체크리스트 (input_kind=video_frames)
1045
1101
  * - 재검사(재촬영 패널): 새 세트의 3프레임만 + 해당 항목만 재판정 후 결과 병합 */
1046
1102
  async _runInspection() {
1103
+ var _a, _b, _c;
1047
1104
  const isRecapture = this.panel === 'recapture' && !!this.selectedItem;
1048
1105
  try {
1049
1106
  this.loading = true;
1050
1107
  this.loadingText = '동영상 프레임 추출 중...';
1051
1108
  let newPhotos = [];
1109
+ const imageShots = []; // 사진마다 어느 촬영(shot_no)의 것인지
1052
1110
  if (isRecapture) {
1053
1111
  if (!this.recaptureSet) {
1054
1112
  notify({ message: '재촬영 세트를 먼저 업로드해주세요.', level: 'warn' });
@@ -1058,21 +1116,50 @@ let BuildingInspectionAiMeasurement = class BuildingInspectionAiMeasurement exte
1058
1116
  newPhotos = await this._fetchVlmFrames(this.recaptureSet, this.sets.length);
1059
1117
  }
1060
1118
  else {
1061
- const sets = this.uploadedSets;
1062
- if (!sets.length) {
1119
+ if (!this.uploadedSets.length) {
1063
1120
  notify({ message: '업로드된 촬영 세트가 없습니다.', level: 'warn' });
1064
1121
  return;
1065
1122
  }
1066
- for (let i = 0; i < sets.length; i++) {
1067
- newPhotos = [...newPhotos, ...(await this._fetchVlmFrames(sets[i], i))];
1123
+ // 촬영 칸 순서대로 — 비어 있는 칸은 건너뛰되 촬영번호는 가이드 것을 그대로 쓴다
1124
+ for (let i = 0; i < this.sets.length; i++) {
1125
+ const set = this.sets[i];
1126
+ if (!set)
1127
+ continue;
1128
+ const frames = await this._fetchVlmFrames(set, i);
1129
+ const shotNo = ((_c = (_b = (_a = this.guide) === null || _a === void 0 ? void 0 : _a.shots) === null || _b === void 0 ? void 0 : _b[i]) === null || _c === void 0 ? void 0 : _c.shot_no) || i + 1;
1130
+ for (const _ of frames)
1131
+ imageShots.push(shotNo);
1132
+ newPhotos = [...newPhotos, ...frames];
1068
1133
  }
1069
1134
  }
1070
1135
  const files = newPhotos.map(p => p.file);
1071
- const checklist = isRecapture
1136
+ let checklist = isRecapture
1072
1137
  ? this.engineChecklist.filter(c => c.item_id === this.selectedItem.item_id)
1073
1138
  : this.engineChecklist;
1139
+ // 아직 안 올라온 촬영에 배정된 항목은 이번 판정에서 뺀다.
1140
+ // 엔진은 그런 항목의 사진 범위를 비우는 대신 '전체 사진'을 주므로, 그냥 두면
1141
+ // 타설 후 항목이 배근 사진으로 판정된다 (배근·타설은 며칠 간격으로 찍는다).
1142
+ if (!isRecapture) {
1143
+ const pending = this._itemsAwaitingShot();
1144
+ if (pending.size) {
1145
+ checklist = checklist.filter(c => !pending.has(c.item_id));
1146
+ notify({
1147
+ message: `아직 촬영되지 않은 항목 ${pending.size}건은 이번 판정에서 제외했습니다. 해당 촬영을 올린 뒤 다시 실행하세요.`,
1148
+ level: 'warn'
1149
+ });
1150
+ }
1151
+ }
1152
+ const input = { action: 'inspect', checklist, input_kind: 'video_frames' };
1153
+ // 촬영 배정 되돌리기 — 이걸 안 보내면 모든 항목이 모든 사진을 보게 되어
1154
+ // "타설 후 항목이 배근 사진으로 판정되는" 오판이 난다 (엔진 실증에서 실제 발생).
1155
+ // 배정된 촬영이 안 올라온 항목은 엔진이 hold 로 둔다 — 남의 사진으로 판정하지 않게.
1156
+ const shotItems = this._shotItemsMap();
1157
+ if (!isRecapture && shotItems && imageShots.length === files.length) {
1158
+ input.image_shots = imageShots.join(',');
1159
+ input.shot_items = JSON.stringify(shotItems);
1160
+ }
1074
1161
  this.loadingText = 'AI 자동 판정 중... (최대 1~2분 소요)';
1075
- const result = await this._callEngine({ action: 'inspect', checklist, input_kind: 'video_frames' }, files);
1162
+ const result = await this._callEngine(input, files);
1076
1163
  if (isRecapture) {
1077
1164
  this.photos = [...this.photos, ...newPhotos];
1078
1165
  this._mergeItems((result === null || result === void 0 ? void 0 : result.items_sorted) || (result === null || result === void 0 ? void 0 : result.items) || [], this.recaptureBase);