|
|
@ -1,9 +1,16 @@ |
|
|
package com.ccsens.health.service; |
|
|
package com.ccsens.health.service; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
|
import com.ccsens.health.bean.po.HealthRecords; |
|
|
|
|
|
import com.ccsens.health.bean.vo.HealthVo; |
|
|
|
|
|
import com.ccsens.health.util.HealthConstant; |
|
|
import com.ccsens.util.PropUtil; |
|
|
import com.ccsens.util.PropUtil; |
|
|
|
|
|
import com.ccsens.util.RedisUtil; |
|
|
import com.ccsens.util.WebConstant; |
|
|
import com.ccsens.util.WebConstant; |
|
|
import com.ccsens.util.wx.WxXcxUtil; |
|
|
import com.ccsens.util.wx.WxXcxUtil; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
import org.springframework.scheduling.annotation.Async; |
|
|
import org.springframework.scheduling.annotation.AsyncResult; |
|
|
import org.springframework.scheduling.annotation.AsyncResult; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
@ -11,6 +18,7 @@ import org.springframework.transaction.annotation.Propagation; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
import javax.annotation.Resource; |
|
|
|
|
|
import java.util.Calendar; |
|
|
import java.util.concurrent.Future; |
|
|
import java.util.concurrent.Future; |
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@ -18,12 +26,14 @@ import java.util.concurrent.Future; |
|
|
@Service |
|
|
@Service |
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
|
|
public class AsyncService implements IAsyncService { |
|
|
public class AsyncService implements IAsyncService { |
|
|
|
|
|
@Resource |
|
|
|
|
|
private RedisUtil redisUtil; |
|
|
@Resource |
|
|
@Resource |
|
|
private IStudentService studentService; |
|
|
private IStudentService studentService; |
|
|
@Resource |
|
|
@Resource |
|
|
private IJourneyService journeyService; |
|
|
private IJourneyService journeyService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Future<String> generateQRCode(String scene, WxXcxUtil.LineColor color) throws Exception { |
|
|
public Future<String> generateQRCode(String scene, WxXcxUtil.LineColor color) throws Exception { |
|
|
log.info("生成二维码:{}, {}", scene, color); |
|
|
log.info("生成二维码:{}, {}", scene, color); |
|
|
@ -45,4 +55,18 @@ public class AsyncService implements IAsyncService { |
|
|
public void updateStudentNum() { |
|
|
public void updateStudentNum() { |
|
|
studentService.updateStudentNum(); |
|
|
studentService.updateStudentNum(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void saveHealthRecordWithRedis(HealthVo.HealthInfo healthRecords) { |
|
|
|
|
|
HealthVo.HealthRecordRedis healthRecordRedis = new HealthVo.HealthRecordRedis(); |
|
|
|
|
|
BeanUtil.copyProperties(healthRecords,healthRecordRedis); |
|
|
|
|
|
String key = HealthConstant.getHealthRecordKey(healthRecordRedis.getUserId()); |
|
|
|
|
|
//过期时间
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
calendar.set(calendar.get(Calendar.YEAR),calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH),23,59,59); |
|
|
|
|
|
long tt = calendar.getTime().getTime()/1000; |
|
|
|
|
|
long seconds = tt - System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
redisUtil.set(key, JSONObject.toJSONString(healthRecordRedis),seconds); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|