Kaynağa Gözat

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

wangjun 3 yıl önce
ebeveyn
işleme
6cf65691f9
46 değiştirilmiş dosya ile 1459 ekleme ve 190 silme
  1. 20 1
      common/common-entity/sql记录
  2. 10 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageDO.java
  3. 11 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageRecordDO.java
  4. 1 0
      common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSignRecordDO.java
  5. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java
  6. 103 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/PatientSosContactsDO.java
  7. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java
  8. 19 0
      common/common-rest-model/src/main/java/com/yihu/jw/restmodel/emergency/EmergencyOrderVO.java
  9. 41 0
      common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java
  10. 4 0
      svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageEndpoint.java
  11. 2 0
      svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageService.java
  12. 4 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/NetworkCardConfig.java
  13. 20 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/contacts/PatientSosContactsDao.java
  14. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java
  15. 35 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java
  16. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java
  17. 19 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  18. 18 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  19. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientHealthController.java
  20. 32 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/lifeCare/PatientLifeCareEndpoint.java
  21. 15 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java
  22. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java
  23. 56 21
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/sign/SignEndpoint.java
  24. 12 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  25. 2 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java
  26. 171 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  27. 6 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java
  28. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  29. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  30. 18 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/patient/CarePatientService.java
  31. 21 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  32. 1 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ArchiveService.java
  33. 2 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/CapacityAssessmentRecordService.java
  34. 143 117
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java
  35. 2 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  36. 1 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java
  37. 49 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  38. 34 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/config/NetworkCardConfig.java
  39. 21 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/DeviceDao.java
  40. 66 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  41. 22 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/PatientSosContactsDao.java
  42. 10 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java
  43. 83 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/device/PatientSosContactsJob.java
  44. 121 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java
  45. 221 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  46. 4 1
      svr/svr-cloud-job/src/main/resources/system.properties

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

