Jelajahi Sumber

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

 Conflicts:
	common/common-entity/sql记录
Shi Kejing 4 tahun lalu
induk
melakukan
b402e6d249
27 mengubah file dengan 800 tambahan dan 189 penghapusan
  1. 6 0
      business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java
  2. 3 0
      common/common-entity/sql记录
  3. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java
  4. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientFamilyMemberDO.java
  5. 40 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/BasePatientContactsOrgDO.java
  6. 4 0
      common/common-util/src/main/java/com/yihu/jw/util/common/LatitudeUtils.java
  7. 5 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  8. 21 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/contacts/BasePatientContactsOrgDao.java
  9. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  10. 8 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/family/PatientFamilyMemberDao.java
  11. 20 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  12. 17 8
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java
  13. 125 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java
  14. 15 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  15. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  16. 175 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  17. 15 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  18. 52 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  19. 36 21
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  20. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java
  21. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  22. 42 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  23. 19 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  24. 9 9
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
  25. 155 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/GpsUtil.java
  26. 0 83
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  27. 16 61
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

+ 6 - 0
business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java

@ -61,4 +61,10 @@ public interface BaseOrgDao extends PagingAndSortingRepository<BaseOrgDO, String
    
    @Query(value="select b.* from base_org b where b.org_level= ?1 and b.del=?2 ORDER BY sort DESC",nativeQuery = true)
    List<BaseOrgDO> findByLevelAndDel(Integer level,String del);
    @Query(value="select Distinct org from BaseOrgDO org,BaseDoctorHospitalDO h where org.code = h.orgCode and h.del=1 and org.del=1 and h.doctorCode=?1 and org.type=?2 " )
    List<BaseOrgDO> findByDoctorAndType(String doctor,String type);
    @Query(value="select org from BaseOrgDO org where org.del=1  and org.type in ?1 " )
    List<BaseOrgDO> findByTypeIn(String[] type);
}

+ 3 - 0
common/common-entity/sql记录

@ -447,5 +447,8 @@ alter table base_doctor add doctor_level tinyint(4) DEFAULT NULL COMMENT '类型
alter table base_patient ADD disease varchar(50) ;
alter table patient_medicare_card ADD medicare_number varchar(50) ;
-- 2021-05-07 ysj
alter table base_patient_family_member add is_contacts tinyint(1) DEFAULT NULL COMMENT '是否是一键联系人';
-- 2021-05-07 skj
ALTER TABLE base.wlyy_patient_device add COLUMN  `sos_address` varchar(50) DEFAULT NULL COMMENT '设备类型为报警器时,需要填写投放地址 category_code = 7';

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java

@ -84,7 +84,7 @@ public class BaseOrgDO extends UuidIdentityEntityWithOperator {
	private String spell;
    /**
	 * 机构类型: 1. 等级医院2. 社区医院3.  养老机构
	 * 机构类型: 1. 等级医院2. 社区医院3.  养老机构 4.  托育机构
	 */
	private String type;

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientFamilyMemberDO.java

@ -17,6 +17,7 @@ public class BasePatientFamilyMemberDO extends UuidIdentityEntityWithOperator {
    private String familyMember;//家庭成员code',
    private Integer familyRelation;//家庭关系关系 1配偶 2父亲 3母亲 4公公 5婆婆 6岳父 7岳母 8子女',
    private Integer isAuthorize;//是否授权0:未授权,1:已授权,默认为1',
    private Integer isContacts;//是否是一键联系人 1是
    private Integer del;//删除标志(1正常,0删除)
    @Column(name = "patient")
@ -63,4 +64,13 @@ public class BasePatientFamilyMemberDO extends UuidIdentityEntityWithOperator {
    public void setDel(Integer del) {
        this.del = del;
    }
    @Column(name = "is_contacts")
    public Integer getIsContacts() {
        return isContacts;
    }
    public void setIsContacts(Integer isContacts) {
        this.isContacts = isContacts;
    }
}

+ 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);

+ 5 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java

@ -27,6 +27,11 @@ public class AqgConfig {
     */
    public static final String sos_numbers = baseUrl +"/api/device/{0}/sos_numbers/{1}";
    /**
     * 获取设备最新位置数据
     */
    public static final String device_last_locationdata = baseUrl +"/api/device/{0}/data/locationdata/";
    public static final String username = "13559485270";
    public static final String password = "zjxl@2021";
    public static final String redisKey = "aqgCooker";

+ 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);
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java

@ -54,5 +54,5 @@ public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatie
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);
    List<DevicePatientDevice> findByUserAndCategoryCode(String user,String categoryCode);
}

+ 8 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/family/PatientFamilyMemberDao.java

@ -50,4 +50,12 @@ public interface PatientFamilyMemberDao extends PagingAndSortingRepository<BaseP
    BasePatientFamilyMemberDO findByPatientAndFamilyMember(String patient,String member);
    List<BasePatientFamilyMemberDO> findByFamilyMemberAndIsAuthorize(String familyMember,Integer isAuthorize);
    @Modifying
    @Query("update BasePatientFamilyMemberDO m set m.isContacts = 0 where m.patient=?1 ")
    int updateContactsByPatient(String patient);
    @Modifying
    @Query("update BasePatientFamilyMemberDO m set m.isContacts = 1 where m.id=?1 ")
    int updateContactsById(String id);
}

