|
@ -0,0 +1,109 @@
|
|
|
package com.yihu.jw.care.service.patient;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.mysql.query.BaseJpaService;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONArray;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/***
|
|
|
* @ClassName: OnlineContactService
|
|
|
* @Description:
|
|
|
* @Auther: shi kejing
|
|
|
* @Date: 2021/8/11 16:47
|
|
|
*/
|
|
|
@Service
|
|
|
public class OnlineContactService extends BaseJpaService<BasePatientDO, BasePatientDao> {
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private ImUtil imUtil;
|
|
|
|
|
|
public JSONObject getOnLineObj(String patient){
|
|
|
JSONObject obj = new JSONObject();
|
|
|
String zlySql = "SELECT d.id,d.name,d.photo FROM base_doctor d,base_service_package_sign_record spsr\n" +
|
|
|
"WHERE d.del = 1 AND d.doctor_level = 2 AND d.id = spsr.sign_doctor AND spsr.`status` = 1 AND spsr.patient = '"+patient+"'";
|
|
|
String jsSql = "SELECT p.id,p.`name`,p.photo,pfm.family_relation familyRelation,p.archive_type\n" +
|
|
|
"FROM base_patient_family_member pfm,base_patient p\n" +
|
|
|
"WHERE pfm.del = 1 AND pfm.family_member = p.id AND p.patient_status = 1 AND pfm.patient = '"+patient+"'";
|
|
|
String fwzSql = "SELECT o.`code`,o.`name`,o.photo,o.mobile,o.address\n" +
|
|
|
"FROM base_doctor_hospital dh,base_org o,base_service_package_sign_record spsr\n" +
|
|
|
"WHERE dh.del = 1 AND o.del = 1 AND spsr.`status` = 1 AND spsr.sign_doctor = dh.doctor_code\n" +
|
|
|
"AND dh.org_code = o.`code` AND spsr.patient = '"+patient+"' GROUP BY o.`code`";
|
|
|
List<Map<String,Object>> zlyList = jdbcTemplate.queryForList(zlySql);
|
|
|
List<Map<String,Object>> jsList = jdbcTemplate.queryForList(jsSql);
|
|
|
List<Map<String,Object>> fwzList = jdbcTemplate.queryForList(fwzSql);
|
|
|
if (zlyList.size() > 0){
|
|
|
for (int i=0;i<zlyList.size();i++){
|
|
|
JSONObject helperObj = new JSONObject();
|
|
|
helperObj.put("id",zlyList.get(i).get("id"));
|
|
|
helperObj.put("name",zlyList.get(i).get("name"));
|
|
|
helperObj.put("photo",zlyList.get(i).get("photo"));
|
|
|
Integer onLineFlag =0;
|
|
|
String onLineStr = imUtil.findByUserIdAndType(zlyList.get(i).get("id").toString(),"helper");
|
|
|
JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
|
|
|
if (200 == oneLineObj.getInteger("status")){
|
|
|
if (oneLineObj.getInteger("data")>0){
|
|
|
onLineFlag=1;
|
|
|
}
|
|
|
}
|
|
|
helperObj.put("onLineFlag", onLineFlag);
|
|
|
obj.put("helperObj",helperObj);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (jsList.size() > 0){
|
|
|
for (int i=0;i<jsList.size();i++){
|
|
|
JSONObject familyObj = new JSONObject();
|
|
|
familyObj.put("id",jsList.get(i).get("id"));
|
|
|
familyObj.put("name",jsList.get(i).get("name"));
|
|
|
familyObj.put("photo",jsList.get(i).get("photo"));
|
|
|
familyObj.put("familyRelation",jsList.get(i).get("familyRelation"));
|
|
|
String archive_type = null;
|
|
|
Integer onLineFlag =0;
|
|
|
switch (jsList.get(i).get("archive_type").toString()){
|
|
|
case "1":
|
|
|
archive_type = "older";//老人
|
|
|
break;
|
|
|
case "2":
|
|
|
archive_type = "child";//新生儿
|
|
|
break;
|
|
|
}
|
|
|
if (StringUtils.isNotBlank(archive_type)){
|
|
|
String onLineStr = imUtil.findByUserIdAndType(jsList.get(i).get("id").toString(),archive_type);
|
|
|
JSONObject oneLineObj = JSONObject.parseObject(onLineStr);
|
|
|
if (200 == oneLineObj.getInteger("status")){
|
|
|
if (oneLineObj.getInteger("data")>0){
|
|
|
onLineFlag=1;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
familyObj.put("onLineFlag", onLineFlag);
|
|
|
obj.put("familyObj",familyObj);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (fwzList.size() > 0){
|
|
|
for (int i=0;i<fwzList.size();i++){
|
|
|
JSONObject serStationObj = new JSONObject();
|
|
|
serStationObj.put("code",fwzList.get(i).get("code"));
|
|
|
serStationObj.put("name",fwzList.get(i).get("name"));
|
|
|
serStationObj.put("photo",fwzList.get(i).get("photo"));
|
|
|
serStationObj.put("mobile",fwzList.get(i).get("mobile"));
|
|
|
serStationObj.put("address",fwzList.get(i).get("address"));
|
|
|
obj.put("serStationObj",serStationObj);
|
|
|
}
|
|
|
}
|
|
|
return obj;
|
|
|
}
|
|
|
|
|
|
}
|