xiaoyi
2026-10-30 ae3ab0d376959cd8560e45dce24b6a8b1b39d162
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
import type { PageParam, PageResult } from '@vben/request';
 
import { requestClient } from '#/api/request';
 
/** 安全生产 - 通用分页参数 */
type PageQuery = PageParam & Record<string, any>;
 
/** 安全生产 API 命名空间 */
export namespace SafetyApi {
  // ==================== 安全组织架构 ====================
  export interface Org {
    id?: number;
    parentId?: number;
    name: string;
    /** 负责人(员工编号,关联 hrm_employee) */
    leaderId?: number;
    leaderName?: string;
    leaderPhone?: string;
    memberNames?: string;
    duty?: string;
    sort: number;
    status: number;
    remark?: string;
    createTime?: string;
    children?: Org[];
  }
 
  // ==================== 特种作业证 ====================
  export interface Certificate {
    id?: number;
    /** 持证人(员工编号,关联 hrm_employee) */
    employeeId?: number;
    /** 持证人关联的系统用户编号 */
    userId?: number;
    employeeName?: string;
    employeeNo?: string;
    deptName?: string;
    phone?: string;
    certType: string;
    certTypeName?: string;
    certNo: string;
    issuer?: string;
    issueDate?: string;
    expireDate: string;
    reviewDate?: string;
    warnDays?: number;
    status?: string;
    statusName?: string;
    remainingDays?: number;
    attachment?: string;
    remark?: string;
    createTime?: string;
  }
 
  // ==================== 巡检点位 ====================
  export interface InspectionPoint {
    id?: number;
    code: string;
    name: string;
    pointType: string;
    pointTypeName?: string;
    /** 所属车间(关联 mes_md_workshop) */
    workshopId?: number;
    workshopName?: string;
    location?: string;
    inspectItems?: string;
    inspectCycle?: string;
    inspectCycleName?: string;
    /** 责任人(员工编号,关联 hrm_employee) */
    ownerId?: number;
    ownerName?: string;
    status: number;
    lastInspectTime?: string;
    remark?: string;
    createTime?: string;
  }
 
  // ==================== 巡检记录 ====================
  export interface Inspection {
    id?: number;
    pointId: number;
    pointName?: string;
    pointType?: string;
    pointTypeName?: string;
    inspectTime: string;
    /** 巡检人(员工编号,关联 hrm_employee) */
    inspectorId?: number;
    inspector?: string;
    result?: string;
    resultName?: string;
    content?: string;
    photoUrls?: string;
    hazardCount?: number;
    remark?: string;
    createTime?: string;
  }
 
  // ==================== 隐患 ====================
  export interface Hazard {
    id?: number;
    code?: string;
    title: string;
    level?: string;
    levelName?: string;
    source?: string;
    sourceName?: string;
    inspectionId?: number;
    pointId?: number;
    pointName?: string;
    location?: string;
    description?: string;
    photoUrls?: string;
    /** 上报人(员工编号,关联 hrm_employee) */
    reporterId?: number;
    reporter?: string;
    reportTime?: string;
    /** 整改责任人(员工编号,关联 hrm_employee) */
    assigneeId?: number;
    assignee?: string;
    assignTime?: string;
    rectifyDeadline?: string;
    overdue?: boolean;
    rectifyDesc?: string;
    rectifyPhotoUrls?: string;
    rectifyTime?: string;
    /** 复查人(员工编号,关联 hrm_employee) */
    recheckerId?: number;
    rechecker?: string;
    recheckTime?: string;
    recheckResult?: string;
    recheckResultName?: string;
    recheckRemark?: string;
    status?: string;
    statusName?: string;
    closeTime?: string;
    remark?: string;
    createTime?: string;
  }
 
  // ==================== 高危作业票 ====================
  export interface WorkPermit {
    id?: number;
    code?: string;
    permitType: string;
    permitTypeName?: string;
    title: string;
    /** 作业车间(关联 mes_md_workshop) */
    workshopId?: number;
    workshopName?: string;
    location?: string;
    workContent?: string;
    /** 申请人(员工编号,关联 hrm_employee) */
    applicantId?: number;
    applicant?: string;
    applyTime?: string;
    planStartTime: string;
    planEndTime: string;
    actualStartTime?: string;
    actualEndTime?: string;
    riskLevel?: string;
    riskLevelName?: string;
    safetyMeasures?: string;
    /** 审批人(员工编号,关联 hrm_employee) */
    approverId?: number;
    approver?: string;
    approveTime?: string;
    approveComment?: string;
    /** 监护人(员工编号,关联 hrm_employee) */
    guardianId?: number;
    guardian?: string;
    guardianRequired?: boolean;
    status?: string;
    statusName?: string;
    attachment?: string;
    photoUrls?: string;
    remark?: string;
    createTime?: string;
  }
 
