业务逻辑
parent
b1be20acea
commit
fe8d904375
|
@ -0,0 +1,97 @@
|
||||||
|
package com.spider.common.domain;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @TableName t_car
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Car implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆ID
|
||||||
|
*/
|
||||||
|
// @NotNull(message="[车辆ID]不能为空")
|
||||||
|
@ApiModelProperty("车辆ID")
|
||||||
|
private Integer carId;
|
||||||
|
/**
|
||||||
|
* 员工主键
|
||||||
|
*/
|
||||||
|
// @NotNull(message="[员工主键]不能为空")
|
||||||
|
@ApiModelProperty("员工主键")
|
||||||
|
private Integer empId;
|
||||||
|
/**
|
||||||
|
* 车牌号
|
||||||
|
*/
|
||||||
|
@Size(max= 40,message="编码长度不能超过40")
|
||||||
|
@ApiModelProperty("车牌号")
|
||||||
|
@Length(max= 40,message="编码长度不能超过40")
|
||||||
|
@NotBlank(message = "车牌号不能为空")
|
||||||
|
private String carCard;
|
||||||
|
/**
|
||||||
|
* 车辆型号
|
||||||
|
*/
|
||||||
|
@Size(max= 40,message="编码长度不能超过40")
|
||||||
|
@ApiModelProperty("车辆型号")
|
||||||
|
@Length(max= 40,message="编码长度不能超过40")
|
||||||
|
@NotBlank(message = "车辆型号不能为空")
|
||||||
|
private String carModel;
|
||||||
|
/**
|
||||||
|
* 登记时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("登记时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:ss:mm",timezone = "GMT+8")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:ss:mm")
|
||||||
|
private Date regTime;
|
||||||
|
/**
|
||||||
|
* 车辆位置
|
||||||
|
*/
|
||||||
|
@Size(max= 100,message="编码长度不能超过100")
|
||||||
|
@ApiModelProperty("车辆位置")
|
||||||
|
@Length(max= 100,message="编码长度不能超过100")
|
||||||
|
private String carPosition;
|
||||||
|
/**
|
||||||
|
* 类型 0:临时车辆 1:长期车辆
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("类型 0:临时车辆 1:长期车辆")
|
||||||
|
private Integer carType;
|
||||||
|
/**
|
||||||
|
* 状态 0:有效 1:已失效
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("状态 0:有效 1:已失效")
|
||||||
|
private Integer carState;
|
||||||
|
/**
|
||||||
|
* 进入校园次数
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("进入校园次数")
|
||||||
|
private Integer carCount;
|
||||||
|
/**
|
||||||
|
* 最近一次进出校园时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("最近一次进出校园时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:ss:mm",timezone = "GMT+8")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:ss:mm")
|
||||||
|
private Date latelyTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.spider.common.domain;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @TableName t_emp
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Emp implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工主键
|
||||||
|
*/
|
||||||
|
@NotNull(message="[员工主键]不能为空")
|
||||||
|
@ApiModelProperty("员工主键")
|
||||||
|
private Integer empId;
|
||||||
|
/**
|
||||||
|
* 员工名称
|
||||||
|
*/
|
||||||
|
@Size(max= 50,message="编码长度不能超过50")
|
||||||
|
@ApiModelProperty("员工名称")
|
||||||
|
@Length(max= 50,message="编码长度不能超过50")
|
||||||
|
private String empName;
|
||||||
|
/**
|
||||||
|
* 员工密码
|
||||||
|
*/
|
||||||
|
@Size(max= 20,message="编码长度不能超过20")
|
||||||
|
@ApiModelProperty("员工密码")
|
||||||
|
@Length(max= 20,message="编码长度不能超过20")
|
||||||
|
private String empPwd;
|
||||||
|
/**
|
||||||
|
* 员工手机号
|
||||||
|
*/
|
||||||
|
@Size(max= 50,message="编码长度不能超过50")
|
||||||
|
@ApiModelProperty("员工手机号")
|
||||||
|
@Length(max= 50,message="编码长度不能超过50")
|
||||||
|
private String empMobile;
|
||||||
|
/**
|
||||||
|
* 入职时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("入职时间")
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,79 @@
|
||||||
|
package com.spider.common.domain;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @TableName t_record
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class Record implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录Id
|
||||||
|
*/
|
||||||
|
// @NotNull(message="[记录Id]不能为空")
|
||||||
|
@ApiModelProperty("记录Id")
|
||||||
|
private Integer recordId;
|
||||||
|
/**
|
||||||
|
* 车牌号
|
||||||
|
*/
|
||||||
|
@Size(max= 40,message="编码长度不能超过40")
|
||||||
|
@ApiModelProperty("车牌号")
|
||||||
|
@Length(max= 40,message="编码长度不能超过40")
|
||||||
|
private String carCard;
|
||||||
|
/**
|
||||||
|
* 车辆型号
|
||||||
|
*/
|
||||||
|
@Size(max= 40,message="编码长度不能超过40")
|
||||||
|
@ApiModelProperty("车辆型号")
|
||||||
|
@Length(max= 40,message="编码长度不能超过40")
|
||||||
|
private String carModel;
|
||||||
|
/**
|
||||||
|
* 进出时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("进出时间")
|
||||||
|
@JsonFormat(pattern = "yyyy/MM/dd HH:ss:mm",timezone = "GMT+8")
|
||||||
|
@DateTimeFormat(pattern = "yyyy/MM/dd HH:ss:mm")
|
||||||
|
private Date createTime;
|
||||||
|
/**
|
||||||
|
* 车主姓名
|
||||||
|
*/
|
||||||
|
@Size(max= 40,message="编码长度不能超过40")
|
||||||
|
@ApiModelProperty("车主姓名")
|
||||||
|
@Length(max= 40,message="编码长度不能超过40")
|
||||||
|
private String empName;
|
||||||
|
/**
|
||||||
|
* 车主手机号
|
||||||
|
*/
|
||||||
|
@Size(max= 50,message="编码长度不能超过50")
|
||||||
|
@ApiModelProperty("车主手机号")
|
||||||
|
@Length(max= 50,message="编码长度不能超过50")
|
||||||
|
private String empMobile;
|
||||||
|
/**
|
||||||
|
* 0:进 1:出
|
||||||
|
*/
|
||||||
|
@ApiModelProperty("0:进 1:出")
|
||||||
|
private Integer type;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.spider.common.domain;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @TableName t_user
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class User implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户Id
|
||||||
|
*/
|
||||||
|
@NotNull(message="[用户Id]不能为空")
|
||||||
|
@ApiModelProperty("用户Id")
|
||||||
|
private Integer userId;
|
||||||
|
/**
|
||||||
|
* 用户名
|
||||||
|
*/
|
||||||
|
@Size(max= 30,message="编码长度不能超过30")
|
||||||
|
@ApiModelProperty("用户名")
|
||||||
|
@Length(max= 30,message="编码长度不能超过30")
|
||||||
|
private String userAccount;
|
||||||
|
/**
|
||||||
|
* 用户密码
|
||||||
|
*/
|
||||||
|
@Size(max= 30,message="编码长度不能超过30")
|
||||||
|
@ApiModelProperty("用户密码")
|
||||||
|
@Length(max= 30,message="编码长度不能超过30")
|
||||||
|
private String userPwd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.spider.common.domain.bo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 11:22
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CarBo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工姓名
|
||||||
|
*/
|
||||||
|
private String empName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工车牌号
|
||||||
|
*/
|
||||||
|
private String carCard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工手机哈
|
||||||
|
*/
|
||||||
|
private String mobile;
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.spider.common.domain.bo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 11:37
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EmpBo {
|
||||||
|
/**
|
||||||
|
* 员工Id
|
||||||
|
*/
|
||||||
|
private String empId;
|
||||||
|
/**
|
||||||
|
* 员工名称
|
||||||
|
*/
|
||||||
|
private String empName;
|
||||||
|
/**
|
||||||
|
* 员工手机号
|
||||||
|
*/
|
||||||
|
private String empMobile;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.spider.common.domain.request;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 10:52
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CarReq{
|
||||||
|
|
||||||
|
private String empName;
|
||||||
|
|
||||||
|
private String carCard;
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.spider.common.domain.response;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.C;
|
||||||
|
import com.spider.common.domain.Car;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 11:05
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CarRes extends Car {
|
||||||
|
/**
|
||||||
|
* 员工名称
|
||||||
|
*/
|
||||||
|
@Size(max= 50,message="编码长度不能超过50")
|
||||||
|
@ApiModelProperty("员工名称")
|
||||||
|
@Length(max= 50,message="编码长度不能超过50")
|
||||||
|
private String empName;
|
||||||
|
/**
|
||||||
|
* 员工手机号
|
||||||
|
*/
|
||||||
|
@Size(max= 50,message="编码长度不能超过50")
|
||||||
|
@ApiModelProperty("员工手机号")
|
||||||
|
@Length(max= 50,message="编码长度不能超过50")
|
||||||
|
private String empMobile;
|
||||||
|
}
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.spider.common.domain.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 12:03
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class EchoCarRes {
|
||||||
|
/**
|
||||||
|
* 员工姓名
|
||||||
|
*/
|
||||||
|
private String empName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工车牌号
|
||||||
|
*/
|
||||||
|
private String carCard;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 员工手机哈
|
||||||
|
*/
|
||||||
|
private String empMobile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车辆类型
|
||||||
|
*/
|
||||||
|
private String carModel;
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package com.spider.common.handler;
|
||||||
|
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
import org.springframework.validation.ObjectError;
|
||||||
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 14:55
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@RestControllerAdvice
|
||||||
|
public class ValidatedHandler {
|
||||||
|
|
||||||
|
@ExceptionHandler
|
||||||
|
public Result<String> validatedHandler(MethodArgumentNotValidException e){
|
||||||
|
|
||||||
|
String error = "";
|
||||||
|
|
||||||
|
for (ObjectError allError : e.getBindingResult().getAllErrors()) {
|
||||||
|
String defaultMessage = allError.getDefaultMessage();
|
||||||
|
|
||||||
|
error = defaultMessage+"\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.error(error);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,314 @@
|
||||||
|
package com.spider.common.utils;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.security.KeyManagementException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.net.ssl.SSLContext;
|
||||||
|
import javax.net.ssl.TrustManager;
|
||||||
|
import javax.net.ssl.X509TrustManager;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.NameValuePair;
|
||||||
|
import org.apache.http.client.HttpClient;
|
||||||
|
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||||
|
import org.apache.http.client.methods.HttpDelete;
|
||||||
|
import org.apache.http.client.methods.HttpGet;
|
||||||
|
import org.apache.http.client.methods.HttpPost;
|
||||||
|
import org.apache.http.client.methods.HttpPut;
|
||||||
|
import org.apache.http.conn.ClientConnectionManager;
|
||||||
|
import org.apache.http.conn.scheme.Scheme;
|
||||||
|
import org.apache.http.conn.scheme.SchemeRegistry;
|
||||||
|
import org.apache.http.conn.ssl.SSLSocketFactory;
|
||||||
|
import org.apache.http.entity.ByteArrayEntity;
|
||||||
|
import org.apache.http.entity.StringEntity;
|
||||||
|
import org.apache.http.impl.client.DefaultHttpClient;
|
||||||
|
import org.apache.http.message.BasicNameValuePair;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class HttpUtils {
|
||||||
|
/**
|
||||||
|
* get
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doGet(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpGet request = new HttpGet(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* post form
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param bodys
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPost(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
Map<String, String> bodys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bodys != null) {
|
||||||
|
List<NameValuePair> nameValuePairList = new ArrayList<NameValuePair>();
|
||||||
|
|
||||||
|
for (String key : bodys.keySet()) {
|
||||||
|
nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key)));
|
||||||
|
}
|
||||||
|
UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8");
|
||||||
|
formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8");
|
||||||
|
request.setEntity(formEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post String
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPost(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
String body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(body)) {
|
||||||
|
request.setEntity(new StringEntity(body, "utf-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Post stream
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPost(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
byte[] body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPost request = new HttpPost(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body != null) {
|
||||||
|
request.setEntity(new ByteArrayEntity(body));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put String
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPut(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
String body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(body)) {
|
||||||
|
request.setEntity(new StringEntity(body, "utf-8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Put stream
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @param body
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doPut(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys,
|
||||||
|
byte[] body)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpPut request = new HttpPut(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (body != null) {
|
||||||
|
request.setEntity(new ByteArrayEntity(body));
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete
|
||||||
|
*
|
||||||
|
* @param host
|
||||||
|
* @param path
|
||||||
|
* @param method
|
||||||
|
* @param headers
|
||||||
|
* @param querys
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public static HttpResponse doDelete(String host, String path, String method,
|
||||||
|
Map<String, String> headers,
|
||||||
|
Map<String, String> querys)
|
||||||
|
throws Exception {
|
||||||
|
HttpClient httpClient = wrapClient(host);
|
||||||
|
|
||||||
|
HttpDelete request = new HttpDelete(buildUrl(host, path, querys));
|
||||||
|
for (Map.Entry<String, String> e : headers.entrySet()) {
|
||||||
|
request.addHeader(e.getKey(), e.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient.execute(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String buildUrl(String host, String path, Map<String, String> querys) throws UnsupportedEncodingException {
|
||||||
|
StringBuilder sbUrl = new StringBuilder();
|
||||||
|
sbUrl.append(host);
|
||||||
|
if (!StringUtils.isBlank(path)) {
|
||||||
|
sbUrl.append(path);
|
||||||
|
}
|
||||||
|
if (null != querys) {
|
||||||
|
StringBuilder sbQuery = new StringBuilder();
|
||||||
|
for (Map.Entry<String, String> query : querys.entrySet()) {
|
||||||
|
if (0 < sbQuery.length()) {
|
||||||
|
sbQuery.append("&");
|
||||||
|
}
|
||||||
|
if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) {
|
||||||
|
sbQuery.append(query.getValue());
|
||||||
|
}
|
||||||
|
if (!StringUtils.isBlank(query.getKey())) {
|
||||||
|
sbQuery.append(query.getKey());
|
||||||
|
if (!StringUtils.isBlank(query.getValue())) {
|
||||||
|
sbQuery.append("=");
|
||||||
|
sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (0 < sbQuery.length()) {
|
||||||
|
sbUrl.append("?").append(sbQuery);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return sbUrl.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static HttpClient wrapClient(String host) {
|
||||||
|
HttpClient httpClient = new DefaultHttpClient();
|
||||||
|
if (host.startsWith("https://")) {
|
||||||
|
sslClient(httpClient);
|
||||||
|
}
|
||||||
|
|
||||||
|
return httpClient;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void sslClient(HttpClient httpClient) {
|
||||||
|
try {
|
||||||
|
SSLContext ctx = SSLContext.getInstance("TLS");
|
||||||
|
X509TrustManager tm = new X509TrustManager() {
|
||||||
|
public X509Certificate[] getAcceptedIssuers() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
public void checkClientTrusted(X509Certificate[] xcs, String str) {
|
||||||
|
|
||||||
|
}
|
||||||
|
public void checkServerTrusted(X509Certificate[] xcs, String str) {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ctx.init(null, new TrustManager[] { tm }, null);
|
||||||
|
SSLSocketFactory ssf = new SSLSocketFactory(ctx);
|
||||||
|
ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
|
||||||
|
ClientConnectionManager ccm = httpClient.getConnectionManager();
|
||||||
|
SchemeRegistry registry = ccm.getSchemeRegistry();
|
||||||
|
registry.register(new Scheme("https", 443, ssf));
|
||||||
|
} catch (KeyManagementException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
} catch (NoSuchAlgorithmException ex) {
|
||||||
|
throw new RuntimeException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package com.spider.common.utils;
|
||||||
|
|
||||||
|
import org.apache.http.HttpResponse;
|
||||||
|
import org.apache.http.util.EntityUtils;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class MsgUtil {
|
||||||
|
|
||||||
|
public String sendMsg(String phone,String code){
|
||||||
|
String result = null;
|
||||||
|
String host = "https://gyidcard.market.alicloudapi.com";
|
||||||
|
String path = "/sms/smsSend";
|
||||||
|
String method = "POST";
|
||||||
|
String appcode = "3a5b9903d4a6470c9b75dd44c35811a9";
|
||||||
|
Map<String, String> headers = new HashMap<String, String>();
|
||||||
|
//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
|
||||||
|
headers.put("Authorization", "APPCODE " + appcode);
|
||||||
|
Map<String, String> querys = new HashMap<String, String>();
|
||||||
|
querys.put("mobile", phone);
|
||||||
|
querys.put("param", "**code**:"+code+",**minute**:5");
|
||||||
|
|
||||||
|
//smsSignId(短信前缀)和templateId(短信模板),可登录国阳云控制台自助申请。参考文档:http://help.guoyangyun.com/Problem/Qm.html
|
||||||
|
|
||||||
|
querys.put("smsSignId", "2e65b1bb3d054466b82f0c9d125465e2");
|
||||||
|
querys.put("templateId", "908e94ccf08b4476ba6c876d13f084ad");
|
||||||
|
Map<String, String> bodys = new HashMap<String, String>();
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
/**
|
||||||
|
* 重要提示如下:
|
||||||
|
* HttpUtils请从\r\n\t \t* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java\r\n\t \t* 下载
|
||||||
|
*
|
||||||
|
* 相应的依赖请参照
|
||||||
|
* https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml
|
||||||
|
*/
|
||||||
|
HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
|
||||||
|
// System.out.println(response.toString());
|
||||||
|
//获取response的body
|
||||||
|
result = EntityUtils.toString(response.getEntity());
|
||||||
|
System.out.println(result);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,2 +1,4 @@
|
||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
com.spider.common.config.RedisConfig
|
com.spider.common.config.RedisConfig,\
|
||||||
|
com.spider.common.utils.MsgUtil,\
|
||||||
|
com.spider.common.handler.ValidatedHandler
|
||||||
|
|
|
@ -1,7 +1,18 @@
|
||||||
package com.spider.system.controller;
|
package com.spider.system.controller;
|
||||||
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import com.spider.common.domain.Car;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import com.spider.common.domain.request.CarReq;
|
||||||
|
import com.spider.common.domain.response.CarRes;
|
||||||
|
import com.spider.common.domain.response.EchoCarRes;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
import com.spider.system.service.CarService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 📝 TODO
|
* 📝 TODO
|
||||||
|
@ -10,5 +21,78 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/car")
|
@RequestMapping("/car")
|
||||||
|
@Log4j2
|
||||||
public class CarController {
|
public class CarController {
|
||||||
|
|
||||||
|
private final CarService carService;
|
||||||
|
|
||||||
|
public CarController(CarService carService) {
|
||||||
|
this.carService = carService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private HttpServletRequest request;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆信息
|
||||||
|
* @param carReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/queryCar")
|
||||||
|
public Result<List<CarRes>> queryCar(@RequestBody CarReq carReq){
|
||||||
|
return carService.getCarList(carReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取消登记
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/cancelReg")
|
||||||
|
public Result<String> cancelReg(@RequestBody String[] carIds ){
|
||||||
|
log.info("功能描述: xx,请求URI:{},请求方式: {},请求参数: {}",
|
||||||
|
request.getRequestURI(),request.getMethod(),carIds);
|
||||||
|
|
||||||
|
return carService.updCarState(carIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登记
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/sign")
|
||||||
|
public Result<String> sign(@RequestBody @Validated Car car){
|
||||||
|
return carService.saveCar(car);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆信息
|
||||||
|
* @param carId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/redact")
|
||||||
|
public Result<CarRes> redact(@RequestParam String carId){
|
||||||
|
return carService.getCarResByCarId(carId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/renewal")
|
||||||
|
public Result<String> renewal(@RequestBody @Validated Car car){
|
||||||
|
return carService.renewal(car);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回显登记信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/echoCar")
|
||||||
|
public Result<EchoCarRes> echoCar(@RequestParam String carId){
|
||||||
|
return carService.getEchoCarResByCarId(carId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.spider.system.controller;
|
||||||
|
|
||||||
|
import com.spider.common.domain.bo.EmpBo;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
import com.spider.system.service.EmpService;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 11:35
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/emp")
|
||||||
|
public class EmpController {
|
||||||
|
private final EmpService empService;
|
||||||
|
|
||||||
|
public EmpController(EmpService empService) {
|
||||||
|
this.empService = empService;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("queryEmp")
|
||||||
|
public Result<List<EmpBo>> queryEmp() {
|
||||||
|
|
||||||
|
return empService.getEmpList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.spider.system.controller;
|
||||||
|
|
||||||
|
import com.spider.common.domain.Record;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
import com.spider.system.service.RecordService;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 12:39
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/record")
|
||||||
|
public class RecordController {
|
||||||
|
private final RecordService recordService;
|
||||||
|
|
||||||
|
public RecordController(RecordService recordService) {
|
||||||
|
this.recordService = recordService;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进出登记
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/entryExitReg")
|
||||||
|
public Result<String> entryExitReg(@RequestBody Record record){
|
||||||
|
return recordService.entryExitReg(record);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取记录列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/queryRecord")
|
||||||
|
public Result<List<Record>> queryRecord(){
|
||||||
|
return recordService.getRecordList();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,17 @@
|
||||||
package com.spider.system.mapper;
|
package com.spider.system.mapper;
|
||||||
|
|
||||||
|
import com.spider.common.domain.Car;
|
||||||
|
import com.spider.common.domain.bo.CarBo;
|
||||||
|
import com.spider.common.domain.request.CarReq;
|
||||||
|
import com.spider.common.domain.response.CarRes;
|
||||||
|
import com.spider.common.domain.response.EchoCarRes;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 📝 TODO
|
* 📝 TODO
|
||||||
|
@ -9,4 +20,20 @@ import org.apache.ibatis.annotations.Mapper;
|
||||||
*/
|
*/
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface CarMapper {
|
public interface CarMapper {
|
||||||
|
|
||||||
|
List<CarRes> selectCarList(CarReq carReq);
|
||||||
|
|
||||||
|
int updCarStateByCarId(@Param("carIds") String[] carIds);
|
||||||
|
|
||||||
|
List<CarBo> selectCarAndEmpByCarId(@Param("carIds") String[] carIds);
|
||||||
|
|
||||||
|
int insertCar(Car car);
|
||||||
|
|
||||||
|
CarRes selectCarByCarId(@Param("carId") String carId);
|
||||||
|
|
||||||
|
int updCarByCarId( Car car);
|
||||||
|
|
||||||
|
EchoCarRes selectEchoCarResByCarId(@Param("carId") String carId);
|
||||||
|
|
||||||
|
int updCarCountAndLatelyTimeByCarCard(@Param("carCard") String carCard);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.spider.system.mapper;
|
||||||
|
|
||||||
|
import com.spider.common.domain.Emp;
|
||||||
|
import com.spider.common.domain.bo.EmpBo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 11:36
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface EmpMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取员工姓名和手机号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<EmpBo> selectEmpList();
|
||||||
|
|
||||||
|
EmpBo selectEmpByEmpId(@Param("empId") String empId);
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
package com.spider.system.mapper;
|
||||||
|
|
||||||
|
import com.spider.common.domain.Record;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 12:40
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RecordMapper {
|
||||||
|
int insertRecord(Record record);
|
||||||
|
|
||||||
|
List<Record> selectRecord();
|
||||||
|
}
|
|
@ -1,9 +1,60 @@
|
||||||
package com.spider.system.service;
|
package com.spider.system.service;
|
||||||
|
|
||||||
|
import com.spider.common.domain.Car;
|
||||||
|
import com.spider.common.domain.request.CarReq;
|
||||||
|
import com.spider.common.domain.response.CarRes;
|
||||||
|
import com.spider.common.domain.response.EchoCarRes;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 📝 TODO
|
* 📝 TODO
|
||||||
* 🕟 2024/1/19 10:50
|
* 🕟 2024/1/19 10:50
|
||||||
* 👦 Lxj
|
* 👦 Lxj
|
||||||
*/
|
*/
|
||||||
public interface CarService {
|
public interface CarService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆列表
|
||||||
|
* @param carReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Result<List<CarRes>> getCarList(CarReq carReq);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所选记录状态可以正确的更新为已失效
|
||||||
|
* @param carIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Result<String> updCarState(String[] carIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登记车辆
|
||||||
|
* @param car
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Result<String> saveCar(Car car);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆信息
|
||||||
|
* @param carId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Result<CarRes> getCarResByCarId(String carId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据
|
||||||
|
* @param car
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Result<String> renewal( Car car);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Result<EchoCarRes> getEchoCarResByCarId(String carId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.spider.system.service;
|
||||||
|
|
||||||
|
import com.spider.common.domain.bo.EmpBo;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 11:35
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
public interface EmpService {
|
||||||
|
/**
|
||||||
|
* 获取员工姓名和手机号
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Result<List<EmpBo>> getEmpList();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package com.spider.system.service;
|
||||||
|
|
||||||
|
import com.spider.common.domain.Record;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 12:39
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
public interface RecordService {
|
||||||
|
|
||||||
|
Result<String> entryExitReg(Record record);
|
||||||
|
|
||||||
|
Result<List<Record>> getRecordList();
|
||||||
|
}
|
|
@ -1,13 +1,185 @@
|
||||||
package com.spider.system.service.impl;
|
package com.spider.system.service.impl;
|
||||||
|
|
||||||
|
import com.spider.common.domain.Car;
|
||||||
|
import com.spider.common.domain.bo.CarBo;
|
||||||
|
import com.spider.common.domain.bo.EmpBo;
|
||||||
|
import com.spider.common.domain.request.CarReq;
|
||||||
|
import com.spider.common.domain.response.CarRes;
|
||||||
|
import com.spider.common.domain.response.EchoCarRes;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
import com.spider.common.utils.MsgUtil;
|
||||||
|
import com.spider.common.utils.StringUtils;
|
||||||
|
import com.spider.system.mapper.CarMapper;
|
||||||
|
import com.spider.system.mapper.EmpMapper;
|
||||||
import com.spider.system.service.CarService;
|
import com.spider.system.service.CarService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 📝 TODO
|
* 📝 TODO
|
||||||
* 🕟 2024/1/19 10:50
|
* 🕟 2024/1/19 10:50
|
||||||
* 👦 Lxj
|
* 👦 Lxj
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
|
@Log4j2
|
||||||
public class CarServiceImpl implements CarService {
|
public class CarServiceImpl implements CarService {
|
||||||
|
private final CarMapper carMapper;
|
||||||
|
|
||||||
|
private final EmpMapper empMapper;
|
||||||
|
|
||||||
|
public CarServiceImpl(CarMapper carMapper, EmpMapper empMapper) {
|
||||||
|
this.carMapper = carMapper;
|
||||||
|
|
||||||
|
this.empMapper = empMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MsgUtil msgUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆
|
||||||
|
* @param carReq
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<List<CarRes>> getCarList(CarReq carReq) {
|
||||||
|
|
||||||
|
List<CarRes> cars = carMapper.selectCarList(carReq);
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(cars)){
|
||||||
|
return Result.error("获取车辆异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success(cars);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所选记录状态可以正确的更新为已失效
|
||||||
|
* @param carIds
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<String> updCarState(String[] carIds) {
|
||||||
|
|
||||||
|
int res = carMapper.updCarStateByCarId(carIds);
|
||||||
|
|
||||||
|
if(res < 1){
|
||||||
|
return Result.error("操作异常,请稍后");
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取信息
|
||||||
|
List<CarBo> carBos = carMapper.selectCarAndEmpByCarId(carIds);
|
||||||
|
|
||||||
|
if(StringUtils.isEmpty(carBos)){
|
||||||
|
return Result.error("短信发送异常");
|
||||||
|
}
|
||||||
|
|
||||||
|
//循环发短信
|
||||||
|
carBos.forEach(carBo -> {
|
||||||
|
String msg = msgUtil.sendMsg(
|
||||||
|
carBo.getMobile(),
|
||||||
|
"尊敬的" + carBo.getEmpName() + "你的车辆<" + carBo.getCarCard() + ">已取消登记成功"
|
||||||
|
);
|
||||||
|
log.info(msg);
|
||||||
|
|
||||||
|
if(msg.contains("ok")){
|
||||||
|
log.info("尊敬的" + carBo.getEmpName() + "你的车辆<" + carBo.getCarCard() + ">已取消登记成功");
|
||||||
|
}else {
|
||||||
|
log.error("尊敬的" + carBo.getEmpName() + "你的车辆<" + carBo.getCarCard() + ">取消登记失败");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登记车辆
|
||||||
|
* @param car
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<String> saveCar(Car car) {
|
||||||
|
|
||||||
|
int res = carMapper.insertCar(car);
|
||||||
|
|
||||||
|
if(res < 1){
|
||||||
|
return Result.error("登记异常,请稍后");
|
||||||
|
}
|
||||||
|
|
||||||
|
String empId = String.valueOf(car.getEmpId());
|
||||||
|
|
||||||
|
EmpBo empBo = empMapper.selectEmpByEmpId(empId);
|
||||||
|
|
||||||
|
String msg = msgUtil.sendMsg(
|
||||||
|
empBo.getEmpMobile(),
|
||||||
|
"尊敬的" + empBo.getEmpName() + "你的车辆<" + empBo.getEmpMobile() + ">已取消登记成功"
|
||||||
|
);
|
||||||
|
|
||||||
|
log.info(msg);
|
||||||
|
|
||||||
|
if(msg.contains("ok")){
|
||||||
|
log.info("尊敬的" + empBo.getEmpName() + "你的车辆<" + empBo.getEmpMobile() + ">已取消登记成功");
|
||||||
|
}else {
|
||||||
|
log.error("尊敬的" + empBo.getEmpName() + "你的车辆<" + empBo.getEmpMobile() + ">取消登记失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询车辆信息
|
||||||
|
* @param carId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<CarRes> getCarResByCarId(String carId) {
|
||||||
|
|
||||||
|
CarRes carRes = carMapper.selectCarByCarId(carId);
|
||||||
|
|
||||||
|
if(StringUtils.isNull(carRes)){
|
||||||
|
return Result.error("获取异常,请重试");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success(carRes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新数据
|
||||||
|
* @param car
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<String> renewal(Car car) {
|
||||||
|
|
||||||
|
int res = carMapper.updCarByCarId(car);
|
||||||
|
|
||||||
|
if(res < 1){
|
||||||
|
return Result.error("更新异常,请稍后");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取车辆
|
||||||
|
* @param carId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<EchoCarRes> getEchoCarResByCarId(String carId) {
|
||||||
|
EchoCarRes echoCarRes = carMapper.selectEchoCarResByCarId(carId);
|
||||||
|
|
||||||
|
if(StringUtils.isNull(echoCarRes)){
|
||||||
|
return Result.error("获取异常,请重试");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.success(echoCarRes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.spider.system.service.impl;
|
||||||
|
|
||||||
|
|
||||||
|
import com.spider.common.domain.bo.EmpBo;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
import com.spider.system.mapper.EmpMapper;
|
||||||
|
import com.spider.system.service.EmpService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 11:35
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class EmpServiceImpl implements EmpService {
|
||||||
|
|
||||||
|
private final EmpMapper empMapper;
|
||||||
|
|
||||||
|
public EmpServiceImpl(EmpMapper empMapper) {
|
||||||
|
this.empMapper = empMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<List<EmpBo>> getEmpList() {
|
||||||
|
|
||||||
|
return Result.success(empMapper.selectEmpList());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,63 @@
|
||||||
|
package com.spider.system.service.impl;
|
||||||
|
|
||||||
|
import com.spider.common.domain.Record;
|
||||||
|
import com.spider.common.result.Result;
|
||||||
|
import com.spider.system.mapper.CarMapper;
|
||||||
|
import com.spider.system.mapper.RecordMapper;
|
||||||
|
import com.spider.system.service.RecordService;
|
||||||
|
import lombok.extern.log4j.Log4j2;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 📝 TODO
|
||||||
|
* 🕟 2024/1/19 12:40
|
||||||
|
* 👦 Lxj
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Log4j2
|
||||||
|
public class RecordServiceImpl implements RecordService {
|
||||||
|
private final RecordMapper recordMapper;
|
||||||
|
|
||||||
|
public RecordServiceImpl(RecordMapper recordMapper) {
|
||||||
|
this.recordMapper = recordMapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CarMapper carMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 进出登记
|
||||||
|
* @param record
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<String> entryExitReg(Record record) {
|
||||||
|
|
||||||
|
int res = recordMapper.insertRecord(record);
|
||||||
|
|
||||||
|
if(res < 1){
|
||||||
|
return Result.error("记录异常,请稍后");
|
||||||
|
}
|
||||||
|
|
||||||
|
int updCarRes = carMapper
|
||||||
|
.updCarCountAndLatelyTimeByCarCard(record.getCarCard());
|
||||||
|
|
||||||
|
if (updCarRes > 1)
|
||||||
|
log.info(record.getCarCard()+"记录成功");
|
||||||
|
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取记录列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Result<List<Record>> getRecordList() {
|
||||||
|
|
||||||
|
return Result.success(recordMapper.selectRecord());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
<?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">
|
||||||
|
<!--
|
||||||
|
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||||
|
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||||
|
-->
|
||||||
|
<mapper namespace="com.spider.system.mapper.CarMapper">
|
||||||
|
|
||||||
|
<insert id="insertCar">
|
||||||
|
INSERT INTO `week02-car`.`t_car` ( `emp_id`, `car_card`, `car_model`, `reg_time`, `car_position`, `car_type`,`car_count`, `lately_time` )
|
||||||
|
VALUES
|
||||||
|
( #{empId}, #{carCard}, #{carModel}, now(), #{carPosition}, #{carType}, 1, now() );
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updCarStateByCarId">
|
||||||
|
UPDATE t_car c
|
||||||
|
SET c.car_state = 1
|
||||||
|
WHERE
|
||||||
|
c.car_id in (
|
||||||
|
|
||||||
|
<foreach collection="carIds" item="id" separator="," >
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updCarByCarId">
|
||||||
|
UPDATE `week02-car`.`t_car`
|
||||||
|
SET
|
||||||
|
`car_card` = #{carCard},
|
||||||
|
`car_model` = #{carModel},
|
||||||
|
`car_position` = #{carPosition},
|
||||||
|
`car_type` = 1,
|
||||||
|
`car_state` = 0
|
||||||
|
WHERE
|
||||||
|
`car_id` = #{carId};
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updCarCountAndLatelyTimeByCarCard">
|
||||||
|
UPDATE `week02-car`.`t_car`
|
||||||
|
SET
|
||||||
|
`car_count` = car_count+1,
|
||||||
|
lately_time = now()
|
||||||
|
WHERE
|
||||||
|
`car_card` = #{carCard};
|
||||||
|
</update>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectCarList" resultType="com.spider.common.domain.response.CarRes">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
t_car c
|
||||||
|
LEFT JOIN t_emp e ON c.emp_id = e.emp_id
|
||||||
|
WHERE
|
||||||
|
1
|
||||||
|
<if test="empName != null and empName != ''">
|
||||||
|
and e.emp_name like CONCAT('%',#{empName},'%')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="carCard != null and carCard != ''">
|
||||||
|
and c.car_card like CONCAT('%',#{carCard},'%')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCarAndEmpByCarId" resultType="com.spider.common.domain.bo.CarBo">
|
||||||
|
SELECT
|
||||||
|
c.car_card,
|
||||||
|
e.emp_name,
|
||||||
|
e.emp_mobile
|
||||||
|
FROM
|
||||||
|
t_car c
|
||||||
|
LEFT JOIN t_emp e ON c.emp_id = e.emp_id
|
||||||
|
WHERE c.car_id in
|
||||||
|
(
|
||||||
|
<foreach collection="carIds" item="id" separator="," >
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectCarByCarId" resultType="com.spider.common.domain.response.CarRes">
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
t_car c
|
||||||
|
LEFT JOIN t_emp e ON c.emp_id = e.emp_id
|
||||||
|
WHERE c.car_id = #{carId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectEchoCarResByCarId" resultType="com.spider.common.domain.response.EchoCarRes">
|
||||||
|
SELECT
|
||||||
|
c.car_card,
|
||||||
|
e.emp_name,
|
||||||
|
e.emp_mobile,
|
||||||
|
c.car_model
|
||||||
|
FROM
|
||||||
|
t_car c
|
||||||
|
LEFT JOIN t_emp e ON c.emp_id = e.emp_id
|
||||||
|
WHERE c.car_id = #{carId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?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">
|
||||||
|
<!--
|
||||||
|
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||||
|
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||||
|
-->
|
||||||
|
<mapper namespace="com.spider.system.mapper.EmpMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="selectEmpList" resultType="com.spider.common.domain.bo.EmpBo">
|
||||||
|
SELECT
|
||||||
|
e.emp_id,
|
||||||
|
e.emp_name,
|
||||||
|
e.emp_mobile
|
||||||
|
FROM
|
||||||
|
t_emp e
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectEmpByEmpId" resultType="com.spider.common.domain.bo.EmpBo">
|
||||||
|
SELECT
|
||||||
|
e.emp_name,
|
||||||
|
e.emp_mobile
|
||||||
|
FROM
|
||||||
|
t_emp e.emp_id = #{empId}
|
||||||
|
where e
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?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">
|
||||||
|
<!--
|
||||||
|
1.在mybats的开发中namespace有特殊的意思,一定要是对应接口的全限定名
|
||||||
|
通过namespace可以简历mapper.xml和接口之间的关系(名字不重要,位置不重要)
|
||||||
|
-->
|
||||||
|
<mapper namespace="com.spider.system.mapper.RecordMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="insertRecord">
|
||||||
|
INSERT INTO `week02-car`.`t_record` ( `car_card`, `car_model`, `create_time`, `emp_name`, `emp_mobile`, `type` )
|
||||||
|
VALUES
|
||||||
|
( #{carCard}, #{carModel}, now(),#{empName} , #{empMobile}, #{type} );
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="selectRecord" resultType="com.spider.common.domain.Record">
|
||||||
|
select * from t_record
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue