Переглянути джерело

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

wangzhinan 3 роки тому
батько
коміт
fcb13ffc9b
33 змінених файлів з 1038 додано та 101 видалено
  1. 2 0
      business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java
  2. 5 1
      common/common-entity/sql记录
  3. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java
  4. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/device/PatientSafeAreaDO.java
  5. 117 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/visit/BaseVisitDO.java
  6. 1 1
      server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java
  7. 6 0
      svr/svr-cloud-care/pom.xml
  8. 18 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/visit/BaseVisitDao.java
  9. 38 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/family/FamilyMemberEndpoint.java
  10. 3 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/label/PatientLabelEndpoint.java
  11. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/security/SecurityMonitoringOrderEndpoint.java
  12. 134 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/visit/VisitEndpoint.java
  13. 99 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/family/PatientFamilyMemberService.java
  14. 15 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/label/PatientLableService.java
  15. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java
  16. 6 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  17. 97 10
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  18. 8 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  19. 212 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/visit/BaseVisitService.java
  20. 78 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/GetuiUtil.java
  21. 10 2
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/endpoint/DeviceController.java
  22. 8 29
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  23. 6 4
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceUploadService.java
  24. 2 36
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/HvDeviceService.java
  25. 1 1
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/OnenetService.java
  26. 1 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java
  27. 51 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceDataPushLogUtil.java
  28. 9 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java
  29. 10 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java
  30. 39 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/visit/OverTimeVistJob.java
  31. 15 12
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  32. 10 1
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java
  33. 3 0
      svr/svr-cloud-job/src/main/resources/system.properties

+ 2 - 0
business/base-service/src/main/java/com/yihu/jw/patient/dao/BasePatientDao.java

@ -50,4 +50,6 @@ public interface BasePatientDao extends PagingAndSortingRepository<BasePatientDO
//    int updateOpenId(String id, String openId);
    BasePatientDO findByIdAndDel(String id,String del);
    List<BasePatientDO> findByNameAndIdcard(String name,String idcard);
}

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

@ -1584,4 +1584,8 @@ CREATE TABLE `dm_ys_config` (
  `iot_access_token_key` varchar(25) DEFAULT NULL COMMENT 'iot token Key',
  `secret_key` varchar(25) DEFAULT NULL COMMENT '设备的解密秘钥 key',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4;
) ENGINE=InnoDB AUTO_INCREMENT=46 DEFAULT CHARSET=utf8mb4;
-- 2021-11-11
alter table base_patient  add column `home_lat_lon` varchar(100) DEFAULT NULL COMMENT '居民家庭经纬度';
ALTER table wlyy_patient_safe_area add column manage_status TINYINT(2) default '0' COMMENT '电子围栏确认情况 0待确认 1已确认';

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/patient/BasePatientDO.java

@ -292,6 +292,8 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    private String medicalState;//医保授权状态
    private String homeLatLon;//家庭经纬度
    @Column(name = "medical_state")
    public String getMedicalState() {
@ -906,4 +908,13 @@ public class BasePatientDO extends UuidIdentityEntityWithOperator {
    public void setDeviceFlag(Integer deviceFlag) {
        this.deviceFlag = deviceFlag;
    }
    @Column(name="home_lat_lon")
    public String getHomeLatLon() {
        return homeLatLon;
    }
    public void setHomeLatLon(String homeLatLon) {
        this.homeLatLon = homeLatLon;
    }
}

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/device/PatientSafeAreaDO.java

@ -21,6 +21,8 @@ public class PatientSafeAreaDO extends IdEntity {
    private Date createTime;
    private Date updateTime;
    private Integer manageStatus;//电子围栏确认情况 0待确认 1已确认
    public String getPatient() {
        return patient;
    }
@ -63,4 +65,12 @@ public class PatientSafeAreaDO extends IdEntity {
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getManageStatus() {
        return manageStatus;
    }
    public void setManageStatus(Integer manageStatus) {
        this.manageStatus = manageStatus;
    }
}

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

@ -0,0 +1,117 @@
package com.yihu.jw.entity.care.visit;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.util.Date;
/**
 * Created by yeshijie on 2021/11/11.
 */
@Entity
@Table(name = "base_visit")
public class BaseVisitDO extends UuidIdentityEntityWithCreateTime {
    private String patient;
    private String patientName;
    private String type;//类型 1老人日常走访
    private String status;//状态 0计划中 1 已完成 2计划超时
    private Date visitDate;//完成走访时间
    private Date visitPlanDate;//计划走访时间
    private String doctor;
    private String doctorName;
    private String visitContent;//走访记录
    private String visitImg;//走访图片
    @Column(name = "patient")
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "patient_name")
    public String getPatientName() {
        return patientName;
    }
    public void setPatientName(String patientName) {
        this.patientName = patientName;
    }
    @Column(name = "type")
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "status")
    public String getStatus() {
        return status;
    }
    public void setStatus(String status) {
        this.status = status;
    }
    @Column(name = "visit_date")
    public Date getVisitDate() {
        return visitDate;
    }
    public void setVisitDate(Date visitDate) {
        this.visitDate = visitDate;
    }
    @Column(name = "visit_plan_date")
    public Date getVisitPlanDate() {
        return visitPlanDate;
    }
    public void setVisitPlanDate(Date visitPlanDate) {
        this.visitPlanDate = visitPlanDate;
    }
    @Column(name = "doctor")
    public String getDoctor() {
        return doctor;
    }
    public void setDoctor(String doctor) {
        this.doctor = doctor;
    }
    @Column(name = "doctor_name")
    public String getDoctorName() {
        return doctorName;
    }
    public void setDoctorName(String doctorName) {
        this.doctorName = doctorName;
    }
    @Column(name = "visit_content")
    public String getVisitContent() {
        return visitContent;
    }
    public void setVisitContent(String visitContent) {
        this.visitContent = visitContent;
    }
    @Column(name = "visit_img")
    public String getVisitImg() {
        return visitImg;
    }
    public void setVisitImg(String visitImg) {
        this.visitImg = visitImg;
    }
}

+ 1 - 1
server/svr-authentication/src/main/java/com/yihu/jw/security/core/userdetails/jdbc/WlyyUserDetailsService.java

