Commit aca1bd05 by fz

1.获取分享钥匙列表,获取单个分享钥匙判断过期时间,关闭分享状态

1 parent 2dc61cb8
...@@ -64,7 +64,7 @@ public interface SmartVehicleBlueShareKeyMapper { ...@@ -64,7 +64,7 @@ public interface SmartVehicleBlueShareKeyMapper {
*/ */
int updateByPrimaryKey(SmartVehicleBlueShareKey record); int updateByPrimaryKey(SmartVehicleBlueShareKey record);
// int updateShareStatusByIds(List<Long> ids); int updateShareStatusByIds(List<Long> ids);
List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId); List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId);
......
...@@ -35,7 +35,7 @@ public interface SmartVehicleBlueShareKeyService { ...@@ -35,7 +35,7 @@ public interface SmartVehicleBlueShareKeyService {
SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByID(Long id); SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByID(Long id);
//int updateShareStatusByIds(List<Long> ids); int updateShareStatusByIds(List<Long> ids);
List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId); List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId);
......
...@@ -701,6 +701,37 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService { ...@@ -701,6 +701,37 @@ public class AiLockingKeyServiceImpl implements AiLockingKeyService {
SmartVehicleBlueShareKeyExample shareKeyExample = smartVehicleBlueShareKeyService.getBlueKeyShareExampleByCarKeyID(keyId.getId()); SmartVehicleBlueShareKeyExample shareKeyExample = smartVehicleBlueShareKeyService.getBlueKeyShareExampleByCarKeyID(keyId.getId());
List<SmartVehicleBlueShareKey> shareKeyList = smartVehicleBlueShareKeyService.selectByExample(shareKeyExample); List<SmartVehicleBlueShareKey> shareKeyList = smartVehicleBlueShareKeyService.selectByExample(shareKeyExample);
//校验过期时间
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<Long> expireList = new ArrayList<>();
//过期数据分类
Date finalNowDate = nowDate;
shareKeyList.stream().forEach(key -> {
Date expireDate = key.getExpireTime();
if (finalNowDate.after(expireDate)) {
expireList.add(key.getId());
//过期关闭
key.setShareStatus(0);
key.setStopTime(new Date());
}
});
//如果当前时间已经超过过期时间,更新数据
if (CollectionUtils.isNotEmpty(expireList)) {
smartVehicleBlueShareKeyService.updateShareStatusByIds(expireList);
}
//重新根据分享状态排序 //重新根据分享状态排序
if(CollectionUtils.isNotEmpty(shareKeyList) && shareKeyList.size()>1){ if(CollectionUtils.isNotEmpty(shareKeyList) && shareKeyList.size()>1){
return R.ok().data(PageInfo.of(shareKeyList.stream().sorted().collect(Collectors.toList()))); return R.ok().data(PageInfo.of(shareKeyList.stream().sorted().collect(Collectors.toList())));
......
...@@ -162,6 +162,31 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService { ...@@ -162,6 +162,31 @@ public class AiLockingKeyShareServiceImpl implements AiLockingKeyShareService {
if (CollectionUtils.isEmpty(keyList)) if (CollectionUtils.isEmpty(keyList))
return R.ok().data(null); 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)); return R.ok().data(keyList.get(0));
} }
......
...@@ -97,10 +97,10 @@ public class SmartVehicleBlueShareKeyServiceImpl implements SmartVehicleBlueShar ...@@ -97,10 +97,10 @@ public class SmartVehicleBlueShareKeyServiceImpl implements SmartVehicleBlueShar
return example; return example;
} }
//@Override @Override
//public int updateShareStatusByIds(List<Long> ids) { public int updateShareStatusByIds(List<Long> ids) {
// return smartVehicleBlueShareKeyMapper.updateShareStatusByIds(ids); return smartVehicleBlueShareKeyMapper.updateShareStatusByIds(ids);
//} }
@Override @Override
public List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId) { public List<SmartShareKeyBlueKey> getShareKeyListByUserId(Long userId) {
......
...@@ -421,16 +421,17 @@ ...@@ -421,16 +421,17 @@
</update> </update>
<!-- <update id="updateShareStatusByIds">--> <update id="updateShareStatusByIds">
<!-- update smart_vehicle_blue_share_key--> update smart_vehicle_blue_share_key
<!-- <set>--> <set>
<!-- share_status = 1--> stop_time = now(),
<!-- </set>--> share_status = 1
<!-- where id in--> </set>
<!-- <foreach close=")" collection="list" index="index" item="keyId" open="(" separator=",">--> where id in
<!-- #{keyId}--> <foreach close=")" collection="list" index="index" item="keyId" open="(" separator=",">
<!-- </foreach>--> #{keyId}
<!-- </update>--> </foreach>
</update>
<select id="getShareKeyListByUserId" resultMap="BaseMultiResultMap"> <select id="getShareKeyListByUserId" resultMap="BaseMultiResultMap">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!