|
@ -2,20 +2,28 @@ package com.yihu.jw.care.service.contacts;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.care.dao.contacts.BasePatientContactsOrgDao;
|
|
|
import com.yihu.jw.care.dao.device.PatientDeviceDao;
|
|
|
import com.yihu.jw.care.dao.family.PatientFamilyMemberDao;
|
|
|
import com.yihu.jw.care.service.device.PatientDeviceService;
|
|
|
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
|
|
|
import com.yihu.jw.care.service.sign.ServicePackageService;
|
|
|
import com.yihu.jw.entity.base.org.BaseOrgDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientDO;
|
|
|
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
|
|
|
import com.yihu.jw.entity.care.contacts.BasePatientContactsOrgDO;
|
|
|
import com.yihu.jw.entity.care.device.DevicePatientDevice;
|
|
|
import com.yihu.jw.org.dao.BaseOrgDao;
|
|
|
import com.yihu.jw.patient.dao.BasePatientDao;
|
|
|
import com.yihu.jw.util.common.LatitudeUtils;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
@ -41,6 +49,38 @@ public class ContactsService {
|
|
|
private PatientFamilyMemberService patientFamilyMemberService;
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private BasePatientContactsOrgDao contactsOrgDao;
|
|
|
@Autowired
|
|
|
private BaseOrgDao baseOrgDao;
|
|
|
@Autowired
|
|
|
private ServicePackageService servicePackageService;
|
|
|
|
|
|
/**
|
|
|
* 查找居民联系服务站
|
|
|
* @param patient
|
|
|
*/
|
|
|
public BaseOrgDO getContactsOrg(String patient){
|
|
|
BasePatientContactsOrgDO contactsOrgDO = contactsOrgDao.findByPatient(patient);
|
|
|
if(contactsOrgDO == null){
|
|
|
return null;
|
|
|
}
|
|
|
return baseOrgDao.findByCode(contactsOrgDO.getOrgCode());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置居民联系服务站
|
|
|
* @param patient
|
|
|
*/
|
|
|
public void setContactsOrg(String patient,String orgCode){
|
|
|
BasePatientContactsOrgDO contactsOrgDO = contactsOrgDao.findByPatient(patient);
|
|
|
if(contactsOrgDO == null){
|
|
|
contactsOrgDO = new BasePatientContactsOrgDO();
|
|
|
contactsOrgDO.setPatient(patient);
|
|
|
}
|
|
|
contactsOrgDO.setOrgCode(orgCode);
|
|
|
contactsOrgDao.save(contactsOrgDO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取居民的联系人
|
|
@ -84,6 +124,11 @@ public class ContactsService {
|
|
|
return resultArray;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 设置一键联系人
|
|
|
* @param fid
|
|
|
* @param patient
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void setContacts(String fid,String patient){
|
|
|
BasePatientFamilyMemberDO familyMemberDO = memberDao.findOne(fid);
|
|
@ -106,4 +151,25 @@ public class ContactsService {
|
|
|
familyMemberDO.setIsContacts(1);
|
|
|
memberDao.save(familyMemberDO);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取居民签约机构
|
|
|
*/
|
|
|
public List<Map<String,Object>> findSignOrg(String patient,String lng,String lat){
|
|
|
List<Map<String,Object>> result = new ArrayList<>();
|
|
|
List<BaseOrgDO> orgDOList = servicePackageService.findSignOrg(patient);
|
|
|
for (BaseOrgDO orgDO : orgDOList){
|
|
|
Map<String,Object> map = new HashedMap();
|
|
|
map.put("distance", LatitudeUtils.getDistance(lat,lng,orgDO.getLatitude(),orgDO.getLongitude()));
|
|
|
map.put("id",orgDO.getId());
|
|
|
map.put("code",orgDO.getCode());
|
|
|
map.put("name",orgDO.getName());
|
|
|
map.put("photo",orgDO.getPhoto());
|
|
|
map.put("mobile",orgDO.getMobile());
|
|
|
map.put("address",orgDO.getAddress());
|
|
|
result.add(map);
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
}
|