SOURCE

let array = [{
    "jkb": "0",
    "code": "0",
    "flag": "常驻",
    "passTime": "2022-03-27 11:33:45",
    "hs": "2022-03-28 阴性",
    "message": " 健康宝未见异常",
    "userName": "",
    "userId": "8b625ab4-2afa-46c9-860c-8f3ae6a291d8",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3620,
    "company": "北京博奥晶典生物技术有限公司"
},
{
    "jkb": "31",
    "code": "0",
    "flag": "常驻",
    "passTime": "2022-03-27 11:33:45",
    "hs": "2022-03-28 阴性",
    "message": " 健康宝未见异常",
    "userName": "",
    "userId": "8b625ab4-2afa-46c9-860c-8f3ae6a291d8",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3620,
    "company": "北京博奥晶典生物技术有限公司"
},
{
    "jkb": "0",
    "code": "1",
    "flag": "常驻",
    "passTime": "2022-03-28 11:33:52",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.6℃",
    "userName": "",
    "userId": "535bc5fd-42ed-4a11-9341-67568d394d22",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3660,
    "company": "尚健单抗(北京)生物技术有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "常驻",
    "passTime": "2022-03-29 14:42:21",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.3℃",
    "userName": "",
    "userId": "fbc23737-32bf-4eb6-9da1-af30471ca7e2",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3630,
    "company": "安诺优达基因科技(北京)有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "常驻",
    "passTime": "2022-03-29 14:42:25",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.2℃",
    "userName": "",
    "userId": "47738166-a8cf-48f9-8a33-79edc3d9b914",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3620,
    "company": "尚健单抗(北京)生物技术有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "常驻",
    "passTime": "2022-03-30 09:58:23",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.6℃",
    "userName": "",
    "userId": "f0490780-3f7b-4a32-ac55-f6095f81707b",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3660,
    "company": "安诺优达基因科技(北京)有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "常驻",
    "passTime": "2022-03-30 09:58:28",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.7℃",
    "userName": "",
    "userId": "36903249-0d2a-4be2-ba30-2e0aa0fc42d3",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3670,
    "company": "安诺优达基因科技(北京)有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "常驻",
    "passTime": "2022-03-30 09:58:34",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.1℃",
    "userName": "",
    "userId": "623810f2-e5d0-4a3c-b5dc-74b341da4bdf",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3610,
    "company": "尚健单抗(北京)生物技术有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "访客",
    "passTime": "2022-03-30 10:00:27",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.6℃",
    "userName": "",
    "userId": "210fe268-dcfe-4cdc-af30-47072733d680",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3660,
    "company": "安诺优达基因科技(北京)有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "常驻",
    "passTime": "2022-03-31 13:56:04",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.3℃",
    "userName": "",
    "userId": "0da92c42-0814-469d-91b2-388813e090e7",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3630,
    "company": "安诺优达基因科技(北京)有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "常驻",
    "passTime": "2022-03-31 14:19:31",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.4℃",
    "userName": "夏炎炎",
    "userId": "91ee6ac6-8f77-4308-a5dd-19b93f306b63",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3640,
    "company": "北京加美康联医疗科技有限责任公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "常驻",
    "passTime": "2022-03-31 14:30:47",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 36.4℃",
    "userName": "张照照",
    "userId": "3bb616fc-a097-4bcd-841a-16bdf14d0df5",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3640,
    "company": "尚健单抗(北京)生物技术有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "访客",
    "passTime": "2022-04-01 15:17:47",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 35.9℃",
    "userName": "",
    "userId": "0693e7f6-56ac-41c5-98fc-8779a81f4382",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3590,
    "company": "安诺优达基因科技(北京)有限公司"
},
{
    "jkb": "31",
    "code": "1",
    "flag": "访客",
    "passTime": "2022-04-02 15:17:47",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 35.9℃",
    "userName": "",
    "userId": "0693e7f6-56ac-41c5-98fc-8779a81f4382",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3590,
    "company": "安诺优达基因科技(北京)有限公司"
}
    ,
{
    "jkb": "0",
    "code": "1",
    "flag": "访客",
    "passTime": "2022-04-02 15:17:47",
    "hs": "2022-03-28 阴性",
    "message": " 认证失败 35.9℃",
    "userName": "",
    "userId": "0693e7f6-56ac-41c5-98fc-8779a81f4382",
    "mach_id": "118F010T00200031",
    "passPosition": "",
    "ym": "3",
    "temperature": 3590,
    "company": "安诺优达基因科技(北京)有限公司"
}
]

// console.log(array)
const companyArr = array.map(item => {
    let a = item.passTime.split(' ')[0].split('-')
    return a[1] + '-' + a[2]
})
let set = new Set(companyArr)
let xList = [...set]

// console.log(xList)

// for (let index = 0; index < array.length; index++) {
//     let a = array[index].passTime.split(' ')[0].split('-')
//     let time = a[1] + '-' + a[2]
//     let j = 0
//     for (let i = 0; i < xList.length; i++) {

//         if (xList[i] == time) {
//             newArr[index].passTime = xList[i]
//             newArr.push(array[index])
//         } else {
//             // console.log(j)
//             if (j < 1) {
//                 newArr[index].passTime = xList[i]
//                 newArr.push(array[index])
//                 j++
//             }

//         }

//     }
// }

const arr2 = array.map(item => {
    let a = item.passTime.split(' ')[0].split('-')
    return a[1] + '-' + a[2]
})
console.log(arr2, 'cccc')

let newArr = []

for (let index = 0; index < array.length; index++) {
    let a = array[index].passTime.split(' ')[0].split('-')
    let time = a[1] + '-' + a[2]
    array[index].passTime = time
    newArr.push(array[index])
}

console.log(newArr, 'newArr')

let countList = []
for (let index = 0; index < 2; index++) {

    for (let i = 1; i < newArr.length; i++) {
        let k = 0;
        if (newArr[index].passTime == newArr[i].passTime && newArr[index].jkb != '0') {
            k++
            console.log(k,'k--')
            countList[index] = k
            console.log(newArr[index].passTime, newArr[i].passTime)
        } else {
            countList[index] = 0
            console.log(k,'----')
           unique;
        }

    }
    // countList.push(k)
}
console.log(countList)

// let quchongList = []
// function getData(data) {
//     let map = new Map()
//     data.forEach(e => {
//         let day = e.passTime
//         map.set(day+e.jkb != '0' && e.jkb!= '10' && e.jkb != '20' && e.jkb != '30', e)
//     })
//     quchongList = [...map.values()]

// }

// getData(newArr)

// console.log(quchongList,'quchongList')
// for (let j = 0; j < quchongList.length; j++) {
//     if (quchongList[j].jkb != '0' && quchongList[j].jkb != '10' && quchongList[j].jkb != '20' && quchongList[j].jkb != '30') {

//     }
//     else{
//         console.log(quchongList[j].passTime)
//         list[j]=0
//     }
// }

// console.log(list,'最终')
console 命令行工具 X clear

                    
>
console