mongo cws export.js > out.csv
export.js
//
Date.prototype.getIOSDate = function () {
return new Date(this.getTime() + this.getTimezoneOffset() * 60 * 1000)
}
print('磨机A')
printCsv('aaaaaa')
function printCsv(device) {
print('日期,时间,给水量,给煤量,添加剂添加量,磨机出料槽煤浆浓度,磨机出料槽煤浆温度,磨机出料槽煤浆粘度,煤浆槽煤浆瞬时流量,煤浆槽煤浆浓度,煤浆槽煤浆温度,煤浆槽煤浆粘度')
db.coal_slurry_run.find({"deviceid":device}).forEach(data=>{
print(`${format(data.datetime.getIOSDate())},${data.time},${data.water.nullfloat64.float64},${data.coal.nullfloat64.float64},${data.additive.nullfloat64.float64},${data.outconcentration.nullfloat64.float64},${data.outtemperature.nullfloat64.float64},${data.outviscosity.nullfloat64.float64},${data.instantflow.nullfloat64.float64},${data.highconcentration.nullfloat64.float64},${data.hightemperature.nullfloat64.float64},${data.highviscosity.nullfloat64.float64}`)
})
}
function format(date) {
return date.getFullYear() + '-' +('0' + (date.getMonth()+1)).slice(-2) + '-' + date.getDate()
}