@@ -138,7 +138,7 @@ function checkPathNameFrequency(resourceName, pathName, recordDir, isFood = fals
138138 if ( line . startsWith ( '路径名: ' ) ) {
139139 currentPathName = line . split ( '路径名: ' ) [ 1 ] ;
140140 } else if ( line . startsWith ( '内容检测码: ' ) ) {
141- recordContentCode = line . split ( '内容检测码: ' ) [ 1 ] ;
141+ recordContentCode = line . split ( '内容检测码: ' ) [ 1 ] . trim ( ) ;
142142 } else if ( line === '' && currentPathName && recordContentCode ) {
143143 if ( hasValidContentCode ) {
144144 if ( recordContentCode === currentContentCode ) {
@@ -266,11 +266,11 @@ function getLastRunEndTime(resourceName, pathName, recordDir, noRecordDir, pathi
266266
267267 blockLines . forEach ( line => {
268268 if ( line . startsWith ( '路径名: ' ) ) {
269- blockPathName = line . split ( '路径名: ' ) [ 1 ] ;
269+ blockPathName = line . split ( '路径名: ' ) [ 1 ] . trim ( ) ;
270270 } else if ( line . startsWith ( '内容检测码: ' ) ) {
271- blockContentCode = line . split ( '内容检测码: ' ) [ 1 ] || '00000000' ;
271+ blockContentCode = line . split ( '内容检测码: ' ) [ 1 ] . trim ( ) || '00000000' ;
272272 } else if ( line . startsWith ( '结束时间: ' ) ) {
273- blockEndTime = line . split ( '结束时间: ' ) [ 1 ] ;
273+ blockEndTime = line . split ( '结束时间: ' ) [ 1 ] . trim ( ) ;
274274 }
275275 } ) ;
276276
@@ -308,7 +308,7 @@ function getLastRunEndTime(resourceName, pathName, recordDir, noRecordDir, pathi
308308 * @param {Object } cache - 缓存对象(单次路径处理周期内有效)
309309 * @returns {Array<Object> } 结构化记录列表(含runTime、quantityChange)
310310 */
311- function getHistoricalPathRecords ( resourceKey , pathName , recordDir , noRecordDir , isFood = false , cache = { } , pathingFilePath ) {
311+ function getHistoricalPathRecords ( resourceKey , pathName , recordDir , noRecordDir , isFood = false , cache = { } , pathingFilePath , filterExcessMaterials = false ) {
312312 const contentCode = pathingFilePath ? generatePathContentCode ( pathingFilePath ) : null ;
313313 const hasValidContentCode = contentCode && contentCode !== "00000000" ;
314314
@@ -353,14 +353,14 @@ function getHistoricalPathRecords(resourceKey, pathName, recordDir, noRecordDir,
353353
354354 blockLines . forEach ( line => {
355355 if ( line . startsWith ( '路径名: ' ) ) {
356- const recordPathName = line . split ( '路径名: ' ) [ 1 ] ;
356+ const recordPathName = line . split ( '路径名: ' ) [ 1 ] . trim ( ) ;
357357 const cleanRecordPathName = recordPathName . replace ( / _ [ 0 - 9 a - f A - F ] { 8 } \. j s o n $ / , '.json' ) ;
358358 if ( cleanRecordPathName === cleanPathName ) {
359359 isTargetPath = true ;
360360 }
361361 }
362362 if ( line . startsWith ( '内容检测码: ' ) ) {
363- recordContentCode = line . split ( '内容检测码: ' ) [ 1 ] || "00000000" ;
363+ recordContentCode = line . split ( '内容检测码: ' ) [ 1 ] . trim ( ) || "00000000" ;
364364 }
365365 if ( line . startsWith ( '运行时间: ' ) ) {
366366 runTime = parseInt ( line . split ( '运行时间: ' ) [ 1 ] . split ( '秒' ) [ 0 ] , 10 ) || 0 ;
@@ -391,6 +391,35 @@ function getHistoricalPathRecords(resourceKey, pathName, recordDir, noRecordDir,
391391
392392 cache [ cacheKey ] = records ;
393393 if ( debugLog ) log . debug ( `${ CONSTANTS . LOG_MODULES . RECORD } 读取记录并缓存:${ cacheKey } (${ records . length } 条)` ) ;
394+
395+ if ( filterExcessMaterials && excessMaterialNames . length > 0 ) {
396+ const filteredRecords = records . filter ( record => {
397+ const { quantityChange } = record ;
398+
399+ if ( isFood ) {
400+ return true ;
401+ }
402+
403+ if ( monsterToMaterials [ resourceKey ] ) {
404+ const monsterMaterials = monsterToMaterials [ resourceKey ] ;
405+ const allExcess = monsterMaterials . every ( mat => excessMaterialNames . includes ( mat ) ) ;
406+ return ! allExcess ;
407+ }
408+
409+ if ( quantityChange [ resourceKey ] !== undefined ) {
410+ return ! excessMaterialNames . includes ( resourceKey ) ;
411+ }
412+
413+ return true ;
414+ } ) ;
415+
416+ if ( debugLog && filteredRecords . length !== records . length ) {
417+ log . debug ( `${ CONSTANTS . LOG_MODULES . RECORD } 过滤超量材料记录:${ records . length } 条 -> ${ filteredRecords . length } 条` ) ;
418+ }
419+
420+ return filteredRecords ;
421+ }
422+
394423 return records ;
395424}
396425
0 commit comments