|
@ -10,20 +10,16 @@ import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.util.common.IdCardUtil;
|
|
|
import com.yihu.jw.util.date.DateUtil;
|
|
|
import com.yihu.jw.wlyy.wlyyhttp.WlyyHttpService;
|
|
|
import com.yihu.utils.security.MD5;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.http.NameValuePair;
|
|
|
import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* Created by Trick on 2019/8/21.
|
|
@ -134,34 +130,90 @@ public class WlyyBusinessService {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
public String getPatientCodeByWlyyIdcard(String idcard) {
|
|
|
/**
|
|
|
* 根据身份证获取i健康居民信息
|
|
|
* @param idcard
|
|
|
* @return
|
|
|
*/
|
|
|
public String getPatientCodeByWlyyIdcard(String idcard) throws Exception {
|
|
|
BasePatientDO patientDO = basePatientDao.findByIdcardAndDel(idcard,"1");
|
|
|
String result = "";
|
|
|
if(patientDO == null){
|
|
|
/**
|
|
|
* todo 调用i健康接口获取居民信息
|
|
|
*/
|
|
|
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("idcard",idcard);
|
|
|
|
|
|
JSONObject rs = wlyyHttpService.sendWlyyMes("wlyyGetPatient",null,params);
|
|
|
if(rs!=null){
|
|
|
Integer status = rs.getInteger("status");
|
|
|
if(200 == status){
|
|
|
JSONObject data = rs.getJSONObject("data");
|
|
|
BasePatientDO patient = new BasePatientDO();
|
|
|
String salt = UUID.randomUUID().toString().substring(0,5);
|
|
|
String mobile = data.getString("mobile");
|
|
|
String pw = null;
|
|
|
|
|
|
if(StringUtils.isNotBlank(mobile)){
|
|
|
pw = mobile.substring(mobile.length()-6);
|
|
|
}else{
|
|
|
pw = idcard.substring(idcard.length()-6);
|
|
|
}
|
|
|
|
|
|
patient.setIdcard(idcard);
|
|
|
patient.setName(data.getString("name"));
|
|
|
patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
|
|
|
patient.setSalt(salt);
|
|
|
patient.setMobile(mobile);
|
|
|
patient.setDel("1");
|
|
|
patient.setEnabled(1);
|
|
|
patient.setLocked(0);
|
|
|
patient.setCreateTime(new Date());
|
|
|
patient.setUpdateTime(new Date());
|
|
|
patient.setBirthday(DateUtil.strToDate(data.getString("birthday"),"yyyyMMdd"));
|
|
|
patient = basePatientDao.save(patient);
|
|
|
result = patient.getId();
|
|
|
}else{
|
|
|
throw new Exception("请求i健康接口,获取居民信息失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
|
|
|
result = patientDO.getId();
|
|
|
}
|
|
|
return patientDO.getId();
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* (健康咨询)转发消息
|
|
|
* @param senderIdcard
|
|
|
* @param reciverIdcard
|
|
|
* @param messageids
|
|
|
* @param title
|
|
|
* @param sessionType
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public Boolean wlyyMessageForward(String senderIdcard, String reciverIdcard, String messageids, String title, String sessionType) throws Exception {
|
|
|
|
|
|
Map<String,String> params = new HashMap<>();
|
|
|
params.put("senderIdcard",senderIdcard);
|
|
|
params.put("reciverIdcard",reciverIdcard);
|
|
|
params.put("messageids",messageids);
|
|
|
params.put("title",title);
|
|
|
params.put("sessionType",sessionType);
|
|
|
|
|
|
JSONObject rs = wlyyHttpService.sendWlyyMes("wlyyMessageForward",null,params);
|
|
|
if(rs!=null){
|
|
|
Integer status = rs.getInteger("status");
|
|
|
if(200 == status){
|
|
|
return true;
|
|
|
}else{
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
|
|
|
// public String getPatientInfo(String ){
|
|
|
// List<NameValuePair> params = new ArrayList<>();
|
|
|
// params.add(new BasicNameValuePair("clientId", getClientId()));
|
|
|
// ClientDetails clientDetails = clientDetailsService.loadClientByClientId(getClientId());
|
|
|
// params.add(new BasicNameValuePair("clientSecret", clientDetails.getClientSecret()));
|
|
|
// params.add(new BasicNameValuePair("code", username));
|
|
|
// params.add(new BasicNameValuePair("openid", getOpenid()));
|
|
|
// String res = null;
|
|
|
// try{
|
|
|
// res = httpClientUtil.post(getSynPath(getWechatId()), params, "UTF-8");
|
|
|
// }catch (Exception e){
|
|
|
// logger.error("远程请求i健康用户信息异常:" + e.getMessage());
|
|
|
// return users;
|
|
|
// }
|
|
|
// }
|
|
|
|
|
|
/**
|
|
|
* 根据居民CODE换取居民请求秘钥
|