欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

springboot+vue.js智能停车场管理系统

程序员文章站 2024-01-15 22:22:04
...

介绍

最近公司在研发一款智能停车场系统,其中使用的技术栈比较新,我这边打算跟大家分享一下开发过程

运行环境

1.jdk1.8
2.mysql5.7+
3.npm
4.node.js

采用技术

  1. SpringBoot 2.1.3.RELEASE
  2. Apache Shiro 1.3.2
  3. Lombok
  4. WebSocket
  5. Mysql、Mybatis、Mapper、Pagehelper
  6. Spring Data Jpa
  7. fastJson
  8. swagger-ui
  9. qiniu

运行模块

springboot+vue.js智能停车场管理系统
具体实现代码如下:

    @BussinessLog(value = "登录",type = LogTypeEnum.LOGIN)
    @ApiOperation(value = "用户登录接口")
    @RequestMapping("login")
    public ResponseEntity<User> login(@RequestBody User entity, HttpServletRequest r){
        UsernamePasswordToken token = new UsernamePasswordToken(entity.getAccount(), entity.getPassword());
        Subject subject = SecurityUtils.getSubject();
        try {
            subject.login(token);
            User user = (User) subject.getPrincipal();
            log.info("当前登录ip:"+IpUtil.getUserIP(r));
            return ResponseEntity.ok(user);
        } catch (Exception e) {
            log.info("登陆失败:"+e.getMessage());
            throw e;
        }
    }

springboot+vue.js智能停车场管理系统
数据可视化代码如下:

package com.cqjtu.platform.controller;

import com.cqjtu.platform.dao.CarPlaceDao;
import com.cqjtu.platform.dao.ParkingDao;
import com.cqjtu.platform.entity.CarPlace;
import com.cqjtu.platform.entity.Coder;
import com.cqjtu.platform.entity.Parking;
import com.cqjtu.platform.service.CarPlaceService;
import com.cqjtu.platform.service.CoderService;
import com.cqjtu.platform.service.ParkingService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author pengyangyan
 */
@Api(description = "主页数据分析接口")
@RestController
@RequestMapping(value = "api/analyze")
public class AnalyzeController {

    @Resource
    private ParkingDao parkingDao;
    @Resource
    private CarPlaceDao carPlaceDao;
    @Autowired
    CoderService coderService;
    @Autowired
    CarPlaceService carPlaceService;

    @GetMapping("/getParkingAnalyzeData")
    public ResponseEntity getParkingAnalyzeData(){
        Integer allParking = parkingDao.selectAllCount();
        Integer status = coderService.selectIdByName("是否营业", "是");
        Integer bussinessCount = parkingDao.selectBussinessParkingNum(status);
        Integer allPlace = carPlaceDao.selectAllCount();
        Integer bussiness = coderService.selectIdByName("车位状态", "空闲");
        Integer leftNum = carPlaceDao.selectLeftNum(bussiness);
        Map<String,Integer> result = new HashMap<>();
        result.put("parkingNum",allParking);
        result.put("bussinessCount",bussinessCount);
        result.put("carplace",allPlace);
        result.put("leftNum",leftNum);
        return ResponseEntity.ok(result);
    }

    @GetMapping("/getParkingSortAnalyzeData")
    public ResponseEntity getParkingSortAnalyzeData(){
        List<Coder> parkingSortCode = coderService.getOptionByCode("parkingSortCode");
        List<String> sortData = new ArrayList<>();
        List<Integer> sortNum = new ArrayList<>();
        parkingSortCode.forEach( p -> {
            sortData.add(p.getValueDesc());
            Integer integer = parkingDao.selectSortNum(p.getId());
            sortNum.add(integer);
        });
        Map<String,Object> result = new HashMap<>();
        result.put("sortData",sortData);
        result.put("sortNum",sortNum);
        return ResponseEntity.ok(result);
    }



