From 3e5c003f60c477b303da7b639d4430c0d09c990b Mon Sep 17 00:00:00 2001 From: Miku <2634544095@qq.com> Date: Wed, 23 Aug 2023 19:26:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0car=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=EF=BC=8C=E5=AE=9E=E7=8E=B0=E5=81=9C=E8=BD=A6=E5=9C=BA=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E4=B8=9A=E5=8A=A1=EF=BC=8C=E5=81=9C=E8=BD=A6=E8=AE=B0?= =?UTF-8?q?=E5=BD=95=EF=BC=8C=E6=B1=BD=E8=BD=A6=E7=AE=A1=E7=90=86CRUD?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../smart/module/car/entity/CarManage.java | 135 ++++++++++ .../module/car/entity/CarParkManage.java | 102 ++++++++ .../module/car/entity/CarParkingRecord.java | 89 +++++++ .../car/repository/CarManageRepository.java | 10 + .../CarParkingRecordRepository.java | 10 + .../car/repository/ParkManageRepository.java | 10 + .../module/car/service/CarManageService.java | 47 ++++ .../car/service/CarParkingRecordService.java | 33 +++ .../module/car/service/ParkManageService.java | 34 +++ .../service/impl/CarManageServiceImpl.java | 145 +++++++++++ .../impl/CarParkingRecordServiceImpl.java | 102 ++++++++ .../service/impl/ParkManageServiceImpl.java | 90 +++++++ .../module/car/web/CarManageController.java | 88 +++++++ .../car/web/CarParkingRecordController.java | 46 ++++ .../module/car/web/ParkManageController.java | 91 +++++++ .../templates/car/carManage/form.html | 204 +++++++++++++++ .../templates/car/carManage/list.html | 240 ++++++++++++++++++ .../templates/car/carManage/org.html | 71 ++++++ .../templates/car/carManage/park.html | 71 ++++++ .../templates/car/carManage/renew.html | 132 ++++++++++ .../templates/car/parkManage/form.html | 140 ++++++++++ .../templates/car/parkManage/list.html | 177 +++++++++++++ .../templates/car/parkManage/org.html | 71 ++++++ .../templates/car/parkManage/payConfig.html | 82 ++++++ .../templates/car/parkingRecord/list.html | 196 ++++++++++++++ 25 files changed, 2416 insertions(+) create mode 100644 src/main/java/com/smart/module/car/entity/CarManage.java create mode 100644 src/main/java/com/smart/module/car/entity/CarParkManage.java create mode 100644 src/main/java/com/smart/module/car/entity/CarParkingRecord.java create mode 100644 src/main/java/com/smart/module/car/repository/CarManageRepository.java create mode 100644 src/main/java/com/smart/module/car/repository/CarParkingRecordRepository.java create mode 100644 src/main/java/com/smart/module/car/repository/ParkManageRepository.java create mode 100644 src/main/java/com/smart/module/car/service/CarManageService.java create mode 100644 src/main/java/com/smart/module/car/service/CarParkingRecordService.java create mode 100644 src/main/java/com/smart/module/car/service/ParkManageService.java create mode 100644 src/main/java/com/smart/module/car/service/impl/CarManageServiceImpl.java create mode 100644 src/main/java/com/smart/module/car/service/impl/CarParkingRecordServiceImpl.java create mode 100644 src/main/java/com/smart/module/car/service/impl/ParkManageServiceImpl.java create mode 100644 src/main/java/com/smart/module/car/web/CarManageController.java create mode 100644 src/main/java/com/smart/module/car/web/CarParkingRecordController.java create mode 100644 src/main/java/com/smart/module/car/web/ParkManageController.java create mode 100644 src/main/resources/templates/car/carManage/form.html create mode 100644 src/main/resources/templates/car/carManage/list.html create mode 100644 src/main/resources/templates/car/carManage/org.html create mode 100644 src/main/resources/templates/car/carManage/park.html create mode 100644 src/main/resources/templates/car/carManage/renew.html create mode 100644 src/main/resources/templates/car/parkManage/form.html create mode 100644 src/main/resources/templates/car/parkManage/list.html create mode 100644 src/main/resources/templates/car/parkManage/org.html create mode 100644 src/main/resources/templates/car/parkManage/payConfig.html create mode 100644 src/main/resources/templates/car/parkingRecord/list.html diff --git a/src/main/java/com/smart/module/car/entity/CarManage.java b/src/main/java/com/smart/module/car/entity/CarManage.java new file mode 100644 index 0000000..9c880f0 --- /dev/null +++ b/src/main/java/com/smart/module/car/entity/CarManage.java @@ -0,0 +1,135 @@ +package com.smart.module.car.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.smart.common.model.PageBean; +import lombok.Data; + +import javax.persistence.*; +import java.io.Serializable; +import java.sql.Timestamp; + +/** + * app_car 实体类 + */ +/** + * app_car 实体类 + */ +@Data // 使用Lombok插件自动生成getter、setter等方法 +@Entity // 声明该类为实体类 +@Table(name = "app_car_manage") // 指定实体类对应的数据库表名为app_car_manage +public class CarManage extends PageBean implements Serializable { + + @Id // 声明该属性为主键 + @GeneratedValue(strategy = GenerationType.IDENTITY) // 设置主键生成策略为自增 + @Column(name = "id", nullable = false, length = 20) // 指定该属性对应数据库表中的id列,非空且长度为20 + private Long id; + + /** + * 名称 + */ + @Column(name = "name", length = 500) // 指定该属性对应数据库表中的name列,长度为500 + private String name; + + /** + * 所属单位ID + */ + @Column(name = "org_id", nullable = false, length = 20) // 指定该属性对应数据库表中的org_id列,非空且长度为20 + private Long orgId; + + /** + * 所属单位 + */ + @Column(name = "org_name", length = 500) // 指定该属性对应数据库表中的org_name列,长度为500 + private String orgName; + + + /** + * 停车场ID + */ + @Column(name = "park_manage_id", nullable = false, length = 20) + private Long parkManageId; + + /** + * 停车场 + */ + @Column(name = "park_manage_name", length = 500) + private String parkManageName; + + /** + * 车牌号 + */ + @Column(name = "plate_number", length = 100) + private String plateNumber; + + /** + * 性别 + */ + @Column(name = "gender", length = 1) + private String gender; + + /** + * 车主姓名 + */ + @Column(name = "nickname", length = 100) + private String nickname; + + /** + * 手机号 + */ + @Column(name = "mobile", length = 20) + private String mobile; + + + /** + * 已购车位 + */ + @Column(name = "parking_lot", length = 100) + private String parkingLot; + + /** + * 类型 0:包月车 1:VIP免费车 2:临时 + */ + @Column(name = "type", length = 4) + private Short type; + + /** + * 状态,0:禁用 1:正常 + */ + @Column(name = "status", length = 4) + private Short status; + + /** + * 备注 + */ + @Column(name = "remark", length = 200) + private String remark; + + /** + * 有效期至 + */ + @Column(name = "validity_time") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Timestamp validityTime; + + /** + * 创建时间 + */ + @Column(name = "gmt_create") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") // 该属性在序列化为JSON时按指定格式进行格式化 + private Timestamp gmtCreate; + + /** + * 修改时间 + */ + @Column(name = "gmt_modified") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Timestamp gmtModified; + + /** + * 创建用户id + */ + @Column(name = "user_id_create")// 指定该属性对应数据库表中的user_id_create列 + private Long userIdCreate; + +} + diff --git a/src/main/java/com/smart/module/car/entity/CarParkManage.java b/src/main/java/com/smart/module/car/entity/CarParkManage.java new file mode 100644 index 0000000..ff184b8 --- /dev/null +++ b/src/main/java/com/smart/module/car/entity/CarParkManage.java @@ -0,0 +1,102 @@ +package com.smart.module.car.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.smart.common.config.BigDecimalSerialize; +import com.smart.common.model.PageBean; +import lombok.Data; + +import javax.persistence.*; +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.Timestamp; + +/** + * app_car_park_manage 实体类 + */ +@Data // 使用Lombok插件自动生成getter、setter等方法 +@Entity // 声明该类为实体类 +@Table(name = "app_car_park_manage") // 指定实体类对应的数据库表名为app_car_park_manage +public class CarParkManage extends PageBean implements Serializable { + + @Id // 声明该属性为主键 + @GeneratedValue(strategy = GenerationType.IDENTITY) // 设置主键生成策略为自增 + @Column(name = "id", nullable = false, length = 20) // 指定该属性对应数据库表中的id列,非空且长度为20 + private Long id; + + /** + * 名称 + */ + @Column(name = "name", length = 500) // 指定该属性对应数据库表中的name列,长度为500 + private String name; + + /** + * 所属单位 + */ + @Column(name = "org_id", nullable = false, length = 20) // 指定该属性对应数据库表中的org_id列,非空且长度为20 + private Long orgId; + + /** + * 所属单位 + */ + @Column(name = "org_name", length = 500) // 指定该属性对应数据库表中的org_name列,长度为500 + private String orgName; + + /** + * 状态,0:隐藏 1:显示 + */ + @Column(name = "status", length = 4) // 指定该属性对应数据库表中的status列,长度为4 + private Short status; + + /** + * 停车位数量 + */ + @Column(name = "parking_space_number") // 指定该属性对应数据库表中的parking_space_number列 + private Integer parkingSpaceNumber; + + /** + * 免费时长 + */ + @Column(name = "free_time") // 指定该属性对应数据库表中的free_time列 + private Integer freeTime; + + /** + * 计时单元 + */ + @Column(name = "time_unit") // 指定该属性对应数据库表中的time_unit列 + private Integer timeUnit; + + /** + * 单元费用 + */ + @JsonSerialize(using = BigDecimalSerialize.class) // 对BigDecimal类型的字段进行序列化时,使用自定义的BigDecimalSerialize类进行处理 + @Column(name = "unit_cost", scale = 2, precision = 18) // 指定该属性对应数据库表中的unit_cost列,其精度为18位,小数点后保留2位 + private BigDecimal unitCost; + + /** + * 最大收费金额 + */ + @JsonSerialize(using = BigDecimalSerialize.class) // 对BigDecimal类型的字段进行序列化时,使用自定义的BigDecimalSerialize类进行处理 + @Column(name = "max_money", scale = 2, precision = 18) // 指定该属性对应数据库表中的max_money列,其精度为18位,小数点后保留2位 + private BigDecimal maxMoney; + + /** + * 创建时间 + */ + @Column(name = "gmt_create") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") // 该属性在序列化为JSON时按指定格式进行格式化 + private Timestamp gmtCreate; + + /** + * 修改时间 + */ + @Column(name = "gmt_modified") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") // 该属性在序列化为JSON时按指定格式进行格式化 + private Timestamp gmtModified; + + /** + * 创建用户id + */ + @Column(name = "user_id_create") // 指定该属性对应数据库表中的user_id_create列 + private Long userIdCreate; +} diff --git a/src/main/java/com/smart/module/car/entity/CarParkingRecord.java b/src/main/java/com/smart/module/car/entity/CarParkingRecord.java new file mode 100644 index 0000000..bece7d2 --- /dev/null +++ b/src/main/java/com/smart/module/car/entity/CarParkingRecord.java @@ -0,0 +1,89 @@ +package com.smart.module.car.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.smart.common.config.BigDecimalSerialize; +import com.smart.common.model.PageBean; +import lombok.Data; + +import javax.persistence.*; +import java.io.Serializable; +import java.math.BigDecimal; +import java.sql.Timestamp; + +/** + * app_car_parking_record 实体类 + */ +@Data // 使用Lombok插件自动生成getter、setter等方法 +@Entity // 声明该类为实体类 +@Table(name = "app_car_parking_record") // 指定实体类对应的数据库表名为app_car_parking_record +public class CarParkingRecord extends PageBean implements Serializable { + + @Id // 声明该属性为主键 + @GeneratedValue(strategy = GenerationType.IDENTITY) // 设置主键生成策略为自增 + @Column(name = "id", nullable = false, length = 20) // 指定该属性对应数据库表中的id列,非空且长度为20 + private Long id; + + /** + * 订单号 + */ + @Column(name = "order_no", length = 500) // 指定该属性对应数据库表中的order_no列,长度为500 + private String orderNo; + + /** + * 所属单位 + */ + @Column(name = "org_id", nullable = false, length = 20) // 指定该属性对应数据库表中的org_id列,非空且长度为20 + private Long orgId; + + /** + * 所属单位 + */ + @Column(name = "org_name", length = 500) // 指定该属性对应数据库表中的org_name列,长度为500 + private String orgName; + + /** + * 停车场 + */ + @Column(name = "park_manage_id", nullable = false, length = 20) // 指定该属性对应数据库表中的park_manage_id列,非空且长度为20 + private Long parkManageId; + + /** + * 停车场 + */ + @Column(name = "park_manage_name", length = 500) // 指定该属性对应数据库表中的park_manage_name列,长度为500 + private String parkManageName; + + /** + * 车牌号 + */ + @Column(name = "plate_number", length = 100) // 指定该属性对应数据库表中的plate_number列,长度为100 + private String plateNumber; + + /** + * 类型 ,0:包月车 1:VIP免费车 2:临时车 + */ + @Column(name = "type", length = 4) // 指定该属性对应数据库表中的type列,长度为4 + private Short type; + + /** + * 入场时间 + */ + @Column(name = "gmt_into") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") // 该属性在序列化为JSON时按指定格式进行格式化 + private Timestamp gmtInto; + + /** + * 出场时间 + */ + @Column(name = "gmt_out") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") // 该属性在序列化为JSON时按指定格式进行格式化 + private Timestamp gmtOut; + + /** + * 收费金额 + */ + @JsonSerialize(using = BigDecimalSerialize.class) // 对BigDecimal类型的字段进行序列化时,使用自定义的BigDecimalSerialize类进行处理 + @Column(name = "cost", scale = 2, precision = 18) // 指定该属性对应数据库表中的cost列,其精度为18位,小数点后保留2位 + private BigDecimal cost; +} diff --git a/src/main/java/com/smart/module/car/repository/CarManageRepository.java b/src/main/java/com/smart/module/car/repository/CarManageRepository.java new file mode 100644 index 0000000..4ac18d5 --- /dev/null +++ b/src/main/java/com/smart/module/car/repository/CarManageRepository.java @@ -0,0 +1,10 @@ +package com.smart.module.car.repository; + +import com.smart.module.car.entity.CarManage; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository// 声明该类为仓库类 +public interface CarManageRepository extends JpaRepository { + +} diff --git a/src/main/java/com/smart/module/car/repository/CarParkingRecordRepository.java b/src/main/java/com/smart/module/car/repository/CarParkingRecordRepository.java new file mode 100644 index 0000000..a5f71cb --- /dev/null +++ b/src/main/java/com/smart/module/car/repository/CarParkingRecordRepository.java @@ -0,0 +1,10 @@ +package com.smart.module.car.repository; + +import com.smart.module.car.entity.CarParkingRecord; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository// 声明该类为仓库类 +public interface CarParkingRecordRepository extends JpaRepository { + +} diff --git a/src/main/java/com/smart/module/car/repository/ParkManageRepository.java b/src/main/java/com/smart/module/car/repository/ParkManageRepository.java new file mode 100644 index 0000000..ec896c9 --- /dev/null +++ b/src/main/java/com/smart/module/car/repository/ParkManageRepository.java @@ -0,0 +1,10 @@ +package com.smart.module.car.repository; + +import com.smart.module.car.entity.CarParkManage; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository// 声明该类为仓库类 +public interface ParkManageRepository extends JpaRepository { + +} diff --git a/src/main/java/com/smart/module/car/service/CarManageService.java b/src/main/java/com/smart/module/car/service/CarManageService.java new file mode 100644 index 0000000..9bc4824 --- /dev/null +++ b/src/main/java/com/smart/module/car/service/CarManageService.java @@ -0,0 +1,47 @@ +package com.smart.module.car.service; + +import com.smart.common.model.Result; +import com.smart.common.util.ExcelExport; +import com.smart.module.car.entity.CarManage; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; + +import java.io.IOException; + +/** + * 车辆管理 + */ +public interface CarManageService { + + /** + * 保存车辆管理信息 + * @param entity 车辆管理实体对象 + * @return 返回保存结果 + */ + Result save(CarManage entity); + + /** + * 查询车辆管理列表 + * @param entity 车辆管理实体对象,用于构建查询条件 + * @return 返回查询结果 + */ + Result list(CarManage entity); + + /** + * 根据车牌号和停车场ID获取车辆管理信息 + * @param plateNumber 车牌号 + * @param parkManageId 停车场ID + * @return 返回车辆管理实体对象 + */ + CarManage getByPlateNumber(String plateNumber, Long parkManageId); + + /** + * 导出数据至Excel文件 + * @param orgId 组织机构ID + * @param parkManageId 停车场ID + * @return 返回导出的Excel文件对象 + * @throws IOException 异常处理 + * @throws InvalidFormatException 异常处理 + */ + ExcelExport exportData(Long orgId, Long parkManageId) throws IOException, InvalidFormatException; + +} diff --git a/src/main/java/com/smart/module/car/service/CarParkingRecordService.java b/src/main/java/com/smart/module/car/service/CarParkingRecordService.java new file mode 100644 index 0000000..bddfa16 --- /dev/null +++ b/src/main/java/com/smart/module/car/service/CarParkingRecordService.java @@ -0,0 +1,33 @@ +package com.smart.module.car.service; + +import com.smart.common.model.Result; +import com.smart.module.car.entity.CarParkingRecord; + +/** + * 车辆管理 + */ +public interface CarParkingRecordService { + + /** + * 保存车辆停车记录 + * @param entity + * @return + */ + Result save(CarParkingRecord entity); + + /** + * 查询车辆停车记录列表 + * @param entity + * @return + */ + Result list(CarParkingRecord entity); + + /** + * 根据车牌和停车场获取停车记录 + * @param plateNumber + * @param parkManageId + * @return + */ + CarParkingRecord getByPlateNumber(String plateNumber,Long parkManageId); + +} diff --git a/src/main/java/com/smart/module/car/service/ParkManageService.java b/src/main/java/com/smart/module/car/service/ParkManageService.java new file mode 100644 index 0000000..9454518 --- /dev/null +++ b/src/main/java/com/smart/module/car/service/ParkManageService.java @@ -0,0 +1,34 @@ +package com.smart.module.car.service; + +import com.smart.common.model.Result; +import com.smart.module.car.entity.CarParkManage; + +import java.util.List; +import java.util.Map; + +/** + * 停车场管理 + */ +public interface ParkManageService { + + /** + * 保存停车场信息到数据库 + * @param entity + * @return + */ + Result save(CarParkManage entity); + + /** + * 查询停车场信息列表 + * @param entity + * @return + */ + Result list(CarParkManage entity); + + /** + * 根据用户权限获取停车场信息下拉列表数据 + * @param entity + * @return + */ + List> select(CarParkManage entity); +} diff --git a/src/main/java/com/smart/module/car/service/impl/CarManageServiceImpl.java b/src/main/java/com/smart/module/car/service/impl/CarManageServiceImpl.java new file mode 100644 index 0000000..7fc767b --- /dev/null +++ b/src/main/java/com/smart/module/car/service/impl/CarManageServiceImpl.java @@ -0,0 +1,145 @@ +package com.smart.module.car.service.impl; + +import cn.hutool.core.io.FileUtil; +import com.smart.common.constant.SystemConstant; +import com.smart.common.dynamicquery.DynamicQuery; +import com.smart.common.model.PageBean; +import com.smart.common.model.Result; +import com.smart.common.util.DateUtils; +import com.smart.common.util.ExcelExport; +import com.smart.common.util.ShiroUtils; +import com.smart.module.car.entity.CarManage; +import com.smart.module.car.repository.CarManageRepository; +import com.smart.module.car.service.CarManageService; +import com.smart.module.sys.entity.SysUser; +import org.apache.commons.lang3.StringUtils; +import org.apache.poi.openxml4j.exceptions.InvalidFormatException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.ClassUtils; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.sql.Timestamp; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +@Service +public class CarManageServiceImpl implements CarManageService { + + @Autowired + private DynamicQuery dynamicQuery; // 动态查询工具类 + + @Autowired + private CarManageRepository carManageRepository; // 汽车管理的数据访问层接口 + + + // 保存汽车管理信息并刷新到数据库 + @Override + @Transactional(rollbackFor=Exception.class) + public Result save(CarManage entity) { + if(entity.getId()==null){ + entity.setGmtCreate(DateUtils.getTimestamp()); // 设置创建时间为当前时间 + entity.setGmtModified(entity.getGmtCreate()); + }else{ + entity.setGmtModified(DateUtils.getTimestamp()); // 设置修改时间为当前时间 + } + carManageRepository.saveAndFlush(entity); // 保存并刷新实体对象到数据库 + return Result.ok("保存成功"); + } + + // 查询汽车管理列表 + @Override + public Result list(CarManage entity) { + String nativeSql = "SELECT COUNT(*) FROM app_car_manage "; + nativeSql += common(entity); // 构建通用的 SQL 条件语句 + Long count = dynamicQuery.nativeQueryCount(nativeSql); // 执行原生查询,统计总数 + PageBean data = new PageBean<>(); + if(count>0){ + nativeSql = "SELECT * FROM app_car_manage "; + nativeSql += common(entity); + nativeSql += " ORDER BY gmt_create desc"; + Pageable pageable = PageRequest.of(entity.getPageNo(),entity.getPageSize()); // 构建分页请求对象 + List list = dynamicQuery.nativeQueryPagingList(CarManage.class,pageable,nativeSql); // 执行分页查询 + data = new PageBean(list,count); // 构建分页结果对象 + } + return Result.ok(data); + } + + // 根据车牌号和停车场ID获取汽车管理信息 + @Override + public CarManage getByPlateNumber(String plateNumber, Long parkManageId) { + String nativeSql = "SELECT * FROM app_car_manage WHERE plate_number=? AND park_manage_id=? "; + CarManage carManage = + dynamicQuery.nativeQuerySingleResult(CarManage.class,nativeSql,plateNumber,parkManageId); // 执行原生查询,获取单个对象 + return carManage; + } + + + + // 导出数据至 Excel + @Override + @Transactional(readOnly = true) + public ExcelExport exportData(Long orgId,Long parkManageId) throws IOException, InvalidFormatException { + SysUser user = ShiroUtils.getUserEntity(); + Map dataMap = new LinkedHashMap<>(); + dataMap.put("org_name", ExcelExport.CELL_ALIGN_LEFT); // 设置列名与对齐方式的映射关系 + dataMap.put("park_manage_name", ExcelExport.CELL_ALIGN_LEFT); + dataMap.put("plate_number", ExcelExport.CELL_ALIGN_LEFT); + dataMap.put("nickname", ExcelExport.CELL_ALIGN_LEFT); + dataMap.put("type", ExcelExport.CELL_ALIGN_LEFT); + dataMap.put("status", ExcelExport.CELL_ALIGN_LEFT); + dataMap.put("validity_time", ExcelExport.CELL_ALIGN_LEFT); + String nativeSql = "SELECT org_name,park_manage_name,plate_number,nickname,(CASE TYPE WHEN 0 THEN '包月车' ELSE '免费车' END) type ,(CASE STATUS WHEN 0 THEN '禁用' ELSE '正常' END) status,validity_time FROM app_car_manage WHERE 1=1"; + List> list; + if(ShiroUtils.isHasRole(SystemConstant.ROLE_ADMIN)){ + if(orgId!=null){ + nativeSql +=" AND org_id="+orgId; + } + }else{ + nativeSql +=" AND org_id="+user.getOrgId(); + } + if(parkManageId!=null){ + nativeSql +=" AND park_manage_id=?"; + list = dynamicQuery.nativeQueryListMap(nativeSql,parkManageId); // 执行原生查询,获取多个对象的列表 + }else{ + list = dynamicQuery.nativeQueryListMap(nativeSql); + } + /** + * 开始生成模板、导出数据 + */ + InputStream stream = ClassUtils.getDefaultClassLoader() + .getResourceAsStream("static/excelTemplate/carManageExport.xls"); + ExcelExport excelExport = new ExcelExport( + FileUtil.writeFromStream(stream, new File("excelTemplate/carManageExport.xls")), 1); // 创建 Excel 导出工具类对象 + excelExport.setDataList(list, dataMap, false, ""); // 设置导出数据和列名与对齐方式的映射关系 + return excelExport; // 返回 Excel 导出工具类对象 + } + + // 构建通用的 SQL 条件语句 + public String common(CarManage entity){ + String description = entity.getDescription(); + String commonSql = " WHERE 1=1 "; + if(StringUtils.isNotBlank(description)){ + commonSql += " AND name like '"+description+"%' "; + } + if(ShiroUtils.isHasRole(SystemConstant.ROLE_ADMIN)){ + if(entity.getOrgId()!=null){ + commonSql +=" AND org_id="+entity.getOrgId(); + } + }else{ + Long orgId = ShiroUtils.getUserEntity().getOrgId(); + commonSql +=" AND org_id="+orgId; + } + if(entity.getParkManageId()!=null){ + commonSql +=" AND park_manage_id="+entity.getParkManageId(); + } + return commonSql; + } + +} diff --git a/src/main/java/com/smart/module/car/service/impl/CarParkingRecordServiceImpl.java b/src/main/java/com/smart/module/car/service/impl/CarParkingRecordServiceImpl.java new file mode 100644 index 0000000..387713b --- /dev/null +++ b/src/main/java/com/smart/module/car/service/impl/CarParkingRecordServiceImpl.java @@ -0,0 +1,102 @@ +package com.smart.module.car.service.impl; + +import com.smart.common.constant.SystemConstant; +import com.smart.common.dynamicquery.DynamicQuery; +import com.smart.common.model.PageBean; +import com.smart.common.model.Result; +import com.smart.common.util.DateUtils; +import com.smart.common.util.ShiroUtils; +import com.smart.module.car.entity.CarParkingRecord; +import com.smart.module.car.repository.CarParkingRecordRepository; +import com.smart.module.car.service.CarParkingRecordService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * 车辆停车记录模块的服务实现类 + */ +@Service +public class CarParkingRecordServiceImpl implements CarParkingRecordService { + + @Autowired + private DynamicQuery dynamicQuery; + @Autowired + private CarParkingRecordRepository carParkingRecordRepository; + + + @Override + @Transactional(rollbackFor=Exception.class) + public Result save(CarParkingRecord entity) { + + carParkingRecordRepository.saveAndFlush(entity); + return Result.ok("保存成功"); + } + + /** + * 计算符合条件的记录总数 + * @param entity + * @return + */ + + @Override + public Result list(CarParkingRecord entity) { + String nativeSql = "SELECT COUNT(*) FROM app_car_parking_record "; + nativeSql += common(entity); + Long count = dynamicQuery.nativeQueryCount(nativeSql); + PageBean data = new PageBean<>(); + if(count>0){ + nativeSql = "SELECT * FROM app_car_parking_record "; + nativeSql += common(entity); + nativeSql += " ORDER BY gmt_into desc"; + Pageable pageable = PageRequest.of(entity.getPageNo(),entity.getPageSize());//分页查询 + List list = + dynamicQuery.nativeQueryPagingList(CarParkingRecord.class,pageable,nativeSql); + data = new PageBean(list,count); + } + return Result.ok(data); + } + + /** + * + * @param plateNumber + * @param parkManageId + * @return 返回车辆停车记录实体对象 + */ + @Override + public CarParkingRecord getByPlateNumber(String plateNumber, Long parkManageId) { + String nativeSql = "SELECT * FROM app_car_parking_record WHERE plate_number=? AND park_manage_id=? AND gmt_out is null"; + return dynamicQuery.nativeQuerySingleResult(CarParkingRecord.class,nativeSql,plateNumber,parkManageId); + } + + /** + * 构建通用的SQL查询条件 + * @param entity + * @return + */ + public String common(CarParkingRecord entity){ + String description = entity.getDescription(); + String commonSql = " WHERE 1=1"; + if(StringUtils.isNotBlank(description)){ + commonSql += " AND plate_number like '"+description+"%' "; + } + if(ShiroUtils.isHasRole(SystemConstant.ROLE_ADMIN)){ + if(entity.getOrgId()!=null){ + commonSql +=" AND org_id="+entity.getOrgId(); + } + }else{ + Long orgId = ShiroUtils.getUserEntity().getOrgId(); + commonSql +=" AND org_id="+orgId; + } + if(entity.getParkManageId()!=null){ + commonSql +=" AND park_manage_id="+entity.getParkManageId(); + } + return commonSql; + } + +} diff --git a/src/main/java/com/smart/module/car/service/impl/ParkManageServiceImpl.java b/src/main/java/com/smart/module/car/service/impl/ParkManageServiceImpl.java new file mode 100644 index 0000000..fb11a62 --- /dev/null +++ b/src/main/java/com/smart/module/car/service/impl/ParkManageServiceImpl.java @@ -0,0 +1,90 @@ +package com.smart.module.car.service.impl; + +import com.smart.common.constant.SystemConstant; +import com.smart.common.dynamicquery.DynamicQuery; +import com.smart.common.model.PageBean; +import com.smart.common.model.Result; +import com.smart.common.util.DateUtils; +import com.smart.common.util.ShiroUtils; +import com.smart.module.car.entity.CarParkManage; +import com.smart.module.car.repository.ParkManageRepository; +import com.smart.module.car.service.ParkManageService; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.PageRequest; +import org.springframework.data.domain.Pageable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Map; + +@Service // 服务注解,表示该类为一个服务类 +public class ParkManageServiceImpl implements ParkManageService { + + // 自动装配动态查询工具类和停车场仓库类 + @Autowired + private DynamicQuery dynamicQuery; + @Autowired + private ParkManageRepository parkManageRepository; + + // 保存停车场信息的方法 + @Override + @Transactional(rollbackFor=Exception.class) // 添加事务注解,表示该方法需要事务支持 + public Result save(CarParkManage entity) { + // 判断是新增还是更新停车场信息 + if(entity.getId()==null){ + entity.setGmtCreate(DateUtils.getTimestamp()); // 设置创建时间 + entity.setGmtModified(entity.getGmtCreate()); // 设置修改时间 + }else{ + entity.setGmtModified(DateUtils.getTimestamp()); // 设置修改时间 + } + parkManageRepository.saveAndFlush(entity); // 保存停车场信息到数据库 + return Result.ok("保存成功"); // 返回操作结果 + } + + // 查询停车场信息列表的方法 + @Override + public Result list(CarParkManage entity) { + String nativeSql = "SELECT COUNT(*) FROM app_car_park_manage "; // 构建查询总数的 SQL 语句 + nativeSql += common(entity); // 拼接公共查询条件 + Long count = dynamicQuery.nativeQueryCount(nativeSql); // 查询符合条件的停车场信息总数 + + PageBean data = new PageBean<>(); // 创建分页实体类对象 + if(count>0){ + nativeSql = "SELECT * FROM app_car_park_manage "; // 构建查询数据的 SQL 语句 + nativeSql += common(entity); // 拼接公共查询条件 + nativeSql += "ORDER BY gmt_create desc"; // 按创建时间倒序排序 + Pageable pageable = PageRequest.of(entity.getPageNo(),entity.getPageSize()); // 创建分页请求对象 + List list = dynamicQuery.nativeQueryPagingList(CarParkManage.class,pageable,nativeSql); // 分页查询符合条件的停车场信息列表 + data = new PageBean(list,count); // 设置查询结果到分页实体类对象中 + } + return Result.ok(data); // 返回查询结果 + } + + // 获取停车场信息下拉列表的方法 + @Override + @Transactional(readOnly = true) // 添加只读事务注解,表示该方法不进行数据修改操作 + public List> select(CarParkManage entity) { + String nativeSql = "SELECT id,name FROM app_car_park_manage WHERE 1=1"; // 构建查询 SQL 语句 + if(ShiroUtils.isHasRole(SystemConstant.ROLE_ADMIN)){ // 判断当前用户是否具有管理员角色 + if(entity.getOrgId()!=null){ + nativeSql +=" AND org_id="+entity.getOrgId(); // 根据组织机构ID查询对应的停车场信息 + } + }else{ + Long orgId = ShiroUtils.getUserEntity().getOrgId(); // 获取当前登录用户的组织机构ID + nativeSql +=" AND org_id="+orgId; // 根据当前登录用户的组织机构ID查询对应的停车场信息 + } + return dynamicQuery.nativeQueryListMap(nativeSql); // 执行查询并返回停车场ID和名称的列表数据 + } + + // 辅助方法,拼接公共查询条件 + public String common(CarParkManage entity){ + String description = entity.getDescription(); // 获取停车场名称的查询条件 + String commonSql = ""; + if(StringUtils.isNotBlank(description)){ + commonSql += "WHERE name like '"+description+"%' "; // 根据停车场名称模糊查询 + } + return commonSql; + } +} diff --git a/src/main/java/com/smart/module/car/web/CarManageController.java b/src/main/java/com/smart/module/car/web/CarManageController.java new file mode 100644 index 0000000..d852275 --- /dev/null +++ b/src/main/java/com/smart/module/car/web/CarManageController.java @@ -0,0 +1,88 @@ +package com.smart.module.car.web; + +import com.smart.common.model.Result; +import com.smart.common.util.ExcelExport; +import com.smart.module.car.entity.CarManage; +import com.smart.module.car.repository.CarManageRepository; +import com.smart.module.car.service.CarManageService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresRoles; +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; +import javax.servlet.http.HttpServletResponse; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * 停车场管理 + */ +@RestController +@RequestMapping("/car/manage") +public class CarManageController { + + @Autowired + private CarManageService carManageService; + @Autowired + private CarManageRepository carManageRepository; + + /** + * 查询停车场信息列表 + */ + @PostMapping("list") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result list(CarManage entity){ + return carManageService.list(entity); + } + + /** + * 获取指定ID的停车场信息 + */ + @PostMapping("get") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result get(Long id){ + CarManage entity = + carManageRepository.findById(id).orElse(new CarManage()); + return Result.ok(entity); + } + + /** + * 保存或更新停车场信息 + */ + @PostMapping("save") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result save(@RequestBody CarManage entity){ + return carManageService.save(entity); + } + + /** + * 删除指定ID的停车场信息 + */ + @PostMapping("delete") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result delete(Long id){ + carManageRepository.deleteById(id); + return Result.ok(); + } + + + /** + * 导出车辆信息到Excel文件 + */ + @PostMapping("export") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public void export(Long orgId,Long parkManageId,HttpServletRequest request, HttpServletResponse response){ + try{ + ExcelExport excelExport = carManageService.exportData(orgId,parkManageId); + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss"); + excelExport.writeTemplate(response, request, + "车辆信息-" + sdf.format(new Date()) + ".xls"); + }catch (Exception e){ + e.printStackTrace(); + } + } +} diff --git a/src/main/java/com/smart/module/car/web/CarParkingRecordController.java b/src/main/java/com/smart/module/car/web/CarParkingRecordController.java new file mode 100644 index 0000000..917d291 --- /dev/null +++ b/src/main/java/com/smart/module/car/web/CarParkingRecordController.java @@ -0,0 +1,46 @@ +package com.smart.module.car.web; + +import com.smart.common.model.Result; +import com.smart.module.car.entity.CarParkingRecord; +import com.smart.module.car.repository.CarParkingRecordRepository; +import com.smart.module.car.service.CarParkingRecordService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresRoles; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * 车辆进出记录 + */ +@RestController +@RequestMapping("/car/parkingRecord") +public class CarParkingRecordController { + + @Autowired + private CarParkingRecordService carParkingRecordService; + @Autowired + private CarParkingRecordRepository carParkingRecordRepository; + + /** + * 查询车辆进出记录列表 + */ + @PostMapping("list") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result list(CarParkingRecord entity){ + return carParkingRecordService.list(entity); + } + + /** + * 获取指定ID的车辆进出记录信息 + */ + @PostMapping("get") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result get(Long id){ + CarParkingRecord entity = + carParkingRecordRepository.findById(id).orElse(new CarParkingRecord()); + return Result.ok(entity); + } + +} diff --git a/src/main/java/com/smart/module/car/web/ParkManageController.java b/src/main/java/com/smart/module/car/web/ParkManageController.java new file mode 100644 index 0000000..5131873 --- /dev/null +++ b/src/main/java/com/smart/module/car/web/ParkManageController.java @@ -0,0 +1,91 @@ +package com.smart.module.car.web; + +import com.smart.common.model.Result; +import com.smart.common.util.OrderUtils; +import com.smart.module.car.entity.CarParkManage; +import com.smart.module.car.repository.ParkManageRepository; +import com.smart.module.car.service.ParkManageService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresRoles; +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 java.util.List; +import java.util.Map; + +/** + * 停车场管理 + */ +@RestController +@RequestMapping("/car/parkManage") +public class ParkManageController { + + @Autowired + private ParkManageService parkManageService; + // 注入停车场管理服务,用于业务处理 + + @Autowired + private ParkManageRepository parkManageRepository; + // 注入停车场管理仓库,用于查询停车场信息 + + + + /** + * 停车场列表信息 + */ + @PostMapping("list") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result list(CarParkManage entity){ + return parkManageService.list(entity); + } + // 返回停车场列表信息的接口,需要管理员或组织管理员角色权限 + + /** + * 根据停车场id获取停车场信息 + */ + @PostMapping("get") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result get(Long id){ + CarParkManage carParkManage = + parkManageRepository.findById(id).orElse(new CarParkManage()); + return Result.ok(carParkManage); + } + // 根据停车场id获取停车场信息的接口,需要管理员或组织管理员角色权限 + + /** + * 保存停车场信息 + */ + @PostMapping("save") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result save(@RequestBody CarParkManage entity){ + return parkManageService.save(entity); + } + // 保存停车场信息的接口,需要管理员或组织管理员角色权限 + + /** + * 删除停车场信息 + */ + @PostMapping("delete") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result delete(Long id){ + parkManageRepository.deleteById(id); + return Result.ok(); + } + // 删除停车场信息的接口,需要管理员或组织管理员角色权限 + + /** + * 列表 + */ + @PostMapping("/select") + @RequiresRoles(value={"admin","orgAdmin"},logical = Logical.OR) + public Result select(CarParkManage entity){ + List> list = parkManageService.select(entity); + return Result.ok(list); + } + // 返回停车场列表信息的接口,需要管理员或组织管理员角色权限 + + +} diff --git a/src/main/resources/templates/car/carManage/form.html b/src/main/resources/templates/car/carManage/form.html new file mode 100644 index 0000000..a4b9de7 --- /dev/null +++ b/src/main/resources/templates/car/carManage/form.html @@ -0,0 +1,204 @@ + + + + +
+ +
+
+ + + \ No newline at end of file diff --git a/src/main/resources/templates/car/carManage/list.html b/src/main/resources/templates/car/carManage/list.html new file mode 100644 index 0000000..77d2abb --- /dev/null +++ b/src/main/resources/templates/car/carManage/list.html @@ -0,0 +1,240 @@ + + + + +
+ + + + +
+
+ + + diff --git a/src/main/resources/templates/car/carManage/org.html b/src/main/resources/templates/car/carManage/org.html new file mode 100644 index 0000000..26f35e0 --- /dev/null +++ b/src/main/resources/templates/car/carManage/org.html @@ -0,0 +1,71 @@ + + + + + + + + +
+
+
    +
    +
    +
    + + + \ No newline at end of file diff --git a/src/main/resources/templates/car/carManage/park.html b/src/main/resources/templates/car/carManage/park.html new file mode 100644 index 0000000..d1eb7e2 --- /dev/null +++ b/src/main/resources/templates/car/carManage/park.html @@ -0,0 +1,71 @@ + + + + + + + + +
    +
    +
      +
      +
      +
      + + + \ No newline at end of file diff --git a/src/main/resources/templates/car/carManage/renew.html b/src/main/resources/templates/car/carManage/renew.html new file mode 100644 index 0000000..4bbab4e --- /dev/null +++ b/src/main/resources/templates/car/carManage/renew.html @@ -0,0 +1,132 @@ + + + + +
      + +
      +
      + + + \ No newline at end of file diff --git a/src/main/resources/templates/car/parkManage/form.html b/src/main/resources/templates/car/parkManage/form.html new file mode 100644 index 0000000..72112a6 --- /dev/null +++ b/src/main/resources/templates/car/parkManage/form.html @@ -0,0 +1,140 @@ + + + + +
      + +
      +
      + + + \ No newline at end of file diff --git a/src/main/resources/templates/car/parkManage/list.html b/src/main/resources/templates/car/parkManage/list.html new file mode 100644 index 0000000..cfafda8 --- /dev/null +++ b/src/main/resources/templates/car/parkManage/list.html @@ -0,0 +1,177 @@ + + + + +
      + + + +
      +
      + + + diff --git a/src/main/resources/templates/car/parkManage/org.html b/src/main/resources/templates/car/parkManage/org.html new file mode 100644 index 0000000..e1407f8 --- /dev/null +++ b/src/main/resources/templates/car/parkManage/org.html @@ -0,0 +1,71 @@ + + + + + + + + +
      +
      +
        +
        +
        +
        + + + \ No newline at end of file diff --git a/src/main/resources/templates/car/parkManage/payConfig.html b/src/main/resources/templates/car/parkManage/payConfig.html new file mode 100644 index 0000000..f5e1f3f --- /dev/null +++ b/src/main/resources/templates/car/parkManage/payConfig.html @@ -0,0 +1,82 @@ + + + + +
        + +
        +
        + + + \ No newline at end of file diff --git a/src/main/resources/templates/car/parkingRecord/list.html b/src/main/resources/templates/car/parkingRecord/list.html new file mode 100644 index 0000000..cdf4411 --- /dev/null +++ b/src/main/resources/templates/car/parkingRecord/list.html @@ -0,0 +1,196 @@ + + + + +
        + + + +
        +
        + + +