Ver código fonte

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

yeshijie 3 anos atrás
pai
commit
601b4ed40e
36 arquivos alterados com 1284 adições e 58 exclusões
  1. 2 2
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/BaseNatAppointmentDao.java
  2. 10 4
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java
  3. 96 25
      business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TasyNatService.java
  4. 20 1
      common/common-entity/sql记录
  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-cloud-care/src/main/java/com/yihu/jw/care/config/NetworkCardConfig.java
  11. 20 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/contacts/PatientSosContactsDao.java
  12. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/assistance/EmergencyAssistanceEndpoint.java
  13. 35 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorDeviceController.java
  14. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/DoctorHealthController.java
  15. 19 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PadDeviceController.java
  16. 18 6
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientDeviceController.java
  17. 3 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/device/PatientHealthController.java
  18. 15 3
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/patient/PatientContactsEndpoint.java
  19. 12 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  20. 171 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  21. 6 4
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java
  22. 12 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  23. 1 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/doctor/CareDoctorService.java
  24. 21 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  25. 2 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  26. 1 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java
  27. 49 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/config/AqgConfig.java
  28. 34 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/config/NetworkCardConfig.java
  29. 21 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/DeviceDao.java
  30. 66 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/PatientDeviceDao.java
  31. 22 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/PatientSosContactsDao.java
  32. 10 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java
  33. 83 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/device/PatientSosContactsJob.java
  34. 121 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java
  35. 221 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  36. 4 1
      svr/svr-cloud-job/src/main/resources/system.properties

+ 2 - 2
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/dao/BaseNatAppointmentDao.java

@ -17,8 +17,8 @@ public interface BaseNatAppointmentDao extends PagingAndSortingRepository<BaseNa
    List<BaseNatAppointmentDO> findPayStatusByPatientId(String patientId);
    @Query("from BaseNatAppointmentDO t where t.payStatus = 1 or t.payStatus = 0 and t.isSuccess=1 and t.patientId=?1")
    List<BaseNatAppointmentDO> findPayStatusByPatientIdTASY(String patientId);
    @Query("from BaseNatAppointmentDO t where t.patientId=?1 and t.payStatus in (0,1) and t.isSuccess=1 ")
    List<BaseNatAppointmentDO> findByTasy(String patientId);
    @Query("select a from BaseNatAppointmentDO a where  a.realOrder =?1 ")

+ 10 - 4
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/PrescriptionService.java

@ -11777,7 +11777,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                baseNatAppointmentDO.setCardNo(cardNo);
                baseNatAppointmentDO.setCardType(cardType);
                baseNatAppointmentDO.setAddress(address);
                baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDateLong(natTime));
                //baseNatAppointmentDO.setAppointmentTime(DateUtil.strToDateLong(natTime));
                //baseNatAppointmentDO.setOderNum(orderNum);
                baseNatAppointmentDO.setCityName(cityName);
                baseNatAppointmentDO.setFirstJobCode(firstJobCode);
@ -11805,6 +11805,7 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                baseNatAppointmentDO.setDoctorId(staffNo);
                baseNatAppointmentDO.setConsumer(consumer);
                baseNatAppointmentDO.setDoctorName(staffName);
                baseNatAppointmentDO.setAppointmentTime(new Date());
                baseNatAppointmentDO= baseNatAppointmentDao.save(baseNatAppointmentDO);
                logger.info("BaseNatAppointmentDO保存结束"+baseNatAppointmentDO.getId());
                //添加订单
