Commit ed3a4057 by fz

1.添加车钥匙过期时间任务,关闭车钥匙分享状态

1 parent ca8255a2
Showing 14 changed files with 365 additions and 9 deletions
package cn.com.glsx.vasp.modules.entity;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;
/**
* 分享智能蓝牙车钥匙表
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "smart_vehicle_blue_share_key")
public class SmartVehicleBlueShareKey{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 车钥匙ID
*/
private Long carKeyId;
/**
* 令牌
*/
private String shareKeyToken;
/**
* 钥匙领取状态 0:未领取 1:已领取
*/
private Integer sharePickStatus;
/**
* 领取用户ID
*/
private Long pickUserId;
/**
* 分享状态 1:打开 0:关闭
*/
private Integer shareStatus;
/**
* 创建时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
/**
* 领取时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date pickTime;
/**
* 分享钥匙过期时间
*/
@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(
pattern = "yyyy-MM-dd",
timezone = "GMT+8"
)
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;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.vasp.modules.mapper;
import cn.com.glsx.vasp.modules.entity.SmartVehicleBlueShareKey;
import cn.com.glsx.vasp.modules.entity.SmartVehicleBlueShareKeyExample;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface SmartVehicleBlueShareKeyMapper {
long countByExample(SmartVehicleBlueShareKeyExample example);
int deleteByExample(SmartVehicleBlueShareKeyExample example);
/**
* delete by primary key
*
* @param id primaryKey
* @return deleteCount
*/
int deleteByPrimaryKey(Long id);
/**
* insert record to table
*
* @param record the record
* @return insert count
*/
int insert(SmartVehicleBlueShareKey record);
/**
* insert record to table selective
*
* @param record the record
* @return insert count
*/
int insertSelective(SmartVehicleBlueShareKey record);
List<SmartVehicleBlueShareKey> selectByExample(SmartVehicleBlueShareKeyExample example);
/**
* select by primary key
*
* @param id primary key
* @return object by primary key
*/
SmartVehicleBlueShareKey selectByPrimaryKey(Long id);
int updateByExampleSelective(@Param("record") SmartVehicleBlueShareKey record, @Param("example") SmartVehicleBlueShareKeyExample example);
int updateByExample(@Param("record") SmartVehicleBlueShareKey record, @Param("example") SmartVehicleBlueShareKeyExample example);
/**
* update record selective
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKeySelective(SmartVehicleBlueShareKey record);
/**
* update record
*
* @param record the updated record
* @return update count
*/
int updateByPrimaryKey(SmartVehicleBlueShareKey record);
}
\ No newline at end of file \ No newline at end of file
...@@ -10,7 +10,6 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -10,7 +10,6 @@ import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
......
package cn.com.glsx.smartdevice.job;
import cn.com.glsx.smartdevice.service.SmartVehicleBlueShareKeyService;
import cn.com.glsx.vasp.modules.entity.SmartVehicleBlueShareKey;
import cn.com.glsx.vasp.modules.entity.SmartVehicleBlueShareKeyExample;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* @author fengzhi
* @date 2021/5/01 10:57
* 定时任务处理车钥匙过期时间,关闭分享状态
*/
@Slf4j
@Component
@ElasticSimpleJob(jobName = "SmartCarKeyExpireTimeFixJob",cron="1/59 * * * * ?")
public class SmartCarKeyExpireTimeFixJob implements SimpleJob {
@Autowired
private SmartVehicleBlueShareKeyService shareKeyService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("Jobname==="+shardingContext.getJobName());
//定时每分钟执行,处理分享车钥匙过期时间数据
//将当前时间转为yyyy-MM-dd格式
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();
log.error("时间格式不对:yyyy-MM-dd");
}
//过期时间的数据更新状态为分享关闭
SmartVehicleBlueShareKey shareKey = new SmartVehicleBlueShareKey();
shareKey.setShareStatus(0);
shareKey.setStopTime(new Date());
//筛选过期时间小于当前日期的数据更新
SmartVehicleBlueShareKeyExample example = new SmartVehicleBlueShareKeyExample();
example.createCriteria()
.andExpireTimeLessThan(nowDate);
int count = shareKeyService.updateByExampleSelective(shareKey,example);
log.info("SmartCarKeyExpireTimeFixJob=======update count:"+count);
}
}
...@@ -2,7 +2,7 @@ package cn.com.glsx.smartdevice.job; ...@@ -2,7 +2,7 @@ package cn.com.glsx.smartdevice.job;
import cn.com.glsx.smartdevice.factory.Condition; import cn.com.glsx.smartdevice.factory.Condition;
import cn.com.glsx.smartdevice.service.SceneService; import cn.com.glsx.smartdevice.service.Impl.SceneService;
import com.dangdang.ddframe.job.api.ShardingContext; import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob; import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob; import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob;
......
package cn.com.glsx.smartdevice.job; package cn.com.glsx.smartdevice.job;
import cn.com.glsx.smartdevice.factory.Condition; import cn.com.glsx.smartdevice.factory.Condition;
import cn.com.glsx.smartdevice.service.SceneService; import cn.com.glsx.smartdevice.service.Impl.SceneService;
import com.dangdang.ddframe.job.api.ShardingContext; import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob; import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob; import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob;
......
package cn.com.glsx.smartdevice.job; package cn.com.glsx.smartdevice.job;
import cn.com.glsx.smartdevice.service.CheckDayService; import cn.com.glsx.smartdevice.service.Impl.CheckDayService;
import com.dangdang.ddframe.job.api.ShardingContext; import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob; import com.dangdang.ddframe.job.api.simple.SimpleJob;
import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob; import com.dangdang.elasticjob.lite.annotation.ElasticSimpleJob;
......
package cn.com.glsx.smartdevice.service; package cn.com.glsx.smartdevice.service.Impl;
import cn.com.glsx.smartdevice.Common.EMonth; import cn.com.glsx.smartdevice.Common.EMonth;
import cn.com.glsx.smartdevice.utils.HttpUtil; import cn.com.glsx.smartdevice.utils.HttpUtil;
......
package cn.com.glsx.smartdevice.service; package cn.com.glsx.smartdevice.service.Impl;
import cn.com.glsx.kafka.config.MqConfig; import cn.com.glsx.kafka.config.MqConfig;
import cn.com.glsx.kafka.producer.ScenseProducer; import cn.com.glsx.kafka.producer.ScenseProducer;
......
package cn.com.glsx.smartdevice.service.Impl;
import cn.com.glsx.smartdevice.service.SmartVehicleBlueShareKeyService;
import cn.com.glsx.vasp.modules.entity.SmartVehicleBlueShareKey;
import cn.com.glsx.vasp.modules.entity.SmartVehicleBlueShareKeyExample;
import cn.com.glsx.vasp.modules.mapper.SmartVehicleBlueShareKeyMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class SmartVehicleBlueShareKeyServiceImpl implements SmartVehicleBlueShareKeyService {
@Resource
private SmartVehicleBlueShareKeyMapper smartVehicleBlueShareKeyMapper;
@Override
public long countByExample(SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.countByExample(example);
}
@Override
public int deleteByExample(SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.deleteByExample(example);
}
@Override
public int deleteByPrimaryKey(Long id) {
return smartVehicleBlueShareKeyMapper.deleteByPrimaryKey(id);
}
@Override
public int insert(SmartVehicleBlueShareKey record) {
return smartVehicleBlueShareKeyMapper.insert(record);
}
@Override
public int insertSelective(SmartVehicleBlueShareKey record) {
return smartVehicleBlueShareKeyMapper.insertSelective(record);
}
@Override
public List<SmartVehicleBlueShareKey> selectByExample(SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.selectByExample(example);
}
@Override
public SmartVehicleBlueShareKey selectByPrimaryKey(Long id) {
return smartVehicleBlueShareKeyMapper.selectByPrimaryKey(id);
}
@Override
public int updateByExampleSelective(SmartVehicleBlueShareKey record, SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.updateByExampleSelective(record, example);
}
@Override
public int updateByExample(SmartVehicleBlueShareKey record, SmartVehicleBlueShareKeyExample example) {
return smartVehicleBlueShareKeyMapper.updateByExample(record, example);
}
@Override
public int updateByPrimaryKeySelective(SmartVehicleBlueShareKey record) {
return smartVehicleBlueShareKeyMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(SmartVehicleBlueShareKey record) {
return smartVehicleBlueShareKeyMapper.updateByPrimaryKey(record);
}
//查询分享车钥匙列表example,根据主钥匙ID查
@Override
public SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByCarKeyID(Long carKeyId) {
SmartVehicleBlueShareKeyExample example = new SmartVehicleBlueShareKeyExample();
example.setOrderByClause("`share_status` desc");
example.createCriteria()
.andCarKeyIdEqualTo(carKeyId)
//已领取
.andSharePickStatusEqualTo(1);
return example;
}
//查询分享车钥匙example,根据分享钥匙ID查
@Override
public SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByID(Long id) {
SmartVehicleBlueShareKeyExample example = new SmartVehicleBlueShareKeyExample();
example.createCriteria()
.andIdEqualTo(id)
//已领取
.andSharePickStatusEqualTo(1)
//分享状态打开
.andShareStatusEqualTo(1);
return example;
}
}
package cn.com.glsx.smartdevice.service;
import cn.com.glsx.vasp.modules.entity.SmartVehicleBlueShareKey;
import cn.com.glsx.vasp.modules.entity.SmartVehicleBlueShareKeyExample;
import java.util.List;
public interface SmartVehicleBlueShareKeyService {
long countByExample(SmartVehicleBlueShareKeyExample example);
int deleteByExample(SmartVehicleBlueShareKeyExample example);
int deleteByPrimaryKey(Long id);
int insert(SmartVehicleBlueShareKey record);
int insertSelective(SmartVehicleBlueShareKey record);
List<SmartVehicleBlueShareKey> selectByExample(SmartVehicleBlueShareKeyExample example);
SmartVehicleBlueShareKey selectByPrimaryKey(Long id);
int updateByExampleSelective(SmartVehicleBlueShareKey record, SmartVehicleBlueShareKeyExample example);
int updateByExample(SmartVehicleBlueShareKey record, SmartVehicleBlueShareKeyExample example);
int updateByPrimaryKeySelective(SmartVehicleBlueShareKey record);
int updateByPrimaryKey(SmartVehicleBlueShareKey record);
SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByCarKeyID(Long carKeyId);
SmartVehicleBlueShareKeyExample getBlueKeyShareExampleByID(Long id);
}
...@@ -6,9 +6,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -6,9 +6,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import java.util.stream.Collectors;
@RestController @RestController
public class TestController { public class TestController {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!