> For the complete documentation index, see [llms.txt](https://kopens.gitbook.io/plantpulse-platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kopens.gitbook.io/plantpulse-platform/admin/modules/batch.md).

# batch (배치 처리)

## 역할

스케줄 기반 배치 작업 실행기. 일/시/월 단위 통계 집계, 데이터 정리, 보고서 생성, OEE/RAM/EMS 플러그인 계산을 수행합니다.

| 항목    | 값                                                   |
| ----- | --------------------------------------------------- |
| 모듈명   | `plantpulse-batch`                                  |
| 설치 경로 | `/opt/kopens/plantpulse-platform/plantpulse-batch/` |
| 포트    | **9500**                                            |
| 스케줄러  | Quartz (PostgreSQL JDBC store)                      |

## 주요 책임

* 시간별 / 일별 / 월별 집계 (tag → asset)
* OEE / RAM / EMS 플러그인 계산
* 보고서 자동 생성
* 데이터 보관 정책 적용
* 데이터 무결성 검증

## 구성

```mermaid
graph LR
  QUARTZ[Quartz 스케줄러<br/>:9500] --> AGGR[집계 작업]
  QUARTZ --> PLUGIN_BATCH[플러그인 배치]
  QUARTZ --> REPORT[보고서 생성]
  QUARTZ --> CLEANUP[데이터 정리]

  AGGR --> CASS[(Cassandra)]
  PLUGIN_BATCH --> CASS
  PLUGIN_BATCH --> PG[(PostgreSQL)]
  REPORT --> MINIO[(MinIO)]
```

## 디렉토리 구조

```
plantpulse-batch/
├── app/
├── bin/start.sh stop.sh log-viewer.sh
├── logs/system.log
└── server/conf/server.xml
```

## 주요 설정

`plantpulse-batch/app/.../WEB-INF/classes/batch.properties`:

```properties
batch.scheduler.threads=8
batch.quartz.jdbc.url=jdbc:postgresql://${PP_POSTGRES_HOST}:${PP_POSTGRES_PORT}/${PP_DB_NAME}
batch.quartz.jdbc.user=${PP_PG_USER}
batch.quartz.jdbc.password=${PP_PG_PASSWORD}

# 집계 윈도우
batch.aggregate.interval.minutes=60
batch.aggregate.lookback.hours=24

# 플러그인
batch.plugin.oee.enabled=true
batch.plugin.ram.enabled=true
batch.plugin.ems.enabled=true
```

## 운영 명령

```bash
cd /opt/kopens/plantpulse-platform/plantpulse-startup

./restart-batch.sh
./status.sh                # 9500 RUNNING 확인
```

콘솔의 **시스템 > 배치 관리** 메뉴에서 개별 job 의 실행 / 일시 정지 / 트리거가 가능합니다.

## 자주 발생하는 문제

| 증상         | 원인                 | 조치                                  |
| ---------- | ------------------ | ----------------------------------- |
| Job 실행 안 됨 | Quartz 락 / 클러스터 충돌 | `qrtz_locks` 테이블 확인                 |
| 집계 결과 누락   | 대상 데이터 시간 범위 오차    | `batch.aggregate.lookback.hours` 조정 |
| 메모리 부족     | 큰 윈도우 처리           | 힙 상향 또는 윈도우 분할                      |

## 관련 문서

* [모듈 인덱스](/plantpulse-platform/admin/modules.md)
* [플러그인 (OEE/RAM/EMS) 사용자 가이드](/plantpulse-platform/user/plugins.md)
* [개발자: 스케줄러 아키텍처](/plantpulse-platform/developer/scheduler.md)
