|
@ -1,5 +1,6 @@
|
|
|
package com.yihu.wlyy.service.specialist.rehabilitation;
|
|
|
|
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
import com.yihu.wlyy.entity.doctor.profile.Doctor;
|
|
|
import com.yihu.wlyy.entity.message.Message;
|
|
|
import com.yihu.wlyy.entity.patient.Patient;
|
|
@ -14,6 +15,8 @@ import com.yihu.wlyy.service.specialist.SpecialistEvaluateSevice;
|
|
|
import com.yihu.wlyy.task.PushMsgTask;
|
|
|
import com.yihu.wlyy.util.DateUtil;
|
|
|
import com.yihu.wlyy.util.IdCardUtil;
|
|
|
import com.yihu.wlyy.util.QrcodeUtil;
|
|
|
import com.yihu.wlyy.util.fastdfs.FastDFSUtil;
|
|
|
import com.yihu.wlyy.util.http.HttpResponse;
|
|
|
import com.yihu.wlyy.util.http.HttpUtils;
|
|
|
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
|
|
@ -28,7 +31,10 @@ import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.InputStream;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@ -41,6 +47,14 @@ import java.util.Map;
|
|
|
public class RehabilitationManageService extends BaseService {
|
|
|
@Value("${specialist.url}")
|
|
|
private String specialistUrl;
|
|
|
@Value("${wechat.wechat_base_url}")
|
|
|
private String wechat_base_url;
|
|
|
@Value("${wechat.appId}")
|
|
|
private String appId;
|
|
|
@Value("${neiwang.enable}")
|
|
|
private Boolean isneiwang; //如果不是内网项目要转到到内网wlyy在上传
|
|
|
@Value("${fastDFS.fastdfs_file_url}")
|
|
|
private String fastdfs_file_url;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
@ -59,6 +73,10 @@ public class RehabilitationManageService extends BaseService {
|
|
|
private WeiXinOpenIdUtils weiXinOpenIdUtils;
|
|
|
@Autowired
|
|
|
private WeiXinAccessTokenUtils accessTokenUtils;
|
|
|
@Autowired
|
|
|
protected HttpServletRequest request;
|
|
|
@Autowired
|
|
|
private com.yihu.wlyy.util.CommonUtil CommonUtil;
|
|
|
|
|
|
/************************************************************* start ************************************************************************/
|
|
|
private String findRehabilitationPlanList = "/svr-specialist/findRehabilitationPlanList";//康复管理-康复计划列表
|
|
@ -323,7 +341,7 @@ public class RehabilitationManageService extends BaseService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public JSONObject patientRehabilitationDetail(String patientCode) throws Exception{
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
|
|
|
List<SignFamily> list = signFamilyDao.findByPatientAndExpensesStatusAndStatus(patientCode,"1",1);
|
|
|
String healthDoctor = null;
|
|
|
String healthDoctorName =null;
|
|
@ -333,6 +351,8 @@ public class RehabilitationManageService extends BaseService {
|
|
|
Integer age = null;
|
|
|
String sex = null;
|
|
|
String signHospitalName = null;
|
|
|
JSONObject json = null;
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
if(list.size()>0){
|
|
|
SignFamily signFamily = list.get(0);
|
|
|
healthDoctor = signFamily.getDoctorHealth();
|
|
@ -340,43 +360,56 @@ public class RehabilitationManageService extends BaseService {
|
|
|
generalDoctor = signFamily.getDoctor();
|
|
|
generalDoctorName = signFamily.getDoctorName();
|
|
|
patientName = signFamily.getName();
|
|
|
age = IdCardUtil.getAgeForIdcard(signFamily.getIdcard());
|
|
|
sex = IdCardUtil.getSexForIdcard_new(signFamily.getIdcard());
|
|
|
signHospitalName = signFamily.getHospitalName();
|
|
|
}
|
|
|
param.put("patientCode", patientCode);
|
|
|
param.put("healthDoctor", healthDoctor);
|
|
|
param.put("healthDoctorName", healthDoctorName);
|
|
|
param.put("generalDoctor", generalDoctor);
|
|
|
param.put("generalDoctorName", generalDoctorName);
|
|
|
HttpResponse response = HttpUtils.doGet(specialistUrl + patientRehabilitationDetail, param);
|
|
|
JSONObject result = new JSONObject(response.getContent());
|
|
|
if(result.getInt("status")==200){
|
|
|
JSONObject json = result.getJSONObject("obj").getJSONObject("patientInfo");
|
|
|
json.put("patientName",patientName);
|
|
|
json.put("age",age);
|
|
|
json.put("sex",sex);
|
|
|
String healthyConditionSql =" select label_name,label from wlyy_sign_patient_label_info where status=1 and patient='"+patientCode+"' and label_type=8";
|
|
|
List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
|
|
|
String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
|
|
|
String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
|
|
|
json.put("healthyCondition",healthyCondition);
|
|
|
json.put("healthyConditionType",healthyConditionType);
|
|
|
json.put("signHospitalName",signHospitalName);
|
|
|
Patient patient = patientDao.findByCode(patientCode);
|
|
|
json.put("photo",patient.getPhoto());
|
|
|
json.put("mobile",patient.getMobile());
|
|
|
JSONArray jsonArray = result.getJSONObject("obj").getJSONArray("serviceDoctorList");
|
|
|
String doctorCode ="";
|
|
|
Doctor doctor = null;
|
|
|
for(int i=0;i<jsonArray.length();i++){
|
|
|
doctorCode = jsonArray.getJSONObject(i).get("doctorCode")+"";
|
|
|
doctor = doctorDao.findByCode(doctorCode);
|
|
|
jsonArray.getJSONObject(i).put("doctorPhoto",doctor!=null?doctor.getPhoto():"");
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
param.put("patientCode", patientCode);
|
|
|
param.put("healthDoctor", healthDoctor);
|
|
|
param.put("healthDoctorName", healthDoctorName);
|
|
|
param.put("generalDoctor", generalDoctor);
|
|
|
param.put("generalDoctorName", generalDoctorName);
|
|
|
HttpResponse response = HttpUtils.doGet(specialistUrl + patientRehabilitationDetail, param);
|
|
|
JSONObject result = new JSONObject(response.getContent());
|
|
|
if(result.getInt("status")==200){
|
|
|
json = result.getJSONObject("obj").getJSONObject("patientInfo");
|
|
|
json.put("patientName",patientName);
|
|
|
String healthyConditionSql =" select label_name,label from wlyy_sign_patient_label_info where status=1 and patient='"+patientCode+"' and label_type=8";
|
|
|
List<Map<String,Object>> healthyConditionList = jdbcTemplate.queryForList(healthyConditionSql);
|
|
|
String healthyCondition = healthyConditionList.size()>0?healthyConditionList.get(0).get("label_name")+"":"";
|
|
|
String healthyConditionType = healthyConditionList.size()>0?healthyConditionList.get(0).get("label")+"":"";
|
|
|
json.put("healthyCondition",healthyCondition);
|
|
|
json.put("healthyConditionType",healthyConditionType);
|
|
|
json.put("signHospitalName",signHospitalName);
|
|
|
age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
|
|
|
sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard());
|
|
|
json.put("patientCode", patientCode);
|
|
|
json.put("patientName", patient.getName());
|
|
|
json.put("age",age);
|
|
|
json.put("sex",sex);
|
|
|
json.put("photo",patient.getPhoto());
|
|
|
json.put("mobile",patient.getMobile());
|
|
|
JSONArray jsonArray = result.getJSONObject("obj").getJSONArray("serviceDoctorList");
|
|
|
String doctorCode ="";
|
|
|
Doctor doctor = null;
|
|
|
for(int i=0;i<jsonArray.length();i++){
|
|
|
doctorCode = jsonArray.getJSONObject(i).get("doctorCode")+"";
|
|
|
doctor = doctorDao.findByCode(doctorCode);
|
|
|
jsonArray.getJSONObject(i).put("doctorPhoto",doctor!=null?doctor.getPhoto():"");
|
|
|
}
|
|
|
return result.getJSONObject("obj").put("patientInfo",json);
|
|
|
}
|
|
|
return result.getJSONObject("obj").put("patientInfo",json);
|
|
|
throw new Exception("请求微服务失败!");
|
|
|
}else{
|
|
|
json = new JSONObject();
|
|
|
}
|
|
|
throw new Exception("请求微服务失败!");
|
|
|
age = IdCardUtil.getAgeForIdcard(patient.getIdcard());
|
|
|
sex = IdCardUtil.getSexForIdcard_new(patient.getIdcard());
|
|
|
json.put("patientCode", patientCode);
|
|
|
json.put("patientName", patient.getName());
|
|
|
json.put("age",age);
|
|
|
json.put("sex",sex);
|
|
|
json.put("photo",patient.getPhoto());
|
|
|
json.put("mobile",patient.getMobile());
|
|
|
return new JSONObject().put("patientInfo",json) ;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@ -404,8 +437,46 @@ public class RehabilitationManageService extends BaseService {
|
|
|
|
|
|
public String createServiceQrCode(String planDetailId,String doctorCode) throws Exception{
|
|
|
Map<String, Object> param = new HashedMap();
|
|
|
String fileUrl = "";
|
|
|
String sql ="SELECT service_qr_code FROM wlyy_specialist.wlyy_rehabilitation_plan_detail where id='"+planDetailId+"'";
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
if(list!=null && list.size()>0){
|
|
|
fileUrl = String.valueOf(list.get(0).get("service_qr_code"));
|
|
|
}
|
|
|
if (StringUtils.isEmpty(fileUrl)){
|
|
|
//生成二维码图片
|
|
|
String contentJsonStr="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appId+"&redirect_uri="+wechat_base_url+"/wx/html/kfgl/html/confirm-service.html"+"?paramStr="+planDetailId+","+doctorCode+"&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
|
|
|
InputStream ipt = QrcodeUtil.createQrcode(contentJsonStr, 300, "png");
|
|
|
if (isneiwang) {
|
|
|
// 圖片列表
|
|
|
List<String> tempPaths = new ArrayList<String>();
|
|
|
try {
|
|
|
ObjectNode imgNode = FastDFSUtil.upload(ipt, "png", "plan_service_qrcode" + System.currentTimeMillis());
|
|
|
com.alibaba.fastjson.JSONObject json = com.alibaba.fastjson.JSONObject.parseObject(imgNode.toString());
|
|
|
tempPaths.add(json.getString("fid"));
|
|
|
String urls = "";
|
|
|
for (String image : tempPaths) {
|
|
|
if (urls.length() == 0) {
|
|
|
urls = image;
|
|
|
} else {
|
|
|
urls += "," + image;
|
|
|
}
|
|
|
}
|
|
|
fileUrl = fastdfs_file_url + urls;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
} else {
|
|
|
try {
|
|
|
fileUrl = fastdfs_file_url + CommonUtil.PrescriptionQRCodetoNeiWang(ipt);
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
param.put("planDetailId", planDetailId);
|
|
|
param.put("doctorCode", doctorCode);
|
|
|
param.put("imageUrl",fileUrl);
|
|
|
//specialistUrl= "http://localhost:10051";
|
|
|
HttpResponse response = HttpUtils.doPost(specialistUrl + createServiceQrCode, param);
|
|
|
JSONObject result = new JSONObject(response.getContent());
|
|
@ -454,7 +525,15 @@ public class RehabilitationManageService extends BaseService {
|
|
|
HttpResponse response = HttpUtils.doGet(specialistUrl + serviceDoctorList, param);
|
|
|
JSONObject result = new JSONObject(response.getContent());
|
|
|
if(result.getInt("status")==200){
|
|
|
return result.getJSONArray("obj");
|
|
|
JSONArray jsonArray = result.getJSONArray("obj");
|
|
|
String doctorCode ="";
|
|
|
Doctor doctor = null;
|
|
|
for(int i=0;i<jsonArray.length();i++){
|
|
|
doctorCode = jsonArray.getJSONObject(i).get("doctorCode")+"";
|
|
|
doctor = doctorDao.findByCode(doctorCode);
|
|
|
jsonArray.getJSONObject(i).put("doctorPhoto",doctor!=null?doctor.getPhoto():"");
|
|
|
}
|
|
|
return jsonArray;
|
|
|
}
|
|
|
throw new Exception("请求微服务失败!");
|
|
|
}
|