B2BÍøÂçÈí¼þ

 ÕÒ»ØÃÜÂë
 Á¢¼´×¢²á ÉóºËÍøÕ¾ºÅ:QQ:896757558
ËÑË÷
²é¿´: 6|»Ø¸´: 0
´òÓ¡ ÉÏÒ»Ö÷Ìâ ÏÂÒ»Ö÷Ìâ

AIWROKÊý×é·½·¨¸ß¼¶Ó¦Óð¸Àý

[¸´ÖÆÁ´½Ó]

985

Ö÷Ìâ

990

Ìû×Ó

7217

»ý·Ö

abc

Rank: 9Rank: 9Rank: 9

»ý·Ö
7217
Ìø×ªµ½Ö¸¶¨Â¥²ã
Â¥Ö÷
·¢±íÓÚ ×òÌì 08:47 | Ö»¿´¸Ã×÷Õß »ØÌû½±Àø |µ¹Ðòä¯ÀÀ |ÔĶÁģʽ

AIWROKÊý×é·½·¨¸ß¼¶Ó¦Óð¸Àý



  1. /**
  2. * AIWROKÊý×é·½·¨¸ß¼¶Ó¦Óð¸Àý
  3. * רΪ°²×¿Rhino JavaScriptÒýÇæÓÅ»¯µÄÊý×é´¦Àí½â¾ö·½°¸
  4. * 🍎½»Á÷QQȺ711841924Ⱥһ£¬Æ»¹ûÄÚ²âȺ£¬528816639
  5. * @¹¦ÄÜÌØµã
  6. * - ÍêÈ«¼æÈÝES5Óï·¨ºÍRhinoÒýÇæ
  7. * - ÌṩÊý¾Ý¹ýÂË¡¢×ª»»¡¢¾ÛºÏµÈ¸ß¼¶²Ù×÷
  8. * - Ö§³ÖÅúÁ¿´¦ÀíºÍÒì²½²Ù×÷ģʽ
  9. * - ¼¯³ÉAIWROKÌØÓеÄÈÕÖ¾ºÍUIÏÔʾ¹¦ÄÜ
  10. * - °üº¬ÐÔÄÜÓÅ»¯ºÍÄÚ´æ¹ÜÀí
  11. *
  12. * @Ó¦Óó¡¾°
  13. * - UI¿Ø¼þÅúÁ¿²Ù×÷
  14. * - ÍøÂçÇëÇóÊý¾Ý´¦Àí
  15. * - ͼÏñʶ±ð½á¹ûɸѡ
  16. * - ÈÕÖ¾Êý¾Ý¾ÛºÏ·ÖÎö
  17. * - ¶àÏß³ÌÊý¾Ý´¦Àí
  18. *
  19. * @×÷Õß AIWROK¿ª·¢ÍŶÓ
  20. * @°æ±¾ 1.0 - Rhino¼æÈݰæ
  21. * @ÈÕÆÚ 2024
  22. */

  23. //===========================================
  24. // »ù´¡¼æÈÝÐÔÉèÖÃ
  25. //===========================================

  26. // È·±£printlº¯Êý¿ÉÓ㨼æÈÝRhino»·¾³£©
  27. if (typeof printl === 'undefined') {
  28.     function printl(message) {
  29.         try {
  30.             if (typeof console !== 'undefined' && console.log) {
  31.                 console.log(message);
  32.             } else if (typeof print !== 'undefined') {
  33.                 print(message);
  34.             } else {
  35.                 java.lang.System.out.println(String(message));
  36.             }
  37.         } catch (e) {
  38.             // ¾²Ä¬Ê§°Ü
  39.         }
  40.     }
  41. }

  42. //===========================================
  43. // ¸ß¼¶Êý×鹤¾ßÀà
  44. //===========================================

  45. /**
  46. * ArrayUtils - ¸ß¼¶Êý×é²Ù×÷¹¤¾ßÀà
  47. * ÌṩÁ´Ê½µ÷Óá¢ÅúÁ¿´¦ÀíºÍÐÔÄÜÓÅ»¯¹¦ÄÜ
  48. */
  49. function ArrayUtils() {
  50.     this.version = "1.0.0";
  51.     this.performanceMetrics = {
  52.         operations: 0,
  53.         startTime: 0,
  54.         endTime: 0
  55.     };
  56. }

  57. /**
  58. * ¿ªÊ¼ÐÔÄÜ¼à¿Ø
  59. */
  60. ArrayUtils.prototype.startPerformanceMonitoring = function() {
  61.     this.performanceMetrics.startTime = new Date().getTime();
  62.     this.performanceMetrics.operations = 0;
  63.     return this;
  64. };

  65. /**
  66. * ½áÊøÐÔÄÜ¼à¿Ø²¢·µ»Ø±¨¸æ
  67. */
  68. ArrayUtils.prototype.endPerformanceMonitoring = function() {
  69.     this.performanceMetrics.endTime = new Date().getTime();
  70.     var duration = this.performanceMetrics.endTime - this.performanceMetrics.startTime;
  71.     return {
  72.         duration: duration,
  73.         operations: this.performanceMetrics.operations,
  74.         opsPerSecond: Math.round(this.performanceMetrics.operations / (duration / 1000))
  75.     };
  76. };

  77. /**
  78. * °²È«Êý×é±éÀú - Ö§³ÖÖжϺÍÒì³£´¦Àí
  79. * @param {Array} array - Òª±éÀúµÄÊý×é
  80. * @param {Function} callback - »Øµ÷º¯Êý£¬·µ»Øfalse¿ÉÖжϱéÀú
  81. * @param {Object} context - »Øµ÷º¯ÊýÉÏÏÂÎÄ
  82. * @returns {ArrayUtils} Ö§³ÖÁ´Ê½µ÷ÓÃ
  83. */
  84. ArrayUtils.prototype.forEachSafe = function(array, callback, context) {
  85.     if (!Array.isArray(array)) throw new Error('²ÎÊý±ØÐëÊÇÊý×é');
  86.     if (typeof callback !== 'function') throw new Error('»Øµ÷º¯Êý±ØÐëÊǺ¯Êý');
  87.    
  88.     context = context || this;
  89.    
  90.     try {
  91.         for (var i = 0; i < array.length; i++) {
  92.             this.performanceMetrics.operations++;
  93.             var result = callback.call(context, array[i], i, array);
  94.             if (result === false) break; // Ö§³ÖÖ÷¶¯ÖжÏ
  95.         }
  96.     } catch (e) {
  97.         printl("Êý×é±éÀú´íÎó at index " + i + ": " + (e.message || e));
  98.     }
  99.    
  100.     return this;
  101. };

  102. /**
  103. * ÖÇÄÜÊý×é¹ýÂË - Ö§³Ö¶àÌõ¼þºÍ¸´ÔÓÂß¼­
  104. * @param {Array} array - Ô´Êý×é
  105. * @param {Array} conditions - ¹ýÂËÌõ¼þÊý×é
  106. * @returns {Array} ¹ýÂ˺óµÄÊý×é
  107. *
  108. * @ʾÀý
  109. * var result = arrayUtils.smartFilter(data, [
  110. *     { field: 'age', operator: '>', value: 18 },
  111. *     { field: 'name', operator: 'contains', value: 'ÕÅ' },
  112. *     { field: 'score', operator: 'between', value: [60, 100] }
  113. * ]);
  114. */
  115. ArrayUtils.prototype.smartFilter = function(array, conditions) {
  116.     if (!Array.isArray(array)) throw new Error('µÚÒ»¸ö²ÎÊý±ØÐëÊÇÊý×é');
  117.     if (!Array.isArray(conditions)) throw new Error('Ìõ¼þ²ÎÊý±ØÐëÊÇÊý×é');
  118.    
  119.     var self = this;
  120.    
  121.     return array.filter(function(item) {
  122.         self.performanceMetrics.operations++;
  123.         
  124.         for (var i = 0; i < conditions.length; i++) {
  125.             var condition = conditions[i];
  126.             var fieldValue = self.getFieldValue(item, condition.field);
  127.             
  128.             if (!self.evaluateCondition(fieldValue, condition.operator, condition.value)) {
  129.                 return false;
  130.             }
  131.         }
  132.         
  133.         return true;
  134.     });
  135. };

  136. /**
  137. * »ñÈ¡¶ÔÏó×Ö¶ÎÖµ - Ö§³ÖǶÌ×ÊôÐÔ·ÃÎÊ
  138. */
  139. ArrayUtils.prototype.getFieldValue = function(obj, field) {
  140.     if (!obj || !field) return undefined;
  141.    
  142.     var parts = field.split('.');
  143.     var result = obj;
  144.    
  145.     for (var i = 0; i < parts.length; i++) {
  146.         if (result === null || result === undefined) return undefined;
  147.         result = result[parts[i]];
  148.     }
  149.    
  150.     return result;
  151. };

  152. /**
  153. * ÆÀ¹ÀÌõ¼þ - Ö§³Ö¶àÖÖ²Ù×÷·û
  154. */
  155. ArrayUtils.prototype.evaluateCondition = function(fieldValue, operator, conditionValue) {
  156.     switch (operator) {
  157.         case '==': return fieldValue == conditionValue;
  158.         case '===': return fieldValue === conditionValue;
  159.         case '!=': return fieldValue != conditionValue;
  160.         case '!==': return fieldValue !== conditionValue;
  161.         case '>': return fieldValue > conditionValue;
  162.         case '>=': return fieldValue >= conditionValue;
  163.         case '<': return fieldValue < conditionValue;
  164.         case '<=': return fieldValue <= conditionValue;
  165.         case 'contains':
  166.             return String(fieldValue).indexOf(conditionValue) !== -1;
  167.         case 'startsWith':
  168.             return String(fieldValue).indexOf(conditionValue) === 0;
  169.         case 'endsWith':
  170.             var str = String(fieldValue);
  171.             return str.lastIndexOf(conditionValue) === str.length - conditionValue.length;
  172.         case 'between':
  173.             return fieldValue >= conditionValue[0] && fieldValue <= conditionValue[1];
  174.         case 'in':
  175.             return conditionValue.indexOf(fieldValue) !== -1;
  176.         case 'notIn':
  177.             return conditionValue.indexOf(fieldValue) === -1;
  178.         default:
  179.             return false;
  180.     }
  181. };

  182. /**
  183. * Êý×éÊý¾Ý¾ÛºÏ - Ö§³Ö¶àÖ־ۺϺ¯Êý
  184. * @param {Array} array - Ô´Êý×é
  185. * @param {Object} config - ¾ÛºÏÅäÖÃ
  186. * @returns {Object} ¾ÛºÏ½á¹û
  187. *
  188. * @ʾÀý
  189. * var stats = arrayUtils.aggregate(salesData, {
  190. *     groupBy: 'category',
  191. *     metrics: {
  192. *         totalSales: { field: 'amount', operation: 'sum' },
  193. *         avgPrice: { field: 'price', operation: 'avg' },
  194. *         count: { operation: 'count' }
  195. *     }
  196. * });
  197. */
  198. ArrayUtils.prototype.aggregate = function(array, config) {
  199.     if (!Array.isArray(array)) throw new Error('²ÎÊý±ØÐëÊÇÊý×é');
  200.    
  201.     var result = {};
  202.     var self = this;
  203.    
  204.     // ·Ö×é´¦Àí
  205.     if (config.groupBy) {
  206.         var groups = {};
  207.         
  208.         array.forEach(function(item) {
  209.             self.performanceMetrics.operations++;
  210.             var groupKey = self.getFieldValue(item, config.groupBy);
  211.             if (!groups[groupKey]) {
  212.                 groups[groupKey] = [];
  213.             }
  214.             groups[groupKey].push(item);
  215.         });
  216.         
  217.         // ¶Ôÿ¸ö·Ö×é½øÐоۺÏ
  218.         for (var groupKey in groups) {
  219.             if (groups.hasOwnProperty(groupKey)) {
  220.                 result[groupKey] = self.calculateMetrics(groups[groupKey], config.metrics);
  221.             }
  222.         }
  223.     } else {
  224.         // ²»·Ö×飬ֱ½Ó¾ÛºÏ
  225.         result = this.calculateMetrics(array, config.metrics);
  226.     }
  227.    
  228.     return result;
  229. };

  230. /**
  231. * ¼ÆËãÖ¸±ê - Ö§³Ö¶àÖ־ۺϲÙ×÷
  232. */
  233. ArrayUtils.prototype.calculateMetrics = function(array, metrics) {
  234.     var result = {};
  235.     var self = this;
  236.    
  237.     for (var metricName in metrics) {
  238.         if (metrics.hasOwnProperty(metricName)) {
  239.             var metric = metrics[metricName];
  240.             result[metricName] = self.calculateMetric(array, metric);
  241.         }
  242.     }
  243.    
  244.     return result;
  245. };

  246. /**
  247. * ¼ÆËãµ¥¸öÖ¸±ê
  248. */
  249. ArrayUtils.prototype.calculateMetric = function(array, metric) {
  250.     var operation = metric.operation;
  251.     var field = metric.field;
  252.    
  253.     switch (operation) {
  254.         case 'count':
  255.             return array.length;
  256.             
  257.         case 'sum':
  258.             return array.reduce(function(sum, item) {
  259.                 return sum + (field ? this.getFieldValue(item, field) : item);
  260.             }.bind(this), 0);
  261.             
  262.         case 'avg':
  263.             var sum = array.reduce(function(sum, item) {
  264.                 return sum + (field ? this.getFieldValue(item, field) : item);
  265.             }.bind(this), 0);
  266.             return array.length > 0 ? sum / array.length : 0;
  267.             
  268.         case 'max':
  269.             return Math.max.apply(Math, array.map(function(item) {
  270.                 return field ? this.getFieldValue(item, field) : item;
  271.             }.bind(this)));
  272.             
  273.         case 'min':
  274.             return Math.min.apply(Math, array.map(function(item) {
  275.                 return field ? this.getFieldValue(item, field) : item;
  276.             }.bind(this)));
  277.             
  278.         default:
  279.             return 0;
  280.     }
  281. };

  282. /**
  283. * Êý×é·ÖÒ³´¦Àí - Ö§³Ö´óÊý¾Ý¼¯µÄ·ÖÒ³ÏÔʾ
  284. * @param {Array} array - Ô´Êý×é
  285. * @param {number} pageSize - ÿҳ´óС
  286. * @param {number} pageNumber - Ò³Â루´Ó1¿ªÊ¼£©
  287. * @returns {Object} ·ÖÒ³½á¹û
  288. */
  289. ArrayUtils.prototype.paginate = function(array, pageSize, pageNumber) {
  290.     if (!Array.isArray(array)) throw new Error('²ÎÊý±ØÐëÊÇÊý×é');
  291.    
  292.     pageSize = Math.max(1, pageSize || 10);
  293.     pageNumber = Math.max(1, pageNumber || 1);
  294.    
  295.     var totalItems = array.length;
  296.     var totalPages = Math.ceil(totalItems / pageSize);
  297.     var startIndex = (pageNumber - 1) * pageSize;
  298.     var endIndex = Math.min(startIndex + pageSize, totalItems);
  299.    
  300.     return {
  301.         items: array.slice(startIndex, endIndex),
  302.         pagination: {
  303.             pageNumber: pageNumber,
  304.             pageSize: pageSize,
  305.             totalItems: totalItems,
  306.             totalPages: totalPages,
  307.             hasPrevious: pageNumber > 1,
  308.             hasNext: pageNumber < totalPages,
  309.             startIndex: startIndex,
  310.             endIndex: endIndex - 1
  311.         }
  312.     };
  313. };

  314. /**
  315. * Êý×éÈ¥ÖØ - Ö§³Ö¸´ÔÓ¶ÔÏóµÄÈ¥ÖØ
  316. * @param {Array} array - Ô´Êý×é
  317. * @param {string|Function} keySelector - ÓÃÓÚÈ¥ÖØµÄ¼üÑ¡ÔñÆ÷
  318. * @returns {Array} È¥ÖØºóµÄÊý×é
  319. */
  320. ArrayUtils.prototype.distinct = function(array, keySelector) {
  321.     if (!Array.isArray(array)) throw new Error('²ÎÊý±ØÐëÊÇÊý×é');
  322.    
  323.     var seen = {};
  324.     var result = [];
  325.     var self = this;
  326.    
  327.     array.forEach(function(item) {
  328.         self.performanceMetrics.operations++;
  329.         
  330.         var key;
  331.         if (typeof keySelector === 'function') {
  332.             key = keySelector(item);
  333.         } else if (typeof keySelector === 'string') {
  334.             key = self.getFieldValue(item, keySelector);
  335.         } else {
  336.             key = item;
  337.         }
  338.         
  339.         var keyString = String(key);
  340.         if (!seen.hasOwnProperty(keyString)) {
  341.             seen[keyString] = true;
  342.             result.push(item);
  343.         }
  344.     });
  345.    
  346.     return result;
  347. };

  348. //===========================================
  349. // AIWROKÌØ¶¨¹¦Äܼ¯³É
  350. //===========================================

  351. /**
  352. * UI¿Ø¼þÅúÁ¿´¦Àí - ½áºÏAIWROKµÄUI²Ù×÷
  353. * @param {Array} uiElements - UIÔªËØÊý×é
  354. * @param {Function} processor - ´¦Àíº¯Êý
  355. * @param {Object} options - ´¦ÀíÑ¡Ïî
  356. */
  357. ArrayUtils.prototype.batchUIProcess = function(uiElements, processor, options) {
  358.     options = options || {};
  359.     var batchSize = options.batchSize || 10;
  360.     var delay = options.delay || 100;
  361.     var self = this;
  362.    
  363.     printl("¿ªÊ¼ÅúÁ¿´¦Àí " + uiElements.length + " ¸öUIÔªËØ");
  364.    
  365.     var batches = [];
  366.     for (var i = 0; i < uiElements.length; i += batchSize) {
  367.         batches.push(uiElements.slice(i, i + batchSize));
  368.     }
  369.    
  370.     // ·ÖÅú´¦Àí
  371.     batches.forEach(function(batch, batchIndex) {
  372.         setTimeout(function() {
  373.             printl("´¦ÀíµÚ " + (batchIndex + 1) + " Åú£¬¹² " + batch.length + " ¸öÔªËØ");
  374.             
  375.             batch.forEach(function(element, index) {
  376.                 try {
  377.                     processor(element, index);
  378.                     self.performanceMetrics.operations++;
  379.                 } catch (e) {
  380.                     printl("´¦ÀíUIÔªËØÊ§°Ü: " + (e.message || e));
  381.                 }
  382.             });
  383.             
  384.             if (batchIndex === batches.length - 1) {
  385.                 printl("ÅúÁ¿´¦ÀíÍê³É");
  386.             }
  387.         }, batchIndex * delay);
  388.     });
  389.    
  390.     return this;
  391. };

  392. /**
  393. * OCR½á¹ûÖÇÄÜɸѡ - ½áºÏAIWROKµÄOCR¹¦ÄÜ
  394. * @param {Array} ocrResults - OCRʶ±ð½á¹ûÊý×é
  395. * @param {Object} filterOptions - ɸѡѡÏî
  396. * @returns {Array} ɸѡºóµÄ½á¹û
  397. */
  398. ArrayUtils.prototype.filterOCRResults = function(ocrResults, filterOptions) {
  399.     filterOptions = filterOptions || {};
  400.    
  401.     var conditions = [];
  402.    
  403.     // Îı¾³¤¶È¹ýÂË
  404.     if (filterOptions.minLength) {
  405.         conditions.push({
  406.             field: 'text',
  407.             operator: '>',
  408.             value: filterOptions.minLength
  409.         });
  410.     }
  411.    
  412.     // ÖÃÐŶȹýÂË
  413.     if (filterOptions.minConfidence) {
  414.         conditions.push({
  415.             field: 'confidence',
  416.             operator: '>=',
  417.             value: filterOptions.minConfidence
  418.         });
  419.     }
  420.    
  421.     // Îı¾ÄÚÈݹýÂË
  422.     if (filterOptions.contains) {
  423.         conditions.push({
  424.             field: 'text',
  425.             operator: 'contains',
  426.             value: filterOptions.contains
  427.         });
  428.     }
  429.    
  430.     // λÖùýÂË
  431.     if (filterOptions.minX !== undefined) {
  432.         conditions.push({
  433.             field: 'x',
  434.             operator: '>=',
  435.             value: filterOptions.minX
  436.         });
  437.     }
  438.    
  439.     return this.smartFilter(ocrResults, conditions);
  440. };

  441. /**
  442. * ÈÕÖ¾Êý¾Ý¾ÛºÏ·ÖÎö - ½áºÏAIWROKµÄÈÕÖ¾¹¦ÄÜ
  443. * @param {Array} logEntries - ÈÕÖ¾ÌõÄ¿Êý×é
  444. * @param {Object} analysisConfig - ·ÖÎöÅäÖÃ
  445. * @returns {Object} ·ÖÎö½á¹û
  446. */
  447. ArrayUtils.prototype.analyzeLogs = function(logEntries, analysisConfig) {
  448.     analysisConfig = analysisConfig || {};
  449.    
  450.     var timeWindow = analysisConfig.timeWindow || 3600000; // 1Сʱ
  451.     var logLevelWeights = analysisConfig.logLevelWeights || {
  452.         'ERROR': 10,
  453.         'WARN': 5,
  454.         'INFO': 1,
  455.         'DEBUG': 0.5
  456.     };
  457.    
  458.     var currentTime = new Date().getTime();
  459.     var recentLogs = logEntries.filter(function(log) {
  460.         return currentTime - log.timestamp <= timeWindow;
  461.     });
  462.    
  463.     var analysis = {
  464.         totalLogs: recentLogs.length,
  465.         levelDistribution: {},
  466.         errorRate: 0,
  467.         warningRate: 0,
  468.         healthScore: 100
  469.     };
  470.    
  471.     // ͳ¼ÆÈÕÖ¾¼¶±ð·Ö²¼
  472.     recentLogs.forEach(function(log) {
  473.         var level = log.level || 'INFO';
  474.         analysis.levelDistribution[level] = (analysis.levelDistribution[level] || 0) + 1;
  475.     });
  476.    
  477.     // ¼ÆËã´íÎóÂʺ;¯¸æÂÊ
  478.     var errorCount = analysis.levelDistribution['ERROR'] || 0;
  479.     var warnCount = analysis.levelDistribution['WARN'] || 0;
  480.    
  481.     analysis.errorRate = analysis.totalLogs > 0 ? (errorCount / analysis.totalLogs) * 100 : 0;
  482.     analysis.warningRate = analysis.totalLogs > 0 ? (warnCount / analysis.totalLogs) * 100 : 0;
  483.    
  484.     // ¼ÆË㽡¿µ·ÖÊý
  485.     var totalWeight = 0;
  486.     var weightedScore = 0;
  487.    
  488.     for (var level in analysis.levelDistribution) {
  489.         if (analysis.levelDistribution.hasOwnProperty(level)) {
  490.             var count = analysis.levelDistribution[level];
  491.             var weight = logLevelWeights[level] || 1;
  492.             totalWeight += count * weight;
  493.             weightedScore += count * weight;
  494.         }
  495.     }
  496.    
  497.     if (totalWeight > 0) {
  498.         analysis.healthScore = Math.max(0, 100 - (errorCount * 10) - (warnCount * 3));
  499.     }
  500.    
  501.     return analysis;
  502. };

  503. //===========================================
  504. // ʹÓÃʾÀýºÍ²âÊÔ
  505. //===========================================

  506. function ecommerceDataProcessingExample() {
  507.     printl("=== AIWROKÊý×é·½·¨¸ß¼¶Ó¦Óð¸Àý ===");
  508.    
  509.     // ´´½¨Êý×鹤¾ßʵÀý
  510.     var arrayUtils = new ArrayUtils();
  511.    
  512.     // Ä£ÄâµçÉÌÊý¾Ý
  513.     var products = [
  514.         { id: 1, name: 'iPhone 13', category: 'ÊÖ»ú', price: 5999, stock: 50, sales: 120 },
  515.         { id: 2, name: '»ªÎªP50', category: 'ÊÖ»ú', price: 4488, stock: 30, sales: 85 },
  516.         { id: 3, name: 'MacBook Pro', category: 'µçÄÔ', price: 12999, stock: 20, sales: 45 },
  517.         { id: 4, name: 'СÃ×µçÊÓ', category: '¼Òµç', price: 2999, stock: 15, sales: 200 },
  518.         { id: 5, name: 'AirPods Pro', category: 'Åä¼þ', price: 1999, stock: 100, sales: 300 },
  519.         { id: 6, name: '»ªÎªÊÖ±í', category: 'Åä¼þ', price: 2688, stock: 25, sales: 150 },
  520.         { id: 7, name: 'iPad Air', category: 'ƽ°å', price: 4399, stock: 40, sales: 180 },
  521.         { id: 8, name: '´÷¶ûÏÔʾÆ÷', category: 'µçÄÔ', price: 2199, stock: 35, sales: 95 }
  522.     ];
  523.    
  524.     // ¿ªÊ¼ÐÔÄÜ¼à¿Ø
  525.     arrayUtils.startPerformanceMonitoring();
  526.    
  527.     printl("ԭʼÊý¾Ý£º¹² " + products.length + " ¸öÉÌÆ·");
  528.    
  529.     // 1. ÖÇÄÜɸѡ£ºÕÒ³ö¼Û¸ñ´óÓÚ2000ÇÒÏúÁ¿´óÓÚ100µÄÉÌÆ·
  530.     var hotProducts = arrayUtils.smartFilter(products, [
  531.         { field: 'price', operator: '>', value: 2000 },
  532.         { field: 'sales', operator: '>', value: 100 }
  533.     ]);
  534.    
  535.     printl("ÈÈÃÅÉÌÆ·£º" + hotProducts.length + " ¸ö");
  536.     hotProducts.forEach(function(product) {
  537.         printl("  - " + product.name + " (¼Û¸ñ: ¥" + product.price + ", ÏúÁ¿: " + product.sales + ")");
  538.     });
  539.    
  540.     // 2. Êý¾Ý¾ÛºÏ£º°´Àà±ðͳ¼Æ
  541.     var categoryStats = arrayUtils.aggregate(products, {
  542.         groupBy: 'category',
  543.         metrics: {
  544.             totalProducts: { operation: 'count' },
  545.             avgPrice: { field: 'price', operation: 'avg' },
  546.             totalSales: { field: 'sales', operation: 'sum' },
  547.             totalValue: { field: 'stock', operation: 'sum' }
  548.         }
  549.     });
  550.    
  551.     printl("\nÀà±ðͳ¼Æ£º");
  552.     for (var category in categoryStats) {
  553.         if (categoryStats.hasOwnProperty(category)) {
  554.             var stats = categoryStats[category];
  555.             printl("  " + category + ": ");
  556.             printl("    ÉÌÆ·ÊýÁ¿: " + stats.totalProducts);
  557.             printl("    ƽ¾ù¼Û¸ñ: ¥" + Math.round(stats.avgPrice));
  558.             printl("    ×ÜÏúÁ¿: " + stats.totalSales);
  559.             printl("    ¿â´æ×ÜÁ¿: " + stats.totalValue);
  560.         }
  561.     }
  562.    
  563.     // 3. ·ÖÒ³ÏÔʾ£ºÃ¿Ò³ÏÔʾ3¸öÉÌÆ·
  564.     var pageResult = arrayUtils.paginate(products, 3, 2);
  565.    
  566.     printl("\n·ÖÒ³ÏÔʾ£¨µÚ2Ò³£¬Ã¿Ò³3¸ö£©£º");
  567.     pageResult.items.forEach(function(product) {
  568.         printl("  " + product.name + " - " + product.category);
  569.     });
  570.    
  571.     printl("·ÖÒ³ÐÅÏ¢£º");
  572.     printl("  µ±Ç°Ò³: " + pageResult.pagination.pageNumber);
  573.     printl("  ×ÜÒ³Êý: " + pageResult.pagination.totalPages);
  574.     printl("  ×ÜÉÌÆ·Êý: " + pageResult.pagination.totalItems);
  575.    
  576.     // 4. ¸´ÔÓÊý¾Ý´¦ÀíʾÀý£ºÕÒ³ö¸÷Æ·ÀàÖÐ×ÏúµÄÉÌÆ·
  577.     var topProductsByCategory = {};
  578.     var categories = arrayUtils.distinct(products, 'category');
  579.    
  580.     categories.forEach(function(category) {
  581.         var categoryProducts = arrayUtils.smartFilter(products, [
  582.             { field: 'category', operator: '==', value: category }
  583.         ]);
  584.         
  585.         // °´ÏúÁ¿ÅÅÐò£¬È¡ÏúÁ¿×î¸ßµÄ
  586.         categoryProducts.sort(function(a, b) {
  587.             return b.sales - a.sales;
  588.         });
  589.         
  590.         // È·±£·ÖÀàÏÂÓÐÉÌÆ·ÔÙ¸³Öµ
  591.         if (categoryProducts.length > 0) {
  592.             topProductsByCategory[category] = categoryProducts[0];
  593.         }
  594.     });
  595.    
  596.     printl("\n¸÷Æ·Àà×ÏúÉÌÆ·£º");
  597.     for (var cat in topProductsByCategory) {
  598.         if (topProductsByCategory.hasOwnProperty(cat)) {
  599.             var product = topProductsByCategory[cat];
  600.             if (product) { // È·±£²úÆ·´æÔÚÔÙÊä³ö
  601.                 printl("  " + cat + ": " + product.name + " (ÏúÁ¿: " + product.sales + ")");
  602.             }
  603.         }
  604.     }
  605.    
  606.     // 5. ÐÔÄÜ¼à¿Ø½á¹û
  607.     var perfReport = arrayUtils.endPerformanceMonitoring();
  608.     printl("\nÐÔÄܱ¨¸æ£º");
  609.     printl("  Ö´ÐÐʱ¼ä: " + perfReport.duration + "ms");
  610.     printl("  ²Ù×÷´ÎÊý: " + perfReport.operations);
  611.     printl("  ´¦ÀíËÙ¶È: " + perfReport.opsPerSecond + " ops/sec");
  612. }

  613. /**
  614. * OCRʶ±ð½á¹û´¦ÀíʾÀý
  615. */
  616. function ocrResultProcessingExample() {
  617.     printl("\n=== OCRʶ±ð½á¹û´¦ÀíʾÀý ===");
  618.    
  619.     var arrayUtils = new ArrayUtils();
  620.    
  621.     // Ä£ÄâOCRʶ±ð½á¹û
  622.     var ocrResults = [
  623.         { text: 'µÇ¼', confidence: 0.95, x: 100, y: 200, width: 50, height: 30 },
  624.         { text: 'Óû§Ãû', confidence: 0.87, x: 50, y: 300, width: 70, height: 25 },
  625.         { text: 'ÃÜÂë', confidence: 0.92, x: 50, y: 350, width: 50, height: 25 },
  626.         { text: '¼ÇסÎÒ', confidence: 0.78, x: 100, y: 400, width: 80, height: 20 },
  627.         { text: 'Íü¼ÇÃÜÂë', confidence: 0.85, x: 200, y: 400, width: 90, height: 20 },
  628.         { text: '×¢²á', confidence: 0.90, x: 300, y: 200, width: 50, height: 30 },
  629.         { text: 'AIWROK', confidence: 0.98, x: 150, y: 100, width: 100, height: 40 },
  630.         { text: '°ïÖú', confidence: 0.72, x: 300, y: 500, width: 50, height: 25 }
  631.     ];
  632.    
  633.     // ɸѡ¸ßÖÃÐŶÈÎı¾
  634.     var highConfidenceTexts = arrayUtils.filterOCRResults(ocrResults, {
  635.         minConfidence: 0.85
  636.     });
  637.    
  638.     printl("¸ßÖÃÐŶÈÎı¾ (" + highConfidenceTexts.length + " ¸ö):");
  639.     highConfidenceTexts.forEach(function(result) {
  640.         printl("  - " + result.text + " (ÖÃÐŶÈ: " + result.confidence + ")");
  641.     });
  642.    
  643.     // ²éÕÒÌØ¶¨¹Ø¼ü´Ê
  644.     var loginRelatedTexts = arrayUtils.filterOCRResults(ocrResults, {
  645.         contains: 'µÇ¼'
  646.     });
  647.    
  648.     printl("\n°üº¬'µÇ¼'µÄÎı¾:");
  649.     loginRelatedTexts.forEach(function(result) {
  650.         printl("  - " + result.text);
  651.     });
  652. }

  653. /**
  654. * ÈÕÖ¾·ÖÎöʾÀý
  655. */
  656. function logAnalysisExample() {
  657.     printl("\n=== ÈÕÖ¾·ÖÎöʾÀý ===");
  658.    
  659.     var arrayUtils = new ArrayUtils();
  660.    
  661.     // Ä£ÄâÈÕÖ¾Êý¾Ý
  662.     var logEntries = [
  663.         { level: 'INFO', message: 'Ó¦ÓÃÆô¶¯', timestamp: new Date().getTime() - 3600000 },
  664.         { level: 'DEBUG', message: '¼ÓÔØÅäÖÃÎļþ', timestamp: new Date().getTime() - 3590000 },
  665.         { level: 'INFO', message: 'Óû§µÇ¼³É¹¦', timestamp: new Date().getTime() - 3500000 },
  666.         { level: 'WARN', message: 'ÄÚ´æÊ¹ÓÃÂʹý¸ß', timestamp: new Date().getTime() - 3000000 },
  667.         { level: 'ERROR', message: 'Êý¾Ý¿âÁ¬½Óʧ°Ü', timestamp: new Date().getTime() - 2500000 },
  668.         { level: 'INFO', message: 'Êý¾Ý¿âÁ¬½Ó»Ö¸´', timestamp: new Date().getTime() - 2400000 },
  669.         { level: 'ERROR', message: 'APIÇëÇó³¬Ê±', timestamp: new Date().getTime() - 2000000 },
  670.         { level: 'WARN', message: 'APIÏìÓ¦»ºÂý', timestamp: new Date().getTime() - 1800000 },
  671.         { level: 'INFO', message: 'Óû§Ö´ÐвÙ×÷', timestamp: new Date().getTime() - 1500000 },
  672.         { level: 'DEBUG', message: '»º´æ¸üÐÂ', timestamp: new Date().getTime() - 1000000 }
  673.     ];
  674.    
  675.     // ·ÖÎö×î½üһСʱµÄÈÕÖ¾
  676.     var analysis = arrayUtils.analyzeLogs(logEntries, {
  677.         timeWindow: 3600000, // 1Сʱ
  678.         logLevelWeights: {
  679.             'ERROR': 10,
  680.             'WARN': 5,
  681.             'INFO': 1,
  682.             'DEBUG': 0.5
  683.         }
  684.     });
  685.    
  686.     printl("ÈÕÖ¾·ÖÎö½á¹û:");
  687.     printl("  ×ÜÈÕÖ¾Êý: " + analysis.totalLogs);
  688.     printl("  ´íÎóÂÊ: " + analysis.errorRate.toFixed(2) + "%");
  689.     printl("  ¾¯¸æÂÊ: " + analysis.warningRate.toFixed(2) + "%");
  690.     printl("  ÏµÍ³½¡¿µÆÀ·Ö: " + analysis.healthScore);
  691.     printl("  ÈÕÖ¾¼¶±ð·Ö²¼:");
  692.    
  693.     for (var level in analysis.levelDistribution) {
  694.         if (analysis.levelDistribution.hasOwnProperty(level)) {
  695.             printl("    " + level + ": " + analysis.levelDistribution[level]);
  696.         }
  697.     }
  698. }

  699. /**
  700. * UIÔªËØÅúÁ¿´¦ÀíʾÀý
  701. */
  702. function uiElementBatchProcessingExample() {
  703.     printl("\n=== UIÔªËØÅúÁ¿´¦ÀíʾÀý ===");
  704.    
  705.     var arrayUtils = new ArrayUtils();
  706.    
  707.     // Ä£ÄâUIÔªËØ
  708.     var uiElements = [
  709.         { id: 'btn1', type: 'button', text: 'Ìá½»', visible: true },
  710.         { id: 'btn2', type: 'button', text: 'È¡Ïû', visible: true },
  711.         { id: 'inp1', type: 'input', text: '', visible: true },
  712.         { id: 'inp2', type: 'input', text: '', visible: false },
  713.         { id: 'chk1', type: 'checkbox', text: 'ͬÒâÌõ¿î', visible: true },
  714.         { id: 'lbl1', type: 'label', text: 'Óû§Ð­Òé', visible: true },
  715.         { id: 'img1', type: 'image', text: '', visible: true }
  716.     ];
  717.    
  718.     // ´¦Àí¿É¼ûµÄ°´Å¥ÔªËØ
  719.     var visibleButtons = arrayUtils.smartFilter(uiElements, [
  720.         { field: 'visible', operator: '==', value: true },
  721.         { field: 'type', operator: '==', value: 'button' }
  722.     ]);
  723.    
  724.     printl("¿É¼û°´Å¥ÊýÁ¿: " + visibleButtons.length);
  725.    
  726.     // Ä£ÄâÅúÁ¿´¦Àí
  727.     arrayUtils.batchUIProcess(visibleButtons, function(element, index) {
  728.         try {
  729.             printl("  ´¦Àí°´Å¥ #" + (index+1) + ": " + element.text + " (ID: " + element.id + ")");
  730.             // ÕâÀï¿ÉÒÔÖ´ÐÐʵ¼ÊµÄUI²Ù×÷£¬Èçµã»÷¡¢ÐÞ¸ÄÊôÐÔµÈ
  731.         } catch (e) {
  732.             printl("  ´¦Àí°´Å¥Ê±³ö´í: " + e.message);
  733.         }
  734.     }, { batchSize: 2, delay: 500 });
  735. }

  736. //===========================================
  737. // Ö÷º¯ÊýºÍÖ´ÐÐÈë¿Ú
  738. //===========================================

  739. /**
  740. * ÔËÐÐËùÓÐʾÀý
  741. */
  742. function runAllExamples() {
  743.     try {
  744.         ecommerceDataProcessingExample();
  745.         ocrResultProcessingExample();
  746.         logAnalysisExample();
  747.         uiElementBatchProcessingExample();
  748.         printl("\n=== ËùÓÐʾÀýÖ´ÐÐÍê³É ===");
  749.     } catch (e) {
  750.         printl("Ö´ÐÐʾÀýʱ·¢Éú´íÎó: " + (e.message || e));
  751.     }
  752. }

  753. // Èç¹ûÖ±½ÓÔËÐд˽ű¾£¬ÔòÖ´ÐÐËùÓÐʾÀý
  754. if (typeof module === 'undefined' || !module.exports) {
  755.     runAllExamples();
  756. }

  757. // µ¼³öArrayUtilsÀ๩ÆäËûÄ£¿éʹÓÃ
  758. if (typeof module !== 'undefined' && module.exports) {
  759.     module.exports = ArrayUtils;
  760. }