@ -12065,9 +12066,14 @@ public class PrescriptionService extends BaseJpaService<WlyyPrescriptionDO, Pres
                "t.id as \"id\"," +
                "t.card_no_type as \"cardNoType\"," +
                "t.HOSPITAL_FLAG as \"hospitalFlag\"," +
                "t.charge_amount as \"chargeAmount\"," +
                "t.appointment_time as \"appointmentTime\" " +
                " from base_nat_appointment t where 1=1 ";
                "t.charge_amount as \"chargeAmount\"," ;
        if ("xm_tasy_wx".equalsIgnoreCase(wechatId)){
            sql+=" date_format(t.appointment_time ,'%Y-%m-%d' ) as \"appointmentTime\" ";
        }else {
            sql+=" t.appointment_time as \"appointmentTime\"";
        }
        sql+=  " from base_nat_appointment t where 1=1 ";
        if (StringUtils.isNoneBlank(patientId)){
            if (wechatId.equalsIgnoreCase("xm_ykyy_wx")){
                sql+=" and t.consumer ='"+patientId+"'";

+ 96 - 25
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/TasyNatService.java

@ -618,7 +618,7 @@ public class TasyNatService {
            key1.put("color",wxTemplateConfigDO1.getKeyword6());
            key2.put("value",baseNatAppointmentD0.getInspectionName());
            key2.put("color",wxTemplateConfigDO1.getKeyword6());
            key3.put("value",DateUtil.formatDate(baseNatAppointmentD0.getAppointmentTime(),"yyyy-MM-dd HH:mm:ss"));
            key3.put("value",wxTemplateConfigDO1.getKeyword3());//DateUtil.formatDate(baseNatAppointmentD0.getAppointmentTime(),"yyyy-MM-dd")
            key3.put("color",wxTemplateConfigDO1.getKeyword6());
            key4.put("value",wxTemplateConfigDO1.getKeyword4());
            key4.put("color",wxTemplateConfigDO1.getKeyword6());
@ -804,37 +804,108 @@ public class TasyNatService {
    }
    public void savePayStatusByHis(String patientId) throws Exception {
        List<BaseNatAppointmentDO> baseNatAppointmentDOList = baseNatAppointmentDao.findPayStatusByPatientIdTASY(patientId);
        List<BaseNatAppointmentDO> baseNatAppointmentDOList = baseNatAppointmentDao.findByTasy(patientId);
        for (BaseNatAppointmentDO baseNatAppointmentDO:baseNatAppointmentDOList){
            System.out.println("baseNatAppointmentDO==="+baseNatAppointmentDO.getName());
                String res = QueryApplyInfo(baseNatAppointmentDO.getRealOrder());
                JSONObject jsonObject = JSON.parseObject(res);
                if (jsonObject!=null){
                    if (jsonObject.getString("ReturnCode").equalsIgnoreCase("1")){
                        String voucherNo = jsonObject.getString("ApplyNo");
                        baseNatAppointmentDO.setVoucherNo(voucherNo);
                        if ("已扣费".equalsIgnoreCase(jsonObject.getString("Status"))){
                            baseNatAppointmentDO.setPayStatus("1");
                            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                            if (businessOrderDO!=null){
                                businessOrderDO.setStatus(1);
                                businessOrderDao.save(businessOrderDO);
                            }
                        }else if ("已退费".equalsIgnoreCase(jsonObject.getString("Status"))){
                            logger.info("进入退费订单同步");
                            baseNatAppointmentDO.setPayStatus("-1");
                            baseNatAppointmentDO.setIsSuccess("-1");
                            baseNatAppointmentDO.setCancelReson("患者本人线下取消");
                            baseNatAppointmentDO.setCancelTime(new Date());
                            baseNatAppointmentDO.setCancelBy(patientId);
                            BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                            if (businessOrderDO!=null){
                                businessOrderDO.setStatus(-1);
                                businessOrderDao.save(businessOrderDO);
                        String applyinfo = jsonObject.getString("applyinfo");
                        if (StringUtils.isNoneBlank(applyinfo)){
                            if (applyinfo.contains("[")){
                                JSONArray jsonArray = JSON.parseArray(applyinfo);
                                if (jsonArray!=null&&jsonArray.size()>0) {
                                    if (StringUtils.isNoneBlank(baseNatAppointmentDO.getVoucherNo())) {
                                        for (int i = 0; i < jsonArray.size(); i++) {
                                            JSONObject child = jsonArray.getJSONObject(i);
                                            System.out.println("数组" + child.getString("ApplyNo"));
                                            if (child.getString("ApplyNo").equalsIgnoreCase(baseNatAppointmentDO.getVoucherNo())) {
                                                if ("已扣费".equalsIgnoreCase(child.getString("Status"))) {
                                                    baseNatAppointmentDO.setPayStatus("1");
                                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                                    if (businessOrderDO != null) {
                                                        businessOrderDO.setStatus(1);
                                                        businessOrderDao.save(businessOrderDO);
                                                    }
                                                } else if ("已退费".equalsIgnoreCase(child.getString("Status"))) {
                                                    logger.info("进入退费订单同步");
                                                    baseNatAppointmentDO.setPayStatus("-1");
                                                    baseNatAppointmentDO.setIsSuccess("-1");
                                                    baseNatAppointmentDO.setCancelReson("患者本人线下取消");
                                                    baseNatAppointmentDO.setCancelTime(new Date());
                                                    baseNatAppointmentDO.setCancelBy(patientId);
                                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                                    if (businessOrderDO != null) {
                                                        businessOrderDO.setStatus(-1);
                                                        businessOrderDao.save(businessOrderDO);
                                                    }
                                                    //取消号源
                                                    //cancleOrder(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getRegisterNo(),baseNatAppointmentDO.getOderNum());
                                                }
                                                baseNatAppointmentDao.save(baseNatAppointmentDO);
                                            }
                                        }
                                    }else {
                                        JSONObject child = jsonArray.getJSONObject(jsonArray.size()-1);
                                        System.out.println("数组" + child.getString("ApplyNo"));
                                        if (child.getString("ApplyNo").equalsIgnoreCase(baseNatAppointmentDO.getVoucherNo())) {
                                            if ("已扣费".equalsIgnoreCase(child.getString("Status"))) {
                                                baseNatAppointmentDO.setPayStatus("1");
                                                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                                if (businessOrderDO != null) {
                                                    businessOrderDO.setStatus(1);
                                                    businessOrderDao.save(businessOrderDO);
                                                }
                                            } else if ("已退费".equalsIgnoreCase(child.getString("Status"))) {
                                                logger.info("进入退费订单同步");
                                                baseNatAppointmentDO.setPayStatus("-1");
                                                baseNatAppointmentDO.setIsSuccess("-1");
                                                baseNatAppointmentDO.setCancelReson("患者本人线下取消");
                                                baseNatAppointmentDO.setCancelTime(new Date());
                                                baseNatAppointmentDO.setCancelBy(patientId);
                                                BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                                if (businessOrderDO != null) {
                                                    businessOrderDO.setStatus(-1);
                                                    businessOrderDao.save(businessOrderDO);
                                                }
                                                //取消号源
                                                //cancleOrder(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getRegisterNo(),baseNatAppointmentDO.getOderNum());
                                            }
                                            baseNatAppointmentDO.setVoucherNo(child.getString("ApplyNo"));
                                            baseNatAppointmentDao.save(baseNatAppointmentDO);
                                        }
                                    }
                                }
                            }else {
                                JSONObject jsonObject1 = JSONObject.parseObject(applyinfo);
                                System.out.println("单条"+jsonObject1.getString("ApplyNo"));
                                if ("已扣费".equalsIgnoreCase(jsonObject1.getString("Status"))){
                                    baseNatAppointmentDO.setPayStatus("1");
                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                    if (businessOrderDO!=null){
                                        businessOrderDO.setStatus(1);
                                        businessOrderDao.save(businessOrderDO);
                                    }
                                }else if ("已退费".equalsIgnoreCase(jsonObject1.getString("Status"))){
                                    logger.info("进入退费订单同步");
                                    baseNatAppointmentDO.setPayStatus("-1");
                                    baseNatAppointmentDO.setIsSuccess("-1");
                                    baseNatAppointmentDO.setCancelReson("患者本人线下取消");
                                    baseNatAppointmentDO.setCancelTime(new Date());
                                    baseNatAppointmentDO.setCancelBy(patientId);
                                    BusinessOrderDO businessOrderDO = businessOrderDao.selectByRelationCode(baseNatAppointmentDO.getId().toString());
                                    if (businessOrderDO!=null){
                                        businessOrderDO.setStatus(-1);
                                        businessOrderDao.save(businessOrderDO);
                                    }
                                    //取消号源
                                    //cancleOrder(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getRegisterNo(),baseNatAppointmentDO.getOderNum());
                                }
                                baseNatAppointmentDO.setVoucherNo(jsonObject1.getString("ApplyNo"));
                                baseNatAppointmentDao.save(baseNatAppointmentDO);
                            }
                            //取消号源
                            //cancleOrder(baseNatAppointmentDO.getCardNo(),baseNatAppointmentDO.getRegisterNo(),baseNatAppointmentDO.getOderNum());
                        }
                        baseNatAppointmentDao.save(baseNatAppointmentDO);
                    }
                }
            }

+ 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 '设备触发工单时有该字段';

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

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

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

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

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

+ 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 * * * ?