|
@ -4,21 +4,24 @@ import com.yihu.wlyy.entity.patient.Patient;
|
|
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
|
|
import com.yihu.wlyy.entity.patient.PatientFamilyMember;
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
import com.yihu.wlyy.entity.patient.SignFamily;
|
|
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
|
|
import com.yihu.wlyy.entity.patient.invitation.PatientInvitationLog;
|
|
|
|
import com.yihu.wlyy.entity.security.AccessToken;
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
import com.yihu.wlyy.repository.patient.PatientDao;
|
|
import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
|
|
import com.yihu.wlyy.repository.patient.PatientFamilyMemberDao;
|
|
import com.yihu.wlyy.repository.patient.PatientInvitationLogDao;
|
|
import com.yihu.wlyy.repository.patient.PatientInvitationLogDao;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.service.BaseService;
|
|
import com.yihu.wlyy.service.app.sign.FamilyContractService;
|
|
import com.yihu.wlyy.service.app.sign.FamilyContractService;
|
|
import com.yihu.wlyy.service.common.SMSService;
|
|
import com.yihu.wlyy.service.common.SMSService;
|
|
|
|
import com.yihu.wlyy.service.common.account.AccessTokenService;
|
|
|
|
import com.yihu.wlyy.util.HttpUtil;
|
|
import com.yihu.wlyy.util.IdCardUtil;
|
|
import com.yihu.wlyy.util.IdCardUtil;
|
|
import com.yihu.wlyy.util.MD5;
|
|
import com.yihu.wlyy.util.MD5;
|
|
|
|
import com.yihu.wlyy.util.SystemConf;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONArray;
|
|
import org.json.JSONObject;
|
|
import org.json.JSONObject;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
@ -43,6 +46,9 @@ public class FamilyMemberService extends BaseService {
|
|
private PatientInvitationLogDao patientInviteLogDao;
|
|
private PatientInvitationLogDao patientInviteLogDao;
|
|
@Autowired
|
|
@Autowired
|
|
FamilyContractService contractService;
|
|
FamilyContractService contractService;
|
|
|
|
@Autowired
|
|
|
|
private AccessTokenService accessTokenService;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
JdbcTemplate jdbcTemplate;
|
|
JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@ -140,7 +146,8 @@ public class FamilyMemberService extends BaseService {
|
|
|
|
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
public int addMember(Patient p, String member,int type) throws Exception{
|
|
|
|
|
|
|
|
|
|
public int addMember(Patient p, String member, int type) throws Exception {
|
|
if (p.getCode().equals(member)) {
|
|
if (p.getCode().equals(member)) {
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
@ -368,9 +375,9 @@ public class FamilyMemberService extends BaseService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
public JSONArray getPatientMembers(String patient, String doctorCode, boolean isContain, String current) {
|
|
public JSONArray getPatientMembers(String patient, String doctorCode, boolean isContain, String current) {
|
|
JSONArray resultArray = getPatientFamilyMembers(patient,doctorCode);
|
|
|
|
|
|
JSONArray resultArray = getPatientFamilyMembers(patient, doctorCode);
|
|
|
|
|
|
if(resultArray == null){
|
|
|
|
|
|
if (resultArray == null) {
|
|
resultArray = new JSONArray();
|
|
resultArray = new JSONArray();
|
|
}
|
|
}
|
|
|
|
|
|
@ -487,4 +494,108 @@ public class FamilyMemberService extends BaseService {
|
|
|
|
|
|
return relationTrans;
|
|
return relationTrans;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 验证添加的家庭成员
|
|
|
|
*
|
|
|
|
* @param code 用于查询openId
|
|
|
|
* @param menber 预绑定成员
|
|
|
|
* @return 0未绑定微信,1仅绑定微信,2仅绑定手机,3手机微信都绑定
|
|
|
|
*/
|
|
|
|
public JSONObject checkFamilyMember(String code, String menber,String sus) throws Exception {
|
|
|
|
|
|
|
|
JSONObject r = new JSONObject();
|
|
|
|
|
|
|
|
//未绑定微信,未绑定手机
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
//1.判断微信过滤
|
|
|
|
//判断是否绑定微信,如果版绑定了微信,将状态改变为 1
|
|
|
|
if(sus.equals("1")){
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//2.判断手机过滤
|
|
|
|
//判断是否绑定了手机
|
|
|
|
Patient p = patientDao.findByCode(menber);
|
|
|
|
if(StringUtils.isNoneBlank(p.getMobile())){
|
|
|
|
//如果用户绑定了微信,将状态更改为4
|
|
|
|
if(result == 1){
|
|
|
|
result = 3;
|
|
|
|
//如果用户未绑定微信,将状态更改为2
|
|
|
|
}else if(result == 0){
|
|
|
|
result = 2 ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//返回过滤后的状态
|
|
|
|
r.put("state",result);
|
|
|
|
if(result==0){
|
|
|
|
r.put("mes","未绑定微信和手机");
|
|
|
|
}else if(result==1){
|
|
|
|
r.put("mes","仅绑定微信");
|
|
|
|
}else if(result==2){
|
|
|
|
r.put("mes","仅绑定手机");
|
|
|
|
}else if(result==3){
|
|
|
|
r.put("mes","手机和微信皆绑定");
|
|
|
|
}
|
|
|
|
|
|
|
|
return r;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 获取微信的access_token
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String getAccessToken() throws Exception {
|
|
|
|
Iterable<AccessToken> accessTokens = accessTokenService.findAccessToken();
|
|
|
|
if (accessTokens != null) {
|
|
|
|
for (AccessToken accessToken : accessTokens) {
|
|
|
|
if ((System.currentTimeMillis() - accessToken.getAdd_timestamp()) < (accessToken.getExpires_in() * 1000)) {
|
|
|
|
return accessToken.getAccess_token();
|
|
|
|
} else {
|
|
|
|
accessTokenService.delAccessToken(accessToken);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String token_url = "https://api.weixin.qq.com/cgi-bin/token";
|
|
|
|
String params = "grant_type=client_credential&appid=" + SystemConf.getInstance().getAppId() + "&secret=" + SystemConf.getInstance().getAppSecret();
|
|
|
|
String result = HttpUtil.sendGet(token_url, params);
|
|
|
|
JSONObject json = new JSONObject(result);
|
|
|
|
if (json.has("access_token")) {
|
|
|
|
String token = json.get("access_token").toString();
|
|
|
|
String expires_in = json.get("expires_in").toString();
|
|
|
|
AccessToken newaccessToken = new AccessToken();
|
|
|
|
newaccessToken.setAccess_token(token);
|
|
|
|
newaccessToken.setExpires_in(Long.parseLong(expires_in));
|
|
|
|
accessTokenService.addAccessToken(newaccessToken);
|
|
|
|
return token;
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 查询所有待处理列表
|
|
|
|
* @param code
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public JSONObject getFamilyMesList(String code){
|
|
|
|
JSONObject result = new JSONObject();
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(getFamilyMesListSql(code));
|
|
|
|
result.put("mes",list);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getFamilyMesListSql(String code){
|
|
|
|
StringBuffer sql = new StringBuffer("SELECT t.*,p.idcard,p.mobile FROM wlyy_patient_family_temp t,wlyy_patient p WHERE t.patient = p.code AND t.dealer ="+code);
|
|
|
|
return sql.toString();
|
|
|
|
}
|
|
}
|
|
}
|