liubing hace 4 años
padre
commit
3483f6c344
Se han modificado 16 ficheros con 360 adiciones y 15 borrados
  1. 6 0
      business/base-service/src/main/java/com/yihu/jw/org/dao/BaseOrgDao.java
  2. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/base/org/BaseOrgDO.java
  3. 5 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  4. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  5. 20 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/doctor/DoctorEndpoint.java
  6. 15 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  7. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  8. 14 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  9. 52 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  10. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java
  11. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  12. 42 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  13. 19 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  14. 9 9
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
  15. 155 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/GpsUtil.java
  16. 16 0
      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);
}

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

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

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

@ -50,5 +50,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);
}

+ 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("查询失败");
        }
    }
}

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

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

@ -728,7 +728,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;
    }
}

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

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