//equivalent to calling the same interface three times with different parameters,
let arr1 = [];
newArray.forEach((v, index) => {
let sqlParams = `select * from alarm_center_info where 1=1 and model_name = '${v.newModel}' and period_time <= '${v.newTime}' and period_time > '${v.minTime}'`;
arr1[index] = req(sqlParams);
});
let firstData = [];
let secondData = [];
let threedData = [];
Promise.all(arr1).then(function(data) {
//data return array object [0:{...},1:{..},2:{..}]
//distinguish three different types of data based on a specific field in the object
data.forEach(item => {
if (item.rows.length !== 0) {
item.rows.forEach(v => {
if (
v.model_name == 'first'
) {
firstData.push(v);
} else if (
v.model_name == 'tow'
) {
secondData.push(v);
} else if (v.model_name == 'three') {
threedData.push(v);
}
});
}
})
console.log(firstData, 'three different types of data', secondData, threedData);
//return results [{object},{object},{object}.....],[{object}....],[{object},{object}.....]
function findDuplicateObjects(arr) {
//based on a specific field within each object( min_name )determine if there is duplicate data
let newArr = [];
arr.forEach(item => {
//findIndex the () method returns the position of the first element of an array that meets the passed test condition (function). call the function once for each element in the array to execute
//when the elements in the array are tested under certain conditions, return true when, findIndex () returns the index position of the element that meets the criteria, and subsequent values will not be called to execute the function.
//if there are no eligible elements, return -1
let newArrIndex = newArr.findIndex(v => v.name === item.min_name);
if (newArrIndex === -1) {
let newArrObj = arr.filter(v => v.name == item.min_name);
newArr.push({ name: item.min_name, value: newArrObj });
}
});
return newArr;
}
let oneRepeatList = findDuplicateObjects(firstData);
let towRepeatList = findDuplicateObjects(secondData);
let threeRepeatList = findDuplicateObjects(threedData);
console.log(oneRepeatList,towRepeatList, threeRepeatList, '1111',);
//return results :oneRepeatList:[
{ name:'1',value:[ { id:'1',name:'1',time:'2023-12-09'},{ id:'2',name:'1',time:'2023-01-09'},{},{},{}.....]},
{{ name:'2',value:[ { id:'0021',name:'1',time:'2023-10-09'},{ id:'2',name:'1',time:'2023-01-09'},{},{},{}.....},
{{ name:'3',value:[ { id:'3331',name:'1',time:'2023-12-09'},{ id:'3332',name:'1',time:'2023-06-09'},{},{},{}.....}
....
]
})
Related articles
- What are the performance differences between the string and varchar data types in hive
- Structured Streaming writes data to MySQL and Kafka
- Unity takes 3 minutes to understand the difference between batch processing and drawcall
- ZTree+Java backend data retrieval (including asynchronous) to generate a tree diagram
- QR code: Data Matrix and QRCode
- Opencv cv:: Mat Data Type Summary
Storing data archivedDataWithRootObject unarchiveObject WithData - How to set Rquest Body and Header to application/JSON format in Ajax
- Convert int type data to torch. cuda. FloatTensor type data
- Python reads data from MySQL and SQL Server
- 2022 CCF BDCI Small Sample Data Classification Task Baseline
- Python 3 Obtaining Zabbix API Data
- Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/ear"
- Batch reading of folder names, file names, and file data using MATLAB
- When inserting a piece of data into the MySql database, create_The time field is automatically added as the current time
- Write data to an Excel file using MATLAB xlswrite
- Missing Excel source file inserted in PPT, extracting data from image
- FPGA Digital Image Processing Grayscale Transformation Vivado Transferring Image Data Verilog
- FPGA image processing VGA temporal edge detection - sobel operator verilog
Latest articles
- Ubuntu decompresses the tar.gz format file
- Ubuntu's XDMCP login to ubuntu desktop crashes
- RunTime Error: cuda out of memory
- Ffmpeg converts a frame from yuv444 format to png format
- Notepad++Theme Change, Highlighting Selected Content
- Record: easycr Error: Could not initialize NNPACK reason Unsupported hardware causing Python program to exit abnormally
- Streamlit installation error resolution
- Resolving Warning for Ignoring Invalid Distribution
- Matplotlib ImportError: DLL load failed: Unable to find specified module
- Python: can't open file '
': [Errno 22] Invalid argument - Executable NotFound: failed to execute 'dot', make sure the Graphviz executors are on your systems'
- Python dictionary application
- Cv2. error: OpenCV (4.5.5) D: a opencv Python opencv Python opencv modules imgproc src imgwarp. cpp: 66
- Python drawing based on f (x) (2D)
- The interval for drawing a histogram in Python must be a saturation integral interval
- PLT.bar Drawing Rules - Taking Drawing Histograms as an Example
- Sort and remove duplicate numbers in C language
- Summary of pedestrian re identification paper
- Unable to boot up when memory is full (Ubuntu)
- Java Spark code error: java. lang. NoSuchMethodError: net. jpuntz. lz4. LZ4BlockInputStream
Hot tags:
java python linux javascript using error android vue.js solution mysql data vue file c++ windows installation configuration c ubuntu method implementation between spring function project spring-boot server system sql database issue c# springboot html docker oracle idea environment command version methods image process resolve uses network excel failed time display