From 2ecd8db79a4dcf572fa93b58bf58cd4a6e7bf6df Mon Sep 17 00:00:00 2001 From: Misaka Date: Sat, 28 Feb 2026 22:45:06 +0800 Subject: [PATCH] feat: implement production order DAO - Add ProductionOrderDAO class for production order data access - Implement queryProductionOrderNumbers() to query SQL Server for production order numbers - Implement readProductionIds() to read production IDs from text files - Includes proper error handling and logging Co-Authored-By: Claude Sonnet 4.5 --- src/main/dao/production-order.dao.ts | 45 ++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/main/dao/production-order.dao.ts diff --git a/src/main/dao/production-order.dao.ts b/src/main/dao/production-order.dao.ts new file mode 100644 index 0000000..c80b0fb --- /dev/null +++ b/src/main/dao/production-order.dao.ts @@ -0,0 +1,45 @@ +import { DatabaseService } from '../services/database.service'; +import { LoggerService } from '../services/logger.service'; + +export class ProductionOrderDAO { + constructor(private dbService: DatabaseService) {} + + async queryProductionOrderNumbers(productionIds: string[]): Promise { + try { + LoggerService.info(`Querying production orders for ${productionIds.length} IDs`); + + const idsString = productionIds.map((id) => `'${id}'`).join(','); + const query = ` + SELECT DISTINCT production_order_no + FROM production_orders + WHERE production_id IN (${idsString}) + `; + + const result = await this.dbService.executeSQLServerQuery(query); + const orderNumbers = result.rows.map((row: any) => row.production_order_no); + + LoggerService.info(`Found ${orderNumbers.length} production orders`); + return orderNumbers; + } catch (error) { + LoggerService.error('Failed to query production orders', error); + throw error; + } + } + + async readProductionIds(filePath: string): Promise { + try { + const fs = await import('fs/promises'); + const content = await fs.readFile(filePath, 'utf-8'); + const ids = content + .split('\n') + .map((line) => line.trim()) + .filter((line) => line.length > 0); + + LoggerService.info(`Read ${ids.length} production IDs from file`); + return ids; + } catch (error) { + LoggerService.error('Failed to read production IDs file', error); + throw error; + } + } +}