    @GetMapping("/getCarPlaceAnalyzeData")
    public ResponseEntity getCarPlaceAnalyzeData(@RequestParam("parkingId") Integer parkingId){
        List<String> sortData = new ArrayList<>();
        List<Map<String,Object>> sortNum = new ArrayList<>();
        List<Coder> carplaceSort = coderService.getOptionByCode("carPlaceStatus");
        carplaceSort.forEach( p -> {
            sortData.add(p.getValueDesc());
            Map<String,Object> map = new HashMap<>();
            Integer integer = carPlaceDao.selectLeftNumByParkingId(parkingId,p.getId());
            map.put("name",p.getValueDesc());
            map.put("value",integer);
            sortNum.add(map);
        });
        Map<String,Object> result = new HashMap<>();
        result.put("sortData",sortData);
        result.put("sortNum",sortNum);
        return ResponseEntity.ok(result);
    }



}

springboot+vue.js智能停车场管理系统
具体实现代码如下:

/*
* pyy Inc.
* Copyright (c) 2019 All Rights Reserved.
* create by pengyangyan
* date:2019-02-28
*/
package com.cqjtu.platform.controller;

import com.cqjtu.platform.entity.Parking;
import com.cqjtu.platform.enums.ExceptionEnums;
import com.cqjtu.platform.exception.MyException;
import com.cqjtu.platform.log.annotation.BussinessLog;
import com.cqjtu.platform.service.CoderService;
import com.cqjtu.platform.service.ParkingService;
import com.cqjtu.platform.utils.Condition;
import com.cqjtu.platform.utils.vo.ParkingVO;
import com.cqjtu.platform.utils.vo.RelativeParkingVO;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;

import java.math.BigInteger;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.logging.SimpleFormatter;


/**
 * Parking 控制器
 * 
 * @author pengyangyan
 * Date: 2019-02-28 11:15:58
 */
@Api(description = "车库信息接口")
@Slf4j
@Controller
@RequestMapping(value = "api/parking")
public class ParkingController extends BaseController<ParkingService,Parking,Integer>{

    @Autowired
    private ParkingService parkingService;
    @Autowired
    CoderService coderService;