@ -1209,6 +1209,7 @@ CREATE TABLE `voluntary_recruitment_people` (
alter table base_job_category  add code varchar(50);
alter table base_nat_appointment  add oder_num varchar(50);
alter table base_business_order_pay  add history_order varchar(1000);
@ -1223,4 +1224,22 @@ create TABLE base.base_emergency_warn_log(
	content VARCHAR(255) default null comment '操作详情',
	create_time timestamp NULL DEFAULT NULL COMMENT '创建时间',
	PRIMARY KEY(id)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='紧急预警工单动态消息';
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='紧急预警工单动态消息';
-- 2021-08-10
CREATE TABLE `base_patient_sos_contacts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `patient` varchar(50) DEFAULT NULL COMMENT '居民id',
  `sos_name` varchar(50) DEFAULT NULL COMMENT '紧急联系人姓名',
  `sos_phone` varchar(50) DEFAULT NULL COMMENT '紧急联系人电话',
  `relation` int(2) DEFAULT NULL COMMENT '家庭关系 同base_patient_family_member',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `success_flag` tinyint(4) DEFAULT NULL COMMENT '联系人是否同步成功-1失败 0待同步 1成功',
  `del` int(1) DEFAULT NULL COMMENT '是否有效 1有效 0无效',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='居民紧急联系人';
-- 2021-08-11
ALTER table base.base_patient_sos_contacts add column phone_seqid int(2) default null COMMENT '联系人序号';
ALTER table base_emergency_assistance_order add column device_sn varchar(50) DEFAULT NULL COMMENT '设备触发工单时有该字段';
ALTER table base_security_monitoring_order add column device_sn varchar(50) DEFAULT NULL COMMENT '设备触发工单时有该字段';

+ 10 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageDO.java

@ -33,6 +33,7 @@ public class ServicePackageDO extends UuidIdentityEntityWithCreateTime implement
    private List<BaseTeamDO> teamDOList;//服务团队
    private String teamNames;//服务团队
    private String orgNames;//服务机构
    private String orgCodes;
    private String orgCode;
    private String orgName;
@ -143,6 +144,15 @@ public class ServicePackageDO extends UuidIdentityEntityWithCreateTime implement
        this.teamNames = teamNames;
    }
    @Transient
    public String getOrgCodes() {
        return orgCodes;
    }
    public void setOrgCodes(String orgCodes) {
        this.orgCodes = orgCodes;
    }
    @Transient
    public String getOrgNames() {
        return orgNames;

+ 11 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageRecordDO.java

@ -2,6 +2,7 @@ package com.yihu.jw.entity.base.servicePackage;
import com.yihu.jw.entity.UuidIdentityEntityWithCreateTime;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
@ -26,6 +27,7 @@ public class ServicePackageRecordDO extends UuidIdentityEntityWithCreateTime imp
     * 居民id
     */
    private String patient;
    private String teamCode;//服务团队id
    public String getSignId() {
        return signId;
@ -50,4 +52,13 @@ public class ServicePackageRecordDO extends UuidIdentityEntityWithCreateTime imp
    public void setPatient(String patient) {
        this.patient = patient;
    }
    @Column(name = "team_code")
    public String getTeamCode() {
        return teamCode;
    }
    public void setTeamCode(String teamCode) {
        this.teamCode = teamCode;
    }
}

+ 1 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/base/servicePackage/ServicePackageSignRecordDO.java

@ -137,4 +137,5 @@ public class ServicePackageSignRecordDO extends UuidIdentityEntityWithCreateTime
    public void setPackageList(List<Map<String,Object>> packageList) {
        this.packageList = packageList;
    }
}

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

@ -69,6 +69,7 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    private Integer type; //发起类型(1本人发起 2家人待预约 3医生代预约)
    private Integer orderSource;//工单发起来源状态 1APP 2手环 3居家报警
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String deviceSn;//设备sn  设备触发是才有该字段值
    private String sendMessage;//
@ -352,4 +353,12 @@ public class EmergencyAssistanceDO extends UuidIdentityEntityWithOperator {
    public void setEmergencyCancel(Integer emergencyCancel) {
        this.emergencyCancel = emergencyCancel;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
}

+ 103 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/PatientSosContactsDO.java

@ -0,0 +1,103 @@
package com.yihu.jw.entity.care.contacts;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.yihu.jw.entity.IdEntity;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;
import java.util.Date;
/**
 * Created by Bing on 2021/8/10.
 * 居民紧急联系人表
 */
@Entity
@Table(name="base_patient_sos_contacts")
public class PatientSosContactsDO extends IdEntity {
    private String patient;
    private String sosName; //紧急联系人
    private String sosPhone; //联系电话
    private String relation; //与联系人关系 同base_patient_family_member
    private Date updateTime; //修改日期
    private Integer successFlag;//联系人是否同步成功 -2删除失败 -1添加失败 0待同步 1添加成功 2删除成功
    private Integer del;
    private Integer phoneSeqid;// 联系人序号 1 或2
    private String relationName;
    public String getPatient() {
        return patient;
    }
    public void setPatient(String patient) {
        this.patient = patient;
    }
    public String getSosName() {
        return sosName;
    }
    public void setSosName(String sosName) {
        this.sosName = sosName;
    }
    public String getSosPhone() {
        return sosPhone;
    }
    public void setSosPhone(String sosPhone) {
        this.sosPhone = sosPhone;
    }
    public String getRelation() {
        return relation;
    }
    public void setRelation(String relation) {
        this.relation = relation;
    }
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
    public Integer getSuccessFlag() {
        return successFlag;
    }
    public void setSuccessFlag(Integer successFlag) {
        this.successFlag = successFlag;
    }
    public Integer getDel() {
        return del;
    }
    public void setDel(Integer del) {
        this.del = del;
    }
    @Transient
    public String getRelationName() {
        return relationName;
    }
    public void setRelationName(String relationName) {
        this.relationName = relationName;
    }
    public Integer getPhoneSeqid() {
        return phoneSeqid;
    }
    public void setPhoneSeqid(Integer phoneSeqid) {
        this.phoneSeqid = phoneSeqid;
    }
}

+ 9 - 0
common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java

@ -322,6 +322,7 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    private Integer emergencyCancel;// 紧急预警工单误报警原因 字典emergency_cancel
    private String topicItem;//安防工单所属专题 base_system_dict_entry表service_item
    private String sceneImg;//现场照片
    private String deviceSn;//设备sn  设备触发是才有该字段值
    /**
     * 医生确认医生结束服务时间
@ -727,4 +728,12 @@ public class SecurityMonitoringOrderDO extends UuidIdentityEntityWithOperator {
    public void setSceneImg(String sceneImg) {
        this.sceneImg = sceneImg;
    }
    public String getDeviceSn() {
        return deviceSn;
    }
    public void setDeviceSn(String deviceSn) {
        this.deviceSn = deviceSn;
    }
}

+ 19 - 0
common/common-rest-model/src/main/java/com/yihu/jw/restmodel/emergency/EmergencyOrderVO.java

@ -1,6 +1,7 @@
package com.yihu.jw.restmodel.emergency;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
@ -50,6 +51,8 @@ public class EmergencyOrderVO {
    private String otherDoctorDistance;//其他医生定位信息
    private String topicItem;//安防工单专题code关联security_topic_dict字典
    private List<BaseEmergencyWarnLogDO> orderLogInfo;
    private List<PatientSosContactsDO> sosContacts;//紧急联系人
    private List<Map<String,Object>> securityDevices;//安防设备列表
    public String getId() {
        return id;
@ -266,4 +269,20 @@ public class EmergencyOrderVO {
    public void setOrderLogInfo(List<BaseEmergencyWarnLogDO> orderLogInfo) {
        this.orderLogInfo = orderLogInfo;
    }
    public List<PatientSosContactsDO> getSosContacts() {
        return sosContacts;
    }
    public void setSosContacts(List<PatientSosContactsDO> sosContacts) {
        this.sosContacts = sosContacts;
    }
    public List<Map<String, Object>> getSecurityDevices() {
        return securityDevices;
    }
    public void setSecurityDevices(List<Map<String, Object>> securityDevices) {
        this.securityDevices = securityDevices;
    }
}

+ 41 - 0
common/common-util/src/main/java/com/yihu/jw/util/date/DateUtil.java

@ -11,6 +11,7 @@ import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
/**
 * Created by chenweida on 2017/5/19.
@ -1354,6 +1355,46 @@ public class DateUtil {
        return dateTime.substring(0, 10);
    }
    /**
     *  返回 xx天XX小时XX分钟XX秒前
     * @param date1 当前时间
     * @param date2 过去时间
     * @return
     */
    public static String getDifferentTimeInfo(Date date1, Date date2){
        if (date1 == null || date2 == null){
            return null;
        }
        StringBuilder result = new StringBuilder("");
        long millisecondsDiff = date1.getTime() - date2.getTime();
        long secondsDiff = millisecondsDiff / TimeUnit.SECONDS.toMillis(1L);
        long minutesDiff = millisecondsDiff / TimeUnit.MINUTES.toMillis(1L);
        long hoursDiff = millisecondsDiff / TimeUnit.HOURS.toMillis(1L);
        long daysDiff = millisecondsDiff / TimeUnit.DAYS.toMillis(1L);
        long hourFieldDiff = hoursDiff - TimeUnit.DAYS.toHours(daysDiff);
        long minuteFieldDiff = minutesDiff - TimeUnit.HOURS.toMinutes(hoursDiff);
        long secondFieldDiff = secondsDiff - TimeUnit.MINUTES.toSeconds(minutesDiff);
        if (daysDiff > 0L) {
            result.append(String.format("%d天", daysDiff));
            result.append("前");
            return result.toString();
        }
        if (hourFieldDiff > 0L) {
            result.append(String.format("%d小时", hourFieldDiff));
        }
        if (minuteFieldDiff > 0L) {
            result.append(String.format("%d分钟", minuteFieldDiff));
            if (result.indexOf("小时")>0){
                result.append("前");
                return result.toString();
            }
        }
        if (secondFieldDiff > 0L) {
            result.append(String.format("%d秒", secondFieldDiff));
        }
        result.append("前");
        return result.toString();
    }
}

+ 4 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/servicePackage/ServicePackageEndpoint.java

@ -81,8 +81,12 @@ public class ServicePackageEndpoint extends EnvelopRestEndpoint {
            List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByServicePackageId(servicePackageDO.getId());
            List<String> orgNames = itemDOList.stream().map(p -> p.getOrgName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
            List<String> teamNames = itemDOList.stream().map(p -> p.getTeamName()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
            List<String> orgCodes = itemDOList.stream().map(p -> p.getOrgCode()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
 //           List<String> teamCodes = itemDOList.stream().map(p -> p.getTeamCode()).collect(Collectors.toList()).stream().distinct().collect(Collectors.toList());
            servicePackageDO.setOrgNames(StringUtils.join(orgNames,","));
            servicePackageDO.setTeamNames(StringUtils.join(teamNames,","));
            servicePackageDO.setOrgCodes(StringUtils.join(orgCodes,","));
            for (WlyyHospitalSysDictDO wlyyHospitalSysDictDO:wlyyHospitalSysDictDOS){
                if (servicePackageDO.getType().equalsIgnoreCase(wlyyHospitalSysDictDO.getDictCode())){

+ 2 - 0
svr/svr-base/src/main/java/com/yihu/jw/base/service/servicePackage/ServicePackageService.java

@ -74,6 +74,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
            oldDO.setDel(servicePackageDO.getDel());
            oldDO.setType(servicePackageDO.getType());
            oldDO.setIntroduce(servicePackageDO.getIntroduce());
            oldDO.setOrgCode(servicePackageDO.getOrgCode());
            oldDO.setOrgName(servicePackageDO.getOrgName());
            servicePackageDO= servicePackageDao.save(oldDO);
            servicePackageItemDao.deleteByServicePackageId(oldDO.getId());
        }

+ 4 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/config/NetworkCardConfig.java

@ -9,11 +9,15 @@ import com.yihu.jw.util.date.DateUtil;
public class NetworkCardConfig {
    //平台地址 https://ct.cmonelink.com/zh/#/infoPanel/index
    //user:BE5714630405 password:Zjxl2008@
    //文档地址https://ec.iot.10086.cn/ecology/supportService/documents
    public static final String appid="571AIOT2021072910102922281";
    public static final String password="OnXE@QFlwt9R";
    public static final String redisKey="dianXinAssesToken";
    public static final String groupId="9911000019160041";//所有卡号均在同一分组下方便维护
    //APPID+YYYYMMDDHHMISS+8位数字序列
    public static String getTransid() {

+ 20 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/contacts/PatientSosContactsDao.java

@ -0,0 +1,20 @@
package com.yihu.jw.care.dao.contacts;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/8/10.
 */
public interface PatientSosContactsDao extends PagingAndSortingRepository<PatientSosContactsDO,Long>,
        JpaSpecificationExecutor<PatientSosContactsDO> {
    List<PatientSosContactsDO> findByPatientAndDel(String patient,Integer del);
    List<PatientSosContactsDO> findByPatientOrderByUpdateTimeDesc(String patient);
    PatientSosContactsDO findByPatientAndSosPhone(String patient,String sosPhone);
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java

@ -329,7 +329,7 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
    }
    @PostMapping("doctorSendMessageLog")
    @ApiOperation(value = "助老员紧急预警发送消息日志")
    @ApiOperation(value = "助老员紧急预警im发送消息日志")
    public ObjEnvelop doctorSendMessageLog(
            @ApiParam(name="doctor")@RequestParam(value = "doctor")String doctor,
            @ApiParam(name="type",value = "im会话对应type")@RequestParam(value = "type")String type,

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

@ -1,14 +1,17 @@
package com.yihu.jw.care.endpoint.device;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.util.CommonUtil;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
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.endpoint.EnvelopRestEndpoint;
import io.swagger.annotations.Api;
@ -52,6 +55,8 @@ public class DoctorDeviceController extends BaseController {
	@Autowired
	private JmsTemplate jmsTemplate;
	@Autowired
	private ContactsService contactsService;
	private ObjectMapper  objectMapper=new ObjectMapper();
@ -116,4 +121,34 @@ public class DoctorDeviceController extends BaseController {
			return write(200, "获取设备成功!", "data",objects);
	}
	@RequestMapping(value ="updatePatientSosContacts",method = RequestMethod.POST)
	@ApiOperation(value = "设置居民紧急联系人")
	public String updatePatientSosContacts(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
										   @RequestParam(value = "patient", required = true) String patient,
										   @ApiParam(name="num",value = "成员配置的语音白名单号码 新增时只能传一个,删除时最多两个,用下划线隔开")
										   @RequestParam(value = "num")String num,
										   @ApiParam(name="operType",value = "1新增 4删除")
										   @RequestParam(value ="operType",required = true)Integer operType,
										   @ApiParam(name = "name", value = "联系人姓名")
										   @RequestParam(value = "name", required = false) String name,
										   @ApiParam(name = "relation", value = "与联系人关系,同base_patient_family_member")
										   @RequestParam(value = "relation", required = false) String relation){
		try {
			if (1!=operType&&4!=operType){
				return error(-1,"参数错误");
			}
			JSONObject result = contactsService.updatePatientSosContacts(patient,num,operType,name,relation);
			if (ResponseContant.success == result.getInteger(ResponseContant.resultFlag)){
				return success("修改成功");
			}
			else {
				return error(-1,result.getString(ResponseContant.resultMsg));
			}
		}catch (Exception e){
			return errorResult(e);
		}
	}
}

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

@ -100,6 +100,9 @@ public class DoctorHealthController extends BaseController {
											  @RequestParam(value="pagesize",required = true) int pagesize) {
		try {
			JSONObject jsonObject = new JSONObject();
			if(StringUtils.isBlank(begin)){
				begin="2016-07-23 00:00:00";
			}
			if (type == 1) {
				List<Object> list = healthIndexService.findIndexByPatient2(patient, type, begin, end, page, pagesize);
				jsonObject.put("data",list);

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

@ -1,8 +1,11 @@
package com.yihu.jw.care.endpoint.device;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.endpoint.BaseController;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.device.DeviceDetailService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.PatientHealthIndexService;
@ -12,6 +15,8 @@ import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.sync.BaseSyncDataDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.rm.base.BaseRequestMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -47,6 +52,8 @@ public class PadDeviceController extends BaseController {
    private ObjectMapper objectMapper = new ObjectMapper();
    @Autowired
    private BaseDoctorDao baseDoctorDao;
    @Autowired
    private ContactsService contactsService;
    /**
     * 设备列表获取
     *
@ -149,4 +156,16 @@ public class PadDeviceController extends BaseController {
        }
    }
    @RequestMapping(value ="getPatientSosContacts",method = RequestMethod.GET)
    @ApiOperation(value = "获取居民紧急联系人")
    public String getPatientSosContacts(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                             @RequestParam(value = "patient", required = true) String patient){
        try {
            return write(200,"获取成功","detailModelList",contactsService.getPatientSosContacts(patient));
        }catch (Exception e){
            return errorResult(e);
        }
    }
}

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

@ -179,6 +179,17 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("紧急预警获取患者设备信息")
    @RequestMapping(value = "patientEmeDeviceList", method = RequestMethod.GET)
    public String patientEmeDeviceList(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                           @RequestParam(value = "patient", required = true) String patient) {
        try {
            return write(200,"查询成功","detailModelList",  patientDeviceService.patientEmeDeviceList(patient));
        } catch (Exception ex) {
            return errorResult(ex);
        }
    }
    /**
     * 设备删除
     */
@ -226,7 +237,7 @@ public class PatientDeviceController extends BaseController {
        }
    }
    @ApiOperation("修改删除 爱牵挂亲情号码")
    @ApiOperation("修改删除 爱牵挂亲情号码--未使用")
    @RequestMapping(value = "updAqgDeviceSosInfo",method = RequestMethod.POST)
    public String updAqgDeviceSosInfo(@ApiParam(name = "deviceSn",value = "设备id")
                                   @RequestParam(value = "deviceSn",required = true)String deviceSn,
@ -241,11 +252,12 @@ public class PatientDeviceController extends BaseController {
                                   @ApiParam(name = "clear",value = "删除标志,删除传1",required = false)
                                   @RequestParam(value = "clear",required = false)String clear){
        try {
            com.alibaba.fastjson.JSONObject json = patientDeviceService.updAqgDeviceSosInfo(deviceSn, seqid, name, num, dial_flag, clear);
            if(json.getBoolean("success")){
                return success("操作成功");
            }
            return error(-1,json.getString("error_desc"));
//            com.alibaba.fastjson.JSONObject json = patientDeviceService.updAqgDeviceSosInfo(deviceSn, seqid, name, num, dial_flag, clear);
//            if(json.getBoolean("success")){
//                return success("操作成功");
//            }
//            return error(-1,json.getString("error_desc"));
            return error(-1,"接口无效");
        }catch (Exception e){
            return errorResult(e);
        }

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

@ -410,6 +410,9 @@ public class PatientHealthController extends BaseController {
        try {
            JSONObject jsonObject = new JSONObject();
            if (StringUtils.isBlank(start)){
                start="2016-07-23 00:00:00";
            }
            if (type == 1) {
                List<Object> list = healthIndexService.findIndexByPatient2(getUID(), type, start, end, page, pagesize);
                jsonObject.put("data",list);

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

@ -94,6 +94,38 @@ public class PatientLifeCareEndpoint  extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "infoCount")
    @ApiOperation(value = "查询工单数量")
    public ObjEnvelop infoCount(
            @ApiParam(name = "patient", value = "居民code") @RequestParam(value = "patient", required = true) String patient) {
        try {
            JSONObject allResult = lifeCareOrderService.queryInfoList(patient, null, 1, 5);
            if (allResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(allResult.getString(ResponseContant.resultMsg), -1);
            }
            int allCount = allResult.getIntValue(ResponseContant.count);
            JSONObject object = new JSONObject();
            object.put("allCount",allCount);
            JSONObject qxResult = lifeCareOrderService.queryInfoList(patient, -1, 1, 5);
            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, 1, 5);
            if (wcResult.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return ObjEnvelop.getError(wcResult.getString(ResponseContant.resultMsg), -1);
            }
            int wcCount = wcResult.getIntValue(ResponseContant.count);
            object.put("wcCount",wcCount);
            return ObjEnvelop.getSuccess("查询成功",object);
        }catch (Exception e){
            return failedObjEnvelopException(e);
        }
    }
    @GetMapping(value = "findItemDict")
    @ApiOperation(value = "查找服务项字典")
    public ListEnvelop findItemDict() {

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

@ -57,12 +57,13 @@ public class PatientContactsEndpoint extends EnvelopRestEndpoint {
     * @return
     */
    @RequestMapping(value = "setPatientContacts", method = RequestMethod.POST)
    @ApiOperation(value = "设置一键联系人")
    @ApiOperation(value = "设置一键联系人--未使用")
    public Envelop setPatientContacts(@RequestParam(required = true) String patient,
                                      @RequestParam(required = true) String fid) {
        try {
            contactsService.setContacts(fid,patient);
            return ObjEnvelop.getSuccess("设置成功");
//            contactsService.setContacts(fid,patient);
//            return ObjEnvelop.getSuccess("设置成功");
            return Envelop.getError("接口无效");
        } catch (Exception e) {
            return failedException2(e);
        }
@ -129,4 +130,15 @@ public class PatientContactsEndpoint extends EnvelopRestEndpoint {
            return failedListEnvelopException2(e);
        }
    }
    @RequestMapping(value ="getPatientSosContacts",method = RequestMethod.GET)
    @ApiOperation(value = "获取居民紧急联系人")
    public ListEnvelop getPatientSosContacts(@ApiParam(name = "patient", value = "patient", defaultValue = "patient")
                                                 @RequestParam(value = "patient", required = true) String patient){
        try {
            return ListEnvelop.getSuccess("获取成功",contactsService.getPatientSosContacts(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}

+ 1 - 1
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientEndpoint.java

@ -41,7 +41,7 @@ public class PatientEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "testException")
    @ApiOperation(value = "测试异常")
    public String testException2(String type) throws Exception {
//        patientService.intiPatient();
        if("1".equals(type)){
            throw new NullPointerException();
        }else if("2".equals(type)){

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

@ -67,7 +67,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
    @GetMapping(value = "findSignDoctor")
    @ApiOperation(value = "查找签约医生")
    public ListEnvelop findSignDoctor (
            @ApiParam(name = "patient", value = "医生code", required = true)
            @ApiParam(name = "patient", value = "居民code", required = true)
            @RequestParam(value = "patient",required = true) String patient,
            @ApiParam(name = "orgCode", value = "医院code", required = false)
            @RequestParam(value = "orgCode",required = false) String orgCode) throws Exception {
@ -192,6 +192,30 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value = "findPatientSignList")
    @ApiOperation(value = "获取签约服务包记录")
    public ListEnvelop findPatientSignList (
            @ApiParam(name = "patient", value = "patient", required = true)
            @RequestParam(value = "patient") String patient) throws Exception {
        try{
            return ListEnvelop.getSuccess("查询成功",servicePackageService.findPatientSignList(patient));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "signPackageDetail")
    @ApiOperation(value = "获取签约服务包记录详情")
    public ObjEnvelop signPackageDetail (
            @ApiParam(name = "id", value = "id", required = true)
            @RequestParam(value = "id") String id) throws Exception {
        try{
            return ObjEnvelop.getSuccess("查询成功",servicePackageService.signPackageDetail(id));
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @PostMapping(value = "servicePackageSign")
    @ApiOperation(value = "分配服务包-签约")
    @ObserverRequired
@ -200,32 +224,47 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @RequestParam String jsonData,
            @ApiParam(name = "patientId", value = "居民id", required = true)
            @RequestParam String patientId,
            @ApiParam(name = "signYear", value = "签约时长 0长期 1 1年 2 2年", required = true)
            @RequestParam String signYear,
            @ApiParam(name = "doctorId", value = "医生id", required = true)
            @RequestParam String doctorId) {
        try{
           JSONObject result  = servicePackageService.servicePackageSign(jsonData,doctorId,patientId);
           JSONObject result  = servicePackageService.servicePackageSign(jsonData,doctorId,patientId,signYear);
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.fail) {
                return Envelop.getError(result.getString(ResponseContant.resultMsg));
            }
            servicePackageService.setPatientServiceItems(result.getJSONObject("resultMsg").getString("patient"));
            return Envelop.getSuccess("分配成功");
            return Envelop.getSuccess("签约成功");
        }catch (Exception e){
            if (e.getMessage().contains("重复签约服务项目")){
                return failed("分配失败,"+e.getMessage(),-1);
                return failed("签约失败,"+e.getMessage(),-1);
            }
            return failedException2(e);
        }
    }
    @GetMapping(value = "findServicePackageByOrgCode")
    @ApiOperation(value = "获取服务包")
    public ListEnvelop<List<Map<String,Object>>> findServicePackageByOrgCode (
            @ApiParam(name = "orgCode", value = "机构code", required = false)
            @RequestParam(value = "orgCode",required = false)  String orgCode) {
        try{
            return ListEnvelop.getSuccess("获取成功",servicePackageService.findServicePackageByOrgCode(orgCode));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value = "servicePackagePage")
    @ApiOperation(value = "获取服务包分页")
    public PageEnvelop<List<Map<String,Object>>> servicePackagePage (
            @ApiParam(name = "orgCode", value = "机构code", required = false)
            @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) throws Exception {
        try{
            return servicePackageService.servicePackagePage(page, size);
            return servicePackageService.servicePackagePage(page, size,orgCode);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -269,8 +308,6 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "status",required = false) Integer status,
            @ApiParam(name = "levelConclusion", value = "评估结果/等级结论", required = false)
            @RequestParam(value = "levelConclusion",required = false) Integer levelConclusion,
            @ApiParam(name = "servicePackageStatus", value = "服务包分配(0未分配,1已分配)", required = false)
            @RequestParam(value = "servicePackageStatus",required = false) Integer servicePackageStatus,
            @ApiParam(name = "type", value = "type 0当年 1全部", required = false)
            @RequestParam(value = "type",required = false,defaultValue = "0") Integer type,
            @ApiParam(name = "page", value = "分页大小", required = true, defaultValue = "1")
@ -278,7 +315,7 @@ public class SignEndpoint extends EnvelopRestEndpoint {
            @ApiParam(name = "size", value = "页码", required = true, defaultValue = "15")
            @RequestParam(value = "size") int size) throws Exception {
        try{
            return capacityAssessmentRecordService.assessmentPage(doctorId,patientId, name, type,page, size, status, levelConclusion, servicePackageStatus);
            return capacityAssessmentRecordService.assessmentPage(doctorId,patientId, name, type,page, size, status, levelConclusion);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
@ -503,18 +540,6 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value="getServerDoctorByPackage")
    @ApiOperation(value = "根据服务包,服务项目获取对应的服务医生")
    public ListEnvelop getServerDoctorByPackage(@ApiParam(name="packageId",value = "服务包id",required = true)
                       @RequestParam(value = "packageId")String packageId,
                       @ApiParam(name="serverItem",value = "服务项目code",required = true)
                       @RequestParam(value = "serverItem")String serverItem){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.getServerDoctorByPackage(packageId,serverItem));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
    @GetMapping(value="getServerDoctorAll")
    @ApiOperation(value = "获取所有服务医生")
@ -562,4 +587,14 @@ public class SignEndpoint extends EnvelopRestEndpoint {
        }
    }
    @GetMapping(value="signPackageDoctorList")
    @ApiOperation(value = "签约服务包医生列表")
    public ListEnvelop signPackageDoctorList(@ApiParam(name="pateint",value = "姓名或身份证",required = true)
                                      @RequestParam(value = "pateint",required = true)String pateint){
        try {
            return ListEnvelop.getSuccess("查询成功",servicePackageService.signPackageDoctorList(pateint));
        }catch (Exception e){
            return failedListEnvelopException2(e);
        }
    }
}

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

@ -14,6 +14,7 @@ import com.yihu.jw.care.dao.sign.ServicePackageSignRecordDao;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.util.ConstantUtil;
@ -24,6 +25,7 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.entity.care.securitymonitoring.BaseEmergencyWarnLogDO;
import com.yihu.jw.entity.care.securitymonitoring.EmergencyWarnConclusionDO;
@ -39,6 +41,7 @@ import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.restmodel.emergency.EmergencyOrderVO;
import com.yihu.jw.restmodel.web.PageEnvelop;
import com.yihu.jw.util.common.IdCardUtil;
import com.yihu.jw.util.date.DateUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import com.yihu.mysql.query.BaseJpaService;
import org.apache.commons.lang3.StringUtils;
@ -103,7 +106,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    @Autowired
    private BaseEmergencyWarnLogDao logDao;
    @Autowired
    private SecurityMonitoringOrderDao securityMonitoringOrderDao;
    private ContactsService contactsService;
    /**
     * 新建居民紧急救助
@ -121,7 +124,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            result.put(ResponseContant.resultMsg,failMsg);
            return result;
        }
        if (emergencyAssistanceDao.findByPatientAndStatus(patient,EmergencyAssistanceDO.Status.apply.getType())!=null){
        if (emergencyAssistanceDao.findByPatientAndStatus(patient,EmergencyAssistanceDO.Status.apply.getType()).size()>0){
            String failMsg = "当前居民存在发起中工单,请完成后再申请";
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,failMsg);
@ -285,7 +288,14 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        emergencyOrderVO.setPhone(assistanceDO.getPatientPhone());
        List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(assistanceDO.getId());
        for (BaseEmergencyWarnLogDO tmp:logDOS){
            tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(),tmp.getCreateTime()));
        }
        emergencyOrderVO.setOrderLogInfo(logDOS);
        List<PatientSosContactsDO> contactsDOS = contactsService.getPatientSosContacts(assistanceDO.getPatient());
        emergencyOrderVO.setSosContacts(contactsDOS);
        List<Map<String,Object>> securityDevices = patientDeviceService.patientEmeDeviceList(assistanceDO.getPatient());
        emergencyOrderVO.setSecurityDevices(securityDevices);
        if(StringUtils.isNotBlank(patientDO.getIdcard())){
            emergencyOrderVO.setAge((IdCardUtil.getAgeForIdcard(patientDO.getIdcard()))+"");

+ 2 - 11
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/consult/ConsultTeamService.java

@ -14,9 +14,7 @@ import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.assistance.EmergencyAssistanceDO;
import com.yihu.jw.entity.care.doorCoach.BaseDoorCoachOrderDO;
import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.hospital.message.dao.SystemMessageDao;
import com.yihu.jw.im.dao.ConsultDao;
@ -24,23 +22,16 @@ import com.yihu.jw.im.dao.ConsultTeamDao;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.sms.service.TXYSmsService;
import com.yihu.jw.sms.service.ZBSmsService;
import com.yihu.jw.utils.EntityUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import static com.yihu.jw.rm.hospital.BaseHospitalRequestMapping.PatientIM.patientInfo;
/**
 * Created by yeshijie on 2020/12/23.
 */
@ -233,7 +224,7 @@ public class ConsultTeamService {
        }
        //加入团队医生
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient,"emergencyAssistance");
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient);
        for(Map<String,Object> map:doctorList){
            participants.put(String.valueOf(map.get("id")), 0);
        }
@ -440,7 +431,7 @@ public class ConsultTeamService {
        //加入团队医生
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient,"preventLost");
        List<Map<String,Object>> doctorList = servicePackageService.fingdDoctorByPaitenId(patient);
        for(Map<String,Object> map:doctorList){
            participants.put(String.valueOf(map.get("id")), 0);
        }

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

@ -1,10 +1,13 @@
package com.yihu.jw.care.service.contacts;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.contacts.BasePatientContactsOrgDao;
import com.yihu.jw.care.dao.contacts.PatientSosContactsDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.care.dao.family.PatientFamilyMemberDao;
import com.yihu.jw.care.service.device.NetworkCardService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
import com.yihu.jw.care.service.sign.ServicePackageService;
@ -12,20 +15,24 @@ import com.yihu.jw.entity.base.org.BaseOrgDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.base.patient.BasePatientFamilyMemberDO;
import com.yihu.jw.entity.care.contacts.BasePatientContactsOrgDO;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.org.dao.BaseOrgDao;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.restmodel.ResponseContant;
import com.yihu.jw.util.common.LatitudeUtils;
import org.apache.commons.collections.map.HashedMap;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.xml.crypto.Data;
import java.util.*;
import java.util.stream.Collectors;
/**
 * Created with IntelliJ IDEA.
@ -55,6 +62,10 @@ public class ContactsService {
    private BaseOrgDao baseOrgDao;
    @Autowired
    private ServicePackageService servicePackageService;
    @Autowired
    private PatientSosContactsDao sosContactsDao;
    @Autowired
    private NetworkCardService networkCardService;
    /**
     * 查找居民联系服务站
@ -126,7 +137,7 @@ public class ContactsService {
    }
    /**
     * 设置一键联系人
     * 设置一键联系人  未使用
     * @param fid
     * @param patient
     */
@ -202,4 +213,160 @@ public class ContactsService {
        return result;
    }
    /**
     * 获取居民紧急联系人
     */
    public List<PatientSosContactsDO> getPatientSosContacts(String patient){
        List<PatientSosContactsDO> sosContactsDOS = sosContactsDao.findByPatientAndDel(patient,1);
        for (PatientSosContactsDO tmp:sosContactsDOS){
            tmp.setRelationName(PatientFamilyMemberService.relations.get(tmp.getRelation()));
        }
        return sosContactsDOS;
    }
    /**
     *设置居民紧急联系人
     */
    public JSONObject updatePatientSosContacts(String patient,String num,Integer operType,String name,String relation) throws Exception {
        JSONObject result = new JSONObject();
        List<PatientSosContactsDO> list = sosContactsDao.findByPatientOrderByUpdateTimeDesc(patient);
        if (4==operType){//一个月只能删除一次
            if (list.size()>0){
                Date updateTime = list.get(0).getUpdateTime();
                if (null==updateTime){
                }else {
                    Long timeDiffer = DateUtil.timeDifference(new Date(),updateTime);
                    if (timeDiffer<=(1000L*3600*24*30)){
                        Long day = (1000L*3600*24*30-timeDiffer)/(1000L*3600*24)+1;
                        result.put(ResponseContant.resultFlag,ResponseContant.fail);
                        result.put(ResponseContant.resultMsg,"您本月删除紧急联系人次数已使用,请"+day+"天后再试");
                        return result;
                    }
                }
                String[] numTmp = num.split("_");
                String sql = " select pd.device_sn,wd.sim from  wlyy_patient_device pd inner join wlyy_devices wd  " +
                        "on pd.device_sn = wd.device_code and pd.del=0 and wd.sim is not null and pd.category_code in('7','4')  " +
                        "where pd.user='"+patient+"' ";
                List<Map<String,Object>> sims = jdbcTemplate.queryForList(sql);
                //修改
                delSosNumber(sims,patient,numTmp);
            }else {
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"该用户已无紧急联系人");
                return result;
            }
        }
        if (1==operType){//新增联系人
            list = sosContactsDao.findByPatientAndDel(patient,1);
            Integer seqid=1;
            if (list.size()>=2){
                result.put(ResponseContant.resultFlag,ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"该用户紧急联系人已上线");
                return result;
            }
            else {
                if (list.size()>0){
                    seqid = list.get(0).getPhoneSeqid();
                }
                PatientSosContactsDO contactsDO = new PatientSosContactsDO();
                list = sosContactsDao.findByPatientAndDel(patient,0);
                if (list.size()>0) {
                    contactsDO =list.get(0);
                }
                else {
                    contactsDO.setPhoneSeqid(1==seqid?2:1);
                }
                contactsDO.setDel(1);
                contactsDO.setPatient(patient);
                contactsDO.setSosName(name);
                contactsDO.setSosPhone(num);
                contactsDO.setRelation(relation);
                contactsDO.setSuccessFlag(0);
                sosContactsDao.save(contactsDO);
            }
        }
        result.put(ResponseContant.resultFlag,ResponseContant.success);
        result.put(ResponseContant.resultMsg,"修改成功");
        return result;
    }
    public void delSosNumber(List<Map<String,Object>> sims,String patient,String[] numTmp) {
        String delSuccess = "";//白名单删除号码
        for (Map<String,Object> simTmp : sims) {
            String sim = simTmp.get("sim").toString();
            try {
                JSONArray respons = networkCardService.getPatientContacts(sim, null, null, null);
                List<Map<String, Object>> memberArr = null;
                if (respons.size() > 0) {
                    respons.getJSONObject(0).getJSONArray("memVoiceWhiteList");
                    memberArr = (List<Map<String, Object>>) JSONArray.parse(respons.getJSONObject(0).getJSONArray("memVoiceWhiteList").toJSONString());
                    List<String> WhiteList = memberArr.stream().map(e -> e.get("whiteNumber").toString()).collect(Collectors.toList());
                    String del_num = "";
                    if (WhiteList.contains(numTmp[0])) {
                        del_num = numTmp[0];
                    }
                    if (numTmp.length == 2) {
                        if (WhiteList.contains(numTmp[1])) {
                            if (StringUtils.isNotBlank(del_num)) {
                                del_num += "_" + numTmp[1];
                            } else {
                                del_num = numTmp[1];
                            }
                        }
                    }
                    if (StringUtils.isNotBlank(del_num)) {
//                        String response = networkCardService.setPatientContacts(sim, null, null, "4", del_num, null);
//                        if (StringUtils.isNotBlank(response)) {
                        if (StringUtils.isNotBlank("111")) {//todo 对接时不做
                            String[] DelNums = del_num.split("_");
                            for (String tmp:DelNums){
                                if (!delSuccess.contains(tmp)){//本次已删除过 不再作删除操作
                                    String deviceCode = simTmp.get("device_sn").toString();
                                    JSONObject aqgDeviceInfo = patientDeviceService.getAqgDeviceInfo(deviceCode);
                                    JSONArray aqgDeviceSosNum = aqgDeviceInfo.getJSONArray("sos_numbers");
                                    Integer numIndex=0;
                                    for (int i=0;i<aqgDeviceSosNum.size();i++){
                                        JSONObject aqgTmp = aqgDeviceSosNum.getJSONObject(i);
                                        String aqgNum = aqgTmp.getString("num");
                                        if (aqgNum.equals(tmp)){
                                            numIndex = aqgTmp.getInteger("seqid");
                                            break;
                                        }
                                    }
                                    if (numIndex!=0){
                                      JSONObject response2 =  patientDeviceService.updAqgDeviceSosInfo(deviceCode,numIndex+"",null,null,null,"1");
                                      if (response2.getBoolean("success")){
                                          delSuccess += "_"+tmp;
                                      }
                                    }
                                }
                            }
                        }
                    }
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        //保存修改记录
        List<PatientSosContactsDO> modify = new ArrayList<>();
        for (String num:numTmp){
            if (StringUtils.isNotBlank(num)){
                PatientSosContactsDO patientSosContactsDO = sosContactsDao.findByPatientAndSosPhone(patient,num);
                patientSosContactsDO.setUpdateTime(new Date());
                patientSosContactsDO.setDel(0);
                if (delSuccess.contains(num)){
                    patientSosContactsDO.setSuccessFlag(2);
                }
                else {
                    patientSosContactsDO.setSuccessFlag(-2);
                }
                modify.add(patientSosContactsDO);
            }
        }
        sosContactsDao.save(modify);
    }
}

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

@ -74,7 +74,7 @@ public class NetworkCardService {
        if (!flag&&StringUtils.isNotBlank(imsi)){
            params.add(new BasicNameValuePair("imsi", imsi));
        }
        params.add(new BasicNameValuePair("groupId", groupId));
        params.add(new BasicNameValuePair("groupId", NetworkCardConfig.groupId));
        params.add(new BasicNameValuePair("token", getAccessToken()));
        String response = httpClientUtil.get(NetworkCardConfig.getPatientContacts,params,"UTF-8");
@ -82,7 +82,9 @@ public class NetworkCardService {
        if (responseBody.getInteger("status")==0){
            JSONArray tmp = responseBody.getJSONArray("result");
            return tmp;
        }else {
        }else if (responseBody.getInteger("status")==14008){//未查询到数据白名单列表为空
            return new JSONArray();
        }else{
            throw new Exception(response);
        }
    }
@ -101,7 +103,7 @@ public class NetworkCardService {
        if (!flag&&StringUtils.isNotBlank(imsi)){
            params.add(new BasicNameValuePair("imsi", imsi));
        }
        params.add(new BasicNameValuePair("groupId", groupId));
        params.add(new BasicNameValuePair("groupId", NetworkCardConfig.groupId));
        params.add(new BasicNameValuePair("token", getAccessToken()));
        params.add(new BasicNameValuePair("operType", operType));
        params.add(new BasicNameValuePair("whiteNumber", whiteNumber));
@ -112,7 +114,7 @@ public class NetworkCardService {
            JSONObject tmp = responseBody.getJSONArray("result").getJSONObject(0);
            return tmp.getString("orderNum");
        }else {
            throw new Exception(response);
            throw new Exception("物联网卡操作失败:"+response);
        }
    }

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

@ -461,6 +461,17 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
        return jdbcTemplate.queryForList(sql);
    }
    public List<Map<String,Object>> patientEmeDeviceList(String patient){
        String sql = "select dd.photo,pd.device_sn,dd.brands,dd.category_code,dd.model,pd.device_name,date_format(pd.czrq,'%Y-%m-%d %H:%i:%S' ) deviceTime " +
                "from dm_device dd INNER JOIN wlyy_patient_device pd on dd.category_code = pd.category_code INNER JOIN wlyy_devices wd on dd.model = wd.device_model and pd.device_sn = wd.device_code \n" +
                "where 1=1 and  pd.del=0 ";
        if (StringUtils.isNotBlank(patient)) {
            sql += " and  pd.`user`='" + patient + "' ";
        }
        sql+=" and dd.service_topic is not null order by pd.czrq asc ";
        return jdbcTemplate.queryForList(sql);
    }
    public JSONArray getDeviceByDeviceSn(String deviceSn, String type) {
        List<DevicePatientDevice> list = patientDeviceDao.findByDeviceSnAndCategoryCode(deviceSn, type);
        JSONArray objects = new JSONArray();
@ -804,6 +815,7 @@ public class PatientDeviceService extends BaseJpaService<DevicePatientDevice, Pa
    |
     */
    public com.alibaba.fastjson.JSONObject updAqgDeviceSosInfo(String deviceSn,String seqid,String name,String num,String dial_flag,String clear){
        //先对移动接口限制做判断。
        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
        String url ="";
        if ("4".equals(devices.get(0).getCategoryCode())){//手表

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

@ -546,4 +546,5 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
        return result;
    }
}

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

@ -214,10 +214,7 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        result.put(ResponseContant.resultFlag, ResponseContant.success);
        result.put(ResponseContant.resultMsg,"修改成功");
        if(jsonObject1!=null){
            result = servicePackageService.servicePackageSign(jsonObject1.toJSONString(),doctorId,patientBrief.getId());
            if (result.getIntValue(ResponseContant.resultFlag) == ResponseContant.success) {
                servicePackageService.setPatientServiceItems(patientBrief.getId());
            }
//            result = servicePackageService.servicePackageSign(jsonObject1.toJSONString(),doctorId,patientBrief.getId());
        }
        return result;
    }
@ -571,4 +568,21 @@ public class CarePatientService extends BaseJpaService<BasePatientDO, BasePatien
        }
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
    public void intiPatient(){
        String sql = "SELECT * from base_patient WHERE residential_area is not null and `password` is null";
        List<BasePatientDO> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper(BasePatientDO.class));
        for (BasePatientDO patient:list){
            patient.setEnabled(1);
            patient.setLocked(0);
            String salt = UUID.randomUUID().toString().substring(0,5);
            String idcard = patient.getIdcard();
            String  pw = idcard.substring(idcard.length()-6);
            patient.setPassword(MD5.md5Hex(pw + "{" + salt + "}"));
            patient.setSalt(salt);
        }
        patientDao.save(list);
    }
}

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

@ -10,6 +10,7 @@ import com.yihu.jw.care.dao.security.*;
import com.yihu.jw.care.dao.team.BaseTeamMemberDao;
import com.yihu.jw.care.service.common.DictService;
import com.yihu.jw.care.service.consult.ConsultTeamService;
import com.yihu.jw.care.service.contacts.ContactsService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.care.service.device.YsDeviceService;
import com.yihu.jw.care.service.family.PatientFamilyMemberService;
@ -18,6 +19,7 @@ import com.yihu.jw.care.util.ConstantUtil;
import com.yihu.jw.care.util.CountDistance;
import com.yihu.jw.entity.base.im.ConsultDo;
import com.yihu.jw.entity.base.im.ConsultTeamDo;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import com.yihu.jw.entity.hospital.message.SystemMessageDO;
import com.yihu.jw.im.dao.ConsultDao;
import com.yihu.jw.im.dao.ConsultTeamDao;
@ -107,6 +109,8 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
    private YsDeviceService ysDeviceServicel;
    @Autowired
    private BaseEmergencyWarnLogDao logDao;
    @Autowired
    private ContactsService contactsService;
    private Logger logger = LoggerFactory.getLogger(SecurityMonitoringOrderService.class);
@ -271,7 +275,15 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        }
        List<BaseEmergencyWarnLogDO> logDOS = logDao.findByOrderIdOrderByCreateTimeDesc(orderDO.getId());
        for (BaseEmergencyWarnLogDO tmp:logDOS){
            tmp.setTimeInfo(DateUtil.getDifferentTimeInfo(new Date(),tmp.getCreateTime()));
        }
        emergencyOrderVO.setOrderLogInfo(logDOS);
        List<PatientSosContactsDO> contactsDOS = contactsService.getPatientSosContacts(orderDO.getPatient());
        emergencyOrderVO.setSosContacts(contactsDOS);
        List<Map<String,Object>> securityDevices = patientDeviceService.patientEmeDeviceList(orderDO.getPatient());
        emergencyOrderVO.setSecurityDevices(securityDevices);
        if(StringUtils.isNotBlank(patientDO.getIdcard())){
            emergencyOrderVO.setAge((IdCardUtil.getAgeForIdcard(patientDO.getIdcard()))+"");
@ -1227,15 +1239,19 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
            }
        }
        if ((StringUtils.isNotBlank(topicItem)&&"preventFall".equals(topicItem))||StringUtils.isBlank(topicItem)){
            String sql = " select count(id) from base_security_monitoring_order where patient='"+patient+"' and topic_item='preventFall' and status="+SecurityMonitoringOrderDO.Status.apply.getType();
            Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
            if (count>0){
                result.put("fall",true);
            }
            List<DevicePatientDevice> devicePatientDeviceDos = patientDeviceDao.findByUserAndCategoryCode(patient,"12");
            if (devicePatientDeviceDos.size()==0){
            }
            else{
                String sql = " select count(id) from base_security_monitoring_order where patient='"+patient+"' and topic_item='preventFall' and status="+SecurityMonitoringOrderDO.Status.apply.getType();
                Integer count = jdbcTemplate.queryForObject(sql,Integer.class);
                if (count>0){
                    result.put("fall",true);
                }
                else {
                    result.put("fall",false);
                }
                try {
                    JSONObject monitorUrl = ysDeviceServicel.getDeviceLiveAddress(patient,devicePatientDeviceDos.get(0).getDeviceSn(),1,null);
                    result.put("monitorInfoStatus",monitorUrl.getIntValue(ResponseContant.resultFlag));

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

@ -6,9 +6,7 @@ import com.yihu.jw.care.dao.sign.ArchiveDao;
import com.yihu.jw.doctor.dao.BaseDoctorDao;
import com.yihu.jw.doctor.dao.BaseDoctorHospitalDao;
import com.yihu.jw.entity.base.doctor.BaseDoctorDO;
import com.yihu.jw.entity.base.doctor.BaseDoctorHospitalDO;
import com.yihu.jw.entity.base.patient.BasePatientDO;
import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.dao.BasePatientMedicareCardDao;
@ -95,7 +93,7 @@ public class ArchiveService extends BaseJpaService<ArchiveDO, ArchiveDao> {
            filters += " and a.sign_status = "+signStatus;
        }
        if(StringUtils.isNotBlank(name)){
            filters += " and p.name like '%"+name+"%'";
            filters += " and (p.name like '%"+name+"%' or p.idcard like '%"+name+"%')";
        }
        if (signStatus!=null&&signStatus==1){//已签约不按建档查询,只要该居民服务医生就在列表中
            filters+=" UNION " +

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

@ -143,8 +143,8 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
    }
    public PageEnvelop<List<Map<String,Object>>> assessmentPage(String doctorId,String patientId,String name,int type, int page, int size,
                    Integer status,Integer levelConclusion,Integer servicePackageStatus){
        String sql = "SELECT c.id,c.patient,c.assessment_time,c.service_package_status servicePackageStatus, " +
                    Integer status,Integer levelConclusion){
        String sql = "SELECT c.id,c.patient,c.assessment_time, " +
                "c.`status`,c.level_conclusion levelConclusion,c.org_code orgCode,c.org_name orgName,p.name,p.photo,p.mobile,p.sex,p.idcard  ";
        String countSql = "SELECT count(*) ";
@ -167,9 +167,6 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
        if(levelConclusion!=null){
            filters += " and c.level_conclusion = "+levelConclusion;
        }
        if(servicePackageStatus!=null){
            filters += " and c.service_package_status = "+servicePackageStatus;
        }
        if(!StringUtil.isEmpty(name)){
            filters += " and (c.name like '%"+name+"%' or c.idcard like '%"+name+"%') ";
        }
@ -183,7 +180,6 @@ public class CapacityAssessmentRecordService extends BaseJpaService<CapacityAsse
            map.put("assessmentTime", map.get("assessment_time").toString().substring(0,19));
            map.put("age", IdCardUtil.getAgeForIdcard(idcard));
            map.put("levelConclusionName",dictService.fingByNameAndCode(ConstantUtil.DICT_LEVEL_CONCLUSION,String.valueOf(map.get("levelConclusion"))));
            map.put("servicePackageStatusName",dictService.fingByNameAndCode(ConstantUtil.DICT_SERVICEPACKAGESTATUS,String.valueOf(map.get("servicePackageStatus"))));
            map.put("statusName",dictService.fingByNameAndCode(ConstantUtil.DICT_CAPACITY_AGREE_STATUS,String.valueOf(map.get("status"))));
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);

+ 143 - 117
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/sign/ServicePackageService.java

@ -14,7 +14,6 @@ import com.yihu.jw.entity.base.servicePackage.ServicePackageRecordDO;
import com.yihu.jw.entity.base.servicePackage.ServicePackageSignRecordDO;
import com.yihu.jw.entity.care.apply.PatientBedApplyDo;
import com.yihu.jw.entity.care.archive.ArchiveDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
import com.yihu.jw.im.util.ImUtil;
import com.yihu.jw.patient.dao.BasePatientDao;
import com.yihu.jw.patient.service.BasePatientMedicardCardService;
@ -87,11 +86,11 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                "FROM " +
                " base_service_package_sign_record sr, " +
                " base_service_package_record r, " +
                " base_service_package_item i, " +
                " base_service_package i, " +
                " base_org o " +
                "WHERE " +
                " sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"' " +
                "AND r.service_package_id = i.service_package_id " +
                "AND r.service_package_id = i.id " +
                "AND i.del = 1 " +
                "and i.org_code = o.code " +
                "AND sr.`status` = 1 ";
@ -120,12 +119,12 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                "FROM " +
                " base_service_package_sign_record sr, " +
                " base_service_package_record r, " +
                " base_service_package_item i, " +
                " base_service_package i, " +
                " base_team_member m,base_doctor d  " +
                "WHERE " +
                " sr.id = r.sign_id and sr.status=1 and sr.patient = '"+patient+"'" +
                " AND r.service_package_id = i.service_package_id " +
                "AND i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                " AND r.service_package_id = i.id " +
                "AND i.del = 1  and m.team_code = r.team_code and sr.id=r.sign_id and m.doctor_code = d.id " +
                "               and m.del = '1'";
        if(StringUtils.isNoneBlank(orgCode)){
            sql += " and i.org_code = '"+orgCode+"' " ;
@ -134,39 +133,6 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return list;
    }
    /**
     * 获取居民签约的服务项
     * @param patientId
     * @return
     */
    public List<String> getPatientServiceItems(String patientId){
        String key = "serviceItem:"+patientId;
        List<String> res;
        if(redisTemplate.hasKey(key)){
            long size = redisTemplate.opsForList().size(key);
            res = redisTemplate.opsForList().range(key,0,size);
        }else{
            res = fingServiceItemsCodeByPatientId(patientId);
            redisTemplate.opsForList().leftPushAll(key,res);
        }
        return res;
    }
    /**
     * 每次修改服务项重新设置res的服务项值
     * @param patientId
     */
    public void setPatientServiceItems(String patientId){
        String key = "serviceItem:"+patientId;
        if(redisTemplate.hasKey(key)){
            redisTemplate.delete(key);
        }
        List<String> res = fingServiceItemsCodeByPatientId(patientId);
        if(res!=null&&res.size()>0){
            redisTemplate.opsForList().leftPushAll(key,res);
        }
    }
    /**
     * 查找居民的签约服务项
@ -174,7 +140,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @return
     */
    public List<Map<String,Object>> fingServiceItemsByPatientId(String patientId){
        String sql = "SELECT DISTINCT i.code,i.name,i.team_code from base_service_package_sign_record sr,base_service_package_record r, " +
        String sql = "SELECT DISTINCT i.code,i.name,r.team_code from base_service_package_sign_record sr,base_service_package_record r, " +
                " base_service_package_item i  where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "  and i.del = 1 and sr.`status`=1 and  sr.patient  = '"+patientId+"' ";
        return jdbcTemplate.queryForList(sql);
@ -216,10 +182,8 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @param signId
     */
    public List<Map<String,Object>> fingdDoctorBySignId(String signId,Integer level){
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m,base_doctor d " +
                "WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor d " +
                "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 d.doctor_level = " + level+
                " and sr.id = '"+signId+"' ";
        return jdbcTemplate.queryForList(sql);
@ -229,29 +193,13 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * 根据居民和服务项查找医生
     * @param patientId
     */
    public List<Map<String,Object>> fingdDoctorByPaitenId(String patientId,String serviceItem){
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r,  " +
                "               base_service_package_item i,base_team_member m,base_doctor d  " +
                "               WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id  " +
                "               and i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                "               and m.del = '1' and sr.patient = '"+patientId+"' " +
                "and i.`code` = '"+serviceItem+"'";
    public List<Map<String,Object>> fingdDoctorByPaitenId(String patientId){
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_doctor d  " +
                "               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 = '"+patientId+"' " ;
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 根据服务包id查找医生/助老员
     * @param packageId
     */
    public List<Map<String,Object>> fingdDoctorByPackageId(String packageId,Integer level){
        String sql = "SELECT DISTINCT d.id,d.name from base_service_package_record r, " +
                "base_service_package_item i,base_team_member m,base_doctor d " +
                "WHERE r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and m.doctor_code = d.id " +
                "and m.del = '1' and d.doctor_level = " + level+
                " and r.id = '"+packageId+"' ";
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 根据签约记录查找服务包
@ -277,11 +225,9 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        String sql = "SELECT DISTINCT sr.patient,sr.id,sr.start_time,p.name,p.sex,p.idcard,p.openid,p.photo ";
        String countSql = "SELECT count(DISTINCT sr.patient) ";
        String filters = " from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m,base_patient p " +
                "WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code and p.id = sr.patient " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1 ";
        String filters = " from base_service_package_sign_record sr,base_service_package_record r,base_team_member m,base_patient p " +
                "WHERE  sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id and p.id = sr.patient " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1'  ";
        if(!StringUtil.isEmpty(name)){
            filters += " and sr.name like '%"+name+"%' ";
@ -309,11 +255,9 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @return
     */
    public int getSignTotal(String doctorId){
        String sql = "SELECT COUNT(DISTINCT sr.patient) from base_service_package_sign_record sr,base_service_package_record r, " +
                "base_service_package_item i,base_team_member m " +
                "WHERE sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id " +
                "and i.del = 1 and m.team_code = i.team_code " +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' and sr.`status`=1 ";
        String sql = "SELECT COUNT(DISTINCT sr.patient) from base_service_package_sign_record sr,base_service_package_record r,base_team_member m " +
                "WHERE sr.status=1 and m.team_code = r.team_code and sr.id=r.sign_id" +
                "and m.doctor_code = '"+doctorId+"' and m.del = '1' ";
        return jdbcTemplate.queryForObject(sql,Integer.class);
    }
@ -324,11 +268,12 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
     * @param doctorId
     */
    @Transactional(rollbackFor = Exception.class)
    public JSONObject servicePackageSign(String jsonData,String doctorId,String patientId) throws Exception{
    public JSONObject servicePackageSign(String jsonData,String doctorId,String patientId,String signYear) throws Exception{
        BasePatientDO patientDO = patientDao.findById(patientId);
        JSONObject result = new JSONObject();
        ServicePackageSignRecordDO signRecordDO = objectMapper.readValue(jsonData, ServicePackageSignRecordDO.class);
        signRecordDO.setPatient(patientId);
        signRecordDO.setName(patientDO.getName());
        List<ServicePackageRecordDO> recordDOList = signRecordDO.getRecordDOList();
        String signId = signRecordDO.getId();
        List<String> idList = new ArrayList<>();
@ -338,9 +283,15 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                BaseDoctorDO doctorDO = doctorDao.findById(doctorId);
                //需要新增签约记录
                signRecordDO.setStatus(1);
                int year;
                if("0".equals(signYear)){
                    year = 100;
                }else{
                    year = Integer.valueOf(signYear);
                }
                signRecordDO.setStartTime(new Date());
                Calendar cal = Calendar.getInstance();
                cal.add(Calendar.YEAR,1);
                cal.add(Calendar.YEAR,year);
                signRecordDO.setEndTime(cal.getTime());
                signRecordDO.setSignDoctor(doctorId);
                signRecordDO.setSignDoctorName(doctorDO.getName());
@ -354,15 +305,24 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
                    archiveDao.save(archiveDO);
                }
            }else{
                ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patientId,doctorId);
                if(archiveDO!=null){
                    archiveDO.setSignStatus(1);
                    archiveDao.save(archiveDO);
                }
                signId = signRecordDOs.get(0).getId();
                List<ServicePackageRecordDO> existList = servicePackageRecordDao.findBySignId(signId);
                idList = existList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
                //不能重复签约
                result.put(ResponseContant.resultFlag, ResponseContant.fail);
                result.put(ResponseContant.resultMsg,"请勿重复签约");
                return result;
//                ArchiveDO archiveDO = archiveDao.findByPatientAndDoctorCode(patientId,doctorId);
//                if(archiveDO!=null){
//                    archiveDO.setSignStatus(1);
//                    archiveDao.save(archiveDO);
//                }
//                signId = signRecordDOs.get(0).getId();
//                List<ServicePackageRecordDO> existList = servicePackageRecordDao.findBySignId(signId);
//                idList = existList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
            }
        }else{
            //不能重复签约
            result.put(ResponseContant.resultFlag, ResponseContant.fail);
            result.put(ResponseContant.resultMsg,"请勿重复签约");
            return result;
        }
        //服务项目 emergencyAssistance 只能签约一个
@ -376,12 +336,12 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
            ServicePackageRecordDO recordDO = iterator.next();
            recordDO.setPatient(patientId);
            recordDO.setSignId(signId);
            if (idList.contains(recordDO.getServicePackageId())) {
                iterator.remove();//使用迭代器的删除方法删除
            }
//            if (idList.contains(recordDO.getServicePackageId())) {
//                iterator.remove();//使用迭代器的删除方法删除
//            }
        }
        if(recordDOList.size()>0){
/*        if(recordDOList.size()>0){
            List<String> packages = recordDOList.stream().map(ServicePackageRecordDO::getServicePackageId).collect(Collectors.toList());
            String packagesId = packages.stream().map(String::valueOf).collect(Collectors.joining("','"));
            sqlItem = "select item.`code`,item.name from base_service_package_item item " +
@ -392,10 +352,10 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
               String message = "重复签约服务项目:"+newItem.get("emergencyAssistance").get(0).get("name").toString();
               throw new Exception(message);
           }
        }
        CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
        capacityAssessmentRecordDO.setServicePackageStatus(1);
        capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
        }*/
//        CapacityAssessmentRecordDO capacityAssessmentRecordDO = capacityAssessmentRecordService.findAssessmentByPatientId(patientId);
//        capacityAssessmentRecordDO.setServicePackageStatus(1);
//        capacityAssessmentRecordService.save(capacityAssessmentRecordDO);
        servicePackageRecordDao.save(recordDOList);
        //修改床位生请状态为已完成
@ -410,15 +370,31 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return result;
    }
    public List<ServicePackageDO> findServicePackageByOrgCode( String orgCode){
        String sql = "SELECT p.*  ";
        String filters = "from base_service_package p " +
                "WHERE p.del = 1 ";
        if(!StringUtil.isBlank(orgCode)){
            filters += " and p.org_code = '"+orgCode+"'";
        }
        filters += " ORDER BY p.create_time DESC ";
        List<ServicePackageDO> list = jdbcTemplate.query(sql+filters,new BeanPropertyRowMapper<>(ServicePackageDO.class));
        return list;
    }
    public PageEnvelop<List<Map<String,Object>>> servicePackagePage(int page, int size){
    public PageEnvelop<List<Map<String,Object>>> servicePackagePage(int page, int size,String orgCode){
        String sql = "SELECT p.id,p.`name`,p.type,p.introduce,p.num  ";
        String countSql = "SELECT count(*) ";
        String filters = "from base_service_package p " +
                "WHERE p.del = 1 ";
        if(!StringUtil.isBlank(orgCode)){
            filters += " and p.org_code = '"+orgCode+"'";
        }
        String orderBy = " ORDER BY p.create_time DESC " +
                "LIMIT "+ (page - 1) * size + "," + size;
@ -428,10 +404,6 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
            String id = map.get("id").toString();
            List<ServicePackageItemDO> itemDOList = servicePackageItemDao.findByServicePackageId(id);
            map.put("detail",itemDOList);
            List<Map<String,Object>> doctorList = fingdDoctorByPackageId(id,1);
            List<Map<String,Object>> helperList = fingdDoctorByPackageId(id,2);
            map.put("doctorList",doctorList);
            map.put("helperList",helperList);
        }
        Long count = jdbcTemplate.queryForObject(countSql+filters,Long.class);
        return PageEnvelop.getSuccessListWithPage("success",list,page,size,count);
@ -501,8 +473,7 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
    public List<Map<String, Object>> servicePackageByTopicType(String patient, String topicType)
    {
        String sql="\n" +
                "select  DISTINCT item.code serverItem,item.name,pack.introduce,pack.type packageType,pack.`name` packageName \n" +
        String sql="select  DISTINCT item.code serverItem,item.name,pack.introduce,pack.type packageType,pack.`name` packageName \n" +
                "from base_service_package_record re, base_service_package_item item,base_service_package pack \n" +
                "where re.service_package_id = item.service_package_id and item.service_package_id = pack.id\n" +
                " and pack.del=1 and  item.topic_item='"+topicType+"' and re.sign_id in (\n" +
@ -511,24 +482,11 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        return result;
    }
    public List<Map<String,Object>> getServerDoctorByPackage(String packageId,String serverItem){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,\n" +
                "CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile\n" +
                "from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
                "where item.`code`='"+serverItem+"' and item.service_package_id='"+packageId+"' and item.service_package_id = pack.id " +
                "and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 and pack.del=1 ";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        return result;
    }
    public List<Map<String,Object>> getServerDoctorAll(String patient,String onlineFlag){
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,0 as onLineFlag\n" +
                "from base_service_package_item item ,base_service_package pack,base_team_member mem,base_doctor doc\n" +
                "where item.service_package_id in (\n" +
                "SELECT spc.service_package_id FROM base_service_package_record spc ,base_service_package_sign_record spsr\n" +
                "WHERE spc.patient = '"+patient+"' AND spsr.status = 1 AND spsr.patient = spc.patient\n" +
                ") and item.service_package_id = pack.id\n" +
                "and item.team_code = mem.team_code and mem.doctor_code = doc.id and mem.del=1 and pack.del=1 and item.del = 1";
        String sql="select DISTINCT doc.id doctor,CONCAT(doc.`name`,CASE WHEN doc.doctor_level=1 THEN '(社区医生)' ELSE '(助老员)' END) as name,doc.photo,doc.mobile,0 as onLineFlag " +
                "from base_service_package_sign_record spsr,base_service_package_record r,base_team_member mem,base_doctor doc " +
                "WHERE spsr.patient = '"+patient+"' AND spsr.status = 1  " +
                "and r.team_code = mem.team_code and spsr.id=r.sign_id and mem.doctor_code = doc.id and mem.del=1 ";
        List<Map<String,Object>>result = jdbcTemplate.queryForList(sql);
        if ("1".equals(onlineFlag)){//展示是否在线
            String listStr = imUtil.getOnlineListByType("helper");
@ -582,4 +540,72 @@ public class ServicePackageService extends BaseJpaService<ServicePackageDO, Serv
        }
        return jdbcTemplate.queryForList(sql);
    }
    /**
     * 查找居民签约记录
     * @param patient
     */
    public List<Map<String,Object>> findPatientSignList(String patient){
        String sql = "SELECT r.id,r.team_code teamCode,sr.id signId, DATE_FORMAT(sr.create_time,'%Y-%m-%d %H:%i:%S') createTime, " +
                " DATE_FORMAT(sr.start_time,'%Y-%m-%d %H:%i:%S')  startTime, " +
                " DATE_FORMAT(sr.end_time,'%Y-%m-%d %H:%i:%S') endTime,p.name,sr.`status`,p.org_code orgCode,p.org_name orgName " +
                "FROM " +
                " base_service_package_sign_record sr, " +
                " base_service_package_record r, " +
                " base_service_package p " +
                "WHERE " +
                " sr.id = r.sign_id and r.service_package_id = p.id " +
                "AND sr.patient = '"+patient+"' ORDER BY sr.create_time desc";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        String doctorSql = "SELECT d.name from base_team_member t,base_doctor d WHERE t.team_code = ? and t.doctor_code = d.id and d.del = 1 and t.del =1";
        for(Map<String,Object> map:list){
            List<String> doctorList = new ArrayList<>();
            if(map.get("teamCode")!=null){
                String teamCode = map.get("teamCode")+"";
                try {
                    doctorList = jdbcTemplate.queryForList(doctorSql,String.class, teamCode);
                }catch (Exception e){
                    e.printStackTrace();
                }
            }
            map.put("doctorList",doctorList);
        }
        return list;
    }
    /**
     * 签约服务包详情
     * @param id
     */
    public Map<String,Object> signPackageDetail(String id){
        String orgSql = "SELECT o.id,o.code,o.name,o.address,o.photo FROM " +
                " base_org o, " +
                " base_service_package_record r, " +
                " base_service_package p " +
                "WHERE " +
                " p.org_code = o.code and r.service_package_id = p.id " +
                "AND r.id = '"+id+"' ";
        String doctorSql = "SELECT d.* from base_team_member t,base_doctor d,base_service_package_record r,base_service_package_sign_record sr" +
                " WHERE r.id = '"+id+"' and r.sign_id=sr.id and t.team_code = r.team_code and t.doctor_code = d.id and d.del = 1 and t.del =1";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(orgSql);
        Map<String,Object> result = list.get(0);
        List<BaseDoctorDO> doctorDOList = jdbcTemplate.query(doctorSql, new BeanPropertyRowMapper(BaseDoctorDO.class));
        result.put("doctorDOList",doctorDOList);
        return result;
    }
    /**
     * 签约服务包医生列表
     */
    public List<Map<String,Object>> signPackageDoctorList(String pateint){
        String sql = "SELECT d.id,d.name,d.photo,r.id detailId,h.org_code orgCode,h.org_name orgName,d.job_title_code jobTitleCode,d.job_title_name jobTitleName" +
                " from base_team_member t,base_doctor d,base_service_package_record r,base_service_package_sign_record sr" +
                ",base_doctor_hospital h" +
                " WHERE sr.patient = '"+pateint+"'and sr.status=1  and r.sign_id=sr.id and t.team_code = r.team_code " +
                " and t.doctor_code = d.id and d.del = 1 and t.del =1 and h.doctor_code = d.id and h.del=1";
        List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
        return list;
    }
}

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

@ -172,6 +172,7 @@ public class DeviceService {
                jsonObject.put("orgName",sqlResult.get(0).get("org_name").toString());
                jsonObject.put("patient",logDO.getPatient());
                jsonObject.put("patientName",logDO.getPatientName());
                jsonObject.put("deviceSn",logDO.getDeviceSn());
                String url = cloudCareUrl+"cloudCare/noLogin/emergency_assistance/newOrder";
                Map map = new HashMap<String, String>();
                map.put("patientId", logDO.getPatient());
@ -281,6 +282,7 @@ public class DeviceService {
                                jsonObject.put("serveLat",lat);
                                jsonObject.put("serveLon",lon);
                                jsonObject.put("topicItem","preventLost");
                                jsonObject.put("deviceSn",deviceid);
                                JSONObject jsonObjectParam = new JSONObject();
                                jsonObjectParam.put("order", jsonObject);
                                map.put("jsonData", jsonObjectParam.toJSONString());

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

@ -182,6 +182,7 @@ public class YsDeviceService {
                    jsonObject.put("serveLat",lat);
                    jsonObject.put("serveLon",lon);
                    jsonObject.put("topicItem","preventFall");
                    jsonObject.put("deviceSn",deviceSN);
                    if (StringUtils.isNotBlank(sceneUrl)){
                        jsonObject.put("sceneImg",sceneUrl);
                    }

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

@ -0,0 +1,49 @@
package com.yihu.jw.care.config;
/**
 * Created with IntelliJ IDEA.
 *
 * @Author: yeshijie
 * @Date: 2021/4/29
 * @Description: 爱牵挂配置
 */
public class AqgConfig {
    /**
     * 基础url
     */
//    public static final String baseUrl = "http://120.24.56.48:8889";//测试环境
    public static final String baseUrl = "http://api.aiqiangua.com:8888";// 正式环境
    /**
     * 登录
     */
    public static final String login = baseUrl +"/api/auth/login";
    /**
     * 获取设备信息
     */
    public static final String deviceInfo = baseUrl +"/api/device/{0}";
    /**
     * 修改亲情号码
     */
    public static final String sos_numbers = baseUrl +"/api/device/{0}/sos_numbers/{1}";
    public static final String X1sos_numbers = baseUrl +"/api/device/{0}/4g/sos_numbers/{1}";
    /**
     * 获取设备最新位置数据
     */
    public static final String device_last_locationData = baseUrl +"/api/device/{0}/data/locationdata/";
    /**
     * 设置智能手环安全区域
     */
    public static final String S3fence_area = baseUrl +"/api/device/{0}/fences/{1}";
    public static final String X1fence_area = baseUrl +"/api/device/{0}/4g/fences/{1}";
    public static final String username = "13559485270";
    public static final String password = "zjxl@2021";
    public static final String redisKey = "aqgCooker";
    /**
     * cookie时效24小时,吧过期时间设置为23 小时
     */
    public static final Long overTime = 23L;
}

+ 34 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/config/NetworkCardConfig.java

@ -0,0 +1,34 @@
package com.yihu.jw.care.config;
import com.yihu.jw.util.date.DateUtil;
/**
 * Created by Bing on 2021/8/6.
 * 电信物联网卡
 */
public class NetworkCardConfig {
    //平台地址 https://ct.cmonelink.com/zh/#/infoPanel/index
    //user:BE5714630405 password:Zjxl2008@
    //文档地址https://ec.iot.10086.cn/ecology/supportService/documents
    public static final String appid="571AIOT2021072910102922281";
    public static final String password="OnXE@QFlwt9R";
    public static final String redisKey="dianXinAssesToken";
    public static final String groupId="9911000019160041";//所有卡号均在同一分组下方便维护
    //APPID+YYYYMMDDHHMISS+8位数字序列
    public static String getTransid() {
        return appid+ DateUtil.getNo(8);
    }
    public static final String getToken="https://api.iot.10086.cn/v5/ec/get/token";
    //获取语音白名单
    public static final String getPatientContacts="https://api.iot.10086.cn/v5/ec/query/member-voice-whitelist";
    //设置语音白名单 //同一卡号一分钟只能调用该接口一次 一个月仅能删除一次(一次最多删除2个号码)
    public static final String setPatientContacts="https://api.iot.10086.cn/v5/ec/config/member-voice-whitelist";
}

+ 21 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/DeviceDao.java

@ -0,0 +1,21 @@
/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.Device;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface DeviceDao extends PagingAndSortingRepository<Device, Long> {
	@Query("select a from Device a where a.categoryCode = ?1 and a.del = '1'")
	List<Device> findByCategoryCode(String categoryCode);
	@Query("select a from Device a where a.del = '1'")
	List<Device> findAll();
}

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

@ -0,0 +1,66 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface PatientDeviceDao extends PagingAndSortingRepository<DevicePatientDevice, Long>, JpaSpecificationExecutor<DevicePatientDevice> {
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    Iterable<DevicePatientDevice> findByUser(String user);
    @Query("select a from DevicePatientDevice a where a.del = 0 ")
    List<DevicePatientDevice> findByAll();
    @Query("select a from DevicePatientDevice a where a.user = ?1 ")
    List<DevicePatientDevice> findByPatient(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.del=0 and a.deviceName like '%药盒%'")
    List<DevicePatientDevice> findByPatientAndDel(String user);
    @Query("select a from DevicePatientDevice a where a.user = ?1 and a.deviceSn=?2 ")
    List<DevicePatientDevice> findByPatientAndDeviceSn(String user, String deviceSn);
    List<DevicePatientDevice> findByUser(String user, Pageable pageRequest);
    List<DevicePatientDevice> findByUserAndDoctor(String user, String doctor, Pageable pageRequest);
    List<DevicePatientDevice> findByDeviceSnAndCategoryCode(String deviceSn, String categoryCode);
    DevicePatientDevice findByDeviceSnAndCategoryCodeAndUserType(String deviceSn, String categoryCode, String userType);
    DevicePatientDevice findByDeviceIdAndDeviceSnAndUserType(Long deviceId, String deviceSn, String userType);
    DevicePatientDevice findByDeviceSnAndUserType(String deviceSn, String userType);
    @Query("select pd from DevicePatientDevice pd where pd.deviceSn = ?1 and pd.del=0")
    List<DevicePatientDevice> findByDeviceSn(String deviceSn);
    //更换患者绑定的血糖仪
    @Modifying
    @Query("update DevicePatientDevice t set t.deviceSn = ?3 , t.userType = ?4,t.sim=?5,t.hospital=?6,t.hospitalName=?7,t.checkDoctorName=?8 where t.user = ?1 and t.deviceSn = ?2 ")
    int updatePatientDevice(String user, String deviceSN, String newDeviceSN, String userType, String sim, String hospital, String hospitalName, String checkDoctorName);
    //管理员解绑居民设备
    @Modifying
    @Query("update DevicePatientDevice t set t.del = 1  where t.deviceSn = ?1 and t.del =0  ")
    int updatePatientDevice(String deviceSN);
    @Query("select a from DevicePatientDevice a")
    List<DevicePatientDevice> findAll();
    @Modifying
    @Query("delete DevicePatientDevice a where a.deviceSn = ?1")
    int deleteByDeviceSn(String deviceSN);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.del=0")
    List<DevicePatientDevice> findAllByUser(String user);
    @Query("select a from DevicePatientDevice a where a.user=?1 and a.categoryCode =?2 and a.del=0")
    List<DevicePatientDevice> findByUserAndCategoryCode(String user,String categoryCode);
}

+ 22 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/PatientSosContactsDao.java

@ -0,0 +1,22 @@
package com.yihu.jw.care.dao.device;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
/**
 * Created by Bing on 2021/8/10.
 */
public interface PatientSosContactsDao extends PagingAndSortingRepository<PatientSosContactsDO,Long>,
        JpaSpecificationExecutor<PatientSosContactsDO> {
    List<PatientSosContactsDO> findByPatientAndDel(String patient,Integer del);
    List<PatientSosContactsDO> findByPatientOrderByUpdateTimeDesc(String patient);
    PatientSosContactsDO findByPatientAndSosPhone(String patient,String sosPhone);
    List<PatientSosContactsDO> findByDelAndAndSuccessFlag(Integer del,Integer successFlag);
}

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

@ -2,6 +2,7 @@ package com.yihu.jw.care.event;
import com.yihu.jw.care.job.QuartzHelper;
import com.yihu.jw.care.job.consult.FinishConsultJob;
import com.yihu.jw.care.job.device.PatientSosContactsJob;
import com.yihu.jw.care.job.message.DoctorSendUnreadJob;
import com.yihu.jw.care.job.message.PatientSendUnreadJob;
import com.yihu.jw.care.job.order.CancelPayOrderJob;
@ -64,6 +65,15 @@ public class ApplicationEvent implements ApplicationListener<ContextRefreshedEve
                logger.info("CANCEL_PAY_ORDER_OVERTIME_JOB exist");
            }
            //#居民紧急联系人数据同步更新每2分钟执行一次
            if (!quartzHelper.isExistJob("PATIENT_SOS_CONTACTS_JOB")) {
                String trigger = SystemConf.getInstance().getSystemProperties().getProperty("PATIENT_SOS_CONTACTS_JOB");
                quartzHelper.addJob(PatientSosContactsJob.class, trigger, "PATIENT_SOS_CONTACTS_JOB", new HashMap<String, Object>());
                logger.info("PATIENT_SOS_CONTACTS_JOB success");
            } else {
                logger.info("PATIENT_SOS_CONTACTS_JOB exist");
            }
        } catch (Exception e) {
            logger.info(" job start failed");
        }

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

@ -0,0 +1,83 @@
package com.yihu.jw.care.job.device;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.dao.device.PatientSosContactsDao;
import com.yihu.jw.care.service.device.NetworkCardService;
import com.yihu.jw.care.service.device.PatientDeviceService;
import com.yihu.jw.entity.care.contacts.PatientSosContactsDO;
import org.apache.commons.lang3.StringUtils;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * Created by Bing on 2021/8/10.
 */
@DisallowConcurrentExecution
public class PatientSosContactsJob implements Job {
    private static Logger logger = LoggerFactory.getLogger(PatientSosContactsJob.class);
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private PatientSosContactsDao sosContactsDao;
    @Autowired
    private NetworkCardService cardService;
    @Autowired
    private PatientDeviceService deviceService;
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        logger.info("PATIENT_SOS_CONTACTS_JOB start");
        String sql = " select pd.device_sn,wd.sim,sc.* from  wlyy_patient_device pd inner join wlyy_devices wd " +
                " on pd.device_sn = wd.device_code and pd.del=0 and wd.sim is not null and pd.category_code in('7','4') " +
                "INNER JOIN base_patient_sos_contacts sc on sc.patient = pd.user and sc.del=1 and sc.success_flag=0 group by wd.sim";
        List<Map<String,Object>> sims = jdbcTemplate.queryForList(sql);
        List<PatientSosContactsDO> modify = new ArrayList<>();
        for(Map<String,Object> tmp:sims){//添加白名单,添加设备联系人
            String sim = tmp.get("sim").toString() ;
            String device_sn = tmp.get("device_sn").toString() ;
            String id = tmp.get("id").toString() ;
            String sos_name = tmp.get("sos_name").toString() ;
            String sos_phone = tmp.get("sos_phone").toString() ;
            String phone_seqid = tmp.get("phone_seqid").toString() ;
            try {
                PatientSosContactsDO sosContactsDO = sosContactsDao.findOne(Long.parseLong(id));
                if(null!=sosContactsDO){
                    JSONObject response = cardService.setPatientContacts(sim, null, null, "1", sos_phone, null);//移动白名单
                    //0成功 12102名单重复
                    if (response.getInteger("status")==0||response.getInteger("status")==12108){
                        //设备修改
                        JSONObject response2 =  deviceService.updAqgDeviceSosInfo(device_sn,phone_seqid,sos_name,sos_phone,"1",null);
                        if (response2.getBoolean("success")){
                            sosContactsDO.setSuccessFlag(1);
                        }else {
                            sosContactsDO.setSuccessFlag(-1);
                        }
                        modify.add(sosContactsDO);
                    }else {
                        sosContactsDO.setSuccessFlag(-1);
                        modify.add(sosContactsDO);
                        throw new Exception("物联网卡操作失败:"+response);
                    }
                }
            }catch (Exception e){
                logger.info(sim+"--同步失败--"+sos_phone);
                e.printStackTrace();
            }
        }
        sosContactsDao.save(modify);
        logger.info("PATIENT_SOS_CONTACTS_JOB end");
    }
}

+ 121 - 0
svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java

@ -0,0 +1,121 @@
package com.yihu.jw.care.service.device;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.care.config.NetworkCardConfig;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
 * Created by Bing on 2021/8/6.
 */
@Service
public class NetworkCardService {
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    /**
     * 获取电信物联网卡assesToken
     */
    public String getAccessToken() throws Exception {
        if(redisTemplate.hasKey(NetworkCardConfig.redisKey)){
            return redisTemplate.opsForValue().get(NetworkCardConfig.redisKey);
        }
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("appid", NetworkCardConfig.appid));
        params.add(new BasicNameValuePair("password",NetworkCardConfig.password));
        params.add(new BasicNameValuePair("transid", NetworkCardConfig.getTransid()));
        String response = httpClientUtil.get(NetworkCardConfig.getToken,params,"UTF-8");
        JSONObject responseBody = JSONObject.parseObject(response);
        String assToken = null;
        if (responseBody.getInteger("status")==0){
            JSONObject tmp = responseBody.getJSONArray("result").getJSONObject(0);
            assToken = tmp.getString("token");
            Long expireTime =Long.parseLong(tmp.getString("ttl"));//token有效期
            redisTemplate.opsForValue().set(NetworkCardConfig.redisKey,assToken,expireTime, TimeUnit.SECONDS);
        }else {
            throw new Exception(response);
        }
        return assToken;
    }
    public JSONArray getPatientContacts(String msisdn, String iccid, String imsi, String groupId) throws Exception {
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("transid", NetworkCardConfig.getTransid()));
        boolean flag = false;
        if (!flag&&StringUtils.isNotBlank(msisdn)){
            params.add(new BasicNameValuePair("msisdn", msisdn));
            flag=true;
        }
        if (!flag&&StringUtils.isNotBlank(iccid)){
            params.add(new BasicNameValuePair("iccid", iccid));
        }
        if (!flag&&StringUtils.isNotBlank(imsi)){
            params.add(new BasicNameValuePair("imsi", imsi));
        }
        params.add(new BasicNameValuePair("groupId", NetworkCardConfig.groupId));
        params.add(new BasicNameValuePair("token", getAccessToken()));
        String response = httpClientUtil.get(NetworkCardConfig.getPatientContacts,params,"UTF-8");
        JSONObject responseBody = JSONObject.parseObject(response);
        if (responseBody.getInteger("status")==0){
            JSONArray tmp = responseBody.getJSONArray("result");
            return tmp;
        }else if (responseBody.getInteger("status")==14008){//未查询到数据白名单列表为空
            return new JSONArray();
        }else{
            throw new Exception(response);
        }
    }
    /**
     *
     * @param msisdn
     * @param iccid
     * @param imsi
     * @param operType  1新增 4删除
     * @param whiteNumber
     * @param groupId
     * @return
     * @throws Exception
     */
    public JSONObject setPatientContacts(String msisdn, String iccid, String imsi,String operType,String  whiteNumber,String groupId) throws Exception {
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("transid", NetworkCardConfig.getTransid()));
        boolean flag = false;
        if (!flag&&StringUtils.isNotBlank(msisdn)){
            params.add(new BasicNameValuePair("msisdn", msisdn));
            flag=true;
        }
        if (!flag&&StringUtils.isNotBlank(iccid)){
            params.add(new BasicNameValuePair("iccid", iccid));
        }
        if (!flag&&StringUtils.isNotBlank(imsi)){
            params.add(new BasicNameValuePair("imsi", imsi));
        }
        params.add(new BasicNameValuePair("groupId", NetworkCardConfig.groupId));
        params.add(new BasicNameValuePair("token", getAccessToken()));
        params.add(new BasicNameValuePair("operType", operType));
        params.add(new BasicNameValuePair("whiteNumber", whiteNumber));
        String response = httpClientUtil.get(NetworkCardConfig.setPatientContacts,params,"UTF-8");
        JSONObject responseBody = JSONObject.parseObject(response);
        return responseBody;
    }
}

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

@ -0,0 +1,221 @@
package com.yihu.jw.care.service.device;
import com.yihu.jw.care.config.AqgConfig;
import com.yihu.jw.care.dao.device.DeviceDao;
import com.yihu.jw.care.dao.device.PatientDeviceDao;
import com.yihu.jw.entity.care.device.Device;
import com.yihu.jw.entity.care.device.DevicePatientDevice;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.http.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import javax.annotation.PostConstruct;
import java.text.MessageFormat;
import java.util.*;
import java.util.concurrent.TimeUnit;
@Component
@Transactional(rollbackFor = Exception.class)
public class PatientDeviceService {
    private static Logger logger = LoggerFactory.getLogger(PatientDeviceService.class);
    @Autowired
    private StringRedisTemplate redisTemplate;
    @Autowired
    private HttpClientUtil httpClientUtil;
    @Autowired
    private PatientDeviceDao patientDeviceDao;
    @Autowired
    private GpsUtil gpsUtil;
    @Autowired
    private DeviceDao deviceDao;
    Map<Integer, String> relations = new HashMap<>();
    @PostConstruct
    public void init() {
        relations.put(0, "其他");
        relations.put(1, "父亲");
        relations.put(2, "母亲");
        relations.put(3, "老公");
        relations.put(4, "老婆");
        relations.put(5, "儿子");
        relations.put(6, "女儿");
        relations.put(7, "未知");
        relations.put(8, "免疫关联");
    }
     /******************************************* 爱牵挂设备start *****************************************************/
    /**
     * 获取爱牵挂管理员cookie
     */
    public synchronized String getCookie(){
        if(redisTemplate.hasKey(AqgConfig.redisKey)){
            return redisTemplate.opsForValue().get(AqgConfig.redisKey);
        }
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("username",AqgConfig.username);
        param.add("password",AqgConfig.password);
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.cookiePostHttp(AqgConfig.login,param);
        HttpHeaders responseHeaders = response.getHeaders();
        String cookie =  responseHeaders.get("Set-Cookie").get(0);
        logger.info("cookie="+cookie);
        redisTemplate.opsForValue().set(AqgConfig.redisKey,cookie,AqgConfig.overTime, TimeUnit.HOURS);
        return cookie;
    }
    /**
     * 获取爱牵挂设备信息
     * @param imei
     */
    public com.alibaba.fastjson.JSONObject getAqgDeviceInfo(String imei) throws Exception{
        String url = MessageFormat.format(AqgConfig.deviceInfo, imei);
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, null, HttpMethod.GET, getCookie());
        com.alibaba.fastjson.JSONObject json = response.getBody();
        if(!json.getBoolean("success")){
             throw new Exception(json.getString("error_desc")) ;
        }
        return json.getJSONObject("obj");
    }
    /**
     * 修改删除 爱牵挂亲情号码
     * @param deviceSn
     * | name  |  否  | String       | 号码昵称                        |
    | num          |  否  | String       | 亲情号码,可以是手机或固话        |
    | dial_flag    |  否  | Int          | 0不设置为紧急呼叫号码,1设置为紧急呼叫号码       |
    | clear        |  否  | any          | 清空设置,[例如id值为2,如果发送的url带clear,系统只处理clear命令,则上述设置的亲情号2的参数无效,
    若该设备以前已设置亲情号码2,则以前设置的亲情号码2也会被清空]
    |
     */
    public com.alibaba.fastjson.JSONObject updAqgDeviceSosInfo(String deviceSn,String seqid,String name,String num,String dial_flag,String clear){
        //先对移动接口限制做判断。
        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
        String url ="";
        if ("4".equals(devices.get(0).getCategoryCode())){//手表
            Device device = deviceDao.findOne(devices.get(0).getDeviceId());
            if (device!=null){
                if ("X1".equals(device.getModel())){
                    url = MessageFormat.format(AqgConfig.X1sos_numbers, deviceSn,seqid);
                }
            }
        }else {
            url = MessageFormat.format(AqgConfig.sos_numbers, deviceSn,seqid);
        }
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(StringUtils.isBlank(clear)){
            param.add("name", name);
            param.add("num", num);
            param.add("dial_flag", dial_flag);
        }else {
            param.add("clear",clear);
        }
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie());
        return response.getBody();
    }
    /**
     * 获取设备最新位置数据
     * @param deviceSn
     * @param type  0:Gps定位; 1:基站定位 (非必填)
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONObject getDeviceLastLocation(String deviceSn,String type) throws Exception{
        String url = MessageFormat.format(AqgConfig.device_last_locationData, deviceSn);
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        param.add("type", type);
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.GET, getCookie());
        com.alibaba.fastjson.JSONObject responseJSON =  response.getBody();
        if (responseJSON.getBooleanValue("success")){
            if (responseJSON.containsKey("obj")&&responseJSON.getJSONObject("obj")!=null){
                com.alibaba.fastjson.JSONObject tmp= responseJSON.getJSONObject("obj");
                if (tmp.containsKey("locationdata")&&tmp.getJSONObject("locationdata")!=null){
                    com.alibaba.fastjson.JSONObject locationdataJson= tmp.getJSONObject("locationdata");
                    if (locationdataJson.containsKey("point")&&locationdataJson.getJSONObject("point")!=null){
                        com.alibaba.fastjson.JSONObject tmpPoint = locationdataJson.getJSONObject("point");
                        if (tmpPoint.containsKey("coordinates")&&tmpPoint.getJSONArray("coordinates")!=null){
                            com.alibaba.fastjson.JSONArray pointArr = tmpPoint.getJSONArray("coordinates");
                            Double lon = pointArr.getDouble(0);
                            Double lat = pointArr.getDouble(1);
                            com.alibaba.fastjson.JSONObject pointJson = gpsUtil.gcj02_To_Bd09(lat,lon);
                            locationdataJson.put("point",pointJson);
                        }
                    }
                }
            }
        }
        return responseJSON;
    }
    /**
     *
     *    | enable       |  否  | Int          |  0,1 是否启用                        |
     *    | name         |  否  | String       |   安全区名称                           |
     *    | freq         |  否  | Boolean      |  0,触发一天;1,每日触发        |
     *    | time_begin   |  否  | Int          |  目标时间与当日0点之间相差的秒数。如8 a.m 8*60*60=28800 |n
     *    | time_end     |  否  | Int          |  同上                        |
     *    | safe_area    |  否  | String       | x1,y1;x2,y2;xn,yn  一组由';'分隔的坐标,坐标用','分隔。且需要呈闭环,如A,B,C,D4个点,则应该上传的数据为 A;B;C;D;A  |
     *    | clear        |  否  | any          | 如果指定clear参数,则上述参数全部无意义,全部重设为缺省值    |
     * @return
     * @throws Exception
     */
    public com.alibaba.fastjson.JSONObject updateDeviceFenceArea(String deviceSn,Integer fenceNO,String enable,String name,String freq,
                                                                 String time_begin,String time_end,String safe_area ,String clear) throws Exception{
        List<DevicePatientDevice> devices = patientDeviceDao.findByDeviceSn(deviceSn);
        String url ="";
        if ("4".equals(devices.get(0).getCategoryCode())){//手表
            Device device = deviceDao.findOne(devices.get(0).getDeviceId());
            if (device!=null){
                if ("X1".equals(device.getModel())){
                    url = MessageFormat.format(AqgConfig.X1fence_area, deviceSn,fenceNO);
                }
            }
        }else {
            url = MessageFormat.format(AqgConfig.S3fence_area, deviceSn,fenceNO);
        }
        MultiValueMap<String, String> param = new LinkedMultiValueMap<>();
        if(StringUtils.isBlank(clear)){
            if (StringUtils.isNotBlank(safe_area)){
                String[] position = safe_area.split(";");
                safe_area = "";
                for (String tmp:position){
                    String[] point = tmp.split(",");
                    safe_area+= gpsUtil.bd09_To_Gcj02_str(Double.parseDouble(point[1]),Double.parseDouble(point[0]))+";";
                }
            }
            param.add("name", name);
            param.add("freq", freq);
            param.add("enable",enable);
            param.add("time_begin", time_begin);
            param.add("time_end", time_end);
            param.add("safe_area", safe_area);
        }else {
            param.add("clear",clear);
        }
        HttpEntity<com.alibaba.fastjson.JSONObject> response = httpClientUtil.aqgCookieHttp(url, param, HttpMethod.POST, getCookie());
        return response.getBody();
    }
    /******************************************* 爱牵挂设备end *****************************************************/
}

+ 4 - 1
svr/svr-cloud-job/src/main/resources/system.properties

@ -9,4 +9,7 @@ DOCTOR_SEND_UNREAD_MES_JOB=0 0 9 * * ?
PATIENT_SEND_UNREAD_MES_JOB=0 0 9 * * ?
#取消订单支付超时的订单,每3分钟执行一次
CANCEL_PAY_ORDER_OVERTIME_JOB=0 0/3 * * * ?
CANCEL_PAY_ORDER_OVERTIME_JOB=0 0/3 * * * ?
#居民紧急联系人数据同步更新每2分钟执行一次
PATIENT_SOS_CONTACTS_JOB=0 0/2 * * * ?