Browse Source

预警总数和预警列表

xiaoyunquan 2 years ago
parent
commit
8096dc6731

+ 23 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/endpoint/third/platForm/PatientInfoPlatFormEndpoint.java

@ -459,4 +459,27 @@ public class PatientInfoPlatFormEndpoint extends EnvelopRestEndpoint {
        }
    }
    @RequestMapping(value = "getWarningCount", method = RequestMethod.GET)
    @ApiOperation(value = "获取预警中的总数")
    public ObjEnvelop getWarningCount(@ApiParam(name="patient",value = "居民id") @RequestParam(value = "patient",required = false) String patient){
        try{
            return patientInfoPlatFormService.getWarningCount(patient);
        }catch (Exception e){
            return failedObjEnvelopException2(e);
        }
    }
    @RequestMapping(value = "getWarningList", method = RequestMethod.GET)
    @ApiOperation(value = "获取预警中的列表")
    public PageEnvelop getWarningList(@ApiParam(name="page",value = "页码") @RequestParam(value = "page") Integer page,
                                      @ApiParam(name="pageSize",value = "每页大小") @RequestParam(value = "pageSize") Integer pageSize,
                                      @ApiParam(name="patient",value = "居民id") @RequestParam(value = "patient",required = false) String patient){
        try{
            return patientInfoPlatFormService.getWarningList(page,pageSize,patient);
        }catch (Exception e){
            return failedPageEnvelopException2(e);
        }
    }
}

+ 138 - 0
svr/svr-cloud-care/src/main/java/com/yihu/jw/care/service/third/PatientInfoPlatFormService.java