    @Override
    @PostMapping(value = "add")
    @BussinessLog(value = "创建车库信息")
    public ResponseEntity<Parking> save(@RequestBody Parking entity) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMddHHmmss");
        String date = simpleDateFormat.format(new Date());
        entity.setId(Integer.parseInt(date));
        entity.setCreateDatetime(new Date());
        entity.setUpdateDatetime(new Date());
        return super.save(entity);
    }

    @PostMapping("/getParkingVOList")
    @ResponseBody
    public ResponseEntity<PageInfo> getParkingVOList(@RequestBody Condition condition){
        PageInfo pageInfo;
        try{
            pageInfo=parkingService.getParkingVOList(condition);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_LIST_ERROR);
        }
        return ResponseEntity.ok(pageInfo);
    }

    @GetMapping("/getParkingListNameAndId")
    @ResponseBody
    public ResponseEntity<List<Parking>> getParkingListNameAndId(){
        List<Parking> parkingList=null;
        try {
            parkingList=parkingService.getParkingListNameAndId();
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_LIST_ERROR);
        }
        return ResponseEntity.ok(parkingList);
    }

    @GetMapping("/getParkingNameAndIdIsUsed/{isUsed}")
    @ResponseBody
    public ResponseEntity<List<Parking>> getParkingNameAndIdIsUsed(@PathVariable Integer isUsed){
        List<Parking> parkingList=null;
        try {
            parkingList=parkingService.getParkingNameAndIdIsUsed(isUsed);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_LIST_ERROR);
        }
        return ResponseEntity.ok(parkingList);
    }

    @GetMapping("/getParkingOfUser/{userId}")
    @ResponseBody
    public ResponseEntity<List<Parking>> getParkingOfUser(@PathVariable Integer userId){
        List<Parking> parkingList=null;
        try {
            parkingList=parkingService.getParkingOfUser(userId);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_LIST_ERROR);
        }
        return ResponseEntity.ok(parkingList);
    }

    @PostMapping("/selectParking")
    @ResponseBody
    public ResponseEntity<Parking> selectParking(@RequestBody Parking parking){
        Parking parkingResult = null;
        try {
            parkingResult=parkingService.selectParking(parking);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_ITEM);
        }
        return ResponseEntity.ok(parkingResult);
    }

    @PostMapping("/checkParking")
    @ResponseBody
    public ResponseEntity<Map<String,Object>> checkParking(@RequestBody Parking parking){
        Map<String,Object> result = null;
        try {
            result=parkingService.checkParking(parking);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_ITEM);
        }
        return ResponseEntity.ok(result);

    }


    @GetMapping("/selectByParkingName")
    public ResponseEntity selectByParkingName(@RequestParam("name") String name){
        Parking parking = service.selectByParkingName(name);
        return ResponseEntity.ok(parking);
    }

    @PostMapping("/checkParkingDelete")
    @ResponseBody
    public ResponseEntity<Map<String,Object>> checkParkingDelete(@RequestBody Parking parking){
        Map<String,Object> result = null;
        try {
            result=parkingService.checkParkingDelete(parking);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_ITEM);
        }
        return ResponseEntity.ok(result);
    }


    @PostMapping("/getRelativeParking")
    @ResponseBody
    public ResponseEntity getRelativeParking(@RequestBody Double[] point){
        List<RelativeParkingVO> list = new ArrayList<>();
        Example example = new Example(Parking.class);
        example.createCriteria().andEqualTo("isUsed",1);
        List<Parking> parkings = this.service.selectByExample(example);
        parkings.forEach(p -> {
            RelativeParkingVO relativeParkingVO = new RelativeParkingVO();
            BeanUtils.copyProperties(p,relativeParkingVO,"distance");
            Double distance = getDistance(p.getLatitude(), p.getLongitude(), point[0], point[1]);
            relativeParkingVO.setDistance(distance);
            list.add(relativeParkingVO);
        });
        return ResponseEntity.ok(list);


    }

    private Double getDistance(Double x,Double y,Double x1,Double y1){
         return Double.valueOf(Math.round(Math.abs(Math.sqrt((y1-y)*(y1-y)+(x1-x)*(x1-x))) * 1000000));
    }

    /**
     *  获取最热门的车库排名
     * @return 获取最热门的车库排名
     */
    @GetMapping("/getAllUsedParking")
    public ResponseEntity getAllUsedParking(){
        Example example = new Example(Parking.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("isUsed",1);
        List<Parking> parkings = this.service.selectByExample(example);
        return ResponseEntity.ok(parkings);
    }

}

springboot+vue.js智能停车场管理系统
springboot+vue.js智能停车场管理系统
具体实现代码如下:

/*
* pyy Inc.
* Copyright (c) 2019 All Rights Reserved.
* create by pengyangyan
* date:2019-02-28
*/
package com.cqjtu.platform.controller;

import com.cqjtu.platform.dao.ParkingOrderDao;
import com.cqjtu.platform.entity.*;
import com.cqjtu.platform.enums.ExceptionEnums;
import com.cqjtu.platform.exception.MyException;
import com.cqjtu.platform.log.annotation.BussinessLog;
import com.cqjtu.platform.service.*;
import com.cqjtu.platform.utils.Condition;
import com.cqjtu.platform.utils.vo.OrderVO;
import com.cqjtu.platform.websocket.util.WebSocketUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;

import javax.annotation.Resource;
import java.util.*;

/**
 * ParkingOrder 控制器
 * 
 * @author pengyangyan
 * Date: 2019-02-28 11:15:58
 */
@Slf4j
@Api(description = "订单信息接口")
@RestController
@RequestMapping(value = "api/parkingOrder")
public class ParkingOrderController extends BaseController<ParkingOrderService,ParkingOrder,Integer>{

    @Resource
    private ParkingOrderService parkingOrderService;
    @Resource
    private ParkingOrderDao parkingOrderDao;
    @Resource
    private ParkingService parkingService;
    @Resource
    private CarPlaceService carPlaceService;
    @Resource
    private PayRulesService payRulesService;
    @Resource
    private CarInfoService carInfoService;
    @Resource
    private UserService userService;
    @Resource
    private ParkingRecordService parkingRecordService;
    @Resource
    private CoderService coderService;

