智能停——基于云计算的停车服务平台(续)

StationOrderServiceImpl
package com.cloud.station.service.impl;

import com.cloud.station.mapper.StationOrderMapper;
import com.cloud.station.pojo.DepotInfo;
import com.cloud.station.pojo.StationOrder;
import com.cloud.station.service.DepotInfoService;
import com.cloud.station.service.StationOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service(“stationOrderService”)
public class StationOrderServiceImpl implements StationOrderService {

@Autowired
DepotInfoService depotInfoService;
@Autowired
StationOrderMapper stationOrderMapper;
/**
 * 添加车牌
 *
 * @param carNumber
 * @return
 */
@Override
public Integer addByCarNum(Long stationId,String carNumber) {
    StationOrder stationOrder = new StationOrder();
    stationOrder.setStationId(stationId);
    stationOrder.setCarNum(carNumber);
    stationOrder.setCreateTime(new Date().getTime());
    stationOrder.setEndTime(0L);
    stationOrder.setState(StationOrder.UNDO);

    //如果存在
    StationOrder stationOrder_ = getByStationIdAndCarNuber(stationId,carNumber);
    if(stationOrder_!=null)return 0;

    try {
        return stationOrderMapper.insert(stationOrder);
    } catch (Exception e) {
        return 0;
    }
}

/**
 * 更新实体
 *
 * @param stationOrder
 * @return
 */
@Override
public Integer update(StationOrder stationOrder) {
    try {
        return stationOrderMapper.update(stationOrder);
    } catch (Exception e) {
        return 0;
    }
}

/**
 * 根据车牌查询
 *
 * @param carNum
 * @return
 */
@Override
public StationOrder getByCarNumber(String carNum) {
    StationOrder stationOrder = new StationOrder();
    stationOrder.setCarNum(carNum);

    try {
        return (StationOrder) stationOrderMapper.find(stationOrder).get(0);
    } catch (Exception e) {
        return null;
    }

}

/**
 * 根据停车场ID和车牌查询
 *
 * @param stationId
 * @param carNum
 * @return
 */
@Override
public StationOrder getByStationIdAndCarNuber(Long stationId, String carNum) {
    try {
        return stationOrderMapper.findByStationIdAndCarNuber(stationId,carNum);
    } catch (Exception e) {
        return null;
    }
}

/**
 * 查看历史信息
 *
 * @param carNum
 * @return
 */
@Override
public List getHistory(String carNum) {
    StationOrder stationOrder = new StationOrder();
    stationOrder.setCarNum(carNum);
    try {
        return stationOrderMapper.find(stationOrder);
    } catch (Exception e) {
        return null;
    }
}

}

UserInfoServiceImpl
package com.cloud.station.service.impl;

import org.apache.catalina.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cloud.station.base.impl.BaseServiceImpl;
import com.cloud.station.mapper.UserInfoMapper;
import com.cloud.station.pojo.UserInfo;
import com.cloud.station.service.UserInfoService;

import java.util.List;

@Service(“userInfoService”)
public class UserInfoServiceImpl extends BaseServiceImpl implements
UserInfoService {

@Autowired
private UserInfoMapper userInfoMapper;

/**
* 插入一条用户信息记录
* @param userInfo 实体
* @return Integer
*/
@Override
public Integer save(UserInfo userInfo) {
try{
Integer result = userInfoMapper.insert(userInfo);
return result;
}catch(Exception e){
return 0;//插入用户信息出现异常,返回0.
}
}

/**
* 更具主键查询一条记录
*
* @param obj 主键
* @return 对象实体
* @
*/
@Override
public Object findByPrimaryKey(Object obj) {
try {
return (UserInfo) userInfoMapper.findByPrimaryKey(obj);
} catch (Exception e) {
return null;
}
}

/**
* 根据名称精确查找
*
* @param name 名称
* @return
* @
*/
@Override
public List findByName(String name) {
try {
return userInfoMapper.findByName(name);
} catch (Exception e) {
return null;
}
}

/**
* 更新一条记录
*
* @param entity 实体
* @return 影响记录条数
* @
*/
@Override
public Integer update(Object entity) {
try {
return userInfoMapper.update(entity);
} catch (Exception e) {
return 0;
}
}

/**************************************
* userInfoService
***********************************/
/

* 根据用户名查询密码
* @param account
* @return
*/
@Override
public String getPasswordByAccount(String account) {
try{
String password = userInfoMapper.findPasswordByAccount(account);
return password;
}catch(Exception e){
return null;
}
}

/**
* 根据用户名查询对象
* @param account
* @return
*/
@Override
public UserInfo getUserInfoByAccount(String account) {
try{
UserInfo userInfo = userInfoMapper.findByAccount(account);
return userInfo;
}catch(Exception e){
return null;
}
}

/**
* 分页查询
*
* @param skip 跳过记录数
* @param limit 每页记录查询条数
* @return 集合
* @
*/
@Override
public List findByPage(Integer skip, Integer limit) {
try {
return userInfoMapper.findByPage((skip-1)*limit,limit);
} catch (Exception e) {
return null;
}
}

/**
* 统计总记录条数
*
* @return 总记录数
* @
*/
@Override
public Long count() {
try {
return userInfoMapper.count();
} catch (Exception e) {
return 0L;
}
}
}

POJO类
dto
AddressDTO
package com.cloud.station.pojo.dto;

/**

  • 地址信息DTO类
    */
    public class AddressDTO {
    private double lat;//目标地址经度
    private double lng;//目标地址纬度
    private double distance;//目标地址覆盖半径(米)
    private double step;//增量幅度

    private Long sid;//首选停车场ID

    private int page;//当前页码
    private int limit;//每页数据条数

    public double getLat() {
    return lat;
    }

    public void setLat(double lat) {
    this.lat = lat;
    }

    public double getLng() {
    return lng;
    }

    public void setLng(double lng) {
    this.lng = lng;
    }

    public double getDistance() {
    return distance;
    }

    public void setDistance(double distance) {
    this.distance = distance;
    }

    public int getPage() {
    return page;
    }

    public void setPage(int page) {
    this.page = page;
    }

    public int getLimit() {
    return limit;
    }

    public void setLimit(int limit) {
    this.limit = limit;
    }

    public double getStep() {
    return step;
    }

    public void setStep(double step) {
    this.step = step;
    }

    public Long getSid() {
    return sid;
    }

    public void setSid(Long sid) {
    this.sid = sid;
    }
    }

CarDTO
package com.cloud.station.pojo.dto;

import com.fasterxml.jackson.annotation.JsonInclude;

/**

  • 车辆类
    */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    public class CarDTO {

    private String number;//车牌号码
    private Long startTime;//初始时间
    private Long endTime;//结束时间
    private Long stationId;//停车场ID

    public String getNumber() {
    return number;
    }

    public void setNumber(String number) {
    this.number = number;
    }

    public Long getStartTime() {
    return startTime;
    }

    public void setStartTime(Long startTime) {
    this.startTime = startTime;
    }

    public Long getEndTime() {
    return endTime;
    }

    public void setEndTime(Long endTime) {
    this.endTime = endTime;
    }

    public Long getStationId() {
    return stationId;
    }

    public void setStationId(Long stationId) {
    this.stationId = stationId;
    }
    }

MapAddressDTO
package com.cloud.station.pojo.dto;

import com.cloud.station.pojo.Address;

/**

  • 地图地址DTO
    */
    public class MapAddressDTO extends Address{

    //街道编号
    private String citycode;

    private String neighborhood;

    //街
    private String street;

    //道
    private String township;

    public String getCitycode() {
    return citycode;
    }

    public void setCitycode(String citycode) {
    this.citycode = citycode;
    }

    public String getNeighborhood() {
    return neighborhood;
    }

    public void setNeighborhood(String neighborhood) {
    this.neighborhood = neighborhood;
    }

    public String getStreet() {
    return street;
    }

    public void setStreet(String street) {
    this.street = street;
    }

    public String getTownship() {
    return township;
    }

    public void setTownship(String township) {
    this.township = township;
    }

    @Override
    public String toString() {
    return “MapAddressDTO{” +
    “citycode=’” + citycode + ‘’’ +
    “, neighborhood=’” + neighborhood + ‘’’ +
    “, street=’” + street + ‘’’ +
    “, township=’” + township + ‘’’ +
    ‘}’;
    }
    }

Position
package com.cloud.station.pojo.dto;

/**

  • 区域坐标(经纬度)
    */
    public class Position {

    /**

    • 中心点边界点的经纬度
      */
      private double leftTopLat;
      private double leftTopLng;

    private double rightTopLat;
    private double rightTopLng;

    private double leftBottomLat;
    private double leftBottomLng;

    private double rightBottomLat;
    private double rightBottomLng;

    //中心点经纬度
    private double centerLat;
    private double centerLng;

    public double getLeftTopLat() {
    return leftTopLat;
    }

    public void setLeftTopLat(double leftTopLat) {
    this.leftTopLat = leftTopLat;
    }

    public double getLeftTopLng() {
    return leftTopLng;
    }

    public void setLeftTopLng(double leftTopLng) {
    this.leftTopLng = leftTopLng;
    }

    public double getRightTopLat() {
    return rightTopLat;
    }

    public void setRightTopLat(double rightTopLat) {
    this.rightTopLat = rightTopLat;
    }

    public double getRightTopLng() {
    return rightTopLng;
    }

    public void setRightTopLng(double rightTopLng) {
    this.rightTopLng = rightTopLng;
    }

    public double getLeftBottomLat() {
    return leftBottomLat;
    }

    public void setLeftBottomLat(double leftBottomLat) {
    this.leftBottomLat = leftBottomLat;
    }

    public double getLeftBottomLng() {
    return leftBottomLng;
    }

    public void setLeftBottomLng(double leftBottomLng) {
    this.leftBottomLng = leftBottomLng;
    }

    public double getRightBottomLat() {
    return rightBottomLat;
    }

    public void setRightBottomLat(double rightBottomLat) {
    this.rightBottomLat = rightBottomLat;
    }

    public double getRightBottomLng() {
    return rightBottomLng;
    }

    public void setRightBottomLng(double rightBottomLng) {
    this.rightBottomLng = rightBottomLng;
    }

    public double getCenterLat() {
    return centerLat;
    }

    public void setCenterLat(double centerLat) {
    this.centerLat = centerLat;
    }

    public double getCenterLng() {
    return centerLng;
    }

    public void setCenterLng(double centerLng) {
    this.centerLng = centerLng;
    }

    @Override
    public String toString() {
    return “Position{” +
    “leftTopLat=” + leftTopLat +
    “, leftTopLng=” + leftTopLng +
    “, rightTopLng=” + rightTopLng +
    “, leftBottomLat=” + leftBottomLat +
    ‘}’;
    }
    }

StationStateDTO
package com.cloud.station.pojo.dto;

import com.cloud.station.pojo.DepotInfo;

public class StationStateDTO {

private Long stationId;//停车场ID

private Integer left;//车位剩余数量

private Long lastTime;//最近更新时间
public Long getStationId() {
    return stationId;
}

public void setStationId(Long stationId) {
    this.stationId = stationId;
}

public Integer getLeft() {
    return left;
}

public void setLeft(Integer left) {
    this.left = left;
}

public Long getLastTime() {
    return lastTime;
}

public void setLastTime(Long lastTime) {
    this.lastTime = lastTime;
}

}

StepFare
package com.cloud.station.pojo.dto;

