diff --git a/webserve/app.js b/webserve/app.js index c8836b9772eeed07214f79ef86b4813bdd9b134c..bceb2353f4f49d7223fb806671be91921db45654 100644 --- a/webserve/app.js +++ b/webserve/app.js @@ -6,8 +6,12 @@ var logger = require('morgan'); var cors = require('cors') var indexRouter = require('./routes/index'); var usersRouter = require('./routes/users'); + +var myrRouter=require('./routes/myr') + let szhRouter = require('./routes/szh'); + var app = express(); app.use(cors()); @@ -23,8 +27,12 @@ app.use(express.static(path.join(__dirname, 'public'))); app.use('/', indexRouter); app.use('/users', usersRouter); + +app.use('/myr', myrRouter); + app.use('/szh',szhRouter); + // catch 404 and forward to error handler app.use(function(req, res, next) { next(createError(404)); diff --git a/webserve/model/model.js b/webserve/model/model.js index 4543f389a1e9cb2521d1010d25d208718a213d7f..14fe4b11fc8af8e0053716f39af84e2260a8183f 100644 --- a/webserve/model/model.js +++ b/webserve/model/model.js @@ -1,3 +1,69 @@ + +const mongoose = require('./db') + +const xicheCate = new mongoose.Schema({ + cate: String +}) + +const XiHeSchema = new mongoose.Schema({ + name: String, //司机名称 + tel: String,//手机号码 + start: String,//开始时间 + end: String, //结束时间 + carid: { + type: mongoose.Schema.Types.ObjectId, + ref: 'xichetype' + }, + // 预约编号 + yuey: Boolean,// 预约类型 + beizhu: String, //备注信息 + nums: Number //盒子数量 +}) + + +const XihedengjiSchema = new mongoose.Schema({ + djbianh: String, //登记编号 + carsnum: String, //车牌号码 + cartype: String, //车辆类型 + sjname: String, //司机姓名 + tel: String, //手机号码 + starts: String, //登记时间 + nums: Number, //盒子数量 + qj: String, //清洁情况 + memy: Number, //缴费金额 + beizhu: String //备注 +}) +const XiheSchema=new mongoose.Schema({ + myrbianh: String, //登记编号 + myrcarhao: String,//车牌号码 + cartype: String,//车辆类型 + name: String,//司机姓名 + tel: String,//手机号码 + myrstart: String,//登记时间 + nums:Number,//盒子数量 + myrend:String,//洗盒时间 + qingkuang:Boolean,//清洁情况 + memy:Number,//缴费金额 + beizhu: String//备注 +}) +const xihebaobiaoSchema=new mongoose.Schema({ + myrbianh: String,//登记编号 + myrcarhao: String,//车牌号码 + nums:Number,//盒子数量 + myrstart: String,//登记时间 + myrend:String,//洗盒时间 + gan:Number,//干净 + chong:Number,//虫卵 + chan:Number,//残渣 + qita:Number//其他数量 +}) +const Xiche = mongoose.model('xiche', XiHeSchema, 'xiche') //洗盒登记 +const Xichetype = mongoose.model('xichetype', xicheCate, 'xichetype') // 洗盒类型 +const Xichedengji = mongoose.model(' Xihedengji', XihedengjiSchema, ' Xihedengji') //洗盒记录 +const Xihejilu=mongoose.model('XiheSchema',XiheSchema,'XiheSchema') +const xihebaobiao=mongoose.model('xihebaobiaoSchema',xihebaobiaoSchema,'xihebaobiaoSchema') +module.exports = { Xiche, Xichetype,Xichedengji,Xihejilu,xihebaobiao} + const mongoose = require('./db'); let carRegisterSchema = new mongoose.Schema({ @@ -16,3 +82,4 @@ let carRegisterModel = mongoose.model('carRegister', carRegisterSchema, 'carRegi module.exports = { carRegisterModel } + diff --git a/webserve/routes/myr.js b/webserve/routes/myr.js new file mode 100644 index 0000000000000000000000000000000000000000..0cea669ee9d9fd30d7e12f5b3e8bc67844c57f93 --- /dev/null +++ b/webserve/routes/myr.js @@ -0,0 +1,127 @@ +var express = require('express'); +var router = express.Router(); +let {Xiche,Xichetype,Xichedengji,Xihejilu,xihebaobiao} =require('../model/model') + +/* GET home page. */ +// 添加洗盒登记 +router.post('/xicheadd',(req,res)=>{ + Xiche.create(req.body) + res.send({ + code:'200', + }) +}) +// 添加车辆编号 +router.post('/xichetypeadd',(req,res)=>{ + Xichetype.create(req.body) + res.send({ + code:'200' + }) +}) + +// 洗车登记数据 +router.get('/getdengji',async(req,res)=>{ + let {page}=req.query; + let datas=await Xiche.find({yuey:false}).populate('carid').skip((page-1)*10).limit(10) + let total=(await Xiche.find()).length + let tylist=await Xichetype.find() + res.send({ + code:'200', + list:datas, + total, + tylist + }) +}) + +router.get('/getdengjitow',async(req,res)=>{ + let {page}=req.query; + let datas=await Xiche.find({yuey:true}).populate('carid').skip((page-1)*10).limit(10) + let total=(await Xiche.find()).length + res.send({ + code:'200', + list:datas, + total + }) +}) + +router.post('/addXichedengji',(req,res)=>{ + Xichedengji.create(req.body) + res.send({ + code:'200', + }) +}) +router.get('/xihelogin',async(req,res)=>{ + let {_id,sjname,start,end}=req.query + let add=[{}] + if(sjname){ + add.push({sjname:new RegExp(sjname)}) + } + if(_id){ + add.push({_id:_id}) + } + let datas=await Xichedengji.find({$and:add}) + let total=datas.length + res.send({ + code:'200', + list:datas, + total + }) +}) + +router.post('/upyuyue',async(req,res)=>{ + let {id}=req.body + let oo=await Xiche.find({_id:id}) + await Xiche.updateOne({_id:id},{yuey:!oo[0]['yuey']}) + + res.send({ + code:'200', + }) +}) + +router.post('/delsome',async(req,res)=>{ + let {ids}=req.body + await Xiche.deleteOne({_id:ids}) + res.send({ + code:'200' + }) +}) + +router.post('/addXihejilu',(req,res)=>{ + Xihejilu.create(req.body) + res.send({ + code:'200', + }) +}) + +router.get('/getXihejilu',async(req,res)=>{ + let {name}=req.query + let ass=[{}] + if(name){ + ass.push({name:new RegExp(name)}) + } + let datas=await Xihejilu.find({$and:ass}) + let total=datas.length + res.send({ + code:'200', + list:datas, + total + }) +}) + +router.post('/xihebaobiao',(req,res)=>{ + xihebaobiao.create(req.body) + res.send({ + code:'200', + }) +}) + +router.get('/xihelist',async(req,res)=>{ + let {page}=req.query + let datas=await xihebaobiao.find().skip((page-1)*10).limit(10) + let total=(await xihebaobiao.find()).length + res.send({ + code:'200', + list:datas, + total + }) +}) +module.exports = router; \ No newline at end of file