Compare commits

...

14 Commits

Author SHA1 Message Date
syl b0241c68f2 Merge pull request '更新预约(新增获取用户信息)' (#6) from syl into master
Reviewed-on: #6
2023-12-12 21:26:21 +08:00
ASUS 1268957b82 更新预约(新增获取用户信息) 2023-12-12 21:25:55 +08:00
syl 1abb5c0478 Merge pull request 'syl' (#4) from syl into master
Reviewed-on: #4
2023-12-12 21:22:16 +08:00
ASUS 4b558ab882 更新项目 2023-12-12 21:21:29 +08:00
ASUS 7b298d7993 新增支付+预约 2023-12-12 21:19:24 +08:00
ASUS a669037c02 修改停车信息表 2023-12-12 21:17:00 +08:00
ASUS b8ed9c0370 修改停车场表 2023-12-12 21:16:13 +08:00
syl 7fa35df738 Merge pull request '修改预约表' (#3) from syl into master
Reviewed-on: #3
2023-12-12 21:15:03 +08:00
FangShiBa 4c00a43f89 Merge pull request 'syl' (#2) from syl into master
Reviewed-on: #2
2023-12-12 21:14:44 +08:00
ASUS 8d8b939cff 修改预约表 2023-12-12 21:13:15 +08:00
ASUS f9d6949bb6 新增VO 2023-12-12 21:11:06 +08:00
ASUS 44ae184388 新增DTO 2023-12-12 21:08:49 +08:00
FangShiBa 8964c61eed Merge pull request 'fangshiba' (#1) from fangshiba into master
Reviewed-on: #1
2023-12-12 17:17:55 +08:00
fangzhe 242746813a 项目框架 2023-12-12 16:31:54 +08:00
23 changed files with 625 additions and 6 deletions

View File

@ -9,6 +9,7 @@
<file url="file://$PROJECT_DIR$/bwie-common/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/bwie-common/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-gateway/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/bwie-gateway/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-gateway/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/bwie-gateway/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/bwie-list/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/bwie-user/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/bwie-models/bwie-user/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/src/main/java" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/bwie-models/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/bwie-models/src/main/resources" charset="UTF-8" /> <file url="file://$PROJECT_DIR$/bwie-models/src/main/resources" charset="UTF-8" />

View File

@ -0,0 +1,47 @@
package com.bwie.common.pojo.DTO;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DTOLogMake {
/*
*/
private Integer makeId;
/*
*/
private String carNum;
/*
(: 1, : 2, : 3)
*/
private Integer makeState;
/*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date makeTime;
/*
id
*/
private Integer parkingId;
/*
id
*/
private Integer userId;
}

View File

@ -0,0 +1,64 @@
package com.bwie.common.pojo.DTO;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DTOStop {
/*
*/
private Integer stopId;
/*
*/
private Integer carId;
/*
*/
private Integer userId;
/*
*/
private Integer parkingId;
/*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date stopStart;
/*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date stopEnd;
/*
*/
private Integer stopTime;
/*
(1- 2-)
*/
private Integer stopState;
/*
*/
private Integer stopPrice;
/*
*/
private Integer stopPay;
/*
*/
private Integer time;
}

View File

@ -24,9 +24,10 @@ public class LogMake {
*/ */
private Integer makeId; private Integer makeId;
/* /*
*/ */
private Integer carId; private String carNum;
/* /*
(: 1, : 2, : 3) (: 1, : 2, : 3)
*/ */
@ -38,7 +39,15 @@ public class LogMake {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date makeTime; private Date makeTime;
/*
id
*/
private Integer parkingId;
/*
id
*/
private Integer userId;

View File

@ -28,9 +28,9 @@ public class Parking {
*/ */
private String parkingAddress; private String parkingAddress;
/* /*
(: 1, : 2, : 3)
*/ */
private Integer makeId; private Integer parkingState;

View File

@ -56,7 +56,11 @@ public class Stop {
*/ */
private Integer stopState; private Integer stopState;
/* /*
*/ */
private String stopPrice; private Integer stopPrice;
/*
*/
private Integer stopPay;
} }

View File

@ -0,0 +1,33 @@
package com.bwie.common.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VOLogMake {
/*
*/
private String carNum;
/*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date makeTime;
/*
id
*/
private Integer userId;
}

View File

@ -0,0 +1,29 @@
package com.bwie.common.pojo.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class VOStop {
/*
*/
private String carNum;
/*
*/
private Integer stopPrice;
/*
*/
private Integer stopPay;
public VOStop(String carNum, Integer stopPrice) {
this.carNum = carNum;
this.stopPrice = stopPrice;
}
}

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.bwie</groupId>
<artifactId>stopCar</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>bwie-list</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- 系统公共 依赖 -->
<dependency>
<groupId>com.bwie</groupId>
<artifactId>bwie-common</artifactId>
</dependency>
<!-- SpringBoot Web-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Druid -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.8</version>
</dependency>
<!-- Mysql Connector -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- Mybatis 依赖配置 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.2</version>
</dependency>
<!-- Pagehelper -->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.1</version>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.26.5</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,11 @@
package com.bwie;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ListApplication {
public static void main(String[] args) {
SpringApplication.run(ListApplication.class);
}
}

View File

@ -0,0 +1,36 @@
package com.bwie.list.controller;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.pojo.vo.VOLogMake;
import com.bwie.common.result.Result;
import com.bwie.list.service.ParkingService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@Log4j2
public class ParkingController {
@Autowired
private ParkingService parkingService;
@Autowired
private HttpServletRequest request;
@PostMapping("/makeAppointment")
public Result makeAppointment(@RequestBody VOLogMake voLogMake){
log.info("功能名称:预约,请求URI:{},请求方式:{},请求参数:{}",
request.getRequestURI(),request.getMethod(),voLogMake);
Result result = parkingService.makeAppointment(voLogMake);
log.info("功能名称:预约,请求URI:{},请求方式:{},响应结果:{}",
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
return result;
}
}

View File

@ -0,0 +1,58 @@
package com.bwie.list.controller;
import com.alibaba.fastjson.JSONObject;
import com.bwie.common.pojo.vo.VOStop;
import com.bwie.common.result.Result;
import com.bwie.list.service.StopService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
@RestController
@Log4j2
public class StopConroller {
@Autowired
private StopService stopService;
@Autowired
private HttpServletRequest request;
/**
*
* @param carNum
* @return
*/
@PostMapping("/findVOStop")
public Result findVOStop(@RequestParam String carNum){
log.info("功能名称:回显车牌号和应交停车费,请求URI:{},请求方式:{},请求参数:{}",
request.getRequestURI(),request.getMethod(),carNum);
Result result = stopService.findVOStop(carNum);
log.info("功能名称:回显车牌号和应交停车费,请求URI:{},请求方式:{},响应结果:{}",
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
return result;
}
/**
*
* @param voStop
* @return
*/
@PostMapping("/takeStopPrice")
public Result takeStopPrice(@RequestBody VOStop voStop){
log.info("功能名称:支付,请求URI:{},请求方式:{},请求参数:{}",
request.getRequestURI(),request.getMethod(),voStop);
Result result = stopService.takeStopPrice(voStop);
log.info("功能名称:支付,请求URI:{},请求方式:{},响应结果:{}",
request.getRequestURI(),request.getMethod(), JSONObject.toJSONString(result));
return result;
}
}

View File

@ -0,0 +1,10 @@
package com.bwie.list.mapper;
import com.bwie.common.pojo.vo.VOLogMake;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface ParkingMapper {
Integer makeAppointment(VOLogMake voLogMake);
}

View File

@ -0,0 +1,19 @@
package com.bwie.list.mapper;
import com.bwie.common.pojo.Car;
import com.bwie.common.pojo.DTO.DTOStop;
import com.bwie.common.pojo.Stop;
import com.bwie.common.pojo.vo.VOStop;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface StopMapper {
Car findCarId(VOStop voStop);
DTOStop findStartDate(@Param("carNum") String carNum);
Integer updateTime(Stop stop);
void addPay(@Param("userId") Integer userId, @Param("stopId") Integer stopId);
}

View File

@ -0,0 +1,8 @@
package com.bwie.list.service;
import com.bwie.common.pojo.vo.VOLogMake;
import com.bwie.common.result.Result;
public interface ParkingService {
Result makeAppointment(VOLogMake voLogMake);
}

View File

@ -0,0 +1,11 @@
package com.bwie.list.service;
import com.bwie.common.pojo.vo.VOStop;
import com.bwie.common.result.Result;
public interface StopService {
Result takeStopPrice(VOStop voStop);
Result findVOStop(String carNum);
}

View File

@ -0,0 +1,46 @@
package com.bwie.list.service.impl;
import com.alibaba.fastjson.JSON;
import com.bwie.common.constants.TokenConstants;
import com.bwie.common.pojo.User;
import com.bwie.common.pojo.vo.VOLogMake;
import com.bwie.common.result.Result;
import com.bwie.common.utils.JwtUtils;
import com.bwie.list.mapper.ParkingMapper;
import com.bwie.list.service.ParkingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
@Service
public class ParkingServiceImpl implements ParkingService {
@Autowired
private ParkingMapper parkingMapper;
@Autowired
private HttpServletRequest request;
@Autowired
private RedisTemplate<String,String> redisTemplate;
@Override
public Result makeAppointment(VOLogMake voLogMake) {
//1.获取用户信息
String token = request.getHeader("token");
String userKey = JwtUtils.getUserKey(token);
String s = redisTemplate.opsForValue().get(TokenConstants.LOGIN_TOKEN_KEY + userKey);
User user = JSON.parseObject(s, User.class);
if (user != null) {
voLogMake.setUserId(user.getUserId());
}
//2.添加预约信息
System.out.println("开始添加");
Integer i = parkingMapper.makeAppointment(voLogMake);
if (i>0){
return Result.success(voLogMake,"预约成功");
}
return Result.error("预约异常");
}
}

View File

@ -0,0 +1,55 @@
package com.bwie.list.service.impl;
import com.bwie.common.pojo.Car;
import com.bwie.common.pojo.DTO.DTOStop;
import com.bwie.common.pojo.Stop;
import com.bwie.common.pojo.vo.VOStop;
import com.bwie.common.result.Result;
import com.bwie.list.mapper.StopMapper;
import com.bwie.list.service.StopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class StopServiceImpl implements StopService {
@Autowired
private StopMapper stopMapper;
@Override
public Result takeStopPrice(VOStop voStop) {
//1.查找车牌号获取用户信息
Car car = stopMapper.findCarId(voStop);
System.out.println("hahahha");
//2.通过车牌号获取停车信息(得到停车时长)
DTOStop dtoStop = stopMapper.findStartDate(voStop.getCarNum());
//3.一个小时3元
if (dtoStop!=null){
Stop stop = new Stop();
stop.setStopId(dtoStop.getStopId());
stop.setStopTime(dtoStop.getTime());
stop.setStopPay(voStop.getStopPay());
stop.setStopPrice(voStop.getStopPrice());
Integer i = stopMapper.updateTime(stop);
if (i>0 && stop.getStopPrice().equals(stop.getStopPay())){
//添加日志
stopMapper.addPay(car.getUserId(),dtoStop.getStopId());
}
}
return Result.success("支付成功");
}
@Override
public Result findVOStop(String carNum) {
DTOStop dtoStop = stopMapper.findStartDate(carNum);
if (dtoStop!=null){
if (dtoStop.getTime()<1){
dtoStop.setStopPrice(3);
}else {
dtoStop.setStopPrice(dtoStop.getTime()*3);
}
return Result.success(dtoStop,"回显成功");
}
return Result.error("失败");
}
}

View File

@ -0,0 +1,29 @@
# Tomcat
server:
port: 9003
# Spring
spring:
main:
allow-circular-references: true
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
application:
# 应用名称
name: bwie-list
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 82.157.236.130:8848
config:
# 配置中心地址
server-addr: 82.157.236.130:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bwie.list.mapper.ParkingMapper">
<insert id="makeAppointment">
insert into `stop_car`.`log_make` (`car_num`,`make_time`,`user_id`)
values (#{carNum},#{makeTime},#{userId})
</insert>
</mapper>

View File

@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.bwie.list.mapper.StopMapper">
<insert id="addPay">
insert into `stop_car`.`log_pay` (`user_id`,`stop_id`,`pay_date`) values (#{userId},#{stopId},NOW())
</insert>
<update id="updateTime">
UPDATE `stop_car`.`t_stop` SET`stop_end` = now(), `stop_time` = #{stopTime}, `stop_state` = 2, `stop_price` = #{stopPrice}, `stop_pay` = #{stopPay} WHERE `stop_id` =#{stopId}
</update>
<select id="findCarId" resultType="com.bwie.common.pojo.Car">
select c.car_id,c.car_name,c.car_num,c.car_card,c.user_id,u.user_name,u.user_sex
FROM t_car c
LEFT JOIN t_user u on c.user_id = u.user_id
where c.car_num=#{carNum}
</select>
<select id="findStartDate" resultType="com.bwie.common.pojo.DTO.DTOStop">
select s.stop_id,s.parking_id,p.parking_name,p.parking_address,s.stop_start,stop_end,stop_time,
s.stop_state,s.stop_price,s.car_id,c.car_name,c.car_num,c.car_card,s.user_id,u.user_name,
u.user_phone,TIMESTAMPDIFF(HOUR,stop_start,NOW()) `time`
FROM t_stop s
LEFT JOIN t_car c on s.car_id = c.car_id
LEFT JOIN t_user u on s.user_id=u.user_id
LEFT JOIN t_parking p on s.parking_id = p.parking_id
where c.car_num=#{carNum}
</select>
<!--
select s.stop_id,s.parking_id,s.stop_start,stop_end,stop_time,s.stop_state,
s.stop_price,s.car_id,c.car_name,c.car_num,c.car_card,s.user_id,u.user_name,u.user_phone
FROM t_stop s
LEFT JOIN t_car c on s.car_id = c.car_id
LEFT JOIN t_user u on s.user_id=u.user_id
-->
</mapper>

View File

@ -0,0 +1,35 @@
package com.bwie.stopCar.controller;
import com.bwie.common.result.Result;
import com.bwie.stopCar.service.StopCarService;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author FangShiBa
* @date 2023/12/12
* @apiNote
*/
@Log4j2
@RestController
@RequestMapping("/stopCar")
public class StopCarController {
@Autowired
private HttpServletRequest request;
@Autowired
private StopCarService service;
//扫码停车(扫码后跳转等车界面,输入车牌)点击确认后修改状态并记录时间判断是否为固定车辆(数据库登记)
//如果是,信息入库而后开闸,不是,添加信息,而后开闸
@PostMapping("/stopCar")
public Result stopCar(@RequestBody VOCar )
}

View File

@ -14,6 +14,7 @@
<module>bwie-gateway</module> <module>bwie-gateway</module>
<module>bwie-models</module> <module>bwie-models</module>
<module>bwie-mq</module> <module>bwie-mq</module>
<module>bwie-models/bwie-list</module>
</modules> </modules>
<properties> <properties>