/**

  • 梯步区间类

  • 整个区间费用=(t1-t0)moneyunit
    */
    public class StepFare {

    //时间t0
    private int t0;

    //时间t1
    private int t1;

    //价格
    private float money;

    //小时数
    private float unit;

    public int getT0() {
    return t0;
    }

    /**

    • 整个区间的费用
    • @return
      */
      public float calc(){
      return (this.t1-this.t0)this.moneythis.unit;
      }

    public void setT0(int t0) {
    this.t0 = t0;
    }

    public int getT1() {
    return t1;
    }

    public void setT1(int t1) {
    this.t1 = t1;
    }

    public float getMoney() {
    return money;
    }

    public void setMoney(float money) {
    this.money = money;
    }

    public float getUnit() {
    return unit;
    }

    public void setUnit(float unit) {
    this.unit = unit;
    }
    }

ex
FriendEx
package com.cloud.station.pojo.ex;

import com.cloud.station.pojo.UserInfo;

public class FriendEx extends UserInfo{

//关系 默认是陌生人
private Integer relative;

//好友添加时间
private Long addTime;

public Integer getRelative() {
    return relative;
}

public void setRelative(Integer relative) {
    this.relative = relative;
}

public Long getAddTime() {
    return addTime;
}

public void setAddTime(Long addTime) {
    this.addTime = addTime;
}

}

StationOrderUser
package com.cloud.station.pojo.ex;

import com.cloud.station.pojo.UserInfo;
import com.fasterxml.jackson.annotation.JsonInclude;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class StationOrderUser extends UserInfo{

//订单创建时间
private Long orderCreateTime;

//订单提价时间
private Long orderEndTime;

//订单的状态
private Integer orderState;

}

UserBlackListEx
package com.cloud.station.pojo.ex;

import com.cloud.station.pojo.CarNumberBlacklist;
import com.cloud.station.pojo.UserInfo;

public class UserBlackListEx extends CarNumberBlacklist {

private UserInfo userInfo;

public UserInfo getUserInfo() {
    return userInfo;
}

public void setUserInfo(UserInfo userInfo) {
    this.userInfo = userInfo;
}

}

Address
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

//地址信息类
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Address implements Serializable{
//主键
private Long id;

//省
private String provice;

//市
private String city;

//县
private String country;

//村
private String village;

//描述
private String desc;

//创建时间
private Long createTime;

//停车场管理员ID
private Long adminDepotId;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getProvice() {
return provice;
}
public void setProvice(String provice) {
this.provice = provice;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getVillage() {
return village;
}
public void setVillage(String village) {
this.village = village;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Long getAdminDepotId() {
return adminDepotId;
}
public void setAdminDepotId(Long adminDepotId) {
this.adminDepotId = adminDepotId;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}

@Override
public String toString() {
return “Address{” +
“id=” + id +
“, provice=’” + provice + ‘’’ +
“, city=’” + city + ‘’’ +
“, country=’” + country + ‘’’ +
“, village=’” + village + ‘’’ +
“, desc=’” + desc + ‘’’ +
“, createTime=” + createTime +
“, adminDepotId=” + adminDepotId +
‘}’;
}
}

AdminInfo
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

//系统管理员类
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AdminInfo {
//主键
private Long id;

//管理员帐号
private String account;

//密码,加密处理
private String pwd;

//创建时间
private Long createTime;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}

}

Application
package com.cloud.station.pojo;

/**

  • 应用实体
    */
    public class Application {

    //主键
    private Long id;

    //应用名称
    private String name;

    //应用描述
    private String desc;

    //应用ID号
    private String appKey;

    //应用密钥
    private String appSecrte;

    //停车场管理员ID
    private String adminId;

    public Long getId() {
    return id;
    }

    public void setId(Long id) {
    this.id = id;
    }

    public String getName() {
    return name;
    }

    public void setName(String name) {
    this.name = name;
    }

    public String getDesc() {
    return desc;
    }

    public void setDesc(String desc) {
    this.desc = desc;
    }

    public String getAppKey() {
    return appKey;
    }

    public void setAppKey(String appKey) {
    this.appKey = appKey;
    }

    public String getAppSecrte() {
    return appSecrte;
    }

    public void setAppSecrte(String appSecrte) {
    this.appSecrte = appSecrte;
    }

    public String getAdminId() {
    return adminId;
    }

    public void setAdminId(String adminId) {
    this.adminId = adminId;
    }
    }

CarInfo
package com.cloud.station.pojo;

/**

  • 车牌实体
    */
    public class CarInfo {

    //ID
    private Long id;

    //车牌
    private String carNumber;

    //当前使用者ID(0:车主)
    private Long currentUsed;

    //车主ID
    private Long userId;

    //车牌类别
    private String carNumberType;

    //车辆牌照
    private String photo;

    //车辆品牌
    private String carType;

    //车辆型号
    private String carXH;

    //车辆年份
    private Integer carYear;

    //车身颜色
    private String carColor;

    //识别号码
    private String code;

    public Long getId() {
    return id;
    }

    public void setId(Long id) {
    this.id = id;
    }

    public String getCarNumber() {
    return carNumber;
    }

    public void setCarNumber(String carNumber) {
    this.carNumber = carNumber;
    }

    public Long getCurrentUsed() {
    return currentUsed;
    }

    public void setCurrentUsed(Long currentUsed) {
    this.currentUsed = currentUsed;
    }

    public Long getUserId() {
    return userId;
    }

    public void setUserId(Long userId) {
    this.userId = userId;
    }

    public String getCarNumberType() {
    return carNumberType;
    }

    public void setCarNumberType(String carNumberType) {
    this.carNumberType = carNumberType;
    }

    public String getPhoto() {
    return photo;
    }

    public void setPhoto(String photo) {
    this.photo = photo;
    }

    public String getCarType() {
    return carType;
    }

    public void setCarType(String carType) {
    this.carType = carType;
    }

    public String getCarXH() {
    return carXH;
    }

    public void setCarXH(String carXH) {
    this.carXH = carXH;
    }

    public Integer getCarYear() {
    return carYear;
    }

    public void setCarYear(Integer carYear) {
    this.carYear = carYear;
    }

    public String getCarColor() {
    return carColor;
    }

    public void setCarColor(String carColor) {
    this.carColor = carColor;
    }

    public String getCode() {
    return code;
    }

    public void setCode(String code) {
    this.code = code;
    }

    @Override
    public String toString() {
    return “CarInfo{” +
    “id=” + id +
    “, carNumber=’” + carNumber + ‘’’ +
    “, currentUsed=” + currentUsed +
    “, userId=” + userId +
    “, carNumberType=’” + carNumberType + ‘’’ +
    “, photo=’” + photo + ‘’’ +
    “, carType=’” + carType + ‘’’ +
    “, carXH=’” + carXH + ‘’’ +
    “, carYear=” + carYear +
    “, carColor=’” + carColor + ‘’’ +
    “, code=’” + code + ‘’’ +
    ‘}’;
    }
    }

CarNumberBlacklist
package com.cloud.station.pojo;

import java.util.Date;

/*
*用户黑名单类
*/
public class CarNumberBlacklist {
//自增主键
private Long id;
//车牌号
private String carNum;
//使用用户的id
private Long userId;
//欠费金额
private float oweAmount=0.0f;
//欠费时间(创建时间)
private Long oweTime=new Date().getTime();
//处理时间(最近一次)
private Long disposeTime=0L;
//欠费次数
private Long oweMoneyTime=0L;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCarNum() {
return carNum;
}
public void setCarNum(String carNum) {
this.carNum = carNum;
}

public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}

public float getOweAmount() {
return oweAmount;
}
public void setOweAmount(float oweAmount) {
this.oweAmount = oweAmount;
}
public Long getOweTime() {
return oweTime;
}
public void setOweTime(Long oweTime) {
this.oweTime = oweTime;
}
public Long getDisposeTime() {
return disposeTime;
}
public void setDisposeTime(Long disposeTime) {
this.disposeTime = disposeTime;
}
public Long getOweMoneyTime() {
return oweMoneyTime;
}
public void setOweMoneyTime(Long oweMoneyTime) {
this.oweMoneyTime = oweMoneyTime;
}

}

CarNumberUsed
package com.cloud.station.pojo;

/**

  • 用户绑定车牌实体
    */
    public class CarNumberUsed {

    //ID
    private Long id;

    //车牌ID
    private Long carNumberId;

    private Long userId;

    //创建时间
    private Long createTime;

    public Long getUserId() {
    return userId;
    }

    public void setUserId(Long userId) {
    this.userId = userId;
    }

    public Long getId() {
    return id;
    }

    public void setId(Long id) {
    this.id = id;
    }

    public Long getCarNumberId() {
    return carNumberId;
    }

    public void setCarNumberId(Long carNumberId) {
    this.carNumberId = carNumberId;
    }

    public Long getCreateTime() {
    return createTime;
    }

    public void setCreateTime(Long createTime) {
    this.createTime = createTime;
    }
    }

CarNumberUsing
package com.cloud.station.pojo;

/**

  • 用户使用车牌实体
    */
    public class CarNumberUsing {

    //ID
    private Long id;

    //车牌ID
    private Long carNumberId;

    //使用开始时间
    private Long starTime;

    //使用结束时间
    private Long endTime;

    //使用人
    private Long userId;

    //使用状态(1:正在使用,-1:过期,2:使用完成)
    private Integer state;

    public Long getId() {
    return id;
    }

    public void setId(Long id) {
    this.id = id;
    }

    public Long getCarNumberId() {
    return carNumberId;
    }

    public void setCarNumberId(Long carNumberId) {
    this.carNumberId = carNumberId;
    }

    public Long getStarTime() {
    return starTime;
    }

    public void setStarTime(Long starTime) {
    this.starTime = starTime;
    }

    public Long getEndTime() {
    return endTime;
    }

    public void setEndTime(Long endTime) {
    this.endTime = endTime;
    }

    public Long getUserId() {
    return userId;
    }

    public void setUserId(Long userId) {
    this.userId = userId;
    }

    public Integer getState() {
    return state;
    }

    public void setState(Integer state) {
    this.state = state;
    }
    }

DepotAdminInfo
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

//停车场管理员类
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DepotAdminInfo {
//主键
private Long id;

//停车场管理员帐号
private String account;

//密码,加密处理
private String pwd;

//创建时间
private Long createTime;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}

}

DepotFareStandard
package com.cloud.station.pojo;

