Commit 8f69b3fe by fz

1.车钥匙蓝牙感应列表,业务逻辑修改为根据车钥匙id

1 parent 68cd326a
......@@ -63,4 +63,9 @@ public interface SmartKeyBlueSenseMapper {
* @return update count
*/
int updateByPrimaryKey(SmartKeyBlueSense record);
/**
*
*/
List<SmartKeyBlueSense> getByCarKeyIds(List<Long> ids);
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ public enum ResultEnum {
CAR_KEY_EXCEP_7(1107, "智能车钥匙secretKey加密异常"),
CAR_KEY_EXCEP_8(1108, "智能车钥匙新增异常"),
CAR_KEY_EXCEP_9(1109, "智能车钥匙注册成功数据保存,自动感应新增异常"),
CAR_KEY_EXCEP_10(1110, "异常数据,无crep"),
CAR_KEY_EXCEP_10(1110, "智能车钥匙无crep"),
CAR_KEY_EXCEP_11(1111, "自动感应新增异常"),
CAR_KEY_EXCEP_12(1112, "智能车钥匙用户查询,secretKey解密异常"),
CAR_KEY_EXCEP_13(1113, "智能车钥匙用户查询,crep/secret加密异常"),
......
......@@ -29,6 +29,7 @@ public interface SmartKeyBlueSenseService {
int updateByPrimaryKey(SmartKeyBlueSense record);
List<SmartKeyBlueSense> getByCarKeyIds(List<Long> ids);
}
......
......@@ -55,12 +55,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
public R getLockingKey(SmartCarKeyRequest request) {
SmartCarKeyResponse response = new SmartCarKeyResponse();
//根据sn查询车钥匙
SmartVehicleBlueKeyExample example = new SmartVehicleBlueKeyExample();
example.createCriteria()
.andSnEqualTo(request.getSn())
.andUserIdEqualTo(Long.valueOf(request.getUserId()))
.andIsDeleteEqualTo(0);
List<SmartVehicleBlueKey> smartVehicleBlueKeys = smartVehicleBlueKeyService.selectByExample(example);
List<SmartVehicleBlueKey> smartVehicleBlueKeys = smartVehicleBlueKeyService.selectByExample(getBlueKeyExampleByUserAndSn(Long.valueOf(request.getUserId()), request.getSn()));
if (CollectionUtils.isEmpty(smartVehicleBlueKeys)) {
//sn查询没有车钥匙
......@@ -123,7 +118,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
//逻辑删除蓝牙车钥匙设备
SmartVehicleBlueKey smartVehicleBlueKey = new SmartVehicleBlueKey();
smartVehicleBlueKey.setIsDelete(1);
smartVehicleBlueKeyService.updateByExampleSelective(smartVehicleBlueKey, getBlueKeyExampleBysn(Long.valueOf(request.getUserId()), request.getSn()));
smartVehicleBlueKeyService.updateByExampleSelective(smartVehicleBlueKey, getBlueKeyExampleByUserAndSn(Long.valueOf(request.getUserId()), request.getSn()));
return R.ok();
}
......@@ -186,9 +181,11 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
example.createCriteria()
.andUserIdEqualTo(Long.valueOf(request.getUserId()))
.andIsDeleteEqualTo(0);
List<SmartVehicleBlueKey> keyList = smartVehicleBlueKeyService.selectByExample(example);
if (CollectionUtils.isNotEmpty(keyList)) {
//判断用户下是否已经存在同名的设备
boolean IfExist = keyList.stream().anyMatch(key -> {
//数据库中存在的sn
......@@ -196,7 +193,9 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
//数据库中存在的keyName
String keyName_db = key.getKeyName();
return (keyName.equals(keyName_db) && !sn.equals(sn_db));
boolean exist = (keyName.equals(keyName_db) && !sn.equals(sn_db));
return exist;
});
if (IfExist)
......@@ -221,26 +220,26 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
public R setLockingKeyAutoSense(SmartCarKeyAutoSenseRequest request) {
long userId = Long.valueOf(request.getUserId());
String sn = request.getSn();
String mobileMac = request.getMobileMac();
Integer autoSenseStatus = Integer.valueOf(request.getAutoSenseStatus());
//查询该用户设备的手机蓝牙是否存在
SmartKeyBlueSenseExample example = new SmartKeyBlueSenseExample();
example.createCriteria()
.andUserIdEqualTo(userId)
.andSnEqualTo(sn)
.andMobileBlueMacEqualTo(mobileMac)
.andIsDeleteEqualTo(0);
//查询该车钥匙是否存在
List<SmartVehicleBlueKey> blueKeys = smartVehicleBlueKeyService.selectByExample(getBlueKeyExampleByUserAndSn(userId, sn));
if (CollectionUtils.isEmpty(blueKeys))
return R.error("车钥匙不存在");
long carKeyId = blueKeys.get(0).getId();
//根据车钥匙id查询蓝牙信息
SmartKeyBlueSenseExample example = getBlueSenseExampleByCarKeyID(carKeyId);
List<SmartKeyBlueSense> blueSenseList = smartKeyBlueSenseService.selectByExample(example);
SmartKeyBlueSense blueSense = null;
//查询车钥匙信息,蓝牙信息设置钥匙主键
List<SmartVehicleBlueKey> blueKeys = smartVehicleBlueKeyService.selectByExample(getBlueKeyExampleBysn(userId,sn));
if (CollectionUtils.isEmpty(blueSenseList)) {
//不存在,新增手机蓝牙,感应状态数据
blueSense = SmartKeyBlueSense.builder()
SmartKeyBlueSense blueSense = SmartKeyBlueSense.builder()
.carKeyId(carKeyId)
.userId(userId)
.sn(sn)
.mobileBlueMac(mobileMac)
......@@ -248,14 +247,10 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
.autoSenseStatus(autoSenseStatus)
.createTime(new Date())
.build();
if(CollectionUtils.isNotEmpty(blueKeys))
blueSense.setCarKeyId(blueKeys.get(0).getId());
smartKeyBlueSenseService.insert(blueSense);
} else {
//存在,更新感应状态
blueSense = blueSenseList.get(0);
SmartKeyBlueSense blueSense = blueSenseList.get(0);
blueSense.setAutoSenseStatus(autoSenseStatus);
blueSense.setCreateTime(new Date());
smartKeyBlueSenseService.updateByPrimaryKeySelective(blueSense);
......@@ -268,10 +263,12 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
@Override
public R getAllKeyByUser(SmartCarKeyUserRequest request) {
long userId = Long.valueOf(request.getUserId());
//根据用户id查询车钥匙
SmartVehicleBlueKeyExample example = new SmartVehicleBlueKeyExample();
example.createCriteria()
.andUserIdEqualTo(userId)
.andIsDeleteEqualTo(0);
List<SmartVehicleBlueKey> keyList = smartVehicleBlueKeyService.selectByExample(example);
//如果没有数据直接返回
if (CollectionUtils.isEmpty(keyList)) {
......@@ -305,7 +302,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
throw new BusinessException(ResultEnum.CAR_KEY_EXCEP_13);
}
//拷贝属性
//拷贝属性
BeanUtils.copyProperties(key, response);
response.setCrepCode(crep_encrypt);
......@@ -322,14 +319,16 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
.forEach(key -> key.setKeyName("钥匙" + num.getAndIncrement()));
//根据用户查询蓝牙,感应列表
SmartKeyBlueSenseExample blueSenseExampl = new SmartKeyBlueSenseExample();
//根据用户钥匙id,查询蓝牙,感应列表
List<Long> carKeyIds = keyList.stream().map(SmartVehicleBlueKey::getId).collect(Collectors.toList());
List<SmartKeyBlueSense> smartKeyBlueSenseList = smartKeyBlueSenseService.getByCarKeyIds(carKeyIds);
/*SmartKeyBlueSenseExample blueSenseExampl = new SmartKeyBlueSenseExample();
blueSenseExampl.createCriteria()
.andUserIdEqualTo(userId)
.andCarKeyIdIn(carKeyIds)
.andIsDeleteEqualTo(0);
List<SmartKeyBlueSense> smartKeyBlueSenseList = smartKeyBlueSenseService.selectByExample(blueSenseExampl);
*/
//如果用户下没有蓝牙记录
if (CollectionUtils.isEmpty(smartKeyBlueSenseList)) {
return R.ok().data(responseList);
......@@ -372,17 +371,19 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
long userId = Long.valueOf(request.getUserId());
String sn = request.getSn();
//查询钥匙
List<SmartVehicleBlueKey> keys =smartVehicleBlueKeyService.selectByExample(getBlueKeyExampleBysn(userId,sn));
List<SmartVehicleBlueKey> keys = smartVehicleBlueKeyService.selectByExample(getBlueKeyExampleByUserAndSn(userId, sn));
if(CollectionUtils.isEmpty(keys))
if (CollectionUtils.isEmpty(keys))
return R.ok().data("");
SmartKeyBlueSenseExample example = getBlueSenseExampleBysn(userId,sn);
//根据钥匙id查蓝牙信息
long carKeyId = keys.get(0).getId();
SmartKeyBlueSenseExample example = getBlueSenseExampleByCarKeyID(carKeyId);
List<SmartKeyBlueSense> datas = smartKeyBlueSenseService.selectByExample(example);
return R.ok().data(datas);
}
//智能车钥匙注册成功后的数据保存
@Override
public R saveLockingKeyRegisterInfo(SmartCarKeyRegisterRequest request) {
......@@ -421,41 +422,42 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
SmartVehicleBlueKey smartVehicleBlueKey = smartVehicleBlueKeyList.get(0);
String mobileMac = request.getMobileMac();
if (StringUtils.isNotBlank(mobileMac)) {
try {
SmartKeyBlueSenseExample blueSenseExample = new SmartKeyBlueSenseExample();
blueSenseExample.createCriteria()
.andUserIdEqualTo(smartVehicleBlueKey.getUserId())
.andSnEqualTo(smartVehicleBlueKey.getSn())
.andMobileBlueMacEqualTo(mobileMac)
.andIsDeleteEqualTo(0);
List<SmartKeyBlueSense> list = smartKeyBlueSenseService.selectByExample(blueSenseExample);
if (CollectionUtils.isEmpty(list)) {
//如果手机mac不存在,新增
SmartKeyBlueSense blueSense = SmartKeyBlueSense.builder()
.carKeyId(smartVehicleBlueKey.getId())
.userId(smartVehicleBlueKey.getUserId())
.sn(smartVehicleBlueKey.getSn())
.mobileBlueMac(mobileMac)
.createTime(new Date())
.isDelete(0)
.autoSenseStatus(0)
.build();
//新增车钥匙手机蓝牙mac,自动感应状态
smartKeyBlueSenseService.insert(blueSense);
} else {
SmartKeyBlueSense blueSense = list.get(0);
blueSense.setMobileBlueMac(mobileMac);
blueSense.setCarKeyId(smartVehicleBlueKey.getId());
//更新车钥匙手机蓝牙mac,自动感应状态
smartKeyBlueSenseService.updateByPrimaryKeySelective(blueSense);
}
} catch (Exception e) {
throw new BusinessException(ResultEnum.CAR_KEY_EXCEP_9);
if (StringUtils.isBlank(mobileMac))
return R.error("手机蓝牙不能为空");
try {
//查询该钥匙下手机mac是否存在
SmartKeyBlueSenseExample blueSenseExample = new SmartKeyBlueSenseExample();
blueSenseExample.createCriteria()
.andCarKeyIdEqualTo(smartVehicleBlueKey.getId())
.andMobileBlueMacEqualTo(mobileMac)
.andIsDeleteEqualTo(0);
List<SmartKeyBlueSense> list = smartKeyBlueSenseService.selectByExample(blueSenseExample);
if (CollectionUtils.isEmpty(list)) {
//如果该钥匙下手机mac不存在,新增
SmartKeyBlueSense blueSense = SmartKeyBlueSense.builder()
.carKeyId(smartVehicleBlueKey.getId())
.userId(smartVehicleBlueKey.getUserId())
.sn(smartVehicleBlueKey.getSn())
.mobileBlueMac(mobileMac)
.createTime(new Date())
.isDelete(0)
.autoSenseStatus(0)
.build();
smartKeyBlueSenseService.insert(blueSense);
} else {
//存在则刷新时间
SmartKeyBlueSense blueSense = list.get(0);
blueSense.setCreateTime(new Date());
smartKeyBlueSenseService.updateByPrimaryKeySelective(blueSense);
}
} catch (Exception e) {
throw new BusinessException(ResultEnum.CAR_KEY_EXCEP_9);
}
//更新车钥匙注册信息
smartVehicleBlueKey.setSmartLockMac(request.getSmartLockMac());
smartVehicleBlueKey.setMobileCode(request.getMobileCode());
......@@ -534,8 +536,8 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
response.setCrepCode(crep_encrypt);
response.setSecretKey(secret_key_encrypt);
//userID查询关联的手机蓝牙mac,自动感应状态
SmartKeyBlueSense smartKeyBlueSense = getMobileBlueSenseByUser(carkey.getUserId(), carkey.getSn());
//CarKeyID查询关联的手机蓝牙mac,自动感应状态
SmartKeyBlueSense smartKeyBlueSense = getRecentBlueSenseByCarKeyID(carkey.getId());
if (null == smartKeyBlueSense)
return;
......@@ -543,9 +545,8 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
response.setAutoSenseStatus(smartKeyBlueSense.getAutoSenseStatus());
}
//查询车钥匙example,根据用户ID和sn查
private SmartVehicleBlueKeyExample getBlueKeyExampleBysn(Long userId, String sn) {
private SmartVehicleBlueKeyExample getBlueKeyExampleByUserAndSn(Long userId, String sn) {
SmartVehicleBlueKeyExample example = new SmartVehicleBlueKeyExample();
example.createCriteria()
.andUserIdEqualTo(userId)
......@@ -555,18 +556,17 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
}
//查询车钥匙手机蓝牙,感应状态example,根据用户ID和sn查
private SmartKeyBlueSenseExample getBlueSenseExampleBysn(Long userId, String sn) {
private SmartKeyBlueSenseExample getBlueSenseExampleByCarKeyID(Long carKeyId) {
SmartKeyBlueSenseExample example = new SmartKeyBlueSenseExample();
example.createCriteria()
.andUserIdEqualTo(userId)
.andSnEqualTo(sn)
.andCarKeyIdEqualTo(carKeyId)
.andIsDeleteEqualTo(0);
return example;
}
private SmartKeyBlueSense getMobileBlueSenseByUser(Long userId, String sn) {
SmartKeyBlueSenseExample example = getBlueSenseExampleBysn(userId, sn);
//查询车钥匙最近的蓝牙感应信息
private SmartKeyBlueSense getRecentBlueSenseByCarKeyID(Long carKeyId) {
SmartKeyBlueSenseExample example = getBlueSenseExampleByCarKeyID(carKeyId);
List<SmartKeyBlueSense> smartKeyBlueSenseList = smartKeyBlueSenseService.selectByExample(example);
return getRecentBlueMacAutoSense(smartKeyBlueSenseList);
}
......
......@@ -69,6 +69,10 @@ public class SmartKeyBlueSenseServiceImpl implements SmartKeyBlueSenseService {
return smartKeyBlueSenseMapper.updateByPrimaryKey(record);
}
@Override
public List<SmartKeyBlueSense> getByCarKeyIds(List<Long> ids) {
return smartKeyBlueSenseMapper.getByCarKeyIds(ids);
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.glsx.smart.dao.mapper.SmartKeyBlueSenseMapper">
<resultMap id="BaseResultMap" type="com.glsx.smart.dao.entity.SmartKeyBlueSense">
<!--@mbg.generated-->
<!--@Table smart_key_blue_sense-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="sn" jdbcType="VARCHAR" property="sn" />
<result column="auto_sense_status" jdbcType="TINYINT" property="autoSenseStatus" />
<result column="mobile_blue_mac" jdbcType="VARCHAR" property="mobileBlueMac" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="is_delete" jdbcType="TINYINT" property="isDelete" />
<result column="car_key_id" jdbcType="BIGINT" property="carKeyId" />
</resultMap>
<sql id="Example_Where_Clause">
<!--@mbg.generated-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<!-- <when test="criterion.listValue">-->
<!-- and ${criterion.condition}-->
<!-- <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">-->
<!-- #{listItem}-->
<!-- </foreach>-->
<!-- </when>-->
</choose>
<resultMap id="BaseResultMap" type="com.glsx.smart.dao.entity.SmartKeyBlueSense">
<!--@mbg.generated-->
<!--@Table smart_key_blue_sense-->
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="user_id" jdbcType="BIGINT" property="userId"/>
<result column="sn" jdbcType="VARCHAR" property="sn"/>
<result column="auto_sense_status" jdbcType="TINYINT" property="autoSenseStatus"/>
<result column="mobile_blue_mac" jdbcType="VARCHAR" property="mobileBlueMac"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="is_delete" jdbcType="TINYINT" property="isDelete"/>
<result column="car_key_id" jdbcType="BIGINT" property="carKeyId"/>
</resultMap>
<sql id="Example_Where_Clause">
<!--@mbg.generated-->
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<!-- <when test="criterion.listValue">-->
<!-- and ${criterion.condition}-->
<!-- <foreach close=")" collection="criterion.value" item="listItem" open="("-->
<!-- separator=",">-->
<!-- #{listItem}-->
<!-- </foreach>-->
<!-- </when>-->
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--@mbg.generated-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<!-- <when test="criterion.listValue">-->
<!-- and ${criterion.condition}-->
<!-- <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">-->
<!-- #{listItem}-->
<!-- </foreach>-->
<!-- </when>-->
</choose>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<!--@mbg.generated-->
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<!-- <when test="criterion.listValue">-->
<!-- and ${criterion.condition}-->
<!-- <foreach close=")" collection="criterion.value" item="listItem" open="("-->
<!-- separator=",">-->
<!-- #{listItem}-->
<!-- </foreach>-->
<!-- </when>-->
</choose>
</foreach>
</trim>
</if>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, user_id, sn, auto_sense_status, mobile_blue_mac, create_time, is_delete, car_key_id
</sql>
<select id="selectByExample" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSenseExample" resultMap="BaseResultMap">
<!--@mbg.generated-->
</where>
</sql>
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, user_id, sn, auto_sense_status, mobile_blue_mac, create_time, is_delete, car_key_id
</sql>
<select id="selectByExample" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSenseExample"
resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<if test="distinct">
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
</if>
<include refid="Base_Column_List"/>
from smart_key_blue_sense
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
<include refid="Base_Column_List"/>
from smart_key_blue_sense
where id = #{id,jdbcType=BIGINT}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--@mbg.generated-->
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
<!--@mbg.generated-->
delete from smart_key_blue_sense
where id = #{id,jdbcType=BIGINT}
</delete>
<delete id="deleteByExample" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSenseExample">
<!--@mbg.generated-->
</delete>
<delete id="deleteByExample" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSenseExample">
<!--@mbg.generated-->
delete from smart_key_blue_sense
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSense" useGeneratedKeys="true">
<!--@mbg.generated-->
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSense"
useGeneratedKeys="true">
<!--@mbg.generated-->
insert into smart_key_blue_sense (user_id, sn, auto_sense_status,
mobile_blue_mac, create_time, is_delete,
car_key_id)
values (#{userId,jdbcType=BIGINT}, #{sn,jdbcType=VARCHAR}, #{autoSenseStatus,jdbcType=TINYINT},
#{mobileBlueMac,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{isDelete,jdbcType=TINYINT},
#{carKeyId,jdbcType=BIGINT})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSense" useGeneratedKeys="true">
<!--@mbg.generated-->
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id"
parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSense" useGeneratedKeys="true">
<!--@mbg.generated-->
insert into smart_key_blue_sense
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
</if>
<if test="sn != null">
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">
user_id,
</if>
<if test="sn != null">
sn,
</if>
<if test="autoSenseStatus != null">
</if>
<if test="autoSenseStatus != null">
auto_sense_status,
</if>
<if test="mobileBlueMac != null">
</if>
<if test="mobileBlueMac != null">
mobile_blue_mac,
</if>
<if test="createTime != null">
</if>
<if test="createTime != null">
create_time,
</if>
<if test="isDelete != null">
</if>
<if test="isDelete != null">
is_delete,
</if>
<if test="carKeyId != null">
</if>
<if test="carKeyId != null">
car_key_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="sn != null">
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">
#{userId,jdbcType=BIGINT},
</if>
<if test="sn != null">
#{sn,jdbcType=VARCHAR},
</if>
<if test="autoSenseStatus != null">
</if>
<if test="autoSenseStatus != null">
#{autoSenseStatus,jdbcType=TINYINT},
</if>
<if test="mobileBlueMac != null">
</if>
<if test="mobileBlueMac != null">
#{mobileBlueMac,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="isDelete != null">
</if>
<if test="isDelete != null">
#{isDelete,jdbcType=TINYINT},
</if>
<if test="carKeyId != null">
</if>
<if test="carKeyId != null">
#{carKeyId,jdbcType=BIGINT},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSenseExample" resultType="java.lang.Long">
<!--@mbg.generated-->
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSenseExample"
resultType="java.lang.Long">
<!--@mbg.generated-->
select count(*) from smart_key_blue_sense
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--@mbg.generated-->
<if test="_parameter != null">
<include refid="Example_Where_Clause"/>
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
<!--@mbg.generated-->
update smart_key_blue_sense
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.userId != null">
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=BIGINT},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT},
</if>
<if test="record.sn != null">
</if>
<if test="record.sn != null">
sn = #{record.sn,jdbcType=VARCHAR},
</if>
<if test="record.autoSenseStatus != null">
</if>
<if test="record.autoSenseStatus != null">
auto_sense_status = #{record.autoSenseStatus,jdbcType=TINYINT},
</if>
<if test="record.mobileBlueMac != null">
</if>
<if test="record.mobileBlueMac != null">
mobile_blue_mac = #{record.mobileBlueMac,jdbcType=VARCHAR},
</if>
<if test="record.createTime != null">
</if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.isDelete != null">
</if>
<if test="record.isDelete != null">
is_delete = #{record.isDelete,jdbcType=TINYINT},
</if>
<if test="record.carKeyId != null">
</if>
<if test="record.carKeyId != null">
car_key_id = #{record.carKeyId,jdbcType=BIGINT},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--@mbg.generated-->
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByExample" parameterType="map">
<!--@mbg.generated-->
update smart_key_blue_sense
set id = #{record.id,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT},
......@@ -221,40 +443,104 @@
create_time = #{record.createTime,jdbcType=TIMESTAMP},
is_delete = #{record.isDelete,jdbcType=TINYINT},
car_key_id = #{record.carKeyId,jdbcType=BIGINT}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSense">
<!--@mbg.generated-->
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause"/>
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSense">
<!--@mbg.generated-->
update smart_key_blue_sense
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="sn != null">
<set>
<if test="userId != null">
user_id = #{userId,jdbcType=BIGINT},
</if>
<if test="sn != null">
sn = #{sn,jdbcType=VARCHAR},
</if>
<if test="autoSenseStatus != null">
</if>
<if test="autoSenseStatus != null">
auto_sense_status = #{autoSenseStatus,jdbcType=TINYINT},
</if>
<if test="mobileBlueMac != null">
</if>
<if test="mobileBlueMac != null">
mobile_blue_mac = #{mobileBlueMac,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="isDelete != null">
</if>
<if test="isDelete != null">
is_delete = #{isDelete,jdbcType=TINYINT},
</if>
<if test="carKeyId != null">
</if>
<if test="carKeyId != null">
car_key_id = #{carKeyId,jdbcType=BIGINT},
</if>
</set>
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSense">
<!--@mbg.generated-->
</update>
<update id="updateByPrimaryKey" parameterType="com.glsx.smart.dao.entity.SmartKeyBlueSense">
<!--@mbg.generated-->
update smart_key_blue_sense
set user_id = #{userId,jdbcType=BIGINT},
sn = #{sn,jdbcType=VARCHAR},
......@@ -264,5 +550,23 @@
is_delete = #{isDelete,jdbcType=TINYINT},
car_key_id = #{carKeyId,jdbcType=BIGINT}
where id = #{id,jdbcType=BIGINT}
</update>
</update>
<select id="getByCarKeyIds" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from smart_key_blue_sense where car_key_id in
<foreach collection="list" item="keyId" open="(" separator="," close=")" index="index">
#{keyId}
</foreach>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!