+ 20 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java

@ -12,6 +12,7 @@ import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -93,4 +94,23 @@ public class DoctorEndpoint extends EnvelopRestEndpoint {
        }
        return success("保存成功");
    }
    @GetMapping(value = "getOrgDoctor")
    @ApiOperation(value = "医生通讯录机构详情查询")
    public ObjEnvelop getOrgDoctor(
            @ApiParam(name = "doctorId", value = "doctorId", required = false)
            @RequestParam(value = "doctorId",required = false) String doctorId,
            @ApiParam(name = "orgType", value = "1,2医疗机构 3养老机构,4托育机构")
            @RequestParam(value = "orgType") String orgType
    ){
        try {
            if (orgType.equals("3")&&StringUtils.isBlank(doctorId)){
                return ObjEnvelop.getError("参数错误");
            }
            return ObjEnvelop.getSuccess("查询成功", doctorService.getOrgDoctor(doctorId,orgType));
        }catch (Exception e){
            e.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
}

+ 17 - 8
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java

@ -171,21 +171,21 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
    /**
     * 家庭成员查询
     * @param patient
     * @param isAgree (任意值已同意(只查询家人关系表),null不同意)
     * @param isContacts (1是一键联系人)
     * @return
     */
    @RequestMapping(value = "/members", method = RequestMethod.GET)
    @ApiOperation(value = "家庭成员查询")
    public ObjEnvelop getPatientFamilyMembers(@RequestParam(required = false) String patient,
                                              @RequestParam(required = false) String isContain,
                                              @RequestParam(required = false) Integer isAgree) {
                                              @RequestParam(required = false) Integer isContacts) {
        try {
            JSONObject data = new JSONObject();
            JSONArray result = new JSONArray();
            if (StringUtils.isNotEmpty(patient)) {
                result = familyMemberService.getPatientMembers(patient, "", isContain,isAgree);
                result = familyMemberService.getPatientMembers(patient, "", isContain,isContacts);
            } else  {
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",null);
                result = familyMemberService.getPatientFamilyMembers(getUID(), "",isContacts);
            }
            data.put("normalmembers",result);//家人关系
@ -314,12 +314,21 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "/addMemberByCaptcha", method = RequestMethod.POST)
    @ApiOperation(value = "通过手机验证码新增家庭成员")
    public Envelop addMemberByCaptcha(@RequestParam("member") String member,
    public Envelop addMemberByCaptcha(@RequestParam("idcard") String idcard,
                                      @RequestParam("name") String name,
                                      @RequestParam("mobile") String mobile,
                                      @RequestParam("archiveType") Integer archiveType,
                                     @RequestParam("captcha") String captcha,
                                     @RequestParam("relation") int relation){
        try {
            if (StringUtils.isEmpty(member)) {
                return failed( "添加成员不能为空",-1);
            if (StringUtils.isEmpty(idcard)) {
                return failed( "添加成员身份证不能为空",-1);
            }
            if (StringUtils.isEmpty(name)) {
                return failed( "添加成员姓名不能为空",-1);
            }
            if (StringUtils.isEmpty(mobile)) {
                return failed( "添加成员手机号不能为空",-1);
            }
            if (StringUtils.isEmpty(captcha)) {
                return failed( "验证码不能为空",-1);
@ -328,7 +337,7 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
                return failed( "家庭关系无效",-1);
            }
            int result = familyMemberService.addMemberByCaptcha(getUID(),member,captcha,relation);
            int result = familyMemberService.addMemberByCaptcha(getUID(),idcard,name,mobile,archiveType,captcha,relation);
            if(result==0){
                return failed( "不能添加自己",-1);

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

@ -0,0 +1,125 @@
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;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
@RestController
@RequestMapping("patientContacts" )
@Api(tags = "居民-联系人", description = "居民-联系人")
public class PatientContactsEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private ContactsService contactsService;
    /**
     * 联系人查询
     * @param patient
     * @param isContacts (1是一键联系人)
     * @return
     */
    @RequestMapping(value = "getPatientContacts", method = RequestMethod.GET)
    @ApiOperation(value = "联系人查询")
    public Envelop getPatientContacts(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) Integer isContacts) {
        try {
            JSONArray result = contactsService.getPatientContacts(patient,isContacts);
            return ObjEnvelop.getSuccess( "查询成功", result);
        } catch (Exception e) {
            e.printStackTrace();
            return ObjEnvelop.getError( "查询失败");
        }
    }
    /**
     * 设置一键联系人
     * @param patient
     * @return
     */
    @RequestMapping(value = "setPatientContacts", method = RequestMethod.POST)
    @ApiOperation(value = "设置一键联系人")
    public Envelop setPatientContacts(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) String fid) {
        try {
            contactsService.setContacts(fid,patient);
            return ObjEnvelop.getSuccess("设置成功");
        } catch (Exception e) {
            e.printStackTrace();
            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( "查询失败");
        }
    }
}

+ 15 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java

@ -3,6 +3,7 @@ package com.yihu.jw.care.endpoint.security;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringConclusionDO;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -269,4 +270,18 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
            return ListEnvelop.getError("查询失败");
        }
    }
    @ApiOperation("获取居民监护信息")
    @RequestMapping(value = "patientMonitoringInfo ", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public ObjEnvelop patientMonitoringInfo(@ApiParam(name = "patient", value = "patient")
                                @RequestParam(value = "patient") String patient) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", securityMonitoringOrderService.patientMonitoringInfo(patient));
        } catch (Exception ex) {
            ex.printStackTrace();
            return ObjEnvelop.getError("查询失败");
        }
    }
}

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java