@ -657,7 +657,7 @@ public class WlyyUserDetailsService extends JdbcDaoSupport implements UserDetail
        if(StringUtils.isNotBlank(padImei)){
            try {
                if(isPateint == 1){
                    this.getJdbcTemplate().update("update base_patient p set p.pad_imei = ? where p.id = ? or p.idcard = ?", padImei, id);
                    this.getJdbcTemplate().update("update base_patient p set p.pad_imei = ? where p.id = ? or p.idcard = ?", padImei, id,id);
                }
            }catch (Exception e){
                e.printStackTrace();

+ 6 - 0
svr/svr-cloud-care/pom.xml

@ -242,6 +242,12 @@
            <artifactId>json-lib</artifactId>
            <version>2.4</version>
        </dependency>
        <!-- 个推v2sdk -->
        <dependency>
            <groupId>com.getui.push</groupId>
            <artifactId>restful-sdk</artifactId>
            <version>1.0.0.1</version>
        </dependency>
        <dependency>
            <groupId>com.yihu.jw</groupId>

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

@ -0,0 +1,18 @@
package com.yihu.jw.care.dao.visit;
import com.yihu.jw.entity.care.visit.BaseVisitDO;
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;
/**
 * Created by yeshijie on 2021/11/11.
 */
public interface BaseVisitDao  extends PagingAndSortingRepository<BaseVisitDO, String>, JpaSpecificationExecutor<BaseVisitDO> {
    @Query("select a from BaseVisitDO a where a.doctor = ?1 and a.visitPlanDate between ?2 and ?3 ")
    List<BaseVisitDO> findByDoctor(String doctor, Date begin, Date end) throws Exception;
}

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

@ -8,6 +8,7 @@ import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.Envelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
@ -88,6 +89,43 @@ public class FamilyMemberEndpoint extends EnvelopRestEndpoint {
        }
    }
    @RequestMapping(value = "/addOlderByRelatives", method = RequestMethod.POST)
    @ApiOperation(value = "家属添加监护老人")
    @ObserverRequired
    public Envelop addOlderByRelatives(
            @ApiParam(name = "relatives",value = "家属code")
            @RequestParam("relatives") String relatives,
            @ApiParam(name = "name",value = "老人姓名")
            @RequestParam("name") String name,
            @ApiParam(name = "idcard",value = "老人身份证")
            @RequestParam("idcard") String idcard,
            @RequestParam(value = "relation",defaultValue = "0") Integer relation,
            /**********注册流程绑定监护老人时传  补充当前家属信息************/
            @ApiParam(name = "relativesName",value = "家属本人姓名")
            @RequestParam(value = "relativesName",required = false) String relativesName,
            @ApiParam(name = "relativesIdcard",value = "家属本人身份证")
            @RequestParam(value = "relativesIdcard",required = false) String relativesIdcard,
            @ApiParam(name = "relativesSex",value = "家属本人性别")
            @RequestParam(value = "relativesSex",required = false) String relativesSex
            /**********************/) {
        try {
            if (StringUtils.isEmpty(relatives)) {
                return failed("当前用户信息错误",-1);
            }
            JSONObject result = familyMemberService.addOlderByRelatives(relatives,name,idcard,relation,relativesName,relativesIdcard,relativesSex);
            if (result.getInteger(ResponseContant.resultFlag)==ResponseContant.success){
                return success("添加成功");
            }else {
                return success(result.getString(ResponseContant.resultMsg));
            }
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    /**
     * 更新家庭关系
     *

+ 3 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/label/PatientLabelEndpoint.java

@ -49,12 +49,14 @@ public class PatientLabelEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "labelCode",required = true) String labelCode,
            @ApiParam(name = "name", value = "姓名或身份证", required = false)
            @RequestParam(value = "name",required = false) String name,
            @ApiParam(name = "topicItem", value = "专题code,关联security_topic_dict字典", required = false)//有绑定相关专题设备
            @RequestParam(value = "topicItem",required = false) String topicItem,
            @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) throws Exception {
        try{
            return patientLableService.findSignPatientLabelListByTeamCode(teamCode, labelCode, name, page, size);
            return patientLableService.findSignPatientLabelListByTeamCode(teamCode, labelCode, name,topicItem, page, size);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }

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

@ -333,6 +333,18 @@ public class SecurityMonitoringOrderEndpoint extends EnvelopRestEndpoint {
        }
    }
    @ApiOperation("老人家属首页实时监护信息")
    @RequestMapping(value = "patientMonitoringInfo2", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody
    public ObjEnvelop patientMonitoringInfo2(@ApiParam(name = "patient", value = "patient")
                                            @RequestParam(value = "patient") String patient) {
        try {
            return ObjEnvelop.getSuccess( "查询成功", securityMonitoringOrderService.patientMonitoringInfo2(patient));
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @ApiOperation("获取居民签约专题信息")
    @RequestMapping(value = "patientSignTopicInfo", method = {RequestMethod.POST, RequestMethod.GET})
    @ResponseBody

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

@ -0,0 +1,134 @@
package com.yihu.jw.care.endpoint.visit;
import com.yihu.jw.care.aop.ObserverRequired;
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.web.Envelop;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.restmodel.web.ObjEnvelop;
import com.yihu.jw.restmodel.web.endpoint.EnvelopRestEndpoint;
import com.yihu.jw.rm.hospital.BaseHospitalRequestMapping;
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.*;
import java.util.List;
import java.util.Map;
/**
 * 日常走访
 * Created by yeshijie on 2021/11/11.
 */
@RestController
@RequestMapping(value = "visit", produces = "application/json;charset=UTF-8")
@Api(value = "日常走访", description = "日常走访", tags = {"日常走访"})
public class VisitEndpoint extends EnvelopRestEndpoint {
    @Autowired
    private BaseVisitService baseVisitService;
    @ApiOperation("获取日常走访列表")
    @RequestMapping(value = "/getListByDoctor", method = RequestMethod.GET)
    public ListEnvelop getListByDoctor(@ApiParam(name = "startTime", value = "开始时间", defaultValue = "2021-11-11 00:00:00")
                                        @RequestParam(value = "startTime", required = true) String startTime,
                                       @ApiParam(name = "endTime", value = "结束时间", defaultValue = "2021-11-30 00:00:00")
                                        @RequestParam(value = "endTime", required = true) String endTime,
                                       @ApiParam(name = "doctor", value = "医生id")
                                        @RequestParam(value = "doctor", required = true) String doctor) {
        try {
            List<Map<String, Object>> result = baseVisitService.getListByDoctor(doctor, startTime, endTime);
            return ListEnvelop.getSuccess("创建成功",result);
        } catch (Exception e) {
            return failedListEnvelopException2(e);
        }
    }
    @ApiOperation("获取日常走访详情")
    @RequestMapping(value = "findVisitDetail", method = RequestMethod.GET)
    public ObjEnvelop findVisitDetail(@ApiParam(name = "id", value = "id")
                                       @RequestParam(value = "id", required = true) String id) {
        try {
            Map<String, String> result = baseVisitService.findVisitDetail(id);
            return ObjEnvelop.getSuccess("创建成功",result);
        } catch (Exception e) {
            return failedObjEnvelopException2(e);
        }
    }
    @ApiOperation("新增走访计划(批量)")
    @RequestMapping(value = "/addVisitPlan",method = RequestMethod.POST)
    @ObserverRequired
    public Envelop addVistiPlan(@ApiParam(name = "patient", value = "患者代码", defaultValue = "443a196ef8744536a531260eb26c05d7")
                                  @RequestParam(value = "patient", required = true) String patient,
                                @ApiParam(name = "data", value = "走访计划列表json", defaultValue = "[{\"date\":\"2021-11-16 20:00:00\"},{\"date\":\"2021-11-17 15:00:00\"}]")
                                  @RequestParam(value = "data", required = true) String data,
                                @ApiParam(name = "doctor", value = "医生id")
                                  @RequestParam(value = "doctor", required = true) String doctor) {
        try {
            baseVisitService.addVistiPlan(doctor, patient, data);
            return Envelop.getSuccess("创建成功");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    @ApiOperation("删除走访计划")
    @RequestMapping(value = "/delVisti",method = RequestMethod.POST)
    @ObserverRequired
    public Envelop delVisti(@ApiParam(name = "id", value = "走访id")
                                @RequestParam(value = "id", required = true) String id) {
        try {
            String result = baseVisitService.delVisti(id);
            if(StringUtils.isNotBlank(result)){
                return Envelop.getError("删除失败:"+result,-1);
            }
            return Envelop.getSuccess("删除成功");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    @ApiOperation("修改走访计划时间")
    @RequestMapping(value = "/updVisit",method = RequestMethod.POST)
    @ObserverRequired
    public Envelop updVisit(@ApiParam(name = "id", value = "走访id")
                            @RequestParam(value = "id", required = true) String id,
                            @ApiParam(name = "visitPlanDate", value = "走访计划时间")
                            @RequestParam(value = "visitPlanDate", required = true) String visitPlanDate) {
        try {
            String result = baseVisitService.updVisit(id,visitPlanDate);
            if(StringUtils.isNotBlank(result)){
                return Envelop.getError("修改失败:"+result,-1);
            }
            return Envelop.getSuccess("修改成功");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
    @ApiOperation("完成走访计划时间")
    @RequestMapping(value = "/completeVisit",method = RequestMethod.POST)
    @ObserverRequired
    public Envelop completeVisit(@ApiParam(name = "id", value = "走访id")
                            @RequestParam(value = "id", required = true) String id,
                            @ApiParam(name = "visitContent", value = "走访记录")
                            @RequestParam(value = "visitContent", required = true) String visitContent,
                            @ApiParam(name = "visitImg", value = "走访图片")
                            @RequestParam(value = "visitImg", required = true) String visitImg) {
        try {
            String result = baseVisitService.completeVisit(id,visitContent,visitImg);
            if(StringUtils.isNotBlank(result)){
                return Envelop.getError("操作失败:"+result,-1);
            }
            return Envelop.getSuccess("操作成功");
        } catch (Exception e) {
            return failedException2(e);
        }
    }
}

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

@ -10,6 +10,7 @@ import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.im.util.ImUtil;
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.security.MD5;
import com.yihu.jw.util.wechat.wxhttp.HttpUtil;
@ -220,6 +221,104 @@ public class PatientFamilyMemberService extends BaseJpaService<BasePatientFamily
        return 1;
    }
    public JSONObject addOlderByRelatives(String relatives,String name,String idcard,Integer relation,String relativesName,String relativesIdcard,String relativesSex) throws Exception {
        JSONObject result = new JSONObject();
        BasePatientDO patientDO = patientDao.findById(relatives);
        boolean register=false;
        if (StringUtils.isNotBlank(relativesName)){
            patientDO.setName(relativesName);
            register=true;
        }
        if (StringUtils.isNotBlank(relativesIdcard)){
            BasePatientDO tmp = patientDao.findByIdcard(relativesIdcard);
            if (null != tmp){
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"身份证已存在!");
                return result;
            }
            patientDO.setIdcard(relativesIdcard);
            register=true;
        }
        if (StringUtils.isNotBlank(relativesSex)){
            patientDO.setSex(Integer.parseInt(relativesSex));
            register=true;
        }
        if (register){
            patientDO.setArchiveType(3);
            patientDO.setArchiveStatus(3);
            patientDO = patientDao.save(patientDO);
        }
        if (null == patientDO){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"当前用户信息不存在");
            return result;
        }
        List<BasePatientDO> addPatients = patientDao.findByNameAndIdcard(name,idcard);
        if (addPatients.size()==0){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"添加成员不存在");
            return result;
        }
        BasePatientDO addPatient = addPatients.get(0);
        // 添加自己与对方的关系
        BasePatientFamilyMemberDO fm = memberDao.findByPatientAndFamilyMember(patientDO.getId(), addPatient.getId());
        // 家庭关系已存在时,不重复添加
        if (fm != null) {
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"家庭关系已存在时,不重复添加");
            return result;
        } else {
            fm = new BasePatientFamilyMemberDO();
            fm.setPatient(patientDO.getId());
            fm.setFamilyMember(addPatient.getId());
        }
        fm.setFamilyRelation(relation);
        fm.setIsAuthorize(0);//默认授权
        // 添加对方与自己的关系
        BasePatientFamilyMemberDO fmt = memberDao.findByPatientAndFamilyMember(addPatient.getId(), patientDO.getId());
        // 不存在则创建
        if (fmt == null) {
            fmt = new BasePatientFamilyMemberDO();
            fmt.setPatient(addPatient.getId());
            fmt.setFamilyMember(patientDO.getId());
        }
        // 对方与自己的关系转换
        int relationTrans = familyRelationTrans(patientDO, relation);
        if (relationTrans==-1){
            result.put(ResponseContant.resultFlag,ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"您或添加用户性别信息未填写无法添加成员");
            return result;
        }
        fmt.setFamilyRelation(relationTrans);
        fmt.setIsAuthorize(1);//默认授权
        memberDao.save(fm);
        memberDao.save(fmt);
        //设置家人openid 加入undefined 判断
        if (StringUtils.isBlank(addPatient.getOpenid()) && StringUtils.isNotBlank(patientDO.getOpenid()) && !"undefined".equals(patientDO.getOpenid())) {
            addPatient.setOpenid(patientDO.getOpenid());
            if (addPatient.getOpenidTime() == null) {
                addPatient.setOpenidTime(new Date());
            }
            patientDao.save(addPatient);
        } else if (StringUtils.isBlank(patientDO.getOpenid()) && StringUtils.isNotBlank(addPatient.getOpenid()) && !"undefined".equals(addPatient.getOpenid())) {
            patientDO.setOpenid(addPatient.getOpenid());
            if (patientDO.getOpenidTime() == null) {
                patientDO.setOpenidTime(new Date());
            }
            patientDao.save(patientDO);
        }
        result.put(ResponseContant.resultFlag,ResponseContant.success);
        result.put(ResponseContant.resultMsg,"添加成功");
        return result;
    }
    /**
     * 修改家庭成员关系
     * @param patient  居民

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

@ -3,6 +3,7 @@ package com.yihu.jw.care.service.label;
import com.yihu.jw.care.dao.label.WlyyPatientLabelDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.care.service.sign.ServicePackageService;
import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.entity.care.label.WlyyPatientLabelDO;
import com.yihu.jw.restmodel.web.PageEnvelop;
@ -27,6 +28,8 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
    private DictService dictService;
    @Autowired
    private DeviceService deviceService;
    @Autowired
    private ServicePackageService servicePackageService;
    /**
     * 按团队查找签约居民的标签统计
@ -59,9 +62,9 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
     * @param teamCode
     * @return
     */
    public PageEnvelop<List<Map<String,Object>>> findSignPatientLabelListByTeamCode(String teamCode, String labelCode, String name, int page, int size){
    public PageEnvelop<List<Map<String,Object>>> findSignPatientLabelListByTeamCode(String teamCode, String labelCode, String name,String topicItem, int page, int size){
        String sql = "SELECT DISTINCT p.id,p.name,p.photo,p.idcard,p.mobile,p.openid,p.sex,p.pad_imei padImei " ;
        sql +=",(select COUNT(*) from wlyy_patient_device a where a.`user` = p.id) deviceFlag ";
        sql +=",(select COUNT(*) from wlyy_patient_device a where a.`user` = p.id and a.del=0) deviceFlag ";
        String countSql = "SELECT count(DISTINCT p.id) ";
        String filters = "from base_service_package_sign_record sr,base_service_package_record r,  " +
                "                base_patient p,wlyy_patient_label l " +
@ -71,6 +74,11 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
        if(StringUtils.isNotBlank(name)){
            filters += " and (p.name like '%"+name+"%' or p.idcard like '%"+name+"%') ";
        }
        if (StringUtils.isNotBlank(topicItem)){
            filters += " and EXISTS (select 1 from wlyy_patient_device pd INNER JOIN dm_device dd on pd.device_id = dd.id " +
                    "where  pd.user = sr.patient and  FIND_IN_SET(dd.service_topic,'"+topicItem+"')) ";
        }
        String orderBy = " ORDER BY sr.create_time DESC " +
                "LIMIT "+ (page - 1) * size + "," + size;
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql+filters+orderBy);
@ -78,6 +86,11 @@ public class PatientLableService extends BaseJpaService<WlyyPatientLabelDO, Wlyy
            String idcard = map.get("idcard").toString();
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            map.put("deviceType",deviceService.getPatientDeviceCategoryCode(map.get("id").toString()));
            //签约医生标识
            List<Map<String,Object>> doctorList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","1");
            List<Map<String,Object>> helperList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","2");
            map.put("helper", helperList.size()>0?1:0);
            map.put("doctor", doctorList.size()>0?1:0);
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/message/PatientMessageService.java

@ -92,7 +92,7 @@ public class PatientMessageService {
                "(select  count(1) as 'all',type,DATE_FORMAT(create_time,'%Y-%m-%d %H:%i:%S') create_time " +
                "from base_system_message where receiver in("+patient+") and del=1  GROUP BY type ORDER BY create_time desc)A " +
                "LEFT JOIN (select count(1) notRead,type " +
                "from base_system_message where receiver in("+patient+") and is_read=0 and del=1  GROUP BY type)B on A.type = B.type " +
                "from base_system_message where receiver in("+patient+") and (is_read=0 or is_read is null ) and del=1  GROUP BY type)B on A.type = B.type " +
                "ORDER BY A.create_time desc ";
        return jdbcTemplate.queryForList(sql);
    }

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

@ -232,12 +232,18 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
            signRecordDO.setHelperList(helperList);
            signRecordDO.setPackageList(packageList);
            res.put("signRecordDO",signRecordDO);
            res.put("doctor",doctorList.size()>0?1:0);
            res.put("helper",helperList.size()>0?1:0);
            if("1".equals(isCapacity)){
                //能力评估
                CapacityAssessmentRecordDO recordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
                res.put("capAssRecordDO",recordDO);
            }
        }else {
            res.put("doctor",0);
            res.put("helper",0);
        }
        //能力状况
        BaseCapacityLabelDO capacityLabelDO = capacityLabelDao.findByPatient(patientId);

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

@ -1458,10 +1458,81 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        return result;
    }
    /**
     *老人家属首页实时监护信息
     * 居家状态取手表 无手表缺省
     * 监控
     */
    public JSONObject patientMonitoringInfo2(String patient){
        JSONObject result = new JSONObject();
        result.put("atHome",null);// 居家状态
        result.put("location",null);
        result.put("fences",null);
        result.put("gasLeakage",null);
        result.put("fire",null);
        result.put("fall",null);
        result.put("sleep",null);
        result.put("deviceSn",null);
        result.put("emeAssistance",false);
        result.put("monitorInfo",null);
        String sql = " select dict.code,count(ord.id) total from base_system_dict_entry dict LEFT JOIN base_security_monitoring_order ord " +
                " on dict.code = ord.topic_item COLLATE utf8_unicode_ci and ord.status="+SecurityMonitoringOrderDO.Status.apply.getType()+" where dict.dict_code='service_item' " +
                "and dict.remark='security' and ord.patient='"+patient+"' GROUP BY dict.code ";
        List<Map<String,Object>> sqlResult = jdbcTemplate.queryForList(sql);
        for (Map<String,Object>tmp:sqlResult){
            switch (tmp.get("code").toString()){
                case "preventGasLeakage":
                    Integer count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("gasLeakage",true);
                    }else {
                        result.put("gasLeakage",false);
                    }
                    break;
                case "preventFire":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("fire",true);
                    }else {
                        result.put("fire",false);
                    }
                    break;
                case "preventFall":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("fall",true);
                    }else {
                        result.put("fall",false);
                    }
                    break;
                case "preventOutOfBed":
                    count = Integer.parseInt(tmp.get("total").toString());
                    if (count>0){
                        result.put("sleep",true);
                    }else {
                        result.put("sleep",false);
                    }
                    break;
            }
        }
        sql = " select count(id) from base_emergency_assistance_order  where patient='"+patient+"' and status="+ EmergencyAssistanceDO.Status.apply.getType();
        Integer counnt = jdbcTemplate.queryForObject(sql,Integer.class);
        if (counnt>0){
            result.put("emeAssistance",true);
        }
        List<DevicePatientDevice> devices4 = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表
        if (devices4.size()>0){
            result =  patientSignTopicInfo(result,patient,"preventLost",devices4.get(0).getDeviceSn());
        }
        patientSignTopicInfo(result,patient,"preventFall",null);
        return result;
    }
    public void preventLost(JSONObject result,String patient,String deviceSn){
        //手表与拐杖同时绑定时优先手表,围栏状态其中一个超出围栏即为超出围栏
        try {
            Integer categoryCode=0;
            Integer categoryCode=0;//未指定设备
            List<DevicePatientDevice> devicePatientDeviceDos = new ArrayList<>();
            List<DevicePatientDevice> devicePatientDeviceDos2 = new ArrayList<>();
            if (StringUtils.isNotBlank(deviceSn)){//查看指定设备详情
@ -1476,11 +1547,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                        devicePatientDeviceDos2 = devices;
                    }
                }
            }else {
                devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");
                devicePatientDeviceDos2 = patientDeviceDao.findByUserAndCategoryCode(patient,"16");
            }else {//未指定设备
                devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"4");//手表
                devicePatientDeviceDos2 = patientDeviceDao.findByUserAndCategoryCode(patient,"16");//拐杖
            }
            if (devicePatientDeviceDos.size()>0&&(4==categoryCode||0==categoryCode)){
            if (devicePatientDeviceDos.size()>0&&(4==categoryCode||0==categoryCode)){//手表
                DevicePatientDevice device = devicePatientDeviceDos.get(0);
                result.put("deviceSn",device.getDeviceSn());
                JSONObject response= patientDeviceService.getAqgDeviceInfo2(device.getDeviceSn());
@ -1495,6 +1566,22 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                        tmp.put("province",response.getString("last_province"));
                        tmp.put("address",response.getString("last_address"));
                        result.put("location",tmp);
                        BasePatientDO patientDO = basePatientDao.findById(patient);
                        if (null != patientDO){
                            if (StringUtils.isNotBlank(patientDO.getHomeLatLon())){
                                String homeLatLon = patientDO.getHomeLatLon();
                                double homeLat = Double.parseDouble( homeLatLon.split(",")[0]);
                                double homeLon = Double.parseDouble( homeLatLon.split(",")[1]);
                                double homeDistance =  countDistance.getDistance(result.getJSONObject("location").getDouble("lat"),result.getJSONObject("location").getDouble("lon"),
                                       homeLat,homeLon);
                                if (homeDistance>50*1000){
                                    result.put("atHome",false);
                                }else {
                                    result.put("atHome",true);
                                }
                            }
                        }
                    }
                    //围栏信息
                    if (response.containsKey("fences")&&response.get("fences")!=null){
@ -1525,7 +1612,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                    }
                }
            }
            if (devicePatientDeviceDos2.size()>0&&(16==categoryCode||0==categoryCode)) {
            if (devicePatientDeviceDos2.size()>0&&(16==categoryCode||0==categoryCode)) {//拐杖
                DevicePatientDevice deviceDO = devicePatientDeviceDos2.get(0);
                double dulat = 0l;
                double dulon = 0l;
@ -1571,11 +1658,11 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                            positionTmp.put("lon", areaLon);
                            fenceLocation.add(positionTmp);
                        }
                        if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode) {
                        if (devicePatientDeviceDos2.size() > 0 && 0 == categoryCode && devicePatientDeviceDos2.size()>0) {
                            JSONObject obj = result.getJSONArray("fences").getJSONObject(0);
                            if (!obj.getBooleanValue("inFenceStatus")) {
                            if (obj.getBooleanValue("inFenceStatus")) {
                                if (!countDistance.isInPolygon(dulon, dulat, fenceLocation)) {
                                    obj.put("inFenceStatus", false);
                                    obj.put("inFenceStatus", false);//超出围栏
                                    obj = result.getJSONObject("location");
                                    obj.put("address", address);
                                    obj.put("lon", dulon);
@ -1583,7 +1670,7 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
                                }
                            }
                        }
                        if (devicePatientDeviceDos2.size() > 0 && 16 == categoryCode) {
                        else if(devicePatientDeviceDos2.size() > 0) {//指定拐杖设备
                            if (StringUtils.isNotBlank(safeArea)) {
                                result.put("deviceSn", deviceDO.getDeviceSn());
                                JSONObject location = new JSONObject();

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

@ -3,6 +3,7 @@ package com.yihu.jw.care.service.sign;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.apply.PatientBedApplyDao;
import com.yihu.jw.care.dao.sign.ArchiveDao;
import com.yihu.jw.care.service.device.DeviceService;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
@ -47,6 +48,8 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
    private BaseDoctorHospitalDao baseDoctorHospitalDao;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private DeviceService deviceService;
    /**
@ -130,6 +133,11 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
            if("1".endsWith(sign_status)){
                map.put("servicePackageList",servicePackageService.getServicePackageListByPatient(patientId,null));
            }
            map.put("deviceType",deviceService.getPatientDeviceCategoryCode(map.get("id").toString()));
            List<Map<String,Object>> doctorList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","1");
            List<Map<String,Object>> helperList = servicePackageService.getServerDoctorAll(map.get("id").toString(),"0","2");
            map.put("helper", helperList.size()>0?1:0);
            map.put("doctor", doctorList.size()>0?1:0);
        }
        Long count = jdbcTemplate.queryForObject(countSql+sql+filters+" )tmp",Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);

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

@ -0,0 +1,212 @@
package com.yihu.jw.care.service.visit;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.visit.BaseVisitDao;
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.patient.dao.BasePatientDao;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.*;
/**
 * Created by yeshijie on 2021/11/11.
 */
@Service
public class BaseVisitService {
    @Autowired
    private BaseVisitDao baseVisitDao;
    @Autowired
    private ObjectMapper objectMapper;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private BaseDoctorDao doctorDao;
    /**
     * 获取走访列表-日历
     */
    public List<Map<String, Object>> getListByDoctor(String doctorCode, String startTime, String endTime) throws Exception {
        List<Map<String, Object>> re = new ArrayList<>();
        Map<String, Map<String, Object>> temp = new HashMap<>();
        List<BaseVisitDO> list = baseVisitDao.findByDoctor(doctorCode, DateUtil.strToDate(startTime), DateUtil.strToDate(endTime));
        if (list != null && list.size() > 0) {
            for (BaseVisitDO visitDO : list) {
                String date = DateUtil.dateToStrShort(visitDO.getVisitPlanDate());
                Map<String, String> map = getVisitDetail(visitDO);
                if (temp.containsKey(date)) {
                    Map<String, Object> vo = temp.get(date);
                    vo.put("num", Integer.parseInt(vo.get("num").toString()) + 1);
                    ((List<Map<String, String>>) vo.get("list")).add(map);
                    temp.put(date, vo);
                } else {
                    Map<String, Object> vo = new HashMap<>();
                    List<Map<String, String>> list1 = new ArrayList<>();
                    vo.put("date", date);
                    vo.put("num", 1);
                    list1.add(map);
                    vo.put("list", list1);
                    temp.put(date, vo);
                }
            }
            for (Map<String, Object> map : temp.values()) {
                re.add(map);
            }
        }
        return re;
    }
    /**
     * 转译走访信息
     */
    private Map<String, String> getVisitDetail(BaseVisitDO visitDO) {
        Map<String, String> re = new HashMap<>();
        re.put("id", visitDO.getId());
        re.put("visitDate", DateUtil.dateToStrLong(visitDO.getVisitDate()));
        re.put("visitPlanDate", DateUtil.dateToStrLong(visitDO.getVisitPlanDate()));
        re.put("type", visitDO.getType());
        re.put("status", visitDO.getStatus());
        re.put("doctor", visitDO.getDoctor());
        re.put("doctorName", visitDO.getDoctorName());
        re.put("patient", visitDO.getPatient());
        re.put("patientName", visitDO.getPatientName());
        return re;
    }
    /**
     * 删除
     * @param id
     * @return
     */
    public String delVisti(String id){
        BaseVisitDO visitDO = baseVisitDao.findOne(id);
        if(visitDO == null){
            return "走访已删除,请勿重复操作";
        }
        if("1".equals(visitDO.getStatus())){
            return "走访已完成不能删除";
        }
        return null;
    }
    /**
     * 修改走访计划时间
     * @param id
     * @return
     */
    public String updVisit(String id,String visitPlanDate){
        BaseVisitDO visitDO = baseVisitDao.findOne(id);
        if("1".equals(visitDO.getStatus())){
            return "走访已完成不能修改";
        }
        Date planDate = DateUtil.strToDate(visitPlanDate);
        if(DateUtil.compareDateTime(planDate,new Date())<0){
            return "计划走访日期不能早于当前日期";
        }
        visitDO.setVisitPlanDate(planDate);
        visitDO.setStatus("0");
        baseVisitDao.save(visitDO);
        return null;
    }
    /**
     * 完成走访
     * @param id
     * @return
     */
    public String completeVisit(String id,String visitContent,String visitImg){
        BaseVisitDO visitDO = baseVisitDao.findOne(id);
        if("1".equals(visitDO.getStatus())){
            return "走访已完成,请勿重复操作";
        }
        visitDO.setVisitDate(new Date());
        visitDO.setStatus("1");
        visitDO.setVisitContent(visitContent);
        visitDO.setVisitImg(visitImg);
        baseVisitDao.save(visitDO);
        return null;
    }
    /**
     * 获取走访详情
     * @param id
     * @return
     */
    public Map<String, String> findVisitDetail(String id){
        Map<String, String> re = new HashMap<>();
        BaseVisitDO visitDO = baseVisitDao.findOne(id);
        re.put("id", visitDO.getId());
        re.put("visitDate", DateUtil.dateToStrLong(visitDO.getVisitDate()));
        re.put("visitPlanDate", DateUtil.dateToStrLong(visitDO.getVisitPlanDate()));
        re.put("type", visitDO.getType());
        re.put("status", visitDO.getStatus());
        re.put("doctor", visitDO.getDoctor());
        re.put("doctorName", visitDO.getDoctorName());
        re.put("patient", visitDO.getPatient());
        re.put("patientName", visitDO.getPatientName());
        re.put("visitImg",visitDO.getVisitImg());
        re.put("visitContent",visitDO.getVisitContent());
        BasePatientDO patient = patientDao.findById(visitDO.getPatient());
        if (patient != null) {
            re.put("idcard", patient.getIdcard());
            String mobile = patient.getMobile();
            re.put("mobile", mobile);
            re.put("sex", String.valueOf(patient.getSex()));
            re.put("birthday", DateUtil.dateToStrLong(patient.getBirthday()));
            re.put("photo", patient.getPhoto());
            re.put("age", IdCardUtil.getAgeByIdcardOrBirthday(patient.getIdcard(),patient.getBirthday())+"");
        }
        return re;
    }
    /**
     * 新增随访计划(批量)
     */
    @Transactional
    public void addVistiPlan(String doctorCode, String patientCode, String data) throws Exception {
        //批量随访计划
        JavaType javaType = objectMapper.getTypeFactory().constructParametricType(List.class, Map.class);
        List<Map<String, String>> list = objectMapper.readValue(data, javaType);
        if (list != null && list.size() > 0) {
            //获取患者信息
            BasePatientDO patient = patientDao.findById(patientCode);
            if (patient == null) {
                throw new Exception("获取不到用户信息!");
            }
            BaseDoctorDO doctor = doctorDao.findById(doctorCode);
            if (doctor == null) {
                throw new Exception("获取不到医生信息!");
            }
            List<BaseVisitDO> visitPlans = new ArrayList<>();
            for (Map<String, String> map : list) {
                BaseVisitDO visitDO = new BaseVisitDO();
                visitDO.setType("1");
                visitDO.setStatus("0");
                Date date = DateUtil.strToDate(map.get("date"));
                visitDO.setVisitPlanDate(date);
                visitDO.setDoctor(doctorCode);
                visitDO.setDoctorName(doctor.getName());
                visitDO.setPatient(patientCode);
                visitDO.setPatientName(patient.getName());
                visitPlans.add(visitDO);
            }
            baseVisitDao.save(visitPlans);
        }
    }
}

+ 78 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/util/GetuiUtil.java

@ -0,0 +1,78 @@
package com.yihu.jw.care.util;
import com.alibaba.fastjson.JSONObject;
import com.getui.push.v2.sdk.ApiHelper;
import com.getui.push.v2.sdk.GtApiConfiguration;
import com.getui.push.v2.sdk.api.PushApi;
import com.getui.push.v2.sdk.common.ApiResult;
import com.getui.push.v2.sdk.dto.req.Audience;
import com.getui.push.v2.sdk.dto.req.Settings;
import com.getui.push.v2.sdk.dto.req.message.PushDTO;
import com.getui.push.v2.sdk.dto.req.message.PushMessage;
import com.getui.push.v2.sdk.dto.req.message.android.GTNotification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Map;
/**
 * Created with IntelliJ IDEA.
 * 个推推送工具类
 * @Author: yeshijie
 * @Date: 2021/7/8
 * @Description:
 */
public class GetuiUtil {
    private static final Logger logger = LoggerFactory.getLogger(GetuiUtil.class);
    public static String AppID = "GjGtBQUgSbASF0F9svJ6b7";
    public static String AppKey = "LcDj4vwtE29Q88KyPjJEj9";
    public static String AppSecret = "0VAMmhF1F76oGjheYWATM3";
    public static String MasterSecret = "hB6swhmr0mAeaJgyoLMkC5";
    private static PushApi getPushApi(){
        GtApiConfiguration apiConfiguration = new GtApiConfiguration();
        //填写应用配置
        apiConfiguration.setAppId(AppID);
        apiConfiguration.setAppKey(AppKey);
        apiConfiguration.setMasterSecret(MasterSecret);
        // 接口调用前缀,请查看文档: 接口调用规范 -> 接口前缀, 可不填写appId
        apiConfiguration.setDomain("https://restapi.getui.com/v2/");
        // 实例化ApiHelper对象,用于创建接口对象
        ApiHelper apiHelper = ApiHelper.build(apiConfiguration);
        // 创建对象,建议复用。目前有PushApi、StatisticApi、UserApi
        PushApi pushApi = apiHelper.creatApi(PushApi.class);
        return pushApi;
    }
    /**
     * 单推
     */
    public static ApiResult<Map<String, Map<String, String>>> pushToSingleByCid(String cid, JSONObject json) {
        //根据cid进行单推
        PushDTO<Audience> pushDTO = new PushDTO<>();
        // 设置推送参数
        pushDTO.setRequestId(System.currentTimeMillis() + "");
        PushMessage pushMessage = new PushMessage();
        pushDTO.setPushMessage(pushMessage);
        GTNotification notification = new GTNotification();
        pushMessage.setNotification(notification);
        notification.setTitle(json.getString("title"));
        notification.setBody(json.getString("body"));
        notification.setClickType(json.getString("clickType"));
        notification.setUrl(json.getString("url"));
        // 设置接收人信息
        Audience audience = new Audience();
        pushDTO.setAudience(audience);
        audience.addCid(cid);
        //消息离线时间设置
        Settings settings = new Settings();
        //	消息离线时间设置,单位毫秒,-1表示不设离线,-1 ~ 3 * 24 * 3600 * 1000(3天)之间
        settings.setTtl(3 * 24 * 3600 * 1000);
        pushDTO.setSettings(settings);
        // 进行cid单推
        return getPushApi().pushToSingleByCid(pushDTO);
    }
}

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

@ -72,6 +72,7 @@ public class DeviceController {
            deviceService.aqgsos(imei, label_mac, time_begin,request);
            long endTime=System.currentTimeMillis();
            dataPushLogUtil.savePushLog(imei,paraString,"爱牵挂SOS数据接收");
            dataPushLogUtil.updContactStatus(imei,1,false);
            logger.info("爱牵挂设备sos数据接收,请求参数:\n"+paraString+"\n"+(endTime-startTime)+"ms");
            return success();
        } catch (Exception e) {
@ -95,8 +96,9 @@ public class DeviceController {
        try {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂设备开关机数据接收,请求参数:\n"+paraString);
            dataPushLogUtil.savePushLog(imei,paraString,"爱牵挂开关机数据接收");
            deviceService.aqgSwitch(imei, time_begin, remaining_power, type,request);
            dataPushLogUtil.savePushLog(imei,paraString,"爱牵挂开关机数据接收");
            dataPushLogUtil.updContactStatus(imei,1,false);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
@ -120,6 +122,7 @@ public class DeviceController {
            deviceService.pushdata(type, deviceid, communityid, request);
            long endTime=System.currentTimeMillis();
            dataPushLogUtil.savePushLog(deviceid,paraString,"爱牵挂消息通知接收");
            dataPushLogUtil.updContactStatus(deviceid,1,false);
            logger.info("爱牵挂设备消息通知数据接收,请求参数:\n"+paraString+"\n"+(endTime-startTime)+"ms");
            return success();
        } catch (Exception e) {
@ -156,6 +159,7 @@ public class DeviceController {
            logger.info("爱牵挂位置接收,请求参数:\n"+paraString);
            dataPushLogUtil.savePushLog(imei,paraString,"爱牵挂位置数据接收");
            deviceService.byLocation(imei,time_begin,is_reply,is_track,city,address,lon,lat,type);
            dataPushLogUtil.updContactStatus(imei,1,false);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
@ -241,6 +245,7 @@ public class DeviceController {
            logger.info("爱牵挂跌倒数据接收,请求参数: \n"+paraString);
            dataPushLogUtil.savePushLog(imei,paraString,"爱牵挂跌倒数据接收");
            deviceService.byFall(imei,time_begin,city,address,lon,lat,type);
            dataPushLogUtil.updContactStatus(imei,1,false);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
@ -263,6 +268,7 @@ public class DeviceController {
            logger.info("爱牵挂步数接收,请求参数:\n"+paraString);
            dataPushLogUtil.savePushLog(imei,paraString,"爱牵挂设备步数数据接收");
            deviceService.bySteps(imei,time_begin,value);
            dataPushLogUtil.updContactStatus(imei,1,false);
            return success();
        } catch (Exception e) {
            e.printStackTrace();
@ -296,6 +302,7 @@ public class DeviceController {
            long endTime=System.currentTimeMillis();
            logger.info("爱牵挂-睡眠带接收,请求参数:"+paraString+"\n"+(endTime-startTime)+"ms");
            dataPushLogUtil.savePushLog(device,paraString,"睡眠带数据接收");
            dataPushLogUtil.updContactStatus(device,1,false);
            deviceService.sleepHealthIndex(device,heartrate,breath,time_begin);
            return success();
        } catch (Exception e) {
@ -352,6 +359,7 @@ public class DeviceController {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂-睡眠带睡眠报告,请求参数:"+paraString);
            dataPushLogUtil.savePushLog(device,paraString,"睡眠带报告数据接收");
            dataPushLogUtil.updContactStatus(device,1,false);
            deviceService.bySleepReport(device,date,fallasleep,sleepTime,restTime,awakeTime,lightTime,remTime,deepTime,bucket,
                    avghr,avgbr,awakePer,remPer,lightPer,efficiency,score,deepPer);
            return success();
@ -377,7 +385,7 @@ public class DeviceController {
            String paraString = JSON.toJSONString(request.getParameterMap());
            logger.info("爱牵挂-睡眠带wifi在线状态接收:"+paraString);
            dataPushLogUtil.savePushLog(device,paraString,"睡眠带在线状态数据接收");
            deviceService.byOnlineStatus(device,onlinestatu,time_begin);
            dataPushLogUtil.updContactStatus(device,Integer.parseInt(onlinestatu),false);
            return success();
        } catch (Exception e) {
            e.printStackTrace();

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

@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.*;
import com.yihu.jw.care.util.DeviceDataPushLogUtil;
import com.yihu.jw.care.util.DeviceLostMessageUtil;
import com.yihu.jw.care.util.SecurityOrderUtil;
import com.yihu.jw.entity.base.patient.BasePatientDO;
@ -94,6 +95,8 @@ public class DeviceService {
    private DeviceLostMessageUtil deviceLostMessageUtil;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private DeviceDataPushLogUtil dataPushLogUtil;
    /**
     * 获取爱牵挂管理员cookie
@ -434,7 +437,9 @@ public class DeviceService {
                        content_notice = content_notice.substring(0,content_notice.length()-1);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        dataPushLogUtil.updContactStatus(imei,1,true);
                    }
                    dataPushLogUtil.updContactStatus(imei,1,false);
                    healthIndexDao.save(patientHealthIndex);
                    systemMessageDao.save(messageDO);
                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
@ -516,8 +521,9 @@ public class DeviceService {
                        content_notice = content_notice.substring(0,content_notice.length()-1);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        dataPushLogUtil.updContactStatus(imei,1,true);
                    }
                    dataPushLogUtil.updContactStatus(imei,1,false);
                    healthIndexDao.save(patientHealthIndex);
                    systemMessageDao.save(messageDO);
                    imUtil.sendPatientSystemMessage(messageDO.getReceiver(),JSON.toJSONString(message,SerializerFeature.WriteMapNullValue));
@ -919,34 +925,7 @@ public class DeviceService {
            e.printStackTrace();
        }
    }
    @Async
    public void byOnlineStatus(String device,String onlinestatu,String time_begin){
        try {
            if(StringUtils.isNotBlank(device)){
                List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByDeviceSn(device);
                if (devicePatientDeviceDos.size()>0){
                    DevicePatientDevice tmp = devicePatientDeviceDos.get(0);
                    patientDeviceDao.save(tmp);
                }
            }
            DeviceDetail deviceDetail = deviceDetailDao.findBySn(device);
            if(deviceDetail!=null){
                deviceDetail.setContactStatus(Integer.parseInt(onlinestatu));
                deviceDetailDao.save(deviceDetail);
                if ("0".equals(onlinestatu)){
                    List<String> sns = new ArrayList<>();
                    sns.add(device);
                    deviceLostMessageUtil.deviceLostMessage(sns);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    //睡眠带心率呼吸数据
    @Async
    public void sleepHealthIndex(String device,String heartrate,String breath,String time_begin) {

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

@ -136,6 +136,7 @@ public class DeviceUploadService {
                throw new Exception("This device is not relate patient!");
            }
            dataPushLogUtil.savePushLog(deviceSn,paraString,"体征数据接收");
            dataPushLogUtil.updContactStatus(deviceSn,1,false);
            //保存消息
            BasePatientDO patientDO = patientDao.findById(result.getUser());
            if (null != patientDO){
@ -191,9 +192,9 @@ public class DeviceUploadService {
                        content_notice = content_notice.substring(0,content_notice.length()-1);
                        message.put("content_notice","您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        messageDO.setContent("您的key1过高,请注意饮食,尽量食用少油少盐食物".replace("key1",content_notice));
                        hvDeviceService.updContactStatus(deviceSn,1,true);
                        dataPushLogUtil.updContactStatus(deviceSn,1,true);
                    }else{
                        hvDeviceService.updContactStatus(deviceSn,1,false);
                        dataPushLogUtil.updContactStatus(deviceSn,1,false);
                    }
                    patientHealthIndexDao.save(result);
                    systemMessageDao.save(messageDO);
@ -478,6 +479,7 @@ public class DeviceUploadService {
                String tmp[] = inst.split("\\*");
                String sn = tmp[1];
                dataPushLogUtil.savePushLog(sn,"{\"message\":\""+instructions+"\"}","拐杖数据接收");
                dataPushLogUtil.updContactStatus(sn,1,false);
                String order = tmp[3];
                if(order.contains(",")){
                    String tmp1[] = order.split(",");
@ -539,7 +541,7 @@ public class DeviceUploadService {
                        deviceIndex.setLat(dulat+"");
                        deviceIndex.setLon(dulon+"");
                        yxDeviceIndexDao.save(deviceIndex);
                        hvDeviceService.updContactStatus(sn,1,flag);
                        dataPushLogUtil.updContactStatus(sn,1,flag);
                    }
                    if ("AL".equals(tmp1[0])){//触发报警 SOS
                        String lat,lon;
@ -614,7 +616,7 @@ public class DeviceUploadService {
                        deviceIndex.setLat(dulat+"");
                        deviceIndex.setLon(dulon+"");
                        yxDeviceIndexDao.save(deviceIndex);
                        hvDeviceService.updContactStatus(sn,1,flag);
                        dataPushLogUtil.updContactStatus(sn,1,flag);
                    }
                }
            }

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

@ -166,7 +166,7 @@ public class HvDeviceService {
                list.add(index);
                dataPushLogUtil.savePushLog(resourceSerial,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"烟探测器监测信息接收");
            }
            updContactStatus(resourceSerial,1,false);
            dataPushLogUtil.updContactStatus(resourceSerial,1,false);
        }
        if(list.size()>0){
            deviceHealthIndexDao.save(list);
@ -185,45 +185,11 @@ public class HvDeviceService {
            List<HvDeviceRecord> list = hvdeviceRecordDao.findByDeviceId(deviceID);
            dataPushLogUtil.savePushLog(deviceID,jsonObject.toJSONString(jsonObject,SerializerFeature.WriteMapNullValue),"气感烟感探测器监测信息接收");
            if(list.size()>0){
                updContactStatus(list.get(0).getDeviceSn(),Integer.valueOf(deviceStatus),null);
                dataPushLogUtil.updContactStatus(list.get(0).getDeviceSn(),Integer.valueOf(deviceStatus),null);
            }
        }
    }
    /**
     * 更新在线状态 及次数
     * @param sn
     * @param status
     * @param flag 状态 true 异常 false 正常 null其他
     */
    public void updContactStatus(String sn,Integer status,Boolean flag){
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(sn);
        if(deviceDetail!=null){
            deviceDetail.setContactStatus(status);
            if(0==status){
               List<String> sns =  new ArrayList<String>();
               sns.add(sn);
               deviceLostMessageUtil.deviceLostMessage(sns);
            }
            deviceDetail.setContactStatusTime(new Date());
            if(deviceDetail.getCollectNum()==null){
                deviceDetail.setCollectNum(0L);
            }
            if(deviceDetail.getAbnormalNum()==null){
                deviceDetail.setAbnormalNum(0L);
            }
            if(flag!=null){
                deviceDetail.setCollectNum(deviceDetail.getCollectNum()+1L);
                if(flag){
                    deviceDetail.setAbnormalNum(deviceDetail.getAbnormalNum()+1L);
                }
            }
            deviceDetailDao.save(deviceDetail);
        }
    }
    /**
     * 同步设备
     */

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

@ -115,7 +115,7 @@ public class OnenetService {
                }
            }
            hvDeviceService.updContactStatus(deviceSn,1,flag);
            dataPushLogUtil.updContactStatus(deviceSn,1,flag);
            record.setContent(msg.toJSONString());
            record.setStatus(1);

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

@ -279,6 +279,7 @@ public class YsDeviceService {
                DeviceDetail deviceDetail = deviceDetailDao.findBySn(deviceSN);
                dataPushLogUtil.savePushLog(deviceSN,bodyJsonObj.toJSONString(bodyJsonObj,SerializerFeature.WriteMapNullValue),"跌倒监护摄像头数据接收");
                dataPushLogUtil.updContactStatus(deviceSN,1,false);
                if (deviceDetail!=null){
                    deviceDetail.setContactStatus(1);
                    deviceDetailDao.save(deviceDetail);

+ 51 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceDataPushLogUtil.java

@ -1,14 +1,18 @@
package com.yihu.jw.care.util;
import com.yihu.jw.care.dao.device.DeviceDataPushLogDao;
import com.yihu.jw.care.dao.device.DeviceDetailDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.device.DeviceDataPushLog;
import com.yihu.jw.entity.care.device.DeviceDetail;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -25,6 +29,13 @@ public class DeviceDataPushLogUtil {
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private BasePatientDao patientDao;
    @Autowired
    private DeviceLostMessageUtil deviceLostMessageUtil;
    @Autowired
    private DeviceDetailDao deviceDetailDao;
    @Autowired
    private SystemMessageDao systemMessageDao;
    public void savePushLog(String sn,String data,String apiName){
        try {
@ -49,4 +60,44 @@ public class DeviceDataPushLogUtil {
            e.printStackTrace();
        }
    }
    /**
     * 更新在线状态 及次数
     * @param sn
     * @param status
     * @param flag 状态 true 异常 false 正常 null其他
     */
    public void updContactStatus(String sn,Integer status,Boolean flag){
        DeviceDetail deviceDetail = deviceDetailDao.findBySn(sn);
        if(deviceDetail!=null){
            deviceDetail.setContactStatus(status);
            if(0==status){
                List<String> sns =  new ArrayList<String>();
                sns.add(sn);
                deviceLostMessageUtil.deviceLostMessage(sns);
            }
            else if(1==status){
                //设备在线清除原有的离线消息
                List<String> sns = new ArrayList<String>();
                sns.add(sn);
                systemMessageDao.delMessageByRelationCode(sns);
            }
            deviceDetail.setContactStatusTime(new Date());
            if(deviceDetail.getCollectNum()==null){
                deviceDetail.setCollectNum(0L);
            }
            if(deviceDetail.getAbnormalNum()==null){
                deviceDetail.setAbnormalNum(0L);
            }
            if(flag!=null){
                deviceDetail.setCollectNum(deviceDetail.getCollectNum()+1L);
                if(flag){
                    deviceDetail.setAbnormalNum(deviceDetail.getAbnormalNum()+1L);
                }
            }
            deviceDetailDao.save(deviceDetail);
        }
    }
}

+ 9 - 0
svr/svr-cloud-device/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java

@ -44,6 +44,14 @@ public class DeviceLostMessageUtil {
                        "               WHERE sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id and m.doctor_code = d.id " +
                        "               and m.del = '1' and sr.patient = '"+deviceDO.getUser()+"' " ;
                List<Map<String,Object>> doctors = jdbcTemplate.queryForList(sql);
                // 家属
                sql = " select  t2.id,t2.name from  base_patient_family_member t1,  base_patient t2 where  " +
                        "t2.id in (select family_member from base_patient_family_member where patient = '"+deviceDO.getUser()+"' )  " +
                        " and t1.patient = '"+deviceDO.getUser()+"'  and t1.family_member = t2.id  " +
                        " and t2.archive_type=3 GROUP BY t2.id " ;
                List<Map<String,Object>> relatives = jdbcTemplate.queryForList(sql);
                doctors.addAll(relatives);
                String deviceName="";
                for (Map<String,Object> docTmp:doctors){
                    switch (deviceDO.getCategoryCode()){
@ -82,6 +90,7 @@ public class DeviceLostMessageUtil {
                    SystemMessageDO messageDO = new SystemMessageDO();
                    messageDO.setTitle("设备离线通知");
                    messageDO.setType("43");
                    messageDO.setIsRead("0");
                    messageDO.setSender(deviceDO.getUser());
                    messageDO.setSenderName(patientDO.getName());
                    messageDO.setRelationCode(id);

+ 10 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java

@ -10,6 +10,7 @@ import com.yihu.jw.care.job.message.PatientSendUnreadJob;
import com.yihu.jw.care.job.order.CancelPayOrderJob;
import com.yihu.jw.care.job.order.EmeWarnOrderDayJob;
import com.yihu.jw.care.job.order.EmeWarnOrderJob;
import com.yihu.jw.care.job.visit.OverTimeVistJob;
import com.yihu.jw.care.util.SystemConf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -113,6 +114,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("EME_WARNING_OVERTIME_NOT_RESPONSE_DAY exist");
            }
            //#取消订单支付超时的订单,每5分钟执行一次
            if (!quartzHelper.isExistJob("OVERTIME_VISIT_JOB")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("OVERTIME_VISIT_JOB");
                quartzHelper.addJob(OverTimeVistJob.class, trigger, "OVERTIME_VISIT_JOB", new HashMap<String, Object>());
                logger.info("OVERTIME_VISIT_JOB success");
            } else {
                logger.info("OVERTIME_VISIT_JOB exist");
            }
        } catch (Exception e) {
            logger.info(" job start failed");
        }

+ 39 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/visit/OverTimeVistJob.java

@ -0,0 +1,39 @@
package com.yihu.jw.care.job.visit;
import com.yihu.jw.util.date.DateUtil;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
/**
 * 每5分钟执行一次 过期超时的日常走访
 * Created by yeshijie on 2021/11/15.
 */
@DisallowConcurrentExecution//解决执行频率和间隔时间的问题。到了执行时间点前一任务还在执行中,不会执行下一次任务,直至该次任务完成
public class OverTimeVistJob implements Job {
    private static Logger logger = LoggerFactory.getLogger(OverTimeVistJob.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        Long nowTime = System.currentTimeMillis();
        logger.info("OverTimeVistJob start 过期超时的日常走访JOb开始----截至支付时间:"+nowTime);
        try {
            String now = DateUtil.getStringDate();
            String sql = "update base_visit set status ='2' WHERE `status` = 0 and visit_plan_date<='"+now+"'";
            jdbcTemplate.execute(sql);
        }catch (Exception e){
            e.printStackTrace();
        }
        logger.info("OverTimeVistJob end 过期超时的日常走访JOb结束----");
    }
}

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

@ -250,20 +250,23 @@ public class PatientDeviceService {
            List<String> onContact = new ArrayList<>();
            /*******************未失联**/
           //血糖仪,血压计。30天内有数据上传,则改为未失联
            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and EXISTS ( " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
            List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
            if (devices.size() > 0) {
                onContact.addAll(devices);
            }
//            String sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (1,2) and EXISTS ( " +
//                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
//                    " BETWEEN '"+startTimeDevice1+"' AND '"+endTime+"') ";
//            List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
//            if (devices.size() > 0) {
//                onContact.addAll(devices);
//            }
//
//            //智能拐杖。手表2天内有数据上传,则改为未失联**
//            sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (4,16) and EXISTS ( " +
//                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
//                    " BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"') ";
            //智能拐杖。手表2天内有数据上传,则改为未失联**
            sql = " SELECT pd.device_sn FROM base.wlyy_patient_device pd  where pd.del=0 and pd.category_code in (4,16) and EXISTS ( " +
                    "select dp.device_sn from device_data_push_log dp where dp.device_sn = pd.device_sn and dp.create_time " +
            //清除消息
            String sql = " select distinct dp.device_sn from device_data_push_log dp where  dp.create_time " +
                    " BETWEEN '"+startTimeDevice2+"' AND '"+endTime+"') ";
            devices = jdbcTemplate.queryForList(sql,String.class) ;
            List<String> devices = jdbcTemplate.queryForList(sql,String.class) ;
            if (devices.size() > 0) {
                onContact.addAll(devices);
            }

+ 10 - 1
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/util/DeviceLostMessageUtil.java

@ -45,7 +45,15 @@ public class DeviceLostMessageUtil {
                        "               WHERE sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id and m.doctor_code = d.id " +
                        "               and m.del = '1' and sr.patient = '"+deviceDO.getUser()+"' and d.doctor_level=2 " ;
                List<Map<String,Object>> doctors = jdbcTemplate.queryForList(sql);
                        String deviceName="";
                // 家属
                sql = " select  t2.id,t2.name from  base_patient_family_member t1,  base_patient t2 where  " +
                         "t2.id in (select family_member from base_patient_family_member where patient = '"+deviceDO.getUser()+"' )  " +
                         " and t1.patient = '"+deviceDO.getUser()+"'  and t1.family_member = t2.id  " +
                         " and t2.archive_type=3 GROUP BY t2.id " ;
                List<Map<String,Object>> relatives = jdbcTemplate.queryForList(sql);
                doctors.addAll(relatives);
                String deviceName="";
                for (Map<String,Object> docTmp:doctors){
                    switch (deviceDO.getCategoryCode()){
                        case "1":
@ -83,6 +91,7 @@ public class DeviceLostMessageUtil {
                    SystemMessageDO messageDO = new SystemMessageDO();
                    messageDO.setTitle("设备离线通知");
                    messageDO.setType("43");
                    messageDO.setIsRead("0");
                    messageDO.setSender(deviceDO.getUser());
                    messageDO.setSenderName(patientDO.getName());
                    messageDO.setRelationCode(id);

+ 3 - 0
svr/svr-cloud-job/src/main/resources/system.properties

@ -14,6 +14,9 @@ BIRTHDAY_REMINDER_JOB=0 0 9 * * ?
#\u53D6\u6D88\u8BA2\u5355\u652F\u4ED8\u8D85\u65F6\u7684\u8BA2\u5355\uFF0C\u6BCF3\u5206\u949F\u6267\u884C\u4E00\u6B21
CANCEL_PAY_ORDER_OVERTIME_JOB=0 0/3 * * * ?
#\u8FC7\u671F\u8D85\u65F6\u7684\u65E5\u5E38\u8D70\u8BBF\uFF0C\u6BCF5\u5206\u949F\u6267\u884C\u4E00\u6B21
OVERTIME_VISIT_JOB=0 0/5 * * * ?
#\u5C45\u6C11\u7D27\u6025\u8054\u7CFB\u4EBA\u6570\u636E\u540C\u6B65\u66F4\u65B0\u6BCF2\u5206\u949F\u6267\u884C\u4E00\u6B21
PATIENT_SOS_CONTACTS_JOB=0 0/2 * * * ?