mongodb 多表数据拼接查询
db.T_ZXJC_FSXSSJB.aggregate([ { $group:{ _id:"any", T_ZXJC_FSXSSJB:{ $push: {pwxkzbh:"$pwxkzbh",WrState:"$WrState"} }, maxid: { $max: '$data_time' } } }, { $lookup:{ from:"T_ZXJC_FQXSSJB", localField:"pwxkzbh", foreignField:"pwxkzbh", as:"T_ZXJC_FQXSSJB" } }, { $project:{ _id:0, allValue:{ $setUnion:["$T_ZXJC_FSXSSJB","$T_ZXJC_FQXSSJB"] } } }, {$unwind:"$allValue"}, { $project:{ _id:0, type:"$allValue.pwxkzbh", wrstate:"$allValue.WrState" } } ])