# statusstart statusend statusname
2020-08-25 07:00:24 2020-08-25 07:00:24 MICRO STOP
2020-08-25 07:00:24 2020-08-25 07:02:24 UNKNOWN STATUS
2020-08-25 07:02:24 2020-08-25 07:04:24 UNKNOWN STATUS
2020-08-25 07:04:24 2020-08-25 07:06:24 UNKNOWN STATUS
2020-08-25 07:06:24 2020-08-25 07:08:24 UNKNOWN STATUS
2020-08-25 07:08:24 2020-08-25 07:10:24 UNKNOWN STATUS
2020-08-25 07:10:24 2020-08-25 07:12:24 UNKNOWN STATUS
2020-08-25 07:12:24 2020-08-25 07:15:24 UNKNOWN STATUS
2020-08-25 07:15:24 2020-08-25 07:16:10 PRODUCTION
2020-08-25 07:16:10 2020-08-25 07:17:00 PRODUCTION
2020-08-25 07:17:00 2020-08-25 07:18:00 MICRO STOP
2020-08-25 07:18:00 2020-08-25 07:19:00 UNKNOWN STATUS
我想输出这样的数组:
[['MICRO STOP', 2020-08-25 07:00:24, 2020-08-25 07:00:24],
['UNKNOWN STATUS', 2020-08-25 07:00:24, 2020-08-25 07:15:24],
['PRODUCTION', '2020-08-25 07:15:24', '2020-08-25 07:17:00'],
['MICRO STOP', '2020-08-25 07:17:00', '2020-08-25 07:18:00']
['UNKNOWN STATUS', '2020-08-25 07:18:00', '2020-08-25 07:19:00']
]
这是我试过的:
let status = '';
let statusStart: Date;
let statusEnd: Date;
let data = new Array<any>();
this.evolutionAnalysis.forEach((e, idx) => {
if(status === '') {
status = e.statusname;
statusStart = new Date(e.statusstart);
}
if (e.statusname !== status) {
statusEnd = new Date(this.evolutionAnalysis[idx - 1].statusend);
data.push([
this.operatorsAnalysis.find(o => o.operatorid == e.operatorid).operatorname,
status,
statusStart,
statusEnd
]);
status = e.statusname;
}
});
在我知道 statusEnd 之后,如何确定 statusStart
汪汪一只猫
守着星空守着你
相关分类