/**

  • 计费规则
    */
    public class DepotFareStandard {

    //ID
    private Long id;

    //停车场ID
    private Long depotId;

    //免费结束时间(单位小时)
    private Float freeEndTime;

    //freeEndTime内收费 >0有效
    private Float freeTimeMoney;

    //梯步价格 JSON字符串
    private String fareStep;

    //梯步价最大值(超过这个时间的收费标准)(单位小时)
    private Float stepEndTime;

    //车型号(与收费标准有关例如:小型车 大型车)
    private String carType;

    //添加时间
    private Long createTime;

    //收费单元(小时数,1:每一小时,0.5:每半小时) 默认0.5小时
    private Float fareUnit;

    //折扣
    private Float discount;

    //优惠金额
    private Float discountMoney;

    //最多收费
    private Float maxMoney;

    //超过梯步价格后的收费标准
    private Float stepOutFare;

    //不超过时间(配合max_money来说)(小时)
    private Float maxTime;

    public Long getId() {
    return id;
    }

    public void setId(Long id) {
    this.id = id;
    }

    public Long getDepotId() {
    return depotId;
    }

    public Float getFreeTimeMoney() {
    return freeTimeMoney;
    }

    public Float getStepOutFare() {
    return stepOutFare;
    }

    public void setStepOutFare(Float stepOutFare) {
    this.stepOutFare = stepOutFare;
    }

    public void setFreeTimeMoney(Float freeTimeMoney) {
    this.freeTimeMoney = freeTimeMoney;
    }

    public void setDepotId(Long depotId) {
    this.depotId = depotId;
    }

    public Float getFreeEndTime() {
    return freeEndTime;
    }

    public void setFreeEndTime(Float freeEndTime) {
    this.freeEndTime = freeEndTime;
    }

    public String getFareStep() {
    return fareStep;
    }

    public void setFareStep(String fareStep) {
    this.fareStep = fareStep;
    }

    public Float getStepEndTime() {
    return stepEndTime;
    }

    public void setStepEndTime(Float stepEndTime) {
    this.stepEndTime = stepEndTime;
    }

    public String getCarType() {
    return carType;
    }

    public void setCarType(String carType) {
    this.carType = carType;
    }

    public Long getCreateTime() {
    return createTime;
    }

    public void setCreateTime(Long createTime) {
    this.createTime = createTime;
    }

    public Float getFareUnit() {
    return fareUnit;
    }

    public void setFareUnit(Float fareUnit) {
    this.fareUnit = fareUnit;
    }

    public Float getDiscount() {
    return discount;
    }

    public void setDiscount(Float discount) {
    this.discount = discount;
    }

    public Float getDiscountMoney() {
    return discountMoney;
    }

    public void setDiscountMoney(Float discountMoney) {
    this.discountMoney = discountMoney;
    }

    public Float getMaxMoney() {
    return maxMoney;
    }

    public void setMaxMoney(Float maxMoney) {
    this.maxMoney = maxMoney;
    }

    public Float getMaxTime() {
    return maxTime;
    }

    public void setMaxTime(Float maxTime) {
    this.maxTime = maxTime;
    }
    }

DepotInfo
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

//停车场信息类
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DepotInfo {
//主键
private Long id;

//停车场名称
private String name;

//停车场地址外键ID号
private Long addressId;

//信息创建者ID号
private Long userId;

//创建时间,时间戳形式
private Long createTime;

//描述信息
private String desc;

//车位总数
private int stationNum;

private String address;

//纬度
private Double latitude;

//经度
private Double longitude;

private DepotStationState depotStationState;

private String photo;//照片

private Double distance;//与中心点的直线距离

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getAddressId() {
return addressId;
}
public void setAddressId(Long addressId) {
this.addressId = addressId;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public int getStationNum() {
return stationNum;
}
public void setStationNum(int stationNum) {
this.stationNum = stationNum;
}

public String getAddress() {
return address;
}

public void setAddress(String address) {
this.address = address;
}

public Double getLatitude() {
return latitude;
}

public void setLatitude(Double latitude) {
this.latitude = latitude;
}

public Double getLongitude() {
return longitude;
}

public void setLongitude(Double longitude) {
this.longitude = longitude;
}

public DepotStationState getDepotStationState() {
return depotStationState;
}

public void setDepotStationState(DepotStationState depotStationState) {
this.depotStationState = depotStationState;
}

public String getPhoto() {
return photo;
}

public void setPhoto(String photo) {
this.photo = photo;
}

public Double getDistance() {
return distance;
}

public void setDistance(Double distance) {
this.distance = distance;
}

@Override
public String toString() {
return “DepotInfo{” +
“id=” + id +
“, name=’” + name + ‘’’ +
“, addressId=” + addressId +
“, userId=” + userId +
“, createTime=” + createTime +
“, desc=’” + desc + ‘’’ +
“, stationNum=” + stationNum +
“, address=’” + address + ‘’’ +
“, latitude=” + latitude +
“, longitude=” + longitude +
“, depotStationState=” + depotStationState +
“, photo=’” + photo + ‘’’ +
‘}’;
}
}

DepotState
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

//停车场状态信息类
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DepotState {

//主键
private Long id;

//已占车位数
private int occupy;

//停车场id
private Long depotId;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public int getOccupy() {
return occupy;
}

public void setOccupy(int occupy) {
this.occupy = occupy;
}

public Long getDepotId() {
return depotId;
}

public void setDepotId(Long depotId) {
this.depotId = depotId;
}

}

DepotStation
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

//车位信息表
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DepotStation {
//主键
private Long id;

//车位编号
private String code;

//车位位置
private String loc;

//车位描述
private String desc;

//创建时间
private Long createTime;

//所属停车场ID
private Long depotId;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getLoc() {
return loc;
}
public void setLoc(String loc) {
this.loc = loc;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public Long getDepotId() {
return depotId;
}
public void setDepotId(Long depotId) {
this.depotId = depotId;
}

}

DepotStationState
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

//车位状态信息类
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DepotStationState implements Serializable {
//主键
private Long id;

//停车场ID号
private Long stationId;

//状态,0为空闲,1为占用,2为VIP车位,3暂停使
private int state;

//占用开始时间
private Long startTime;

//占用释放时间
private Long endTime;

//用户ID
private Long userId;

private int left;//剩余数量

private String carNumber;//车牌号码

private DepotInfo depotInfo;//停车场信息

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Long getStationId() {
return stationId;
}

public void setStationId(Long stationId) {
this.stationId = stationId;
}

public int getState() {
return state;
}

public void setState(int state) {
this.state = state;
}

public Long getStartTime() {
return startTime;
}

public void setStartTime(Long startTime) {
this.startTime = startTime;
}

public Long getEndTime() {
return endTime;
}

public void setEndTime(Long endTime) {
this.endTime = endTime;
}

public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}

public int getLeft() {
return left;
}

public void setLeft(int left) {
this.left = left;
}

public DepotInfo getDepotInfo() {
return depotInfo;
}

public void setDepotInfo(DepotInfo depotInfo) {
this.depotInfo = depotInfo;
}

public String getCarNumber() {
return carNumber;
}

public void setCarNumber(String carNumber) {
this.carNumber = carNumber;
}

@Override
public String toString() {
return “DepotStationState{” +
“id=” + id +
“, stationId=” + stationId +
“, state=” + state +
“, startTime=” + startTime +
“, endTime=” + endTime +
“, userId=” + userId +
“, left=” + left +
“, carNumber=’” + carNumber + ‘’’ +
“, depotInfo=” + depotInfo +
‘}’;
}
}

FareRule
package com.cloud.station.pojo;

/**

  • 计费规则类
    */
    public class FareRule {

    //ID
    private Long id;

    //停车场ID
    private Long stationId;

    //创建时间
    private Long createTime;

    //计费规则
    private String rule;

    //模式
    private Integer mode;

    //描述
    private String desc;

    //是否被使用 0:No 1:Yes
    private Integer used;

    //创建者ID
    private Long userId;

    //规则名称
    private String title;

    public Long getId() {
    return id;
    }

    public void setId(Long id) {
    this.id = id;
    }

    public Long getStationId() {
    return stationId;
    }

    public void setStationId(Long stationId) {
    this.stationId = stationId;
    }

    public Long getCreateTime() {
    return createTime;
    }

    public void setCreateTime(Long createTime) {
    this.createTime = createTime;
    }

    public String getRule() {
    return rule;
    }

    public void setRule(String rule) {
    this.rule = rule;
    }

    public Integer getMode() {
    return mode;
    }

    public void setMode(Integer mode) {
    this.mode = mode;
    }

    public String getDesc() {
    return desc;
    }

    public void setDesc(String desc) {
    this.desc = desc;
    }

    public String getTitle() {
    return title;
    }

    public void setTitle(String title) {
    this.title = title;
    }

    public Integer getUsed() {
    return used;
    }

    public void setUsed(Integer used) {
    this.used = used;
    }

    public Long getUserId() {
    return userId;
    }

    public void setUserId(Long userId) {
    this.userId = userId;
    }

    @Override
    public String toString() {
    return “FareRule{” +
    “id=” + id +
    “, stationId=” + stationId +
    “, createTime=” + createTime +
    “, rule=’” + rule + ‘’’ +
    “, mode=” + mode +
    “, desc=’” + desc + ‘’’ +
    “, used=” + used +
    “, userId=” + userId +
    “, title=’” + title + ‘’’ +
    ‘}’;
    }
    }

Friend
package com.cloud.station.pojo;

/**

  • 好友类
    */
    public class Friend {

    //好友关系常量
    public static Integer GOOD_FRIEND = 0;//好朋友
    public static Integer STRANGER = 1;//陌生人
    public static Integer BLACK_LIST = 2;//被拉黑
    public static Integer FAMILY = 3;//家人
    public static Integer WORKERS = 4;//同事

    //ID
    private Long id;

    //我的ID
    private Long myId;

    //好友ID
    private Long frendId;

    //关系 默认是陌生人
    private Integer relative;

    //添加时间
    private Long createTime;

    public Long getId() {
    return id;
    }

    public void setId(Long id) {
    this.id = id;
    }

    public Long getMyId() {
    return myId;
    }

    public void setMyId(Long myId) {
    this.myId = myId;
    }

    public Long getFrendId() {
    return frendId;
    }

    public void setFrendId(Long frendId) {
    this.frendId = frendId;
    }

    public Long getCreateTime() {
    return createTime;
    }

    public void setCreateTime(Long createTime) {
    this.createTime = createTime;
    }

    public Integer getRelative() {
    return relative;
    }

    public void setRelative(Integer relative) {
    this.relative = relative;
    }
    }

LogStation
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

//车位占用记录类
@JsonInclude(JsonInclude.Include.NON_NULL)
public class LogStation {
//主键
private Long id;

//车位编号
private Long stationCode;

//停车场名称
private Long depoteName;

//用户id
private Long userId;

//创建时间
private Long createTime;

public Long getId() {
return id;
}

public void setId(Long id) {
this.id = id;
}

public Long getStationCode() {
return stationCode;
}

public void setStationCode(Long stationCode) {
this.stationCode = stationCode;
}

public Long getDepoteName() {
return depoteName;
}

public void setDepoteName(Long depoteName) {
this.depoteName = depoteName;
}

public Long getUserId() {
return userId;
}

public void setUserId(Long userId) {
this.userId = userId;
}

public Long getCreateTime() {
return createTime;
}

public void setCreateTime(Long createTime) {
this.createTime = createTime;
}

}

StationOrder
package com.cloud.station.pojo;

/**

  • 停车场使用记录以及预约实体
    */
    public class StationOrder {
    public static Integer NORMAL = 1;//正常完成
    public static Integer USER_CANCEL=2;//用户取消
    public static Integer UNDO = 3;//未处理
    public static Integer UNDO_MONEY = 4;//欠费

    //ID
    private Long id;

    //停车场ID
    private Long stationId;

    //用户ID
    private Long userId;

    //创建时间
    private Long createTime;

    //订单提交时间
    private Long endTime;

    //状态
    private Integer state;

    //车牌
    private String carNum;

    public Long getId() {
    return id;
    }

    public void setId(Long id) {
    this.id = id;
    }

    public Long getStationId() {
    return stationId;
    }

    public void setStationId(Long stationId) {
    this.stationId = stationId;
    }

    public Long getUserId() {
    return userId;
    }

    public void setUserId(Long userId) {
    this.userId = userId;
    }

    public Long getCreateTime() {
    return createTime;
    }

    public void setCreateTime(Long createTime) {
    this.createTime = createTime;
    }

    public Integer getState() {
    return state;
    }

    public void setState(Integer state) {
    this.state = state;
    }

    public Long getEndTime() {
    return endTime;
    }

    public void setEndTime(Long endTime) {
    this.endTime = endTime;
    }

    public String getCarNum() {
    return carNum;
    }

    public void setCarNum(String carNum) {
    this.carNum = carNum;
    }
    }

UserInfo
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

//用户信息实体
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UserInfo {

//主键
private Long id;

//账号
private String account;

//手机号
private String tel;

//注册时间,以时间戳的形式保存
private Long createTime;

//账号余额,保留2位小数
private float money;

//头像,图片路径
private String face;

//等级积分,跟消费积分是分开的
private float rankPoints;

//身份证号码
private String idCard;

//信誉度,保留一位小数
private float reputationPoints;

//密码,加密处理
private String pwd;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
public Long getCreateTime() {
return createTime;
}
public void setCreateTime(Long createTime) {
this.createTime = createTime;
}
public float getMoney() {
return money;
}
public void setMoney(float money) {
this.money = money;
}
public String getFace() {
return face;
}
public void setFace(String face) {
this.face = face;
}
public float getRankPoints() {
return rankPoints;
}
public void setRankPoints(float rankPoints) {
this.rankPoints = rankPoints;
}
public String getIdCard() {
return idCard;
}
public void setIdCard(String idCard) {
this.idCard = idCard;
}
public float getReputationPoints() {
return reputationPoints;
}
public void setReputationPoints(float reputationPoints) {
this.reputationPoints = reputationPoints;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}

@Override
public String toString() {
return “UserInfo{” +
“id=” + id +
“, account=’” + account + ‘’’ +
“, tel=’” + tel + ‘’’ +
“, createTime=” + createTime +
“, money=” + money +
“, face=’” + face + ‘’’ +
“, rankPoints=” + rankPoints +
“, idCard=’” + idCard + ‘’’ +
“, reputationPoints=” + reputationPoints +
“, pwd=’” + pwd + ‘’’ +
‘}’;
}
}

UserUrgentContact
package com.cloud.station.pojo;

import com.fasterxml.jackson.annotation.JsonInclude;

//紧急联系人类
@JsonInclude(JsonInclude.Include.NON_NULL)
public class UserUrgentContact {
//主键
private Long id;

//联系人姓名
private Long realName;

//联系人电话
private Long contactTel;

//可用状态,0为不可用,1为可用
private Long telStatus;

//权值:用于排序,权值降序排列
private Long weight;

//描述
private Long desc;

//创建者id
private Long userId;

public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getRealName() {
return realName;
}
public void setRealName(Long realName) {
this.realName = realName;
}
public Long getContactTel() {
return contactTel;
}
public void setContactTel(Long contactTel) {
this.contactTel = contactTel;
}
public Long getTelStatus() {
return telStatus;
}
public void setTelStatus(Long telStatus) {
this.telStatus = telStatus;
}
public Long getWeight() {
return weight;
}
public void setWeight(Long weight) {
this.weight = weight;
}
public Long getDesc() {
return desc;
}
public void setDesc(Long desc) {
this.desc = desc;
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}

}

Fare收费规则模块
Api
Impl
DayFare
package com.cloud.station.fare.api.impl;

import com.cloud.station.fare.entity.BaseCharge;
import com.cloud.station.fare.entity.DayCharge;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class DayFare {

/**
 * @param list
 * @param baseCharge
 * @param startTime 开始时间
 * @param endTime 结束时间
 * @return
 */
public float calc(List list, BaseCharge baseCharge, float startTime,float endTime){
    float money = 0;
    //排序 安装区间排列
    Collections.sort(list, new Comparator() {
        @Override
        public int compare(DayCharge o1, DayCharge o2) {
            if(o1.getT0()o2.getT0())
                return 1;
            else
                return 0;
        }
    });
    boolean flag = false;//是否找到匹配的区间
    for(DayCharge dc:list){
        if(startTime>=dc.getT0()&& startTimedc.getTn()){
                money+=(dc.getTn()-dc.getT0())*dc.getUnit()*dc.getPrice();
            }else{
                money+=(endTime-dc.getT0())*dc.getUnit()*dc.getPrice();
                break;
            }
        }
    }

    //优惠
    if(baseCharge!=null){
        //折扣
        if(baseCharge.getDiscount()!=null){
            if(baseCharge.getDiscount()>0 && baseCharge.getDiscount()<=1)
                if((endTime-startTime)>=baseCharge.getDistime())money=money*baseCharge.getDiscount();
        }

        if(baseCharge.getDismoney()!=null){
            if((endTime-startTime)>=baseCharge.getDistime())money-=baseCharge.getDismoney();
        }
    }
    return money<=0?0:money;
}

}

