The article finally got back on track: faking data for mongodb.Previous random numbers, random license plates, random times, and Chinese strings of a specified length from this note are all preparations for this note.Take a look at our preparation (code base)
// 1,Gets a random number in a specified range-Include maximum and minimum values var getRangeRandomNumber = function(num1,num2){ num1 = Number.isInteger(num1) ? num1: 0; num2 = Number.isInteger(num2) ? num2: 0; var minNum=Math.min(num1,num2),maxNum=Math.max(num1,num2); return Math.round(Math.random() * (maxNum - minNum)) + minNum; }; // 2,Format Date Time-Reference resources: https://www.cnblogs.com/zhangpengshou/archive/2012/07/19/2599053.html var dateExtendFormat = function(date, format) { var o = { "M+": date.getMonth() + 1, "d+": date.getDate(), "H+": date.getHours(), "m+": date.getMinutes(), "s+": date.getSeconds(), "q+": Math.floor((date.getMonth() + 3) / 3), "S": date.getMilliseconds() } if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); } } return format; }; // 3,Get Random Time for a Specified Range, Dependent on Method getRangeRandomNumber,dateExtendFormat var getRangeRandomDate=function(date1,date2,format){ var date1ValueOf=new Date(date1).valueOf(),date2ValueOf=new Date(date2).valueOf(); if(isNaN(date1ValueOf)&&isNaN(date2ValueOf)){ date1ValueOf=0; date2ValueOf=new Date().valueOf(); } else{ if(isNaN(date1ValueOf))date1ValueOf=0; if(isNaN(date2ValueOf))date2ValueOf=0; } var retDate=new Date(getRangeRandomNumber(Math.abs(date1ValueOf-date2ValueOf)) + Math.min(date1ValueOf,date2ValueOf)); if(format){ retDate=dateExtendFormat(retDate,format); } return retDate; }; // 4,Get Random License Plates var getRandomLicensePlate=(function f(excludeArr){ if(!Array.isArray(excludeArr))excludeArr=[]; // Generate a random combined license plate var strProvinceShorter="Jing-Jin-Ji-Jin-Meng-Liao-Ji-Hei-Hu-Su-Zhejiang-Fujian-Fujian-Fujian-Hunan-Guangdong-Gui-Qian-Gui-Yun-Shan-Gan-Qing-Ning-Xin-Hong Kong-Macao-Taiwan"; var strNumberLetter="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var tempRetLicensePlate=strProvinceShorter[getRangeRandomNumber(strProvinceShorter.length-1)]; for(var i=0;i<6;i++){ tempRetLicensePlate+=strNumberLetter[getRangeRandomNumber(strNumberLetter.length-1)]; } // Determine if this license plate exists if(excludeArr.indexOf(tempRetLicensePlate)>=0){ tempRetLicensePlate = f(excludeArr); } else { excludeArr.push(tempRetLicensePlate); } return tempRetLicensePlate; }); // 5.0,Get a random Chinese character var getChineseCharacter=function(){ return String.fromCharCode(getRangeRandomNumber(parseInt("4E00",16),parseInt("9FA5",16))); }; // 5.1,Gets the Chinese string of the specified length var getCustomChineseCharacters=function(len){ len=isNaN(Number(len))?1:Math.abs(Math.ceil(Number(len))); var retStr=""; for(var i=0;i<len;i++){ retStr+=getChineseCharacter(); } return retStr; };
Now that everything is ready, let's get down to business.To make the data meaningful, I thought of three forms.This is the vehicle information table, the vehicle wear and tear table, and the vehicle revenue table. Here's a look at the structure of the three tables
Vehicle Information Table (FormId: 507048044944691000, FormVersion: 507048044944691001) |
||||
Unique Identification |
Chinese Description |
Control type |
Is it required |
Other configuration of form items (configuration at form design time, text box length, time format, etc.) |
1572493551001 |
Vehicle Brand Name |
Input |
yes |
|
1572493551002 |
Vehicle Brand Model |
Input |
yes |
|
1572493551003 |
license plates |
Input |
yes |
|
1572493551004 |
Vehicle Purchase Date |
Date Time |
no |
|
1572493551005 |
Vehicle Purchase Price |
Numeric Text Box |
no |
|
1572493551006 |
Remarks |
Multiline Text Box |
no |
Vehicle Information Table (FormId: 507048044944691000, FormVersion: 5070480444691002) |
||||
Unique Identification |
Chinese Description |
Control type |
Is it required |
Other configuration of form items (configuration at form design time, text box length, time format, etc.) |
1572493551001 |
Vehicle Brand Name |
Input |
yes |
|
1572493551002 |
Vehicle Brand Model |
Input |
yes |
|
1572493551003 |
license plates |
Input |
yes |
|
1572493551004 |
Vehicle Purchase Date |
Time Control |
no |
|
1572493551005 |
Vehicle Purchase Price |
Numeric Text Box |
no |
|
1572493551006 |
Remarks |
Multiline Text Box |
no |
|
...Business requirements, delete or add one or more fields to generate a new version number |
Vehicle Loss Table (FormId: 507048044944692000, FormVersion: 507048044944692001) |
||||
Unique Identification |
Chinese Description |
Control type |
Is it required |
Other configuration of form items (configuration at form design time, text box length, time format, etc.) |
1572493552001 |
Owned Vehicle |
Drop-down search control |
yes |
|
1572493552002 |
Wasting personnel |
Select Person Control |
yes |
|
1572493552003 |
Wasting time |
Time Control |
yes |
|
1572493552004 |
Loss category |
Input |
yes |
|
1572493552005 |
Consumption amount |
Numeric Text Box |
yes |
|
1572493552006 |
Remarks |
Multiline Text Box |
no |
Vehicle Revenue Table (FormId: 507048044944693000, FormVersion: 5070480444693001) |
||||
Unique Identification |
Chinese Description |
Control type |
Is it required |
Other configuration of form items (configuration at form design time, text box length, time format, etc.) |
1572493553001 |
Owned Vehicle |
Drop-down search control |
yes |
|
1572493553002 |
Revenue earners |
Select Person Control |
yes |
|
1572493553003 |
Revenue Time |
Time Control |
yes |
|
1572493553004 |
Revenue category |
Input |
yes |
|
1572493553005 |
Revenue amount |
Numeric Text Box |
yes |
|
1572493553006 |
mileage |
Numeric Text Box |
no |
|
1572493553007 |
Remarks |
Multiline Text Box |
no |
* Now we'll fake the data according to the table structure. Here's the full code (which can be executed in the Mongodb environment)
Fake data// 1,Gets a random number in a specified range-Include maximum and minimum values var getRangeRandomNumber = function(num1,num2){ num1 = Number.isInteger(num1) ? num1: 0; num2 = Number.isInteger(num2) ? num2: 0; var minNum=Math.min(num1,num2),maxNum=Math.max(num1,num2); return Math.round(Math.random() * (maxNum - minNum)) + minNum; }; // 2,Format Date Time-Reference resources: https://www.cnblogs.com/zhangpengshou/archive/2012/07/19/2599053.html var dateExtendFormat = function(date, format) { var o = { "M+": date.getMonth() + 1, "d+": date.getDate(), "H+": date.getHours(), "m+": date.getMinutes(), "s+": date.getSeconds(), "q+": Math.floor((date.getMonth() + 3) / 3), "S": date.getMilliseconds() } if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) { if (new RegExp("(" + k + ")").test(format)) { format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); } } return format; }; // 3,Get Random Time for a Specified Range, Dependent on Method getRangeRandomNumber,dateExtendFormat var getRangeRandomDate=function(date1,date2,format){ var date1ValueOf=new Date(date1).valueOf(),date2ValueOf=new Date(date2).valueOf(); if(isNaN(date1ValueOf)&&isNaN(date2ValueOf)){ date1ValueOf=0; date2ValueOf=new Date().valueOf(); } else{ if(isNaN(date1ValueOf))date1ValueOf=0; if(isNaN(date2ValueOf))date2ValueOf=0; } var retDate=new Date(getRangeRandomNumber(Math.abs(date1ValueOf-date2ValueOf)) + Math.min(date1ValueOf,date2ValueOf)); if(format){ retDate=dateExtendFormat(retDate,format); } return retDate; }; // 4,Get Random License Plates var getRandomLicensePlate=(function f(excludeArr){ if(!Array.isArray(excludeArr))excludeArr=[]; // Generate a random combined license plate var strProvinceShorter="Jing-Jin-Ji-Jin-Meng-Liao-Ji-Hei-Hu-Su-Zhejiang-Fujian-Fujian-Fujian-Hunan-Guangdong-Gui-Qian-Gui-Yun-Shan-Gan-Qing-Ning-Xin-Hong Kong-Macao-Taiwan"; var strNumberLetter="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var tempRetLicensePlate=strProvinceShorter[getRangeRandomNumber(strProvinceShorter.length-1)]; for(var i=0;i<6;i++){ tempRetLicensePlate+=strNumberLetter[getRangeRandomNumber(strNumberLetter.length-1)]; } // Determine if this license plate exists if(excludeArr.indexOf(tempRetLicensePlate)>=0){ tempRetLicensePlate = f(excludeArr); } else { excludeArr.push(tempRetLicensePlate); } return tempRetLicensePlate; }); // 5.0,Get a random Chinese character var getChineseCharacter=function(){ return String.fromCharCode(getRangeRandomNumber(parseInt("4E00",16),parseInt("9FA5",16))); }; // 5.1,Gets the Chinese string of the specified length var getCustomChineseCharacters=function(len){ len=isNaN(Number(len))?1:Math.abs(Math.ceil(Number(len))); var retStr=""; for(var i=0;i<len;i++){ retStr+=getChineseCharacter(); } return retStr; }; // Insert Data Method var handleBatchInsertData=function(initConfig){ if(initConfig.formId&&initConfig.formVersion&&Array.isArray(initConfig.source)&&initConfig.source.length){ var tempTrs=[], tempCreateDate=ISODate(), tempFormInstaceDataCounter=db.getCollection('FormInstace').find({}).count(); initConfig.source.forEach((formItemObj)=>{ var tempCreateUserIdIndex = Math.floor(Math.random() * GV_CreateUserIds.length); var tempTr={ _id:(++tempFormInstaceDataCounter).toString(), FormItems:[], ExtendData:{}, CreateUserId:GV_CreateUserIds[tempCreateUserIdIndex], CreateUserName:GV_CreateUserIds[tempCreateUserIdIndex], CreateDate:tempCreateDate, LastModifyDate:tempCreateDate, FormId:initConfig.formId, FormVersion:initConfig.formVersion }; for(var i in formItemObj){ if (formItemObj.hasOwnProperty(i)){ tempTr.FormItems.push({key:i,value:formItemObj[i]}); } } tempTrs.push(tempTr); }); try{ db.FormInstace.insertMany(tempTrs); }catch(e){ print(e); } } }; // Create a user collection var GV_CreateUserIds = ["user10000","user10001","user10002","user10003","user10004","user10005","user10006","user10007","user10008","user10009"]; // Vehicle Information Table Insert Data Configuration var GV_CarInfoInitConfig = { formId:"507048044944691000", formVersion:"507048044944691001", carTypes:[ { brandName:"red flag", models:[ {name:"HS7",min:349800,max:459800}, {name:"HS5",min:183800,max:249800}, {name:"H7",min:252800,max:317800}, {name:"H5",min:146800,max:190800}, {name:"HE-HS3",min:225800,max:317800} ] }, { brandName:"BYDI", models:[ {name:"element",min:65900,max:99900}, {name:"Song",min:79800,max:119800}, {name:"Song Pro",min:89800,max:119800}, {name:"Tang",min:129900,max:169900}, {name:"BYDI F3",min:43900,max:65900}, {name:"Quick and sharp",min:59900,max:69900}, {name:"Qin Dynasty Pro",min:79800,max:115900}, {name:"Song MAX",min:79900,max:129900}, {name:"element EV",min:89900,max:139900}, {name:"BYDI S2",min:89800,max:109800}, {name:"Song DM",min:176900,max:206900}, {name:"Song Pro DM",min:169800,max:259900}, {name:"Song EV",min:189900,max:219900}, {name:"Song Pro EV",min:179800,max:259900}, {name:"Tang DM",min:229900,max:329900}, {name:"Tang EV",min:259900,max:409900}, {name:"BYDI e1",min:59900,max:79900}, {name:"BYDI e2",min:89800,max:119800}, {name:"BYDI e3",min:103800,max:139800}, {name:"Qin Dynasty DM",min:132900,max:209900}, {name:"Qin Dynasty Pro DM",min:136900,max:206900}, {name:"Qin Dynasty EV",min:149900,max:169900}, {name:"Qin Dynasty Pro EV",min:149900,max:299900}, {name:"Song MAX DM",min:149900,max:196900}, {name:"Song MAX EV",min:179800,max:199800} ] }, { brandName:"Chery", models:[ {name:"Ruihu 3",min:59900,max:79900}, {name:"Ruihu 3 x",min:49900,max:62900}, {name:"Ruihu 5 x",min:59900,max:89900}, {name:"Ruihu 7",min:85900,max:150900}, {name:"Ruihu 8",min:88800,max:155900}, {name:"Irezer 5",min:49900,max:84900}, {name:"Irezer GX",min:74900,max:113900}, {name:"Ruihu 3 xe",min:175800,max:189800}, {name:"Ruihu e",min:109900,max:143900}, {name:"Chery eQ1",min:59800,max:75800}, {name:"Irezer e",min:126800,max:143800}, {name:"Irezer 5 e",min:192300,max:212300} ] }, { brandName:"Auspicious", models:[ {name:"Prospect X1",min:39900,max:57900}, {name:"Prospect X3",min:45900,max:68900}, {name:"Wandering",min:78800,max:129800}, {name:"Prospect S1",min:59900,max:94900}, {name:"Prospect X6",min:68900,max:105900}, {name:"Dihao GS",min:77800,max:116800}, {name:"Boyue",min:88800,max:161800}, {name:"Star Crossing",min:135800,max:195800}, {name:"Peter Jackson's King Kong",min:47900,max:65900}, {name:"Prospect",min:47900,max:73900}, {name:"Dihao",min:68900,max:98800}, {name:"Dihao GL",min:78800,max:121800}, {name:"Murray",min:75800,max:110800}, {name:"Borry",min:136800,max:179800}, {name:"Jiajie",min:99800,max:148800}, {name:"Wandering PHEV",min:149800,max:169800}, {name:"Dihao GSe",min:119800,max:159800}, {name:"Star Crossing PHEV",min:188800,max:216800}, {name:"Dihao EV",min:135800,max:238300}, {name:"Dihao PHEV",min:165800,max:185800}, {name:"Dihao GL PHEV",min:152800,max:164800}, {name:"Borry PHEV",min:176800,max:209800}, {name:"Jiajie PHEV",min:169800,max:192800} ] }, { brandName:"Chang'an", models:[ {name:"Chang'an CS15",min:55900,max:80900}, {name:"Chang'an CS35",min:63900,max:87900}, {name:"Chang'an CS35 PLUS",min:69900,max:109900}, {name:"Chang'an CS55",min:82900,max:133900}, {name:"Chang'an CS75",min:79800,max:174800}, {name:"Chang'an CS75 PLUS",min:106900,max:154900}, {name:"Chang'an CS85 COUPE",min:119900,max:169900}, {name:"Chang'an CS95",min:165900,max:213900}, {name:"Running",min:40900,max:56900}, {name:"ALSVIN",min:49900,max:67900}, {name:"Escape DT",min:52900,max:80900}, {name:"Escape XT",min:77900,max:111900}, {name:"Escape",min:69900,max:103900}, {name:"Raeton CC",min:84900,max:135900}, {name:"Sharp Range CC",min:94900,max:128900}, {name:"Raeton",min:120800,max:150800}, {name:"Ling Xuan",min:67900,max:110900}, {name:"Chang'an CS15 EV",min:89800,max:98800}, {name:"Chang'an CS75 PHEV",min:175800,max:206800}, {name:"Running EV",min:49800,max:81800}, {name:"Escape ET",min:132900,max:142900}, {name:"Escape PHEV",min:160900,max:169900}, {name:"Escape EV",min:129900,max:139900}, ] }, { brandName:"Chang'an Ocean", models:[ {name:"Chang'an Ozanco Sai 3",min:59900,max:76900}, {name:"Chang'an Ozanco Sai 5",min:69900,max:82900}, {name:"Chang'an Ocean X70A",min:49900,max:859500}, {name:"Chang'an Ocean CX70",min:59900,max:109900}, {name:"Chang'an Oshankosai",min:86800,max:152800}, {name:"Auchan S",min:39900,max:55900}, {name:"Ou Shang Long Line",min:68900,max:82900}, {name:"Chang'an Ocean A600",min:49900,max:84900}, {name:"Chang'an Ocean A800",min:62900,max:100900}, {name:"Chang'an Ozankosan",min:79800,max:160800}, {name:"Chang'an Star 9",min:47800,max:48800}, {name:"Chang'an Star Card",min:32900,max:47900}, {name:"NeoⅡ",min:88800,max:100800}, {name:"Oliver EV",min:105800,max:105800}, {name:"Oeno S EV",min:175800,max:175800}, {name:"Ou Shang Long Line EV",min:169800,max:169800}, {name:"Auchan EV",min:169800,max:169800}, {name:"Auchan A600 EV",min:149800,max:149800}, {name:"Chang'an Star 9 EV",min:152800,max:156000}, {name:"Chang'an Star Card EV",min:123800,max:125800}, ] }, { brandName:"Chang'an Lightweight Car", models:[ {name:"Ruixing S50",min:48900,max:77900}, {name:"Ruixing S50T",min:61900,max:78900}, {name:"Ruixing M60",min:51900,max:59900}, {name:"Ruixing M70",min:60500,max:74000}, {name:"Ruixing M80",min:58500,max:72000}, {name:"Ruixing M90",min:68500,max:92500}, {name:"Piston F30",min:47600,max:63800}, {name:"Piston T10",min:39900,max:50900}, {name:"Piston T20",min:33900,max:59700}, {name:"Kaicheng F70",min:92800,max:139800}, {name:"Chang'an Star Card L series",min:39900,max:47900}, {name:"Chang'an Star Card C series",min:30900,max:33600}, {name:"Ruixing ES30",min:66800,max:69800}, {name:"Ruixing EM60",min:122800,max:122800}, {name:"Ruixing EM80",min:96800,max:120000} ] }, { brandName:"Chang'an Crossing", models:[ {name:"Chang'an Crossing V3",min:33500,max:34300}, {name:"Crossing King X1",min:39600,max:51800}, {name:"Crossing King X3",min:45700,max:58400}, {name:"Chang'an Crossing King X5",min:47400,max:65600}, {name:"Chang'an New Leopard 2",min:40700,max:58600}, {name:"New Leopard 3",min:46200,max:59900}, {name:"New Leopard T3",min:41300,max:51800}, {name:"Chang'an New Leopard MINI",min:32100,max:50500}, {name:"Crossover D5",min:59300,max:67700}, {name:"Chang'an Spans New Energy V3 EV",min:79200,max:79200}, {name:"Chang'an Spans New Energy V5 EV",min:93800,max:93800} ] }, { brandName:"Lifan", models:[ {name:"Maiev",min:56800,max:73800}, {name:"Lifan X80",min:109900,max:149900}, {name:"Lifan 820",min:76800,max:119800}, {name:"Xuan Long",min:69800,max:106800}, {name:"Fun",min:35800,max:59800}, {name:"Lifan 650 EV",min:168900,max:175800}, {name:"Lifan 820 EV",min:256800,max:279800} ] }, { brandName:"The Great Wall", models:[ {name:"Fengjun 5",min:68800,max:112800}, {name:"Fengjun 6",min:86800,max:117800}, {name:"Fengjun 7",min:86800,max:138800}, {name:"cannon",min:97800,max:159800}, {name:"The Great Wall C30 EV",min:150000,max:154000} ] }, { brandName:"Harvard", models:[ {name:"Harvard H2",min:74900,max:95900}, {name:"Harvard H2s",min:70000,max:85000}, {name:"Harvard H4",min:73900,max:115000}, {name:"Harvard F5",min:100000,max:130000}, {name:"Harvard H5",min:107800,max:136800}, {name:"Harvard M6",min:66000,max:82000}, {name:"Harvard H6",min:102000,max:136000}, {name:"Harvard H6 Coupe",min:79900,max:119000}, {name:"Harvard H7",min:142000,max:180000}, {name:"Harvard F7",min:109000,max:153700}, {name:"Harvard F7x",min:119900,max:154900}, {name:"Harvard H9",min:209800,max:272800}, ] }, { brandName:"Jiangling", models:[ {name:"Treasure Books",min:78800,max:105300}, {name:"Kairui 800",min:120800,max:129100}, {name:"Carnival Powerful Edition",min:99500,max:117400}, {name:"Carnival Upgrade",min:94800,max:106800}, {name:"Cis-da-wide",min:90800,max:100000}, {name:"Shunda Narrow Body",min:84000,max:89000}, {name:"Teshun",min:101300,max:142700}, {name:"Domain tiger 3",min:89800,max:122200}, {name:"Domain tiger 5",min:96800,max:136300}, {name:"Domain tiger 7",min:119800,max:176300}, {name:"Jiangling E100B",min:73800,max:73800}, {name:"Jiangling E160",min:95800,max:98800}, {name:"Jiangling E200L",min:87800,max:90800}, {name:"Jiangling E200N",min:90800,max:93800}, {name:"Easy access EV3",min:66800,max:83800}, {name:"Easy access EX5",min:89800,max:122800}, {name:"Teshun EV",min:206000,max:206000}, {name:"Pigtail T5",min:65800,max:86800}, {name:"Pigtail T7",min:72800,max:113800}, {name:"Pigtail T100",min:53800,max:71800}, {name:"D-MAX Touring car",min:283000,max:396000}, {name:"Corst RV",min:318000,max:380000}, {name:"Residence Car",min:536000,max:596000}, {name:"Rosa RV Rental",min:268000,max:288000}, {name:"Pigtail T7 Pickup truck",min:258000,max:299800}, {name:"Quanshun Business Hotel",min:468000,max:518000}, {name:"Quanshun T Type V RV",min:408000,max:448000}, {name:"Business RV",min:438000,max:488000}, {name:"Classic Bus RV",min:388000,max:428000}, {name:"Touruiu Business Vehicle",min:298000,max:398000} ] }, ], source:[] }; var GV_TempCarLicensePlates=[]; GV_CarInfoInitConfig.carTypes.forEach((carType)=>{ if(Array.isArray(carType.models)&&carType.models.length){ carType.models.forEach((model)=>{ for(var i=0;i<getRangeRandomNumber(10,100);i++){ var tempPlate = getRandomLicensePlate(GV_TempCarLicensePlates); GV_CarInfoInitConfig.source.push({ "1572493551001":carType.brandName, "1572493551002":model.name, "1572493551003":tempPlate, "1572493551004":getRangeRandomDate("2010-01-01","2018-06-06","yyyy-MM-dd HH:mm:ss"), "1572493551005":getRangeRandomNumber(model.min,model.max), "1572493551006":getCustomChineseCharacters(getRangeRandomNumber(200)) }); } }); } }); // Vehicle Expense Table Insert Data Configuration var GV_CarWastageInitConfig = { formId:"507048044944692000", formVersion:"507048044944692001", wastageType:[ {text:"Violations",detailed:["Signal light","Line pressing","Single and Double Sign","Direction Driving","Avoid Special Vehicles","Give Way To Pedestrians","Time Road Ban"]}, {text:"Car Wash",detailed:["full set","peripheral"]}, {text:"Garage",detailed:["tyre","Front glass","Rear glass","Cushion","Headlight","Rear headlight","Car window","Engine","Battery","Transmission case"]}, {text:"Come on.",detailed:["92","93","95","97"]}, {text:"Insurance",detailed:["The Pacific Ocean","Safety","life insurance","Taikang"]}, {text:"Cause an accident",detailed:["Injuries","guardrail","Car crash","Indirect accidents","Other"]} ], source:[] }; // Vehicle Revenue Table Insert Data Configuration var GV_CarRevenueInitConfig = { formId:"507048044944693000", formVersion:"507048044944693001", revenueTypes:[ {text:"Lease",detailed:["one day","a week","January","A year"]}, {text:"Carry passenger",detailed:["Offline","sound of dripping water","Uber","Fast","Other"]}, {text:"Delivery",detailed:["Mobile phone","Notebook","Camera","Microwave Oven","Electromagnetic Rate","Other"]}, {text:"Other",detailed:["Wedding car","Other"]} ], source:[] }; if(GV_CarInfoInitConfig.source.length){ GV_CarInfoInitConfig.source.forEach((carInfo,carInfoIndex)=>{ for(var i=0;i<getRangeRandomNumber(50,100);i++){ var tempUserIdIndexWastageType = getRangeRandomNumber(GV_CreateUserIds.length-1); var tempWastageTypeIndex = getRangeRandomNumber(GV_CarWastageInitConfig.wastageType.length-1); var tempWastageTypeDetailIndex = getRangeRandomNumber(GV_CarWastageInitConfig.wastageType[tempWastageTypeIndex].detailed.length-1); GV_CarWastageInitConfig.source.push({ "1572493552001": { id: carInfoIndex.toString(), name: carInfo["1572493551003"], value: "" }, "1572493552002": [{id:GV_CreateUserIds[tempUserIdIndexWastageType],name:GV_CreateUserIds[tempUserIdIndexWastageType],face:""}], "1572493552003": getRangeRandomDate(carInfo["1572493551004"],"2019-11-07","yyyy-MM-dd HH:mm:ss"), "1572493552004": GV_CarWastageInitConfig.wastageType[tempWastageTypeIndex].text, "1572493552005": getRangeRandomNumber(20,10000), "1572493552006": GV_CarWastageInitConfig.wastageType[tempWastageTypeIndex].detailed[tempWastageTypeDetailIndex] }); } for(var i=0;i<getRangeRandomNumber(100,200);i++){ var tempUserIdIndexRevenue = getRangeRandomNumber(GV_CreateUserIds.length-1); var tempRevenueIndex = getRangeRandomNumber(GV_CarRevenueInitConfig.revenueTypes.length-1); var tempRevenueDetailIndex = getRangeRandomNumber(GV_CarRevenueInitConfig.revenueTypes[tempRevenueIndex].detailed.length-1); GV_CarRevenueInitConfig.source.push({ "1572493553001": { id: carInfoIndex.toString(), name: carInfo["1572493551003"], value: "" }, "1572493553002": [{id:GV_CreateUserIds[tempUserIdIndexRevenue],name:GV_CreateUserIds[tempUserIdIndexRevenue],face:""}], "1572493553003": getRangeRandomDate(carInfo["1572493551004"],"2019-11-07","yyyy-MM-dd HH:mm:ss"), "1572493553004": GV_CarRevenueInitConfig.revenueTypes[tempRevenueIndex].text, "1572493553005": getRangeRandomNumber(20,10000), "1572493553006": getRangeRandomNumber(50,3000), "1572493553007": GV_CarRevenueInitConfig.revenueTypes[tempRevenueIndex].detailed[tempRevenueDetailIndex] }); } }); } handleBatchInsertData(GV_CarInfoInitConfig); handleBatchInsertData(GV_CarWastageInitConfig); handleBatchInsertData(GV_CarRevenueInitConfig);