    @Override
    @PostMapping("/add")
    public ResponseEntity<ParkingOrder> save(@RequestBody ParkingOrder entity) {
        return super.save(entity);
    }

    @Override
    public ResponseEntity<ParkingOrder> update(@RequestBody ParkingOrder entity) {
        //订单进入停车中时,生成停车记录
        parkingRecordService.insertRecord(entity);
        entity.setStartTime(new Date());
        return super.update(entity);
    }

    @PostMapping("/createParkingOrder")
    @BussinessLog(value = "创建订单信息")
    ResponseEntity<Map<String,Object>> createParkingOrder(@RequestBody ParkingOrder parkingOrder){
        Map<String,Object> result = null;
        try{
            result = parkingOrderService.createParkingOrder(parkingOrder);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.ADD_ERROR);
        }
        return ResponseEntity.ok(result);
    }

    @PostMapping("/deleteOrderList")
    @BussinessLog(value = "删除订单信息")
    ResponseEntity<String> deleteOrderList(@RequestBody List<ParkingOrder> parkingOrderList){
        int num = 0;
        try{
            num = parkingOrderService.deleteOrderList(parkingOrderList);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.DELETE_ERROR);
        }
        return ResponseEntity.ok("成功删除【"+num+"】条订单");
    }

    @PostMapping("/getOrderList")
    ResponseEntity<PageInfo> getOrderList(@RequestBody Condition condition){

        PageInfo<OrderVO> page ;
        try {
            page=parkingOrderService.getOrderVOList(condition);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_LIST_ERROR);
        }
        return ResponseEntity.ok(page);
    }

    @PostMapping("/finishOrder")
    ResponseEntity<Map<String,Object>> finishOrder(@RequestBody ParkingOrder parkingOrder){
        Map<String,Object> result = null;
        try {
                result = parkingOrderService.finishOrder(parkingOrder);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_LIST_ERROR);
        }
        return ResponseEntity.ok(result);
    }

    @PostMapping("/payForOrder")
    ResponseEntity<Map<String,Object>> payForOrder(@RequestBody ParkingOrder parkingOrder){
        Map<String,Object> result = null;
        try {
            result = parkingOrderService.payForMoney(parkingOrder);
        }catch (Exception e){
            log.info(e.getMessage());
            throw new MyException(ExceptionEnums.GET_LIST_ERROR);
        }
        return ResponseEntity.ok(result);
    }

    @GetMapping("/getCurrentOrder")
    ResponseEntity getCurrentOrder(){
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        if (user==null){
            throw new MyException(ExceptionEnums.IS_NOT_LOGIN);
        }else {
            List<ParkingOrder> parkingOrders = parkingOrderDao.getCurrentOrder(user.getId());
            return ResponseEntity.ok(parkingOrders);
        }
    }

    @GetMapping("/changeOrderStatus")
    @BussinessLog(value = "停车")
    ResponseEntity changeOrderStatus(@RequestParam("orderNum") String orderNum,@RequestParam("orderStatus") String orderStatus,@RequestParam("payStatus") String payStatus,@RequestParam("parkingOrderId")Integer parkingOrderId){
        Integer pay = coderService.selectIdByName("支付状态", payStatus);
        Integer order = coderService.selectIdByName("订单状态", orderStatus);
        ParkingOrder parkingOrder = this.service.selectByKey(parkingOrderId);
        parkingOrder.setPayStatus(pay);
        parkingOrder.setOrderStatus(order);
        parkingOrder.setStartTime(new Date());
        this.service.update(parkingOrder);
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        //停车阶段,存入车库记录
        parkingRecordService.insertRecord(parkingOrder);
        WebSocketUtil.sendNotify(new Information().setType("info")
                .setStatus(0).setContent("您已停车,订单开始计费。").setUserId(user.getId()).setSendUserId(user.getId()).setTitle("订单提示"));
        return ResponseEntity.ok("操作成功");
    }

    @PostMapping("/takeCarOrder")
    @BussinessLog(value = "取车")
    ResponseEntity takeCarOrder(@RequestBody ParkingOrder parkingOrder){
        Integer order = coderService.selectIdByName("订单状态", "已完成");
        parkingOrder.setOrderStatus(order);
        parkingOrder.setEndTime(new Date());
        Parking parking = parkingService.selectByKey(parkingOrder.getParkingId());
        //折扣
        int discount = parking.getDiscount();
        long startTime = parkingOrder.getStartTime().getTime();
        long endTime = parkingOrder.getEndTime().getTime();
        int time = (int)(endTime-startTime)/(1000*60);
        int range = time%60;
        int hour = time/60;
        if (range> 30){
            hour = hour + 1;
        }
        log.info("停车{}小时",hour);
        parkingOrder.setParkingTime(hour);
        judgePayWay(parkingOrder,hour,discount);
        if (parkingOrder.getParkingTime()==0){
            parkingOrder.setPayStatus(coderService.selectIdByName("支付状态", "已支付"));
        }
        this.service.update(parkingOrder);
        parkingRecordService.updateParkingRecorderStatus(parkingOrder);
        return ResponseEntity.ok(parkingOrder);

    }

    private void judgePayWay(ParkingOrder parkingOrder,Integer hour,Integer discount){
        Double money = 0.0;
        Double totalMoney = 0.0;
        CarPlace carPlace = carPlaceService.selectByKey(parkingOrder.getCarPlaceId());
        carPlace.setCarPlaceStatus(coderService.selectIdByName("车位状态", "空闲"));
        carPlaceService.update(carPlace);
        PayRules payRules = payRulesService.selectByKey(carPlace.getPayRulesId());
        switch (payRules.getParentId()){
            case 1:
                //时段  根据取车时的时间判断
                money = hour*payRules.getMoney1()*discount/10;
                totalMoney = hour*payRules.getMoney1();
                break;
            case 2:
                //车型
                CarInfo carInfo = carInfoService.selectByKey(parkingOrder.getPlateNum());
                if(Objects.isNull(carInfo)){
                    money = hour*payRules.getMoney1()*discount/10;
                    totalMoney = hour*payRules.getMoney1();
                }else{
                    money = hour*payRules.getMoney1()*discount/10;
                    totalMoney = hour*payRules.getMoney1();
                }
                break;
            case 3:
                //普通
                money = hour*payRules.getMoney1()*discount/10;
                totalMoney = hour*payRules.getMoney1();
                break;
            default:break;
        }
        parkingOrder.setTotalPay(totalMoney);
        parkingOrder.setActualPay(money);
    }

    @GetMapping("/judgePlateNumStatus/{plateNum}")
    ResponseEntity judgePlateNumStatus(@PathVariable("plateNum") String plateNum){
        Map<String,String> map = new HashMap<>();
        Example example = new Example(ParkingOrder.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("plateNum",plateNum);
        criteria.andEqualTo("payStatus",coderService.selectIdByName("支付状态","待支付"));
        criteria.andEqualTo("orderStatus",coderService.selectIdByName("订单状态","已完成"));
        List<ParkingOrder> parkingOrders1 = this.service.selectByExample(example);
        if (parkingOrders1.size()>0){
            map.put("code","1");
            map.put("message","有未支付的订单");
            return ResponseEntity.ok(map);
        }else{
            Example example2 = new Example(ParkingOrder.class);
            Example.Criteria criteria2 = example2.createCriteria();
            criteria2.andEqualTo("plateNum",plateNum);
            criteria2.andEqualTo("orderStatus",coderService.selectIdByName("订单状态","停车中"));
            List<ParkingOrder> parkingOrders2 = this.service.selectByExample(example2);
            if (parkingOrders2.size()>0){
                map.put("code","1");
                map.put("message","该车牌已经再停车中");
                return ResponseEntity.ok(map);
            }else {
                Example example3 = new Example(ParkingOrder.class);
                Example.Criteria criteria3 = example3.createCriteria();
                criteria3.andEqualTo("plateNum",plateNum);
                criteria3.andEqualTo("orderStatus",coderService.selectIdByName("订单状态","预订成功"));
                List<ParkingOrder> parkingOrders3 = this.service.selectByExample(example3);
                if (parkingOrders3.size()>0){
                    map.put("code","1");
                    map.put("message","已提交预定,请勿重复提交!");
                    return ResponseEntity.ok(map);
                }
            }

        }
        map.put("code","0");
        map.put("message","可以预定车位");
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        WebSocketUtil.sendNotify(new Information().setType("info")
                .setStatus(0).setContent("订单预约成功!请在预约保留时间内前往停车,否则会降低您的信誉度。").setUserId(user.getId()).setSendUserId(user.getId()).setTitle("订单提示"));
        return ResponseEntity.ok(map);

    }

    @PostMapping("/payOrder")
    @BussinessLog(value = "支付账单")
    ResponseEntity payOrder(@RequestBody ParkingOrder parkingOrder){
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        user = userService.selectByKey(user.getId());
        Double balance = user.getBalance();
        if (parkingOrder.getActualPay()==null){
            parkingOrder.setActualPay(0.0);
        }
        Map<String,String> map = new HashMap<>();
        if (balance<parkingOrder.getActualPay()){
            map.put("code","1");
            map.put("message","余额不足,请充值!");
            WebSocketUtil.sendNotify(new Information().setType("info")
                    .setStatus(0).setContent("账户余额不足,请尽快充值,否则会影响您的下一次停车。").setUserId(user.getId()).setSendUserId(user.getId()).setTitle("账户提示"));
            return ResponseEntity.ok(map);
        }else {
            balance = balance - parkingOrder.getActualPay();
            if (balance < 10){
                WebSocketUtil.sendNotify(new Information().setType("info")
                        .setStatus(0).setContent("当前账户余额:"+balance+"元,不足10元,为避免影响下一次停车,请及时充值。").setUserId(user.getId()).setTitle("账户提示"));
            }
            user.setBalance(balance);
            userService.update(user);
            Integer pay = coderService.selectIdByName("支付状态", "已支付");
            Integer order = coderService.selectIdByName("订单状态", "已完成");
            this.service.updateOrderStatus(parkingOrder.getOrderNum(),order,pay);
            map.put("code","0");
            map.put("message","交易完成,欢迎下次消费!");
            WebSocketUtil.sendNotify(new Information().setType("info")
                    .setStatus(0).setContent("交易完成,账户余额:"+balance+"元,欢迎下次消费!").setUserId(user.getId()).setSendUserId(user.getId()).setTitle("订单提示"));
            return ResponseEntity.ok(map);
        }
    }

    @GetMapping("/getSelfOrderList")
    ResponseEntity getSelfOrderList(@RequestParam("parkingId") Integer parkingId){
        Example example = new Example(ParkingOrder.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("parkingId",parkingId);
        criteria.andEqualTo("payStatus",coderService.selectIdByName("支付状态","待支付"));
        List<ParkingOrder> parkingOrders = this.service.selectByExample(example);
        return ResponseEntity.ok(parkingOrders);

    }
}

springboot+vue.js智能停车场管理系统
具体实现代码如下:

package com.cqjtu.platform.controller;

import com.cqjtu.platform.entity.Information;
import com.cqjtu.platform.entity.User;
import com.cqjtu.platform.enums.ExceptionEnums;
import com.cqjtu.platform.exception.MyException;
import com.cqjtu.platform.service.InfoService;
import com.cqjtu.platform.utils.dto.InfoDTO;
import com.cqjtu.platform.utils.dto.InfoReadDTO;
import com.cqjtu.platform.utils.dto.MessageDTO;
import com.cqjtu.platform.websocket.util.WebSocketUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.subject.Subject;
import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.mapper.entity.Example;

import java.util.Date;
import java.util.List;


/**
 * @author pengyangyan
 */
@Slf4j
@Api(description = "消息通知接口")
@RestController
@RequestMapping(value = "api/information")
public class InfoController extends BaseController<InfoService,Information,Integer> {

    @PostMapping("/getInfoPage")
    public ResponseEntity<PageInfo<Information>> getPage(@RequestBody InfoDTO infoDTO){
        return ResponseEntity.ok(this.service.getPage(infoDTO));
    }

    @Override
    @GetMapping(value = "get/{id}")
    public ResponseEntity<Information> get(@PathVariable("id") Integer id) {
        Information information = this.service.selectByKey(id);
        information.setStatus(1);
        this.service.update(information);
        return ResponseEntity.ok(information);
    }

    @GetMapping("/getAllInfoById")
    public ResponseEntity getAllInfoById(@RequestParam("content") String content){
        Subject subject = SecurityUtils.getSubject();
        User user = (User) subject.getPrincipal();
        Example example = new Example(Information.class);
        Example.Criteria criteria = example.createCriteria();
        if (!StringUtils.isEmpty(content)){
            criteria.andLike("content","%"+content+"%");
        }
        criteria.andEqualTo("userId",user.getId());
        example.setOrderByClause("update_datetime desc");
        return ResponseEntity.ok(this.service.selectByExample(example));
    }

    @GetMapping("/getUnReadInfoCount")
    public ResponseEntity getUnReadInfoCount(Integer userId){
        List<Information> info = this.service.getUnReadMessageByUserId(userId);
        return ResponseEntity.ok(info.size());
    }

    @PostMapping("/sendMessage")
    @RequiresPermissions(value = "info:send")
    public ResponseEntity sendInfo(@RequestBody MessageDTO messageDTO){
        log.info(messageDTO.toString());
        Integer[] receiveUserIds = messageDTO.getReceiveUserIds();
        if (receiveUserIds.length<1){
            throw new MyException(ExceptionEnums.NO_RECEIVE_USER);
        }else {
            for (Integer receiveUserId : receiveUserIds) {
                Information information = new Information();
                information.setSendUserId(messageDTO.getSendUserId());
                information.setTitle(messageDTO.getTitle());
                information.setContent(messageDTO.getContent());
                information.setType(messageDTO.getType());
                information.setCreateDatetime(new Date());
                information.setUpdateDatetime(new Date());
                information.setUserId(receiveUserId);
                information.setStatus(0);
                this.service.insert(information);
                WebSocketUtil.sendToUser(information);
            }
            return ResponseEntity.ok("发送成功");
        }
    }


    @PostMapping("/setInfoRead")
    public ResponseEntity setInfoRead(@RequestBody InfoReadDTO infoReadDTO){
        if (this.service.markToRead(infoReadDTO)>0){
            return ResponseEntity.ok("操作成功");
        }else {
            throw new MyException(ExceptionEnums.UPDATE_ERROR);
        }
    }

    @PostMapping("/deleteByIds")
    public ResponseEntity deleteByIds(@RequestBody Integer[] ids){
        if (this.service.deleteInfoByIds(ids)>0){
            return ResponseEntity.ok("操作成功");
        }else {
            throw new MyException(ExceptionEnums.DELETE_ERROR);
        }
    }

}

springboot+vue.js智能停车场管理系统
具体实现代码如下:

@Api(description = "评论信息接口")
@Controller
@RequestMapping(value = "api/comment")
public class CommentController extends BaseController<CommentService,Comment,Integer> {

}

springboot+vue.js智能停车场管理系统

  @Override
    @RequiresPermissions("user:add")
    @BussinessLog(value = "新增用户信息")
    public ResponseEntity<User> save(@RequestBody User entity) {
        if (StringUtils.isBlank(entity.getAccount())){
            throw new MyException(ExceptionEnums.ADD_ERROR);
        }
        if (this.service.findByAccount(entity.getAccount())!=null){
            throw new MyException(ExceptionEnums.ACCOUNT_IS_EXIT);
        }
        if (entity.getPassword()==null){
            entity.setPassword("123");
        }
        entity.setPassword(MD5Utils.encrypt(entity.getAccount(), entity.getPassword()));
        return super.save(entity);
    }

运行视频

springboot+vue.js智能停车场管理系统