FrontN
package com.cloud.station.fare.api.impl;

import com.cloud.station.fare.entity.FNCharg;

public class FrontN {

public float calc(FNCharg chargFN, float time){
    float money = 0;
    if(time>chargFN.getTn()){
        money = (chargFN.getTn()-chargFN.getT0())*chargFN.getUnit()*chargFN.getPrice();
    }else{
        money = (time-chargFN.getT0())*chargFN.getUnit()*chargFN.getPrice();
    }

    //计算折扣
    if(chargFN.getDiscount()!=null){
        if(chargFN.getDiscount()>0 && chargFN.getDiscount()<=1)
            if(chargFN.getDistime()!=null && time>=chargFN.getDistime()){//达到折扣时间
                money=money*chargFN.getDiscount();
            }
    }

    //计算优惠
    if(chargFN.getDismoney()!=null){
        if(chargFN.getDismoney()>0){
            if(chargFN.getDistime()!=null && time>=chargFN.getDistime()){
                money-=chargFN.getDismoney();
            }
        }
    }
    return money;
}

}

NormalFare
package com.cloud.station.fare.api.impl;

import com.cloud.station.fare.entity.Normal;

/**

  • 正常计费
    */
    public class NormalFare {

    public float calc(Normal normal, float time){
    float money = 0;
    if(time>normal.getT0()){
    money = (time-normal.getT0())*normal.getUnit()*normal.getPrice();
    }

     //优惠
     if(normal.getDiscount()!=null){
         if(time>normal.getDistime()){
             if(normal.getDiscount()>0 && normal.getDiscount()<=1)
                 money=money*normal.getDiscount();
         }
     }
    
     if(normal.getDismoney()!=null){
         if(time>normal.getDistime())
             money-=normal.getDismoney();
     }
    
     return money<=0?0:money;
    

    }
    }

StepChargeFare
package com.cloud.station.fare.api.impl;

