zhongzewei 6 лет назад
Родитель
Сommit
616a1757ed

+ 1 - 1
web/building_saas/main/js/models/exportStandardInterface.js

@@ -237,7 +237,7 @@ const XMLStandard = (function () {
         function SystemInfo(source) {
         function SystemInfo(source) {
             let attrs = [
             let attrs = [
                 {name: 'ID1', value: source.softInfo, required: true},
                 {name: 'ID1', value: source.softInfo, required: true},
-                {name: 'ID2', value: '', required: true},
+                {name: 'ID2', value: _util.generateHardwareId(), required: true},
                 {name: '生成时间', value: source.generatedTime, type: _config.TYPE.DATE_TIME, required: true},
                 {name: '生成时间', value: source.generatedTime, type: _config.TYPE.DATE_TIME, required: true},
             ];
             ];
             XML_EXPORT_BASE.Element.call(this, '系统信息', attrs);
             XML_EXPORT_BASE.Element.call(this, '系统信息', attrs);

+ 52 - 0
web/building_saas/main/js/models/exportStdInterfaceBase.js

@@ -352,6 +352,57 @@ const XML_EXPORT_BASE = (() => {
         }
         }
         return '';
         return '';
     }
     }
+
+    // 随机生成机器信息码:CPU信息;硬盘序列号;mac地址;
+    // 保存在localStorage中
+    function generateHardwareId() {
+        const hardwareCacheId = window.localStorage.getItem('hardwareId');
+        if (hardwareCacheId) {
+            return hardwareCacheId;
+        }
+        const charList = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D',
+            'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
+            'V', 'W', 'X', 'Y', 'Z'];
+        function generateCpuId() {
+            let id = '';
+            let count = 16;
+            while (count--) {
+                const randomIdx = parseInt(Math.random() * 16);
+                id += charList[randomIdx];
+            }
+            return id;
+        }
+        function generateDiskId() {
+            let id = '';
+            let count = 8;
+            while (count--) {
+                const randomIdx = parseInt(Math.random() * 36);
+                id += charList[randomIdx];
+            }
+            return id;
+        }
+        function generateMacId() {
+            const idList = [];
+            let outerCount = 6;
+            while (outerCount--) {
+                let tempId = '';
+                let innerCount = 2;
+                while (innerCount--) {
+                    const randomIdx = parseInt(Math.random() * 16);
+                    tempId += charList[randomIdx];
+                }
+                idList.push(tempId);
+            }
+            return idList.join('-');
+        }
+        const cpuId = generateCpuId();
+        const diskId = generateDiskId();
+        const macId = generateMacId();
+        const hardwareId = [cpuId, diskId, macId].join(';');
+        window.localStorage.setItem('hardwareId', hardwareId);
+        return hardwareId;
+    }
+
     // 数组打平成对象
     // 数组打平成对象
     function arrayToObj(arr) {
     function arrayToObj(arr) {
         let rst = {};
         let rst = {};
@@ -680,6 +731,7 @@ const XML_EXPORT_BASE = (() => {
         setTimeoutSync,
         setTimeoutSync,
         getFee,
         getFee,
         getValueByKey,
         getValueByKey,
+        generateHardwareId,
         arrayToObj,
         arrayToObj,
         validDepth,
         validDepth,
         checkUnique,
         checkUnique,