liubing 3 年 前
コミット
9ac44994c3
16 ファイル変更210 行追加29 行削除
  1. 6 1
      common/common-entity/sql记录
  2. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/assistance/EmergencyAssistanceDO.java
  3. 10 1
      common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/PatientSosContactsDO.java
  4. 9 0
      common/common-entity/src/main/java/com/yihu/jw/entity/care/securitymonitoring/SecurityMonitoringOrderDO.java
  5. 2 0
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/assistance/EmergencyAssistanceService.java
  6. 25 11
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/contacts/ContactsService.java
  7. 1 1
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java
  8. 0 2
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/device/PatientDeviceService.java
  9. 12 5
      svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/security/SecurityMonitoringOrderService.java
  10. 2 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/DeviceService.java
  11. 1 0
      svr/svr-cloud-device/src/main/java/com/yihu/jw/care/service/YsDeviceService.java
  12. 22 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/dao/device/PatientSosContactsDao.java
  13. 10 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/event/ApplicationEvent.java
  14. 83 0
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/job/device/PatientSosContactsJob.java
  15. 14 7
      svr/svr-cloud-job/src/main/java/com/yihu/jw/care/service/device/NetworkCardService.java
  16. 4 1
      svr/svr-cloud-job/src/main/resources/system.properties

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

@ -1237,4 +1237,9 @@ CREATE TABLE `base_patient_sos_contacts` (
  `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='居民紧急联系人';
) 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;
    }
}

+ 10 - 1
common/common-entity/src/main/java/com/yihu/jw/entity/care/contacts/PatientSosContactsDO.java

@ -21,8 +21,9 @@ public class PatientSosContactsDO extends IdEntity {
    private String sosPhone; //联系电话
    private String relation; //与联系人关系 同base_patient_family_member
    private Date updateTime; //修改日期
    private Integer successFlag;//联系人是否同步成功-1失败 0待同步 1成功
    private Integer successFlag;//联系人是否同步成功 -2删除失败 -1添加失败 0待同步 1添加成功 2删除成功
    private Integer del;
    private Integer phoneSeqid;// 联系人序号 1 或2
    private String relationName;
@ -91,4 +92,12 @@ public class PatientSosContactsDO extends IdEntity {
    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;
    }
}

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

@ -294,6 +294,8 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        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()))+"");

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

@ -233,12 +233,16 @@ public class ContactsService {
        if (4==operType){//一个月只能删除一次
            if (list.size()>0){
                Date updateTime = list.get(0).getUpdateTime();
                Long timeDiffer = DateUtil.timeDifference(new Date(),updateTime);
                if (timeDiffer<=(1000L*3600*24*30)){
                   Long day = timeDiffer/(1000L*3600*24)+1;
                   result.put(ResponseContant.resultFlag,ResponseContant.fail);
                   result.put(ResponseContant.resultMsg,"您本月删除紧急联系人次数已使用,请"+day+"天后再试");
                    return result;
                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  " +
@ -255,17 +259,26 @@ public class ContactsService {
        }
        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);
@ -304,8 +317,9 @@ public class ContactsService {
                        }
                    }
                    if (StringUtils.isNotBlank(del_num)) {
                        String response = networkCardService.setPatientContacts(sim, null, null, "4", null, null);
                        if (StringUtils.isNotBlank(response)) {
//                        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)){//本次已删除过 不再作删除操作
@ -316,7 +330,7 @@ public class ContactsService {
                                    for (int i=0;i<aqgDeviceSosNum.size();i++){
                                        JSONObject aqgTmp = aqgDeviceSosNum.getJSONObject(i);
                                        String aqgNum = aqgTmp.getString("num");
                                        if (aqgNum.equals("tmp")){
                                        if (aqgNum.equals(tmp)){
                                            numIndex = aqgTmp.getInteger("seqid");
                                            break;
                                        }
@ -344,10 +358,10 @@ public class ContactsService {
                patientSosContactsDO.setUpdateTime(new Date());
                patientSosContactsDO.setDel(0);
                if (delSuccess.contains(num)){
                    patientSosContactsDO.setSuccessFlag(1);
                    patientSosContactsDO.setSuccessFlag(2);
                }
                else {
                    patientSosContactsDO.setSuccessFlag(-1);
                    patientSosContactsDO.setSuccessFlag(-2);
                }
                modify.add(patientSosContactsDO);
            }

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

@ -114,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);
        }
    }

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

@ -816,8 +816,6 @@ 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())){//手表

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

@ -281,6 +281,9 @@ public class SecurityMonitoringOrderService extends BaseJpaService<SecurityMonit
        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()))+"");
@ -1236,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);
                    }

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

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

@ -82,7 +82,18 @@ public class NetworkCardService {
        }
    }
    public String setPatientContacts(String msisdn, String iccid, String imsi,String operType,String  whiteNumber,String groupId) throws Exception {
    /**
     *
     * @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;
@ -103,12 +114,8 @@ public class NetworkCardService {
        String response = httpClientUtil.get(NetworkCardConfig.setPatientContacts,params,"UTF-8");
        JSONObject responseBody = JSONObject.parseObject(response);
        if (responseBody.getInteger("status")==0){
            JSONObject tmp = responseBody.getJSONArray("result").getJSONObject(0);
            return tmp.getString("orderNum");
        }else {
            throw new Exception(response);
        }
        return responseBody;
    }
}

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