  export interface WorkPermitMonitor {
    id?: number;
    permitId: number;
    monitorTime?: string;
    /** 监护人(员工编号,关联 hrm_employee) */
    guardianId?: number;
    guardian?: string;
    monitorContent?: string;
    abnormal?: string;
    photoUrls?: string;
    createTime?: string;
  }
 
  // ==================== 应急物资 ====================
  export interface Material {
    id?: number;
    code: string;
    name: string;
    category: string;
    categoryName?: string;
    spec?: string;
    unit?: string;
    stockQty?: number;
    safeStock?: number;
    belowSafeStock?: boolean;
    storageLocation?: string;
    expireDate?: string;
    expireRemainingDays?: number;
    validityMonths?: number;
    /** 保管人(员工编号,关联 hrm_employee) */
    managerId?: number;
    manager?: string;
    status: number;
    remark?: string;
    createTime?: string;
  }
 
  export interface MaterialStock {
    id?: number;
    materialId: number;
    materialName?: string;
    category?: string;
    categoryName?: string;
    bizType: string;
    bizTypeName?: string;
    quantity: number;
    stockBefore?: number;
    stockAfter?: number;
    bizDate?: string;
    operator: string;
    receiver?: string;
    purpose?: string;
    remark?: string;
    createTime?: string;
  }
 
  // ==================== 培训 / 演练 / 事故 ====================
  export interface Training {
    id?: number;
    title: string;
    trainingType?: string;
    trainingTypeName?: string;
    trainDate: string;
    durationHours?: number;
    /** 讲师/组织人(员工编号,关联 hrm_employee) */
    trainerId?: number;
    trainer?: string;
    location?: string;
    participants?: string;
    participantCount?: number;
    content?: string;
    examResult?: string;
    attachment?: string;
    remark?: string;
    createTime?: string;
  }
 
  export interface Drill {
    id?: number;
    title: string;
    drillType?: string;
    drillTypeName?: string;
    drillDate: string;
    location?: string;
    /** 组织人(员工编号,关联 hrm_employee) */
    organizerId?: number;
    organizer?: string;
    participants?: string;
    participantCount?: number;
    planDesc?: string;
    processDesc?: string;
    summary?: string;
    durationMinutes?: number;
    attachment?: string;
    remark?: string;
    createTime?: string;
  }
 
  export interface Accident {
    id?: number;
    code?: string;
    title: string;
    accidentType: string;
    accidentTypeName?: string;
    level?: string;
    levelName?: string;
    occurTime: string;
    location?: string;
    /** 所属车间(关联 mes_md_workshop) */
    workshopId?: number;
    workshopName?: string;
    casualtyDesc?: string;
    economicLoss?: number;
    involvedPersons?: string;
    description?: string;
    causeAnalysis?: string;
    measures?: string;
    /** 登记人(员工编号,关联 hrm_employee) */
    reporterId?: number;
    reporter?: string;
    reportTime?: string;
    status?: string;
    statusName?: string;
    attachment?: string;
    remark?: string;
    createTime?: string;
  }
 
  // ==================== 总览 ====================
  export interface MonthlyCount {
    month: string;
    count: number;
  }
 
  export interface Overview {
    certTotal: number;
    certExpiring: number;
    certExpired: number;
    hazardTotal: number;
    hazardOpen: number;
    hazardOverdue: number;
    hazardCloseRate: number;
    permitPending: number;
    permitInProgress: number;
    materialBelowSafeStock: number;
    materialExpiring: number;
    trainingThisMonth: number;
    drillThisMonth: number;
    accidentThisMonth: number;
    hazardTrend: MonthlyCount[];
    accidentTrend: MonthlyCount[];
  }
}
 
// ==================== 安全组织架构 ====================
export function getOrgTree() {
  return requestClient.get<SafetyApi.Org[]>('/safety/org/tree');
}
export function getOrg(id: number) {
  return requestClient.get<SafetyApi.Org>('/safety/org/get', { params: { id } });
}
export function createOrg(data: SafetyApi.Org) {
  return requestClient.post<number>('/safety/org/create', data);
}
export function updateOrg(data: SafetyApi.Org) {
  return requestClient.put('/safety/org/update', data);
}
export function deleteOrg(id: number) {
  return requestClient.delete('/safety/org/delete', { params: { id } });
}
 
