|
@ -5,12 +5,15 @@ import com.yihu.wlyy.entity.patient.PatientAimSports;
|
|
|
import com.yihu.wlyy.repository.patient.PatientAimSportsDao;
|
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
|
import com.yihu.wlyy.service.BaseService;
|
|
|
import com.yihu.wlyy.service.app.health.bank.TaskService;
|
|
|
import com.yihu.wlyy.util.SecretUtils;
|
|
|
import com.yihu.wlyy.util.http.HttpResponse;
|
|
|
import com.yihu.wlyy.util.http.HttpUtils;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
@ -28,6 +31,7 @@ import java.util.Map;
|
|
|
@Transactional
|
|
|
public class AppletsService extends BaseService {
|
|
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(AppletsService.class);
|
|
|
@Value("${applets.appId}")
|
|
|
private String appid;
|
|
|
@Value("${applets.appSecret}")
|
|
@ -38,6 +42,8 @@ public class AppletsService extends BaseService {
|
|
|
private PatientDao patientDao;
|
|
|
@Autowired
|
|
|
private PatientAimSportsDao patientAimSportsDao;
|
|
|
@Autowired
|
|
|
private TaskService taskService;
|
|
|
|
|
|
public Map<String, Object> checkApplets(String code) throws Exception {
|
|
|
HttpUtils httpUtils = new HttpUtils();
|
|
@ -50,6 +56,8 @@ public class AppletsService extends BaseService {
|
|
|
HttpResponse response = httpUtils.doGet("https://api.weixin.qq.com/sns/jscode2session", param);
|
|
|
JSONObject rs = new JSONObject(response.getContent());
|
|
|
Map<String, Object> res = new HashedMap();
|
|
|
logger.info("checkApplets:"+response.getContent());
|
|
|
|
|
|
res.put("openid", rs.getString("openid"));
|
|
|
res.put("sessionKey", rs.getString("session_key"));
|
|
|
res.put("unionid", rs.getString("unionid"));
|
|
@ -133,6 +141,15 @@ public class AppletsService extends BaseService {
|
|
|
patientAimSportsDao.save(patientAimSports);
|
|
|
}
|
|
|
|
|
|
//上传步数记录
|
|
|
try{
|
|
|
com.alibaba.fastjson.JSONObject json = new com.alibaba.fastjson.JSONObject();
|
|
|
json.put("patientId",patient);
|
|
|
json.put("taskCode","ACTIVITY_STEP");
|
|
|
taskService.createActiveRecord(json);
|
|
|
}catch (Exception e){
|
|
|
logger.info(e.toString());
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|