实体类:
package com.byx.communitycontrol.common.entity.baseinfo;
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 lombok.Data;
import java.time.LocalDateTime;
/**
* 车辆信息
**/
@Data
@TableName(value = "T_CARINFO")
public class CarInfo {
/**
* 车辆标识
*/
@TableId(value = "MOTORVEHICLEID",type = IdType.INPUT)
private String motorvehicleId;
/**
* 设备编码
*/
@TableField(value = "DEVICEID")
private String deviceId;
/**
* 有无车牌
*/
@TableField(value = "HASPLATE")
private String hasPlate;
/**
* 信息分类
*/
@TableField(value = "INFOKIND")
private Integer infoKind;
/**
* 车道号
*/
@TableField(value = "LANONO")
private Integer lanono;
@TableField(value = "LEFTTOPX")
private Integer leftTopX;
@TableField(value = "LEFTTOPY")
private Integer leftTopY;
/**
*
*/
@TableField(value = "MARKTIME")
private String markTime;
/**
* 经过时刻
*/
@TableField(value = "JGSJ")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime jgsj;
/**
* 号牌种类
*/
@TableField(value = "PLATECLASS")
private String plateClass;
/**
* 车牌颜色
*/
@TableField(value = "PLATECOLOR")
private String plateColor;
/**
* 车牌号
*/
@TableField(value = "PLATENO")
private String plateNo;
/**
*
*/
@TableField(value = "RIGHTBTMX")
private Integer rightBtmX;
/**
*
*/
@TableField(value = "RIGHTBTMY")
private Integer rightBtmY;
/**
* 来源标识
*/
@TableField(value = "SOURCEID")
private String sourceId;
/**
* 行驶速度
*/
@TableField(value = "SPEED")
private Float speed;
/**
*
*/
@TableField(value = "STORAGEURL1")
private String storageUrl1;
/**
* 车辆类型
*/
@TableField(value = "VEHICLECLASS")
private String vehicleClass;
/**
* 车身颜色
*/
@TableField(value = "VEHICLECOLOR")
private String vehicleColor;
/**
* 遮阳板状态
*/
@TableField(value = "SUNVISOR")
private Integer sunVisor;
/**
* 安全带状态
*/
@TableField(value = "SAFETYBELT")
private Integer safetyBelt;
/**
* 打电话状态
*/
@TableField(value = "CALLING")
private Integer calling;
/**
*
*/
@TableField(value = "BREAKRULEMODE")
private String breakrlueMode;
/**
* 全景照片
*/
@TableField(value = "QJZP")
private String qjzp;
/**
* 特征照片
*/
@TableField(value = "TZZP")
private String tzzp;
/**
* 颜色深浅
*/
@TableField(value = "VEHICLECOLORDEPTH")
private Integer vehicleColorDepth;
}
package com.byx.communitycontrol.common.entity.baseinfo;
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 lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
@TableName(value = "T_FACEINFO")
@Data
public class FaceInfo implements Serializable {
/**
* 人脸标识
*/
@TableId(value = "FACEID", type = IdType.INPUT)
private String faceId;
/**
* 信息分类
*/
@TableField(value = "INFOKIND")
private Integer infoKind;
/**
* 来源标识
*/
@TableField(value = "SOURCEID")
private String sourceId;
/**
* 设备编码
*/
@TableField(value = "DEVICEID")
private String deviceId;
/**
* 拍摄时间
*/
@TableField(value = "SHOTTIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime shotTime;
/**
* 定位时间
*/
@TableField(value = "LOCATIONMARKTIME")
private String locationMarkTime;
/**
* 人脸出现时间
*/
@TableField(value = "FACEAPPEARTIME")
protected String faceAppearTime;
/**
* 人脸消失时间
*/
@TableField(value = "FACEDISAPPEARTIME")
private String faceDisappearTime;
/**
* 是否司机
*/
@TableField(value = "ISDRIVER")
private Integer isDriver;
/**
* 是否外国人
*/
@TableField(value = "ISFOREIGNER")
private Integer isForeigner;
/**
* 是否疑似恐怖分子
*/
@TableField(value = "ISSUSPECTEDTERRORIST")
private Integer isSuspectedTerrorist;
/**
* 是否犯罪嫌疑人
*/
@TableField(value = "ISCRIMINALINVOLVED")
private Integer isCriminalInvolved;
/**
* 是否被拘留者
*/
@TableField(value = "ISDETAINEES")
private Integer isDetainees;
/**
* 是否受害者
*/
@TableField(value = "ISVICTIM")
private Integer isVictim;
/**
* 是否可疑人物
*/
@TableField(value = "ISSUSPICIOUSPERSON")
private Integer isSuspiciousPerson;
/**
* 事件排序
*/
@TableField(value = "EVENTSORT")
private String eventSort;
/**
* 全景照片
*/
@TableField(value = "QJZP")
private String qjzp;
/**
* 特征照片
*/
@TableField(value = "TZZP")
private String tzzp;
}
实现类:(方法一)
package com.byx.communitycontrol.gm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.byx.communitycontrol.common.entity.AppPage;
import com.byx.communitycontrol.common.entity.baseinfo.CarInfo;
import com.byx.communitycontrol.common.request.CarInfoPageRequest;
import com.byx.communitycontrol.common.vo.CarInfoVo;
import com.byx.communitycontrol.context.helper.MyBatisPlusPageImpl;
import com.byx.communitycontrol.gm.mapper.CarInfoMapper;
import com.byx.communitycontrol.gm.service.ICarInfoService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource;
@Service
public class CarInfoServiceImpl extends ServiceImpl<CarInfoMapper, CarInfo> implements ICarInfoService {
@Resource
private CarInfoMapper carInfoMapper;
@Override
public AppPage<CarInfoVo> findListByPageCondition(CarInfoPageRequest request) {
Page<CarInfo> page = new Page<>(request.getCurrentPage(), request.getPageSize());
//1.排序
QueryWrapper<CarInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("jgsj");
//分页条件查询
if (StringUtils.hasText(request.getPlateNo())) {
queryWrapper.like("plateNo",request.getPlateNo());
}
if (StringUtils.hasText(request.getVehicleClass())) {
queryWrapper.like("vehicleClass",request.getVehicleClass());
}
Page<CarInfo> carInfoPage = carInfoMapper.selectPage(page, queryWrapper);
return new MyBatisPlusPageImpl<>(carInfoPage);
}
}
实现类(方法二):
package com.byx.communitycontrol.gm.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.byx.communitycontrol.common.entity.AppPage;
import com.byx.communitycontrol.common.entity.baseinfo.FaceInfo;
import com.byx.communitycontrol.common.request.FaceInfoPageRequest;
import com.byx.communitycontrol.common.vo.FaceInfoVo;
import com.byx.communitycontrol.context.helper.MyBatisPlusPageImpl;
import com.byx.communitycontrol.gm.mapper.FaceInfoMapper;
import com.byx.communitycontrol.gm.service.IFaceInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@Service
public class FaceInfoServiceImpl extends ServiceImpl<FaceInfoMapper, FaceInfo> implements IFaceInfoService {
@Autowired
private FaceInfoMapper faceInfoMapper;
@Override
public AppPage<FaceInfoVo> findListByPageCondition(FaceInfoPageRequest request) {
Page<FaceInfo> page = new Page<>(request.getCurrentPage(), request.getPageSize());
LocalDateTime startDateTime = null;
LocalDateTime endDateTime = null;
if (request.getFilmingTimeRange() != null && request.getFilmingTimeRange().length > 0) {
startDateTime = LocalDateTime.parse(request.getFilmingTimeRange()[0] + " 00:00:00",
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
endDateTime = LocalDateTime.parse(request.getFilmingTimeRange()[1] + " 23:59:59",
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
page = this.page(page, new QueryWrapper<FaceInfo>().between(startDateTime != null,
"shotTime",
startDateTime,
endDateTime).orderByDesc("shotTime"));
return new MyBatisPlusPageImpl<>(page);
}
}
分页响应类:
package com.byx.communitycontrol.common.entity;
import java.io.Serializable;
import java.util.List;
/**
* 分页Page,各个分页实现框架返回的分页最终二次封装至此接口的实现类。
* <p>以下使用mybatis-plus为例子:
* <pre>{@code
public class MyBatisPlusPageImpl<T> implements AppPage<T> {
private IPage<T> ipage;
public MyBatisPlusPageImpl(IPage<T> ipage) {
this.ipage = ipage;
}
@Override
public int getPageNum() {
return (int) ipage.getCurrent();
}
@Override
public int getPageSize() {
return (int) ipage.getSize();
}
@Override
public long getTotal() {
return ipage.getTotal();
}
@Override
public int getTotalPages() {
return (int) ipage.getPages();
}
@Override
public List<T> getItems() {
return ipage.getRecords();
}
}
}</pre>
*/
public interface AppPage<T> extends Serializable {
/** 当前页页码*/
public int getPageNum();
/** 每页条数*/
public int getPageSize();
/** 总条数*/
public long getTotal();
/** 总页数*/
public int getTotalPages();
/** 分页对象记录*/
public List<T> getItems();
}
package com.byx.communitycontrol.context.helper;
import java.util.List;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.byx.communitycontrol.common.entity.AppPage;
/**
* 分页Page,各个分页实现框架返回的分页最终二次封装至此接口的实现类。
* <p>以下使用mybatis-plus为例子:
* <pre>
*/
public class MyBatisPlusPageImpl<T> implements AppPage<T> {
private static final long serialVersionUID = 1L;
private IPage<T> ipage;
public MyBatisPlusPageImpl(IPage<T> ipage) {
this.ipage = ipage;
}
@Override
public int getPageNum() {
return (int) ipage.getCurrent();
}
@Override
public int getPageSize() {
return (int) ipage.getSize();
}
@Override
public long getTotal() {
return ipage.getTotal();
}
@Override
public int getTotalPages() {
return (int) ipage.getPages();
}
@Override
public List<T> getItems() {
return ipage.getRecords();
}
public void setItems(List<T> itmes){
ipage.setRecords(itmes);
}
}
/**
* </pre>
* =byx
*/
package com.byx.communitycontrol.common.response;
import java.util.List;
import com.byx.communitycontrol.common.consts.WebConstants;
import com.byx.communitycontrol.common.entity.AppPage;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@JsonInclude(Include.NON_NULL)
public class PageResponse<T> extends BaseResponse<T> {
private static final long serialVersionUID = 1L;
private AppPage<T> page;
public PageResponse(){
super();
}
public PageResponse(boolean success, int code, AppPage<T> page) {
this(success, code, null, page);
}
public PageResponse(boolean success, int code, String message, AppPage<T> page) {
super(success, code, message);
this.page = page;
}
public static <T> PageResponse<T> success(AppPage<T> page) {
return new PageResponse<T>(true, WebConstants.SECCUSS_OK_CODE, WebConstants.SECCUSS_OK_MSG, page);
}
public static <T> PageResponse<T> success(String message, AppPage<T> page) {
return new PageResponse<T>(true, WebConstants.SECCUSS_OK_CODE, message, page);
}
public int getPageNum() {
return page.getPageNum();
}
public int getPageSize() {
return page.getPageSize();
}
public long getTotal() {
return page.getTotal();
}
public int getTotalPages() {
return page.getTotalPages();
}
public List<T> getItems() {
return page.getItems();
}
public void setPage(AppPage<T> page) {
this.page = page;
}
}
package com.byx.communitycontrol.common.response;
import java.io.Serializable;
import com.byx.communitycontrol.common.consts.WebConstants;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
@JsonInclude(Include.NON_NULL)
public class BaseResponse<T> implements Serializable {
private static final long serialVersionUID = 1L;
private boolean success;
private int code;
private String message;
private T item;
public BaseResponse(){
super();
}
protected BaseResponse(boolean success, int code) {
this(success, code, null, null);
}
protected BaseResponse(boolean success, int code, String message) {
this(success, code, message, null);
}
protected BaseResponse(boolean success, int code, String message, T item) {
this.success = success;
this.code = code;
this.message = message;
this.item = item;
}
public static BaseResponse<String> success() {
return new BaseResponse<String>(true, WebConstants.SECCUSS_OK_CODE, WebConstants.SECCUSS_OK_MSG);
}
public static BaseResponse<String> success(String message) {
return new BaseResponse<String>(true, WebConstants.SECCUSS_OK_CODE, message);
}
public static <T> BaseResponse<T> success(String message, T any) {
return new BaseResponse<T>(true, WebConstants.SECCUSS_OK_CODE, message, any);
}
public static <T> BaseResponse<T> fail() {
return new BaseResponse<T>(false, WebConstants.FAIL_INTERNAL_CODE, WebConstants.FAIL_INTERNAL_MSG);
}
public static <T> BaseResponse<T> fail(String message) {
return new BaseResponse<T>(false, WebConstants.FAIL_INTERNAL_CODE, message);
}
public static <T> BaseResponse<T> fail(int code, String message) {
return new BaseResponse<T>(false, code, message);
}
public boolean isSuccess() {
return success;
}
public void setSuccess(boolean success) {
this.success = success;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getItem() {
return item;
}
public void setItem(T item) {
this.item = item;
}
}
分页请求父类:
package com.byx.communitycontrol.common.request;
import java.io.Serializable;
public class MyBatisPlusPageRequest implements Serializable {
/**
* 每页条数
*/
private long pageSize;
/**
* 当前页
*/
private long currentPage;
/**
* 最大页数
*/
private long maxPage;
/**
* 数据总条数
*/
private long total;
public long getPageSize() {
return pageSize;
}
public void setPageSize(long pageSize) {
this.pageSize = pageSize;
}
public long getCurrentPage() {
return currentPage;
}
public void setCurrentPage(long currentPage) {
this.currentPage = currentPage;
}
public long getMaxPage() {
return maxPage;
}
public void setMaxPage(long maxPage) {
this.maxPage = maxPage;
}
public long getTotal() {
return total;
}
public void setTotal(long total) {
if (pageSize != 0) {
if (total % pageSize != 0) {
maxPage = total / pageSize + 1;
} else {
maxPage = total / pageSize;
}
}
}
public MyBatisPlusPageRequest() {
}
public MyBatisPlusPageRequest(long pageSize, long currentPage, long total) {
this.pageSize = pageSize;
this.currentPage = currentPage;
this.total = total;
setTotal(total);
}
}