@ -29,6 +29,7 @@ import com.yihu.jw.entity.care.securitymonitoring.SecurityMonitoringOrderDO;
import com.yihu.jw.entity.care.sign.CapacityAssessmentRecordDO;
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.PageEnvelop;
import com.yihu.jw.util.common.GpsUtil;
import com.yihu.jw.util.common.IdCardUtil;
@ -1039,4 +1040,141 @@ public class PatientInfoPlatFormService {
        return detailInfo;
    }
    /**
     * 获取紧急预警和一般预警中的总数
     * @param patient
     * @return
     */
    public ObjEnvelop getWarningCount(String patient){
        String filter1=" ";
        String filter2=" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0&&StringUtils.isBlank(patient)){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            orgCodes = orgCodes.replaceAll(",","','");
            filter1 = " and ord.patient not in ('"+orgCodes+"') ";
            filter2 = " and idx.user not in ('"+orgCodes+"') ";
        }
        //查紧急预警
        Long warningCount = this.getWarningCountByEmergencyAndSecurity(filter1);
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("warningCount",warningCount);
        //查一般预警(体征预警)
        String healthSql = "SELECT\n" +
                "\tcount( idx.id ) \n" +
                "FROM\n" +
                "\twlyy_patient_health_index idx\n" +
                "\tINNER JOIN base_patient p ON idx.USER = p.id AND p.del = 1 \n" +
                "WHERE\n" +
                "\tidx.status = 1 \n" +
                "\tAND idx.del = 1 \n" +
                "\tAND idx.type < 3 \n" + filter2;
        Long healthCount = jdbcTemplate.queryForObject(healthSql, Long.class);
        map.put("healthCount",healthCount);
        map.put("total",warningCount+healthCount);
        return ObjEnvelop.getSuccess("获取成功",map);
    }
    /**
     * 获取紧急预警中的列表
     * @param page
     * @param pageSize
     * @param patient
     * @return
     */
    public PageEnvelop getWarningList(Integer page,Integer pageSize,String patient){
        page = page>0?page-1:0;
        String filter=" ";
        String sqltmp = "SELECT GROUP_CONCAT(dict_code) orgCodes from wlyy_hospital_sys_dict WHERE dict_name = 'jkzl_child' or dict_name = 'jkzl_older' ";
        List<Map<String,Object>> listtmp =  jdbcTemplate.queryForList(sqltmp);
        if(listtmp.size()>0&&StringUtils.isBlank(patient)){
            String orgCodes = String.valueOf(listtmp.get(0).get("orgCodes"));
            orgCodes = orgCodes.replaceAll(",","','");
            filter = " and ord.patient not in ('"+orgCodes+"') ";
        }
        String sql1 = "SELECT\n" +
                "\t'20' AS OrderType,\n" +
                "\tp.archive_type archiveType,\n" +
                "\tp.residential_area residentialArea,\n" +
                "\tord.id,\n" +
                "\tord.patient,\n" +
                "\tp.NAME,\n" +
                "\t'紧急呼叫' AS serve_desc,\n" +
                "\tDATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) create_time,\n" +
                "\tord.`status`,\n" +
                "CASE\n" +
                "\t\tp.sex \n" +
                "\t\tWHEN 1 THEN\n" +
                "\t\t'男' \n" +
                "\t\tWHEN 2 THEN\n" +
                "\t\t'女' ELSE p.sex \n" +
                "\tEND AS sex,\n" +
                "\tTIMESTAMPDIFF(YEAR,p.birthday,now()) AS age \n" +
                "FROM\n" +
                "\tbase_emergency_assistance_order ord\n" +
                "\tINNER JOIN base_patient p ON ord.patient = p.id \n" +
                "\tAND p.del = 1 \n" +
                "WHERE\n" +
                "\tord.STATUS = 1 "+filter;
        String sql2 = "SELECT\n" +
                "\t\t'22' AS 'OrderType',\n" +
                "\t\tp.archive_type archiveType,\n" +
                "\t\tp.residential_area residentialArea,\n" +
                "\t\tord.id,\n" +
                "\t\tord.patient,\n" +
                "\t\tp.NAME,\n" +
                "\t\tord.serve_desc,\n" +
                "\t\tDATE_FORMAT( ord.create_time, '%Y-%m-%d %H:%i:%S' ) create_time,\n" +
                "\t\tord.`status`,\n" +
                "\tCASE\n" +
                "\t\t\tp.sex \n" +
                "\t\t\tWHEN 1 THEN\n" +
                "\t\t\t'男' \n" +
                "\t\t\tWHEN 2 THEN\n" +
                "\t\t\t'女' ELSE p.sex \n" +
                "\t\tEND AS sex,\n" +
                "\t\tTIMESTAMPDIFF(YEAR,p.birthday,now()) AS age \n" +
                "\tFROM\n" +
                "\t\tbase_security_monitoring_order ord\n" +
                "\t\tINNER JOIN base_patient p ON ord.patient = p.id \n" +
                "\t\twhere ord.status = 1"+filter;
        String sql = "select * FROM (" +
                "\t"+sql1+" UNION "+sql2 +
                "\t) t order by t.create_time desc limit "+page*pageSize+","+pageSize;
        List<Map<String, Object>> list = jdbcTemplate.queryForList(sql);
        return PageEnvelop.getSuccessListWithPage("获取成功",list,page,pageSize,this.getWarningCountByEmergencyAndSecurity(filter));
    }
    /**
     * 获取紧急呼救和安防工单正在预警中的总数
     * @param filter1
     * @return
     */
    Long getWarningCountByEmergencyAndSecurity(String filter1){
        //紧急呼救
        String emergencySql = "SELECT count( ord.id ) warningCount \n" +
                "\tFROM\n" +
                "\t\tbase_emergency_assistance_order ord\n" +
                "\t\tINNER JOIN base_patient p ON ord.patient = p.id and p.del=1  \n" +
                "\tWHERE\n" +
                "\t\t ord.STATUS = 1"+filter1;
        //安防监护
        String securitySql = "SELECT count( ord.id ) warningCount \n" +
                "\tFROM\n" +
                "\t\tbase_security_monitoring_order ord\n" +
                "\t\tINNER JOIN base_patient p ON ord.patient = p.id and p.del=1 \n" +
                "\t\tAND ord.STATUS = 1"+filter1;
        String sqlCount = "SELECT\n" +
                "\tsum( warningCount ) warningCount\n" +
                "FROM\n" +
                "\t( " + emergencySql + " UNION ALL " + securitySql +
                ") t";
        return jdbcTemplate.queryForObject(sqlCount, Long.class);
    }
}