初始化
commit
889a3d26ac
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,73 @@
|
|||
<?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.fate</groupId>
|
||||
<artifactId>fate-fence</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>fance-menghang-common</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-redis</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-actuator-autoconfigure</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.0</version>
|
||||
</dependency>
|
||||
<!-- fate Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-datasource</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- fate Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-datascope</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- fate Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-log</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- fate Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-swagger</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,63 @@
|
|||
package com.shiyi.internet.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fate.common.core.annotation.Excel;
|
||||
import com.fate.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description : 车辆电池信息基类
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-20 09:04
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_battery")
|
||||
public class Battery extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("电池ID")
|
||||
@TableId(value = "battery_id", type = IdType.AUTO)
|
||||
private Integer batteryId;
|
||||
|
||||
@ApiModelProperty("电池编号")
|
||||
@TableField("battery_coding")
|
||||
private Integer batteryCoding;
|
||||
|
||||
@ApiModelProperty("电池类型")
|
||||
@TableField("battery_type")
|
||||
private String batteryType;
|
||||
|
||||
@ApiModelProperty("电池容量")
|
||||
@TableField("battery_capacity")
|
||||
private Integer batteryCapacity;
|
||||
|
||||
@ApiModelProperty("电池电压")
|
||||
@TableField("battery_actual_voltage")
|
||||
private BigDecimal batteryActualVoltage;
|
||||
|
||||
@ApiModelProperty("电池质量")
|
||||
@TableField("battery_actual_mass")
|
||||
private Integer batteryActualMass;
|
||||
|
||||
@ApiModelProperty("出厂时间")
|
||||
@TableField("battery_delivery_time")
|
||||
private Date batteryDeliveryTime;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.shiyi.internet.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fate.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Description : 车辆基类
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-19 20:56
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_car")
|
||||
public class Car extends BaseEntity {
|
||||
|
||||
@ApiModelProperty("车辆ID")
|
||||
@TableId(value = "car_id", type = IdType.AUTO)
|
||||
private Integer carId;
|
||||
|
||||
@ApiModelProperty("车辆名称")
|
||||
@TableField("car_name")
|
||||
private String carName;
|
||||
|
||||
@ApiModelProperty("车辆牌号")
|
||||
@TableField("car_license")
|
||||
private String carLicense;
|
||||
|
||||
@ApiModelProperty("车辆状态")
|
||||
@TableField("driving_id")
|
||||
private Integer drivingId;
|
||||
|
||||
@ApiModelProperty("车辆类型")
|
||||
@TableField("type_id")
|
||||
private Integer typeId;
|
||||
|
||||
@ApiModelProperty("车辆围栏")
|
||||
@TableField("fence_id")
|
||||
private Integer fenceId;
|
||||
|
||||
@ApiModelProperty("车辆零件ID")
|
||||
@TableField("drive_id")
|
||||
private Integer driveId;
|
||||
|
||||
@ApiModelProperty("车辆电池")
|
||||
@TableField("battery_id")
|
||||
private Integer batteryId;
|
||||
|
||||
@ApiModelProperty("车辆位置")
|
||||
@TableField("car_address")
|
||||
private String carAddress;
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.shiyi.internet.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fate.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @Description : 车辆零件驱动
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-20 09:02
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_drive")
|
||||
public class Drive extends BaseEntity {
|
||||
|
||||
|
||||
@ApiModelProperty("驱动零件ID")
|
||||
@TableField("drive_id")
|
||||
private String driveId;
|
||||
|
||||
@ApiModelProperty("配件型号")
|
||||
@TableField("drive_name")
|
||||
private String driveName;
|
||||
|
||||
@ApiModelProperty("配件编号")
|
||||
@TableField("drive_part_number")
|
||||
private String drivePartNumber;
|
||||
|
||||
@ApiModelProperty("生产厂商名称")
|
||||
@TableField("drive_generate_name")
|
||||
private String driveGenerateName;
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.shiyi.internet.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fate.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description : 车辆行驶记录
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-20 09:57
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_driving")
|
||||
public class DrivingRecord extends BaseEntity {
|
||||
|
||||
@ApiModelProperty("状态ID")
|
||||
@TableId(value = "driving_id", type = IdType.AUTO)
|
||||
private Integer drivingId ;
|
||||
|
||||
@ApiModelProperty("车辆vin")
|
||||
@TableField("driving_vin")
|
||||
private String drivingVin ;
|
||||
|
||||
@ApiModelProperty("上线时间")
|
||||
@TableId(value = "driving_starttime")
|
||||
private Date drivingStarttime ;
|
||||
|
||||
@ApiModelProperty("下线时间")
|
||||
@TableId(value = "driving_endtime")
|
||||
private Date drivingEndtime ;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.shiyi.internet.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fate.common.core.web.domain.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description : 电子围栏基类
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-18 13:01
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("t_fencing")
|
||||
public class Fencing extends BaseEntity {
|
||||
|
||||
@ApiModelProperty(name = "电子围栏ID",notes = "")
|
||||
private Integer fencingId ;
|
||||
/** 围栏名称 */
|
||||
@ApiModelProperty(name = "围栏名称",notes = "")
|
||||
private String fencingName ;
|
||||
/** 围栏经纬度 */
|
||||
@ApiModelProperty(name = "围栏经纬度",notes = "")
|
||||
private String fencingLat ;
|
||||
/** 激活状态 */
|
||||
@ApiModelProperty(name = "激活状态",notes = "")
|
||||
private Integer fencingStatus ;
|
||||
/** 操作时间 */
|
||||
@ApiModelProperty(name = "操作时间",notes = "")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date fencingTime ;
|
||||
/** 操作者 */
|
||||
@ApiModelProperty(name = "操作者",notes = "")
|
||||
private Integer createUserId ;
|
||||
}
|
|
@ -0,0 +1,109 @@
|
|||
package com.shiyi.internet.domain.response;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName : ResponseCar
|
||||
* @Description : 车辆系统响应
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-19 21:02
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ResponseCar {
|
||||
/** 车辆ID */
|
||||
@ApiModelProperty(name = "车辆ID",notes = "")
|
||||
private Integer carId ;
|
||||
/** 车辆名称 */
|
||||
@ApiModelProperty(name = "车辆名称",notes = "")
|
||||
private String carName ;
|
||||
/** 车辆牌号 */
|
||||
@ApiModelProperty(name = "车辆牌号",notes = "")
|
||||
private String carLicense ;
|
||||
/** 状态ID */
|
||||
@ApiModelProperty(name = "状态ID",notes = "")
|
||||
private Integer drivingId ;
|
||||
/** 车辆vin */
|
||||
@ApiModelProperty(name = "车辆vin",notes = "")
|
||||
private String drivingVin ;
|
||||
/** 上线时间 */
|
||||
@ApiModelProperty(name = "上线时间",notes = "")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date drivingStarttime ;
|
||||
/** 下线时间 */
|
||||
@ApiModelProperty(name = "下线时间",notes = "")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||
private Date drivingEndtime ;
|
||||
/** 车辆类型 */
|
||||
@ApiModelProperty(name = "车辆类型",notes = "")
|
||||
private Integer typeId ;
|
||||
/** 车辆围栏 */
|
||||
@ApiModelProperty(name = "车辆围栏",notes = "")
|
||||
private Integer fenceId ;
|
||||
/** 围栏名称 */
|
||||
@ApiModelProperty(name = "围栏名称",notes = "")
|
||||
private String fencingName ;
|
||||
/** 围栏经纬度 */
|
||||
@ApiModelProperty(name = "围栏经纬度",notes = "")
|
||||
private String fencingLat ;
|
||||
/** 激活状态 */
|
||||
@ApiModelProperty(name = "激活状态",notes = "")
|
||||
private Integer fencingStatus ;
|
||||
/** 车辆零件ID */
|
||||
@ApiModelProperty(name = "车辆零件ID",notes = "")
|
||||
private Integer driveId ;
|
||||
/** 配件型号 */
|
||||
@ApiModelProperty(name = "配件型号",notes = "")
|
||||
private String driveName ;
|
||||
/** 配件编号 */
|
||||
@ApiModelProperty(name = "配件编号",notes = "")
|
||||
private String drivePartNumber ;
|
||||
/** 生产厂商名称 */
|
||||
@ApiModelProperty(name = "生产厂商名称",notes = "")
|
||||
private String driveGenerateName ;
|
||||
@ApiModelProperty("电池ID")
|
||||
@TableId(value = "battery_id", type = IdType.AUTO)
|
||||
private Integer batteryId;
|
||||
|
||||
@ApiModelProperty("电池编号")
|
||||
@TableField("battery_coding")
|
||||
private Integer batteryCoding;
|
||||
|
||||
@ApiModelProperty("电池类型")
|
||||
@TableField("battery_type")
|
||||
private String batteryType;
|
||||
|
||||
@ApiModelProperty("电池容量")
|
||||
@TableField("battery_capacity")
|
||||
private Integer batteryCapacity;
|
||||
|
||||
@ApiModelProperty("电池电压")
|
||||
@TableField("battery_actual_voltage")
|
||||
private BigDecimal batteryActualVoltage;
|
||||
|
||||
@ApiModelProperty("电池质量")
|
||||
@TableField("battery_actual_mass")
|
||||
private Integer batteryActualMass;
|
||||
|
||||
@ApiModelProperty("出厂时间")
|
||||
@TableField("battery_delivery_time")
|
||||
private Date batteryDeliveryTime;
|
||||
|
||||
/** 车辆位置 */
|
||||
@ApiModelProperty(name = "车辆位置",notes = "")
|
||||
private String carAddress ;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.shiyi.internet.domain.response;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @ClassName : RequestFencing
|
||||
* @Description : 电子围栏响应实体类
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-18 13:17
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ResponseFencing {
|
||||
/** 电子围栏ID */
|
||||
@ApiModelProperty(name = "电子围栏ID",notes = "")
|
||||
private Integer fencingId ;
|
||||
/** 围栏名称 */
|
||||
@ApiModelProperty(name = "围栏名称",notes = "")
|
||||
private String fencingName ;
|
||||
/** 围栏经纬度 */
|
||||
@ApiModelProperty(name = "围栏经纬度",notes = "")
|
||||
private String fencingLat ;
|
||||
/** 激活状态 */
|
||||
@ApiModelProperty(name = "激活状态",notes = "")
|
||||
private Integer fencingStatus ;
|
||||
/** 操作时间 */
|
||||
@ApiModelProperty(name = "操作时间",notes = "")
|
||||
private String fencingTime ;
|
||||
/** 操作者 */
|
||||
@ApiModelProperty(name = "操作者",notes = "")
|
||||
private Integer createUserId ;
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
package com.shiyi.internet.domain.utils.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* 自定义导出Excel数据注解
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface Excel
|
||||
{
|
||||
/**
|
||||
* 导出到Excel中的名字.
|
||||
*/
|
||||
public String name() default "";
|
||||
|
||||
/**
|
||||
* 日期格式, 如: yyyy-MM-dd
|
||||
*/
|
||||
public String dateFormat() default "";
|
||||
|
||||
/**
|
||||
* 读取内容转表达式 (如: 0=男,1=女,2=未知)
|
||||
*/
|
||||
public String readConverterExp() default "";
|
||||
|
||||
/**
|
||||
* 分隔符
|
||||
*/
|
||||
public String splitStr() default "";
|
||||
|
||||
/**
|
||||
* 可执行的反射方法值为1个
|
||||
*/
|
||||
public String invokeMethod() default "";
|
||||
|
||||
/**
|
||||
* 可执行的反射类 从SpringIoc容器当中取值
|
||||
*/
|
||||
public Class<?> invokeClass() default String.class;
|
||||
|
||||
/**
|
||||
* 导出类型(0数字 1字符串)
|
||||
*/
|
||||
public ColumnType cellType() default ColumnType.STRING;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的高度 单位为字符
|
||||
*/
|
||||
public double height() default 14;
|
||||
|
||||
/**
|
||||
* 导出时在excel中每个列的宽 单位为字符
|
||||
*/
|
||||
public double width() default 16;
|
||||
|
||||
/**
|
||||
* 文字后缀,如% 90 变成90%
|
||||
*/
|
||||
public String suffix() default "";
|
||||
|
||||
/**
|
||||
* 当值为空时,字段的默认值
|
||||
*/
|
||||
public String defaultValue() default "";
|
||||
|
||||
/**
|
||||
* 提示信息
|
||||
*/
|
||||
public String prompt() default "";
|
||||
|
||||
/**
|
||||
* 设置只能选择不能输入的列内容.
|
||||
*/
|
||||
public String[] combo() default {};
|
||||
|
||||
/**
|
||||
* 是否导出数据,应对需求:有时我们需要导出一份模板,这是标题需要但内容需要用户手工填写.
|
||||
*/
|
||||
public boolean isExport() default true;
|
||||
|
||||
/**
|
||||
* 另一个类中的属性名称,支持多级获取,以小数点隔开
|
||||
*/
|
||||
public String targetAttr() default "";
|
||||
|
||||
/**
|
||||
* 字段类型(0:导出导入;1:仅导出;2:仅导入)
|
||||
*/
|
||||
Type type() default Type.ALL;
|
||||
|
||||
public enum Type {
|
||||
ALL(0), EXPORT(1), IMPORT(2);
|
||||
private final int value;
|
||||
|
||||
Type(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ColumnType {
|
||||
NUMERIC(0), STRING(1);
|
||||
private final int value;
|
||||
|
||||
ColumnType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int value() {
|
||||
return this.value;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.shiyi.internet.domain.utils.annotation;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Excel注解集
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
@Target(ElementType.FIELD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Excels
|
||||
{
|
||||
Excel[] value();
|
||||
}
|
|
@ -0,0 +1,137 @@
|
|||
package com.shiyi.internet.domain.utils.date;
|
||||
|
||||
import org.apache.commons.lang3.time.DateFormatUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 时间工具类
|
||||
*
|
||||
* @author markGuo
|
||||
*/
|
||||
public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
||||
{
|
||||
public static String YYYY = "yyyy";
|
||||
|
||||
public static String YYYY_MM = "yyyy-MM";
|
||||
|
||||
public static String YYYY_MM_DD = "yyyy-MM-dd";
|
||||
|
||||
public static String YYYYMMDDHHMMSS = "yyyyMMddHHmmss";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
"yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
|
||||
|
||||
/**
|
||||
* 获取当前Date型日期
|
||||
*
|
||||
* @return Date() 当前日期
|
||||
*/
|
||||
public static Date getNowDate() {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前日期, 默认格式为yyyy-MM-dd
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public static String getDate() {
|
||||
return dateTimeNow(YYYY_MM_DD);
|
||||
}
|
||||
|
||||
public static final String getTime() {
|
||||
return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow() {
|
||||
return dateTimeNow(YYYYMMDDHHMMSS);
|
||||
}
|
||||
|
||||
public static final String dateTimeNow(final String format) {
|
||||
return parseDateToStr(format, new Date());
|
||||
}
|
||||
|
||||
public static final String dateTime(final Date date) {
|
||||
return parseDateToStr(YYYY_MM_DD, date);
|
||||
}
|
||||
|
||||
public static final String parseDateToStr(final String format, final Date date) {
|
||||
return new SimpleDateFormat(format).format(date);
|
||||
}
|
||||
|
||||
public static final Date dateTime(final String format, final String ts) {
|
||||
try {
|
||||
return new SimpleDateFormat(format).parse(ts);
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如2018/08/08
|
||||
*/
|
||||
public static final String datePath() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyy"+File.separator+"MM"+ File.separator +"dd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期路径 即年/月/日 如20180808
|
||||
*/
|
||||
public static final String dateTime() {
|
||||
Date now = new Date();
|
||||
return DateFormatUtils.format(now, "yyyyMMdd");
|
||||
}
|
||||
|
||||
/**
|
||||
* 日期型字符串转化为日期 格式
|
||||
*/
|
||||
public static Date parseDate(Object str) {
|
||||
if (str == null) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return parseDate(str.toString(), parsePatterns);
|
||||
} catch (ParseException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务器启动时间
|
||||
*/
|
||||
public static Date getServerStartDate() {
|
||||
long time = ManagementFactory.getRuntimeMXBean().getStartTime();
|
||||
return new Date(time);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个时间差
|
||||
*/
|
||||
public static String getDatePoor(Date endDate, Date nowDate) {
|
||||
long nd = 1000 * 24 * 60 * 60;
|
||||
long nh = 1000 * 60 * 60;
|
||||
long nm = 1000 * 60;
|
||||
// long ns = 1000;
|
||||
// 获得两个时间的毫秒时间差异
|
||||
long diff = endDate.getTime() - nowDate.getTime();
|
||||
// 计算差多少天
|
||||
long day = diff / nd;
|
||||
// 计算差多少小时
|
||||
long hour = diff % nd / nh;
|
||||
// 计算差多少分钟
|
||||
long min = diff % nd % nh / nm;
|
||||
// 计算差多少秒//输出结果
|
||||
// long sec = diff % nd % nh % nm / ns;
|
||||
return day + "天" + hour + "小时" + min + "分钟";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.shiyi.internet.domain.utils.exception;
|
||||
|
||||
/**
|
||||
* 业务异常
|
||||
*
|
||||
* @author
|
||||
*/
|
||||
public class PoiException extends RuntimeException
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected final String message;
|
||||
|
||||
public PoiException(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public PoiException(String message, Throwable e) {
|
||||
super(message, e);
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,387 @@
|
|||
package com.shiyi.internet.domain.utils.reflex;
|
||||
|
||||
|
||||
import com.shiyi.internet.domain.utils.date.DateUtils;
|
||||
import com.shiyi.internet.domain.utils.text.Convert;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 反射工具类. 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数.
|
||||
*
|
||||
* @author markGuo
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
public class ReflectUtils {
|
||||
/**
|
||||
* set方法前缀
|
||||
*/
|
||||
private static final String SETTER_PREFIX = "set";
|
||||
|
||||
/**
|
||||
* get方法前缀
|
||||
*/
|
||||
private static final String GETTER_PREFIX = "get";
|
||||
|
||||
/**
|
||||
* CGLIB 类分隔符
|
||||
*/
|
||||
private static final String CGLIB_CLASS_SEPARATOR = "$$";
|
||||
|
||||
/**
|
||||
* 日志
|
||||
*/
|
||||
private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class);
|
||||
|
||||
/**
|
||||
* 调用Getter方法.
|
||||
* 支持多级,如:对象名.对象名.方法
|
||||
* @param obj
|
||||
* @param propertyName
|
||||
* @param <E>
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E invokeGetter(Object obj, String propertyName) {
|
||||
Object object = obj;
|
||||
for (String name : StringUtils.split(propertyName, ".")) {
|
||||
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
|
||||
object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
|
||||
}
|
||||
return (E) object;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用Setter方法, 仅匹配方法名。
|
||||
* 支持多级,如:对象名.对象名.方法
|
||||
* @param obj
|
||||
* @param propertyName
|
||||
* @param value
|
||||
* @param <E>
|
||||
*/
|
||||
public static <E> void invokeSetter(Object obj, String propertyName, E value) {
|
||||
Object object = obj;
|
||||
String[] names = StringUtils.split(propertyName, ".");
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
if (i < names.length - 1) {
|
||||
String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
|
||||
object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
|
||||
} else {
|
||||
String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
|
||||
invokeMethodByName(object, setterMethodName, new Object[] { value });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数.
|
||||
* @param obj
|
||||
* @param fieldName
|
||||
* @param <E>
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E getFieldValue(final Object obj, final String fieldName) {
|
||||
Field field = getAccessibleField(obj, fieldName);
|
||||
if (field == null) {
|
||||
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
|
||||
return null;
|
||||
}
|
||||
E result = null;
|
||||
try {
|
||||
result = (E) field.get(obj);
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("不可能抛出的异常{}", e.getMessage());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数.
|
||||
* @param obj
|
||||
* @param fieldName
|
||||
* @param value
|
||||
* @param <E>
|
||||
*/
|
||||
public static <E> void setFieldValue(final Object obj, final String fieldName, final E value) {
|
||||
Field field = getAccessibleField(obj, fieldName);
|
||||
if (field == null) {
|
||||
// throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
|
||||
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
field.set(obj, value);
|
||||
} catch (IllegalAccessException e) {
|
||||
logger.error("不可能抛出的异常: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接调用对象方法, 无视private/protected修饰符.
|
||||
* 用于一次性调用的情况,否则应使用getAccessibleMethod()函数获得Method后反复调用.
|
||||
* 同时匹配方法名+参数类型,
|
||||
* @param obj
|
||||
* @param methodName
|
||||
* @param parameterTypes
|
||||
* @param args
|
||||
* @param <E>
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
|
||||
final Object[] args) {
|
||||
if (obj == null || methodName == null) {
|
||||
return null;
|
||||
}
|
||||
Method method = getAccessibleMethod(obj, methodName, parameterTypes);
|
||||
if (method == null) {
|
||||
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return (E) method.invoke(obj, args);
|
||||
} catch (Exception e) {
|
||||
String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
|
||||
throw convertReflectionExceptionToUnchecked(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接调用对象方法, 无视private/protected修饰符,
|
||||
* 用于一次性调用的情况,否则应使用getAccessibleMethodByName()函数获得Method后反复调用.
|
||||
* 只匹配函数名,如果有多个同名函数调用第一个。
|
||||
* @param obj
|
||||
* @param methodName
|
||||
* @param args
|
||||
* @param <E>
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <E> E invokeMethodByName(final Object obj, final String methodName, final Object[] args) {
|
||||
Method method = getAccessibleMethodByName(obj, methodName, args.length);
|
||||
if (method == null) {
|
||||
// 如果为空不报错,直接返回空。
|
||||
logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
// 类型转换(将参数数据类型转换为目标方法参数类型)
|
||||
Class<?>[] cs = method.getParameterTypes();
|
||||
for (int i = 0; i < cs.length; i++) {
|
||||
if (args[i] != null && !args[i].getClass().equals(cs[i])) {
|
||||
if (cs[i] == String.class) {
|
||||
args[i] = Convert.toStr(args[i]);
|
||||
if (StringUtils.endsWith((String) args[i], ".0")) {
|
||||
args[i] = StringUtils.substringBefore((String) args[i], ".0");
|
||||
}
|
||||
} else if (cs[i] == Integer.class) {
|
||||
args[i] = Convert.toInt(args[i]);
|
||||
} else if (cs[i] == Long.class) {
|
||||
args[i] = Convert.toLong(args[i]);
|
||||
} else if (cs[i] == Double.class) {
|
||||
args[i] = Convert.toDouble(args[i]);
|
||||
} else if (cs[i] == Float.class) {
|
||||
args[i] = Convert.toFloat(args[i]);
|
||||
} else if (cs[i] == Date.class) {
|
||||
if (args[i] instanceof String) {
|
||||
args[i] = DateUtils.parseDate(args[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return (E) method.invoke(obj, args);
|
||||
} catch (Exception e) {
|
||||
String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
|
||||
throw convertReflectionExceptionToUnchecked(msg, e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问.
|
||||
* 如向上转型到Object仍无法找到, 返回null.
|
||||
* @param obj
|
||||
* @param fieldName
|
||||
* @return
|
||||
*/
|
||||
public static Field getAccessibleField(final Object obj, final String fieldName) {
|
||||
// 为空不报错。直接返回 null
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
Validate.notBlank(fieldName, "fieldName can't be blank");
|
||||
for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
|
||||
try {
|
||||
Field field = superClass.getDeclaredField(fieldName);
|
||||
makeAccessible(field);
|
||||
return field;
|
||||
}
|
||||
catch (NoSuchFieldException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问.
|
||||
* 如向上转型到Object仍无法找到, 返回null.
|
||||
* 匹配函数名+参数类型。
|
||||
* 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
|
||||
* @param obj
|
||||
* @param methodName
|
||||
* @param parameterTypes
|
||||
* @return
|
||||
*/
|
||||
public static Method getAccessibleMethod(final Object obj, final String methodName,
|
||||
final Class<?>... parameterTypes) {
|
||||
// 为空不报错。直接返回 null
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
Validate.notBlank(methodName, "methodName can't be blank");
|
||||
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
|
||||
try {
|
||||
Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
|
||||
makeAccessible(method);
|
||||
return method;
|
||||
} catch (NoSuchMethodException e) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问.
|
||||
* 如向上转型到Object仍无法找到, 返回null.
|
||||
* 只匹配函数名。
|
||||
* 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
|
||||
* @param obj
|
||||
* @param methodName
|
||||
* @param argsNum
|
||||
* @return
|
||||
*/
|
||||
public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) {
|
||||
// 为空不报错。直接返回 null
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
Validate.notBlank(methodName, "methodName can't be blank");
|
||||
for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
|
||||
Method[] methods = searchType.getDeclaredMethods();
|
||||
for (Method method : methods) {
|
||||
if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) {
|
||||
makeAccessible(method);
|
||||
return method;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
|
||||
* @param method
|
||||
*/
|
||||
public static void makeAccessible(Method method) {
|
||||
if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
|
||||
&& !method.isAccessible()) {
|
||||
method.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
|
||||
* @param field
|
||||
*/
|
||||
public static void makeAccessible(Field field) {
|
||||
if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())
|
||||
|| Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过反射, 获得Class定义中声明的泛型参数的类型, 注意泛型必须定义在父类处
|
||||
* 如无法找到, 返回Object.class.
|
||||
* @param clazz
|
||||
* @param <T>
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> Class<T> getClassGenricType(final Class clazz) {
|
||||
return getClassGenricType(clazz, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过反射, 获得Class定义中声明的父类的泛型参数的类型.
|
||||
* 如无法找到, 返回Object.class.
|
||||
* @param clazz
|
||||
* @param index
|
||||
* @return
|
||||
*/
|
||||
public static Class getClassGenricType(final Class clazz, final int index) {
|
||||
Type genType = clazz.getGenericSuperclass();
|
||||
|
||||
if (!(genType instanceof ParameterizedType)) {
|
||||
logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType");
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
|
||||
|
||||
if (index >= params.length || index < 0) {
|
||||
logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
|
||||
+ params.length);
|
||||
return Object.class;
|
||||
}
|
||||
if (!(params[index] instanceof Class)) {
|
||||
logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
return (Class) params[index];
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过实例化对象获取反射对象
|
||||
* @param instance
|
||||
* @return
|
||||
*/
|
||||
public static Class<?> getUserClass(Object instance) {
|
||||
if (instance == null) {
|
||||
throw new RuntimeException("Instance must not be null");
|
||||
}
|
||||
Class clazz = instance.getClass();
|
||||
if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
|
||||
Class<?> superClass = clazz.getSuperclass();
|
||||
if (superClass != null && !Object.class.equals(superClass)) {
|
||||
return superClass;
|
||||
}
|
||||
}
|
||||
return clazz;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 将反射时的checked exception转换为unchecked exception.
|
||||
* @param msg
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) {
|
||||
if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException
|
||||
|| e instanceof NoSuchMethodException) {
|
||||
return new IllegalArgumentException(msg, e);
|
||||
} else if (e instanceof InvocationTargetException) {
|
||||
return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException());
|
||||
}
|
||||
return new RuntimeException(msg, e);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,106 @@
|
|||
package com.shiyi.internet.domain.utils.string;
|
||||
|
||||
import org.springframework.aop.framework.AopContext;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* spring工具类 方便在非spring管理环境中获取bean
|
||||
*
|
||||
* @author markGuo
|
||||
*/
|
||||
@Component
|
||||
public final class SpringUtils implements BeanFactoryPostProcessor
|
||||
{
|
||||
/** Spring应用上下文环境 */
|
||||
private static ConfigurableListableBeanFactory beanFactory;
|
||||
|
||||
@Override
|
||||
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
|
||||
SpringUtils.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象
|
||||
*
|
||||
* @param name
|
||||
* @return Object 一个以所给名字注册的bean的实例
|
||||
* @throws BeansException
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getBean(String name) throws BeansException {
|
||||
return (T) beanFactory.getBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取类型为requiredType的对象
|
||||
*
|
||||
* @param clz
|
||||
* @return
|
||||
* @throws BeansException
|
||||
*
|
||||
*/
|
||||
public static <T> T getBean(Class<T> clz) throws BeansException {
|
||||
T result = beanFactory.getBean(clz);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean containsBean(String name) {
|
||||
return beanFactory.containsBean(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException)
|
||||
*
|
||||
* @param name
|
||||
* @return boolean
|
||||
* @throws NoSuchBeanDefinitionException
|
||||
*
|
||||
*/
|
||||
public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
|
||||
return beanFactory.isSingleton(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param name
|
||||
* @return Class 注册对象的类型
|
||||
* @throws NoSuchBeanDefinitionException
|
||||
*
|
||||
*/
|
||||
public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
|
||||
return beanFactory.getType(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果给定的bean名字在bean定义中有别名,则返回这些别名
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
* @throws NoSuchBeanDefinitionException
|
||||
*
|
||||
*/
|
||||
public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
|
||||
return beanFactory.getAliases(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取aop代理对象
|
||||
*
|
||||
* @param invoker
|
||||
* @return
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T getAopProxy(T invoker) {
|
||||
return (T) AopContext.currentProxy();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,819 @@
|
|||
package com.shiyi.internet.domain.utils.text;
|
||||
|
||||
|
||||
import com.fate.common.core.text.CharsetKit;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 类型转换器
|
||||
*
|
||||
* @author markGuo
|
||||
*/
|
||||
public class Convert {
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value, String defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return (String) value;
|
||||
}
|
||||
return value.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符串<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String toStr(Object value) {
|
||||
return toStr(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为null,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar(Object value, Character defaultValue) {
|
||||
if (null == value) {
|
||||
return defaultValue;
|
||||
}
|
||||
if (value instanceof Character) {
|
||||
return (Character) value;
|
||||
}
|
||||
|
||||
final String valueStr = toStr(value, null);
|
||||
return StringUtils.isEmpty(valueStr) ? defaultValue : valueStr.charAt(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为字符<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Character toChar(Object value) {
|
||||
return toChar(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value, Byte defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (value instanceof Byte) {
|
||||
return (Byte) value;
|
||||
}else if (value instanceof Number) {
|
||||
return ((Number) value).byteValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Byte.parseByte(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为byte<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Byte toByte(Object value) {
|
||||
return toByte(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value, Short defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
}else if (value instanceof Short) {
|
||||
return (Short) value;
|
||||
} else if (value instanceof Number) {
|
||||
return ((Number) value).shortValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Short.parseShort(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Short<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Short toShort(Object value) {
|
||||
return toShort(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value, Number defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (value instanceof Number) {
|
||||
return (Number) value;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return NumberFormat.getInstance().parse(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Number<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Number toNumber(Object value) {
|
||||
return toNumber(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value, Integer defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (value instanceof Integer) {
|
||||
return (Integer) value;
|
||||
} else if (value instanceof Number) {
|
||||
return ((Number) value).intValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为int<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer toInt(Object value) {
|
||||
return toInt(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String str) {
|
||||
return toIntArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String str) {
|
||||
return toLongArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Integer数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Integer[] toIntArray(String split, String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return new Integer[] {};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Integer[] ints = new Integer[arr.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
final Integer v = toInt(arr[i], 0);
|
||||
ints[i] = v;
|
||||
}
|
||||
return ints;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Long数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long[] toLongArray(String split, String str) {
|
||||
if (StringUtils.isEmpty(str)) {
|
||||
return new Long[] {};
|
||||
}
|
||||
String[] arr = str.split(split);
|
||||
final Long[] longs = new Long[arr.length];
|
||||
for (int i = 0; i < arr.length; i++) {
|
||||
final Long v = toLong(arr[i], null);
|
||||
longs[i] = v;
|
||||
}
|
||||
return longs;
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param str 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String str) {
|
||||
return toStrArray(",", str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为String数组<br>
|
||||
*
|
||||
* @param split 分隔符
|
||||
* @param split 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static String[] toStrArray(String split, String str) {
|
||||
return str.split(split);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value, Long defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (value instanceof Long) {
|
||||
return (Long) value;
|
||||
} else if (value instanceof Number) {
|
||||
return ((Number) value).longValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).longValue();
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为long<br>
|
||||
* 如果给定的值为<code>null</code>,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Long toLong(Object value) {
|
||||
return toLong(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble(Object value, Double defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (value instanceof Double) {
|
||||
return (Double) value;
|
||||
} else if (value instanceof Number) {
|
||||
return ((Number) value).doubleValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
// 支持科学计数法
|
||||
return new BigDecimal(valueStr.trim()).doubleValue();
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为double<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Double toDouble(Object value) {
|
||||
return toDouble(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat(Object value, Float defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (value instanceof Float) {
|
||||
return (Float) value;
|
||||
} else if (value instanceof Number) {
|
||||
return ((Number) value).floatValue();
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Float.parseFloat(valueStr.trim());
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Float<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Float toFloat(Object value) {
|
||||
return toFloat(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* String支持的值为:true、false、yes、ok、no,1,0 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool(Object value, Boolean defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (value instanceof Boolean) {
|
||||
return (Boolean) value;
|
||||
}
|
||||
String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
valueStr = valueStr.trim().toLowerCase();
|
||||
switch (valueStr) {
|
||||
case "true":
|
||||
return true;
|
||||
case "false":
|
||||
return false;
|
||||
case "yes":
|
||||
return true;
|
||||
case "ok":
|
||||
return true;
|
||||
case "no":
|
||||
return false;
|
||||
case "1":
|
||||
return true;
|
||||
case "0":
|
||||
return false;
|
||||
default:
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为boolean<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static Boolean toBool(Object value) {
|
||||
return toBool(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @param defaultValue 默认值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value, E defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (clazz.isAssignableFrom(value.getClass())) {
|
||||
@SuppressWarnings("unchecked")
|
||||
E myE = (E) value;
|
||||
return myE;
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return Enum.valueOf(clazz, valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为Enum对象<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
*
|
||||
* @param clazz Enum的Class
|
||||
* @param value 值
|
||||
* @return Enum
|
||||
*/
|
||||
public static <E extends Enum<E>> E toEnum(Class<E> clazz, Object value) {
|
||||
return toEnum(clazz, value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (value instanceof BigInteger) {
|
||||
return (BigInteger) value;
|
||||
} else if (value instanceof Long) {
|
||||
return BigInteger.valueOf((Long) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return new BigInteger(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigInteger<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<code>null</code><br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigInteger toBigInteger(Object value) {
|
||||
return toBigInteger(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @param defaultValue 转换错误时的默认值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value, BigDecimal defaultValue) {
|
||||
if (value == null) {
|
||||
return defaultValue;
|
||||
} else if (value instanceof BigDecimal) {
|
||||
return (BigDecimal) value;
|
||||
} else if (value instanceof Long) {
|
||||
return new BigDecimal((Long) value);
|
||||
} else if (value instanceof Double) {
|
||||
return new BigDecimal((Double) value);
|
||||
} else if (value instanceof Integer) {
|
||||
return new BigDecimal((Integer) value);
|
||||
}
|
||||
final String valueStr = toStr(value, null);
|
||||
if (StringUtils.isEmpty(valueStr)) {
|
||||
return defaultValue;
|
||||
}
|
||||
try {
|
||||
return new BigDecimal(valueStr);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为BigDecimal<br>
|
||||
* 如果给定的值为空,或者转换失败,返回默认值<br>
|
||||
* 转换失败不会报错
|
||||
*
|
||||
* @param value 被转换的值
|
||||
* @return 结果
|
||||
*/
|
||||
public static BigDecimal toBigDecimal(Object value) {
|
||||
return toBigDecimal(value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String utf8Str(Object obj) {
|
||||
return str(obj, CharsetKit.CHARSET_UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charsetName 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(Object obj, String charsetName) {
|
||||
return str(obj, Charset.forName(charsetName));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将对象转为字符串<br>
|
||||
* 1、Byte数组和ByteBuffer会被转换为对应字符串的数组 2、对象数组会调用Arrays.toString方法
|
||||
*
|
||||
* @param obj 对象
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(Object obj, Charset charset) {
|
||||
if (null == obj) {
|
||||
return null;
|
||||
} else if (obj instanceof String) {
|
||||
return (String) obj;
|
||||
} else if (obj instanceof byte[] || obj instanceof Byte[]) {
|
||||
return str(obj, charset);
|
||||
} else if (obj instanceof ByteBuffer) {
|
||||
return str((ByteBuffer) obj, charset);
|
||||
}
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将byte数组转为字符串
|
||||
*
|
||||
* @param bytes byte数组
|
||||
* @param charset 字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(byte[] bytes, String charset) {
|
||||
return str(bytes, StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 解码字节码
|
||||
*
|
||||
* @param data 字符串
|
||||
* @param charset 字符集,如果此字段为空,则解码的结果取决于平台
|
||||
* @return 解码后的字符串
|
||||
*/
|
||||
public static String str(byte[] data, Charset charset) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
} else if (null == charset) {
|
||||
return new String(data);
|
||||
}
|
||||
return new String(data, charset);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(ByteBuffer data, String charset) {
|
||||
if (data == null) {
|
||||
return null;
|
||||
}
|
||||
return str(data, Charset.forName(charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将编码的byteBuffer数据转换为字符串
|
||||
*
|
||||
* @param data 数据
|
||||
* @param charset 字符集,如果为空使用当前系统字符集
|
||||
* @return 字符串
|
||||
*/
|
||||
public static String str(ByteBuffer data, Charset charset) {
|
||||
if (null == charset) {
|
||||
charset = Charset.defaultCharset();
|
||||
}
|
||||
return charset.decode(data).toString();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------- 全角半角转换
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
* @param input String.
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC(String input) {
|
||||
return toSBC(input, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 半角转全角
|
||||
*
|
||||
* @param input String
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 全角字符串.
|
||||
*/
|
||||
public static String toSBC(String input, Set<Character> notConvertSet) {
|
||||
char c[] = input.toCharArray();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
} else if (c[i] == ' ') {
|
||||
c[i] = '\u3000';
|
||||
} else if (c[i] < '\177') {
|
||||
c[i] = (char) (c[i] + 65248);
|
||||
|
||||
}
|
||||
}
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 全角转半角
|
||||
*
|
||||
* @param input String.
|
||||
* @return 半角字符串
|
||||
*/
|
||||
public static String toDBC(String input) {
|
||||
return toDBC(input, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换全角为半角
|
||||
*
|
||||
* @param text 文本
|
||||
* @param notConvertSet 不替换的字符集合
|
||||
* @return 替换后的字符
|
||||
*/
|
||||
public static String toDBC(String text, Set<Character> notConvertSet) {
|
||||
char c[] = text.toCharArray();
|
||||
for (int i = 0; i < c.length; i++) {
|
||||
if (null != notConvertSet && notConvertSet.contains(c[i])) {
|
||||
// 跳过不替换的字符
|
||||
continue;
|
||||
} else if (c[i] == '\u3000') {
|
||||
c[i] = ' ';
|
||||
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') {
|
||||
c[i] = (char) (c[i] - 65248);
|
||||
}
|
||||
}
|
||||
return new String(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* 数字金额大写转换 先写个完整的然后将如零拾替换成零
|
||||
*
|
||||
* @param n 数字
|
||||
* @return 中文大写数字
|
||||
*/
|
||||
public static String digitUppercase(double n) {
|
||||
String[] fraction = { "角", "分" };
|
||||
String[] digit = { "零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖" };
|
||||
String[][] unit = { { "元", "万", "亿" }, { "", "拾", "佰", "仟" } };
|
||||
|
||||
String head = n < 0 ? "负" : "";
|
||||
n = Math.abs(n);
|
||||
|
||||
String s = "";
|
||||
for (int i = 0; i < fraction.length; i++) {
|
||||
s += (digit[(int) (Math.floor(n * 10 * Math.pow(10, i)) % 10)] + fraction[i]).replaceAll("(零.)+", "");
|
||||
}
|
||||
if (s.length() < 1) {
|
||||
s = "整";
|
||||
}
|
||||
int integerPart = (int) Math.floor(n);
|
||||
|
||||
for (int i = 0; i < unit[0].length && integerPart > 0; i++) {
|
||||
String p = "";
|
||||
for (int j = 0; j < unit[1].length && n > 0; j++) {
|
||||
p = digit[integerPart % 10] + unit[1][j] + p;
|
||||
integerPart = integerPart / 10;
|
||||
}
|
||||
s = p.replaceAll("(零.)*零$", "").replaceAll("^$", "零") + unit[0][i] + s;
|
||||
}
|
||||
return head + s.replaceAll("(零.)*零元", "元").replaceFirst("(零.)+", "").replaceAll("(零.)+", "零").replaceAll("^整$", "零元整");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,31 @@
|
|||
<?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.fate</groupId>
|
||||
<artifactId>fate-fence</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>fance-menghang-remote</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<!-- 继承common依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>fance-menghang-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,38 @@
|
|||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
|
@ -0,0 +1,51 @@
|
|||
<?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.fate</groupId>
|
||||
<artifactId>fate-fence</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>fance-menghang-service</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- 继承common依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>fance-menghang-common</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<!-- poi实现excel导入导出-->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>3.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>3.15</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>3.15</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,49 @@
|
|||
package com.shiyi.internet;
|
||||
|
||||
import com.fate.common.security.annotation.EnableCustomConfig;
|
||||
import com.fate.common.security.annotation.EnableMyFeignClients;
|
||||
import com.fate.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
/**
|
||||
* @Description : 电子围栏启动类
|
||||
* @Author : YangHaoYu
|
||||
* @Date: 2023-11-20 18:50
|
||||
*/
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableMyFeignClients
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.shiyi.internet.mapper")
|
||||
public class FencingApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(FencingApplication.class,args);
|
||||
System.out.println("/**\n" +
|
||||
"\n" +
|
||||
" _oo0oo_\n" +
|
||||
" o8888888o\n" +
|
||||
" 88\" . \"88\n" +
|
||||
" (| -_- |)\n" +
|
||||
" 0\\ = /0\n" +
|
||||
" ___/`---'\\___\n" +
|
||||
" .' \\\\| |// '.\n" +
|
||||
" / \\\\||| : |||// \\\n" +
|
||||
" / _||||| -:- |||||- \\\n" +
|
||||
" | | \\\\\\ - /// | |\n" +
|
||||
" | \\_| ''\\---/'' |_/ |\n" +
|
||||
" \\ .-\\__ '-' ___/-. /\n" +
|
||||
" ___'. .' /--.--\\ `. .'___\n" +
|
||||
" .\"\" '< `.___\\_<|>_/___.' >' \"\".\n" +
|
||||
" | | : `- \\`.;`\\ _ /`;.`/ - ` : | |\n" +
|
||||
" \\ \\ `_. \\_ __\\ /__ _/ .-` / /\n" +
|
||||
" =====`-.____`.___ \\_____/___.-`___.-'=====\n" +
|
||||
" `=---='\n" +
|
||||
"\n" +
|
||||
" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
|
||||
"\n" +
|
||||
" 佛祖保佑 永无BUG\n" +
|
||||
"*/");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,144 @@
|
|||
package com.shiyi.internet.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fate.common.core.domain.Result;
|
||||
import com.fate.common.core.web.controller.BaseController;
|
||||
import com.shiyi.internet.domain.Fencing;
|
||||
import com.shiyi.internet.domain.response.ResponseFencing;
|
||||
import com.shiyi.internet.service.FencingService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName : 电子围栏控制层
|
||||
* @Description : FencingController
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-18 13:13
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/fencing")
|
||||
@Log4j2
|
||||
public class FencingController extends BaseController {
|
||||
@Autowired
|
||||
private FencingService fencingService;
|
||||
private HttpServletRequest request;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result<java.util.List<com.shiyi.internet.domain.response.ResponseFencing>>
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/18 13:31
|
||||
*/
|
||||
@GetMapping("/fencingList")
|
||||
public Result<List<ResponseFencing>> fencingList(){
|
||||
log.info("功能名称:电子围栏,请求URL:【{}】,请求方法:【{}】",request.getRequestURI(),
|
||||
request.getMethod());
|
||||
Result<List<ResponseFencing>> result = fencingService.fencingList();
|
||||
log.info("功能名称:电子围栏,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/18 13:54
|
||||
*/
|
||||
@PostMapping("/addfencing")
|
||||
public Result addfencing(@RequestBody Fencing fencing){
|
||||
log.info("功能名称:添加电子围栏,请求URL:【{}】,请求方法:【{}】,请求参数:【{}】",request.getRequestURI(),
|
||||
request.getMethod(),fencing);
|
||||
fencingService.addfencing(fencing);
|
||||
Result result = Result.success();
|
||||
log.info("功能名称:添加电子围栏,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/18 14:00
|
||||
*/
|
||||
@PostMapping("/deleteFencingById/{fencingId}")
|
||||
public Result deleteFencingById(@PathVariable Integer fencingId){
|
||||
log.info("功能名称:获取编号删除围栏,请求URL:【{}】,请求方法:【{}】,请求参数:【{}】",request.getRequestURI(),
|
||||
request.getMethod(),fencingId);
|
||||
Result result = fencingService.deleteFencingById(fencingId);
|
||||
log.info("功能名称:获取编号删除围栏,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/18 14:02
|
||||
*/
|
||||
@PostMapping("/updateFencing")
|
||||
public Result updateFencing(@RequestBody Fencing fencing){
|
||||
log.info("功能名称:修改围栏,请求URL:【{}】,请求方法:【{}】,请求参数:【{}】",request.getRequestURI(),
|
||||
request.getMethod(),fencing);
|
||||
Result result = fencingService.updateFencing(fencing);
|
||||
log.info("功能名称:修改围栏,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description:精确查询电子围栏信息
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/19 19:44
|
||||
*/
|
||||
@PostMapping("/findFencingById/{fencingId}")
|
||||
public Result findFencingById(@PathVariable Integer fencingId){
|
||||
log.info("功能名称:精确查询电子围栏信息,请求URL:【{}】,请求方法:【{}】,请求参数:【{}】",request.getRequestURI(),
|
||||
request.getMethod(),fencingId);
|
||||
ResponseFencing responseFencing = fencingService.findFencingById(fencingId);
|
||||
Result result = Result.success(responseFencing);
|
||||
log.info("功能名称:精确查询电子围栏信息,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @Description:批量删除围栏
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/19 19:50
|
||||
*/
|
||||
@PostMapping("/deleteFencingAllIds/{ids}")
|
||||
public Result deleteFencingAllIds(@PathVariable Integer[] ids){
|
||||
log.info("功能名称:批量删除围栏,请求URL:【{}】,请求方法:【{}】,请求参数:【{}】",request.getRequestURI(),
|
||||
request.getMethod(),ids);
|
||||
Result result = fencingService.deleteFencingAllIds(ids);
|
||||
log.info("功能名称:批量删除围栏,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
package com.shiyi.internet.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fate.common.core.domain.Result;
|
||||
import com.fate.common.core.utils.poi.ExcelUtil;
|
||||
import com.fate.common.core.web.controller.BaseController;
|
||||
import com.shiyi.internet.domain.Car;
|
||||
import com.shiyi.internet.domain.response.ResponseCar;
|
||||
import com.shiyi.internet.service.VehicleService;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName : 车辆管理系统控制层
|
||||
* @Description : CarController
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-19 21:00
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/car")
|
||||
public class VehicleController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private VehicleService vehicleService;
|
||||
private HttpServletRequest request;
|
||||
|
||||
|
||||
/**
|
||||
* @Description:车辆管理系统
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result<java.util.List<com.shiyi.internet.domain.response.ResponseCar>>
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/19 21:20
|
||||
*/
|
||||
@GetMapping("/vehicleList")
|
||||
public Result<List<ResponseCar>> vehicleList(){
|
||||
log.info("功能名称:车辆管理系统,请求URL:【{}】,请求方法:【{}】",request.getRequestURI(),
|
||||
request.getMethod());
|
||||
Result<List<ResponseCar>> result = vehicleService.vehicleList();
|
||||
log.info("功能名称:车辆管理系统,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description:获取编号删除车辆
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/19 21:38
|
||||
*/
|
||||
@PostMapping("/deletVehiclById/{carId}")
|
||||
public Result deletVehiclById(@PathVariable Integer carId){
|
||||
log.info("功能名称:获取编号删除车辆,请求URL:【{}】,请求方法:【{}】,请求参数:【{}】",request.getRequestURI(),
|
||||
request.getMethod(),carId);
|
||||
Result result = vehicleService.deletVehiclById(carId);
|
||||
log.info("功能名称:获取编号删除车辆,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description:添加车辆信息
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/19 22:34
|
||||
*/
|
||||
@PostMapping("/addVehicl")
|
||||
public Result addVehicl(@RequestBody Car car){
|
||||
log.info("功能名称:添加车辆信息,请求URL:【{}】,请求方法:【{}】,请求参数:【{}】",request.getRequestURI(),
|
||||
request.getMethod(),car);
|
||||
vehicleService.addVehicl(car);
|
||||
Result result = Result.success();
|
||||
log.info("功能名称:添加车辆信息,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 精确查询车辆系统信息
|
||||
* No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/20 10:20
|
||||
*/
|
||||
@GetMapping("/findVehiclById/{carId}")
|
||||
public Result findVehiclById(@PathVariable Integer carId){
|
||||
log.info("功能名称:精确查询车辆系统信息,请求URL:【{}】,请求方法:【{}】,请求参数:【{}】",request.getRequestURI(),
|
||||
request.getMethod(),carId);
|
||||
ResponseCar responseCar = vehicleService.findVehiclById(carId);
|
||||
Result result = Result.success(responseCar);
|
||||
log.info("功能名称:精确查询车辆系统信息,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description:修改车辆管理
|
||||
No such property: code for class: Script1
|
||||
* @return: com.fate.common.core.domain.Result
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/20 10:34
|
||||
*/
|
||||
@PostMapping("/updateVehicl")
|
||||
public Result updateVehicl(@RequestBody Car car){
|
||||
log.info("功能名称:修改车辆管理,请求URL:【{}】,请求方法:【{}】,请求参数:【{}】",request.getRequestURI(),
|
||||
request.getMethod(),car);
|
||||
Result result = vehicleService.updateVehicl(car);
|
||||
log.info("功能名称:修改车辆管理,请求URL:【{}】,请求方法:【{}】,响应结果:【{}】",request.getRequestURI(),
|
||||
request.getMethod(), JSONObject.toJSONString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 导出车辆数据
|
||||
No such property: code for class: Script1
|
||||
* @return: void
|
||||
* @Author: YHY
|
||||
* @Updator: YHY
|
||||
* @Date 2023/11/20 13:36
|
||||
*/
|
||||
@PostMapping("/exportVehiclList")
|
||||
public void exportVehiclList(HttpServletResponse response){
|
||||
Result<List<ResponseCar>> list = vehicleService.vehicleList();
|
||||
ExcelUtil<ResponseCar> carExcelUtil = new ExcelUtil<>(ResponseCar.class);
|
||||
carExcelUtil.exportExcel(response,list.getData(),"车辆信息");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.shiyi.internet.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fate.common.core.domain.Result;
|
||||
import com.shiyi.internet.domain.Fencing;
|
||||
import com.shiyi.internet.domain.response.ResponseFencing;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description :电子围栏数据层
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-18 13:15
|
||||
*/
|
||||
@Mapper
|
||||
public interface FencingMapper extends BaseMapper<Fencing> {
|
||||
List<ResponseFencing> fencingList();
|
||||
|
||||
void addfencing(Fencing fencing);
|
||||
|
||||
int deleteFencingById(@Param("fencingId") Integer fencingId);
|
||||
|
||||
int updateFencing(Fencing fencing);
|
||||
|
||||
ResponseFencing findFencingById(@Param("fencingId") Integer fencingId);
|
||||
|
||||
Result deleteFencingAllIds(@Param("ids") Integer[] ids);
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.shiyi.internet.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.shiyi.internet.domain.Car;
|
||||
import com.shiyi.internet.domain.response.ResponseCar;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 车辆管理数据层
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-19 21:25
|
||||
*/
|
||||
@Mapper
|
||||
public interface VehicleMapper extends BaseMapper<Car> {
|
||||
List<ResponseCar> vehicleList();
|
||||
|
||||
int deletVehiclById(@Param("carId") Integer carId);
|
||||
|
||||
void addVehicl(Car car);
|
||||
|
||||
ResponseCar findVehiclById(@Param("carId") Integer carId);
|
||||
|
||||
int updateVehicl(Car car);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.shiyi.internet.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fate.common.core.domain.Result;
|
||||
import com.shiyi.internet.domain.Fencing;
|
||||
import com.shiyi.internet.domain.response.ResponseFencing;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName : FencingService
|
||||
* @Description :
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-18 13:14
|
||||
*/
|
||||
public interface FencingService extends IService<Fencing> {
|
||||
Result<List<ResponseFencing>> fencingList();
|
||||
|
||||
void addfencing(Fencing fencing);
|
||||
|
||||
Result deleteFencingById(Integer fencingId);
|
||||
|
||||
Result updateFencing(Fencing fencing);
|
||||
|
||||
ResponseFencing findFencingById(Integer fencingId);
|
||||
|
||||
Result deleteFencingAllIds(Integer[] ids);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.shiyi.internet.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fate.common.core.domain.Result;
|
||||
import com.shiyi.internet.domain.Car;
|
||||
import com.shiyi.internet.domain.response.ResponseCar;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName : VehicleService
|
||||
* @Description :
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-19 21:24
|
||||
*/
|
||||
public interface VehicleService extends IService<Car> {
|
||||
Result<List<ResponseCar>> vehicleList();
|
||||
|
||||
Result deletVehiclById(Integer carId);
|
||||
|
||||
void addVehicl(Car car);
|
||||
|
||||
ResponseCar findVehiclById(Integer carId);
|
||||
|
||||
Result updateVehicl(Car car);
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.shiyi.internet.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fate.common.core.domain.Result;
|
||||
import com.shiyi.internet.domain.Fencing;
|
||||
import com.shiyi.internet.domain.response.ResponseFencing;
|
||||
import com.shiyi.internet.mapper.FencingMapper;
|
||||
import com.shiyi.internet.service.FencingService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 电子围栏业务层
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-18 13:14
|
||||
*/
|
||||
@Service
|
||||
public class FencingServiceimpl extends ServiceImpl<FencingMapper, Fencing> implements FencingService {
|
||||
|
||||
@Autowired
|
||||
private FencingMapper fencingMapper;
|
||||
|
||||
@Override
|
||||
public Result<List<ResponseFencing>> fencingList() {
|
||||
List<ResponseFencing> list = fencingMapper.fencingList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addfencing(Fencing fencing) {
|
||||
Date date = new Date();
|
||||
fencing.setFencingTime(date);
|
||||
fencingMapper.addfencing(fencing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteFencingById(Integer fencingId) {
|
||||
int i = fencingMapper.deleteFencingById(fencingId);
|
||||
return i>0?Result.success(200,"围栏已成功删除"):Result.error(500,"删除失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateFencing(Fencing fencing) {
|
||||
Date date = new Date();
|
||||
fencing.setFencingTime(date);
|
||||
int i = fencingMapper.updateFencing(fencing);
|
||||
return i>0?Result.success(200,"围栏已成功修改"):Result.error(500,"修改失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseFencing findFencingById(Integer fencingId) {
|
||||
|
||||
return fencingMapper.findFencingById(fencingId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteFencingAllIds(Integer[] ids) {
|
||||
return fencingMapper.deleteFencingAllIds(ids);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.shiyi.internet.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fate.common.core.domain.Result;
|
||||
import com.shiyi.internet.domain.Car;
|
||||
import com.shiyi.internet.domain.response.ResponseCar;
|
||||
import com.shiyi.internet.mapper.FencingMapper;
|
||||
import com.shiyi.internet.mapper.VehicleMapper;
|
||||
import com.shiyi.internet.service.VehicleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 车辆系统业务层
|
||||
* @Author : YHY
|
||||
* @Date: 2023-11-19 21:24
|
||||
*/
|
||||
@Service
|
||||
public class VehicleServiceimpl extends ServiceImpl<VehicleMapper,Car> implements VehicleService {
|
||||
|
||||
@Autowired
|
||||
private VehicleMapper vehicleMapper;
|
||||
|
||||
@Override
|
||||
public Result<List<ResponseCar>> vehicleList() {
|
||||
List<ResponseCar> list = vehicleMapper.vehicleList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deletVehiclById(Integer carId) {
|
||||
int i = vehicleMapper.deletVehiclById(carId);
|
||||
return i>0?Result.success(200,"车辆已成功删除"):Result.error(500,"删除失败");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addVehicl(Car car) {
|
||||
|
||||
vehicleMapper.addVehicl(car);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseCar findVehiclById(Integer carId) {
|
||||
return vehicleMapper.findVehiclById(carId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateVehicl(Car car) {
|
||||
int i = vehicleMapper.updateVehicl(car);
|
||||
return i>0?Result.success(200,"车辆信息已成功修改"):Result.error(500,"修改失败");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
Spring Boot Version: ${spring-boot.version}
|
||||
Spring Application Name: ${spring.application.name}
|
|
@ -0,0 +1,33 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 10002
|
||||
|
||||
# Spring
|
||||
spring:
|
||||
application:
|
||||
# 应用名称
|
||||
name: fate-fence
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 182.254.222.21:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 182.254.222.21:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
logging:
|
||||
level:
|
||||
com.fate.system.mapper: DEBUG
|
||||
|
||||
|
||||
#mybatis:
|
||||
# configuration:
|
||||
# map-underscore-to-camel-case: true
|
|
@ -0,0 +1,74 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration scan="true" scanPeriod="60 seconds" debug="false">
|
||||
<!-- 日志存放路径 -->
|
||||
<property name="log.path" value="./logs/fate/fence" />
|
||||
<!-- 日志输出格式 -->
|
||||
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
|
||||
|
||||
<!-- 控制台输出 -->
|
||||
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<!-- 系统日志输出 -->
|
||||
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/info.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/info.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>INFO</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${log.path}/error.log</file>
|
||||
<!-- 循环政策:基于时间创建日志文件 -->
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!-- 日志文件名格式 -->
|
||||
<fileNamePattern>${log.path}/error.%d{yyyy-MM-dd}.log</fileNamePattern>
|
||||
<!-- 日志最大的历史 60天 -->
|
||||
<maxHistory>60</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<pattern>${log.pattern}</pattern>
|
||||
</encoder>
|
||||
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||
<!-- 过滤的级别 -->
|
||||
<level>ERROR</level>
|
||||
<!-- 匹配时的操作:接收(记录) -->
|
||||
<onMatch>ACCEPT</onMatch>
|
||||
<!-- 不匹配时的操作:拒绝(不记录) -->
|
||||
<onMismatch>DENY</onMismatch>
|
||||
</filter>
|
||||
</appender>
|
||||
|
||||
<!-- 系统模块日志级别控制 -->
|
||||
<logger name="com.bawei" level="info" />
|
||||
<!-- Spring日志级别控制 -->
|
||||
<logger name="org.springframework" level="warn" />
|
||||
|
||||
<root level="info">
|
||||
<appender-ref ref="console" />
|
||||
</root>
|
||||
|
||||
<!--系统操作日志-->
|
||||
<root level="info">
|
||||
<appender-ref ref="file_info" />
|
||||
<appender-ref ref="file_error" />
|
||||
</root>
|
||||
</configuration>
|
|
@ -0,0 +1,43 @@
|
|||
<?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.shiyi.internet.mapper.FencingMapper">
|
||||
<insert id="addfencing">
|
||||
insert into(
|
||||
fencing_id,
|
||||
fencing_name,
|
||||
fencing_lat,
|
||||
fencing_status,
|
||||
fencing_time,
|
||||
create_user_id) values(
|
||||
#{fencingId},
|
||||
#{fencingName},
|
||||
#{fencingLat},
|
||||
#{fencingStatus},
|
||||
#{fencingTime},
|
||||
#{createUserId})
|
||||
</insert>
|
||||
<update id="updateFencing">
|
||||
update t_fencing set
|
||||
fencing_name=#{fencingName},
|
||||
fencing_lat=#{fencingLat},
|
||||
fencing_status=#{fencingStatus},
|
||||
fencing_time=#{fencingTime},
|
||||
create_user_id=#{createUserId} where fencing_id=#{fencingId}
|
||||
</update>
|
||||
<delete id="deleteFencingById">
|
||||
delete from t_fencing where fencing_id=#{fencingId}
|
||||
</delete>
|
||||
<delete id="deleteFencingAllIds">
|
||||
delete from t_fencing where fencing_id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{ids}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="findFencingById" resultType="com.shiyi.internet.domain.response.ResponseFencing">
|
||||
select * from t_fencing where fencing_id=#{fencingId}
|
||||
</select>
|
||||
<select id="fencingList" resultType="com.shiyi.internet.domain.response.ResponseFencing">
|
||||
select * from t_fencing
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,50 @@
|
|||
<?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.shiyi.internet.mapper.VehicleMapper">
|
||||
<insert id="addVehicl">
|
||||
insert into (
|
||||
car_id,
|
||||
car_name,
|
||||
car_license,
|
||||
driving_id,
|
||||
typ_eId,
|
||||
fen_ceId,
|
||||
dri_veId,
|
||||
bat_teryId,
|
||||
car_address) values(
|
||||
#{carId},
|
||||
#{carName},
|
||||
#{carLicense},
|
||||
#{drivingId},
|
||||
#{typeId},
|
||||
#{fenceId},
|
||||
#{driveId},
|
||||
#{batteryId},
|
||||
#{carAddress})
|
||||
</insert>
|
||||
<update id="updateVehicl">
|
||||
update t_car set
|
||||
car_name=#{carName},
|
||||
car_license=#{carLicense},
|
||||
driving_id=#{drivingId},
|
||||
type_id=#{typeId},
|
||||
fence_id=#{fenceId},
|
||||
drive_id=#{driveId},
|
||||
battery_id=#{batteryId},
|
||||
car_address=#{carAddress} where car_id=#{carId}
|
||||
</update>
|
||||
<delete id="deletVehiclById">
|
||||
delete from t_car where car_id=#{carId}
|
||||
</delete>
|
||||
|
||||
<select id="vehicleList" resultType="com.shiyi.internet.domain.response.ResponseCar">
|
||||
select * from t_car ca left join t_drive dr on ca.drive_id=dr.drive_id left join
|
||||
t_battery ba on ca.battery_id=ba.battery_id left join t_driving d on ca.driving_id=d.driving_id
|
||||
left join t_fence fe on ca.fence_id=fe.fence_id
|
||||
</select>
|
||||
<select id="findVehiclById" resultType="com.shiyi.internet.domain.response.ResponseCar">
|
||||
select * from t_car ca left join t_drive dr on ca.drive_id=dr.drive_id left join
|
||||
t_battery ba on ca.battery_id=ba.battery_id left join t_driving d on ca.driving_id=d.driving_id
|
||||
left join t_fence fe on ca.fence_id=fe.fence_id where car_id=#{carId}
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,106 @@
|
|||
<?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.fate</groupId>
|
||||
<artifactId>fate-modules</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>fate-fence</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<description>
|
||||
fate-modules-fence 电子围栏
|
||||
</description>
|
||||
<modules>
|
||||
<module>fance-menghang-remote</module>
|
||||
<module>fance-menghang-common</module>
|
||||
<module>fance-menghang-service</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Nacos Config -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringCloud Alibaba Sentinel -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot Actuator -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Swagger UI -->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>${swagger.fox.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mysql Connector -->
|
||||
<dependency>
|
||||
<groupId>com.mysql</groupId>
|
||||
<artifactId>mysql-connector-j</artifactId>
|
||||
<version>8.0.33</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Fate Common DataSource -->
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-datasource</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Fate Common DataScope -->
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-datascope</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Fate Common Log -->
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-log</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Fate Common Swagger -->
|
||||
<dependency>
|
||||
<groupId>com.fate</groupId>
|
||||
<artifactId>fate-common-swagger</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
</project>
|
Loading…
Reference in New Issue