Преглед изворни кода

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

wangzhinan пре 3 година
родитељ
комит
c8f4a356d9
17 измењених фајлова са 923 додато и 129 уклоњено
  1. 3 0
      business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java
  2. 18 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  3. 3 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  4. 3 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java
  5. 3 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java
  6. 18 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  7. 107 99
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YsDeviceService.java
  8. 3 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YunXunDeviceService.java
  9. 3 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java
  10. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  11. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  12. 59 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  13. 3 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/yunxin/YunxinService.java
  14. 694 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HttpClientUtilCare.java
  15. 1 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java
  16. 1 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  17. 2 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java

+ 3 - 0
business/es-service/src/main/java/com/yihu/jw/es/util/ElasticsearchUtil.java

@ -454,6 +454,9 @@ public class ElasticsearchUtil {
                areaLevel = areaLevels.get(0);
            }
        }
        if (StringUtils.isBlank(areaLevel)){
            areaLevel="6";
        }
        if (StringUtils.isNotEmpty(startDate)) {
            if (startDate.length() > 10) {
                startDate = changeTime(startDate);

+ 18 - 6
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -26,10 +26,7 @@ import io.swagger.annotations.ApiParam;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.Map;
@ -131,6 +128,19 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getPatientInfoNew")
    @ApiOperation("获取居民详情页")
    public ObjEnvelop getPatientInfoNew(@ApiParam(name="patient",value = "居民id",required = true)
                                     @RequestParam(value = "patient")String patient,
                                     @ApiParam(name="patientType",value="患者类型 1老人 2 新生儿")
                                     @RequestParam(name = "patientType",required = false,defaultValue = "1")Integer patientType){
        try {
            return ObjEnvelop.getSuccess("查询成功",patientInfoPlatFormService.getPatientInfoNew(patient,patientType));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "getPatientEvent")
    @ApiOperation("获取就诊事件")
    public ObjEnvelop getPatientEvent(@ApiParam(name="patient",value = "居民id",required = true)
@ -211,9 +221,11 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getPatientMonitoringInfo")
    @ApiOperation("获取居民安监护信息")
    public String getHealthIndexInfo(@ApiParam(name="patient",value="患者代码",defaultValue = "808080eb7917a3be017918a979380055")
                                     @RequestParam(value="patient",required = true) String patient){
                                     @RequestParam(value="patient",required = true) String patient,
                                     @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典", required = false)
                                     @RequestParam(value = "topicItem",required = false) String topicItem){
        try {
            return baseController.write (200,"查询成功","data",patientInfoPlatFormService.getPatientMonitoringInfo(patient));
            return baseController.write (200,"查询成功","data",securityMonitoringOrderService.patientMonitoringInfo(patient,topicItem));
        }catch (Exception e){
            return baseController.errorResult(e);
        }

+ 3 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java

@ -21,6 +21,7 @@ import com.yihu.jw.care.service.doctor.DoctorServicePermissionsService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.care.util.HttpClientUtilCare;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -51,7 +52,7 @@ import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
@ -93,7 +94,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    @Autowired
    private ConsultTeamDao consultTeamDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private HttpClientUtilCare httpClientUtil;
    @Autowired
    private PatientDeviceService patientDeviceService;
    @Autowired
@ -441,7 +442,6 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
//                        }
//
//                    }
                    System.out.println("1");
                }catch (Exception e){
                    e.printStackTrace();
                }

+ 3 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/DeviceDetailService.java

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.util.HttpClientUtilCare;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -13,7 +14,7 @@ import com.yihu.jw.entity.care.device.DeviceDetail;
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 com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
@ -49,7 +50,7 @@ public class DeviceDetailService extends BaseJpaService<DeviceDetail, DeviceDeta
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private HttpClientUtil httpClientUtil;
	private HttpClientUtilCare httpClientUtil;
	@Value("${cloudCare.deviceUrl}")
	private String cloudDeviceUrl;

+ 3 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java

@ -4,8 +4,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.config.NetworkCardConfig;
import com.yihu.jw.care.config.YsConfig;
import com.yihu.jw.care.util.HttpClientUtilCare;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
@ -31,7 +32,7 @@ public class NetworkCardService {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private HttpClientUtilCare httpClientUtil;
    /**
     * 获取电信物联网卡assesToken

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

@ -11,10 +11,7 @@ import com.yihu.jw.care.service.assistance.EmergencyAssistanceService;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.wechat.WeiXinAccessTokenUtils;
import com.yihu.jw.care.util.ConcealUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.care.util.MyJdbcTemplate;
import com.yihu.jw.care.util.Point;
import com.yihu.jw.care.util.*;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -29,7 +26,7 @@ import com.yihu.jw.util.common.LatitudeUtils;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.entity.ServiceException;
import com.yihu.jw.util.healthIndex.HealthIndexUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
@ -92,7 +89,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private HttpClientUtilCare httpClientUtil;
    @Autowired
    private YsDeviceService ysDeviceService;
    @Autowired
@ -1690,6 +1687,21 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return json.getJSONObject("obj");
    }
    public com.alibaba.fastjson.JSONObject getAqgDeviceInfo2(String imei){
        try {
            String url = MessageFormat.format(AqgConfig.deviceInfo, imei);
            HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, null, HttpMethod.GET, getCookie());
            com.alibaba.fastjson.JSONObject json = response.getBody();
            if(!json.getBoolean("success")){
                return  null;
            }
            return json.getJSONObject("obj");
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }
    /**
     * 修改删除 爱牵挂亲情号码
     * @param deviceSn

+ 107 - 99
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YsDeviceService.java

@ -8,12 +8,13 @@ import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.device.YsConfigDao;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.util.DeviceUtil;
import com.yihu.jw.care.util.HttpClientUtilCare;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.device.YsConfigDo;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.rm.iot.IotRequestMapping;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.encode.Base64;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
@ -48,7 +49,7 @@ public class YsDeviceService {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private HttpClientUtilCare httpClientUtil;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
@ -219,7 +220,7 @@ public class YsDeviceService {
    /**
     * 获取视频地址
     */
    public JSONObject getDeviceLiveAddress(String patient,String deviceSerial,Integer channelNo,HttpServletRequest request) throws Exception {
    public JSONObject getDeviceLiveAddress(String patient,String deviceSerial,Integer channelNo,HttpServletRequest request){
        JSONObject result = new JSONObject();
        if (StringUtils.isBlank(deviceSerial)){
            if (StringUtils.isNotBlank(patient)){
@ -230,7 +231,12 @@ public class YsDeviceService {
            }
        }
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("accessToken",getIotAccessToken(deviceSerial));
        try {
            param.add("accessToken",getIotAccessToken(deviceSerial));
        }catch (Exception e){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"监控accessToken获取失败");
        }
        param.add("deviceSerial",deviceSerial);
        param.add("channelNo",channelNo+"");
        HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp(YsConfig.getDeviceLiveAddress,param,HttpMethod.POST);
@ -416,113 +422,115 @@ public class YsDeviceService {
     * @throws Exception
     */
    public JSONObject deviceVideoTimeList(String patient,String deviceSerial,Integer channelNo,String startTime,String endTime,Integer recType,HttpServletRequest request) throws Exception {
        JSONObject result = new JSONObject();
        if (StringUtils.isBlank(deviceSerial)){
            if (StringUtils.isNotBlank(patient)){
                List<DevicePatientDevice> devices = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
                if (devices.size()>0){
                    deviceSerial = devices.get(0).getDeviceSn();
        synchronized (patient.intern()){
            JSONObject result = new JSONObject();
            if (StringUtils.isBlank(deviceSerial)){
                if (StringUtils.isNotBlank(patient)){
                    List<DevicePatientDevice> devices = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
                    if (devices.size()>0){
                        deviceSerial = devices.get(0).getDeviceSn();
                    }
                }
            }
        }
        MultiValueMap<String,String> param = new LinkedMultiValueMap<>();
        param.add("accessToken",getIotAccessToken(deviceSerial));
        param.add("deviceSerial",deviceSerial);
        param.add("channelNo",channelNo+"");
            MultiValueMap<String,String> param = new LinkedMultiValueMap<>();
            param.add("accessToken",getIotAccessToken(deviceSerial));
            param.add("deviceSerial",deviceSerial);
            param.add("channelNo",channelNo+"");
        if (StringUtils.isNotBlank(startTime)){
            Date tmp = DateUtil.dateTimeParse(startTime);
            long timeStemp = tmp.getTime();
            param.add("startTime",timeStemp+"");
        }
        if (StringUtils.isNotBlank(endTime)){
            Date tmp = DateUtil.dateTimeParse(endTime);
            long timeStemp = tmp.getTime();
            param.add("endTime",timeStemp+"");
        }
        if (null != recType){
            param.add("recType",recType+"");
        }
        HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp(YsConfig.deviceVideoTimeList,param,HttpMethod.POST);
        JSONObject responseBody = response.getBody();
        JSONArray timeTmp = new JSONArray();
        if (responseBody.getInteger("code")==200){
            JSONArray tmp = responseBody.getJSONArray("data");
            if (null==tmp||0==tmp.size()){
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"未获取到当天录像信息");
                return result;
            }
            tmp.sort(Comparator.comparing(obj -> Long.parseLong(((LinkedHashMap) obj).get("startTime").toString())));
            LinkedHashMap tmpFirst = tmp.getObject(0,LinkedHashMap.class);
            Long startTimeStr1 =  Long.parseLong(tmpFirst.get("startTime").toString()) ;
            long current = 0;
            if (StringUtils.isNotBlank(startTime)){
                current = DateUtil.strToDate(startTime).getTime();
            }else {
                current = System.currentTimeMillis();
                Date tmp = DateUtil.dateTimeParse(startTime);
                long timeStemp = tmp.getTime();
                param.add("startTime",timeStemp+"");
            }
            long toDayZero = current/(1000*3600*24)*(1000*3600*24) - TimeZone.getDefault().getRawOffset();
            if (toDayZero-startTimeStr1>0){//去除开始时间不为当天是时间段
                tmp.remove(0);
            if (StringUtils.isNotBlank(endTime)){
                Date tmp = DateUtil.dateTimeParse(endTime);
                long timeStemp = tmp.getTime();
                param.add("endTime",timeStemp+"");
            }
            if (null==tmp||0==tmp.size()){
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"未获取到当天录像信息");
                return result;
            if (null != recType){
                param.add("recType",recType+"");
            }
            LinkedHashMap mergeTmp = null;
            Iterator<Object> arrIterator = tmp.iterator();
            while (arrIterator.hasNext()) {
                LinkedHashMap mapTmp = (LinkedHashMap) arrIterator.next();
                Long startTimeStr =  Long.parseLong(mapTmp.get("startTime").toString()) ;
                Long endTimeStr = Long.parseLong(mapTmp.get("endTime").toString()) ;
                String startTimeDate = DateUtil.dateToStrLong(new Date(startTimeStr));
                String endTimeDate = DateUtil.dateToStrLong(new Date(endTimeStr));
                Long videoLong = (endTimeStr-startTimeStr)/1000;
                if (null==mergeTmp){
                    mergeTmp = new LinkedHashMap();
                    mergeTmp.put("recType",mapTmp.get("recType"));
                    mergeTmp.put("startTime",mapTmp.get("startTime"));
                    mergeTmp.put("endTime",mapTmp.get("endTime"));
                    mergeTmp.put("startTimeDate",startTimeDate);
                    mergeTmp.put("endTimeDate",endTimeDate);
                    mergeTmp.put("createTime",mapTmp.get("createTime"));
                    mergeTmp.put("deviceSerial",mapTmp.get("deviceSerial"));
                    mergeTmp.put("channelNo",mapTmp.get("channelNo"));
                    mergeTmp.put("videoLong",videoLong);
                    continue;
            HttpEntity<JSONObject> response = httpClientUtil.iotAssesTokenPostHttp(YsConfig.deviceVideoTimeList,param,HttpMethod.POST);
            JSONObject responseBody = response.getBody();
            JSONArray timeTmp = new JSONArray();
            if (responseBody.getInteger("code")==200){
                JSONArray tmp = responseBody.getJSONArray("data");
                if (null==tmp||0==tmp.size()){
                    result.put(ResponseContant.resultFlag,ResponseContant.fail);
                    result.put(ResponseContant.resultMsg,"未获取到当天录像信息");
                    return result;
                }
                if (startTimeStr==Long.parseLong(mergeTmp.get("endTime").toString())){//时间区间相连
                    startTimeStr =  Long.parseLong(mergeTmp.get("startTime").toString()) ;
                    videoLong = (endTimeStr-startTimeStr)/1000;
                    mergeTmp.put("endTime",mapTmp.get("endTime"));
                    mergeTmp.put("endTimeDate",endTimeDate);
                    mergeTmp.put("videoLong",videoLong);
                }else{
                    timeTmp.add(mergeTmp);
                    mergeTmp = new LinkedHashMap();
                    mergeTmp.put("recType",mapTmp.get("recType"));
                    mergeTmp.put("startTime",mapTmp.get("startTime"));
                    mergeTmp.put("endTime",mapTmp.get("endTime"));
                    mergeTmp.put("startTimeDate",startTimeDate);
                    mergeTmp.put("endTimeDate",endTimeDate);
                    mergeTmp.put("createTime",mapTmp.get("createTime"));
                    mergeTmp.put("deviceSerial",mapTmp.get("deviceSerial"));
                    mergeTmp.put("channelNo",mapTmp.get("channelNo"));
                    mergeTmp.put("videoLong",videoLong);
                tmp.sort(Comparator.comparing(obj -> Long.parseLong(((LinkedHashMap) obj).get("startTime").toString())));
                LinkedHashMap tmpFirst = tmp.getObject(0,LinkedHashMap.class);
                Long startTimeStr1 =  Long.parseLong(tmpFirst.get("startTime").toString()) ;
                long current = 0;
                if (StringUtils.isNotBlank(startTime)){
                    current = DateUtil.strToDate(startTime).getTime();
                }else {
                    current = System.currentTimeMillis();
                }
                if (!arrIterator.hasNext()){
                    timeTmp.add(mergeTmp);
                long toDayZero = current/(1000*3600*24)*(1000*3600*24) - TimeZone.getDefault().getRawOffset();
                if (toDayZero-startTimeStr1>0){//去除开始时间不为当天是时间段
                    tmp.remove(0);
                }
                if (null==tmp||0==tmp.size()){
                    result.put(ResponseContant.resultFlag,ResponseContant.fail);
                    result.put(ResponseContant.resultMsg,"未获取到当天录像信息");
                    return result;
                }
                LinkedHashMap mergeTmp = null;
                Iterator<Object> arrIterator = tmp.iterator();
                while (arrIterator.hasNext()) {
                    LinkedHashMap mapTmp = (LinkedHashMap) arrIterator.next();
                    Long startTimeStr =  Long.parseLong(mapTmp.get("startTime").toString()) ;
                    Long endTimeStr = Long.parseLong(mapTmp.get("endTime").toString()) ;
                    String startTimeDate = DateUtil.dateToStrLong(new Date(startTimeStr));
                    String endTimeDate = DateUtil.dateToStrLong(new Date(endTimeStr));
                    Long videoLong = (endTimeStr-startTimeStr)/1000;
                    if (null==mergeTmp){
                        mergeTmp = new LinkedHashMap();
                        mergeTmp.put("recType",mapTmp.get("recType"));
                        mergeTmp.put("startTime",mapTmp.get("startTime"));
                        mergeTmp.put("endTime",mapTmp.get("endTime"));
                        mergeTmp.put("startTimeDate",startTimeDate);
                        mergeTmp.put("endTimeDate",endTimeDate);
                        mergeTmp.put("createTime",mapTmp.get("createTime"));
                        mergeTmp.put("deviceSerial",mapTmp.get("deviceSerial"));
                        mergeTmp.put("channelNo",mapTmp.get("channelNo"));
                        mergeTmp.put("videoLong",videoLong);
                        continue;
                    }
                    if (startTimeStr==Long.parseLong(mergeTmp.get("endTime").toString())){//时间区间相连
                        startTimeStr =  Long.parseLong(mergeTmp.get("startTime").toString()) ;
                        videoLong = (endTimeStr-startTimeStr)/1000;
                        mergeTmp.put("endTime",mapTmp.get("endTime"));
                        mergeTmp.put("endTimeDate",endTimeDate);
                        mergeTmp.put("videoLong",videoLong);
                    }else{
                        timeTmp.add(mergeTmp);
                        mergeTmp = new LinkedHashMap();
                        mergeTmp.put("recType",mapTmp.get("recType"));
                        mergeTmp.put("startTime",mapTmp.get("startTime"));
                        mergeTmp.put("endTime",mapTmp.get("endTime"));
                        mergeTmp.put("startTimeDate",startTimeDate);
                        mergeTmp.put("endTimeDate",endTimeDate);
                        mergeTmp.put("createTime",mapTmp.get("createTime"));
                        mergeTmp.put("deviceSerial",mapTmp.get("deviceSerial"));
                        mergeTmp.put("channelNo",mapTmp.get("channelNo"));
                        mergeTmp.put("videoLong",videoLong);
                    }
                    if (!arrIterator.hasNext()){
                        timeTmp.add(mergeTmp);
                    }
                }
                result.put(ResponseContant.resultFlag,ResponseContant.success);
                result.put(ResponseContant.resultMsg,timeTmp);
            }else {
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,responseBody.getString("msg"));
            }
            result.put(ResponseContant.resultFlag,ResponseContant.success);
            result.put(ResponseContant.resultMsg,timeTmp);
        }else {
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,responseBody.getString("msg"));
            return result;
        }
        return result;
        //https://open.ys7.com/doc/zh/book/index/device_select.html#device_select-api9
    }

+ 3 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/YunXunDeviceService.java

@ -1,6 +1,7 @@
package com.yihu.jw.care.service.device;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.care.util.HttpClientUtilCare;
import com.yihu.jw.utils.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -20,7 +21,7 @@ public class YunXunDeviceService {
    private static Logger logger = LoggerFactory.getLogger(YunXunDeviceService.class);
    @Autowired
    private HttpClientUtil httpClientUtil;
    private HttpClientUtilCare httpClientUtil;
    /**
     * 设置紧急联系人

+ 3 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doorCoach/DoctorDoorCoachOrderService.java

@ -7,6 +7,7 @@ import com.yihu.jw.care.dao.doorCoach.*;
import com.yihu.jw.care.dao.lifeCare.BaseAdminServiceDynamicDao;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.util.EntranceUtil;
import com.yihu.jw.care.util.HttpClientUtilCare;
import com.yihu.jw.care.util.MessageUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
@ -32,7 +33,7 @@ import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.wechat.dao.BasePatientWechatDao;
import org.apache.commons.lang.StringUtils;
import org.jsoup.Jsoup;
@ -107,7 +108,7 @@ public class DoctorDoorCoachOrderService {
    @Value("${base.hospitalUrl}")
    private String hospitalUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private HttpClientUtilCare httpClientUtil;
    @Value("${wechat.id}")
    private String wxId;
    @Autowired

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

@ -1476,7 +1476,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            if (devicePatientDeviceDos.size()>0&&(4==categoryCode||0==categoryCode)){
                DevicePatientDevice device = devicePatientDeviceDos.get(0);
                result.put("deviceSn",device.getDeviceSn());
                JSONObject response= patientDeviceService.getAqgDeviceInfo(device.getDeviceSn());
                JSONObject response= patientDeviceService.getAqgDeviceInfo2(device.getDeviceSn());
                if (response!=null){
                    //定位信息
                    if (response.containsKey("last_location")&&response.get("last_location")!=null){

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

@ -50,6 +50,7 @@ import java.util.stream.Collectors;
 * Created by yeshijie on 2021/4/7.
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class StatisticsService {
    Logger logger = LoggerFactory.getLogger(StatisticsService.class);

+ 59 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java

@ -142,6 +142,65 @@ public class PatientInfoPlatFormService {
        return null;
    }
    /**
     * 老人--基本信息
     * @param patient
     * @param patientType 1老人 2新生儿
     * @return
     */
    public JSONObject getPatientInfoNew(String patient,Integer patientType){
        JSONObject result = new JSONObject();
        JSONObject tmp = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(patient);
        if (patientDO!=null){
            tmp.put("name",patientDO.getName());
            tmp.put("sex",patientDO.getSex());
            tmp.put("address",patientDO.getAddress());
            tmp.put("address",patientDO.getAddress());
            tmp.put("patient",patientDO.getId());
            String idcard = patientDO.getIdcard();
            if (StringUtils.isNotBlank(idcard)){
                Integer age = IdCardUtil.getAgeForIdcard(idcard);
                tmp.put("age",age);
            }else {
                tmp.put("age",null);
            }
            //标签类型
            List<String> labelList = new ArrayList<>();
            Integer sex = patientDO.getSex();
            String sexName = sex!=null?(1==sex?"男性":"女性"):"未知";
            labelList.add(sexName);
            List<WlyyPatientLabelDO> labelDOS = patientLabelDao.findByPatient(patient);
            List<String> labeltmp = labelDOS.stream().map(WlyyPatientLabelDO::getLabelName).collect(Collectors.toList());
            labelList.addAll(labeltmp);
            tmp.put("patientLabel",labelList);
            result.put("patientInfo",tmp);//基本信息
            result.put("patientDevices",getDevices(patient,patientType));//健康设备
            if (1==patientType){
                result.put("signService",getSignService(patient));//签约服务
//                result.put("MonitoringInfo",getPatientMonitoringInfo(patient));//安防监护信息调用另外一个接口
            }
            if (2==patientType){
                result.put("entranceOrgList",getEntranceOrgList(patient));//入园机构列表(报名且录取机构)
                result.put("MonitoringInfo",getMonitoringInfo(patient)); //新生儿入院信息
            }
            //能力评估
            try{
                CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patient);
                result.put("capAssRecordDO",recordDO);
            }catch (Exception e){
                e.printStackTrace();
            }
            //能力状况
            BaseCapacityLabelDO capacityLabelDO = capacityLabelDao.findByPatient(patient);
            result.put("capacityLabelDO",capacityLabelDO);
            return result;
        }
        return null;
    }
    /**
     * 老人--获取签约服务
     * @param patient

+ 3 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/yunxin/YunxinService.java

@ -1,10 +1,11 @@
package com.yihu.jw.care.service.yunxin;
import com.yihu.jw.care.util.HttpClientUtilCare;
import com.yihu.jw.entity.base.yx.YxTokenMappingDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.hospital.dict.WlyyHospitalSysDictDao;
import com.yihu.jw.util.common.StringUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.utils.CheckSumBuilder;
import com.yihu.jw.utils.GenerateUserSig;
import com.yihu.jw.yx.dao.YxTokenMappingDao;
@ -38,7 +39,7 @@ public class YunxinService {
    @Autowired
    private WlyyHospitalSysDictDao hospitalSysDictDao;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private HttpClientUtilCare httpClientUtil;
    @Autowired
    private YxTokenMappingDao yxTokenMappingDao;

+ 694 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HttpClientUtilCare.java

@ -0,0 +1,694 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.entity.base.dict.BaseExceptionDictDO;
import com.yihu.jw.entity.base.dict.BaseExceptionLogDO;
import com.yihu.jw.entity.base.dict.BaseExceptionServerDictDO;
import com.yihu.jw.util.dao.BaseExceptionDictUtilDao;
import com.yihu.jw.util.dao.BaseExceptionLogUtilDao;
import com.yihu.jw.util.dao.BaseExceptionServerDictUtilDao;
import org.apache.http.Consts;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.ParseException;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.*;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.*;
@Component
public class HttpClientUtilCare {
    /**
     * 发送post请求
     *
     * @param url     请求地址
     * @param params  请求参数
     * @param chatSet 编码格式
     * @return
     */
    public  String post(String url, List<NameValuePair> params, String chatSet) {
        // 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost(url);
        UrlEncodedFormEntity uefEntity;
        try {
            uefEntity = new UrlEncodedFormEntity(params, chatSet);
            httppost.setEntity(uefEntity);
            CloseableHttpResponse response = httpclient.execute(httppost);
            try {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
    /**
     * 发送get请求
     *
     * @param url     请求地址
     * @param chatSet 编码格式
     * @return
     */
    public  String get(String url, String chatSet) {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            // 创建httpget.
            HttpGet httpget = new HttpGet(url);
            // 执行get请求.
            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                // 获取响应实体
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            System.out.println(e.getClass()+"1");
            e.printStackTrace();
        } catch (ParseException e) {
            System.out.println(e.getClass()+"2");
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println(e.getClass()+"3");
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
    public  String get(String url,List<NameValuePair> params, String chatSet) {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            // 创建httpget.
            String entityString = EntityUtils.toString(new UrlEncodedFormEntity(params, Consts.UTF_8));
            HttpGet httpget = new HttpGet(url+"?"+entityString);
            // 执行get请求.
            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                // 获取响应实体
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
    /**
     * http调用方法,(健康之路开放平台)
     *
     * @param url
     * @param params
     * @return
     * @throws Exception
     */
    public static String httpPost(String url, Map<String, String> params) throws Exception {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            HttpPost httpPost = new HttpPost(url);
            if (params != null && params.size() > 0) {
                List<NameValuePair> valuePairs = new ArrayList<NameValuePair>(params.size());
                for (Map.Entry<String, String> entry : params.entrySet()) {
                    NameValuePair nameValuePair = new BasicNameValuePair(entry.getKey(), String.valueOf(entry.getValue()));
                    valuePairs.add(nameValuePair);
                }
                UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(valuePairs, "UTF-8");
                httpPost.setEntity(formEntity);
            }
            CloseableHttpResponse resp = httpclient.execute(httpPost);
            try {
                HttpEntity entity = resp.getEntity();
                String respContent = EntityUtils.toString(entity, "UTF-8").trim();
                return respContent;
            } finally {
                resp.close();
            }
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            httpclient.close();
        }
    }
    /**
     * 获取加密后参数集合(健康之路开放平台)
     *
     * @param params
     * @return
     */
    public  Map<String, String> getSecretParams(Map<String, String> params, String appId, String secret) {
        String timestamp = Long.toString(System.currentTimeMillis());
        params.put("timestamp", timestamp);
        StringBuilder stringBuilder = new StringBuilder();
        // 对参数名进行字典排序  
        String[] keyArray = params.keySet().toArray(new String[0]);
        Arrays.sort(keyArray);
        // 拼接有序的参数名-值串  
        stringBuilder.append(appId);
        for (String key : keyArray) {
            stringBuilder.append(key).append(params.get(key));
        }
        String codes = stringBuilder.append(secret).toString();
        String sign = org.apache.commons.codec.digest.DigestUtils.shaHex(codes).toUpperCase();
        // 添加签名,并发送请求  
        params.put("appId", appId);
        params.put("sign", sign);
        return params;
    }
    /**
     * 向指定 URL 发送POST方法的请求
     *
     * @param url
     *            发送请求的 URL带上参数
     * @param param
     *            POST参数。
     * @return 所代表远程资源的响应结果
     */
    public static  String sendPost(String url, String param) {
        StringBuffer buffer = new StringBuffer();
        PrintWriter out = null;
        BufferedReader in = null;
        HttpURLConnection conn = null;
        try {
            URL realUrl = new URL(url);
            // 打开和URL之间的连接
            conn = (HttpURLConnection) realUrl.openConnection();
            conn.setRequestMethod("POST");
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setUseCaches(false);
            conn.setRequestProperty("Content-Type", "application/json");
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
            osw.write(param.toString());
            osw.flush();
            // 读取返回内容
            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String temp;
            while ((temp = br.readLine()) != null) {
                buffer.append(temp);
                buffer.append("\n");
            }
        } catch (Exception e) {
           e.printStackTrace();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return buffer.toString();
    }
    
    public static   String postBody(String url, JSONObject params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
        String ret = restTemplate.postForObject(url, formEntity, String.class);
        return ret;
    }
    public static String postBodyHead(String url, JSONObject params, Map<String, Object> headerMap) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        for(String str:headerMap.keySet()){
            headers.add(str,headerMap.get(str).toString());
        }
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
        String ret = restTemplate.postForObject(url, formEntity, String.class);
        return ret;
    }
    
    public  void putBody(String url, JSONObject params) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(params.toString(), headers);
        restTemplate.put(url, formEntity, String.class);
    }
    /**
     * 发送post请求
     *
     * @param url     请求地址
     * @param params  请求参数
     * @param chatSet 编码格式
     * @param headerMap 请求头
     * @return
     */
    public  String headerPost(String url, List<NameValuePair> params, String chatSet, Map<String,Object> headerMap) {
        // 创建默认的httpClient实例.
        CloseableHttpClient httpclient = HttpClients.createDefault();
        // 创建httppost
        HttpPost httppost = new HttpPost(url);
        UrlEncodedFormEntity uefEntity;
        try {
            uefEntity = new UrlEncodedFormEntity(params, chatSet);
            httppost.setEntity(uefEntity);
            for(String str:headerMap.keySet()){
                httppost.addHeader(str,headerMap.get(str).toString());
            }
            CloseableHttpResponse response = httpclient.execute(httppost);
            try {
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e1) {
            e1.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
    public  String get(String url, String chatSet,Map<String,Object> headerMap) {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        try {
            // 创建httpget.
            url= url.replaceAll(" ", "%20");
            HttpGet httpget = new HttpGet(url);
            for(String str:headerMap.keySet()){
                httpget.addHeader(str,headerMap.get(str).toString());
            }
            // 执行get请求.
            CloseableHttpResponse response = httpclient.execute(httpget);
            try {
                // 获取响应实体
                HttpEntity entity = response.getEntity();
                if (entity != null) {
                    return EntityUtils.toString(entity, chatSet);
                }
            } finally {
                response.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (ParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            // 关闭连接,释放资源
            try {
                httpclient.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return null;
    }
    /**
     * 原生字符串发送put请求
     *
     * @param url
     * @param token
     * @param jsonStr
     * @return
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static String doPut(String url, String token, String jsonStr) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpPut httpPut = new HttpPut(url);
        RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
        httpPut.setConfig(requestConfig);
        httpPut.setHeader("Content-type", "application/json");
        httpPut.setHeader("DataEncoding", "UTF-8");
        httpPut.setHeader("token", token);
        CloseableHttpResponse httpResponse = null;
        try {
            httpPut.setEntity(new StringEntity(jsonStr));
            httpResponse = httpClient.execute(httpPut);
            HttpEntity entity = httpResponse.getEntity();
            String result = EntityUtils.toString(entity);
            return result;
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } finally {
            if (httpResponse != null) {
                try {
                    httpResponse.close();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            if (null != httpClient) {
                try {
                    httpClient.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
    /**
     * 发送delete请求
     *
     * @param url
     * @param token
     * @param jsonStr
     * @return
     * @throws ClientProtocolException
     * @throws IOException
     */
    public static String doDelete(String url, String token, String jsonStr) {
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpDelete httpDelete = new HttpDelete(url);
        RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
        httpDelete.setConfig(requestConfig);
        httpDelete.setHeader("Content-type", "application/json");
        httpDelete.setHeader("DataEncoding", "UTF-8");
        httpDelete.setHeader("token", token);
        CloseableHttpResponse httpResponse = null;
        try {
            httpResponse = httpClient.execute(httpDelete);
            HttpEntity entity = httpResponse.getEntity();
            String result = EntityUtils.toString(entity);
            return result;
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (httpResponse != null) {
                try {
                    httpResponse.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (null != httpClient) {
                try {
                    httpClient.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return null;
    }
    public String postBodyRawForm(String url, String params) throws IOException {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        List<NameValuePair> pairs = new ArrayList<>(0);
        pairs.add(new BasicNameValuePair("object",params));
        UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(pairs);
        HttpPost httpPost = new HttpPost(url);
        httpPost.setEntity(formEntity);
        CloseableHttpResponse response = httpclient.execute(httpPost);
        HttpEntity entity = response.getEntity();
        String ret = EntityUtils.toString(entity);
        return ret;
    }
    public String getBodyRawForm(String url, String params) throws IOException {
        CloseableHttpClient httpclient = HttpClients.createDefault();
        List<NameValuePair> pairs = new ArrayList<>(0);
        pairs.add(new BasicNameValuePair("object",params));
        String entityString = EntityUtils.toString(new UrlEncodedFormEntity(pairs,Consts.UTF_8));
        HttpGet httpGet = new HttpGet(url+"?"+entityString);
        CloseableHttpResponse response = httpclient.execute(httpGet);
        HttpEntity entity = response.getEntity();
        String ret = EntityUtils.toString(entity);
        return ret;
    }
    /**
     * 爱牵挂请求
     * @param url
     * @param params
     * @return
     */
    public org.springframework.http.HttpEntity<JSONObject> cookiePostHttp(String url,MultiValueMap<String, String> params){
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/x-www-form-urlencoded");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<MultiValueMap<String, String>> request = new org.springframework.http.HttpEntity<>(params, headers);
        org.springframework.http.HttpEntity<JSONObject> response = restTemplate.exchange(url, HttpMethod.POST, request, JSONObject.class);
        return response;
    }
    public org.springframework.http.HttpEntity<JSONObject> aqgCookieHttp(String url, MultiValueMap<String, String> params,HttpMethod method,String cookie) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/x-www-form-urlencoded");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        headers.add("Cookie",cookie);
        org.springframework.http.HttpEntity<MultiValueMap<String, String>> request = new org.springframework.http.HttpEntity<>(params, headers);
        org.springframework.http.HttpEntity<JSONObject> response = restTemplate.exchange(url, method, request, JSONObject.class);
        return response;
    }
    public org.springframework.http.HttpEntity<JSONObject> assesTokenPostHttp(String url, JSONObject params,HttpMethod method){
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType(MediaType.APPLICATION_JSON_VALUE);
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<String> request = new org.springframework.http.HttpEntity<>(params.toString(), headers);
        org.springframework.http.HttpEntity<JSONObject> response = restTemplate.exchange(url, method, request, JSONObject.class);
        return response;
    }
    public  org.springframework.http.HttpEntity<JSONObject> iotAssesTokenPostHttp(String url, MultiValueMap<String, String> params,HttpMethod method){
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType(MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        org.springframework.http.HttpEntity<MultiValueMap<String, String>> request = new org.springframework.http.HttpEntity<>(params, headers);
        org.springframework.http.HttpEntity<JSONObject> response = restTemplate.exchange(url, method, request, JSONObject.class);
        return response;
    }
    /**
     * 向指定URL发送GET方法的请求
     *
     * @param url
     *            发送请求的URL
     * @return URL 所代表远程资源的响应结果
     */
    public String sendGet(String url,Map<String,String> headerMap) {
        String result = "";
        BufferedReader in = null;
        try {
            URL realUrl = new URL(url);
            // 打开和URL之间的连接
            URLConnection connection = realUrl.openConnection();
            // 设置通用的请求属性
            connection.setRequestProperty("accept", "*/*");
            connection.setRequestProperty("connection", "Keep-Alive");
            connection.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            if(headerMap!=null){
                for (String key:headerMap.keySet()){
                    connection.setRequestProperty(key, headerMap.get(key));
                }
            }
            // 建立实际的连接
            connection.connect();
            // 定义 BufferedReader输入流来读取URL的响应
            in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
        return result;
    }
    /**
     * 向指定 URL 发送POST方法的请求
     *
     * @param url
     *            发送请求的 URL带上参数
     * @param param
     *            POST参数。
     * @return 所代表远程资源的响应结果
     */
    public String sendPost(String url, String param,Map<String,String> headerMap) {
        StringBuffer buffer = new StringBuffer();
        PrintWriter out = null;
        BufferedReader in = null;
        HttpURLConnection conn = null;
        try {
            URL realUrl = new URL(url);
            // 打开和URL之间的连接
            conn = (HttpURLConnection) realUrl.openConnection();
            conn.setRequestMethod("POST");
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setUseCaches(false);
            conn.setRequestProperty("Content-Type", "application/json");
            conn.setRequestProperty("accept", "*/*");
            conn.setRequestProperty("connection", "Keep-Alive");
            conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
            if(headerMap!=null){
                for (String key:headerMap.keySet()){
                    conn.setRequestProperty(key, headerMap.get(key));
                }
            }
            OutputStreamWriter osw = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
            osw.write(param.toString());
            osw.flush();
            // 读取返回内容
            BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
            String temp;
            while ((temp = br.readLine()) != null) {
                buffer.append(temp);
                buffer.append("\n");
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (out != null) {
                    out.close();
                }
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
        return buffer.toString();
    }
    public String postBodyAuthorization(String url, String token) {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        headers.add("Authorization", "Basic "+token);
        headers.add("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_VALUE);
        headers.add("Accept",MediaType.ALL_VALUE);
        String str = "grant_type=client_credentials";
        org.springframework.http.HttpEntity<String> formEntity = new org.springframework.http.HttpEntity<String>(str, headers);
        String ret = restTemplate.postForObject(url, formEntity, String.class);
        return ret;
    }
}

+ 1 - 2
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/MessageUtil.java

@ -16,7 +16,6 @@ import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.sms.service.TXYSmsService;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.jw.util.wechat.WeixinMessagePushUtils;
import com.yihu.jw.wechat.dao.WxAccessTokenDao;
import com.yihu.jw.wechat.dao.WxTemplateConfigDao;
@ -49,7 +48,7 @@ public class MessageUtil {
    @Value("${hospital.url}")
    private String serverUrl;
    @Autowired
    private HttpClientUtil httpClientUtil;
    private HttpClientUtilCare httpClientUtil;
    @Autowired
    private WeixinMessagePushUtils weixinMessagePushUtils;
    @Autowired

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

@ -353,7 +353,7 @@ public class DeviceController {
            logger.info("爱牵挂-睡眠带睡眠报告,请求参数:"+paraString);
            dataPushLogUtil.savePushLog(device,paraString,"睡眠带报告数据接收");
            deviceService.bySleepReport(device,date,fallasleep,sleepTime,restTime,awakeTime,lightTime,remTime,deepTime,bucket,
                    avghr,avgbr,awakePer,remPer,lightPer,efficiency,score);
                    avghr,avgbr,awakePer,remPer,lightPer,efficiency,score,deepPer);
            return success();
        } catch (Exception e) {
            e.printStackTrace();

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

@ -869,7 +869,7 @@ public class DeviceService {
    @Async
    public void bySleepReport(String device,String dateStr,String fallasleep,String sleepTime,String restTime,String awakeTime,String lightTime,
                              String remTime,String deepTime,String[] bucket,String avghr,String avgbr,String awakePer,String remPer,String lightPer,
                              String efficiency,String score) {
                              String efficiency,String score,String deepPer) {
        try {
            if(StringUtils.isNotBlank(device)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
@ -896,6 +896,7 @@ public class DeviceService {
                    report.setLightPer(lightPer);
                    report.setEfficiency(efficiency);
                    report.setScore(score);
                    report.setDeepPer(deepPer);
                    sleepDeviceReportDao.save(report);
                }
            }