lyr пре 8 година
родитељ
комит
24c341a76b

+ 108 - 113
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java

@ -203,7 +203,7 @@ public class SignPatientLabelInfoService extends BaseService {
            sql = "select * " +
                    " from " +
                    "     wlyy_sign_family " +
                    " where repdoctor = ? and status > 0 and admin_team_code = ? ";
                    " where (doctor = ? or doctor_health = ?) and status > 0 and admin_team_code = ? ";
            if (labelCode.equals("1")) {
                int week = today.get(Calendar.DAY_OF_WEEK) - 2;
@ -226,7 +226,7 @@ public class SignPatientLabelInfoService extends BaseService {
                throw new Exception("label is not exist");
            }
            args = new Object[]{doctor, teamCode, doctor, teamCode};
            args = new Object[]{doctor, doctor, teamCode};
        } else {
            if (labelCode.equals("0")) {
                sql = "SELECT " +
@ -234,15 +234,15 @@ public class SignPatientLabelInfoService extends BaseService {
                        " FROM " +
                        "    wlyy_sign_family t1 " +
                        " left join " +
                        "    (select repl.patient,repl.label,repl.label_type,repl.label_name from wlyy_sign_family repf left join wlyy_sign_patient_label_info repl on repf.patient = repl.patient where repf.repdoctor = '" + doctor + "' and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
                        "    (select l.patient,l.label,l.label_type,l.label_name from wlyy_sign_family f left join wlyy_sign_patient_label_info l on f.patient = l.patient where (f.doctor = '" + doctor + "' or f.doctor_health = '" + doctor + "') and f.status > 0 and l.label_type = ? and l.status = 1) t2 " +
                        " on t1.patient = t2.patient " +
                        " WHERE " +
                        "    t2.patient is null " +
                        "    AND t1.repdoctor = ? " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?) " +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? ";
                args = new Object[]{labelType, doctor, teamCode, labelType, doctor, teamCode};
                args = new Object[]{labelType, doctor, doctor, teamCode};
            } else {
                sql = "SELECT " +
                        "    t1.* " +
@ -254,19 +254,15 @@ public class SignPatientLabelInfoService extends BaseService {
                        "    AND t2.label_type = ? " +
                        "    AND t2.status = 1 " +
                        "    AND t1.patient = t2.patient " +
                        "    AND t1.repdoctor = ? " +
                        "    AND (t1.doctor = ? or t1.doctor_health = ?)" +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? ";
                args = new Object[]{labelCode, labelType, doctor, teamCode, labelCode, labelType, doctor, teamCode};
                args = new Object[]{labelCode, labelType, doctor, doctor, teamCode};
            }
        }
        String sqlDoc = sql.replaceAll("repdoctor", "doctor");
        String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health").replaceAll("t1", "t3").replaceAll("t2", "t4").replaceAll("repf", "repf1").replaceAll("repl", "repl1");
        sql = "select DISTINCT t.* from (" + sqlDoc + " union all " + sqlDocHealth + ") t limit " + start + "," + pagesize;
        sql += " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
@ -293,10 +289,12 @@ public class SignPatientLabelInfoService extends BaseService {
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            if(redisTemplate.isExposeConnection()) {
                                try {
                                    epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            if (StringUtils.isEmpty(epTime)) {
                                jsonP.put("expensesRemindStatus", 0);
@ -348,10 +346,12 @@ public class SignPatientLabelInfoService extends BaseService {
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        if(redisTemplate.isExposeConnection()) {
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            json.put("expensesRemindStatus", 0);
@ -394,16 +394,11 @@ public class SignPatientLabelInfoService extends BaseService {
        List<Map<String, Object>> signList = new ArrayList<>();
        int start = page * pagesize;
        String sql = "";
        Object[] args = null;
        Object[] args = new Object[]{doctor, doctor, teamCode};
        sql = " select * from wlyy_sign_family where " +
                " repdoctor = ? and status > 0 and admin_team_code = ? ";
        String sqlDoc = sql.replaceAll("repdoctor", "doctor");
        String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health");
                " (doctor = ? or doctor_health = ?) and status > 0 and admin_team_code = ? limit " + start + "," + pagesize;
        args = new Object[]{doctor, teamCode, doctor, teamCode};
        sql = "select t.* from (" + sqlDoc + " union all " + sqlDocHealth + ") t limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
@ -430,10 +425,12 @@ public class SignPatientLabelInfoService extends BaseService {
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e){
                                e.printStackTrace();
                            if(redisTemplate.isExposeConnection()) {
                                try {
                                    epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            if (StringUtils.isEmpty(epTime)) {
                                jsonP.put("expensesRemindStatus", 0);
@ -498,10 +495,12 @@ public class SignPatientLabelInfoService extends BaseService {
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        if(redisTemplate.isExposeConnection()) {
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            json.put("expensesRemindStatus", 0);
@ -569,10 +568,10 @@ public class SignPatientLabelInfoService extends BaseService {
                    Calendar today = Calendar.getInstance();
                    Calendar startDate = Calendar.getInstance();
                    SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
                    sql = "select *" +
                    sql = "select count(DISTINCT patient) count" +
                            " from " +
                            "     wlyy_sign_family " +
                            " where repdoctor = ? and status > 0 " +
                            " where (doctor = ? or doctor_health = ?) and status > 0 " +
                            (teamCode > 0 ? " and admin_team_code = ? " : "");
                    if (label.getLabelCode().equals("1")) {
@ -595,33 +594,33 @@ public class SignPatientLabelInfoService extends BaseService {
                        throw new Exception("label is not exist");
                    }
                    if (teamCode > 0) {
                        args = new Object[]{doctor, teamCode, doctor, teamCode};
                        args = new Object[]{doctor, doctor, teamCode};
                    } else {
                        args = new Object[]{doctor, doctor};
                    }
                } else {
                    if (label.getLabelCode().equals("0")) {
                        sql = " SELECT " +
                                "     t1.* " +
                                "     count(DISTINCT t1.patient) count" +
                                " FROM" +
                                "     wlyy_sign_family t1 " +
                                " left join " +
                                "    (select repl.patient,repl.label,repl.label_type,repl.label_name from wlyy_sign_family repf left join wlyy_sign_patient_label_info repl on repf.patient = repl.patient where  repf.repdoctor = '" + doctor + "' and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
                                "    (select l.patient,l.label,l.label_type,l.label_name from wlyy_sign_family f left join wlyy_sign_patient_label_info l on f.patient = l.patient where (f.doctor = '" + doctor + "' or f.doctor_health = '" + doctor + "') and f.status > 0 and l.label_type = ? and l.status = 1) t2 " +
                                " on t1.patient = t2.patient " +
                                " WHERE" +
                                "     t2.patient is null " +
                                "     AND t1.repdoctor = ? " +
                                "     AND (t1.doctor = ? or t1.doctor_health = ?)" +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
                        if (teamCode > 0) {
                            args = new Object[]{labelType, doctor, teamCode, labelType, doctor, teamCode};
                            args = new Object[]{labelType, doctor, doctor, teamCode};
                        } else {
                            args = new Object[]{labelType, doctor, labelType, doctor};
                            args = new Object[]{labelType, doctor, doctor};
                        }
                    } else {
                        sql = " SELECT " +
                                "     t1.* " +
                                "     count(DISTINCT t1.patient) count" +
                                " FROM" +
                                "     wlyy_sign_family t1, " +
                                "     wlyy_sign_patient_label_info t2 " +
@ -630,23 +629,18 @@ public class SignPatientLabelInfoService extends BaseService {
                                "     AND t2.label = ? " +
                                "     AND t2.label_type = ? " +
                                "     AND t2.status = 1 " +
                                "     AND t1.repdoctor = ? " +
                                "     AND (t1.doctor = ? or t1.doctor_health = ?)" +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
                        if (teamCode > 0) {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, teamCode, label.getLabelCode(), labelType, doctor, teamCode};
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor, teamCode};
                        } else {
                            args = new Object[]{label.getLabelCode(), labelType, doctor, label.getLabelCode(), labelType, doctor};
                            args = new Object[]{label.getLabelCode(), labelType, doctor, doctor};
                        }
                    }
                }
                String sqlDoc = sql.replaceAll("repdoctor", "doctor");
                String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health").replaceAll("t1", "t3").replaceAll("t2", "t4").replaceAll("repf", "repf1").replaceAll("repl", "repl1");
                sql = "select count(DISTINCT t.patient) count from (" + sqlDoc + " union all " + sqlDocHealth + ") t";
                List<Map<String, Object>> count = jdbcTemplate.queryForList(sql, args);
                if (count != null && count.size() > 0 && count.get(0).containsKey("count")) {
@ -1145,7 +1139,7 @@ public class SignPatientLabelInfoService extends BaseService {
        Object[] args = null;
        String sql = "select " +
                "    t1.* " +
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                (StringUtils.isNotEmpty(labelCode) || StringUtils.isNotEmpty(labelType) ?
@ -1154,7 +1148,7 @@ public class SignPatientLabelInfoService extends BaseService {
                " ON t1.patient = t2.patient " +
                (teamCode > 0 ? " join (select * from wlyy_sign_patient_label where label_type != '4' or team_code = " + teamCode + " or (label_type = '4' and (label_code in (1,2)))) lb on t2.label = lb.label_code and t2.label_type = lb.label_type " : "") +
                " WHERE " +
                "    t1.repdoctor = ? " +
                "    (t1.doctor = ? or t1.doctor_health = ?) " +
                "    AND t1.status > 0 " +
                "    AND (" + (StringUtils.isNotEmpty(labelCode) || StringUtils.isNotEmpty(labelType) ? "" : " t2.patient is null OR ") + " t2.status = 1) " +
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
@ -1163,16 +1157,14 @@ public class SignPatientLabelInfoService extends BaseService {
                "  AND (t1.name like ? or t2.label_name like ?) ";
        if (StringUtils.isNotEmpty(labelCode)) {
            args = new Object[]{doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%", doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
            args = new Object[]{doctor, doctor, labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
        } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
            args = new Object[]{doctor, labelType, "%" + filter + "%", "%" + filter + "%", doctor, labelType, "%" + filter + "%", "%" + filter + "%"};
            args = new Object[]{doctor, doctor, labelType, "%" + filter + "%", "%" + filter + "%"};
        } else {
            args = new Object[]{doctor, "%" + filter + "%", "%" + filter + "%", doctor, "%" + filter + "%", "%" + filter + "%"};
            args = new Object[]{doctor, doctor, "%" + filter + "%", "%" + filter + "%"};
        }
        String sqlDoc = sql.replaceAll("repdoctor", "doctor");
        String sqlDocHealth = sql.replaceAll("repdoctor", "doctor_health").replaceAll("t1", "t3").replaceAll("t2", "t4").replaceAll("lb", "lb1");
        sql = "select DISTINCT t.* from (" + sqlDoc + " union all " + sqlDocHealth + ") t limit " + page + "," + pagesize;
        sql += " limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
@ -1199,10 +1191,12 @@ public class SignPatientLabelInfoService extends BaseService {
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            if(redisTemplate.isExposeConnection()) {
                                try {
                                    epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            if (StringUtils.isEmpty(epTime)) {
                                jsonP.put("expensesRemindStatus", 0);
@ -1277,10 +1271,12 @@ public class SignPatientLabelInfoService extends BaseService {
//                }
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        if(redisTemplate.isExposeConnection()) {
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            json.put("expensesRemindStatus", 0);
@ -1340,27 +1336,14 @@ public class SignPatientLabelInfoService extends BaseService {
                " from " +
                "     wlyy_sign_family f,wlyy_patient p " +
                " where " +
                "      f.patient = p.code and f.doctor = ? and f.admin_team_code = ? and f.status > 0 and f.name like ? " +
                " union all " +
                "select " +
                "     f1.patient " +
                "     ,f1.name " +
                "     ,f1.openid " +
                "     ,f1.admin_team_code " +
                "     ,p1.sex " +
                "     ,p1.idcard " +
                "     ,p1.photo " +
                " from " +
                "     wlyy_sign_family f1,wlyy_patient p1" +
                " where " +
                "     f1.patient = p1.code and f1.doctor_health = ? and f1.admin_team_code = ? and f1.status > 0 and f1.name like ? " +
                ") t " + (page < 0 ? "" : "limit " + start + "," + size);
                "      f.patient = p.code and (f.doctor = ? or f.doctor_health = ?) and f.admin_team_code = ? and f.status > 0 and f.name like ?) " +
                (page < 0 ? "" : "limit " + start + "," + size);
        if (teams != null) {
            for (AdminTeam team : teams) {
                teamMap.put(team.getId(), team);
                List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, team.getId(),
                        "%" + filter + "%", doctor, team.getId(), "%" + filter + "%"});
                List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, team.getId(),
                        "%" + filter + "%"});
                if (result != null && result.size() > 0) {
                    for (Map<String, Object> p : result) {
@ -1572,7 +1555,7 @@ public class SignPatientLabelInfoService extends BaseService {
        Object[] args = null;
        String sqlTemp = "select " +
                "    t1.* " +
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                (StringUtils.isNotEmpty(labelCode) || StringUtils.isNotEmpty(labelType) ?
@ -1596,8 +1579,8 @@ public class SignPatientLabelInfoService extends BaseService {
            args = new Object[]{"%" + filter + "%", "%" + filter + "%"};
        }
        String sql = "select DISTINCT t.* from (" + sqlTemp + ") t limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        sqlTemp += " limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sqlTemp, args);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
@ -1623,10 +1606,12 @@ public class SignPatientLabelInfoService extends BaseService {
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            if(redisTemplate.isExposeConnection()) {
                                try {
                                    epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            if (StringUtils.isEmpty(epTime)) {
                                jsonP.put("expensesRemindStatus", 0);
@ -1654,7 +1639,7 @@ public class SignPatientLabelInfoService extends BaseService {
                }
                List<SignPatientLabelInfo> labels = null;
                if(teamCode > 0){
                if (teamCode > 0) {
                    labels = labelInfoDao.findByPatientAndStatusByTeam(sign.get("patient").toString(), 1, teamCode);
                } else {
                    labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
@ -1698,10 +1683,12 @@ public class SignPatientLabelInfoService extends BaseService {
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        if(redisTemplate.isExposeConnection()) {
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            json.put("expensesRemindStatus", 0);
@ -1771,10 +1758,12 @@ public class SignPatientLabelInfoService extends BaseService {
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            try{
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            if(redisTemplate.isExposeConnection()) {
                                try {
                                    epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            if (StringUtils.isEmpty(epTime)) {
@ -1833,10 +1822,12 @@ public class SignPatientLabelInfoService extends BaseService {
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        if(redisTemplate.isExposeConnection()) {
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            json.put("expensesRemindStatus", 0);
@ -1967,10 +1958,12 @@ public class SignPatientLabelInfoService extends BaseService {
                        jsonP.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                        if (StringUtils.isEmpty(String.valueOf(jsonP.get("expensesStatus"))) || String.valueOf(jsonP.get("expensesStatus")).equals("0")) {
                            String epTime = "";
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            if(redisTemplate.isExposeConnection()) {
                                try {
                                    epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                                } catch (Exception e) {
                                    e.printStackTrace();
                                }
                            }
                            if (StringUtils.isEmpty(epTime)) {
@ -2023,10 +2016,12 @@ public class SignPatientLabelInfoService extends BaseService {
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                        } catch (Exception e) {
                            e.printStackTrace();
                        if(redisTemplate.isExposeConnection()) {
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            json.put("expensesRemindStatus", 0);

+ 66 - 79
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/SignWebService.java

@ -39,93 +39,80 @@ public class SignWebService extends BaseService {
     *
     * @param doctor
     * @param status
     * @param page
     * @param pageSize
     * @return
     */
    public List<Map<String, Object>> getSignWebByDoctor(String doctor, int status, int page, int pagesize) {
    public List<Map<String, Object>> getSignWebByDoctor(String doctor, int status, int page, int pageSize) {
        // 查询语句
        String sql = "select " +
                "    a1.code " +
                "    ,a1.repdoctor doctor" +
                "    ,b1.code  as  patient" +
                "    ,b1.idcard " +
                "    ,b1.name " +
                "    ,b1.province_name  as provinceName" +
                "    ,b1.city_name  as cityName" +
                "    ,b1.town_name  as townName" +
                "    ,b1.address " +
                "    ,b1.photo " +
                "    ,a1.status " +
                "    ,a1.id" +
                "    ,a1.begin" +
                (status == 1 ? "    ,a1.patient_apply_date as applyDate " : "    ,a1.expenses_time as applyDate ") +
                "    ,a1.reason " +
                "    ,b1.street_name as streetName" +
                "    ,b1.sex" +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.idcard " +
                "    ,b.name " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                (status == 1 ? "    ,a.patient_apply_date as applyDate " : "    ,a.expenses_time as applyDate ") +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                " from " +
                " ( select code,patient,repdoctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family where repdoctor = ? and status = ? and type = 2 " +
                (status == 3 ? " and expenses_status = '1'" : "") + ") a1 " +
                " ,wlyy_patient b1 " +
                " where a1.patient = b1.code ";
        sql = "select DISTINCT t.* from (" + sql.replaceAll("repdoctor","doctor") + " union all "
                + sql.replaceAll("repdoctor","doctor_health").replaceAll("a1","a2").replaceAll("b1","b2")
                + ") t order by t.begin desc limit " + page * pagesize  + "," + pagesize;
                " ( select code,patient,doctor,status,id,apply_date,patient_apply_date,expenses_time,reason,begin from wlyy_sign_family where (doctor = ? or doctor_health = ?) and status = ? and type = 2" +
                (status == 3 ? " and expenses_status = '1'" : "") + " order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by a.begin desc limit " + page * pageSize + "," + pageSize;
        // 未缴费查询语句
        String sqlExpenses = "select " +
                "    a1.code " +
                "    ,a1.repdoctor doctor" +
                "    ,b1.code  as  patient" +
                "    ,b1.name " +
                "    ,b1.idcard " +
                "    ,b1.province_name  as provinceName" +
                "    ,b1.city_name  as cityName" +
                "    ,b1.town_name  as townName" +
                "    ,b1.address " +
                "    ,b1.photo " +
                "    ,a1.status " +
                "    ,a1.id " +
                "    ,a1.apply_date as applyDate " +
                "    ,a1.reason " +
                "    ,b1.street_name as streetName" +
                "    ,b1.sex" +
                "    ,a1.begin" +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.name " +
                "    ,b.idcard " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                "    ,a.apply_date as applyDate " +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                " from " +
                " ( select code,patient,repdoctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family where repdoctor = ? and status > ? and type = 2 ) a1 " +
                " ,wlyy_patient b1 " +
                " where a1.patient = b1.code and (a1.expenses_status = '0' or a1.len < 1) ";
        sqlExpenses = "select DISTINCT t.* from (" + sqlExpenses.replaceAll("repdoctor","doctor") + " union all "
                + sqlExpenses.replaceAll("repdoctor","doctor_health").replaceAll("a1","a2").replaceAll("b1","b2")
                + ") t order by t.begin desc limit " + page * pagesize  + "," + pagesize;
                " ( select code,patient,doctor,status,id,apply_date,reason,begin,expenses_status,LENGTH(trim(ifnull(expenses_status,''))) len from wlyy_sign_family where (doctor = ? or doctor_health = ?) and status > ? and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code and (a.expenses_status = '0' or a.len < 1) order by a.begin desc limit " + page * pageSize + "," + pageSize;
        // 已解约查询语句
        String surrSql = "select " +
                "    a1.code " +
                "    ,a1.repdoctor doctor" +
                "    ,b1.code  as  patient" +
                "    ,b1.name " +
                "    ,b1.idcard " +
                "    ,b1.province_name  as provinceName" +
                "    ,b1.city_name  as cityName" +
                "    ,b1.town_name  as townName" +
                "    ,b1.address " +
                "    ,b1.photo " +
                "    ,a1.status " +
                "    ,a1.id " +
                "    ,a1.apply_unsign_date as applyDate" +
                "    ,a1.reason " +
                "    ,b1.street_name as streetName" +
                "    ,b1.sex" +
                "    ,a1.begin" +
                "    a.code " +
                "    ,a.doctor " +
                "    ,b.code  as  patient" +
                "    ,b.name " +
                "    ,b.idcard " +
                "    ,b.province_name  as provinceName" +
                "    ,b.city_name  as cityName" +
                "    ,b.town_name  as townName" +
                "    ,b.address " +
                "    ,b.photo " +
                "    ,a.status " +
                "    ,a.id " +
                "    ,a.apply_unsign_date as applyDate" +
                "    ,a.reason " +
                "    ,b.street_name as streetName" +
                "    ,b.sex" +
                " from " +
                " ( select code,patient,repdoctor,status,id,apply_date,apply_unsign_date,reason,begin from wlyy_sign_family where repdoctor = ? and ( status = ? or status = ? ) and type = 2 ) a1 " +
                " ,wlyy_patient b1 " +
                " where a1.patient = b1.code ";
        surrSql = "select DISTINCT t.* from (" + surrSql.replaceAll("repdoctor","doctor") + " union all "
                + surrSql.replaceAll("repdoctor","doctor_health").replaceAll("a1","a2").replaceAll("b1","b2")
                + ") t order by t.begin desc limit " + page * pagesize  + "," + pagesize;
                " ( select code,patient,doctor,status,id,apply_date,apply_unsign_date,reason,begin from wlyy_sign_family where (doctor = ? or doctor_health = ?) and ( status = ? or status = ? ) and type = 2 order by begin desc ) a " +
                " ,wlyy_patient b " +
                " where a.patient = b.code  order by a.begin desc limit " + page * pageSize + "," + pageSize;
        // 分页信息
        //PageRequest pageRequest = new PageRequest(page - 1, pageSize);
@ -134,19 +121,19 @@ public class SignWebService extends BaseService {
        List<Map<String, Object>> patients = null;
        switch (status) {
            case 1:// 待签约
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, 0, doctor, 0});
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, 0});
                break;
            case 2:// 待解约
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, 2, doctor, 2});
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, 2});
                break;
            case 3:// 已签约
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, 1, doctor, 1});
                patients = jdbcTemplate.queryForList(sql, new Object[]{doctor, doctor, 1});
                break;
            case 4:// 4已经解约
                patients = jdbcTemplate.queryForList(surrSql, new Object[]{doctor, -3, -4, doctor, -3, -4});
                patients = jdbcTemplate.queryForList(surrSql, new Object[]{doctor, doctor, -3, -4});
                break;
            case 5: // 未缴费
                patients = jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, 0, doctor, 0});
                patients = jdbcTemplate.queryForList(sqlExpenses, new Object[]{doctor, doctor, 0});
        }
        return patients;

+ 6 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/sign/DoctorSignController.java

@ -257,10 +257,12 @@ public class DoctorSignController extends BaseController {
                    json.put("sex", temp.get("sex"));
                    if (status == 5) {
                        String epTime = "";
                        try {
                            epTime = redisTemplate.opsForValue().get("expenses:remind:" + temp.get("patient"));
                        } catch (Exception e) {
                            e.printStackTrace();
                        if(redisTemplate.isExposeConnection()) {
                            try {
                                epTime = redisTemplate.opsForValue().get("expenses:remind:" + temp.get("patient"));
                            } catch (Exception e) {
                                e.printStackTrace();
                            }
                        }
                        if (StringUtils.isEmpty(epTime)) {
                            json.put("expensesRemindStatus", 0);