import com.cloud.station.fare.entity.BaseCharge;
import com.cloud.station.fare.entity.StepCharge;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class StepChargeFare {

public float calc(List list, BaseCharge baseCharge, float time, Float max_money){
    float money = 0;

    //排序 安装区间排列
    Collections.sort(list, new Comparator() {
        @Override
        public int compare(StepCharge o1, StepCharge o2) {
            if(o1.getT0()=sc.getTn()){
            money+=(sc.getTn()-sc.getT0())*sc.getUnit()*sc.getPrice();
        }else{
            money+=(time-sc.getT0())*sc.getUnit()*sc.getPrice();
            break;
        }

    }


    if(baseCharge!=null){
        //打折
        if(baseCharge.getDiscount()!=null){
            if(baseCharge.getDiscount()>0 && baseCharge.getDiscount()<=1){
                if(baseCharge.getDistime()!=null){
                    if(time>baseCharge.getDistime())money=money*baseCharge.getDiscount();
                }
            }
        }

        //优惠元数
        if(baseCharge.getDismoney()!=null){
            if(baseCharge.getDismoney()>0){
                if(time>baseCharge.getDistime())money-=baseCharge.getDismoney();
            }
        }
    }

    //如果存在最大收费
    if(max_money!=null){
        if(money>=max_money)money=max_money;
    }

    return money<=0?0:money;
}

}

ChargeApi
package com.cloud.station.fare.api;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cloud.station.fare.api.impl.DayFare;
import com.cloud.station.fare.api.impl.FrontN;
import com.cloud.station.fare.api.impl.NormalFare;
import com.cloud.station.fare.api.impl.StepChargeFare;
import com.cloud.station.fare.entity.*;
import com.cloud.station.fare.entity.dto.DayChargeDTO;
import com.cloud.station.fare.entity.dto.StepChargeDTO;
import com.fasterxml.jackson.databind.ser.Serializers;

import java.util.List;

public class ChargeApi {

public static Integer MODE_BY_DAY = 0;//按天按小时收费
public static Integer MODE_BY_NORMAL = 1;//正常计费  y/th   每t小时y元
public static Integer MODE_BY_STEP = 2;//梯步价格计费

private Rule rule;

private FNCharg fnCharg;
private Normal normal;
private DayChargeDTO dayChargeDTO;
private StepChargeDTO stepChargeDTO;
private BaseCharge baseCharge;

public ChargeApi(Rule rule) {
    this.rule = rule;
    this.parseRule();
}

public float calc(){
    float money = 0;
    if(rule.getMode()==MODE_BY_DAY){
        money = fareByDay();
    }else if(rule.getMode()==MODE_BY_STEP){
        money = fareByStep();
    }

    //TODO 这里应采用银行进位法
    String moneyStr = String.format("%.2f",money);

    return money<=0?0:Float.valueOf(moneyStr);
}

private float fareByStep(){
    float money = 0;
    //前n小时计费
    money+=(new FrontN()).calc(stepChargeDTO.getFnCharg(), rule.getTotalTime());
    //梯步价格
    money+=(new StepChargeFare()).calc(stepChargeDTO.getStepChargeList(),stepChargeDTO.getBaseCharge(),rule.getTotalTime(),stepChargeDTO.getMax_money());

    //超过梯步价格收费
    money+=(new NormalFare()).calc(stepChargeDTO.getNormal(),rule.getTotalTime());

    return money;
}

//正常计费  0-n
private float fareByNormal(){
    Normal normal = JSONArray.parseObject(rule.getRule(),Normal.class);
    normal.setT0(0);
    return (new NormalFare()).calc(normal,rule.getTotalTime());
}

//按天按小时收费
private float fareByDay(){

    if(dayChargeDTO!=null && dayChargeDTO.getDayChargeList()!=null)
        return (new DayFare()).calc(dayChargeDTO.getDayChargeList(),
                dayChargeDTO.getBaseCharge(),rule.getStartTime(),rule.getEndTime());
    return 0;
}

/**
 * 解析规则
 */
private void parseRule(){
    if(rule.getMode()==MODE_BY_DAY){
        try{
            dayChargeDTO = JSONArray.parseObject(rule.getRule(),DayChargeDTO.class);

        }catch (Exception e){
            e.printStackTrace();
            dayChargeDTO = null;
        }
    }

    if(rule.getMode()==MODE_BY_STEP){
        try{

            stepChargeDTO = JSONArray.parseObject(rule.getRule(),StepChargeDTO.class);
        }catch (Exception e){
            stepChargeDTO = null;
        }
    }

    if(rule.getMode()==MODE_BY_NORMAL){
        try{
            normal = JSONArray.parseObject(rule.getRule(),Normal.class);
        }catch (Exception e){
            normal = null;
        }
    }
}

}

entity
Dto
DayChargeDTO
package com.cloud.station.fare.entity.dto;

import com.cloud.station.fare.entity.BaseCharge;
import com.cloud.station.fare.entity.DayCharge;

import java.util.List;

public class DayChargeDTO {

private List dayChargeList;

private BaseCharge baseCharge;

private float startTime;//开始时间
private float endTime;//结束时间

public List getDayChargeList() {
    return dayChargeList;
}

public void setDayChargeList(List dayChargeList) {
    this.dayChargeList = dayChargeList;
}

public BaseCharge getBaseCharge() {
    return baseCharge;
}

public void setBaseCharge(BaseCharge baseCharge) {
    this.baseCharge = baseCharge;
}

@Override
public String toString() {
    return "DayChargeDTO{" +
            "dayChargeList=" + dayChargeList +
            ", baseCharge=" + baseCharge +
            '}';
}

}

StepChargeDTO
package com.cloud.station.fare.entity.dto;

import com.cloud.station.fare.entity.BaseCharge;
import com.cloud.station.fare.entity.FNCharg;
import com.cloud.station.fare.entity.Normal;
import com.cloud.station.fare.entity.StepCharge;

import java.util.List;

public class StepChargeDTO {
private BaseCharge baseCharge;
private List stepChargeList;
private Normal normal;
private FNCharg fnCharg;
private Float max_money;//最多收费

public BaseCharge getBaseCharge() {
    return baseCharge;
}

public void setBaseCharge(BaseCharge baseCharge) {
    this.baseCharge = baseCharge;
}

public List getStepChargeList() {
    return stepChargeList;
}

public void setStepChargeList(List stepChargeList) {
    this.stepChargeList = stepChargeList;
}

public Normal getNormal() {
    return normal;
}

public void setNormal(Normal normal) {
    this.normal = normal;
}

public FNCharg getFnCharg() {
    return fnCharg;
}

public void setFnCharg(FNCharg fnCharg) {
    this.fnCharg = fnCharg;
}

public Float getMax_money() {
    return max_money;
}

public void setMax_money(Float max_money) {
    this.max_money = max_money;
}

}

BaseCharge
package com.cloud.station.fare.entity;

import java.io.Serializable;

public class BaseCharge implements Serializable{

private Float discount;//折扣

private Float dismoney;//减价多少

private Float distime;//减价最小时间 配合dismoney|discount使用

private float unit;//收费单元 (n小时收费,例如0.5)

public Float getDiscount() {
    return discount;
}

public void setDiscount(Float discount) {
    this.discount = discount;
}

public float getUnit() {
    return unit;
}

public void setUnit(float unit) {
    this.unit = unit;
}

public Float getDismoney() {
    return dismoney;
}

public void setDismoney(Float dismoney) {
    this.dismoney = dismoney;
}

public Float getDistime() {
    return distime;
}

public void setDistime(Float distime) {
    this.distime = distime;
}

@Override
public String toString() {
    return "BaseCharg{" +
            "discount=" + discount +
            ", unit=" + unit +
            '}';
}

}

DayCharge
package com.cloud.station.fare.entity;

/**

  • 一天的费用

  • 0-24小时之间
    */
    public class DayCharge extends BaseCharge{
    private float t0;//小时数
    private float tn;//小时数

    private float price;

    public float getT0() {
    return t0;
    }

    public void setT0(float t0) {
    this.t0 = t0;
    }

    public float getTn() {
    return tn;
    }

    public void setTn(float tn) {
    this.tn = tn;
    }

    public float getPrice() {
    return price;
    }

    public void setPrice(float price) {
    this.price = price;
    }
    }

FNCharg
package com.cloud.station.fare.entity;

/**

  • 前n小时收费问题

  • t0-tn
    */
    public class FNCharg extends BaseCharge {
    private Float t0;//收费起点
    private Float tn;//收费终点

    private float price;//单价

    public Float getT0() {
    return t0;
    }

    public void setT0(Float t0) {
    this.t0 = t0;
    }

    public void setTn(Float tn) {
    this.tn = tn;
    }

    public Float getTn() {
    return tn;
    }

    public float getPrice() {
    return price;
    }

    public void setPrice(float price) {
    this.price = price;
    }

    @Override
    public String toString() {
    return “ChargFN{” +
    “t0=” + t0 +
    “, tn=” + tn +
    “, price=” + price +
    ‘}’;
    }
    }

Normal
package com.cloud.station.fare.entity;

/**

  • 正常计费,或者超过梯步价计费
    */
    public class Normal extends BaseCharge{
    private float price;//费用
    private float t0;//开始时刻点

    public float getPrice() {
    return price;
    }

    public void setPrice(float price) {
    this.price = price;
    }

    public float getT0() {
    return t0;
    }

    public void setT0(float t0) {
    this.t0 = t0;
    }
    }

Rule
package com.cloud.station.fare.entity;

/**

  • 规则信息
    */
    public class Rule {

    private String rule;

    private Integer mode;//模式
    private int totalTime;//总时间

    private float startTime;//开始时间
    private float endTime;//结束时间

    private float max_money;//最多收费

    public String getRule() {
    return rule;
    }

    public void setRule(String rule) {
    this.rule = rule;
    }

    public float getMax_money() {
    return max_money;
    }

    public void setMax_money(float max_money) {
    this.max_money = max_money;
    }

    public Integer getMode() {
    return mode;
    }

    public void setMode(Integer mode) {
    this.mode = mode;
    }

    public int getTotalTime() {
    return totalTime;
    }

    public void setTotalTime(int totalTime) {
    this.totalTime = totalTime;
    }

    public float getStartTime() {
    return startTime;
    }

    public void setStartTime(float startTime) {
    this.startTime = startTime;
    }

    public float getEndTime() {
    return endTime;
    }

    public void setEndTime(float endTime) {
    this.endTime = endTime;
    }
    }

StepCharge
package com.cloud.station.fare.entity;

/**

  • 梯步价格收费

  • [t0-t1] price元
    */
    public class StepCharge extends BaseCharge {
    private Float t0;
    private Float tn;

    private float price;

    public Float getT0() {
    return t0;
    }

    public void setT0(Float t0) {
    this.t0 = t0;
    }

    public Float getTn() {
    return tn;
    }

    public void setTn(Float tn) {
    this.tn = tn;
    }

    public float getPrice() {
    return price;
    }

    public void setPrice(float price) {
    this.price = price;
    }

    @Override
    public String toString() {
    return “StepCharge{” +
    “t0=” + t0 +
    “, tn=” + tn +
    “, price=” + price +
    ‘}’;
    }
    }

Constant常量
Code
package com.cloud.station.constant;

/**

  • 常用错误状态码
    */
    public interface Code {
    public static Integer SUCCESS = 0;//成功
    public static Integer ERROR = -1;//失败
    }

ConstantsKey
package com.cloud.station.constant;

public interface ConstantsKey {

//登陆方式常量
Integer LOGIN_METHOD_OF_PASSWORD = 0;//密码登陆
Integer PASSWORD_MIN_LEN = 6;//密码最短位数
Integer PASSWORD_MAX_LEN = 12;//密码最长位数

boolean IS_PHONE_NUMBER = true;//是手机号码
boolean IS_NOT_PHONE_NUMBER = false;//不是手机密码

//金额范围
Long MONEY_MIN = 0L;//最小金额
Long MONEY_MAX = 100000L;//最大金额

//余额充值方式
Integer PAY_ZHIFUBAO = 0;//支付宝充值
Integer PAY_WECHART = 1;//微信支付

String LOGIN_SESSION_TOKEN = "id";//登陆成功后保存在session中的标志token

//
String SOCKET_LISTENER_PORT = "socket.port";

String HADWARE_AUTHORYIZE_KEY = "KEY";//硬件认证


//Redis缓存key外键前缀
String STATION_STATE_PREFIX = "depotStationState-id@";//停车场状态key前缀

//管理员类型
Integer ADMIN = 1;//网站管理员
Integer STATION_ADMIN = 0;//停车场管理员
Integer PRIMARY_USER = 2;//普通管理员

}

HttpCode
package com.cloud.station.constant;

/**

  • RESTFULL状态码
    */
    public interface HttpCode {

    public static Integer LOGIN_FAILE = 40010;//登陆失败
    public static Integer LOGIN_PSSWORD_ERROR = 40011;//登陆密码错误
    public static Integer LOGIN_USERNAME_ERROR = 40012;//登陆用户名错误
    public static Integer LOGIN_NULL = 40020;//未登陆
    public static Integer IS_LOGIN = 40022;//已经登陆

    public static Integer NOT_EXSITS = 40013;//不存在

    public static Integer PARAMETER_MISSING = 40014;//参数缺失
    public static Integer PARAMETER_TYPE_ERROR = 40015;//参数类型错误
    public static Integer PARAMETER_INVALIED = 40016;//参数非法
    public static Integer PARAMETER_EMPTY_VALUE = 40026;//参数为空

    public static Integer RESULT_EMPTY = 40017;//结果为空

    public static Integer INVALIED_AUTHORITY = 40018;//权限不够
    public static Integer UNEXPETED_ERROR = 40049;//未知错误

    public static Integer RESOURCE_EXSISTS = 40065;//资源存在

    public static Integer RESOURCE_RESET = 40075;//资源被强制重置

}

Utils工具类
Result
JSONReturn
package com.cloud.station.utils.result;

import com.cloud.station.constant.Code;
import com.cloud.station.constant.HttpCode;

/**

  • JSON返回数据工具类
    /
    public class JSONReturn {
    /
    *

    • success
    • @param errcode 错误码
    • @param object 数据
    • @param msg 消息
    • @return
      */
      public static JSONType success(Object object,Integer errcode,String msg) {
      return new JSONType(errcode,msg,object);
      }

    /**

    • 成功返回
    • @param object 数据
    • @return
      */
      public static JSONType success(Object object) {
      return success(object, Code.SUCCESS,null);
      }

    public static JSONType success(Object object,String msg) {
    return success(object,Code.SUCCESS,msg);
    }

    public static JSONType success(){
    return success(null,Code.SUCCESS,null);
    }
    /**

    • error
    • @param errcode 错误码
    • @param object 数据
    • @param msg 信息
    • @return
      */
      public static JSONType error(Object object,Integer errcode,String msg) {
      JSONType jsonType = new JSONType();
      jsonType.setCode(errcode);
      jsonType.setMsg(msg);
      jsonType.setData(object);
      return jsonType;
      }
      public static JSONType error(Integer errcode,String msg) {
      return error(null,errcode,msg);
      }

    /**

    • 出错
    • @param msg 错误信息
    • @return
      */
      public static JSONType error(String msg) {
      return error(null, Code.ERROR,msg);
      }

    /**

    • 参数缺失
    • @return
      */
      public static JSONType missing() {
      return error(null, HttpCode.PARAMETER_MISSING, “parameter missing”);
      }

    public static JSONType empty(String msg){
    return success(null,HttpCode.RESULT_EMPTY,msg);
    }
    }

JSONType
package com.cloud.station.utils.result;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;

/**

  • JSON 返回结果集

  • @param
    */
    public class JSONType implements Serializable{

    /* 错误码 /
    private Integer code;
    /
    提示信息 */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String msg ;

    /* 具体的内容 */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private T data;

    public JSONType() {
    }

    public JSONType(Integer code, String msg, T data) {
    this.code = code;
    this.msg = msg;
    this.data = data;
    }

    public Integer getCode() {
    return code;
    }

    public void setCode(Integer code) {
    this.code = code;
    }

    public String getMsg() {
    return msg;
    }

    public void setMsg(String msg) {
    this.msg = msg;
    }

    public T getData() {
    return data;
    }

    public void setData(T data) {
    this.data = data;
    }
    }

BeanTools
package com.cloud.station.utils;

import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Configuration;

/**

  • 从spring容器中获取bean
    */
    @Configuration
    public class BeanTools implements ApplicationContextAware {
    private static ApplicationContext applicationContext;

    public void setApplicationContext(ApplicationContext context) {
    applicationContext = context;
    }

    public static Object getBean(Class classname) {
    try{
    Object _restTemplate = applicationContext.getBean(classname);
    return _restTemplate;
    }catch(Exception e){
    return “”;
    }
    }

    public static void setApplicationContext1(ApplicationContext context) {
    applicationContext = context;
    }
    }

BeanUtils
package com.cloud.station.utils;

import javax.servlet.http.HttpServletRequest;

/**

  • 类工具
    */
    public class BeanUtils {

    /**

    • 通过反射映射类
    • @param request
    • @param clazz
    • @param
    • @return
      */
      public static T toObject(HttpServletRequest request,Class clazz){
      return PackObject.getObject(request,clazz);
      }
      }

CommonUtils
package com.cloud.station.utils;

import java.math.BigDecimal;

public class CommonUtils {
/**
* 是否为电话号码
*
* @param tel
* 电话
* @return
*/
public static boolean isTel(String tel) {
// TODO 尚未实现
return true;
}

/**
* 保留n位小数
* @param money
* @return
*/
public static float keepDecimalDigits(float money) {
//TODO 保留n位小数
int scale = 2;// 设置位数
int roundingMode = 4;// 表示四舍五入,可以选择其他舍值方式,例如去尾,等等.
BigDecimal bd = new BigDecimal((double) money);
bd = bd.setScale(scale, roundingMode);
money = bd.floatValue();
return money;
}
}

JsonFormat
package com.cloud.station.utils;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializeConfig;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.SimpleDateFormatSerializer;

import java.util.Date;
import java.util.List;

/**
*

  • DESC: 封装一个结果类型的字符串,包括success和msg两个字段
    */
    public class JsonFormat {
    //格式化日期
    private static String dateFormat;
    static {
    dateFormat = “yyyy-MM-dd HH:mm:ss”;
    }

    private static SerializeConfig mapping = new SerializeConfig();
    static {
    //jackson默认写出的时间数据为时间戳, 这里修改为相应模式的时间数据输出格式
    mapping.put(Date.class, new SimpleDateFormatSerializer(dateFormat));
    }

    /**

    • 将对象或集合转换为json字符串
    • @param obj
    • @return
      */
      public final static String toString(Object obj){
      return JSONObject.toJSONStringWithDateFormat(obj, “yyyy-MM-dd HH:mm:ss”, SerializerFeature.WriteMapNullValue);
      }

    /**

    • 将对象或集合转换为json字符串
    • @param obj
    • @return
      */
      public final static String toStringWithoutNull(Object obj){
      return JSONObject.toJSONStringWithDateFormat(obj, “yyyy-MM-dd HH:mm:ss”);
      }

    /**

    • 将结果字符串转换为标准结果集
    • @param success
    • @param msg
    • @return {“success”:success,“msg”:msg}
      */
      public final static String toStringResult(boolean success, String msg){
      return String.format("{“success”:%s,“msg”:"%s"}", success?“true”:“false”, msg);
      }

    public final static String toStatusResult(int status, Object data){
    return String.format("{“status”:%s,“data”:%s}", status, toString(data));
    }

// public final static String toStatusResult(ResultBean data){
// if (data.getData() instanceof String)
// return data.toString();
// else
// return toStatusResult(data.getStatus(), data.getData());
// }

/**
 * 将对象转换为标准结果集
 * @param success
 * @param msg
 * @return {"success":success,"msg":msg}
 */
public final static String toObjectResult(boolean success, Object msg){
    if (msg != null)
        return String.format("{\"success\":%s,\"msg\":%s}", success, JSONObject.toJSONStringWithDateFormat(msg, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
    else //把null集合转换为[],是为了kendo ui dataSource,直接返回null,会出现Status code=200的异常
        return String.format("{\"success\":%s,\"msg\":\"[]\"}", success);
}

public final static String toString(String key, Object msg){
    return String.format("{\"%s\":%s}", key, JSONObject.toJSONStringWithDateFormat(msg, "yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
}

public final static String toPageString(Integer total, List data){
    if (total == null || total == 0)
        return emptyPageString();

    return String.format("{\"total\":%s, \"data\":%s}", total, JSONObject.toJSONStringWithDateFormat(data, "yyyy-MM-dd HH:mm:ss"));
}

public final static String toPageString(List data){
    if (data.size() == 0)
        return emptyPageString();

    return String.format("{\"total\":%s, \"data\":%s}", data.size(), JSONObject.toJSONStringWithDateFormat(data, "yyyy-MM-dd HH:mm:ss"));
}

public final static String emptyPageString(){
    return "{\"total\":0, \"data\":\"\"}";
}

}

MapUtils
package com.cloud.station.utils;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Map;

public class MapUtils {

public static ArrayList toList(Map map){
    Collection valueCollection = map.values();
    return new ArrayList<>(valueCollection);
}

}

PackObject
package com.cloud.station.utils;

/**

  • 动态生成POJO对象
    */

import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Enumeration;

public class PackObject {
Class clazz;

public static  T getObject(HttpServletRequest request, Class clazz) {

    T t = null;
    try {
        t = clazz.newInstance(); // 实例化参数对象
    } catch (InstantiationException e1) {
        e1.printStackTrace();
    } catch (IllegalAccessException e1) {
        e1.printStackTrace();
    }

    @SuppressWarnings("rawtypes")
    Enumeration e = request.getParameterNames(); // 所有请求参数

    Method[] methods = clazz.getDeclaredMethods(); // 参数对象的所有方法

    // 根据对象的set方法的参数类型去将请求的值做相应转换
    while (e.hasMoreElements()) {
        String paramName = e.nextElement().toString();
        String setParamName = reverseParamName(paramName); //将参数名字转换成set方法名字,如:id 转换成 setId
        
        for (Method method : methods) {
            if (setParamName.equals(method.getName())) {
                try {
                    Class paramType = (method.getParameterTypes())[0]; //得到set方法参数类型
                    String value = request.getParameter(paramName); 
                    adapter(t, method, paramType, value); //通过适配器将值注入进POJO里面
                } catch (IllegalArgumentException e1) {
                    e1.printStackTrace();
                } catch (IllegalAccessException e1) {
                    e1.printStackTrace();
                } catch (InvocationTargetException e1) {
                    e1.printStackTrace();
                } catch (SecurityException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    return t;
}

private static String reverseParamName(String paramName) {
    char firstChar = paramName.charAt(0);
    char toUpper = Character.toUpperCase(firstChar);
    String setParamName = "set" + String.valueOf(toUpper)
            + paramName.substring(1);
    return setParamName;
}

private static  void adapter(T t, Method method, Class paramType,
        String value) throws IllegalAccessException,
        InvocationTargetException {
    if (paramType == String.class) {
        method.invoke(t, value);
    } else if (paramType == Integer.class || paramType == int.class) {
        method.invoke(t, Integer.parseInt(value));
    } else if (paramType == Long.class || paramType == long.class) {
        method.invoke(t, Long.parseLong(value));
    } else if (paramType == Boolean.class || paramType == boolean.class) {
        method.invoke(t, Boolean.parseBoolean(value));
    } else if (paramType == Short.class || paramType == short.class) {
        method.invoke(t, Short.parseShort(value));
    } else if (paramType == Float.class || paramType == float.class) {
        method.invoke(t, Float.parseFloat(value));
    } else if (paramType == Double.class || paramType == double.class) {
        method.invoke(t, Double.parseDouble(value));
    } else if (paramType == Character.class || paramType == char.class) {
        char[] cs = value.toCharArray();
        if (cs.length > 1) {
            throw new IllegalArgumentException("参数长度太大");
        }
        method.invoke(t, value.toCharArray()[0]);
    }
}

}

ParamValidUtils
package com.cloud.station.utils;

/**

  • 请求参数验证工具类
    */
    public class ParamValidUtils {

    /**

    • 判断字符串是否为空(null或“”)
    • @param param 参数
    • @return 如果为null或者“”返回true,否则返回false
      */
      public static boolean isEmpty(String param){
      return (param==null || param.equals(""));
      }

    public static boolean isNotEmpty(String param){
    return !(param==null || param.equals(""));
    }

    /**

    • 批量判断多个变量是否都为空(null或“”)
    • @param args 参数数组
    • @return 如果为null或者“”返回true,否则返回false
      */
      public static boolean isEmptyAll(String…args){
      for(String arg : args){
      if(isEmpty(arg))
      return true;
      }
      return false;
      }
      }

ParanUtils
package com.cloud.station.utils;

/**
*
*/
public class ParanUtils {
}

PasswordUtils
package com.cloud.station.utils;

/**

  • 密码处理工具类
    */
    public class PasswordUtils {

    /**

    • 密码加密处理
    • @param password
    • @return
      */
      public static String encrpty(String password){
      //TODO PasswordUtils.encrpty 未实现
      return password;
      }

    /**

    • 匹配密码是否正确
    • @param oldPassword 原密码
    • @param newPassword 加密后的密码
    • @return
      */
      public static boolean check(String oldPassword,String newPassword){
      return newPassword.equals(encrpty(oldPassword));
      }

    /**

    • 字符过滤
    • @param password 原始密码
    • @return
      */
      public static String filer(String password){
      //TODO 字符密码过滤,未实现
      return password;
      }

    /**

    • 判断密码长度
    • @param password
    • @return
      */
      public static boolean checkLength(String password){
      //TODO 判断密码长度,未实现
      return true;
      }
      }

StringUtils
package com.cloud.station.utils;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**

  • 字符操作常用方法集
    /
    public class StringUtils {
    /
    *

    • 编译后的正则表达式缓存
      */
      private static final Map PATTERN_CACHE = new ConcurrentHashMap<>();

    /**

    • 给定三个字符串str,from,to,已知from字符串中无重复字符,把str中所有的from字符串替换为to字符串,然后替换后的字符串
    • example:str=“123abc”,from=“abc”,to=“456”,return “123456”;
    • @param str
    • @param from 无重复字符
    • @param to
    • @return
      */
      public static String replace(String str,String from,String to){
      if(strnull||str.equals("")||fromnull||from.equals("")){
      return str;
      }
      char[] strArr=str.toCharArray();
      char[] fromArr=from.toCharArray();
      int match=0;
      for(int i=0;i if(strArr[i]fromArr[match]){
      match++;
      if(match
      fromArr.length){
      clear(strArr,i,fromArr.length);
      match=0;
      }
      }else{
      match=0;
      }
      }
      String result="";
      String cur="";
      for(int i=0;i if(strArr[i]!=0){
      cur=cur+String.valueOf(strArr[i]);
      }
      if(strArr[i]0&&(i0||strArr[i-1]!=0)){
      result=result+cur+to;
      cur="";
      }
      }
      if(!cur.equals("")){
      result=result+cur;
      }
      return result;
      }

    public static void clear(char[] str,int end ,int length){
    while(length!=0){
    str[end]=0;
    end–;
    length–;
    }
    }

    /**

    • 合并多个数组
    • @param first
    • @param rest
    • @return
      */
      public static T[] concatAll(T[] first, T[]… rest) {
      int totalLength = first.length;
      for (T[] array : rest) {
      totalLength += array.length;
      }
      T[] result = Arrays.copyOf(first, totalLength);
      int offset = first.length;
      for (T[] array : rest) {
      System.arraycopy(array, 0, result, offset, array.length);
      offset += array.length;
      }
      return result;
      }

    /**

    • 编译一个正则表达式,并且进行缓存,如果换成已存在则使用缓存
    • @param regex 表达式
    • @return 编译后的Pattern
      */
      public static final Pattern compileRegex(String regex) {
      Pattern pattern = PATTERN_CACHE.get(regex);
      if (pattern == null) {
      pattern = Pattern.compile(regex);
      PATTERN_CACHE.put(regex, pattern);
      }
      return pattern;
      }

    /**

    • 将字符串的第一位转为小写
    • @param str 需要转换的字符串
    • @return 转换后的字符串
      */
      public static String toLowerCaseFirstOne(String str) {
      if (Character.isLowerCase(str.charAt(0)))
      return str;
      else {
      char[] chars = str.toCharArray();
      chars[0] = Character.toLowerCase(chars[0]);
      return new String(chars);
      }
      }

    /**

    • 将字符串的第一位转为大写
    • @param str 需要转换的字符串
    • @return 转换后的字符串
      */
      public static String toUpperCaseFirstOne(String str) {
      if (Character.isUpperCase(str.charAt(0)))
      return str;
      else {
      char[] chars = str.toCharArray();
      chars[0] = Character.toUpperCase(chars[0]);
      return new String(chars);
      }
      }

    /**

    • 下划线命名转为驼峰命名
    • @param str 下划线命名格式
    • @return 驼峰命名格式
      */
      public static final String underScoreCase2CamelCase(String str) {
      if (!str.contains("")) return str;
      StringBuilder sb = new StringBuilder();
      char[] chars = str.toCharArray();
      boolean hitUnderScore = false;
      sb.append(chars[0]);
      for (int i = 1; i < chars.length; i++) {
      char c = chars[i];
      if (c == '
      ’) {
      hitUnderScore = true;
      } else {
      if (hitUnderScore) {
      sb.append(Character.toUpperCase©);
      hitUnderScore = false;
      } else {
      sb.append©;
      }
      }
      }
      return sb.toString();
      }

    /**

    • 驼峰命名法转为下划线命名
    • @param str 驼峰命名格式
    • @return 下划线命名格式
      */
      public static final String camelCase2UnderScoreCase(String str) {
      StringBuilder sb = new StringBuilder();
      char[] chars = str.toCharArray();
      for (int i = 0; i < chars.length; i++) {
      char c = chars[i];
      if (Character.isUpperCase©) {
      sb.append("_").append(Character.toLowerCase©);
      } else {
      sb.append©;
      }
      }
      return sb.toString();
      }

    /**

    • 将异常栈信息转为字符串
    • @param e 字符串
    • @return 异常栈
      */
      public static String throwable2String(Throwable e) {
      StringWriter writer = new StringWriter();
      e.printStackTrace(new PrintWriter(writer));
      return writer.toString();
      }

    /**

    • 字符串连接,将参数列表拼接为一个字符串
    • @param more 追加
    • @return 返回拼接后的字符串
      */
      public static String concat(Object… more) {
      return concatSpiltWith("", more);
      }

    public static String concatSpiltWith(String split, Object… more) {
    StringBuilder buf = new StringBuilder();
    for (int i = 0; i < more.length; i++) {
    if (i != 0) buf.append(split);
    buf.append(more[i]);
    }
    return buf.toString();
    }

    /**

    • 将字符串转移为ASCII码
    • @param str 字符串
    • @return 字符串ASCII码
      */
      public static String toASCII(String str) {
      StringBuffer strBuf = new StringBuffer();
      byte[] bGBK = str.getBytes();
      for (int i = 0; i < bGBK.length; i++) {
      strBuf.append(Integer.toHexString(bGBK[i] & 0xff));
      }
      return strBuf.toString();
      }

    public static String toUnicode(String str) {
    StringBuffer strBuf = new StringBuffer();
    char[] chars = str.toCharArray();
    for (int i = 0; i < chars.length; i++) {
    strBuf.append("\u").append(Integer.toHexString(chars[i]));
    }
    return strBuf.toString();
    }

    public static String toUnicodeString(char[] chars) {
    StringBuffer strBuf = new StringBuffer();
    for (int i = 0; i < chars.length; i++) {
    strBuf.append("\u").append(Integer.toHexString(chars[i]));
    }
    return strBuf.toString();
    }

    static final char CN_CHAR_START = ‘\u4e00’;
    static final char CN_CHAR_END = ‘\u9fa5’;

    /**

    • 是否包含中文字符
    • @param str 要判断的字符串
    • @return 是否包含中文字符
      */
      public static boolean containsChineseChar(String str) {
      char[] chars = str.toCharArray();
      for (int i = 0; i < chars.length; i++) {
      if (chars[i] >= CN_CHAR_START && chars[i] <= CN_CHAR_END) return true;
      }
      return false;
      }

    /**

    • 对象是否为无效值
    • @param obj 要判断的对象
    • @return 是否为有效值(不为null 和 “” 字符串)
      */
      public static boolean isNullOrEmpty(Object obj) {
      return obj == null || “”.equals(obj.toString());
      }

    /**

    • 参数是否是有效数字 (整数或者小数)
    • @param obj 参数(对象将被调用string()转为字符串类型)
    • @return 是否是数字
      */
      public static boolean isNumber(Object obj) {
      if (obj instanceof Number) return true;
      return isInt(obj) || isDouble(obj);
      }

    public static String matcherFirst(String patternStr, String text) {
    Pattern pattern = compileRegex(patternStr);
    Matcher matcher = pattern.matcher(text);
    String group = null;
    if (matcher.find()) {
    group = matcher.group();
    }
    return group;
    }

    /**

    • 参数是否是有效整数
    • @param obj 参数(对象将被调用string()转为字符串类型)
    • @return 是否是整数
      */
      public static boolean isInt(Object obj) {
      if (isNullOrEmpty(obj))
      return false;
      if (obj instanceof Integer)
      return true;
      return obj.toString().matches("[-+]?\d+");
      }

    /**

    • 字符串参数是否是double
    • @param obj 参数(对象将被调用string()转为字符串类型)
    • @return 是否是double
      */
      public static boolean isDouble(Object obj) {
      if (isNullOrEmpty(obj))
      return false;
      if (obj instanceof Double || obj instanceof Float)
      return true;
      return compileRegex("[-+]?\d+\.\d+").matcher(obj.toString()).matches();
      }

    /**

    • 判断一个对象是否为boolean类型,包括字符串中的true和false
    • @param obj 要判断的对象
    • @return 是否是一个boolean类型
      */
      public static boolean isBoolean(Object obj) {
      if (obj instanceof Boolean) return true;
      String strVal = String.valueOf(obj);
      return “true”.equalsIgnoreCase(strVal) || “false”.equalsIgnoreCase(strVal);
      }

    /**

    • 对象是否为true
    • @param obj
    • @return
      */
      public static boolean isTrue(Object obj) {
      return “true”.equals(String.valueOf(obj));
      }

    /**

    • 判断一个数组里是否包含指定对象
    • @param arr 对象数组
    • @param obj 要判断的对象
    • @return 是否包含
      */
      public static boolean contains(Object arr[], Object… obj) {
      if (arr == null || obj == null || arr.length == 0) return false;
      return Arrays.asList(arr).containsAll(Arrays.asList(obj));
      }

    /**

    • 将对象转为int值,如果对象无法进行转换,则使用默认值
    • @param object 要转换的对象
    • @param defaultValue 默认值
    • @return 转换后的值
      */
      public static int toInt(Object object, int defaultValue) {
      if (object instanceof Number)
      return ((Number) object).intValue();
      if (isInt(object)) {
      return Integer.parseInt(object.toString());
      }
      if (isDouble(object)) {
      return (int) Double.parseDouble(object.toString());
      }
      return defaultValue;
      }

    /**

    • 将对象转为int值,如果对象不能转为,将返回0
    • @param object 要转换的对象
    • @return 转换后的值
      */
      public static int toInt(Object object) {
      return toInt(object, 0);
      }

    /**

    • 将对象转为long类型,如果对象无法转换,将返回默认值
    • @param object 要转换的对象
    • @param defaultValue 默认值
    • @return 转换后的值
      */
      public static long toLong(Object object, long defaultValue) {
      if (object instanceof Number)
      return ((Number) object).longValue();
      if (isInt(object)) {
      return Long.parseLong(object.toString());
      }
      if (isDouble(object)) {
      return (long) Double.parseDouble(object.toString());
      }
      return defaultValue;
      }

    /**

    • 将对象转为 long值,如果无法转换,则转为0
    • @param object 要转换的对象
    • @return 转换后的值
      */
      public static long toLong(Object object) {
      return toLong(object, 0);
      }

    /**

    • 将对象转为Double,如果对象无法转换,将使用默认值
    • @param object 要转换的对象
    • @param defaultValue 默认值
    • @return 转换后的值
      */
      public static double toDouble(Object object, double defaultValue) {
      if (object instanceof Number)
      return ((Number) object).doubleValue();
      if (isNumber(object)) {
      return Double.parseDouble(object.toString());
      }
      if (null == object) return defaultValue;
      return 0;
      }

    /**

    • 将对象转为Double,如果对象无法转换,将使用默认值0
    • @param object 要转换的对象
    • @return 转换后的值
      */
      public static double toDouble(Object object) {
      return toDouble(object, 0);
      }

    /**

    • 分隔字符串,根据正则表达式分隔字符串,只分隔首个,剩下的的不进行分隔,如: 1,2,3,4 将分隔为 [‘1’,‘2,3,4’]
    • @param str 要分隔的字符串
    • @param regex 分隔表达式
    • @return 分隔后的数组
      */
      public static String[] splitFirst(String str, String regex) {
      return str.split(regex, 2);
      }

    /**

    • 将对象转为字符串,如果对象为null,则返回null,而不是"null"
    • @param object 要转换的对象
    • @return 转换后的对象
      */
      public static String toString(Object object) {
      return toString(object, null);
      }

    /**

    • 将对象转为字符串,如果对象为null,则使用默认值
    • @param object 要转换的对象
    • @param defaultValue 默认值
    • @return 转换后的字符串
      */
      public static String toString(Object object, String defaultValue) {
      if (object == null) return defaultValue;
      return String.valueOf(object);
      }

    /**

    • 将对象转为String后进行分割,如果为对象为空或者空字符,则返回null
    • @param object 要分隔的对象
    • @param regex 分隔规则
    • @return 分隔后的对象
      */
      public static final String[] toStringAndSplit(Object object, String regex) {
      if (isNullOrEmpty(object)) return null;
      return String.valueOf(object).split(regex);
      }

    private static boolean isChinese(char c) {
    Character.UnicodeBlock ub = Character.UnicodeBlock.of©;
    if (ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS
    || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
    || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
    || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION
    || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION
    || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS) {
    return true;
    }
    return false;
    }

    public static boolean isMessyCode(String strName) {
    Pattern p = Pattern.compile("\s*|\t*|\r*|\n*");
    Matcher m = p.matcher(strName);
    String after = m.replaceAll("");
    String temp = after.replaceAll("\p{P}", “”);
    char[] ch = temp.trim().toCharArray();
    float chLength = 0;
    float count = 0;
    for (int i = 0; i < ch.length; i++) {
    char c = ch[i];
    if (!Character.isLetterOrDigit©) {
    if (!isChinese©) {
    count = count + 1;
    }
    chLength++;
    }
    }
    float result = count / chLength;
    if (result > 0.4) {
    return true;
    } else {
    return false;
    }
    }

}

程序入口
WebappApplication
package com.cloud.station;

import com.cloud.station.controller.socket.Instructions;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.boot.web.support.SpringBootServletInitializer;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.socket.config.annotation.EnableWebSocket;

@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan
@MapperScan(“com.cloud.station.mapper”)
@ServletComponentScan//扫描所有的监听注解(@WebListener)
@EnableCaching//使用缓存(Redis)
//public class WebappApplication {
// public static void main(String[] args) {
// SpringApplication.run(WebappApplication.class, args);
// }
//}
//部署时候用
public class WebappApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(WebappApplication.class, args);
}

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(WebappApplication.class);
}

}

Mapper层
AddressMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.dto.MapAddressDTO;

import java.util.List;

/**

  • @className: AddressMapper
  • @data: 2018-03-07
  • @lastModify: 2018-03-23
  • @description: 地址信息Mapper接口
    /
    public interface AddressMapper extends BaseMapper{
    /
    *
    • 根据地址查找停车场的状态信息包括停车场的基本信息
    • @param mapAddressDTO
    • @return
      */
      public List findByMapAddress(MapAddressDTO mapAddressDTO);
      }

AdminInfoMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;

/**

  • @className: AdminInfoMapper

  • @date: 2018-03-07

  • @lastModify: 2018-03-07

  • @description: 系统管理员Mapper接口
    */
    public interface AdminInfoMapper extends BaseMapper{

    /**

    • 根据账号查询密码
    • @param account 字符串
    • @return 影响记录条数
    • @throws Exception
      */
      public String findPasswordByAccount(String account) throws Exception;

}

CarInfoMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.CarInfo;
import com.cloud.station.pojo.StationOrder;
import com.cloud.station.pojo.UserInfo;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface CarInfoMapper extends BaseMapper{

/**
 * 查询用户信息
 * @param carInfo
 * @return
 * @throws Exception
 */
public UserInfo getUser(CarInfo carInfo)throws Exception;

/**
 * 根据车牌查询实体
 * @param carNumber
 * @return
 * @throws Exception
 */
public CarInfo getByCarNumber(String carNumber)throws Exception;

/**
 * 获取用户绑定的所有车牌信息
 * 包括车主自己的和绑定其他的车辆
 * @param userId
 * @return
 * @throws Exception
 */
public List getAll(Long userId) throws Exception;

/**
 * 查询
 * @param carInfo
 * @return
 * @throws Exception
 */
public List find(@Param("carInfo") CarInfo carInfo,@Param("skip") Integer skip,@Param("limit") Integer limit) throws Exception;

/**
 * 过滤统计总记录数
 * @param carInfo
 * @return
 * @throws Exception
 */
public Long count(CarInfo carInfo) throws Exception;

}

CarNumberBlacklistMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.CarNumberBlacklist;

import java.util.List;

public interface CarNumberBlacklistMapper extends BaseMapper{

/**
 * 根据车牌查询信息
 * @param carNum
 * @return
 * @throws Exception
 */
public List getByCarNumber(String carNum,Integer skip,Integer limit) throws Exception;

/**
 * 根据车牌统计
 * @param carNum
 * @return
 * @throws Exception
 */
public Long countByFilterCarNum(String carNum)throws Exception;

}

CarNumberUsedMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;

public interface CarNumberUsedMapper extends BaseMapper{

}

CarNumberUsingMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.CarNumberUsing;
import com.cloud.station.pojo.UserInfo;

import java.util.List;

public interface CarNumberUsingMapper extends BaseMapper{

/**
 * 根据车牌ID查询出车牌的使用情况
 * @param carNumberId 车牌ID
 * @param state  状态
 * @return
 * @throws Exception
 */
public CarNumberUsing getByCarNumberId(Long carNumberId,Integer state)throws Exception;

}

DepotAdminInfoMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;

/**

  • @className: DepotAdminInfoMapper

  • @data: 2018-03-07

  • @lastModify: 2018-03-07

  • @description: 停车场管理员Mapper接口
    */
    public interface DepotAdminInfoMapper extends BaseMapper{

    /**

    • 根据账号查询密码
    • @param account 字符串
    • @return 影响记录条数
    • @throws Exception
      */
      public String findPasswordByAccount(String account) throws Exception;

}

DepotInfoMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.dto.Position;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**

  • @className: DepotInfoMapper
  • @data: 2018-03-07
  • @lastModify: 2018-03-07
  • @description: 停车场信息Mapper接口
    /
    public interface DepotInfoMapper extends BaseMapper{
    /
    *
    • 根据经纬度查询
    • @param position 经纬度范围
    • @param skip 跳过记录条数
    • @param limit 每页条数
    • @return
      */
      public List findByLatAndLon(@Param(“position”) Position position,
      @Param(“skip”) int skip,@Param(“limit”) int limit) throws Exception;
      }

DepotStateMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;

/**

  • @className: DepotStateMapper
  • @data: 2017-03-07
  • @lastModify: 2017-03-07
  • @description: 停车场状态 Mapper接口
    */
    public interface DepotStateMapper extends BaseMapper{

}

DepotStationMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;

/**

  • @className: DepotStationMapper
  • @data: 2018-03-07
  • @lastModify: 2018-03-07
  • @description: 车位信息 Mapper接口
    */
    public interface DepotStationMapper extends BaseMapper{

}

DepotStationStateMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.dto.MapAddressDTO;

import java.util.List;

/**

  • @className: DepotStationStateMapper
  • @data: 2018-03-07
  • @lastModify: 2018-03-07
  • @description: 车位状态 Mapper接口
    */
    public interface DepotStationStateMapper extends BaseMapper{

}

FareRuleMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.FareRule;

import java.util.List;

public interface FareRuleMapper extends BaseMapper{

/**
 * 查询停车场下的所有规则
 * @param stationId
 * @return
 */
public List getAll(Long stationId) throws Exception;

/**
 * 查询停车场正在使用的规则信息
 * @param stationId
 * @return
 * @throws Exception
 */
public FareRule getUsedByStationId(Long stationId) throws Exception;

}

FriendMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.Friend;
import com.cloud.station.pojo.UserInfo;
import com.cloud.station.pojo.ex.FriendEx;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**

  • @className: FriendMapper

  • @data: 2018-04-13

  • @lastModify: 2018-04-13

  • @description: 好友 Mapper接口
    */
    public interface FriendMapper extends BaseMapper{

    /**

    • 查询
    • @param myId 我的ID
    • @param relative 关系包含
    • @param unrelative 关系不包含
    • @param skip
    • @param limit
    • @return
    • @throws Exception
      */
      public List getFriendList(@Param(“myId”) Long myId,
      @Param(“relative”)Integer relative,
      @Param(“unrelative”)Integer unrelative,
      @Param(“skip”)Integer skip,@Param(“limit”)Integer limit) throws Exception;

    /**

    • 条件统计
    • @param myId
    • @param relative
    • @param unrelative
    • @param skip
    • @param limit
    • @return
    • @throws Exception
      */
      public Long countByFilter(@Param(“myId”) Long myId,
      @Param(“relative”)Integer relative,
      @Param(“unrelative”)Integer unrelative) throws Exception;
      }

LogStationMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;

/**
*@className: LogStationMapper
*@data: 2018-03-07
*@lastModify: 2018-03-07
*@description: 车位占用记录Mapper接口
*/
public interface LogStationMapper extends BaseMapper{

}

StationOrderMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.StationOrder;
import com.cloud.station.pojo.UserInfo;
import com.cloud.station.pojo.ex.StationOrderUser;
import org.apache.ibatis.annotations.Param;

import java.util.List;

public interface StationOrderMapper extends BaseMapper {

/**
 * 根据时间段多条件查询
 * @param stationOrder 实体类
 * @param start 开始时间
 * @param end   结束时间
 * @return
 * @throws Exception
 */
public List findByTime(@Param("order")StationOrder stationOrder,
                       @Param("start")Long start,@Param("end")Long end,
                       @Param("skip")Integer skip,@Param("limit")Integer limit)throws Exception;

/**
 * 根据实体查询用户信息
 * @param stationOrder
 * @return
 * @throws Exception
 */
public List findUserByEntity(@Param("order") StationOrder stationOrder,
                                               @Param("skip")Integer page,@Param("limit")Integer limit) throws Exception;

/**
 * 根据停车场ID和车牌查询未支付的记录
 * @param stationId
 * @param carNum
 * @return
 * @throws Exception
 */
public StationOrder findByStationIdAndCarNuber(Long stationId, String carNum) throws Exception;

}

UserInfoMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;
import com.cloud.station.pojo.UserInfo;

/**
*@className: UserInfoMapper
*@data: 2018-03-07
*@lastModify: 2018-03-07
*@description: 用户Mapper接口
*/
public interface UserInfoMapper extends BaseMapper{

/**
 * 根据账号查询密码
 * @param account   字符串
 * @return         影响记录条数
 * @throws Exception
 */
public String findPasswordByAccount(String account) throws Exception;

/**
 * 根据账号查询对象
 * @param account   字符串
 * @return         影响记录条数
 * @throws Exception
 */
public UserInfo findByAccount(String account) throws Exception;

}

UserUrgentContactMapper
package com.cloud.station.mapper;

import com.cloud.station.base.BaseMapper;

/**

  • @className: UserUrgentContactMapper
  • @data: 2018-03-07
  • @lastModify: 2018-03-07
  • @description: 紧急联系人Mapper接口
    */
    public interface UserUrgentContactMapper extends BaseMapper{

}

Mapper Xml编写
AddressMapper.xml

SELECT addr_id id, addr_provice provice, addr_city city, addr_country country, addr_village village, addr_desc `desc`, create_time createTime, admin_depot_id adminDepotId FROM address
  WHERE
     addr_provice=#{provice} AND
     addr_city=#{city}
INSERT INTO address(addr_id, addr_provice, addr_city, addr_country, create_time) VALUES(#{id}, #{provice}, #{city}, #{country}, #{createTime})
       
       

  
  
     
  
     
       
       

  
  
     
  
     
     
        
     
      
       
       

  
     
  
     
     
     
     
     
     
     
  
     
SELECT addr_id id, addr_provice provice, addr_city city, addr_country country, addr_village village, addr_desc `desc`, create_time createTime, admin_depot_id adminDepotId FROM address WHERE addr_id = #{id} SELECT addr_id id, addr_provice provice, addr_city city, addr_country country, create_time createTime FROM address addr_id=#{id} AND addr_provice=#{provice} AND addr_city=#{city} AND addr_country=#{country}
       
       

  
     
     
     
     
     
     
     
     
  
     
  
     
  
     
  
     
       
       

  
     
     
     
     
     
     
     
     
  
     
  
     
  
     
  
     
       
       

  
     
     
     
     
     
     
     
     
  
     
  
     
  
     
  
     

AdminInfoMapper.xml

INSERT INTO admin_info(admin_id, admin_account, admin_pwd, create_time) VALUES(#{id}, #{account}, #{pwd}, #{createTime}) DELETE FROM admin_info WHERE admin_id = #{id} UPDATE admin_info SET admin_account = #{account}, admin_pwd = #{pwd}, create_time = #{createTime} WHERE admin_id = #{id} SELECT admin_id id, admin_account account, admin_pwd pwd, create_time createTime FROM admin_info WHERE admin_id = #{id} SELECT admin_pwd pwd FROM admin_info WHERE admin_account = #{account} SELECT admin_id id, admin_account account, create_time createTime FROM admin_info WHERE admin_account = #{account}

CarInfoMapper.xml

INSERT INTO car_info( id, car_number, current_used, user_id, car_number_type, photo, car_type, car_xinhao, car_year, car_color, car_code) VALUES( #{id}, #{carNumber}, #{currentUsed}, #{userId}, #{carNumberType}, #{photo}, #{carType}, #{carXH}, #{carYear}, #{carColor}, #{code})

你可能感兴趣的:(java,项目)