Browse Source

代码修改

liubing 3 years ago
parent
commit
10308b7d4a

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

@ -426,36 +426,49 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
    public PageEnvelop getArchiveList(Integer type,Integer signStatus,String name,Integer page,Integer size){
        page = page>0?page-1:0;
        String countSql  ="select count(DISTINCT p.id) from base_patient p where 1=1 ";
        String sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,null as sign_status from base_patient p where a.patient = p.id  ";
        String sql = "";
        String sqlCondition = "";
        if (null!=signStatus&&1==type){
        String countSql = "";
        if (StringUtils.isNotBlank(name)){
            sqlCondition +=" and p.name like '%"+name+"%' ";
        }
        if(1==type){//老人
            if (0==signStatus){//未签约
                countSql  ="select count(DISTINCT p.id) from base_patient p where 1=1  ";
                sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,false as sign_status from base_patient p where 1=1 ";
                sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,0 as sign_status from base_patient p where 1=1 ";
                sqlCondition +=" and NOT EXISTS(select sr.id from base_service_package_sign_record sr " +
                        " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                        " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                        " where sr.patient = p.id) ";
            }
            else if (1==signStatus){//已签约
                countSql  ="select count(DISTINCT p.id) from base_patient p where 1=1  ";
                sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,a.sign_status as sign_status from base_patient p,wlyy_archive a where a.patient = p.id ";
                        " where sr.patient = p.id)  and p.del=1 and p.archive_type=1 ";
                sql += sqlCondition;
            }else if (1==signStatus){//已签约
                countSql  ="select count(DISTINCT p.id) from base_patient p,wlyy_archive a where a.patient = p.id  ";
                sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,1 as sign_status from base_patient p,wlyy_archive a where a.patient = p.id ";
                sqlCondition +=" and EXISTS(select sr.id from base_service_package_sign_record sr " +
                        " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                        " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                        " where sr.patient = p.id) ";
                        " where sr.patient = p.id) and p.del=1 and p.archive_type=1 ";
                sql += sqlCondition;
            }
        }
        if (null!=type){//档案类型
            sqlCondition +=" and p.del=1 and p.archive_type="+type+" ";
        }
        if (StringUtils.isNotBlank(name)){
            sqlCondition +=" and p.name like '%"+name+"%' ";
        }
        if(1==type&&1==signStatus){
            sqlCondition += " order by a.sign_status desc ";
            else {
                countSql = "select count(DISTINCT p.id) from base_patient p where 1=1 and p.del=1 and p.archive_type=1 ";
                sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,0 as sign_status from base_patient p where 1=1 "+
                        " and NOT EXISTS(select sr.id from base_service_package_sign_record sr " +
                        " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                        " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                        " where sr.patient = p.id) and  p.del=1 and p.archive_type=1 "+sqlCondition+
                        " union "+
                        "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,1 as sign_status from base_patient p,wlyy_archive a where a.patient = p.id "+
                        " and EXISTS(select sr.id from base_service_package_sign_record sr " +
                        " INNER JOIN base_service_package_record pr on sr.id = pr.sign_id and sr.status=1 " +
                        " INNER JOIN base_service_package pack on pr.service_package_id = pack.id and pack.del=1 " +
                        " where sr.patient = p.id) and p.del=1 and p.archive_type=1 "+sqlCondition;
            }
        }else if (2==type){//新生儿
            countSql  ="select count(DISTINCT p.id) from base_patient p where 1=1 ";
            sql = "select DISTINCT p.id,p.name,p.sex,p.photo,p.idcard,null as sign_status from base_patient p where 1=1  ";
            sqlCondition +=" and p.del=1 and p.archive_type="+2+" ";//新生儿
            sql += sqlCondition;
        }
        Long count = jdbcTemplate.queryForObject(countSql+sqlCondition,Long.class);
@ -475,7 +488,6 @@ public class CareDoctorService extends BaseJpaService<BaseDoctorDO, BaseDoctorDa
            }
        }
        return PageEnvelop.getSuccessListWithPage("查询成功",result,page,size,count);
    }