@ -434,6 +434,9 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        try{
            if (StringUtils.isBlank(doctorId)&&StringUtils.isBlank(name)){
                return PageEnvelop.getError("请求参数错误");
            }
            return archiveService.archiveList(doctorId,page,size,signStatus,name);
        }catch (Exception e){
            e.printStackTrace();

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

@ -0,0 +1,175 @@
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;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/5/7
 * @Description:
 */
@Service
public class ContactsService {
    @Autowired
    private PatientFamilyMemberDao memberDao;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
    private BasePatientDao basePatientDao;
    @Autowired
    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);
    }
    /**
     * 获取居民的联系人
     * @param patient 居民
     * @return
     */
    public JSONArray getPatientContacts(String patient, Integer isContacts) {
        JSONArray resultArray = new JSONArray();
        String sql = "select *,t1.id fid " +
                " from " +
                "    base_patient_family_member t1, " +
                "    base_patient t2 " +
                " where " +
                "    t2.id in (select family_member from base_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.id ";
        if(isContacts == 1){
            sql += " and t1.is_contacts = "+ isContacts;
        }
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient, patient});
        if (result != null && result.size() > 0) {
            for (Map<String, Object> map : result) {
                JSONObject obj = new JSONObject();
                obj.put("id", map.get("id"));
                obj.put("fid", map.get("fid"));
                obj.put("name", map.get("name"));
                obj.put("isContacts", map.get("is_contacts"));
                obj.put("sex", map.get("sex"));
                obj.put("birthday", map.get("birthday"));
                obj.put("idcard", StringUtils.isEmpty(String.valueOf(map.get("idcard"))) ? "" : map.get("idcard").toString());
                obj.put("photo", map.get("photo"));
                obj.put("mobile", map.get("mobile"));
                obj.put("address", StringUtils.isEmpty(String.valueOf(map.get("address"))) ? "" : map.get("address"));
                obj.put("familyRelation", map.get("family_relation"));
                obj.put("familyRelationName", PatientFamilyMemberService.relations.get(map.get("family_relation")));
                resultArray.add(obj);
            }
        }
        return resultArray;
    }
    /**
     * 设置一键联系人
     * @param fid
     * @param patient
     */
    @Transactional(rollbackFor = Exception.class)
    public void setContacts(String fid,String patient){
        BasePatientFamilyMemberDO familyMemberDO = memberDao.findOne(fid);
        BasePatientDO patientDO = basePatientDao.findById(patient);
        //设置爱牵挂智能设备sos号码
        try {
            List<DevicePatientDevice> patientDeviceList = patientDeviceDao.findByPatient(patient);
            for(DevicePatientDevice patientDevice : patientDeviceList){
                if("4".equals(patientDevice.getCategoryCode())||"7".equals(patientDevice.getCategoryCode())){
                    patientDeviceService.updAqgDeviceSosInfo(patientDevice.getDeviceSn(),"1",
                            PatientFamilyMemberService.relations.get(familyMemberDO.getFamilyRelation()),patientDO.getMobile(),"1",null);
                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        memberDao.updateContactsByPatient(patient);
        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;
    }
}

+ 15 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java

@ -754,7 +754,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    若该设备以前已设置亲情号码2,则以前设置的亲情号码2也会被清空]
    |
     */
    public com.alibaba.fastjson.JSONObject updAqgDeviceSosInfo(String deviceSn,String seqid,String name,String num,String dial_flag,String clear) throws Exception{
    public com.alibaba.fastjson.JSONObject updAqgDeviceSosInfo(String deviceSn,String seqid,String name,String num,String dial_flag,String clear){
        String url = MessageFormat.format(AqgConfig.sos_numbers, deviceSn,seqid);
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(StringUtils.isBlank(clear)){
@ -769,7 +769,21 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return response.getBody();
    }
    /**
     * 获取设备最新位置数据
     * @param deviceSn
     * @param type  0:Gps定位; 1:基站定位 (非必填)
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONObject getDeviceLastLocation(String deviceSn,String type) throws Exception{
        String url = MessageFormat.format(AqgConfig.device_last_locationdata, deviceSn);
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("type", type);
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.GET, getCookie());
        return response.getBody();
    }
    /******************************************* 爱牵挂设备end *****************************************************/

+ 52 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java

@ -1,11 +1,16 @@
package com.yihu.jw.care.service.doctor;
import com.alibaba.fastjson.JSONObject;
import com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ;
import com.yihu.jw.care.endpoint.org.OrgEndpoint;
import com.yihu.jw.care.service.role.RoleService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.doctor.dao.DoctorSpecialDiseaseDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.utils.StringUtil;
@ -14,10 +19,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
/**
 * Created by yeshijie on 2021/3/3.
@ -38,6 +48,12 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    private WlyyHospitalSysDictDao wlyyHospitalSysDictDao;
    @Autowired
    private RoleService roleService;
    @Autowired
    private BaseOrgDao orgDao;
    @Autowired
    private BaseDoctorHospitalDao doctorHospitalDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    /**
     * 获取医生详情
@ -118,4 +134,40 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return true;
    }
    public Map<String,Object> getOrgDoctor(String doctorId,String orgType){
        List<BaseOrgDO> orgList = new ArrayList<>();
        Map<String,Object> orgListMap = new HashMap<>();
        Map<String,Object> result = new HashMap<>();
        if (orgType.equals("3")){//养老机构
            orgList = orgDao.findByDoctorAndType(doctorId,"3");
        }
        if (orgType.equals("1,2")){//医疗机构
            orgList = orgDao.findByTypeIn(new String[]{"1","2"});
        }
        if (orgType.equals("4")){//托育机构
            orgList = orgDao.findByDoctorAndType(doctorId,"4");
        }
        List<Map<String,Object>> doctorList = new ArrayList<>();
        if (orgList.size()==0){
            return new HashMap<>();
        }
        for (BaseOrgDO org:orgList){
            String sql = "select dh.org_code,dh.org_name,doc.id,doc.name,doc.mobile,doc.photo,dict.code deptCode,dict.name deptName,dh.doctor_duty_code job,dh.doctor_duty_name jobName\n" +
                    "from base_doctor_hospital dh,dict_hospital_dept dict,base_doctor doc where  dh.doctor_code = doc.id  " +
                    "and dh.dept_code = dict.`code` and dh.org_code = dict.org_code and dh.del=1 and dh.org_code='"+org.getCode()+"' GROUP BY doc.id" ;
            List<Map<String,Object>> tmpList = jdbcTemplate.queryForList(sql);
            Map<String,List<Map<String,Object>>> docTmp = tmpList.stream().collect(Collectors.groupingBy(e->e.get("deptCode").toString()));
//          Map<String,String> deptList = tmpList.stream().collect(Collectors.toMap(s->s.get("deptCode").toString(),s->s.get("deptName").toString(),(oldVal, currVal) -> currVal));
            Map<String,Object> tmpMap = new HashMap<>();
            tmpMap.put("orgCode",org.getCode());
            tmpMap.put("orgName",org.getName());
//            tmpMap.put("deptList",deptList);
            orgListMap.put(org.getCode(),tmpMap);
            doctorList.addAll(tmpList);
        }
        result.put("orgList",orgListMap);
        return result;
    }
}

+ 36 - 21
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java

@ -18,11 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -32,7 +28,7 @@ import java.util.regex.Pattern;
@Service
public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamilyMemberDO, PatientFamilyMemberDao> {
    Map<Integer, String> relations = new HashMap<>();
    public static Map<Integer, String> relations = new HashMap<>();
    @Autowired
    private PatientFamilyMemberDao memberDao;
    @Autowired
@ -43,8 +39,8 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
    private WeiXinAccessTokenUtils weiXinAccessTokenUtils;
    @PostConstruct
    public void init() {
    static {
        relations.put(0, "其他");
        relations.put(1, "父亲");
        relations.put(2, "母亲");
@ -359,7 +355,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
     * @param patient 居民
     * @return
     */
    public JSONArray getPatientFamilyMembers(String patient, String doctorCode, Integer isAgree) {
    public JSONArray getPatientFamilyMembers(String patient, String doctorCode, Integer isContacts) {
        JSONArray resultArray = new JSONArray();
        String sql = "select * " +
                " from " +
@ -369,7 +365,9 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                "    t2.id in (select family_member from base_patient_family_member where patient = ? ) " +
                "    and t1.patient = ? " +
                "    and t1.family_member = t2.id ";
        if(isContacts != null){
            sql += " and t1.is_contacts = "+ isContacts;
        }
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{patient, patient});
        if (result != null && result.size() > 0) {
@ -387,6 +385,7 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
                obj.put("id", map.get("id"));
                obj.put("name", map.get("name"));
                obj.put("isContacts", map.get("is_contacts"));
                obj.put("sex", map.get("sex"));
                obj.put("isAuthorize", isAuthorize);//0:未授权,1:已授权
                obj.put("birthday", map.get("birthday"));
@ -715,31 +714,47 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
    }
    @Transactional
    public int addMemberByCaptcha(String patient, String member, String captcha, int relation) throws Exception {
        if (patient.equals(member)) {
            return 0;
        }
    public int addMemberByCaptcha(String patient, String idcard, String name, String mobile, Integer archiveType, String captcha, int relation) throws Exception {
        BasePatientDO p = patientDao.findById(patient);
        BasePatientDO m = patientDao.findById(member);
        if (p == null) {
            return -1;
        }
        // 添加的成员是否注册判断
        if (m == null) {
            return -2;
        if(idcard.equals(p.getIdcard())){
            return 0;
        }
//        // 验证码验证
        //        // 验证码验证
//        if (StringUtils.isNotEmpty(captcha)) {
//            int checkStatus = smsService.check(m.getMobile(), 10, captcha);
//            int checkStatus = smsService.check(mobile, 10, captcha);
//            if (checkStatus == -2) {
//                return -6;  // 验证码过期
//            } else if (checkStatus == -1) {
//                return -3; // 验证码错误
//            }
//        }
        BasePatientDO m = patientDao.findByIdcard(idcard);
        String member = "";
        // 添加的成员是否注册判断
        if (m == null) {
            //新增账户
            m = new BasePatientDO();
            String salt = UUID.randomUUID().toString().substring(0,5);
            String pw = idcard.substring(idcard.length()-6,idcard.length());
            m.setPassword(com.yihu.utils.security.MD5.md5Hex(pw + "{" + salt + "}"));
            m.setSalt(salt);
            m.setMobile(mobile);
            m.setDel("1");
            m.setEnabled(1);
            m.setLocked(0);
            m.setCreateTime(new Date());
            m.setUpdateTime(new Date());
            m.setName(name);
            m.setIdcard(idcard);
            m.setArchiveType(archiveType);
            patientDao.save(m);
        }
        member = m.getId();
        return addMemberFamily(p, m, patient, member, relation);
    }

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java

@ -40,7 +40,7 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
                "                and i.del = 1 and i.team_code = '"+teamCode+"' " +
                "                and sr.patient = p.id and p.id = l.patient and l.label_type = 1) " +
                "a on dict.dict_code = a.label_code  " +
                "where dict.dict_name = '"+ConstantUtil.DICT_SERVICE_TYPE+"'  " +
                "where dict.dict_name = '"+ConstantUtil.DICT_SERVICE_TYPE+"' and dict_code<>5  " +
                "GROUP BY labelCode,labelName ";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){

+ 1 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java

@ -178,6 +178,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        String sql = "SELECT " +
                "  p.name AS patientName, " +
                "  p.photo AS photo, " +
                "  p.idcard," +
                "  case p.sex  " +
                "  when 1 then '男'  " +
                "  when 2 then '女' " +

+ 42 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java

@ -7,6 +7,7 @@ import com.alibaba.fastjson.serializer.SerializerFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.security.*;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
@ -65,6 +66,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private SecurityMonitoringConclusionDao securityMonitoringConclusionDao;
    @Autowired
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private PatientDeviceService patientDeviceService;
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
@ -906,6 +909,45 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    public JSONObject patientMonitoringInfo(String patient){
        JSONObject result = new JSONObject();
        result.put("location",null);
        result.put("enclosureStatus",null);
        result.put("enclosurePosition",null);
        result.put("smoke",null);
        result.put("fire",null);
        List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
        if (devicePatientDeviceDos.size()==0){
            return result;
        }
        else {
            DevicePatientDevice device = devicePatientDeviceDos.get(0);
            try {
             JSONObject response= patientDeviceService.getDeviceLastLocation(device.getDeviceSn(),null);
             if (response.getBooleanValue("success")){
                JSONObject tmp = response.getJSONObject("obj");
                if (tmp.containsKey("locationdata")&&tmp.get("locationdata")!=null){
                    JSONObject locationTmp = tmp.getJSONObject("locationdata");
                    Double lon = locationTmp.getJSONObject("point").getJSONArray("coordinates").getDouble(0);
                    Double lat = locationTmp.getJSONObject("point").getJSONArray("coordinates").getDouble(1);
                    tmp = new JSONObject();
                    tmp.put("city",locationTmp.getString("city"));
                    tmp.put("address",locationTmp.getString("address"));
                    result.put("location",tmp);
                }
             }
            }catch (Exception e){
                e.printStackTrace();
                result.put("location",null);
            }
            result.put("enclosureStatus",null);
            result.put("enclosurePosition",null);
        }
        return result;
    }
    private String getRandomIntStr(){
        Random rand = new Random();
        int i = rand.nextInt(); //int范围类的随机数

+ 19 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java

@ -84,7 +84,7 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
    public PageEnvelop<List<Map<String,Object>>> archiveList(String doctorId, int page, int size,Integer signStatus,String name){
        String sql = "SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id,CAST(a.sign_status AS char) sign_status ";
        String countSql = "SELECT count(*) ";
        String countSql = "SELECT count(*) from ( ";
        String filters = "from wlyy_archive a,base_patient p " +
                "WHERE  a.patient = p.id ";
@ -97,8 +97,24 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
        if(StringUtils.isNotBlank(name)){
            filters += " and p.name like '%"+name+"%'";
        }
        if (signStatus!=null&&signStatus==1){//已签约不按建档查询,是要该居民服务医生就在列表中
            filters+=" UNION " +
                    " SELECT a.create_time,p.idcard,p.mobile,p.name,p.sex,p.id,CAST(a.sign_status AS char) sign_status \n" +
                    "from wlyy_archive a,base_patient p WHERE  a.patient = p.id and a.sign_status = 1 and EXISTS( " +
                    "SELECT DISTINCT sr.patient from base_service_package_sign_record sr,base_service_package_record r, " +
                    "base_service_package_item i,base_team_member m " +
                    "WHERE  sr.id = r.sign_id and sr.patient = a.patient and sr.status=1 and r.service_package_id = i.service_package_id " +
                    "and i.del = 1 and m.team_code = i.team_code " ;
            if(StringUtils.isNotBlank(doctorId)){
                filters += " and m.doctor_code = '"+doctorId+"' ";
            }
            if(StringUtils.isNotBlank(name)){
                filters += " and p.name like '%"+name+"%'";
            }
            filters+= " and m.del = '1' and sr.`status`=1 ) ";
        }
        String orderBy = " ORDER BY a.create_time DESC " +
        String orderBy = " ORDER BY create_time DESC " +
                "LIMIT "+ (page - 1) * size + "," + size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filters+orderBy);
@ -112,7 +128,7 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
                map.put("servicePackageList",servicePackageService.getServicePackageListByPatient(patientId,null));
            }
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        Long count = jdbcTemplate.queryForObject(countSql+sql+filters+" )tmp",Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }

+ 9 - 9
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java

@ -135,21 +135,21 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
            res.put(String.valueOf(map.get("level_conclusion")),c);
        }
        String sql2 = "SELECT COUNT(DISTINCT ar.id) from base_patient ar, " +
                "base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_service_package_item i,base_team_member m  " +
                "                WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
                "                and i.del = 1 and m.team_code = i.team_code and ar.id = sr.patient and ar.archive_type = 2 " +
                "                and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1";
        Integer count = jdbcTemplate.queryForObject(sql2,Integer.class);
        res.put("10",count);
//        String sql2 = "SELECT COUNT(DISTINCT ar.id) from base_patient ar, " +
//                "base_service_package_sign_record sr,base_service_package_record r,  " +
//                "                base_service_package_item i,base_team_member m  " +
//                "                WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
//                "                and i.del = 1 and m.team_code = i.team_code and ar.id = sr.patient and ar.archive_type = 2 " +
//                "                and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1";
//        Integer count = jdbcTemplate.queryForObject(sql2,Integer.class);
//        res.put("10",count);
        return res;
    }
    public PageEnvelop<List<Map<String,Object>>> assessmentPage(String doctorId,String name, int page, int size,
                    Integer status,Integer levelConclusion,Integer servicePackageStatus){
        String sql = "SELECT c.id,c.patient,c.assessment_time,c.service_package_status servicePackageStatus, " +
                "c.`status`,c.level_conclusion levelConclusion,c.org_code orgCode,c.org_name orgName,p.name,p.mobile,p.sex,p.idcard  ";
                "c.`status`,c.level_conclusion levelConclusion,c.org_code orgCode,c.org_name orgName,p.name,p.photo,p.mobile,p.sex,p.idcard  ";
        String countSql = "SELECT count(*) ";
        String filters = "from base_capacity_assessment_record c,base_patient p " +

+ 155 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/GpsUtil.java

@ -0,0 +1,155 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import org.springframework.stereotype.Component;
/**
 * * 坐标转换工具类
 *  * WGS84: Google Earth采用,Google Map中国范围外使用
 *  * GCJ02: 火星坐标系,中国国家测绘局制定的坐标系统,由WGS84机密后的坐标。Google Map中国和搜搜地图使用,高德
 *  * BD09:百度坐标,GCJ02机密后的坐标系
 *
 * Created by Bing on 2021/5/8.
 */
@Component
public class GpsUtil {
    public static final String BAIDU_LBS_TYPE = "bd09ll";
    public static double pi = 3.1415926535897932384626;
    public static double a = 6378245.0;
    public static double ee = 0.00669342162296594323;
    /**
     * 84 to 火星坐标系 (GCJ-02) World Geodetic System ==> Mars Geodetic System
     * @param lat
     * @param lon
     */
    public  JSONObject gps84_To_Gcj02(double lat, double lon) {
        if (outOfChina(lat, lon)) {
            return null;
        }
        double dLat = transformLat(lon - 105.0, lat - 35.0);
        double dLon = transformLon(lon - 105.0, lat - 35.0);
        double radLat = lat / 180.0 * pi;
        double magic = Math.sin(radLat);
        magic = 1 - ee * magic * magic;
        double sqrtMagic = Math.sqrt(magic);
        dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
        dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
        double mgLat = lat + dLat;
        double mgLon = lon + dLon;
        return getPosition(mgLat, mgLon);
    }
    /**
     * * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return
     */
    public  JSONObject gcj_To_Gps84(double lat, double lon) {
        JSONObject gps = transform(lat, lon);
        double lontitude = lon * 2 - gps.getDouble("lon");
        double latitude = lat * 2 - gps.getDouble("lat");
        return getPosition(latitude, lontitude);
    }
    /**
     * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标
     *
     * @param gg_lat
     * @param gg_lon
     */
    public  JSONObject gcj02_To_Bd09(double gg_lat, double gg_lon) {
        double x = gg_lon, y = gg_lat;
        double z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi);
        double theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi);
        double bd_lon = z * Math.cos(theta) + 0.0065;
        double bd_lat = z * Math.sin(theta) + 0.006;
        return getPosition(bd_lat, bd_lon);
    }
    /**
     * * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 * * 将 BD-09 坐标转换成GCJ-02 坐标 * * @param
     * bd_lat * @param bd_lon * @return
     */
    public  JSONObject bd09_To_Gcj02(double bd_lat, double bd_lon) {
        double x = bd_lon - 0.0065, y = bd_lat - 0.006;
        double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi);
        double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi);
        double gg_lon = z * Math.cos(theta);
        double gg_lat = z * Math.sin(theta);
        return getPosition(gg_lat, gg_lon);
    }
    /**
     * (BD-09)-->84
     * @param bd_lat
     * @param bd_lon
     * @return
     */
    public  JSONObject bd09_To_Gps84(double bd_lat, double bd_lon) {
        JSONObject gcj02 = bd09_To_Gcj02(bd_lat, bd_lon);
        JSONObject map84 = gcj_To_Gps84(gcj02.getDouble("lat"),
                gcj02.getDouble("lon"));
        return map84;
    }
    /**
     * is or not outOfChina
     * @param lat
     * @param lon
     * @return
     */
    public  boolean outOfChina(double lat, double lon) {
        if (lon < 72.004 || lon > 137.8347)
            return true;
        if (lat < 0.8293 || lat > 55.8271)
            return true;
        return false;
    }
    public  JSONObject transform(double lat, double lon) {
        if (outOfChina(lat, lon)) {
            return getPosition(lat, lon);
        }
        double dLat = transformLat(lon - 105.0, lat - 35.0);
        double dLon = transformLon(lon - 105.0, lat - 35.0);
        double radLat = lat / 180.0 * pi;
        double magic = Math.sin(radLat);
        magic = 1 - ee * magic * magic;
        double sqrtMagic = Math.sqrt(magic);
        dLat = (dLat * 180.0) / ((a * (1 - ee)) / (magic * sqrtMagic) * pi);
        dLon = (dLon * 180.0) / (a / sqrtMagic * Math.cos(radLat) * pi);
        double mgLat = lat + dLat;
        double mgLon = lon + dLon;
        return getPosition(mgLat, mgLon);
    }
    public  double transformLat(double x, double y) {
        double ret = -100.0 + 2.0 * x + 3.0 * y + 0.2 * y * y + 0.1 * x * y
                + 0.2 * Math.sqrt(Math.abs(x));
        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(y * pi) + 40.0 * Math.sin(y / 3.0 * pi)) * 2.0 / 3.0;
        ret += (160.0 * Math.sin(y / 12.0 * pi) + 320 * Math.sin(y * pi / 30.0)) * 2.0 / 3.0;
        return ret;
    }
    public  double transformLon(double x, double y) {
        double ret = 300.0 + x + 2.0 * y + 0.1 * x * x + 0.1 * x * y + 0.1
                * Math.sqrt(Math.abs(x));
        ret += (20.0 * Math.sin(6.0 * x * pi) + 20.0 * Math.sin(2.0 * x * pi)) * 2.0 / 3.0;
        ret += (20.0 * Math.sin(x * pi) + 40.0 * Math.sin(x / 3.0 * pi)) * 2.0 / 3.0;
        ret += (150.0 * Math.sin(x / 12.0 * pi) + 300.0 * Math.sin(x / 30.0
                * pi)) * 2.0 / 3.0;
        return ret;
    }
    public JSONObject getPosition(double lat, double lon){
        JSONObject result = new JSONObject();
        result.put("lat",lat);
        result.put("lon",lon);
        return result;
    }
}

