|
@ -6,11 +6,18 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.xxpt.gateway.shared.client.http.ExecutableClient;
|
|
|
import com.alibaba.xxpt.gateway.shared.client.http.GetClient;
|
|
|
import com.alibaba.xxpt.gateway.shared.client.http.PostClient;
|
|
|
import com.yihu.jw.doctor.dao.BaseDoctorDao;
|
|
|
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 阿里巴巴钉钉工具类
|
|
@ -39,6 +46,11 @@ public class DingdingUtil {
|
|
|
//executableClient要单例,并且使用前要初始化,只需要初始化一次
|
|
|
private static ExecutableClient executableClient = null;
|
|
|
|
|
|
@Autowired
|
|
|
private BaseDoctorDao doctorDao;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@PostConstruct
|
|
|
public void clientInit(){
|
|
|
if(executableClient == null){
|
|
@ -100,7 +112,7 @@ public class DingdingUtil {
|
|
|
* @param mobiles
|
|
|
* @return
|
|
|
*/
|
|
|
public static JSONArray get_by_mobiles(String mobiles){
|
|
|
public JSONArray get_by_mobiles(String mobiles){
|
|
|
//调用API
|
|
|
PostClient postClient = executableClient.newPostClient(get_by_mobiles);
|
|
|
//设置参数
|
|
@ -123,6 +135,44 @@ public class DingdingUtil {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 初始化更新钉钉账户id
|
|
|
*/
|
|
|
public void yktDoctorIdInit(){
|
|
|
String sql = "select * from base_doctor where ykt_doctor_id is null limit 50";
|
|
|
List<BaseDoctorDO> doctorDOList = jdbcTemplate.query(sql,new BeanPropertyRowMapper(BaseDoctorDO.class));
|
|
|
List<BaseDoctorDO> doctorDOs = new ArrayList<>();
|
|
|
for (BaseDoctorDO doctorDO:doctorDOList){
|
|
|
JSONArray jsonArray = get_by_mobiles(doctorDO.getMobile());
|
|
|
if(jsonArray!=null&&jsonArray.size()>0){
|
|
|
long accountId = jsonArray.getJSONObject(0).getLong("accountId");
|
|
|
doctorDO.setYktDoctorId(accountId+"");
|
|
|
doctorDOs.add(doctorDO);
|
|
|
}
|
|
|
}
|
|
|
if(doctorDOs.size()>0){
|
|
|
doctorDao.save(doctorDOs);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新单个钉钉账户id
|
|
|
* @param mobile
|
|
|
*/
|
|
|
public void updYktDoctorId(String mobile){
|
|
|
List<BaseDoctorDO> doctorDOs = doctorDao.findByMobile(mobile);
|
|
|
if(doctorDOs.size()>0){
|
|
|
BaseDoctorDO doctorDO = doctorDOs.get(0);
|
|
|
JSONArray jsonArray = get_by_mobiles(doctorDO.getMobile());
|
|
|
if(jsonArray!=null&&jsonArray.size()>0){
|
|
|
long accountId = jsonArray.getJSONObject(0).getLong("accountId");
|
|
|
doctorDO.setYktDoctorId(accountId+"");
|
|
|
doctorDao.save(doctorDOs);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
public String getuserinfo_bycode(String code){
|
|
|
//调用API
|
|
|
PostClient postClient = executableClient.newPostClient(getuserinfo_bycode);
|
|
@ -143,13 +193,4 @@ public class DingdingUtil {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
|
|
|
// public static void main(String[] args) {
|
|
|
// String mobiles = "13559485270,15859634562";
|
|
|
// System.out.println(get_by_mobiles(mobiles));
|
|
|
// getuserinfo_bycode("f826c1a762a54ce6abb01c74dcc3ec000c89b501");
|
|
|
//
|
|
|
// dingtalk_app_user("f826c1a762a54ce6abb01c74dcc3ec000c89b501");
|
|
|
// }
|
|
|
|
|
|
}
|