LAPTOP-KB9HII50\70708 2 years ago
parent
commit
e2967b8ade

+ 3 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/dao/security/BaseEmergencyWarnLogDao.java

@ -16,6 +16,9 @@ public interface BaseEmergencyWarnLogDao extends PagingAndSortingRepository<Base
    @Query("select w from BaseEmergencyWarnLogDO w where w.orderId = ?1 and w.type is null ")
    List<BaseEmergencyWarnLogDO> findByOrderIdOrderByCreateTimeDesc(String oderId);//工单操作日志,有type的为工单流程关键步骤
    @Query("select w from BaseEmergencyWarnLogDO w where w.orderId = ?1 and w.type is not null ")
    List<BaseEmergencyWarnLogDO> findByOrderId(String oderId);
    @Query("select w from BaseEmergencyWarnLogDO w where w.orderId = ?1 and w.type = 1")
    List<BaseEmergencyWarnLogDO> findByOrderIdByType(String orderId);

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

@ -376,7 +376,7 @@ public class EmergencyAssistanceEndpoint extends EnvelopRestEndpoint {
            @RequestParam(value = "doctor", required = true) String doctor,
            @ApiParam(value = "类型 8发起im会话,9发起音视频通话", name = "type")
            @RequestParam(value = "type", required = true) Integer type,
            @ApiParam(value = "复核内容", required = false, name = "content")
            @ApiParam(value = "内容", required = false, name = "content")
            @RequestParam(value = "content", required = false) String content) {
        try {
            assistanceService.addWarnLog(sessionId, doctor,type,content);

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

@ -65,6 +65,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -1230,7 +1231,15 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            BaseDoctorDO doctorDO = doctorDao.findById(doctor);
            if (null!=doctorDO){
                BaseEmergencyWarnLogDO logDO = new BaseEmergencyWarnLogDO();
                BaseEmergencyWarnLogDO logTypeDO = new BaseEmergencyWarnLogDO();
                logDO.setUserCode(doctor);
                logDO.setUserName(doctorDO.getName());
                logDO.setOrderId(orderId);
                logDO.setUserType(2);
                logDO.setCreateTime(new Date());
                logDO.setContent("前往定位");
                logDao.save(logDO);
                List<BaseEmergencyWarnLogDO> byOrderIdByType = logDao.findByOrderIdByType(orderId);
                if (byOrderIdByType.size()==0){
@ -1579,12 +1588,11 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
    }
    public JSONObject getEmergencyAssistanceProcess(String orderId,String orderType){
        JSONObject jsonObject = new JSONObject();
        String eaSql = " ";
        List<Map<String, Object>> maps = new ArrayList<>();
        if ("20".equals(orderType)){
            eaSql   = "SELECT o.`status`,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') AS createTime,o.patient,'紧急呼叫' AS serveDesc,dd.photo " +
            eaSql   = "SELECT o.`status`,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') AS createTime,o.patient,o.team_code,'紧急呼叫' AS serveDesc,dd.photo " +
                    "from base_emergency_assistance_order o " +
                    "LEFT JOIN wlyy_devices wd on wd.device_code=o.device_sn " +
                    "LEFT JOIN dm_device dd on dd.category_code = wd.category_code " +
@ -1592,7 +1600,7 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
        }
        if ("22".equals(orderType)){
            eaSql   = "SELECT o.`status`,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') AS createTime,o.patient,o.serve_desc serveDesc,dd.photo " +
            eaSql   = "SELECT o.`status`,DATE_FORMAT(o.create_time,'%Y-%m-%d %H:%i:%S') AS createTime,o.patient,o.team_code,o.serve_desc serveDesc,dd.photo " +
                    "from base_security_monitoring_order o  " +
                    "LEFT JOIN wlyy_devices wd on wd.device_code=o.device_sn " +
                    "LEFT JOIN dm_device dd on dd.category_code = wd.category_code " +
@ -1603,88 +1611,72 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            return null;
        }
        //发起预警
        jsonObject.put("start",maps.get(0));
        String patient = maps.get(0).get("patient")+"";
        JSONObject start = new JSONObject();
        Map<String, Object> startMap = maps.get(0);
        start.put("createTime",startMap.get("createTime"));
        start.put("photo",startMap.get("photo"));
        start.put("serveDesc",startMap.get("serveDesc"));
        jsonObject.put("start",start);
        String patient = startMap.get("patient")+"";
        String teamCode = startMap.get("team_code")+"";
        //预警推送
        //通知对象
        JSONObject pushLog = new JSONObject();
        pushLog.put("family",patientFamilyPushLog(patient,orderId));
        pushLog.put("docotr",doctorPushLog(orderId,teamCode));
        jsonObject.put("pushLog",pushLog);
        //其他日志
        List<BaseEmergencyWarnLogDO> warnLogDOList = logDao.findByOrderId(orderId);
        Map<Integer,List<BaseEmergencyWarnLogDO>> resultMap = warnLogDOList.stream().collect(Collectors.groupingBy(e -> e.getType()));
        //预警核实
        List<BaseEmergencyWarnLogDO> check = new ArrayList<>();
        check.addAll(resultMap.get(8));
        check.addAll(resultMap.get(9));
        check.addAll(resultMap.get(10));
        if(check.size()>0){
            check = check.stream().sorted(Comparator.comparing(BaseEmergencyWarnLogDO::getCreateTime)).collect(Collectors.toList());
            jsonObject.put("check",check);
        }
        //医生信息
   /*     String sql = "SELECT i.code,r.team_code,pack.org_code,pack.org_name from base_service_package_sign_record sr,base_service_package_record r, base_service_package_item i,base_service_package pack  \n" +
                "where  sr.id = r.sign_id and sr.status=1 and r.service_package_id = i.service_package_id and r.service_package_id = pack.id  and i.del = 1 and sr.`status`=1 \n" +
                "and  sr.patient  = ? and i.code='preventLost' ";
        List<Map<String, Object>> items = jdbcTemplate.queryForList(sql,new Object[]{orderId});
        if (items.size() > 0) {
            Map<String, Object> mapTmp = items.get(0);
            List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembersByLevel(mapTmp.get("team_code").toString(), 2);
            JSONArray otherDoctorDistance = new JSONArray();
            JSONObject otherDoctorDistanceObj = new JSONObject();
            for (BaseDoctorDO doc : doctorDOS) {
                Map<String, Object> noticeObj = new HashMap<>();
                noticeObj.put("type", "1");
                noticeObj.put("typeName", "社工");
                noticeObj.put("id", doc.getId());
                noticeObj.put("name", doc.getName());
                noticeObj.put("photo", doc.getPhoto());
                noticeObj.put("mobile", doc.getMobile());
                List<Map<String, Object>> arr = new ArrayList<>();
                Map<String, Object> tmp = new HashMap<>();
                tmp.put("name", "系统预警");
                tmp.put("status", 0);
                tmp.put("statusName", "未响应");
                if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doc.getId(), orderDO.getId()) != null) {
                    tmp.put("status", 1);
                    tmp.put("statusName", "已响应");
                }
                arr.add(tmp);
                noticeObj.put("response", arr);
                noticePersons.add(noticeObj);
                if (StringUtils.isBlank(doc.getDoctorLat()) || StringUtils.isBlank(doc.getDoctorLon())) {
                    List<BaseDoctorHospitalDO> doctorHospitalDOS = baseDoctorHospitalDao.findByDoctorCode(doc.getId());
                    if (doctorHospitalDOS.size() > 0) {
                        BaseDoctorHospitalDO hospitalDO = doctorHospitalDOS.get(0);
                        BaseOrgDO orgDO = orgDao.findByCode(hospitalDO.getOrgCode());
                        doc.setDoctorLocateAddress(orgDO.getAddress());
                        doc.setDoctorLat(orgDO.getLatitude());
                        doc.setDoctorLon(orgDO.getLongitude());
                    } else {
                        continue;
                    }
                }
                //double distanceTmp = countDistance.getDistance(Double.parseDouble(orderDO.getServeLat()),Double.parseDouble(orderDO.getServeLon()),Double.parseDouble(doc.getDoctorLat()),Double.parseDouble(doc.getDoctorLon()));
                otherDoctorDistanceObj = new JSONObject();
                otherDoctorDistanceObj.put("doctor", doc.getId());
                otherDoctorDistanceObj.put("doctorName", doc.getName());
                otherDoctorDistanceObj.put("doctorAddress", doc.getDoctorLocateAddress());
                otherDoctorDistanceObj.put("doctorLon", doc.getDoctorLon());
                otherDoctorDistanceObj.put("doctorLat", doc.getDoctorLat());
                otherDoctorDistanceObj.put("distance", null);//两点距离
                otherDoctorDistance.add(otherDoctorDistanceObj);
            }
            emergencyOrderVO.setOtherDoctorDistance(otherDoctorDistance.toJSONString());
        }*/
        //预警处置
        List<BaseEmergencyWarnLogDO> dealWith = new ArrayList<>();
        dealWith.addAll(resultMap.get(2));
        dealWith.addAll(resultMap.get(3));
        dealWith.addAll(resultMap.get(4));
        if(dealWith.size()>0){
            dealWith = dealWith.stream().sorted(Comparator.comparing(BaseEmergencyWarnLogDO::getCreateTime)).collect(Collectors.toList());
            jsonObject.put("dealWith",dealWith);
        }
        //其他日志
        //处置结论
        List<BaseEmergencyWarnLogDO> conclusion = resultMap.get(5);
        if(conclusion!=null){
            jsonObject.put("conclusion",conclusion.get(0));
        }
        String sql = "select user_name AS userName,create_time AS createTime,content,type from base_emergency_warn_log where (user_type = 2 and order_id = '"+orderId+"' and type IS NOT NULL) " +
                " OR (user_type = 1 AND order_id = '"+orderId+"' and type IS NOT NULL) order by create_time,type ASC ";
        List<Map<String, Object>> result = jdbcTemplate.queryForList(sql);
        //预警复核
        List<BaseEmergencyWarnLogDO> review = resultMap.get(7);
        if(review!=null){
            jsonObject.put("review",review.get(0));
        }
        jsonObject.put("type5_status",0);
        jsonObject.put("result",result);
        for (Map<String, Object> map : result) {
            if (map.get("type").equals(5)) {
                jsonObject.put("type5_status",1);
            }
        //取消
        List<BaseEmergencyWarnLogDO> cancel = resultMap.get(6);
        if(cancel!=null){
            jsonObject.put("cancel",cancel.get(0));
        }
        jsonObject = JSONObject.parseObject(JSON.toJSONStringWithDateFormat(jsonObject,"yyyy-MM-dd HH:mm:ss", SerializerFeature.WriteMapNullValue));
        return jsonObject;
    }
    public void patientFamily(String patient,String orderId){
    /**
     * 家属推送日志
     * @param patient
     * @param orderId
     * @return
     */
    public List<Map<String, Object>> patientFamilyPushLog(String patient,String orderId){
        List<Map<String, Object>> noticePersons = new ArrayList<>();
        JSONArray familyArr = familyMemberService.getPatientMembers(patient, null, null, null, "3");
        for (int i = 0; i < familyArr.size(); i++) {
@ -1715,6 +1707,33 @@ public class EmergencyAssistanceService extends BaseJpaService<EmergencyAssistan
            noticeObj.put("response", arr);
            noticePersons.add(noticeObj);
        }
        return noticePersons;
    }
    /**
     * 医生推送日志
     * @return
     */
    public List<Map<String, Object>> doctorPushLog(String orderId,String teamCode){
        List<Map<String, Object>> noticePersons = new ArrayList<>();
        List<BaseDoctorDO> doctorDOS = baseTeamMemberDao.findAllMembersByLevel(teamCode,2);
        for (BaseDoctorDO doctorDO:doctorDOS) {
            Map<String,Object> noticeObj = new HashMap<>();
            noticeObj.put("type","1");
            noticeObj.put("typeName","社工");
            noticeObj.put("id",doctorDO.getId());
            noticeObj.put("name",doctorDO.getName());
            noticeObj.put("photo",doctorDO.getPhoto());
            noticeObj.put("mobile",doctorDO.getMobile());
            noticeObj.put("status",0);
            noticeObj.put("statusName","未响应");
            if (emergencyWarnDoctorResponseDao.findByDoctorAndOrderId(doctorDO.getId(),orderId)!=null){
                noticeObj.put("status",1);
                noticeObj.put("statusName","已响应");
            }
            noticePersons.add(noticeObj);
        }
        return noticePersons;
    }
    public int phoneLogSave(BaseEmergencyWarnLogDO baseEmergencyWarnLogDO,Integer type){