This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
NumericalCollection is a Spring Boot 2.6.13 application that collects and synchronizes device metrics data from manufacturing equipment. It integrates with an Oracle database and external device APIs to fetch real-time device data, daily statistics, and production order information. The application runs scheduled tasks to poll device data and provides REST endpoints for manual synchronization.
Build the project:bash mvn clean install
Run the application locally:bash mvn spring-boot:run
The server starts on port 9095 (configured in application.yml).
Run tests:bash mvn test
Compile without tests:bash mvn compile -DskipTests
Package for deployment:bash mvn clean package -DskipTests
Produces target/NumericalCollection.jar.
config/ - Spring configuration classes, including DataAcquisitionConfiguration, MybatisPlusConfig, and result wrapperscontroller/ - REST controllers, primarily KMController which handles manual synchronization endpointsservice/ and service/impl/ - Business logic layerINumericalService - Core service for device data retrieval and synchronizationINumericalNoOrderService - Service for device operations without order context (device list, real-time data, daily statistics)DeviceMetricsService - Handles manual synchronization operations and PDF conversion{Entity}Service (e.g., DeviceService, MesNumericalService)mapper/ - MyBatis-Plus mapper interfaces for database operationsentity/ - JPA/MyBatis entities representing database tablesdto/ - Data transfer objects for API requests/responsestask/ - Scheduled task components, specifically ScheduledTasks for automated data collectionScheduledTasks.java):INumericalService methodssrc/main/resources/mapper/map-underscore-to-camel-case: true)KMController):/Numerical/manualSynchronization - Sync device metrics for a specific order/Numerical/manualSynchronizationBycl - Sync BYCL device metrics/Numerical/RefreshDev and /Numerical/RefreshDevBycl - Refresh device data/Numerical/PdfToBase64 - Convert PDF reports to Base64The application connects to Oracle database at 192.168.0.94:1521/orcl with credentials in application.yml. Override these for local development using environment variables or Spring profiles:bash mvn spring-boot:run -Dspring-boot.run.arguments="--spring.datasource.url=jdbc:oracle:thin:@localhost:1521/orcl --spring.datasource.username=user --spring.datasource.password=pass"
mapper/ package are auto-scanned via @MapperScan annotationsrc/main/resources/mapper/ with matching namesServices extend IService<Entity> from MyBatis-Plus for CRUD operations. Implementations follow the pattern:java @Service @RequiredArgsConstructor public class EntityServiceImpl extends ServiceImpl<EntityMapper, Entity> implements EntityService
Use constructor injection via Lombok's @RequiredArgsConstructor for dependencies.
Add new scheduled methods to ScheduledTasks.java component. Cron expressions follow standard format. Ensure error handling wraps API calls in try-catch blocks as shown in existing tasks.
mvn clean testINumericalService interfaceServiceImpl classKMController if manual trigger neededEdit ScheduledTasks.java and adjust cron expressions. Remember existing offsets:
- Main device polling: every 2 minutes at :00 seconds
- BYCL device polling: every 2 minutes at :30 seconds
- Order sync: daily at 1 AM
- Statistics collection: daily at 2 AM
- Data cleanup: weekly Sunday at midnight
开发工作流程
问题解决流程
1. 首先思考问题,阅读代码库中的相关文件,并将计划写入 tasks/todo.md
2. 计划应包含可以勾选完成的待办事项列表
3. 开始工作前,与我确认计划
4. 然后开始处理待办事项,完成时标记为完成
5. 每一步都提供高层次的变化说明
6. 使每个任务和代码更改尽可能简单,避免大规模或复杂的更改
7. 每个更改应尽可能少地影响代码,一切以简单性为核心
8. 最后,在 todo.md 文件中添加审查部分,总结所做的更改和其他相关信息
开发原则
⦁ 不懒惰: 绝不懒惰。如果有错误,找到根本原因并修复它。不要使用临时修复。你是一名高级开发人员,绝不懒惰。
⦁ 简单性: 使所有修复和代码更改尽可能简单。它们只应影响与任务相关的必要代码,不应影响其他内容。应尽可能少地影响代码。你的目标是不要引入任何错误。一切都关乎简单性。