Commit 7c70db33 by fz

1.车钥匙解绑,用户注销,小程序解绑,分享钥匙都设置为分享关闭

2.分享钥匙添加创建时间,停用时间
1 parent 04e0e86e
......@@ -49,7 +49,7 @@ public class SmartKeyBlueSense {
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
......
......@@ -45,7 +45,7 @@ public class SmartKeyCommandLog implements Serializable {
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
......
......@@ -39,7 +39,7 @@ public class SmartKeyCommandShareLog {
/**
* 下发时间
*/
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
......
......@@ -39,19 +39,29 @@ public class SmartShareKeyBlueKey{
private Long pickUserId;
/**
* 分享钥匙领取时间
* 分享状态 0:关闭 1:打开
*/
@DateTimeFormat(pattern="yyyy-MM-dd")
private Integer shareStatus;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd",
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date pickTime;
private Date createTime;
/**
* 分享状态 0:关闭 1:打开
* 领取时间
*/
private Integer shareStatus;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date pickTime;
/**
* 分享钥匙过期时间
......@@ -63,6 +73,16 @@ public class SmartShareKeyBlueKey{
)
private Date expireTime;
/**
* 停用时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date stopTime;
/*****************主钥匙********************/
/**
......@@ -111,16 +131,6 @@ public class SmartShareKeyBlueKey{
private Integer isDelete;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
/**
* 手机编号
*/
private String mobileCode;
......
......@@ -69,7 +69,7 @@ public class SmartVehicleBlueKey {
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy/MM/dd HH:mm:ss")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
......
......@@ -48,19 +48,29 @@ public class SmartVehicleBlueShareKey implements Comparable<SmartVehicleBlueShar
private Long pickUserId;
/**
* 分享钥匙领取时间
* 分享状态 1:打开 0:关闭
*/
@DateTimeFormat(pattern="yyyy-MM-dd")
private Integer shareStatus;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd",
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date pickTime;
private Date createTime;
/**
* 分享状态 0:关闭 1:打开
* 领取时间
*/
private Integer shareStatus;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date pickTime;
/**
* 分享钥匙过期时间
......@@ -72,8 +82,18 @@ public class SmartVehicleBlueShareKey implements Comparable<SmartVehicleBlueShar
)
private Date expireTime;
/**
* 停用时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date stopTime;
@Override
public int compareTo(SmartVehicleBlueShareKey o) {
public int compareTo(com.glsx.smart.dao.entity.SmartVehicleBlueShareKey o) {
Integer data = this.getShareStatus();
Integer data2 = o.getShareStatus();
if (null == data)
......
package com.glsx.smart.dao.mapper;
import com.glsx.smart.dao.entity.SmartShareKeyBlueKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKey;
import com.glsx.smart.dao.entity.SmartShareKeyBlueKey;import com.glsx.smart.dao.entity.SmartVehicleBlueShareKey;
import com.glsx.smart.dao.entity.SmartVehicleBlueShareKeyExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
......@@ -65,7 +64,9 @@ public interface SmartVehicleBlueShareKeyMapper {
*/
int updateByPrimaryKey(SmartVehicleBlueShareKey record);
int updateShareStatusByIds(List<Long> ids);
// int updateShareStatusByIds(List<Long> ids);
List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId);
int closeShareKeyByMainKeyIds(List<Long> keyIds);
}
\ No newline at end of file
......@@ -35,8 +35,14 @@ public interface SmartVehicleBlueShareKeyService {
SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByID(Long id);
int updateShareStatusByIds(List<Long> ids);
//int updateShareStatusByIds(List<Long> ids);
List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId);
int closeShareKeyByCarKeyId(Long carKeyId);
int closeShareKeyByMainKeyIds(List<Long> keyIds);
}
......@@ -106,11 +106,26 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
//智能车钥匙解绑
@Override
public R removeLockingKey(SmartCarKeyRequest request) {
//根据userid,sn查询主钥匙
SmartVehicleBlueKeyExample example = smartVehicleBlueKeyService.getBlueKeyExampleByUserAndSn(Long.valueOf(request.getUserId()), request.getSn());
List<SmartVehicleBlueKey> keyList = smartVehicleBlueKeyService.selectByExample(example);
if(CollectionUtils.isEmpty(keyList))
return R.ok();
SmartVehicleBlueKey blueKey = keyList.get(0);
//逻辑删除蓝牙车钥匙设备
SmartVehicleBlueKey smartVehicleBlueKey = new SmartVehicleBlueKey();
smartVehicleBlueKey.setIsDelete(1);
SmartVehicleBlueKeyExample example = smartVehicleBlueKeyService.getBlueKeyExampleByUserAndSn(Long.valueOf(request.getUserId()), request.getSn());
smartVehicleBlueKeyService.updateByExampleSelective(smartVehicleBlueKey, example);
smartVehicleBlueKeyService.updateByPrimaryKeySelective(smartVehicleBlueKey);
//主钥匙ID
long carKeyId = blueKey.getId();
//分享钥匙关闭
smartVehicleBlueShareKeyService.closeShareKeyByCarKeyId(carKeyId);
return R.ok();
}
......@@ -119,15 +134,31 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
@Override
public R removeKeysByUser(SmartCarKeyUserRequest request) {
try {
long userId =Long.valueOf(request.getUserId()) ;
SmartVehicleBlueKey smartVehicleBlueKey = new SmartVehicleBlueKey();
smartVehicleBlueKey.setIsDelete(1);
//逻辑删除蓝牙车钥匙设备
SmartVehicleBlueKeyExample example = new SmartVehicleBlueKeyExample();
example.createCriteria()
.andUserIdEqualTo(Long.valueOf(request.getUserId()))
.andUserIdEqualTo(userId)
.andIsDeleteEqualTo(0);
smartVehicleBlueKeyService.updateByExampleSelective(smartVehicleBlueKey, example);
List<SmartVehicleBlueKey> blueKeys = smartVehicleBlueKeyService.selectByExample(example);
List<Long> KeyIds = new ArrayList<>();
//钥匙的ID集合
if(CollectionUtils.isNotEmpty(blueKeys)){
KeyIds = blueKeys.stream().map(SmartVehicleBlueKey::getId).collect(Collectors.toList());
}
//逻辑删除主钥匙
smartVehicleBlueKeyService.updateByExampleSelective(smartVehicleBlueKey,example);
//主钥匙的分享钥匙关闭分享
if(CollectionUtils.isNotEmpty(KeyIds)){
smartVehicleBlueShareKeyService.closeShareKeyByMainKeyIds(KeyIds);
}
} catch (Exception e) {
return R.error(e.getMessage());
}
......@@ -597,12 +628,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
}
//主钥匙如果关闭,将所有共享钥匙设置为停止共享
SmartVehicleBlueShareKey shareKey = new SmartVehicleBlueShareKey();
shareKey.setShareStatus(0);
shareKey.setExpireTime(new Date());
SmartVehicleBlueShareKeyExample shareKeyExample = smartVehicleBlueShareKeyService.getBlueKeyShareExampleByCarKeyID(smartVehicleBlueKey.getId());
smartVehicleBlueShareKeyService.updateByExampleSelective(shareKey,shareKeyExample);
smartVehicleBlueShareKeyService.closeShareKeyByCarKeyId(smartVehicleBlueKey.getId());
return R.ok();
}
......@@ -631,6 +657,7 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
.sharePickStatus(0)
//分享状态默认打开
.shareStatus(1)
.createTime(new Date())
.expireTime(DateUtil.parse(expireTime, "yyyy-MM-dd"))
.build();
smartVehicleBlueShareKeyService.insert(shareKey);
......
......@@ -147,7 +147,7 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
//分享状态关闭
blueKey.setShareStatus(0);
//更新停止时间
blueKey.setExpireTime(new Date());
blueKey.setStopTime(new Date());
SmartVehicleBlueShareKeyExample example = shareKeyService.getBlueKeyShareExampleByID(keyId);
shareKeyService.updateByExampleSelective(blueKey, example);
return R.ok();
......@@ -162,31 +162,6 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
if (CollectionUtils.isEmpty(keyList))
return R.ok().data(null);
//校验过期时间
/* SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String nowTime = sdf.format(new Date());
Date expireDate = keyList.get(0).getExpireTime();
Date nowDate = null;
try {
nowDate = sdf.parse(nowTime);
} catch (ParseException e) {
e.printStackTrace();
throw new BusinessException(ResultEnum.CAR_KEY_EXCEP_15);
}
//如果当前时间已经超过过期时间
if (nowDate.after(expireDate)){
//修改为失效
SmartVehicleBlueShareKey blueKey = new SmartVehicleBlueShareKey();
//分享状态关闭
blueKey.setShareStatus(0);
SmartVehicleBlueShareKeyExample exampleDelete = shareKeyService.getBlueKeyShareExampleByID(Long.valueOf(keyid));
shareKeyService.updateByExampleSelective(blueKey, exampleDelete);
return R.ok().data(null);
}*/
return R.ok().data(keyList.get(0));
}
......@@ -203,40 +178,6 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
Assert.notNull(userId,"用户id不能为空");
List<SmartShareKeyBlueKey> keys = shareKeyService.getShareKeyListByUserId(userId);
//校验过期时间
/* SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String nowTime = sdf.format(new Date());
Date nowDate = null;
try {
nowDate = sdf.parse(nowTime);
} catch (ParseException e) {
e.printStackTrace();
return R.error("时间格式不对:yyyy-MM-dd");
}
List<SmartVehicleBlueShareKey> responseList = new ArrayList<>();
List<Long> expireList = new ArrayList<>();
//过期数据分类
Date finalNowDate = nowDate;
keys.stream().forEach(key -> {
Date expireDate = key.getExpireTime();
if (finalNowDate.after(expireDate)) {
expireList.add(key.getId());
//过期关闭
key.setShareStatus(0);
key.setExpireTime(new Date());
}else {
responseList.add(key);
}
});
//如果当前时间已经超过过期时间,更新数据
if (CollectionUtils.isNotEmpty(expireList)) {
shareKeyService.updateShareStatusByIds(expireList);
}*/
return R.ok().data(keys);
}
......@@ -245,13 +186,13 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
long keyShareID = Long.valueOf((String) claims.get("keyShareID"));
//是否已领取
boolean isReceive = isKeyReceive(keyShareID);
if(isReceive){
throw new BusinessException(ResultEnum.CAR_KEY_EXCEP_14);
}
//校验过期时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String nowTime = sdf.format(new Date());
......@@ -262,7 +203,6 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
throw new BusinessException(ResultEnum.CAR_KEY_EXCEP_15);
}
Date expireDate = shareKey.getExpireTime();
Date nowDate = null;
......
......@@ -7,6 +7,7 @@ import com.glsx.smart.dao.mapper.SmartVehicleBlueShareKeyMapper;
import com.glsx.smart.service.SmartVehicleBlueShareKeyService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
......@@ -96,14 +97,36 @@ public class SmartVehicleBlueShareKeyServiceImpl implements SmartVehicleBlueShar
return example;
}
//@Override
//public int updateShareStatusByIds(List<Long> ids) {
// return smartVehicleBlueShareKeyMapper.updateShareStatusByIds(ids);
//}
@Override
public int updateShareStatusByIds(List<Long> ids) {
return smartVehicleBlueShareKeyMapper.updateShareStatusByIds(ids);
public List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId) {
return smartVehicleBlueShareKeyMapper.getShareKeyListByUserId(userId);
}
@Override
public List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId) {
return smartVehicleBlueShareKeyMapper.getShareKeyListByUserId(userId);
public int closeShareKeyByCarKeyId(Long carKeyId) {
SmartVehicleBlueShareKey shareKey = new SmartVehicleBlueShareKey();
//关闭分享状态,更新过期时间
shareKey.setShareStatus(0);
shareKey.setStopTime(new Date());
SmartVehicleBlueShareKeyExample example = new SmartVehicleBlueShareKeyExample();
example.createCriteria()
.andCarKeyIdEqualTo(carKeyId)
.andShareStatusEqualTo(1);
return smartVehicleBlueShareKeyMapper.updateByExampleSelective(shareKey, example);
}
@Override
public int closeShareKeyByMainKeyIds(List<Long> keyIds) {
//关闭分享状态,更新过期时间
return smartVehicleBlueShareKeyMapper.closeShareKeyByMainKeyIds(keyIds);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!