¸´ÖÆ´úÂë


»Ø¸´

ʹÓõÀ¾ß ¾Ù±¨

±¾°æ»ý·Ö¹æÔò

¹Ø±Õ

QQ|»ÓªÏúÈí¼þ×ÛºÏÌÖÂÛ|»ÓªÏúÈí¼þÓÐÎʱشð|»ÓªÏúÈí¼þ½Ì³Ì×¨Çø|»ÓªÏúÈí¼þPOST½Å±¾·ÖÏí|»ÓªÏúÈí¼þÆÕͨ½Å±¾·ÖÏí|»ÓªÏúÈí¼þÈí¼þ×ÊѶ|»ÓªÏúÈí¼þ¾«Æ·Èí¼þ|»ÓªÏúÈí¼þ¸üй«¸æ|ÓªÏúÈí¼þ|B2BÈí¼þ|B2BÍøÂçÈí¼þ ( ¾©ICP±¸09078825ºÅ )±¾ÍøÕ¾¿ª·¢µÄÓªÏúÈí¼þÊÇÒ»¿îеÄÍøÂçÓªÏúÈí¼þ£¬Õâ¿îÓªÏú¿ÉÒÔÈ¥ÍøÕ¾Èí¼þ£¬²©¿ÍÈí¼þ£¬B2BÈí¼þ£¬·ÖÀàÐÅÏ¢Íø·¢Ìù£¬¿ÉÒÔÇÀɳ·¢£¬¿ÉÒÔµ½°Ù¶ÈÎÄ¿âÉÏ´«WORDÎĵµ£¬¿ÉÒÔµ½Ò»Ð©ÊÇÏà²áÍøÕ¾×Ô¶¯ÉÏ´«Í¼Æ¬£¬Õâ¸ö×Ô¶¯·¢ÌûÈí¼þ×Ô´øÔÆÖ©Ö룬¼Ó¿ìÊÕ¼£¬ÓÐ6ÖÖ¶Ô½Ó´òÂë½Ó¿Ú£¬·½±ã£¬Ð§Âʸߣ¬Ëٶȿ죬¶øÇÒ¶ÔÍ϶¯µÄÑéÖ¤ÂëÈ«ÍøµÚÒ»¼Ò¶À¼ÒÖ§³Ö£¬È«²¿Ô­´´¼¼Êõ£¬¶À¼ÒÑз¢£¬Õý°æÔ­´´´ø°æÈ¨Èí¼þ¡£Ñ¡ÔñÍòÄÜÓªÏúÈí¼þ£¬¾ÍÑ¡ÔñÁËÒ»ÖÖ׬ǮµÄЧÂÊ£¬´ÓûÓб»³¬Ô½¹ý£¬Ò»Ö±ÔÚŬÁ¦Ñз¢Ð¼¼Êõ¡£·Å·ÉÃÎÏ룬½â·ÅË«ÊÖ£¬À´µã´´Ò⣬³É¾ÍÄãµÄÃÎÏ룬¾ÍÔÚÍòÄÜÓªÏúÈí¼þ¿ªÊ¼

map2

GMT+8, 2025-11-21 02:14 , Processed in 0.179896 second(s), 32 queries .

¿ìËٻظ´ ·µ»Ø¶¥²¿ ·µ»ØÁбí