// ==================== 特种作业证 ====================
export function getCertificatePage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.Certificate>>('/safety/certificate/page', { params });
}
export function getCertificate(id: number) {
  return requestClient.get<SafetyApi.Certificate>('/safety/certificate/get', { params: { id } });
}
export function createCertificate(data: SafetyApi.Certificate) {
  return requestClient.post<number>('/safety/certificate/create', data);
}
export function updateCertificate(data: SafetyApi.Certificate) {
  return requestClient.put('/safety/certificate/update', data);
}
export function deleteCertificate(id: number) {
  return requestClient.delete('/safety/certificate/delete', { params: { id } });
}
export function getExpiringCertificates(days?: number) {
  return requestClient.get<SafetyApi.Certificate[]>('/safety/certificate/expiring-list', {
    params: { days },
  });
}
 
// ==================== 巡检点位 ====================
export function getInspectionPointPage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.InspectionPoint>>('/safety/inspection/point/page', { params });
}
export function getInspectionPoint(id: number) {
  return requestClient.get<SafetyApi.InspectionPoint>('/safety/inspection/point/get', { params: { id } });
}
export function getInspectionPointSimpleList() {
  return requestClient.get<SafetyApi.InspectionPoint[]>('/safety/inspection/point/simple-list');
}
export function createInspectionPoint(data: SafetyApi.InspectionPoint) {
  return requestClient.post<number>('/safety/inspection/point/create', data);
}
export function updateInspectionPoint(data: SafetyApi.InspectionPoint) {
  return requestClient.put('/safety/inspection/point/update', data);
}
export function deleteInspectionPoint(id: number) {
  return requestClient.delete('/safety/inspection/point/delete', { params: { id } });
}
 
// ==================== 巡检记录 ====================
export function getInspectionPage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.Inspection>>('/safety/inspection/record/page', { params });
}
export function getInspection(id: number) {
  return requestClient.get<SafetyApi.Inspection>('/safety/inspection/record/get', { params: { id } });
}
export function createInspection(data: SafetyApi.Inspection) {
  return requestClient.post<number>('/safety/inspection/record/create', data);
}
export function updateInspection(data: SafetyApi.Inspection) {
  return requestClient.put('/safety/inspection/record/update', data);
}
export function deleteInspection(id: number) {
  return requestClient.delete('/safety/inspection/record/delete', { params: { id } });
}
 
// ==================== 隐患 ====================
export function getHazardPage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.Hazard>>('/safety/hazard/page', { params });
}
export function getHazard(id: number) {
  return requestClient.get<SafetyApi.Hazard>('/safety/hazard/get', { params: { id } });
}
export function createHazard(data: SafetyApi.Hazard) {
  return requestClient.post<number>('/safety/hazard/create', data);
}
export function updateHazard(data: SafetyApi.Hazard) {
  return requestClient.put('/safety/hazard/update', data);
}
export function deleteHazard(id: number) {
  return requestClient.delete('/safety/hazard/delete', { params: { id } });
}
export function assignHazard(data: { id: number; assigneeId: number; rectifyDeadline?: string; remark?: string }) {
  return requestClient.put('/safety/hazard/assign', data);
}
export function rectifyHazard(data: { id: number; rectifyDesc: string; rectifyPhotoUrls?: string }) {
  return requestClient.put('/safety/hazard/rectify', data);
}
export function recheckHazard(data: {
  id: number;
  recheckerId: number;
  recheckResult: string;
  recheckRemark?: string;
}) {
  return requestClient.put('/safety/hazard/recheck', data);
}
 
// ==================== 高危作业票 ====================
export function getWorkPermitPage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.WorkPermit>>('/safety/permit/page', { params });
}
export function getWorkPermit(id: number) {
  return requestClient.get<SafetyApi.WorkPermit>('/safety/permit/get', { params: { id } });
}
export function createWorkPermit(data: SafetyApi.WorkPermit) {
  return requestClient.post<number>('/safety/permit/create', data);
}
export function updateWorkPermit(data: SafetyApi.WorkPermit) {
  return requestClient.put('/safety/permit/update', data);
}
export function deleteWorkPermit(id: number) {
  return requestClient.delete('/safety/permit/delete', { params: { id } });
}
export function approveWorkPermit(data: {
  id: number;
  approverId: number;
  decision: string;
  approveComment?: string;
}) {
  return requestClient.put('/safety/permit/approve', data);
}
export function startWorkPermit(id: number) {
  return requestClient.put('/safety/permit/start', null, { params: { id } });
}
export function closeWorkPermit(id: number) {
  return requestClient.put('/safety/permit/close', null, { params: { id } });
}
export function cancelWorkPermit(id: number) {
  return requestClient.put('/safety/permit/cancel', null, { params: { id } });
}
export function getMonitorList(permitId: number) {
  return requestClient.get<SafetyApi.WorkPermitMonitor[]>('/safety/permit/monitor/list', {
    params: { permitId },
  });
}
export function createMonitor(data: SafetyApi.WorkPermitMonitor) {
  return requestClient.post<number>('/safety/permit/monitor/create', data);
}
export function deleteMonitor(id: number) {
  return requestClient.delete('/safety/permit/monitor/delete', { params: { id } });
}
 
