Procházet zdrojové kódy

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

wangzhinan před 3 roky
rodič
revize
3ae284fd8f
22 změnil soubory, kde provedl 1953 přidání a 181 odebrání
  1. 17 1
      common/common-entity/sql记录
  2. 12 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java
  3. 1 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitDO.java
  4. 97 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitSignDO.java
  5. 16 5
      server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java
  6. 4 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/message/BaseServiceNewsDao.java
  7. 13 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/visit/BaseVisitSignDao.java
  8. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PadLifeCareEndpoint.java
  9. 7 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PatientLifeCareEndpoint.java
  10. 96 35
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java
  11. 151 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java
  12. 79 30
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java
  13. 41 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/visit/VisitEndpoint.java
  14. 23 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  15. 5 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/lifeCare/LifeCareOrderService.java
  16. 35 7
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/BaseServiceNewsService.java
  17. 27 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  18. 140 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java
  19. 667 57
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/StatisticsService.java
  20. 236 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java
  21. 68 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/visit/BaseVisitService.java
  22. 217 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HlsDownloader.java

+ 17 - 1
common/common-entity/sql记录

@ -1804,4 +1804,20 @@ CREATE TABLE `base_patient_monitor_data` (
  `create_time` datetime DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `idx_patient` (`patient`)
) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8mb4 COMMENT='设备监测日志记录表';
) ENGINE=InnoDB AUTO_INCREMENT=95 DEFAULT CHARSET=utf8mb4 COMMENT='设备监测日志记录表';
-- 2022-05-18
CREATE TABLE `base_visit_sign` (
  `id` varchar(50) NOT NULL,
  `visit_id` varchar(50) DEFAULT NULL COMMENT '走访id',
  `type` int(2) DEFAULT NULL COMMENT '签到方式1.定位,2.拍照',
  `doctor` varchar(50) DEFAULT NULL COMMENT '医生',
  `doctor_name` varchar(50) DEFAULT NULL COMMENT '医生姓名',
  `lon` varchar(20) DEFAULT NULL COMMENT '经度',
  `lat` varchar(20) DEFAULT NULL COMMENT '纬度',
  `address` varchar(255) DEFAULT NULL COMMENT '地址',
  `img` varchar(2500) DEFAULT NULL COMMENT '图片地址“,”分割',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `del` int(2) DEFAULT NULL COMMENT '是否删除1为删除,0.为正常',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=257 DEFAULT CHARSET=utf8mb4 COMMENT='日常走访签到';

+ 12 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java

@ -78,6 +78,18 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private double distance;//医生与患者距离 单位km
    private String otherDoctorDistance;
    //居民绑定的设备code
    private String patientDevices;
    @Transient
    public String getPatientDevices() {
        return patientDevices;
    }
    public void setPatientDevices(String patientDevices) {
        this.patientDevices = patientDevices;
    }
    /**
     * 服务小结
     */

+ 1 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitDO.java

@ -17,7 +17,7 @@ public class BaseVisitDO extends UuidIdentityEntityWithCreateTime {
    private String patient;
    private String patientName;
    private String type;//类型 1老人日常走访 2老人日常临时走访(管理端直接新增记录没有计划)
    private String status;//状态 0计划中 1 已完成 2计划超时
    private String status;//状态 0计划中 1 已完成 2计划超时 3 已签到
    private Date visitDate;//完成走访时间
    private Date visitPlanDate;//计划走访时间
    private String doctor;

+ 97 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitSignDO.java

@ -0,0 +1,97 @@
package com.yihu.jw.entity.care.visit;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
 * Created by Bing on 2022/5/18.
 * 日常走访签到表
 */
@Entity
@Table(name = "base_visit_sign")
public class BaseVisitSignDO extends UuidIdentityEntityWithCreateTime {
    private String visitId; //走访id
    private Integer type;  // 签到方式1.定位,2.拍照
    private String doctor; //签到医生
    private String doctorName;
    private String lon; //经度
    private String lat; //纬度
    private String address;//签到地址
    private String img;//图片 多张逗号隔开
    private Integer del; //0无效 1有效
    public String getVisitId() {
        return visitId;
    }
    public void setVisitId(String visitId) {
        this.visitId = visitId;
    }
    public Integer getType() {
        return type;
    }
    public void setType(Integer type) {
        this.type = type;
    }
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    public String getLon() {
        return lon;
    }
    public void setLon(String lon) {
        this.lon = lon;
    }
    public String getLat() {
        return lat;
    }
    public void setLat(String lat) {
        this.lat = lat;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public String getImg() {
        return img;
    }
    public void setImg(String img) {
        this.img = img;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
}

+ 16 - 5
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyLoginEndpoint.java

@ -7,6 +7,7 @@ import com.google.code.kaptcha.util.Config;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.login.BaseLoginLogDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sms.SmsDO;
import com.yihu.jw.entity.base.wx.WxWechatDO;
import com.yihu.jw.entity.hospital.consult.WlyyHospitalSysDictDO;
import com.yihu.jw.entity.util.AesEncryptUtils;
@ -27,11 +28,10 @@ import com.yihu.jw.security.oauth2.provider.WlyyTokenGranter;
import com.yihu.jw.security.oauth2.provider.error.WlyyOAuth2ExceptionTranslator;
import com.yihu.jw.security.service.*;
import com.yihu.jw.security.utils.*;
import com.yihu.jw.sms.service.TXYSmsService;
import com.yihu.jw.sms.service.YkyyINSMSService;
import com.yihu.jw.sms.service.ZBSmsService;
import com.yihu.jw.sms.service.ZhongShanSMSService;
import com.yihu.jw.sms.dao.BaseSmsDao;
import com.yihu.jw.sms.service.*;
import com.yihu.jw.sms.util.ykyy.vo.ResultMsg;
import com.yihu.jw.util.common.NetworkUtil;
import com.yihu.jw.util.common.StringUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.utils.network.HttpResponse;
@ -169,7 +169,8 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
    private HttpClientUtil httpClientUtil;
    @Autowired
    private HcyyService hcyyService;
    @Autowired
    private BaseSmsDao baseSmsDao;
    @PostConstruct
    private void init() {
@ -834,6 +835,16 @@ public class WlyyLoginEndpoint extends AbstractEndpoint {
        }else {
            //发送短信获取验证码
            String captcha = wlyyRedisVerifyCodeService.getCodeNumber();
            SmsDO smsDO = new SmsDO();
            smsDO.setCaptcha(captcha);
            smsDO.setClientId(client_id);
            smsDO.setContent("您好,你的手机登录短信验证码是:"+captcha+",5分钟内有效。");
            smsDO.setMobile(username);
            smsDO.setDeadline(DateUtil.getNextMin(new Date(),5));
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            smsDO.setRequestIp(NetworkUtil.getIpAddress(request));
            smsDO.setCreateTime(new Date());
            baseSmsDao.save(smsDO);
            //
            String result =  txySmsService.sendMessage(username,captcha);
            if ("Ok".equals(result)) {

+ 4 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/message/BaseServiceNewsDao.java

@ -1,12 +1,12 @@
package com.yihu.jw.care.dao.message;
import com.yihu.jw.entity.care.device.DevicePatientHealthIndex;
import com.yihu.jw.entity.care.message.BaseServiceNews;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.Date;
import java.util.List;
/**
@ -20,4 +20,7 @@ public interface BaseServiceNewsDao extends PagingAndSortingRepository<BaseServi
    @Query("select a from BaseServiceNews a ")
    List<BaseServiceNews> findNews(Pageable pageRequest);
    @Query("select a from BaseServiceNews a where a.createTime >= ?1 and a.createTime <= ?2 ")
    List<BaseServiceNews> findNewsByTime(Date beginTime, Date endTime, Pageable pageRequest);
}

+ 13 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/visit/BaseVisitSignDao.java

@ -0,0 +1,13 @@
package com.yihu.jw.care.dao.visit;
import com.yihu.jw.entity.care.visit.BaseVisitSignDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
/**
 * Created by Bing on 2022/5/18.
 */
public interface BaseVisitSignDao extends PagingAndSortingRepository<BaseVisitSignDO,String>, JpaSpecificationExecutor<BaseVisitSignDO> {
    BaseVisitSignDO findByVisitId(String visitId);
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PadLifeCareEndpoint.java

@ -89,7 +89,7 @@ public class PadLifeCareEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try {
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status,null, page, size);
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status,null, page, size,null);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
            }

+ 7 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PatientLifeCareEndpoint.java

@ -90,10 +90,11 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "status", value = "工单状态,状态为全部时不传") @RequestParam(value = "status", required = false) Integer status,
            @ApiParam(name = "fedCode", value = "生活工单服务项") @RequestParam(value = "fedCode", required = false) String fedCode,
            @ApiParam(name = "orgCode", value = "生活工单服务项所属机构") @RequestParam(value = "orgCode", required = false) String orgCode,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1") @RequestParam(value = "page") int page,
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15") @RequestParam(value = "size") int size) {
        try {
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status,fedCode, page, size);
            JSONObject result = lifeCareOrderService.queryInfoList(patient, status,fedCode, page, size,orgCode);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return PageEnvelop.getError(result.getString(ResponseContant.resultMsg), -1);
            }
@ -108,9 +109,10 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
    @ApiOperation(value = "查询工单数量")
    public ObjEnvelop infoCount(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient,
            @ApiParam(name = "fedCode", value = "生活工单服务项") @RequestParam(value = "fedCode", required = false) String fedCode) {
            @ApiParam(name = "fedCode", value = "生活工单服务项") @RequestParam(value = "fedCode", required = false) String fedCode,
            @ApiParam(name = "orgCode", value = "生活工单服务项所属机构") @RequestParam(value = "orgCode", required = false) String orgCode) {
        try {
            JSONObject allResult = lifeCareOrderService.queryInfoList(patient, null,fedCode, 1, 5);
            JSONObject allResult = lifeCareOrderService.queryInfoList(patient, null,fedCode, 1, 5,orgCode);
            if (allResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(allResult.getString(ResponseContant.resultMsg), -1);
            }
@ -118,14 +120,14 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
            JSONObject object = new JSONObject();
            object.put("allCount",allCount);
            JSONObject qxResult = lifeCareOrderService.queryInfoList(patient, -1, fedCode,1, 5);
            JSONObject qxResult = lifeCareOrderService.queryInfoList(patient, -1, fedCode,1, 5,orgCode);
            if (qxResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(qxResult.getString(ResponseContant.resultMsg), -1);
            }
            int qxCount = qxResult.getIntValue(ResponseContant.count);
            object.put("qxCount",qxCount);
            JSONObject wcResult = lifeCareOrderService.queryInfoList(patient, 2, fedCode,1, 5);
            JSONObject wcResult = lifeCareOrderService.queryInfoList(patient, 2, fedCode,1, 5,orgCode);
            if (wcResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(wcResult.getString(ResponseContant.resultMsg), -1);
            }

+ 96 - 35
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/DetectionPlatformEndpoint.java

@ -3,12 +3,12 @@ package com.yihu.jw.care.endpoint.statistics;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.device.DeviceManageService;
import com.yihu.jw.care.service.device.NetworkCardService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.statistics.DetectionPlatformService;
import com.yihu.jw.care.util.HlsDownloader;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
@ -22,8 +22,6 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
/***
 * @ClassName: DetectionPlatformEndpoint
 * @Description: 社区云照护平台--物联网健康监测展示平台 v1.0.0
@ -48,6 +46,7 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    private DeviceManageService deviceManageService;
    @ApiOperation("环境信息")
    @RequestMapping(value = "envMessage", method = RequestMethod.GET)
    public ObjEnvelop envMessage(@ApiParam(name = "patientId", value = "居民id", defaultValue = "1")
@ -77,7 +76,7 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "设备物联率、失联率")
    public ObjEnvelop getDeviceCompany() {
        try {
            JSONObject o = platformService.getDeviceComapny(null,null);
            JSONObject o = platformService.getDeviceComapny(null, null);
            return success(o);
        } catch (Exception e) {
            return failedObjEnvelopException(e);
@ -283,7 +282,7 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "物联网检测大屏,设备库存、使用、总备案、照护类型设备数量")
    public ObjEnvelop getServiceSituation() {
        try {
            return success("查询成功", 200, platformService.getServiceSituation(null,null));
            return success("查询成功", 200, platformService.getServiceSituation(null, null));
        } catch (Exception e) {
            return failedObjEnvelopException(e);
        }
@ -339,21 +338,21 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
        try {
            return ObjEnvelop.getSuccess("查询成功", networkCardService.getFlowPoolInfo());
        } catch (Exception e) {
           return failedObjEnvelopException2(e);
            return failedObjEnvelopException2(e);
        }
    }
    @ApiOperation("获取流量/语音使用趋势--折线")
    @ResponseBody
    @RequestMapping(value = "getFlowVoiceLineInfo", method = RequestMethod.GET)
    public ListEnvelop getFlowVoiceLineInfo(@ApiParam(name="type",value = "1月2日")
                                       @RequestParam(value ="type",required = true)String type,
                                       @ApiParam(name="data",value = "flow,voice")
                                       @RequestParam(value ="data",required = true)String data,
                                       @ApiParam(name="size",value = "返回大小")
                                       @RequestParam(value ="size",required = true)Integer size) {
    public ListEnvelop getFlowVoiceLineInfo(@ApiParam(name = "type", value = "1月2日")
                                            @RequestParam(value = "type", required = true) String type,
                                            @ApiParam(name = "data", value = "flow,voice")
                                            @RequestParam(value = "data", required = true) String data,
                                            @ApiParam(name = "size", value = "返回大小")
                                            @RequestParam(value = "size", required = true) Integer size) {
        try {
            return ListEnvelop.getSuccess("查询成功",networkCardService.getFlowVoiceLineInfo(type,data,size));
            return ListEnvelop.getSuccess("查询成功", networkCardService.getFlowVoiceLineInfo(type, data, size));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
@ -362,14 +361,14 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @ApiOperation("获取流量/语音使用总数据表格-从统计初至今")
    @ResponseBody
    @RequestMapping(value = "getSimFlowVoiceLineInfo", method = RequestMethod.GET)
    public ListEnvelop getSimFlowVoiceLineInfo(@ApiParam(name="type",value = "1月2日")
                                            @RequestParam(value ="type",required = true)String type,
                                            @ApiParam(name="data",value = "flow,voice")
                                            @RequestParam(value ="data",required = true)String data,
                                            @ApiParam(name="day",value = "")
                                            @RequestParam(value ="day",required = false)String day) {
    public ListEnvelop getSimFlowVoiceLineInfo(@ApiParam(name = "type", value = "1月2日")
                                               @RequestParam(value = "type", required = true) String type,
                                               @ApiParam(name = "data", value = "flow,voice")
                                               @RequestParam(value = "data", required = true) String data,
                                               @ApiParam(name = "day", value = "")
                                               @RequestParam(value = "day", required = false) String day) {
        try {
            return ListEnvelop.getSuccess("查询成功",networkCardService.getSimFlowVoiceLineInfo(type,data,day));
            return ListEnvelop.getSuccess("查询成功", networkCardService.getSimFlowVoiceLineInfo(type, data, day));
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
@ -380,7 +379,7 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "getSimCounts", method = RequestMethod.GET)
    public ListEnvelop getSimCounts() {
        try {
            return ListEnvelop.getSuccess("查询成功",networkCardService.getSimCounts());
            return ListEnvelop.getSuccess("查询成功", networkCardService.getSimCounts());
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
@ -391,29 +390,91 @@ public class DetectionPlatformEndpoint extends EnvelopRestEndpoint {
    @RequestMapping(value = "getTopicPeopleNums", method = RequestMethod.GET)
    public ObjEnvelop getTopicPeopleNums() {
        try {
            return ObjEnvelop.getSuccess("查询成功",platformService.getTopicPeopleNums(null,null));
            return ObjEnvelop.getSuccess("查询成功", platformService.getTopicPeopleNums(null, null));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @RequestMapping(value = "/getPatientMonitorData",method = RequestMethod.GET)
    @ApiOperation(value="获取居民设备监护数据")
    public PageEnvelop getPatientMonitorData(@ApiParam(name = "patient",value = "patient")
                                             @RequestParam(value = "patient")String patient,
                                             @ApiParam(name = "startTime",value = "开始时间")
                                             @RequestParam(value = "startTime")String startTime,
                                             @ApiParam(name = "endTime",value = "endTime")
                                             @RequestParam(value = "endTime")String endTime,
                                             @ApiParam(name = "page",value = "page")
                                             @RequestParam(value = "page")Integer page,
                                             @ApiParam(name = "size",value = "size")
                                             @RequestParam(value = "size")Integer size){
    @RequestMapping(value = "/getPatientMonitorData", method = RequestMethod.GET)
    @ApiOperation(value = "获取居民设备监护数据")
    public PageEnvelop getPatientMonitorData(@ApiParam(name = "patient", value = "patient")
                                             @RequestParam(value = "patient") String patient,
                                             @ApiParam(name = "startTime", value = "开始时间")
                                             @RequestParam(value = "startTime") String startTime,
                                             @ApiParam(name = "endTime", value = "endTime")
                                             @RequestParam(value = "endTime") String endTime,
                                             @ApiParam(name = "page", value = "page")
                                             @RequestParam(value = "page") Integer page,
                                             @ApiParam(name = "size", value = "size")
                                             @RequestParam(value = "size") Integer size) {
        try {
            return deviceManageService.getPatientMonitorData(patient,startTime,endTime,page,size);
            return deviceManageService.getPatientMonitorData(patient, startTime, endTime, page, size);
        } catch (Exception e) {
            e.printStackTrace();
            return PageEnvelop.getError("系统繁忙");
        }
    }
    @GetMapping(value = "getVideoList")
    @ApiOperation(value = "获取监控点列表")
    public PageEnvelop getVideoList(@ApiParam @RequestParam(name = "page", required = false, defaultValue = "0") Integer page,
                                    @ApiParam @RequestParam(name = "pageSize", required = false, defaultValue = "20") Integer pageSize) {
        try {
            return platformService.getVideoList(page, pageSize);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getVideoUrlByCode")
    @ApiOperation(value = "根据编码获取流地址")
    public ObjEnvelop getVideoUrl(@ApiParam @RequestParam String indexCode) {
        try {
            String videoUrl = platformService.getVideoUrl(indexCode);
            if(StringUtils.isBlank(videoUrl)){
                return ObjEnvelop.getError("获取失败");
            }
            return ObjEnvelop.getSuccess("获取成功",videoUrl);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "testDownloadVideoUrl")
    @ApiOperation(value = "下载m3u8")
    public ObjEnvelop downM3u8Video(@ApiParam @RequestParam String url) {
        try {
            return platformService.downM3u8Video(url);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ObjEnvelop.getSuccess("1111","");
    }
    public static void main(String[] args) {
        String originUrlpath = "http://videocdn.renrenjiang.cn/Act-ss-m3u8-sd/1037359_1546064640169/1037359_1546064640169.m3u8";
        String preUrlPath = originUrlpath.substring(0, originUrlpath.lastIndexOf("/")+1);
        String rootPath = "E:\\videodir";
        String fileName = "";
        HlsDownloader downLoader = new HlsDownloader(originUrlpath, preUrlPath, rootPath);
        //downLoader.setThreadQuantity(10);
        try{
            fileName = downLoader.download(true);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        if(StringUtils.isBlank(fileName)){
            System.out.println("下载失败");
        }else{
            System.err.println("下载成功"+fileName);
            System.out.println("完整路径:"+rootPath+"\\"+fileName);
        }
    }
}

+ 151 - 10
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/statistics/OpenStatisticsEndpoint.java

@ -20,6 +20,9 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 *
@ -132,6 +135,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @ApiOperation(value = "服务资源v0.7.0")
    public ObjEnvelop ServiceResources() {
        try {
            //机构和人员总数
            JSONObject result = statisticsService.serviceResources();
            return success(result);
        } catch (Exception e) {
@ -139,6 +143,33 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "getOrgListByPage")
    @ApiOperation(value = "获取机构列表")
    public PageEnvelop getOrgListByPage(@ApiParam(name = "type",value = "类型。1医疗机构,3养老机构,4托育机构,6照料中心") @RequestParam String type,
                                        @ApiParam(name = "page",value = "页码") @RequestParam Integer page,
                                        @ApiParam(name = "pageSize",value = "每页大小") @RequestParam Integer pageSize,
                                        @ApiParam(name = "name",value = "模糊搜索") @RequestParam(name = "name",required = false)String name){
        try {
            return statisticsService.getOrgListByPage(type, page, pageSize,name);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getUserListByPage")
    @ApiOperation(value = "获取人员列表")
    public PageEnvelop getUserListByPage(@ApiParam(name = "type",value = "类型。1医生,2社工,3教师,4助老员") @RequestParam String type,
                                         @ApiParam(name = "page",value = "页码") @RequestParam Integer page,
                                         @ApiParam(name = "pageSize",value = "每页大小") @RequestParam Integer pageSize,
                                         @ApiParam(name = "name",value = "模糊搜索名字") @RequestParam(name = "name",required = false)String name,
                                         @ApiParam(name = "idCard",value = "模糊搜索身份证号") @RequestParam(name = "idCard",required = false)String idCard){
        try {
            return statisticsService.getUserListByPage(type, page, pageSize, name, idCard);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "realTimeDataNew")
    @ApiOperation(value = "实时数据v0.7.0")
    public ObjEnvelop realTimeDataNew() {
@ -152,10 +183,12 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getAllDynamics")
    @ApiOperation(value = "综合动态v0.7.0")
    public PageEnvelop getAllDynamics(
            @RequestParam(required = true) Integer page, @RequestParam(required = true) Integer size) {
    public PageEnvelop getAllDynamics(@ApiParam @RequestParam Integer page,
                                      @ApiParam @RequestParam Integer size,
                                      @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                      @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime) {
        try {
            return statisticsService.getAllDynamics(page, size);
            return statisticsService.getAllDynamics(page, size,beginTime,endTime);
        } catch (Exception e) {
            return failedPageEnvelopException2(e);
        }
@ -210,7 +243,7 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findUserByType")
    @ApiOperation(value = "人员实时动态搜索")
    public Envelop findUserByType(@ApiParam(name = "type", value = "类型:1幼儿,2签约老人,3社工,4医生,5老人家属 6助老员,7社区老人(未签约).不传返回四个类型的数据")
    public Envelop findUserByType(@ApiParam(name = "type", value = "类型:1幼儿,2签约老人,3社工,4医生,5老人家属 6助老员,7街道老人(未签约)8 需招呼老人 原社区老人 .不传返回四个类型的数据")
                                  @RequestParam(value = "type", required = false) String type,
                                  @ApiParam(name = "name", value = "姓名")
                                  @RequestParam(value = "name", required = false) String name,
@ -456,20 +489,128 @@ public class OpenStatisticsEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findTendOld")
    @ApiOperation(value = "获取照护老人列表")
    public ObjEnvelop findTendOld(@ApiParam(name="page",value = "页码",required = false)
                                       @RequestParam(value = "page",required = true,defaultValue = "1") Integer page,
                                   @ApiParam(name="size",value = "分页大小",required = false)
                                       @RequestParam(value = "size",required = true,defaultValue = "5") Integer size){
        try {
            JSONObject tendOld = statisticsService.findTendOld(page, size);
    public ObjEnvelop findTendOld(@ApiParam(name = "page", value = "页码", required = false)
                                  @RequestParam(value = "page", required = true, defaultValue = "1") Integer page,
                                  @ApiParam(name = "size", value = "分页大小", required = false)
                                  @RequestParam(value = "size", required = true, defaultValue = "5") Integer size,
                                  @ApiParam(name = "type", value = "查询类型1老人,2幼儿", required = false)
                                  @RequestParam(value = "type", required = false) Integer type,
                                  @ApiParam(name = "idcard",value = "身份证",required = false)
                                  @RequestParam(value = "idcard",required = false)String idcard,
                                  @ApiParam(name = "name",value = "居民名字",required = false)
                                  @RequestParam(value = "name",required = false)String name,
                                  @ApiParam(name = "orgName",value = "社区名字",required = false)
                                  @RequestParam(value = "orgName",required = false)String  orgName) {
        try {
            JSONObject tendOld = statisticsService.findTendOld(type,page, size,idcard,name,orgName);
            return success(tendOld);
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "findOldOrg")
    @ApiOperation(value = "获取照护老人社区")
    public ListEnvelop findOldOrg(){
        try {
            List<Map<String, Object>> oldOrg = statisticsService.findOldOrg();
            return success(oldOrg);
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "findOverTimeOrder")
    @ApiOperation(value = "获取超时工单")
    public ObjEnvelop findOverTimeOrder(@ApiParam(name = "page", value = "页", required = true,defaultValue = "1")
                                        @RequestParam(value = "page", required = true) Integer page,
                                        @ApiParam(name = "size", value = "条", required = true,defaultValue = "10")
                                        @RequestParam(value = "size", required = true) Integer size,
                                        @ApiParam(name = "name", value = "居民名字", required = false)
                                        @RequestParam(value = "name", required = false) String name,
                                        @ApiParam(name = "idcard", value = "身份证", required = false)
                                        @RequestParam(value = "idcard", required = false) String idcard,
                                        @ApiParam(name = "orgCode", value = "机构code", required = false)
                                        @RequestParam(value = "orgCode", required = false) String orgCode,
                                        @ApiParam(name = "type", value = "查询类型1安防紧急工单 2生活照料", required = false)
                                        @RequestParam(value = "type", required = false) Integer type) {
        try {
            JSONObject jsonObject = statisticsService.overTimeOrderList(type, page, size, name, idcard, orgCode);
            return success(jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "emeSecOrderList")
    @ApiOperation(value = "获取紧急安防工单列表")
    public ObjEnvelop emeSecOrderList(@ApiParam(name = "page", value = "页", required = true,defaultValue = "1")
                                      @RequestParam(value = "page", required = true) Integer page,
                                      @ApiParam(name = "size", value = "条", required = true,defaultValue = "10")
                                      @RequestParam(value = "size", required = true) Integer size,
                                      @ApiParam(name = "name", value = "居民名字", required = false)
                                      @RequestParam(value = "name", required = false) String name,
                                      @ApiParam(name = "idcard", value = "身份证", required = false)
                                      @RequestParam(value = "idcard", required = false) String idcard,
                                      @ApiParam(name = "orgCode", value = "机构code", required = false)
                                      @RequestParam(value = "orgCode", required = false) String orgCode,
                                      @ApiParam(name = "status",value = "工单状态",required = false)
                                      @RequestParam(value = "status",required = false)Integer status){
        try {
            JSONObject jsonObject = statisticsService.emeSecOrderList(status, name, idcard, orgCode, page, size);
            return success(jsonObject);
        } catch (Exception e) {
            e.printStackTrace();
            return failedObjEnvelopException2(e);
        }
    }
    @GetMapping(value = "deviceNameList")
    @ApiOperation(value = "获取设备名字列表")
    public ListEnvelop deviceNameList(@ApiParam(name = "deviceType",value = "设备类型 0健康设备 1安防设备",required = false)
                                      @RequestParam(value = "deviceType",required = false)String deviceType){
        try {
            List<Map<String, Object>> list = statisticsService.deviceNameList(deviceType);
            return success(list);
        } catch (Exception e) {
            e.printStackTrace();
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "healthySecurityDeviceList")
    @ApiOperation(value = "获取安防/健康设备列表")
    public PageEnvelop healthySecurityDeviceList(@ApiParam(name = "page", value = "页", required = true,defaultValue = "1")
                                                 @RequestParam(value = "page", required = true) Integer page,
                                                 @ApiParam(name = "size", value = "条", required = true,defaultValue = "10")
                                                 @RequestParam(value = "size", required = true) Integer size,
                                                 @ApiParam(name = "name", value = "居民名字", required = false)
                                                 @RequestParam(value = "name", required = false) String name,
                                                 @ApiParam(name = "deviceSn", value = "设备Sn码", required = false)
                                                 @RequestParam(value = "deviceSn", required = false) String deviceSn,
                                                 @ApiParam(name = "categoryCode", value = "设备类型Code", required = false)
                                                 @RequestParam(value = "categoryCode", required = false) String categoryCode,
                                                 @ApiParam(name = "contactStatus",value = "在线状态 1在线,0不在线",required = false)
                                                 @RequestParam(value = "contactStatus",required = false)String contactStatus,
                                                 @ApiParam(name = "type",value = "查询设备类型 af / jk",required = false)
                                                 @RequestParam(value = "type",required = false)String type){
        try {
            return statisticsService.healthySecurityDeviceList(name,deviceSn,categoryCode,contactStatus,type,page,size);
        } catch (Exception e) {
            e.printStackTrace();
            return failedPageEnvelopException2(e);
        }
    }
}

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

@ -13,6 +13,7 @@ import com.yihu.jw.care.service.security.SecurityMonitoringOrderService;
import com.yihu.jw.care.service.third.PatientInfoPlatFormService;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.lifeCare.LifeCareOrderDO;
import com.yihu.jw.entity.care.message.BaseServiceNews;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.MixEnvelop;
@ -26,6 +27,8 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * Created by Bing on 2021/6/16.
 * 管理端pc端 居民详情大屏
@ -77,11 +80,12 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    }
    @GetMapping(value = "findUnSignPatientLocations")
    @ApiOperation("查找未签约老人坐标")
    @ApiOperation("查找未签约老人坐标 社区老人/街道老人")
    public PageEnvelop findUnSignPatientLocations(@ApiParam(name = "page")@RequestParam(value = "page")Integer page,
                                                  @ApiParam(name = "size")@RequestParam(value = "size")Integer size){
                                                  @ApiParam(name = "size")@RequestParam(value = "size")Integer size,
                                                  @ApiParam(name = "type",value = "类型1社区老人 2街道老人",required = false)@RequestParam(value = "type",required = false)Integer type){
        try {
            return baseServiceNewsService.findUnSignPatientLocations(page,size);
            return baseServiceNewsService.findUnSignPatientLocations(page,size,type);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -110,17 +114,32 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findNews")
    @ApiOperation("服务动态")
    public ListEnvelop findNews(@ApiParam(name="page",value = "页面大小",required = false)
                                @RequestParam(value = "page",required = false,defaultValue = "0")Integer page,
                                @ApiParam(name="size",value = "页面大小",required = true)
                                @RequestParam(value = "size")Integer size){
    public ListEnvelop findNews(@ApiParam(name="page",value = "页面大小",required = false) @RequestParam(value = "page",required = false,defaultValue = "0")Integer page,
                                @ApiParam(name="size",value = "页面大小",required = true) @RequestParam(value = "size")Integer size,
                                @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            return ListEnvelop.getSuccess("查询成功",baseServiceNewsService.findNews(page,size));
            return ListEnvelop.getSuccess("查询成功",baseServiceNewsService.findNews(page,size,beginTime,endTime));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "findNewsByPage")
    @ApiOperation("服务动态分页")
    public PageEnvelop findNewsByPage(@ApiParam(name="page",value = "页面大小") @RequestParam Integer page,
                                      @ApiParam(name="pageSize",value = "页面大小") @RequestParam Integer pageSize,
                                      @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                      @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            List<BaseServiceNews> news = baseServiceNewsService.findNews(page, pageSize,beginTime,endTime);
            Long count = baseServiceNewsService.findNewsCount(beginTime, endTime);
            return PageEnvelop.getSuccessListWithPage("获取成功",news,page,pageSize,count);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @GetMapping(value = "getPatientInfo")
    @ApiOperation("获取居民详情页--弃用")
    public ObjEnvelop getPatientInfo(@ApiParam(name="patient",value = "居民id",required = true)
@ -378,15 +397,13 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getEmergencyWarnOrderListNew")
    @ApiOperation(value = "安防监测列表 v0.7.0")//        疑似离开安全区域+疑似跌倒
    public PageEnvelop getEmergencyWarnOrderListNew(@ApiParam(name="page",value = "page")
                                                 @RequestParam(value = "page") Integer page,
                                                    @ApiParam(name="patient",value = "patient")
                                                    @RequestParam(value = "patient",required = false) String patient,
                                                 @ApiParam(name="pageSize",value = "pageSize")
                                                 @RequestParam(value = "pageSize") Integer pageSize
    ){
    public PageEnvelop getEmergencyWarnOrderListNew(@ApiParam(name="page",value = "page") @RequestParam(value = "page") Integer page,
                                                    @ApiParam(name="patient",value = "patient") @RequestParam(value = "patient",required = false) String patient,
                                                    @ApiParam(name="pageSize",value = "pageSize") @RequestParam(value = "pageSize") Integer pageSize,
                                                    @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                                    @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            return patientInfoPlatFormService.getEmergencyWarnOrderListNew(page,pageSize,patient);
            return patientInfoPlatFormService.getEmergencyWarnOrderListNew(page,pageSize,patient,beginTime,endTime);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -394,15 +411,13 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getEmergencyWarningListNew")
    @ApiOperation(value = "紧急预警列表 v0.7.0")//        发起紧急救助
    public PageEnvelop getEmergencyWarningListNew(@ApiParam(name="page",value = "page")
                                                    @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name="patient",value = "patient")
                                                  @RequestParam(value = "patient",required = false) String patient,
                                                    @ApiParam(name="pageSize",value = "pageSize")
                                                    @RequestParam(value = "pageSize") Integer pageSize
    ){
    public PageEnvelop getEmergencyWarningListNew(@ApiParam(name="page",value = "page") @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name="patient",value = "patient") @RequestParam(value = "patient",required = false) String patient,
                                                  @ApiParam(name="pageSize",value = "pageSize") @RequestParam(value = "pageSize") Integer pageSize,
                                                  @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                                  @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            return patientInfoPlatFormService.getEmergencyWarningListNew(page,pageSize,patient);
            return patientInfoPlatFormService.getEmergencyWarningListNew(page,pageSize,patient,beginTime,endTime);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -410,13 +425,12 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "getHealthMonitoringListNew")
    @ApiOperation(value = "健康监测列表 v0.7.0")// 血糖+血压
    public PageEnvelop getHealthMonitoringListNew(@ApiParam(name="page",value = "page")
                                                  @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name="pageSize",value = "pageSize")
                                                  @RequestParam(value = "pageSize") Integer pageSize
    ){
    public PageEnvelop getHealthMonitoringListNew(@ApiParam(name="page",value = "page") @RequestParam(value = "page") Integer page,
                                                  @ApiParam(name="pageSize",value = "pageSize") @RequestParam(value = "pageSize") Integer pageSize,
                                                  @ApiParam(name = "beginTime",value = "开始时间,格式2022-05-19 00:00:00") @RequestParam(name = "beginTime",required = false)String beginTime,
                                                  @ApiParam(name = "endTime",value = "结束时间,格式2022-05-19 23:59:59") @RequestParam(name = "endTime",required = false)String endTime){
        try {
            return patientInfoPlatFormService.getHealthMonitoringListNew(page,pageSize);
            return patientInfoPlatFormService.getHealthMonitoringListNew(page,pageSize,beginTime,endTime);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -459,4 +473,39 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @RequestMapping(value = "getWarningCount", method = RequestMethod.GET)
    @ApiOperation(value = "获取预警中的总数")
    public ObjEnvelop getWarningCount(@ApiParam(name="patient",value = "居民id") @RequestParam(value = "patient",required = false) String patient){
        try{
            return patientInfoPlatFormService.getWarningCount(patient);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @RequestMapping(value = "getWarningList", method = RequestMethod.GET)
    @ApiOperation(value = "获取紧急预警中的列表")
    public PageEnvelop getWarningList(@ApiParam(name="page",value = "页码") @RequestParam(value = "page") Integer page,
                                      @ApiParam(name="pageSize",value = "每页大小") @RequestParam(value = "pageSize") Integer pageSize,
                                      @ApiParam(name="patient",value = "居民id") @RequestParam(value = "patient",required = false) String patient){
        try{
            return patientInfoPlatFormService.getWarningList(page,pageSize,patient);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
    @RequestMapping(value = "getHealthWarningList", method = RequestMethod.GET)
    @ApiOperation(value = "获取体征预警中的列表")
    public PageEnvelop getHealthWarningList(@ApiParam(name="page",value = "页码") @RequestParam(value = "page") Integer page,
                                            @ApiParam(name="pageSize",value = "每页大小") @RequestParam(value = "pageSize") Integer pageSize,
                                            @ApiParam(name="patient",value = "居民id") @RequestParam(value = "patient",required = false) String patient){
        try{
            return patientInfoPlatFormService.getHealthWarningList(page,pageSize,patient);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
}

+ 41 - 3
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/visit/VisitEndpoint.java

@ -1,9 +1,12 @@
package com.yihu.jw.care.endpoint.visit;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.aop.ObserverRequired;
import com.yihu.jw.care.service.common.PermissionService;
import com.yihu.jw.care.service.visit.BaseVisitService;
import com.yihu.jw.entity.base.team.BaseTeamDO;
import com.yihu.jw.entity.care.visit.BaseVisitDO;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
@ -13,7 +16,6 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@ -32,6 +34,9 @@ public class VisitEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseVisitService baseVisitService;
    @Autowired
    private PermissionService permissionService;
    @ApiOperation("获取日常走访列表")
    @RequestMapping(value = "/getListByDoctor", method = RequestMethod.GET)
    public ListEnvelop getListByDoctor(@ApiParam(name = "startTime", value = "开始时间", defaultValue = "2021-11-11 00:00:00")
@ -137,7 +142,7 @@ public class VisitEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("直接新增走访--管理员端")
    @ApiOperation("直接新增走访--管理员端--管理员端取消日常走访")
    @RequestMapping(value = "/adminAddVisit",method = RequestMethod.POST)
    public Envelop adminAddVisit(@ApiParam(name = "doctor", value = "医生id")
                                 @RequestParam(value = "doctor", required = true) String doctor,
@ -154,10 +159,43 @@ public class VisitEndpoint extends EnvelopRestEndpoint {
                                 @ApiParam(name = "lifeConsult", value = "生活咨询")
                                 @RequestParam(value = "lifeConsult", required = false) String lifeConsult) {
        try {
            baseVisitService.adminAddVisit(doctor,patient,visitContent,visitImg,deviceMaintenance,health,lifeConsult);
//            baseVisitService.adminAddVisit(doctor,patient,visitContent,visitImg,deviceMaintenance,health,lifeConsult);
            return Envelop.getSuccess("操作成功");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    @PostMapping("signIn")
    @ApiOperation(value = "日常走访签到")
    @ObserverRequired
    public ObjEnvelop signIn(
            @ApiParam(value = "走访id", name = "visitId")
            @RequestParam(value = "visitId", required = true) String visitId,
            @ApiParam(value = "签到方式:1.定位,2.拍照", name = "signWay")
            @RequestParam(value = "signWay", required = true) Integer signWay,
            @ApiParam(value = "签到纬度", name = "signLat")
            @RequestParam(value = "signLat", required = false) String signLat,
            @ApiParam(value = "签到经度", name = "signLon")
            @RequestParam(value = "signLon", required = false) String signLon,
            @ApiParam(value = "签到地址", name = "address")
            @RequestParam(value = "address", required = false) String address,
            @ApiParam(value = "签到照片", name = "signImg")
            @RequestParam(value = "signImg", required = false) String signImg) {
        try {
            String doctorId = permissionService.getUID();
            JSONObject param = new JSONObject();
            param.put("doctorId",doctorId);
            if(permissionService.noPermission(1,param)){
                return ObjEnvelop.getError("该操作没有权限");
            }
            JSONObject result = baseVisitService.signIn(visitId, signWay, signLat,signLon, address,signImg,doctorId);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(result.getString("resultMsg"));
            }
            return ObjEnvelop.getSuccess("操作成功",result.getString(ResponseContant.resultMsg));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
}

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

@ -781,11 +781,34 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        sql.append(" order by ord.create_time "+sort+" limit "+page*pageSize+","+pageSize);
        List<EmergencyAssistanceDO> resultList = jdbcTemplate.query(sql.toString(),new BeanPropertyRowMapper(EmergencyAssistanceDO.class));
        List<String> patientCodes = new ArrayList<>();
        for (EmergencyAssistanceDO obj:resultList){
            BasePatientDO patientDO = patientDao.findById(obj.getPatient());
            obj.setPatientPhoto(patientDO.getPhoto());
            obj.setPatientSex(patientDO.getSex());
            obj.setPatientAge(IdCardUtil.getAgeForIdcard(patientDO.getIdcard()));
            if(!patientCodes.contains(obj.getPatient())){
                patientCodes.add(obj.getPatient());
            }
        }
        String inSql = "";
        for (String code : patientCodes) {
            inSql += "'"+code+"',";
        }
        if(StringUtils.isNotBlank(inSql)){
            inSql = inSql.substring(0,inSql.lastIndexOf(","));
            //居民绑定的设备code
            String deviceSql = "SELECT user,GROUP_CONCAT( DISTINCT category_code SEPARATOR ',' ) code  " +
                    "from wlyy_patient_device where del = 0 and user in ("+inSql+") group by user";
            List<Map<String, Object>> list = jdbcTemplate.queryForList(deviceSql);
            for (Map<String, Object> map : list) {
                for (EmergencyAssistanceDO em : resultList) {
                    if(map.get("user").toString().equals(em.getPatient())){
                        em.setPatientDevices(map.get("code").toString());
                    }
                }
            }
        }
        return resultList;
    }

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

@ -517,7 +517,7 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
     *
     * @return
     */
    public JSONObject queryInfoList(String patient,Integer status,String fedCode ,int page, int size) {
    public JSONObject queryInfoList(String patient,Integer status,String fedCode ,int page, int size,String orgCode) {
        JSONObject result = new JSONObject();
        status = null == status ? -100 : status;
@ -525,9 +525,11 @@ public class LifeCareOrderService extends BaseJpaService<LifeCareOrderDO, LifeCa
        int end = 0 == size ? 15 : size;
        String fedSql = " ";
        if (StringUtils.isNotBlank(fedCode)){
            String fedOrgCode ="";
            if (StringUtils.isNotBlank(orgCode))fedOrgCode="  AND cid.org_code = '"+orgCode+"'";
            fedSql = " and EXISTS ( " +
                    " select 1 from base_life_care_fee_detail fed where fed.order_id = o.id and fed.code='"+fedCode+"' " +
                    " )  ";
                    " select 1 from base_life_care_fee_detail fed LEFT JOIN base_life_care_item_dict cid ON fed.code = cid.code where fed.order_id = o.id and fed.code='"+fedCode+"' " + fedOrgCode +
                    "  )  ";
        }
        String sql = "SELECT *  FROM  base_life_care_order o " +

+ 35 - 7
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/BaseServiceNewsService.java

@ -13,6 +13,7 @@ import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
@ -182,11 +183,11 @@ public class BaseServiceNewsService {
    }
    /**
     * 查找所有未签约老人
     * 社区老人
     * 社区老人   需招呼老人(孤/独/空)   register = 1
     * 街道老人   第三方同步过来的朝晖街道老人数据  register = 2
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> findUnSignPatientLocations(Integer page,Integer size){
    public PageEnvelop<List<Map<String,Object>>> findUnSignPatientLocations(Integer page,Integer size,Integer type){
        page = page>0?page-1:0;
        String filter =" ";
@ -200,12 +201,17 @@ public class BaseServiceNewsService {
            }
        }
        String typeSql =" p.register = 1";
        if (null!=type&&type==2) {
            typeSql = " p.register = 2";
        }
        String sql = "SELECT p.id,p.`name`,p.address,p.photo,p.mobile,p.lat_lon latLon,sex,idcard,archive_type type,p.pad_imei,p.openid " +
                " from base_patient p " +
                "WHERE  p.del =1 and p.archive_type=1 and p.sign_status=0 and p.register = 1 and p.lat_lon is not null "+filter+" limit "+page*size+","+size;
                "WHERE  p.del =1 and p.archive_type=1 and p.sign_status=0 and "+typeSql+" and p.lat_lon is not null "+filter+" limit "+page*size+","+size;
        String sqlCount = "SELECT count(p.id) " +
                " from base_patient p " +
                "WHERE  p.del =1 and p.archive_type=1 and p.sign_status=0 and p.register = 1 and  p.lat_lon is not null "+filter ;
                "WHERE  p.del =1 and p.archive_type=1 and p.sign_status=0 and "+typeSql+" and  p.lat_lon is not null "+filter ;
        Long count = jdbcTemplate.queryForObject(sqlCount,Long.class);
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        for (Map<String,Object> map:list){
@ -255,6 +261,7 @@ public class BaseServiceNewsService {
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
    }
    public List<Map<String , Object>> getLatLon(){
        String filter =" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_helper' or dict_name = 'jkzl_teacher' ";
@ -277,7 +284,7 @@ public class BaseServiceNewsService {
     * @param size
     * @return
     */
    public List<BaseServiceNews> findNews(Integer page,Integer size){
    public List<BaseServiceNews> findNews(Integer page,Integer size,String beginTime,String endTime){
        if (null==page){
            page=0;
        }
@ -292,7 +299,13 @@ public class BaseServiceNewsService {
        List<BaseServiceNews> result = new ArrayList<>();
        List<BaseServiceNews> list = baseServiceNewsDao.findNews(pageRequest);
        List<BaseServiceNews> list =new ArrayList<>();
        if(StringUtils.isBlank(beginTime) && StringUtils.isBlank(endTime)){
            list = baseServiceNewsDao.findNews(pageRequest);
        }else {
            list = baseServiceNewsDao.findNewsByTime(DateUtil.strToDate(beginTime),DateUtil.strToDate(endTime),pageRequest);
        }
        for (BaseServiceNews tmp:list){
            if (jkzlPatients.contains(tmp.getCode())){
                continue;
@ -324,6 +337,21 @@ public class BaseServiceNewsService {
        return result;
    }
    /**
     * 获取综合服务的总数
     * @return
     */
    public Long findNewsCount(String beginTime,String endTime){
        String sql = "SELECT COUNT(*) FROM base_service_news\n" +
                "WHERE code NOT IN \n" +
                "(SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older')";
        String timeSql = " ";
        if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
            timeSql = " and create_time>='"+beginTime+"' and create_time<='"+endTime+"' ";
        }
        return jdbcTemplate.queryForObject(sql+timeSql, Long.class);
    }
    /**
     * 添加服务动态信息-大屏展示用
     * @param name

+ 27 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java

@ -770,7 +770,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            re.put("child",list);
            re.put("childTotal",findChildTotal(name,residentialArea,filter));
        }
        if("2".equals(type)||StringUtil.isBlank(type)){//老人
        if("2".equals(type)||"8".equals(type)||StringUtil.isBlank(type)){//老人  //1.7.7增加  需照护老人(孤/独/空)800 + 老人名单
            filter = "";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_older' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
@ -780,9 +780,9 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
                filter = " and a.id not in ('"+orgCodes+"')";
            }
            List<Map<String,Object>> list = findOld(name,residentialArea,area,level,limit,filter);
            List<Map<String,Object>> list = findOld(type,name,residentialArea,area,level,limit,filter);
            re.put("old",list);
            re.put("oldTotal",findOldTotal(name,residentialArea,area,level,filter));
            re.put("oldTotal",findOldTotal(type,name,residentialArea,area,level,filter));
        }
        if("3".equals(type)||StringUtil.isBlank(type)){//社工
            filter = "";
@ -825,7 +825,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            re.put("helper4",list);
            re.put("helper4Total",findHelper4Total(name,area,level,filter));
        }
        if("7".equals(type)||StringUtils.isBlank(type)){//社区老人
        if("7".equals(type)||StringUtils.isBlank(type)){//街道老人 第三方同步过来的朝晖街道老人数据
            filter = "";
            String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_older' ";
            List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
@ -896,10 +896,18 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
     * @param limit
     * @return
     */
    public List<Map<String,Object>> findOld(String name,String residentialArea,String area,Integer level,String limit,String filter1){
    public List<Map<String,Object>> findOld(String type,String name,String residentialArea,String area,Integer level,String limit,String filter1){
        String sql = "SELECT DISTINCT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
                ",a.ykt_id yktId, case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online,IFNULL(sign_status,0) signStatus from base_patient a " +
                " WHERE a.archive_type = 1 and a.del = '1' and (a.sign_status=1 or a.register = '1')  ";
                " WHERE a.archive_type = 1 and a.del = '1'   ";
        if ("2".equals(type)){
            sql+=" and a.sign_status=1 ";
        }
        if ("8".equals(type)){
            sql+=" and a.register='1' ";
        }
        //case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online
        //if(openid is null,0,1) onlineWx,IFNULL(a.on_line,0) onlinePad
@ -972,8 +980,16 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        return list;
    }
    public Integer findOldTotal(String name,String residentialArea,String area,Integer level,String filter){
        String sql = "SELECT count(DISTINCT a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' and (a.sign_status=1 or a.register = 1)";
    public Integer findOldTotal(String type,String name,String residentialArea,String area,Integer level,String filter){
        String sql = "SELECT count(DISTINCT a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' ";
        if ("2".equals(type)){
            sql+=" and a.sign_status=1 ";
        }
        if ("8".equals(type)){
            sql+=" and a.register='1' ";
        }
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }
@ -1000,7 +1016,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    }
    /**
     * 查找签约老人
     * 街道老人
     * @param name
     * @param residentialArea
     * @param limit
@ -1009,7 +1025,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    public List<Map<String,Object>> findUnSignOld(String name,String residentialArea,String area,Integer level,String limit,String filter1){
        String sql = "SELECT a.id,a.name,a.photo,a.idcard,CAST(IFNULL(a.birthday,'') AS char ) birthday,a.residential_area residentialArea,a.sex " +
                ",a.ykt_id yktId, case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online,IFNULL(sign_status,0) signStatus from base_patient a " +
                " WHERE a.archive_type = 1 and a.del = '1' and a.sign_status=0  ";
                " WHERE a.archive_type = 1 and a.del = '1' and a.register='2'  ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
@ -1067,7 +1083,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
    }
    public Integer findUnSignOldTotal(String name,String residentialArea,String area,Integer level,String filter){
        String sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' and a.sign_status=0 ";
        String sql = "SELECT count(a.id) from base_patient a  WHERE a.archive_type = 1 and a.del = '1' and a.register='2' ";
        if(!StringUtil.isBlank(name)){
            sql+= " and name like '%"+name+"%' ";
        }

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 140 - 5
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/statistics/DetectionPlatformService.java


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

@ -329,9 +329,13 @@ public class StatisticsService {
        }
        JSONObject res = new JSONObject();
        //医疗机构
        String medicalInstitutionSql = "SELECT COUNT(1) FROM base_org WHERE (type = 1 OR type = 2) AND del = 1 " + orgFilter;
        //养老机构
        String elderlyCarServiceSql = "SELECT COUNT(1) FROM base_org WHERE type = 3 AND del = 1 and code not in ('zdjsylfwyxgszhfgs') " + orgFilter;
        //托育机构
        String childcareInstitutionsssSql = "SELECT COUNT(1) FROM base_org WHERE type = 4 AND del = 1" + orgFilter;
        //照料中心
        String careCenterNumSql = "SELECT COUNT(1) FROM base_org WHERE type = 6 AND del = 1" + orgFilter;
        //社工和教师注册人数
@ -347,18 +351,22 @@ public class StatisticsService {
        for (Map<String, Object> map : list2) {
            String archive_type = map.get("doctor_level").toString();
            Integer num = Integer.valueOf(map.get("c").toString());
            //医生
            if ("1".equals(archive_type)) {
                doctorNum = num;
                continue;
            }
            //社工
            if ("2".equals(archive_type)) {
                helperNum = num;
                continue;
            }
            //助老员
            if ("4".equals(archive_type)) {
                helper4Num = num;
                continue;
            }
            //教师
            if ("3".equals(archive_type)) {
                teacherNum = num;
            }
@ -367,7 +375,7 @@ public class StatisticsService {
        Integer elderlyCarServiceNum = jdbcTemplate.queryForObject(elderlyCarServiceSql, Integer.class);
        Integer childcareInstitutionsssNum = jdbcTemplate.queryForObject(childcareInstitutionsssSql, Integer.class);
        Integer careCenterNum = jdbcTemplate.queryForObject(careCenterNumSql, Integer.class);
        res.put("medicalInstitutionNum", medicalInstitutionNum);             //医疗结构
        res.put("medicalInstitutionNum", medicalInstitutionNum);             //医疗机构
        res.put("elderlyCarServiceNum", elderlyCarServiceNum);               //养老机构
        res.put("childcareInstitutionsssNum", childcareInstitutionsssNum);   //托育机构
        res.put("careCenterNum", careCenterNum);   //照料中心
@ -378,6 +386,83 @@ public class StatisticsService {
        return res;
    }
    /**
     * 获取机构列表
     * @param type 类型。1医疗机构,3养老机构,4托育机构,6照料中心
     * @param page
     * @param pageSize
     * @param name 名字模糊搜索
     * @return
     */
    public PageEnvelop getOrgListByPage(String type,Integer page,Integer pageSize,String name){
        page = page>0?page-1:0;
        String orgFilter = "";
        String sqlOrg = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' ";
        List<Map<String, Object>> listOrg = jdbcTemplate.queryForList(sqlOrg);
        if (listOrg.size() > 0) {
            String orgCodes = String.valueOf(listOrg.get(0).get("orgCodes"));
            orgCodes = orgCodes.replaceAll(",", "','");
            orgFilter = " and code not in ('" + orgCodes + "')";
        }
        String typeSql = "";
        if("1".equals(type)){
            typeSql = " and (type = 1 OR type = 2) ";
        }else if("3".equals(type)){
            typeSql = " and type = "+type + " and code not in ('zdjsylfwyxgszhfgs')  ";
        } else {
            typeSql = " and type = "+type;
        }
        if(StringUtils.isNotBlank(name)){
            typeSql = typeSql + " and name like '%"+name+"%' ";
        }
        String sql = "SELECT id,code,name,alias,type,brief,address,photo,intro,mobile FROM base_org WHERE del = 1 "+typeSql+orgFilter;
        String orderSql = " ORDER BY sort limit "+page*pageSize+","+pageSize;
        String countSql = "SELECT count(*) FROM base_org WHERE del = 1 "+typeSql+orgFilter;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql+orderSql);
        Long count = jdbcTemplate.queryForObject(countSql,Long.class);
        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,count);
    }
    /**
     *
     * @param type 类型。1医生,2社工,3教师,4助老员
     * @param page
     * @param pageSize
     * @param name
     * @param idCard
     * @return
     */
    public PageEnvelop getUserListByPage(String type,Integer page,Integer pageSize,String name,String idCard){
        page = page>0?page-1:0;
        String selectSql = "SELECT a.id,a.name,\n" +
                " CASE\n" +
                " a.sex \n" +
                " WHEN 1 THEN\n" +
                " '男' \n" +
                " WHEN 2 THEN\n" +
                " '女' ELSE a.sex \n" +
                " END AS sex,\n" +
                " TIMESTAMPDIFF(YEAR,a.birthday,now()) AS age,\n" +
                " a.doctor_level,a.mobile,h.org_name,a.idcard ";
        String countSql = " select count(a.id)";
        String fromSql = " from base_doctor a,base_doctor_hospital h where a.id=h.doctor_code and a.del = '1' and h.del = '1' " +
                " and a.doctor_level is not null and h.org_code not in ( " +
                " SELECT dict_code from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org'  )  and a.doctor_level="+type+"  ";
        if(StringUtils.isNotBlank(name)){
            fromSql+=" and a.name like '%"+name+"%' ";
        }
        if(StringUtils.isNotBlank(idCard)){
            fromSql+=" and a.idcard like '%"+idCard+"%' ";
        }
        Long count = jdbcTemplate.queryForObject(countSql + fromSql, Long.class);
        fromSql+=" limit "+page*pageSize+","+pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(selectSql + fromSql);
        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,count);
    }
    // v0.7.0实时数据 照护对象、检测设备、紧急救助
    public JSONObject realTimeDataNew() throws Exception {
        JSONObject res = new JSONObject();
@ -482,10 +567,16 @@ public class StatisticsService {
        return res;
    }
    public PageEnvelop getAllDynamics(Integer page, Integer size) {
    public PageEnvelop getAllDynamics(Integer page, Integer size,String beginTime,String endTime) {
        List result = new ArrayList<>();
        Date date = DateUtil.getPreDays(new Date(), -7);
        String dateStr = DateUtil.dateToStrLong(date);
        String dateStr = "";
        if(StringUtils.isBlank(beginTime) && StringUtils.isBlank(endTime)){
            Date date = DateUtil.getPreDays(new Date(), -7);
            dateStr = " and create_time>='" + DateUtil.dateToStrLong(date) +"' ";
        }else {
            dateStr = " and create_time>='" + beginTime+"' and create_time<='"+endTime+"' ";
        }
        String filter = " ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' " +
@ -499,8 +590,8 @@ public class StatisticsService {
            }
        }
        String sql = "select * from base_login_log where login_type<>1 and create_time>='" + dateStr + "' " + filter + " order by create_time desc limit " + (page - 1) * size + "," + size;
        String sqlCount = "select count(id) from base_login_log where login_type<>1 and create_time>='" + dateStr + "' " + filter;
        String sql = "select * from base_login_log where login_type<>1 " + dateStr + filter + " order by create_time desc limit " + (page - 1) * size + "," + size;
        String sqlCount = "select count(id) from base_login_log where login_type<>1 " + dateStr + filter;
        Long count = jdbcTemplate.queryForObject(sqlCount, Long.class);
        List<BaseLoginLogDO> loginLogDOs = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BaseLoginLogDO.class));
        for (BaseLoginLogDO log : loginLogDOs) {
@ -691,6 +782,9 @@ public class StatisticsService {
     * @param level 区域等级 2市3区4机构5团队6医生
     */
    public JSONObject platformPeople(String area,Integer level) {
        boolean b = StringUtils.isNotBlank(area) && 5 == level;
        String areaFilter = " ";
        JSONObject result = new JSONObject();
        Integer olderTotal = 0;
@ -717,6 +811,9 @@ public class StatisticsService {
        Integer unSignOlderTotal=0;
        Integer unSignOlderOff=0;
        Integer unSignOlderOn=0;
        Integer streetOldTotal = 0;
        Integer streetOldOff = 0;
        Integer streetOldOn = 0;
        //儿童注册人数
@ -750,13 +847,13 @@ public class StatisticsService {
            oldFilter = " and a.id not in ('" + orgCodes + "')";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
        if (b){
            areaFilter = " and EXISTS ( select 1 from " +
                    "base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
                    " where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
                    " and i.del = 1  and sr.`status`=1 and CONVERT(sr.patient USING utf8)  = a.id and r.team_code='"+area+"') OR ( a.saas_id = '"+area+"')";
        }
        String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and (a.sign_status=1 or a.register = 1) " +
        String sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and a.sign_status=1 " +
                " and del='1' "+areaFilter+" " + oldFilter + " GROUP BY online";
        List<Map<String, Object>> list1 = jdbcTemplate.queryForList(sql1);
        for (Map<String, Object> map : list1) {
@ -771,8 +868,14 @@ public class StatisticsService {
        olderTotal = olderOff + olderOn;
        childTotal = childOff + childOn;
        sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and (sign_status=0 or sign_status is null ) " +
                " and del='1' " + oldFilter + " GROUP BY online";
        // 社区老人
        String unSignOldAreaSql ="";
        if (b) {
            unSignOldAreaSql = " AND saas_id = '"+area+"'";
        }
        sql1 = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and a.register = 1 and (sign_status=0 or sign_status is null ) " +
                " and del='1' " + oldFilter + unSignOldAreaSql + " GROUP BY online";
        list1 = jdbcTemplate.queryForList(sql1);
        for (Map<String, Object> map : list1) {
            Integer num = Integer.valueOf(map.get("c").toString());
@ -784,9 +887,27 @@ public class StatisticsService {
            }
        }
        unSignOlderTotal = unSignOlderOff+unSignOlderOn;
        //街道老人
        String testUserSql = "(SELECT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_older' OR dict_name = 'jkzl_user') AND (dict_code IS NOT null OR dict_code = ''))";
        String needCareOldSql = "SELECT COUNT(*) c,case 1 WHEN openid is not null then 1 WHEN a.on_line = '1' then 1 ELSE 0 end as online from base_patient a WHERE archive_type = 1 and a.register = 2 and (sign_status=0 or sign_status is null ) " +
                " and del='1' AND id NOT IN " + testUserSql +unSignOldAreaSql+ " GROUP BY online";
        list1 = jdbcTemplate.queryForList(needCareOldSql);
        for (Map<String, Object> map : list1) {
            Integer num = Integer.valueOf(map.get("c").toString());
            Integer online = Integer.valueOf(map.get("online").toString());
            if (online == 1) {
                streetOldOn += num;
            } else {
                streetOldOff += num;
            }
        }
        streetOldTotal = streetOldOff+streetOldOn;
        //社工和教师注册人数
        if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
        if (b){
            areaFilter = " and EXISTS ( select 1 from base_team_member mem where mem.doctor_code = a.id " +
                    " and mem.team_code='"+area+"' and mem.del=1 )  ";
        }
@ -836,7 +957,7 @@ public class StatisticsService {
            orgCodes = orgCodes.replaceAll(",", "','");
            olderRelativeFilter = " and t2.id not in ('" + orgCodes + "') ";
        }
        if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
        if (b){
            //有社区只查询该社区老人的家属列表
            areaFilter = " and EXISTS ( select 1 from " +
                    "base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
@ -864,7 +985,7 @@ public class StatisticsService {
        }
        olderFamilyTotal = olderFamilyOff+olderFamilyOn;
        //家属绑定老人数量
        if (org.apache.commons.lang3.StringUtils.isNotBlank(area)&&5==level){
        if (b){
            areaFilter = " and EXISTS ( select 1 from " +
                    "base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack " +
                    " where sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id " +
@ -876,7 +997,7 @@ public class StatisticsService {
        olderFamilyBinding = jdbcTemplate.queryForObject(sql2,Integer.class);
        //helper 社工,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板 olderFamily老人家属
        //helper 社工,teacher 教师,child 幼儿,olderWx 老人公众号,olderPad 老人平板 olderFamily老人家属  street 街道老人二次导入朝辉街道
        //helper4助老员 unSignOlder社区老人
        result.put("olderTotal", olderTotal);
        result.put("olderOn", olderOn);
@ -884,6 +1005,9 @@ public class StatisticsService {
        result.put("childTotal", childTotal);
        result.put("childOn", childOn);
        result.put("childOff", childOff);
        result.put("streetOldOn",streetOldOn);
        result.put("streetOldTotal",streetOldTotal);
        result.put("streetOldOff",streetOldOff);
        result.put("unSignOlderTotal", unSignOlderTotal);
        result.put("unSignOlderOff", unSignOlderOff);
        result.put("unSignOlderOn", unSignOlderOn);
@ -2930,59 +3054,545 @@ public class StatisticsService {
    /**
     * 获取招呼老人基本信息
     * 获取照护老人+幼儿基本信息
     * 签约老人+未签约有设备的
     *
     */
    public JSONObject  findTendOld(Integer page,Integer size){
        String sql = "SELECT DISTINCT p.id AS id,p.`name` AS `name`, p.sex AS sex,CASE WHEN LENGTH( p.idcard )= 18 THEN\n" +
                "\t\tYEAR (\n" +
                "\t\t\tnow()) - YEAR (\n" +
                "\t\tsubstring( p.idcard, 7, 8 )) \n" +
                "\t\tWHEN LENGTH( p.idcard )= 15 THEN\n" +
                "\t\tYEAR (\n" +
                "\t\t\tnow()) - YEAR (\n" +
                "\t\tSTR_TO_DATE( CONCAT( '19', substring( p.idcard, 7, 2 )), '%Y' )) ELSE NULL \n" +
                "\tEND AS age,\n" +
                "\tp.mobile AS mobile,\n" +
                "\tp.address AS address,\n" +
                "\tt.`name` AS orgName,\n" +
                "\tGROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName \n" +
                "FROM base_patient p, base_service_package_sign_record sr, base_service_package_record r,base_service_package_item i, base_service_package pack,base_team t,base_team_member tm,base_doctor d \n" +
                "WHERE sr.id = r.sign_id  AND sr.STATUS = 1 AND r.service_package_id = i.service_package_id  AND r.service_package_id = pack.id  AND i.del = 1  AND sr.`status` = 1  AND CONVERT ( sr.patient USING utf8 ) = p.id \n" +
                "\tAND r.team_code = t.id AND tm.team_code = t.id AND d.id = tm.doctor_code AND p.id NOT IN (SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_child' or dict_name = 'jkzl_older' \n" +
                "                  or dict_name = 'jkzl_user' or dict_name = 'jkzl_helper'  or dict_name = 'jkzl_teacher' ) and dict_code is not null)\n" +
                "GROUP BY p.idcard UNION SELECT p.id AS id,p.`name` AS `name`, p.sex AS sex,\n" +
                "CASE\n" +
                "\t\tWHEN LENGTH( p.idcard )= 18 THEN\n" +
                "\t\tYEAR (\n" +
                "\t\t\tnow()) - YEAR (\n" +
                "\t\tsubstring( p.idcard, 7, 8 )) \n" +
                "\t\tWHEN LENGTH( p.idcard )= 15 THEN\n" +
                "\t\tYEAR (\n" +
                "\t\t\tnow()) - YEAR (\n" +
                "\t\tSTR_TO_DATE( CONCAT( '19', substring( p.idcard, 7, 2 )), '%Y' )) ELSE NULL \n" +
                "\tEND AS age,\n" +
                "\tp.mobile AS mobile,\n" +
                "\tp.address AS address,\n" +
                "\tp.address AS orgName,\n" +
                "\t'' AS doctorName \n" +
                "FROM base_patient p INNER JOIN wlyy_patient_device d ON p.id = d.`user` \n" +
                "WHERE p.sign_status = 0  AND p.del = 1  AND d.del = 0 AND p.id NOT IN (SELECT DISTINCT dict_code from wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_child' or dict_name = 'jkzl_older' \n" +
                "                  or dict_name = 'jkzl_user' or dict_name = 'jkzl_helper'  or dict_name = 'jkzl_teacher' ) and dict_code is not null) ORDER BY id\n";
    public JSONObject  findTendOld(Integer type,Integer page,Integer size,String idcard,String name,String orgName){
        String sql = "";
        String orgNameSql = "";
        String orgNameSql2 = "";
        String nameSql = "";
        String idcardSql = "";
        if (StringUtils.isNotBlank(name)){
             nameSql = " and p.name like '%"+name+"%'";
        }
        if (StringUtils.isNotBlank(idcard)){
             idcardSql = " and p.idcard = '"+idcard+"'";
        }
        if (StringUtils.isNotBlank(orgName)){
             orgNameSql  = " and t.name ='"+orgName+"'";
             orgNameSql2 = " and p.residential_area = '"+orgName+"'";
        }
        switch (type) {
            case 1:
                sql = " SELECT DISTINCT p.id AS id,p.`name` AS `name`,p.sex AS sex, p.idcard AS idcard, " +
                        " CASE WHEN LENGTH( p.idcard )= 18 THEN " +
                        "  YEAR ( now()) - YEAR (substring( p.idcard, 7, 8 )) WHEN LENGTH( p.idcard )= 15 THEN " +
                        "  YEAR ( now()) - YEAR (STR_TO_DATE( CONCAT( '19', substring( p.idcard, 7, 2 )), '%Y' )) ELSE NULL  " +
                        " END AS age, p.mobile AS mobile, p.address AS address, t.`name` AS orgName, " +
                        " GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName  FROM " +
                        " base_patient p,base_service_package_sign_record sr,base_service_package_record r,base_service_package_item i,base_service_package pack,base_team t,base_team_member tm,base_doctor d  " +
                        " WHERE " +
                        " sr.id = r.sign_id  " +
                        " AND sr.STATUS = 1  " +
                        " AND r.service_package_id = i.service_package_id  " +
                        " AND r.service_package_id = pack.id  " +
                        " AND i.del = 1  " +
                        " AND sr.`status` = 1  " +
                        " AND CONVERT ( sr.patient USING utf8 ) = p.id  " +
                        " AND r.team_code = t.id  " +
                        " AND tm.team_code = t.id " +
                        " AND p.archive_type = 1 " +nameSql+idcardSql+orgNameSql+
                        " AND d.id = tm.doctor_code <testUserSql>  " +
                        " GROUP BY p.idcard " +
                        " UNION " +
                        " SELECT " +
                        " p.id AS id,p.`name` AS `name`, p.sex AS sex, p.idcard AS idcard, " +
                        " CASE WHEN LENGTH( p.idcard )= 18 THEN " +
                        "  YEAR (now()) - YEAR ( substring( p.idcard, 7, 8 ))  " +
                        "  WHEN LENGTH( p.idcard )= 15 THEN " +
                        "  YEAR (now()) - YEAR (STR_TO_DATE( CONCAT( '19', substring( p.idcard, 7, 2 )), '%Y' )) ELSE NULL  " +
                        " END AS age, " +
                        " p.mobile AS mobile,p.address AS address, p.residential_area AS orgName,'' AS doctorName  " +
                        " FROM " +
                        " base_patient p INNER JOIN wlyy_patient_device d ON p.id = d.`user`  " +
                        " WHERE p.sign_status = 0 AND p.del = 1 AND d.del = 0 AND p.archive_type = 1 " + nameSql+idcardSql+orgNameSql2+
                        " <testUserSql>  " +
                        " GROUP BY p.idcard  ";
                break;
            case 2:
                sql +=" SELECT DISTINCT p.id AS id, p.`name` AS `name`,  p.sex AS sex,  p.idcard AS idcard," +
                        " CASE WHEN LENGTH( p.idcard )= 18 THEN  " +
                        " YEAR ( now()) - YEAR (substring( p.idcard, 7, 8 ))   " +
                        " WHEN LENGTH( p.idcard )= 15 THEN YEAR (now()) - YEAR (STR_TO_DATE( CONCAT( '19', substring( p.idcard, 7, 2 )), '%Y' )) ELSE NULL   " +
                        " END AS age,p.mobile AS mobile,p.address AS address  " +
                        " FROM base_patient p  " +
                        " WHERE p.archive_type = 2 and p.del = 1 "+nameSql+idcardSql+" <testUserSql>";
                break;
        }
        page = (page - 1) * size;
        String testUserSql = "AND p.id NOT IN (SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict" +
                " WHERE( dict_name = 'jkzl_child' OR dict_name = 'jkzl_older' OR dict_name = 'jkzl_user') AND dict_code IS NOT NULL ) ";
        sql += "  ORDER BY id limit " + page + "," + size + "";
        sql = sql.replace("<testUserSql>",testUserSql);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("data", list);
        jsonObject.put("userTotal", list.size());
        page = (page-1)*size;
        return jsonObject;
    }
    //对应的社区
    public List<Map<String, Object>> findOldOrg() {
        String sql = " SELECT t.`name`,t.id FROM base_team t WHERE t.org_code IN(SELECT code FROM base_org WHERE type = '3' AND `code`" +
                " not IN(SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org'))  GROUP BY t.`name`";
        return jdbcTemplate.queryForList(sql);
    }
    //超时工单
    public JSONObject overTimeOrderList(Integer type,Integer page ,Integer size ,String name,String idcard,String orgCode){
        String nameSql = "";
        String idcardSql = "";
        String orgCodeSql = "";
        String total = "";
        String sql = "";
        if (StringUtils.isNotBlank(name)) {
            nameSql = " AND p.`name` like '%"+name+"%'";
        }
        if (StringUtils.isNotBlank(idcard)) {
            idcardSql = " AND p.idcard = '"+idcard+"'";
        }
        if (StringUtils.isNotBlank(idcard)) {
            orgCodeSql = " AND t.id = '"+orgCode+"'";
        }
        String testUserSql = " NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE ( dict_name = 'jkzl_child' OR dict_name = 'jkzl_older' OR dict_name = 'jkzl_user' OR dict_name= 'jkzl_olderRelative' ) AND dict_code IS NOT NULL ) ";
        if (page==0)page=1;
        if (size==0)size=10;
        page = (page - 1) * size;
        switch (type) {
            case 1:
                sql = " SELECT DISTINCT" +
                        " p.name, o.`status`, o.id AS orderId,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') as create_time ," +
                        " GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName," +
                        " GROUP_CONCAT( DISTINCT d.mobile SEPARATOR ',' ) AS dmobile," +
                        " p.mobile AS pmobile, p.address AS address, t.`name` AS orgName," +
                        " '紧急预警' AS ewtype, 1 AS type,  o.serve_address AS serviceAddress " +
                        "FROM " +
                        " base_emergency_assistance_order o  INNER JOIN base_patient p ON o.patient = p.id, base_service_package_sign_record sr, " +
                        " base_service_package_record r,base_service_package_item i, base_service_package pack,base_team t,base_team_member tm, " +
                        " base_doctor d WHERE o.STATUS = 1  AND o.patient "+testUserSql+" " +
                        " AND ( TIMESTAMPDIFF( HOUR, o.create_time, now()) >= 1 )  " +
                        " AND NOT EXISTS ( SELECT 1 FROM base_emergency_warn_log log WHERE log.order_id = o.id )  " +
                        " AND sr.id = r.sign_id  " +
                        " AND sr.STATUS = 1  " +
                        " AND r.service_package_id = i.service_package_id  " +
                        " AND r.service_package_id = pack.id  " +
                        " AND i.del = 1  " +
                        " AND sr.`status` = 1  " +
                        " AND CONVERT ( sr.patient USING utf8 ) = p.id  " +
                        " AND r.team_code = t.id  " +
                        " AND tm.team_code = t.id  " +
                        " AND p.archive_type = 1  " +
                        " AND d.id = tm.doctor_code  " +orgCodeSql+idcardSql+nameSql+
                        " union all " +
                        "SELECT DISTINCT p.name,  o.`status`, o.id AS orderId, DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') as create_time, " +
                        " GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName, " +
                        " GROUP_CONCAT( DISTINCT d.mobile SEPARATOR ',' ) AS dmobile, " +
                        " p.mobile AS pmobile, p.address AS address, t.`name` AS orgName, " +
                        " o.serve_desc AS ewtype, 2 AS type, o.serve_address AS serviceAddress " +
                        "FROM " +
                        " base_security_monitoring_order o INNER JOIN base_patient p ON o.patient = p.id , " +
                        " base_service_package_sign_record sr,base_service_package_record r,  base_service_package_item i,  base_service_package pack, " +
                        " base_team t,  base_team_member tm, base_doctor d  " +
                        " WHERE " +
                        " o.STATUS = 1  " +
                        " AND o.patient  "+testUserSql+" " +
                        " AND ( TIMESTAMPDIFF( HOUR, o.create_time, now()) >= 1 )  " +
                        " AND NOT EXISTS (SELECT 1 FROM base_emergency_warn_log log WHERE log.order_id = o.id) " +
                        " AND sr.id = r.sign_id  " +
                        " AND sr.STATUS = 1  " +
                        " AND r.service_package_id = i.service_package_id  " +
                        " AND r.service_package_id = pack.id  " +
                        " AND i.del = 1  " +
                        " AND sr.`status` = 1  " +
                        " AND CONVERT ( sr.patient USING utf8 ) = p.id  " +
                        " AND r.team_code = t.id  " +
                        " AND tm.team_code = t.id  " +
                        " AND p.archive_type = 1  " + orgCodeSql+idcardSql+nameSql+
                        " AND d.id = tm.doctor_code ";
                total = overTimeOrderListTotalSql(1,nameSql,idcardSql,orgCodeSql);
                break;
            case 2:
                sql = "SELECT DISTINCT o.id as orderId, p.`name`, p.mobile,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%s') as create_time , fd.NAME AS lifeName, bo.NAME AS serviceOrgName, bo.mobile AS orgMobile, t.`name` AS area   " +
                        " FROM " +
                        " base_life_care_order o  " +
                        " INNER JOIN base_patient p ON o.patient = p.id  " +
                        " LEFT JOIN base_life_care_fee_detail fd ON o.id = fd.order_id  " +
                        " LEFT JOIN base_org bo ON o.hospital = bo.`code`,  " +
                        " base_service_package_sign_record sr,  " +
                        " base_service_package_record r,  " +
                        " base_service_package_item i,  " +
                        " base_service_package pack,  " +
                        " base_team t   " +
                        " WHERE  " +
                        "  o.STATUS = 1   " +
                        "  AND o.patient "+testUserSql+"  " +
                        "  AND ( TIMESTAMPDIFF( HOUR, o.create_time, now()) >= 6 )   " +
                        "  AND sr.id = r.sign_id   " +
                        "  AND sr.STATUS = 1   " +
                        "  AND r.service_package_id = i.service_package_id   " +
                        "  AND r.service_package_id = pack.id   " +
                        "  AND i.del = 1   " +
                        "  AND sr.`status` = 1   " +
                        "  AND CONVERT ( sr.patient USING utf8 ) = p.id   " +
                        "  AND r.team_code = t.id   " +
                        "  AND p.archive_type = 1 "+nameSql+idcardSql+orgCodeSql+" UNION ALL  " +
                        "SELECT DISTINCT co.id as orderId, p.`name`, p.mobile, DATE_FORMAT(co.create_time,'%Y-%m-%d %H:%i:%s') as create_time, fd.NAME AS lifeName, co.hospital_name AS serviceOrgName,bo.mobile AS orgMobile, p.residential_area AS area   " +
                        "FROM  " +
                        "  base_life_care_order co  " +
                        "  LEFT JOIN base_patient p ON co.patient = p.id  " +
                        "  LEFT JOIN base_life_care_fee_detail fd ON co.id = fd.order_id  " +
                        "  LEFT JOIN base_org bo ON co.hospital = bo.`code`   " +
                        "WHERE  " +
                        "  p.sign_status <> 1   " +
                        "  AND co.`status` = 1   " +
                        "  AND p.id "+testUserSql+""+nameSql+idcardSql+orgCodeSql;
                total = overTimeOrderListTotalSql(2,nameSql,idcardSql,orgCodeSql);
                break;
        }
        sql += "GROUP BY orderId ORDER BY create_time DESC LIMIT "+page+","+size+" ";
        sql += " limit "+page+","+size+"";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("data",list);
        jsonObject.put("oldTotal",list.size());
        jsonObject.put("list",list);
        jsonObject.put("total",total);
        return jsonObject;
    }
    //紧急安防工单列表
    public JSONObject emeSecOrderList(Integer status,String name,String idcard,String orgCode,Integer page,Integer size){
        if (page==null) page=1;
        if (size==null) size=10;
        page = (page-1)*size;
        String statusSql ="AND  o.`status` <> -1";
        String nameSql = "";
        String idcardSql = "";
        String orgCodeSql = "";
        if (StringUtils.isNotBlank(name)){
            nameSql = " AND p.`name` LIKE '%"+name+"%'";
        }
        if (StringUtils.isNotBlank(idcard)){
            idcardSql = "AND p.idcard = '"+idcard+"'";
        }
        if (StringUtils.isNotBlank(orgCode)){
            orgCodeSql =" AND t.id = '"+orgCode+"'";
        }
        if (null!=status){
            statusSql = "AND o.status = "+status+"";
        }
        String sql = "SELECT p.name,o.`status`,o.id AS orderId,DATE_FORMAT( o.create_time, '%Y-%m-%d %H:%i:%s' ) AS create_time, " +
                " GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName, " +
                " GROUP_CONCAT( DISTINCT d.mobile SEPARATOR ',' ) AS dmobile, " +
                " p.mobile AS pmobile, p.address AS address,t.`name` AS orgName, " +
                " '紧急预警' AS ewtype, 1 AS type,o.serve_address AS serviceAddress  " +
                " FROM " +
                " base_emergency_assistance_order o " +
                " LEFT JOIN base_patient p ON o.patient = p.id " +
                " LEFT JOIN base_service_package_sign_record sr ON CONVERT( sr.patient USING utf8 ) = p.id AND sr.STATUS = 1 AND sr.`status` = 1   " +
                " LEFT JOIN base_service_package_record r ON sr.id = r.sign_id  " +
                " LEFT JOIN base_service_package_item i ON r.service_package_id = i.service_package_id  AND i.del = 1  " +
                " LEFT JOIN base_service_package pack ON r.service_package_id = pack.id  " +
                " LEFT JOIN base_team t ON r.team_code = t.id " +
                " LEFT JOIN base_team_member tm ON tm.team_code = t.id " +
                " LEFT JOIN base_doctor d ON d.id = tm.doctor_code " +
                "WHERE 1=1 " +
                 statusSql+nameSql+idcardSql+orgCodeSql+
                " AND o.org_code NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' AND dict_code IS NOT NULL )  GROUP BY o.id " +
                " UNION ALL " +
                " SELECT p.name,o.`status`,o.id AS orderId,DATE_FORMAT( o.create_time, '%Y-%m-%d %H:%i:%s' ) AS create_time, " +
                " GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName, " +
                " GROUP_CONCAT( DISTINCT d.mobile SEPARATOR ',' ) AS dmobile, " +
                " p.mobile AS pmobile,p.address AS address,t.`name` AS orgName, " +
                " o.serve_desc AS ewtype,2 AS type,o.serve_address AS serviceAddress  " +
                "FROM " +
                " base_security_monitoring_order o " +
                " LEFT JOIN base_patient p ON o.patient = p.id " +
                " LEFT JOIN base_service_package_sign_record sr ON CONVERT ( sr.patient USING utf8 ) = p.id AND sr.`status` = 1  " +
                " LEFT JOIN base_service_package_record r ON sr.id = r.sign_id  " +
                " LEFT JOIN base_service_package_item i ON r.service_package_id = i.service_package_id  AND i.del = 1  " +
                " LEFT JOIN base_service_package pack ON r.service_package_id = pack.id  " +
                " LEFT JOIN base_team t ON r.team_code = t.id  " +
                " LEFT JOIN base_team_member tm ON tm.team_code = t.id  " +
                " LEFT JOIN base_doctor d ON d.id = tm.doctor_code  " +
                " WHERE 1=1 " +
                  statusSql+nameSql+idcardSql+orgCodeSql+
                " AND p.id NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE ( dict_name = 'jkzl_child' OR dict_name = 'jkzl_older' OR dict_name = 'jkzl_user' OR dict_name= 'jkzl_olderRelative' ) AND dict_code IS NOT NULL ) " +
                " GROUP BY o.id  ORDER BY create_time DESC LIMIT "+page+","+size+"";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list",list);
        jsonObject.put("total",emeSecOrderListTotalSql(nameSql,idcardSql,orgCodeSql,statusSql));
        return jsonObject;
    }
    private String emeSecOrderListTotalSql(String nameSql,String idcardSql,String orgCodeSql,String statusSql){
        String sql ="SELECT SUM(a.total) FROM(\n" +
                "SELECT \n" +
                "\tcount(DISTINCT o.id) AS total \n" +
                "FROM\n" +
                "\tbase_emergency_assistance_order o\n" +
                "\tLEFT JOIN base_patient p ON o.patient = p.id\n" +
                "\tLEFT JOIN base_service_package_sign_record sr ON CONVERT( sr.patient USING utf8 ) = p.id AND sr.STATUS = 1 AND sr.`status` = 1 \t\n" +
                "\tLEFT JOIN base_service_package_record r ON sr.id = r.sign_id \n" +
                "\tLEFT JOIN base_service_package_item i ON r.service_package_id = i.service_package_id  AND i.del = 1 \n" +
                "\tLEFT JOIN base_service_package pack ON r.service_package_id = pack.id \n" +
                "\tLEFT JOIN base_team t ON r.team_code = t.id\n" +
                "\tLEFT JOIN\tbase_team_member tm ON tm.team_code = t.id\n" +
                "\tLEFT JOIN base_doctor d ON d.id = tm.doctor_code\n" +
                "WHERE\t\n" +
                "\t1=1 \n " +statusSql+nameSql+idcardSql+orgCodeSql+
                "  AND  o.`status` <> -1\n" +
                "\tAND o.org_code NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_org' AND dict_code IS NOT NULL )  \n" +
                "UNION ALL\n" +
                "SELECT \n" +
                "\tcount(DISTINCT o.id) AS total \n" +
                "FROM\n" +
                "\tbase_security_monitoring_order o\n" +
                "\tLEFT JOIN base_patient p ON o.patient = p.id\n" +
                "\tLEFT JOIN base_service_package_sign_record sr ON CONVERT ( sr.patient USING utf8 ) = p.id AND sr.`status` = 1 \n" +
                "  LEFT JOIN\tbase_service_package_record r ON sr.id = r.sign_id \n" +
                "\tLEFT JOIN base_service_package_item i ON r.service_package_id = i.service_package_id  AND i.del = 1 \n" +
                "\tLEFT JOIN base_service_package pack ON r.service_package_id = pack.id \n" +
                "\tLEFT JOIN base_team t ON r.team_code = t.id \n" +
                "\tLEFT JOIN base_team_member tm ON tm.team_code = t.id \n" +
                "\tLEFT JOIN base_doctor d ON d.id = tm.doctor_code \n" +
                "WHERE 1=1 \n" +
                "\t\n" +statusSql+nameSql+idcardSql+orgCodeSql+
                "\tAND p.id NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE ( dict_name = 'jkzl_child' OR dict_name = 'jkzl_older' OR dict_name = 'jkzl_user' OR dict_name= 'jkzl_olderRelative' ) AND dict_code IS NOT NULL )\n" +
                ") a";
        List<String> list = jdbcTemplate.queryForList(sql, String.class);
        return list.get(0);
    }
    private String overTimeOrderListTotalSql(Integer type,String nameSql,String idcardSql,String orgCodeSql){
        String sql = "";
       switch (type){
           case 1:
                sql = "SELECT SUM(a.total) FROM (\n" +
                       "\tSELECT \n" +
                       "\t\tcount(DISTINCT o.id) AS total\n" +
                       "\tFROM\n" +
                       "\t\tbase_emergency_assistance_order o\n" +
                       "\t\tINNER JOIN base_patient p ON o.patient = p.id,\n" +
                       "\t\tbase_service_package_sign_record sr,\n" +
                       "\t\tbase_service_package_record r,\n" +
                       "\t\tbase_service_package_item i,\n" +
                       "\t\tbase_service_package pack,\n" +
                       "\t\tbase_team t,\n" +
                       "\t\tbase_team_member tm,\n" +
                       "\t\tbase_doctor d \n" +
                       "\tWHERE\n" +
                       "\t\to.STATUS = 1 \n" +
                       "\t\tAND o.patient NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE ( dict_name = 'jkzl_child' OR dict_name = 'jkzl_older' OR dict_name = 'jkzl_user' ) AND dict_code IS NOT NULL ) \n" +
                       "\t\tAND ( TIMESTAMPDIFF( HOUR, o.create_time, now()) >= 6 ) \n" +
                       "\t\tAND NOT EXISTS ( SELECT 1 FROM base_emergency_warn_log log WHERE log.order_id = o.id ) \n" +
                       "\t\tAND sr.id = r.sign_id \n" +
                       "\t\tAND sr.STATUS = 1 \n" +
                       "\t\tAND r.service_package_id = i.service_package_id \n" +
                       "\t\tAND r.service_package_id = pack.id \n" +
                       "\t\tAND i.del = 1 \n" +
                       "\t\tAND sr.`status` = 1 \n" +
                       "\t\tAND CONVERT ( sr.patient USING utf8 ) = p.id \n" +
                       "\t\tAND r.team_code = t.id \n" +
                       "\t\tAND tm.team_code = t.id \n" +
                       "\t\tAND p.archive_type = 1 \n" +
                       "\t\tAND d.id = tm.doctor_code "+nameSql+idcardSql+orgCodeSql+" UNION ALL\n" +
                       "\tSELECT \n" +
                       "\t\tCOUNT(DISTINCT o.id) AS total\n" +
                       "\tFROM\n" +
                       "\t\tbase_security_monitoring_order o\n" +
                       "\t\tINNER JOIN base_patient p ON o.patient = p.id,\n" +
                       "\t\tbase_service_package_sign_record sr,\n" +
                       "\t\tbase_service_package_record r,\n" +
                       "\t\tbase_service_package_item i,\n" +
                       "\t\tbase_service_package pack,\n" +
                       "\t\tbase_team t,\n" +
                       "\t\tbase_team_member tm,\n" +
                       "\t\tbase_doctor d \n" +
                       "\tWHERE\n" +
                       "\t\to.STATUS = 1 \n" +
                       "\t\tAND o.patient NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE ( dict_name = 'jkzl_child' OR dict_name = 'jkzl_older' OR dict_name = 'jkzl_user' ) AND dict_code IS NOT NULL ) \n" +
                       "\t\tAND ( TIMESTAMPDIFF( HOUR, o.create_time, now()) >= 6 ) \n" +
                       "\t\tAND NOT EXISTS ( SELECT 1 FROM base_emergency_warn_log log WHERE log.order_id = o.id ) \n" +
                       "\t\tAND sr.id = r.sign_id \n" +
                       "\t\tAND sr.STATUS = 1 \n" +
                       "\t\tAND r.service_package_id = i.service_package_id \n" +
                       "\t\tAND r.service_package_id = pack.id \n" +
                       "\t\tAND i.del = 1 \n" +
                       "\t\tAND sr.`status` = 1 \n" +
                       "\t\tAND CONVERT ( sr.patient USING utf8 ) = p.id \n" +
                       "\t\tAND r.team_code = t.id \n" +
                       "\t\tAND tm.team_code = t.id "+nameSql+idcardSql+orgCodeSql+" \n" +
                       "\t\tAND p.archive_type = 1 \n" +
                       "\t\tAND d.id = tm.doctor_code) a";
               break;
           case 2:
               sql = "SELECT\n" +
                       "\tSUM( a.total ) \n" +
                       "FROM\n" +
                       "\t(\n" +
                       "\tSELECT\n" +
                       "\t\tcount( DISTINCT o.id ) AS total \n" +
                       "\tFROM\n" +
                       "\t\tbase_life_care_order o\n" +
                       "\t\tINNER JOIN base_patient p ON o.patient = p.id\n" +
                       "\t\tLEFT JOIN base_life_care_fee_detail fd ON o.id = fd.order_id\n" +
                       "\t\tLEFT JOIN base_org bo ON o.hospital = bo.`code`,\n" +
                       "\t\tbase_service_package_sign_record sr,\n" +
                       "\t\tbase_service_package_record r,\n" +
                       "\t\tbase_service_package_item i,\n" +
                       "\t\tbase_service_package pack,\n" +
                       "\t\tbase_team t \n" +
                       "\tWHERE\n" +
                       "\t\to.STATUS = 1 \n" +
                       "\t\tAND o.patient NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE ( dict_name = 'jkzl_child' OR dict_name = 'jkzl_older' OR dict_name = 'jkzl_user' ) AND dict_code IS NOT NULL ) \n" +
                       "\t\tAND ( TIMESTAMPDIFF( HOUR, o.create_time, now()) >= 6 ) \n" +
                       "\t\tAND sr.id = r.sign_id \n" +
                       "\t\tAND sr.STATUS = 1 \n" +
                       "\t\tAND r.service_package_id = i.service_package_id \n" +
                       "\t\tAND r.service_package_id = pack.id \n" +
                       "\t\tAND i.del = 1 \n" +
                       "\t\tAND sr.`status` = 1 \n" +
                       "\t\tAND CONVERT ( sr.patient USING utf8 ) = p.id \n" +
                       "\t\tAND r.team_code = t.id \n" +
                       "\t\tAND p.archive_type = 1 "+nameSql+idcardSql+orgCodeSql+" UNION ALL\n" +
                       "\tSELECT\n" +
                       "\t\tcount( DISTINCT co.id ) AS total \n" +
                       "\tFROM\n" +
                       "\t\tbase_life_care_order co\n" +
                       "\t\tLEFT JOIN base_patient p ON co.patient = p.id\n" +
                       "\t\tLEFT JOIN base_life_care_fee_detail fd ON co.id = fd.order_id\n" +
                       "\t\tLEFT JOIN base_org bo ON co.hospital = bo.`code`\n" +
                       "\t\tLEFT JOIN base_team t ON t.org_code = bo.CODE \n" +
                       "\tWHERE\n" +
                       "\t\tp.sign_status <> 1 \n" +
                       "\t\tAND co.`status` = 1 "+nameSql+idcardSql+orgCodeSql+" \n" +
                       "\t\tAND p.id NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE ( dict_name = 'jkzl_child' OR dict_name = 'jkzl_older' OR dict_name = 'jkzl_user' ) AND dict_code IS NOT NULL ) \n" +
                       "\t) a";
               break;
       }
        List<String> list = jdbcTemplate.queryForList(sql, String.class);
        return list.get(0);
    }
    //健康设备-安防设备 列表
    public PageEnvelop healthySecurityDeviceList(String name, String deviceSn, String categoryCode, String contactStatus, String type, Integer page, Integer size) {
        String nameSql = "";
        String deviceSnSql = "";
        String categoryCodeSql = "";
        String contactStatusSql = "";
        String totalSql = "";
        if (StringUtils.isNotBlank(contactStatus))
            contactStatusSql = " AND wd.contact_status = '" + contactStatus + "'";
        if (StringUtils.isNotBlank(name)) nameSql = " AND p.name LIKE '%" + name + "%'";
        if (StringUtils.isNotBlank(deviceSn)) deviceSnSql = " AND pd.device_sn = '" + deviceSn + "'";
        if (page == null) page = 1;
        if (size == null) size = 10;
        page = (page - 1) * size;
        String deviceSql = "";
        if ("jk".equals(type)) {
            categoryCodeSql = " AND ( pd.category_code = 1 OR pd.category_code = 2 )";
            if (StringUtils.isNotBlank(categoryCode))
                categoryCodeSql = " AND pd.category_code = '" + categoryCode + "'";
            deviceSql = "SELECT DISTINCT  p.id AS patient, pd.id as id,pd.device_name AS deviceName,pd.device_sn AS deviceSn,'健康设备' AS deviceType,p.`name`," +
                    " p.mobile,p.phone,dd.photo,wd.contact_status * 1 AS contactStatus" +
                    " FROM " +
                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " +
                    " pd.del = 0 " + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
            totalSql = "SELECT count(DISTINCT pd.id) FROM " +
                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " +
                    " pd.del = 0 " + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
        }
        if ("af".equals(type) || StringUtils.isBlank(type)) {
            categoryCodeSql = " AND pd.category_code > 2 ";
            if (StringUtils.isNotBlank(categoryCode))
                categoryCodeSql = " AND pd.category_code = '" + categoryCode + "'";
            deviceSql = " SELECT DISTINCT  p.id AS patient,pd.id AS id ,pd.device_name AS deviceName,pd.device_sn AS deviceSn,'安防设备' AS deviceType,p.`name`,p.mobile,p.phone,dd.photo,wd.contact_status * 1 AS contactStatus " +
                    " FROM " +
                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " +
                    " pd.del = 0 " + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
            totalSql = " SELECT count(DISTINCT p.id) FROM " +
                    " wlyy_patient_device pd LEFT JOIN base_patient p ON pd.`user` = p.id LEFT JOIN dm_device dd ON pd.category_code = dd.category_code " +
                    " LEFT JOIN wlyy_devices wd ON wd.device_code = pd.device_sn WHERE " +
                    " pd.del = 0 " + nameSql + deviceSnSql + categoryCodeSql + contactStatusSql;
        }
        deviceSql += " GROUP BY id LIMIT " + page + "," + size + " ";
        List<Map<String, Object>> deviceList = jdbcTemplate.queryForList(deviceSql);
        List<String> list = jdbcTemplate.queryForList(totalSql, String.class);
        JSONArray jsonArray = new JSONArray();
        for (Map<String, Object> map : deviceList) {
            Map<String, Object> signInfoMap = patientSignInfo(map.get("patient").toString());
            if (null!=signInfoMap) {
                map.put("orgName", signInfoMap.get("orgName"));
                jsonArray.add(map);
            }
        }
        return PageEnvelop.getSuccessListWithPage("success", jsonArray, page, size, Long.parseLong(list.get(0)));
    }
    //获取对应设备名称
    public List<Map<String, Object>> deviceNameList(String type){
        String sql = "SELECT `name`,category_code FROM dm_device WHERE device_type = "+type+" GROUP BY category_code";
        return  jdbcTemplate.queryForList(sql);
    }
    private Map<String, Object> patientSignInfo(String patient){
        String signSql ="SELECT p.NAME,p.id AS id, " +
                "  GROUP_CONCAT( DISTINCT d.NAME SEPARATOR ',' ) AS doctorName," +
                "  GROUP_CONCAT( DISTINCT d.mobile SEPARATOR ',' ) AS dmobile," +
                "  p.mobile AS pmobile, p.address AS address,t.`name` AS orgName " +
                "  FROM " +
                "  base_patient p " +
                "  INNER JOIN base_service_package_sign_record sr ON CONVERT( sr.patient USING utf8 ) = p.id AND sr.STATUS = 1 AND sr.`status` = 1 " +
                "  INNER JOIN base_service_package_record r ON sr.id = r.sign_id  " +
                "  INNER JOIN base_service_package_item i ON r.service_package_id = i.service_package_id  AND i.del = 1  " +
                "  INNER JOIN base_service_package pack ON r.service_package_id = pack.id  " +
                "  INNER JOIN base_team t ON r.team_code = t.id " +
                "  INNER JOIN base_team_member tm ON tm.team_code = t.id " +
                "  INNER JOIN base_doctor d ON d.id = tm.doctor_code " +
                "  WHERE 1=1 and p.id = '"+patient+"' " +
                "  AND p.id NOT IN ( SELECT DISTINCT dict_code FROM wlyy_hospital_sys_dict WHERE (dict_name = 'jkzl_user' OR dict_name = 'jkzl_older' ) AND dict_code IS NOT NULL )  GROUP BY id\n";
        List<Map<String, Object>> list = jdbcTemplate.queryForList(signSql);
        return list.size()>0?list.get(0):null;
    }
}

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

@ -29,16 +29,19 @@ import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.GpsUtil;
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.healthIndex.HealthIndexUtil;
import org.apache.commons.lang.StringUtils;
import org.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.*;
import java.util.stream.Collectors;
@ -87,6 +90,8 @@ public class PatientInfoPlatFormService {
    private YsDeviceService ysDeviceService;
    @Autowired
    private GpsUtil gpsUtil;
    @Autowired
    private HealthIndexUtil healthIndexUtil;
    /**
@ -477,7 +482,7 @@ public class PatientInfoPlatFormService {
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }
    public PageEnvelop getEmergencyWarnOrderListNew(Integer page,Integer pageSize,String patient){
    public PageEnvelop getEmergencyWarnOrderListNew(Integer page,Integer pageSize,String patient,String beginTime,String endTime){
        page = page>0?page-1:0;
        String filter =" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
@ -490,10 +495,13 @@ public class PatientInfoPlatFormService {
        String sql = " select  '22' as 'OrderType',p.archive_type archiveType,p.residential_area residentialArea,ord.id,ord.patient,p.name,ord.serve_desc,DATE_FORMAT(ord.create_time,'%Y-%m-%d %H:%i:%S') create_time," +
                "ord.`status`,case p.sex when 1 then '男' when 2 then '女' else p.sex end as sex,TIMESTAMPDIFF(YEAR,p.birthday,now()) as age \n" +
                "from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id " ;
                "from base_security_monitoring_order ord INNER JOIN base_patient p on ord.patient = p.id where 1=1 " ;
        if (StringUtils.isNotBlank(patient)){
            sql +=" and ord.patient='"+patient+"' ";
        }
        if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
            sql +=" and ord.create_time>='"+beginTime+"' and ord.create_time<='"+endTime+"' ";
        }
        sql+= filter +" order by create_time desc ";
        String countSql = "select count(id) from ("+sql+")A ";
        long count = jdbcTemplate.queryForObject(countSql,long.class);
@ -639,7 +647,7 @@ public class PatientInfoPlatFormService {
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }
    public PageEnvelop getEmergencyWarningListNew(Integer page,Integer pageSize,String patient){
    public PageEnvelop getEmergencyWarningListNew(Integer page,Integer pageSize,String patient,String beginTime,String endTime){
        page = page>0?page-1:0;
        String filter=" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
@ -657,6 +665,9 @@ public class PatientInfoPlatFormService {
        if (StringUtils.isNotBlank(patient)){
            filter +=" and ord.patient='"+patient+"' ";
        }
        if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
            filter += " and ord.create_time>='"+beginTime+"' and ord.create_time<='"+endTime+"' ";
        }
        sql +=  filter + "  order by create_time desc";
        sqlCount  +=filter;
@ -666,7 +677,7 @@ public class PatientInfoPlatFormService {
        return PageEnvelop.getSuccessListWithPage("查询成功",list,page,pageSize,count);
    }
    public PageEnvelop getHealthMonitoringListNew(Integer page,Integer pageSize){
    public PageEnvelop getHealthMonitoringListNew(Integer page,Integer pageSize,String beginTime,String endTime){
        page = page>0?page-1:0;
        String filter=" ";
@ -677,9 +688,12 @@ public class PatientInfoPlatFormService {
            orgCodes = orgCodes.replaceAll(",","','");
            filter = " and idx.user not in ('"+orgCodes+"') ";
        }
        if(StringUtils.isNotBlank(beginTime) && StringUtils.isNotBlank(endTime)){
            filter+=" and idx.czrq>='"+beginTime+"' and idx.czrq<='"+endTime+"' ";
        }
        String sql = " SELECT idx.id,idx.user,idx.`name`,p.archive_type archiveType,p.residential_area residentialArea,'健康监测' as serve_desc, " +
                "idx.czrq,value1,value2,value3,value4,value5,value6,value7,type FROM wlyy_patient_health_index idx " +
                "idx.czrq,value1,value2,value3,value4,value5,value6,value7,type,DATE_FORMAT(idx.czrq,'%Y-%m-%d %H:%i:%S') createTime FROM wlyy_patient_health_index idx " +
                " INNER JOIN base_patient p on idx.user = p.id and p.del=1\n" +
                " WHERE idx.del = 1 AND idx.type < 3 "+filter+" ORDER BY idx.czrq desc ";
        String countSql = "select count(id) from ("+sql+")A ";
@ -1039,4 +1053,221 @@ public class PatientInfoPlatFormService {
        return detailInfo;
    }
    /**
     * 获取紧急预警和一般预警中的总数
     * @param patient
     * @return
     */
    public ObjEnvelop getWarningCount(String patient){
        String filter1=" ";
        String filter2=" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0&&StringUtils.isBlank(patient)){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            orgCodes = orgCodes.replaceAll(",","','");
            filter1 = " and ord.patient not in ('"+orgCodes+"') ";
            filter2 = " and idx.user not in ('"+orgCodes+"') ";
        }
        //查紧急预警
        Long warningCount = this.getWarningCountByEmergencyAndSecurity(filter1);
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("warningCount",warningCount);
        //查一般预警(体征预警)
        Long healthCount = this.getWarningCountByHealth(filter2);
        map.put("healthCount",healthCount);
        map.put("total",warningCount+healthCount);
        return ObjEnvelop.getSuccess("获取成功",map);
    }
    /**
     * 获取紧急预警中的列表
     * @param page
     * @param pageSize
     * @param patient
     * @return
     */
    public PageEnvelop getWarningList(Integer page,Integer pageSize,String patient){
        page = page>0?page-1:0;
        String filter=" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0&&StringUtils.isBlank(patient)){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            orgCodes = orgCodes.replaceAll(",","','");
            filter = " and ord.patient not in ('"+orgCodes+"') ";
        }
        String sql1 = " SELECT\n" +
                " '20' AS OrderType,\n" +
                " p.archive_type archiveType,\n" +
                " p.residential_area residentialArea,\n" +
                " ord.id,\n" +
                " ord.patient,\n" +
                " p.name,\n" +
                " '紧急呼叫' AS serve_desc,\n" +
                " DATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) createTime,\n" +
                " ord.`status`,\n" +
                " CASE \n" +
                " p.sex \n" +
                " WHEN 1 THEN\n" +
                " '男' \n" +
                " WHEN 2 THEN\n" +
                " '女' ELSE p.sex \n" +
                " END AS sex,\n" +
                " TIMESTAMPDIFF(YEAR,p.birthday,now()) AS age \n" +
                " FROM \n" +
                " base_emergency_assistance_order ord\n" +
                " INNER JOIN base_patient p ON ord.patient = p.id \n" +
                " AND p.del = 1 \n" +
                " WHERE " +
                " ord.STATUS = 1 "+filter;
        String sql2 = " SELECT \n" +
                " '22' AS 'OrderType',\n" +
                " p.archive_type archiveType,\n" +
                " p.residential_area residentialArea,\n" +
                " ord.id,\n" +
                " ord.patient,\n" +
                " p.name,\n" +
                " ord.serve_desc,\n" +
                " DATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) createTime,\n" +
                " ord.`status`,\n" +
                " CASE \n" +
                "  p.sex \n" +
                "  WHEN 1 THEN\n" +
                "  '男' \n" +
                "  WHEN 2 THEN\n" +
                " '女' ELSE p.sex \n" +
                " END AS sex,\n" +
                " TIMESTAMPDIFF(YEAR,p.birthday,now()) AS age \n" +
                " FROM\n" +
                " base_security_monitoring_order ord \n" +
                " INNER JOIN base_patient p ON ord.patient = p.id \n" +
                " where ord.status = 1"+filter;
        String sql = "select * FROM (" +
                " "+sql1+" UNION "+sql2 +
                " ) t order by t.createTime desc limit "+page*pageSize+","+pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,this.getWarningCountByEmergencyAndSecurity(filter));
    }
    /**
     * 获取体征预警中的列表
     * @param page
     * @param pageSize
     * @param patient
     * @return
     */
    public PageEnvelop getHealthWarningList(Integer page,Integer pageSize,String patient){
        page = page>0?page-1:0;
        String filter=" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            orgCodes = orgCodes.replaceAll(",","','");
            filter = " and idx.user not in ('"+orgCodes+"') ";
        }
        String sql = " SELECT\n" +
                " idx.id,\n" +
                " idx.user,\n" +
                " idx.`name`,idx.type,\n" +
                " p.archive_type archiveType,\n" +
                " p.residential_area residentialArea,\n" +
                " '健康监测' AS serve_desc,\n" +
                " TIMESTAMPDIFF(YEAR,p.birthday,now()) AS age, \n" +
                " idx.czrq,\n" +
                " value1,\n" +
                " value2,\n" +
                " value3,\n" +
                " value4,\n" +
                " value5,\n" +
                " value6,\n" +
                " value7,\n" +
                " type,DATE_FORMAT( idx.czrq, '%Y-%m-%d %H:%i:%S' ) createTime, \n" +
                " CASE\n" +
                " p.sex \n" +
                " WHEN 1 THEN\n" +
                " '男' \n" +
                " WHEN 2 THEN\n" +
                " '女' ELSE p.sex \n" +
                " END AS sex\n" +
                " FROM\n" +
                " wlyy_patient_health_index idx\n" +
                " INNER JOIN base_patient p ON idx.USER = p.id AND p.del = 1 \n" +
                " WHERE\n" +
                " idx.del = 1 \n" +
                " and idx.status=1 \n" +
                " AND idx.type < 3 "+filter+" ORDER By idx.czrq DESC limit "+page*pageSize+","+pageSize;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        if(!ObjectUtils.isEmpty(list)){
            //查体征预警信息,偏高偏低
            for (Map<String, Object> map : list) {
                com.alibaba.fastjson.JSONArray info = healthIndexUtil.verifyHealthIndex(
                        Integer.parseInt(map.get("type").toString()),
                        null==map.get("value1")?"":map.get("value1").toString(),
                        null==map.get("value2")?"":map.get("value2").toString(),
                        null==map.get("value3")?"":map.get("value3").toString());
                //去除正常的值
                Iterator it = info.iterator();
                while (it.hasNext()){
                    JSONObject next = (JSONObject)it.next();
                    if("0".equals(next.getString("error"))){
                        it.remove();
                    }
                }
                map.put("info",info);
            }
        }
        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,this.getWarningCountByHealth(filter));
    }
    /**
     * 获取紧急呼救和安防工单正在预警中的总数
     * @param filter
     * @return
     */
    Long getWarningCountByEmergencyAndSecurity(String filter){
        //紧急呼救
        String emergencySql = "SELECT count( ord.id ) warningCount \n" +
                " FROM " +
                " base_emergency_assistance_order ord " +
                " INNER JOIN base_patient p ON ord.patient = p.id and p.del=1  \n" +
                " WHERE\n" +
                "  ord.STATUS = 1"+filter;
        //安防监护
        String securitySql = "SELECT count( ord.id ) warningCount \n" +
                " FROM\n" +
                " base_security_monitoring_order ord\n" +
                " INNER JOIN base_patient p ON ord.patient = p.id and p.del=1 \n" +
                " AND ord.STATUS = 1"+filter;
        String sqlCount = "SELECT\n" +
                " sum( warningCount ) warningCount\n" +
                " FROM\n" +
                " ( " + emergencySql + " UNION ALL " + securitySql +
                " ) t";
        return jdbcTemplate.queryForObject(sqlCount, Long.class);
    }
    /**
     * 获取一般体征预警中的总数
     * @param filter
     * @return
     */
    Long getWarningCountByHealth(String filter){
        String healthSql = "SELECT\n" +
                " count( idx.id ) \n" +
                " FROM\n" +
                " wlyy_patient_health_index idx\n" +
                " INNER JOIN base_patient p ON idx.USER = p.id AND p.del = 1 \n" +
                " WHERE\n" +
                " idx.status = 1 \n" +
                " AND idx.del = 1 \n" +
                " AND idx.type < 3 \n" + filter;
        return jdbcTemplate.queryForObject(healthSql, Long.class);
    }
}

+ 68 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/visit/BaseVisitService.java

@ -1,13 +1,18 @@
package com.yihu.jw.care.service.visit;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.visit.BaseVisitDao;
import com.yihu.jw.care.dao.visit.BaseVisitSignDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.visit.BaseVisitDO;
import com.yihu.jw.entity.care.visit.BaseVisitSignDO;
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 org.apache.commons.lang.StringUtils;
@ -31,6 +36,8 @@ public class BaseVisitService {
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    @Autowired
    private BaseVisitSignDao baseVisitSignDao;
    /**
     * 获取走访列表-日历
@ -103,6 +110,9 @@ public class BaseVisitService {
        if("1".equals(visitDO.getStatus())){
            return "走访已完成不能删除";
        }
        if ("3".equals(visitDO.getStatus())){
            return "走访已签到不能删除";
        }
        baseVisitDao.delete(id);
        return null;
    }
@ -190,6 +200,9 @@ public class BaseVisitService {
    public Map<String, String> findVisitDetail(String id){
        Map<String, String> re = new HashMap<>();
        BaseVisitDO visitDO = baseVisitDao.findOne(id);
        if (null==visitDO){
            return null;
        }
        re.put("id", visitDO.getId());
        re.put("visitDate", DateUtil.dateToStrLong(visitDO.getVisitDate()));
        re.put("visitPlanDate", DateUtil.dateToStrLong(visitDO.getVisitPlanDate()));
@ -205,6 +218,13 @@ public class BaseVisitService {
        re.put("health",visitDO.getHealth());
        re.put("lifeConsult",visitDO.getLifeConsult());
        BaseVisitSignDO visitSignDO = baseVisitSignDao.findByVisitId(visitDO.getId());
        if (null!=visitSignDO){
            re.put("signInfo", JSON.toJSONStringWithDateFormat(visitSignDO,"yyyy-MM-dd HH:mm:ss"));
        }else {
            re.put("signInfo",null);
        }
        BasePatientDO patient = patientDao.findById(visitDO.getPatient());
        if (patient != null) {
            re.put("idcard", patient.getIdcard());
@ -215,7 +235,6 @@ public class BaseVisitService {
            re.put("photo", patient.getPhoto());
            re.put("age", IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(),patient.getBirthday())+"");
        }
        return re;
    }
@ -256,4 +275,52 @@ public class BaseVisitService {
        }
    }
    /**
     * 日常走访签到
     * @return
     */
    public JSONObject signIn(String visitId,Integer signWay,String signLat,String signLon,String address,String signImg,String doctorId){
        BaseVisitDO visitDO = baseVisitDao.findOne(visitId);
        BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
        JSONObject result = new JSONObject();
        if (null==doctorDO){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"当前登录用户不存在无法签到");
            return result;
        }
        if (null==visitDO){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"未找到走访计划");
            return result;
        }
        if ("3".equals(visitDO.getStatus())){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"已完成签到,无法重复签到");
            return result;
        }
        BaseVisitSignDO signDO = new BaseVisitSignDO();
        signDO.setVisitId(visitId);
        signDO.setDoctor(doctorId);
        signDO.setDoctorName(doctorDO.getName());
        signDO.setDel(1);
        signDO.setType(signWay);
        if (2==signWay){//拍照
            signDO.setImg(signImg);
        } else if (1==signWay) {//定位
            signDO.setAddress(address);
            signDO.setLat(signLat);
            signDO.setLon(signLon);
        }else {
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"签到方式错误");
            return result;
        }
        baseVisitSignDao.save(signDO);
        visitDO.setStatus("3");
        baseVisitDao.save(visitDO);
        result.put(ResponseContant.resultFlag,ResponseContant.success);
        result.put(ResponseContant.resultMsg,"success");
        return result;
    }
}

+ 217 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/HlsDownloader.java

@ -0,0 +1,217 @@
package com.yihu.jw.care.util;

import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

// https://my.oschina.net/haitaohu/blog/1941179
public class HlsDownloader {

    private String uuid;
    private String originUrlpath;
    private String preUrlPath;
    private String rootPath;
    private String fileName;
    private String folderPath;
    private int threadQuantity = 10;

    public int getThreadQuantity() {
        return threadQuantity;
    }

    public void setThreadQuantity(int threadQuantity) {
        this.threadQuantity = threadQuantity;
    }


    public HlsDownloader(String originUrlpath, String preUrlPath, String rootPath){
        this.uuid = UUID.randomUUID().toString().replaceAll("-","");
        this.originUrlpath = originUrlpath;
        this.preUrlPath = preUrlPath;
        this.rootPath = rootPath;

        this.fileName = uuid+ ".mp4";

        this.folderPath = rootPath + File.separator + uuid;
        File file = new File(folderPath);
        if(!file.exists()) file.mkdirs();
    }

    public String download(boolean isAsync) throws Exception {

        String indexStr = getIndexFile();

        List urlList = analysisIndex(indexStr);

        HashMap<Integer,String> keyFileMap = new HashMap<>();

        if(isAsync){
            downLoadIndexFileAsync(urlList, keyFileMap);

            while (keyFileMap.size()<urlList.size()){
                //System.out.println("当前下载数量"+keyFileMap.size());
                Thread.sleep(3000);
            }
        }else{
            keyFileMap = downLoadIndexFile(urlList);
        }

        return composeFile(keyFileMap);
    }

    /* 下载索引文件 */
    public String getIndexFile() throws Exception{
        URL url = new URL(originUrlpath);

        /*File file = new File("E:\\JKZL\\1.m3u8");
        url = file.toURL();*/
        //下载资源
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(),"UTF-8"));

        String content = "" ;
        String line;
        while ((line = in.readLine()) != null) {
            content += line + "\n";
        }
        in.close();

        return content;
    }

    /* 解析索引文件 */
    public List analysisIndex(String content) throws Exception{
        Pattern pattern = Pattern.compile(".*ts");
        Matcher ma = pattern.matcher(content);

        List<String> list = new ArrayList<String>();

        while(ma.find()){
            list.add(ma.group());
        }

        return list;
    }

    /* 下载视频片段 */
    public HashMap downLoadIndexFile(List<String> urlList){
        HashMap<Integer,String> keyFileMap = new HashMap<>();

        for(int i =0;i<urlList.size();i++){
            String subUrlPath = urlList.get(i);
            String fileOutPath = folderPath + File.separator + i + ".ts";
            keyFileMap.put(i, fileOutPath);
            try{
                downloadNet(preUrlPath + subUrlPath, fileOutPath);

                System.out.println("成功:"+ (i + 1) +"/" + urlList.size());
            }catch (Exception e){
                System.err.println("失败:"+ (i + 1) +"/" + urlList.size());
            }
        }

        return  keyFileMap;
    }

    public void downLoadIndexFileAsync(List<String> urlList, HashMap<Integer,String> keyFileMap) throws Exception{
        int downloadForEveryThread = (urlList.size() + threadQuantity - 1)/threadQuantity;
        if(downloadForEveryThread == 0) downloadForEveryThread = urlList.size();

        for(int i=0; i<urlList.size();i+=downloadForEveryThread){
            int startIndex = i;
            int endIndex = i + downloadForEveryThread - 1;
            if(endIndex >= urlList.size())
                endIndex = urlList.size() - 1;

            new DownloadThread(urlList, startIndex, endIndex, keyFileMap).start();
        }
    }
    /**
     * 视频片段合成
     */
    public String composeFile(HashMap<Integer,String> keyFileMap) throws Exception{

        if(keyFileMap.isEmpty()) return null;

        String fileOutPath = rootPath + File.separator + fileName;
        FileOutputStream fileOutputStream = new FileOutputStream(new File(fileOutPath));
        byte[] bytes = new byte[1024];
        int length = 0;
        for(int i=0; i<keyFileMap.size(); i++){
            String nodePath = keyFileMap.get(i);
            File file = new File(nodePath);
            if(!file.exists())  continue;

            FileInputStream fis = new FileInputStream(file);
            while ((length = fis.read(bytes)) != -1) {
                fileOutputStream.write(bytes, 0, length);
            }
        }

        return fileName;
    }


    class DownloadThread extends Thread{
        private List<String> urlList;
        private int startIndex;
        private int endIndex;
        private HashMap<Integer,String> keyFileMap;

        public DownloadThread(List<String> urlList, int startIndex, int endIndex, HashMap<Integer,String> keyFileMap){
            this.urlList = urlList;
            this.startIndex = startIndex;
            this.endIndex = endIndex;
            this.keyFileMap = keyFileMap;
        }
        @Override
        public void run(){
            for(int i=startIndex;i<=endIndex;i++){
                String subUrlPath = urlList.get(i);
                String fileOutPath = folderPath + File.separator + i + ".ts";
                keyFileMap.put(i, fileOutPath);
                String message = "%s: 线程 " + (startIndex/(endIndex - startIndex) + 1)
                        + ", "+ (i + 1) +"/" + urlList.size() +", 合计: %d";
                try{
                    downloadNet(preUrlPath + subUrlPath, fileOutPath);

                    System.out.println(String.format(message, "成功", keyFileMap.size()));
                }catch (Exception e){
                    System.err.println(String.format(message, "失败", keyFileMap.size()));
                }
            }
        }
    }

    private void downloadNet(String fullUrlPath, String fileOutPath) throws Exception {
        // 下载网络文件
//        DataInputStream dataInputStream = new DataInputStream(url.openStream());
//        FileOutputStream fileOutputStream = new FileOutputStream(new File(fileOutPath));
//        byte[] bytes = new byte[1024];
//        int length = 0;
//        while ((length = dataInputStream.read(bytes)) != -1) {
//            fileOutputStream.write(bytes, 0, length);
//        }
//        dataInputStream.close();

        //int bytesum = 0;
        int byteread = 0;

        URL url = new URL(fullUrlPath);
        URLConnection conn = url.openConnection();
        InputStream inStream = conn.getInputStream();
        FileOutputStream fs = new FileOutputStream(fileOutPath);

        byte[] buffer = new byte[1204];
        while ((byteread = inStream.read(buffer)) != -1) {
            //bytesum += byteread;
            fs.write(buffer, 0, byteread);
        }
    }

}