+ 0 - 83
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java

@ -226,38 +226,6 @@ public class DeviceController {
        }
    }
    @ApiOperation("柏颐设备sos数据接收")
    @RequestMapping(value = "bySos", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String bySos(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="heartrate",required = false,value="心率")
            @RequestParam(value = "heartrate",required = false) int heartrate,
            @ApiParam(name="city",required = false,value="城市")
            @RequestParam(value = "city",required = false) String city,
            @ApiParam(name="address",required = false,value="地址")
            @RequestParam(value = "address",required = false) String address,
            @ApiParam(name="lon",required = false,value="经度")
            @RequestParam(value = "lon",required = false) double lon,
            @ApiParam(name="lat",required = false,value="纬度")
            @RequestParam(value = "lat",required = false) double lat,
            @ApiParam(name="type",required = false,value="类型  0:Gps定位; 1:基站定位")
            @RequestParam(value = "type",required = false) String type,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("请求参数:"+paraString);
            deviceService.bySos(imei,time_begin,heartrate,city,address,lon,lat,type);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐设备步数接收")
    @RequestMapping(value = "bySteps", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String bySteps(
@ -310,57 +278,6 @@ public class DeviceController {
        }
    }
    @ApiOperation("柏颐设备开关机数据接收")
    @RequestMapping(value = "bySwitch", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String bySwitch(
            @ApiParam(name="imei",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "imei",required = true) String imei,
            @ApiParam(name="time_begin",required = false,value="发生时间YYYY-MM-DD HH:mm:SS")
            @RequestParam(value = "time_begin",required = false) String time_begin,
            @ApiParam(name="type",required = false,value="开/关机类型  0:开机; 1:关机; 2:电量上报; 3:低电通知")
            @RequestParam(value = "type",required = false) String type,
            @ApiParam(name="remaining_power",required = false,value="剩余电量(%)")
            @RequestParam(value = "remaining_power",required = false) int remaining_power,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("请求参数:"+paraString);
            deviceService.bySwitch(imei,time_begin,type,remaining_power);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    @ApiOperation("柏颐设备消息通知数据接收")
    @RequestMapping(value = "byPushData", produces = "application/x-www-form-urlencoded;charset=UTF-8", method = {RequestMethod.POST,RequestMethod.GET})
    public String byPushData(
            @ApiParam(name="type",required = false,value="type=1 SOS,type=2 fall,type=3 new 新成员加入 ,type=4 电子围栏触发, type=5 设备低电,type=6 环境音 ",defaultValue = "")
            @RequestParam(value = "type",required = false) int type,
            @ApiParam(name="deviceid",required = false,value="15位设备唯一序号",defaultValue = "")
            @RequestParam(value = "deviceid",required = true) String deviceid,
            @ApiParam(name="communityid",required = false,value="机构ID")
            @RequestParam(value = "communityid",required = false) String communityid,
            @ApiParam(name="url",required = false,value="环境音下载地址 只有环境音(type=6)为必填,其他type都为非必填")
            @RequestParam(value = "url",required = false) String url,
            @ApiParam(name="name",required = false,value="设备名称")
            @RequestParam(value = "name",required = false) String name,
            HttpServletRequest request) {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("请求参数:"+paraString);
            deviceService.byPushData(type,deviceid,communityid,url,name);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1,"Device data incoming failure");
        }
    }
    /**
     * 返回接口处理结果

+ 16 - 61
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

@ -4,8 +4,10 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.DevicePatientHealthIndexDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang.StringUtils;
@ -45,6 +47,8 @@ public class DeviceService {
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private DevicePatientHealthIndexDao healthIndexDao;
    @Autowired
    private BasePatientDao patientDao;
    /**
     * 获取爱牵挂管理员cookie
@ -195,7 +199,9 @@ public class DeviceService {
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
                    patientHealthIndex.setName(patientDO.getName());
                    patientHealthIndex.setDeviceSn(imei);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
@ -208,6 +214,10 @@ public class DeviceService {
                    if (heartrate>=theshold_heartrate_h||heartrate<=theshold_heartrate_l){
                        patientHealthIndex.setStatus(1);
                    }
                    else {
                        patientHealthIndex.setStatus(0);
                    }
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                }
            }
@ -233,7 +243,9 @@ public class DeviceService {
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(imei);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice devicePatientDevice = devicePatientDeviceDos.get(0);
                    BasePatientDO patientDO = patientDao.findById(devicePatientDevice.getUser());
                    DevicePatientHealthIndex patientHealthIndex = new DevicePatientHealthIndex();
                    patientHealthIndex.setName(patientDO.getName());
                    patientHealthIndex.setDeviceSn(imei);
                    patientHealthIndex.setUser(devicePatientDevice.getUser());
                    patientHealthIndex.setIdcard(devicePatientDevice.getUserIdcard());
@ -247,6 +259,10 @@ public class DeviceService {
                    if (sbp>=sbp_h||dbp<=dbp_l){
                        patientHealthIndex.setStatus(1);
                    }
                    else {
                        patientHealthIndex.setStatus(0);
                    }
                    patientHealthIndex.setDel("1");
                    healthIndexDao.save(patientHealthIndex);
                }
            }
@ -278,29 +294,6 @@ public class DeviceService {
        }
    }
    /**
     * 柏颐sos 接收
     * @param imei  15位设备唯一序号
     * @param time_begin  发生时间YYYY-MM-DD HH:mm:SS
     * @param heartrate   心率
     * @param city  城市
     * @param address  地址
     * @param lon  经度
     * @param lat  纬度
     * @param type  类型   0:Gps定位; 1:基站定位
     */
    @Async
    public void bySos(String imei,String time_begin,int heartrate,String city,String address,double lon,double lat,String type) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐步数数据接收
     * @param imei 15位设备唯一序号
@ -340,42 +333,4 @@ public class DeviceService {
        }
    }
    /**
     * 柏颐开关机数据接收
     * @param imei 15位设备唯一序号
     * @param time_begin 发生时间YYYY-MM-DD HH:mm:SS
     * @param type 开/关机类型  0:开机; 1:关机; 2:电量上报; 3:低电通知
     * @param remaining_power 剩余电量(%)
     */
    @Async
    public void bySwitch(String imei,String time_begin,String type,int remaining_power) {
        try {
            if(StringUtils.isNotBlank(imei)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    /**
     * 柏颐数据消息通知
     * @param type  type=1 SOS,type=2 fall,type=3 new 新成员加入 ,type=4 电子围栏触发, type=5 设备低电,type=6 环境音
     * @param deviceid 15位设备唯一序号
     * @param communityid 机构ID
     * @param url 环境音下载地址 只有环境音(type=6)为必填,其他type都为非必填
     * @param name 设备名称
     */
    @Async
    public void byPushData(int type,String deviceid,String communityid,String url,String name) {
        try {
            if(StringUtils.isNotBlank(deviceid)){
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}