// ==================== 应急物资 ====================
export function getMaterialPage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.Material>>('/safety/material/page', { params });
}
export function getMaterial(id: number) {
  return requestClient.get<SafetyApi.Material>('/safety/material/get', { params: { id } });
}
export function createMaterial(data: SafetyApi.Material) {
  return requestClient.post<number>('/safety/material/create', data);
}
export function updateMaterial(data: SafetyApi.Material) {
  return requestClient.put('/safety/material/update', data);
}
export function deleteMaterial(id: number) {
  return requestClient.delete('/safety/material/delete', { params: { id } });
}
export function getBelowSafeStockMaterials() {
  return requestClient.get<SafetyApi.Material[]>('/safety/material/below-safe-stock');
}
export function getExpiringMaterials(days?: number) {
  return requestClient.get<SafetyApi.Material[]>('/safety/material/expiring-list', { params: { days } });
}
export function getMaterialStockPage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.MaterialStock>>('/safety/material/stock/page', { params });
}
export function createMaterialStock(data: SafetyApi.MaterialStock) {
  return requestClient.post<number>('/safety/material/stock/create', data);
}
 
// ==================== 培训 / 演练 / 事故 ====================
export function getTrainingPage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.Training>>('/safety/training/page', { params });
}
export function getTraining(id: number) {
  return requestClient.get<SafetyApi.Training>('/safety/training/get', { params: { id } });
}
export function createTraining(data: SafetyApi.Training) {
  return requestClient.post<number>('/safety/training/create', data);
}
export function updateTraining(data: SafetyApi.Training) {
  return requestClient.put('/safety/training/update', data);
}
export function deleteTraining(id: number) {
  return requestClient.delete('/safety/training/delete', { params: { id } });
}
 
export function getDrillPage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.Drill>>('/safety/training/drill/page', { params });
}
export function getDrill(id: number) {
  return requestClient.get<SafetyApi.Drill>('/safety/training/drill/get', { params: { id } });
}
export function createDrill(data: SafetyApi.Drill) {
  return requestClient.post<number>('/safety/training/drill/create', data);
}
export function updateDrill(data: SafetyApi.Drill) {
  return requestClient.put('/safety/training/drill/update', data);
}
export function deleteDrill(id: number) {
  return requestClient.delete('/safety/training/drill/delete', { params: { id } });
}
 
export function getAccidentPage(params: PageQuery) {
  return requestClient.get<PageResult<SafetyApi.Accident>>('/safety/training/accident/page', { params });
}
export function getAccident(id: number) {
  return requestClient.get<SafetyApi.Accident>('/safety/training/accident/get', { params: { id } });
}
export function createAccident(data: SafetyApi.Accident) {
  return requestClient.post<number>('/safety/training/accident/create', data);
}
export function updateAccident(data: SafetyApi.Accident) {
  return requestClient.put('/safety/training/accident/update', data);
}
export function deleteAccident(id: number) {
  return requestClient.delete('/safety/training/accident/delete', { params: { id } });
}
 
// ==================== 台账与总览 ====================
export function getSafetyOverview() {
  return requestClient.get<SafetyApi.Overview>('/safety/ledger/overview');
}
export function exportSafetyLedger(params: { type?: string; startDate?: string; endDate?: string }) {
  return requestClient.download('/safety/ledger/export', { params });
}
 
// ==================== 移动端拍照上传 ====================
// 说明:requestClient.upload 对数组字段会展开成 files[0]、files[1],
// 而后端批量接口用 @RequestPart("files") List<MultipartFile>,因此走 FormData 直传。
export function uploadSafetyFile(file: File, bizType = 'safety') {
  return requestClient.upload<string>('/safety/file/upload', { file, bizType });
}
export function uploadSafetyFiles(files: File[], bizType = 'safety') {
  const formData = new FormData();
  files.forEach((file) => formData.append('files', file));
  if (bizType) formData.append('bizType', bizType);
  return requestClient.post<string[]>('/safety/file/upload-batch', formData, {
    headers: { 'Content-Type': 'multipart/form-data' },
  });
}