瀏覽代碼

爱牵挂

yeshijie 4 年之前
父節點
當前提交
fa53ae434d

+ 40 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/BasePatientContactsOrgDO.java

@ -0,0 +1,40 @@
package com.yihu.jw.entity.care.contacts;
import com.yihu.jw.entity.UuidIdentityEntity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
@Entity
@Table(name="base_patient_contacts_org")
public class BasePatientContactsOrgDO extends UuidIdentityEntity {
    private String patient;
    private String orgCode;
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "org_code")
    public String getOrgCode() {
        return orgCode;
    }
    public void setOrgCode(String orgCode) {
        this.orgCode = orgCode;
    }
}

+ 4 - 0
common/common-util/src/main/java/com/yihu/jw/util/common/LatitudeUtils.java

@ -87,6 +87,10 @@ public class LatitudeUtils {
     * @return
     */
    public static String getDistance(String lat1Str, String lng1Str, String lat2Str, String lng2Str) {
        if(StringUtils.isEmpty(lat1Str)||StringUtils.isEmpty(lng1Str)
                ||StringUtils.isEmpty(lat2Str)||StringUtils.isEmpty(lng2Str)){
            return "";
        }
        double lat1 = Double.parseDouble(lat1Str);
        double lng1 = Double.parseDouble(lng1Str);
        double lat2 = Double.parseDouble(lat2Str);

+ 21 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/contacts/BasePatientContactsOrgDao.java

@ -0,0 +1,21 @@
package com.yihu.jw.care.dao.contacts;
import com.yihu.jw.entity.care.contacts.BasePatientContactsOrgDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
public interface BasePatientContactsOrgDao extends PagingAndSortingRepository<BasePatientContactsOrgDO,String>,
        JpaSpecificationExecutor<BasePatientContactsOrgDO> {
    BasePatientContactsOrgDO findByPatient(String patient);
}

+ 56 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java

@ -2,6 +2,7 @@ package com.yihu.jw.care.endpoint.patient;
import com.alibaba.fastjson.JSONArray;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -66,4 +67,59 @@ public class PatientContactsEndpoint extends EnvelopRestEndpoint {
            return ObjEnvelop.getError("设置失败");
        }
    }
    /**
     * 查找居民联系服务站
     * @param patient
     * @return
     */
    @RequestMapping(value = "getContactsOrg", method = RequestMethod.GET)
    @ApiOperation(value = "联系人查询")
    public Envelop getContactsOrg(@RequestParam(required = true) String patient) {
        try {
            BaseOrgDO result = contactsService.getContactsOrg(patient);
            return ObjEnvelop.getSuccess( "查询成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "查询失败");
        }
    }
    /**
     * 设置居民联系服务站
     * @param patient
     * @return
     */
    @RequestMapping(value = "setContactsOrg", method = RequestMethod.POST)
    @ApiOperation(value = "设置居民联系服务站")
    public Envelop setContactsOrg(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) String orgCode) {
        try {
            contactsService.setContactsOrg(patient,orgCode);
            return ObjEnvelop.getSuccess("设置成功");
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError("设置失败");
        }
    }
    /**
     * 查找居民联系服务站
     * @param patient
     * @return
     */
    @RequestMapping(value = "findSignOrg", method = RequestMethod.GET)
    @ApiOperation(value = "联系人查询")
    public Envelop findSignOrg(@RequestParam(required = true) String patient,
                               @RequestParam(required = true) String lng,
                               @RequestParam(required = true) String lat) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", contactsService.findSignOrg(patient,lng,lat));
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "查询失败");
        }
    }
}

+ 66 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java

@ -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;
    }
}