ソースを参照

Merge branch 'dev' of http://192.168.1.220:10080/Amoy/patient-co-management into dev

8 年 前
コミット
4ec4cfa396

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

@ -77,8 +77,6 @@ public class SignPatientLabelInfoService extends BaseService {
            throw new Exception("patient info can not find");
        }
        List<SignFamily> signs = signFamilyDao.findAllSignByPatient(patient);
        // 设置患者标识
        json.put("code", p.getCode());
        // 设置患者姓名
@ -100,62 +98,65 @@ public class SignPatientLabelInfoService extends BaseService {
        // 社保号
        json.put("ssc", p.getSsc());
        if (signs != null && signs.size() > 0) {
            SignFamily ssSign = null;
            SignFamily familySign = null;
            for (SignFamily sign : signs) {
                if (sign.getType() == 1) {
                    ssSign = sign;
                } else if (sign.getType() == 2) {
                    familySign = sign;
                }
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient,1);
        SignFamily familySign = signFamilyDao.findSignByPatient(patient,2);
        if (ssSign != null) {
            // 设置患者紧急联系人
            json.put("emerMobile", StringUtils.isEmpty(ssSign.getEmerMobile()) ? "" : String.valueOf(ssSign.getEmerMobile()));
            // 设置签约日期
            json.put("qyrq", ssSign.getApplyDate() != null ? DateUtil.dateToStr((Date) ssSign.getApplyDate(), DateUtil.YYYY_MM_DD) : "");
            // 设置签约类型
            json.put("signType", 1);
            // 设置签约状态
            json.put("ssStatus", ssSign.getStatus());
            json.put("ssDoctor", ssSign.getDoctor());
            json.put("ssDoctorName", ssSign.getDoctorName());
            json.put("ssDoctorHealth", ssSign.getDoctorHealth());
            json.put("ssDoctorHealthName", ssSign.getDoctorHealthName());
            json.put("ssAdminTeam", ssSign.getAdminTeamId());
        }
        if (familySign != null) {
            // 设置患者紧急联系人
            json.put("emerMobile", StringUtils.isEmpty(familySign.getEmerMobile()) ? "" : String.valueOf(familySign.getEmerMobile()));
            // 设置签约日期
            json.put("qyrq", familySign.getApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getApplyDate(), DateUtil.YYYY_MM_DD) : "");
            // 设置签约日期
            json.put("patientApplyDate", familySign.getPatientApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getPatientApplyDate(), DateUtil.YYYY_MM_DD) : "");
            // 设置签约类型
            json.put("signType", json.has("signType") ? 3 : 2);
            // 缴费情况
            json.put("expensesStatus", StringUtils.isNotEmpty(familySign.getExpensesStatus()) ? String.valueOf(familySign.getExpensesStatus()) : "0");
            // 缴费时间
            json.put("expensesTime", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD_HH_MM) : "");
            // 缴费类型
            json.put("expensesType", StringUtils.isNotEmpty(familySign.getExpensesType()) ? String.valueOf(familySign.getExpensesType()) : "");
            // 设置签约状态
            json.put("familyStatus", familySign.getStatus());
            json.put("jtDoctor", familySign.getDoctor());
            json.put("jtDoctorName", familySign.getDoctorName());
            json.put("jtDoctorHealth", familySign.getDoctorHealth());
            json.put("jtDoctorHealthName", familySign.getDoctorHealthName());
            json.put("jtAdminTeam", familySign.getAdminTeamId());
            if ("1".equals(familySign.getExpensesStatus())) {
                json.put("qyrq", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD) : "");
            }
        }
            if (ssSign != null) {
                // 设置患者紧急联系人
                json.put("emerMobile", StringUtils.isEmpty(ssSign.getEmerMobile()) ? "" : String.valueOf(ssSign.getEmerMobile()));
                // 设置签约日期
                json.put("qyrq", ssSign.getApplyDate() != null ? DateUtil.dateToStr((Date) ssSign.getApplyDate(), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", 1);
                // 设置签约状态
                json.put("ssStatus", ssSign.getStatus());
            }
            if (familySign != null) {
                // 设置患者紧急联系人
                json.put("emerMobile", StringUtils.isEmpty(familySign.getEmerMobile()) ? "" : String.valueOf(familySign.getEmerMobile()));
                // 设置签约日期
                json.put("qyrq", familySign.getApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getApplyDate(), DateUtil.YYYY_MM_DD) : "");
                // 设置签约日期
                json.put("patientApplyDate", familySign.getPatientApplyDate() != null ? DateUtil.dateToStr((Date) familySign.getPatientApplyDate(), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", json.has("signType") ? 3 : 2);
                // 缴费情况
                json.put("expensesStatus", StringUtils.isNotEmpty(familySign.getExpensesStatus()) ? String.valueOf(familySign.getExpensesStatus()) : "0");
                // 缴费时间
                json.put("expensesTime", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD_HH_MM) : "");
                // 缴费类型
                json.put("expensesType", StringUtils.isNotEmpty(familySign.getExpensesType()) ? String.valueOf(familySign.getExpensesType()) : "");
                // 设置签约状态
                json.put("familyStatus", familySign.getStatus());
                if ("1".equals(familySign.getExpensesStatus())) {
                    json.put("qyrq", familySign.getExpensesTime() != null ? DateUtil.dateToStr((Date) familySign.getExpensesTime(), DateUtil.YYYY_MM_DD) : "");
                }
        if (json.has("expensesStatus") && (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 (json.has("expensesStatus") && (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 (StringUtils.isEmpty(epTime)) {
                    json.put("expensesRemindStatus", 0);
                } else {
                    json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                }
            if (StringUtils.isEmpty(epTime)) {
                json.put("expensesRemindStatus", 0);
            } else {
                json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
            }
        }
@ -330,9 +331,6 @@ public class SignPatientLabelInfoService extends BaseService {
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
//                if("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
//                    json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
//                }
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
@ -478,9 +476,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
//                if("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
//                    json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
//                }
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
@ -508,7 +504,6 @@ public class SignPatientLabelInfoService extends BaseService {
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
    /**
     * 查询某个标签类型的所有标签居民数统计
     *
@ -652,7 +647,11 @@ public class SignPatientLabelInfoService extends BaseService {
    }
    /**
     * 获取团队签约人数
     *
     * @param teamCode
     * @return
     * @throws Exception
     */
    public int getPatientAmountByTeam(Long teamCode) throws Exception {
        List<SignFamily> signFamilies = signFamilyDao.findByAdminTeamIdAndStatus(teamCode, 1);
@ -713,7 +712,7 @@ public class SignPatientLabelInfoService extends BaseService {
                            " from " +
                            "     wlyy_sign_family " +
                            " where status > 0 " +
                            (teamCode > 0 ? " and admin_team_code = ? " : "");
                            " and admin_team_code = ? ";
                    if (label.getLabelCode().equals("1")) {
                        int week = today.get(Calendar.DAY_OF_WEEK) - 2;
@ -734,11 +733,8 @@ public class SignPatientLabelInfoService extends BaseService {
                    } else {
                        throw new Exception("label is not exist");
                    }
                    if (teamCode > 0) {
                        args = new Object[]{teamCode, teamCode};
                    } else {
                        args = new Object[]{};
                    }
                    args = new Object[]{teamCode};
                } else {
                    if (label.getLabelCode().equals("0")) {
                        sql = " SELECT " +
@ -746,18 +742,14 @@ 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.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
                                "    (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.admin_team_code = ? and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
                                " on t1.patient = t2.patient " +
                                " WHERE" +
                                "     t2.patient is null " +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
                                "     AND t1.admin_team_code = ? ";
                        if (teamCode > 0) {
                            args = new Object[]{labelType, teamCode, labelType, teamCode};
                        } else {
                            args = new Object[]{labelType, labelType};
                        }
                        args = new Object[]{teamCode, labelType, teamCode};
                    } else {
                        sql = " SELECT " +
                                "     t1.* " +
@ -770,20 +762,13 @@ public class SignPatientLabelInfoService extends BaseService {
                                "     AND t2.label_type = ? " +
                                "     AND t2.status = 1 " +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
                                "    AND t1.admin_team_code = ? ";
                        if (teamCode > 0) {
                            args = new Object[]{label.getLabelCode(), labelType, teamCode, label.getLabelCode(), labelType, teamCode};
                        } else {
                            args = new Object[]{label.getLabelCode(), labelType, label.getLabelCode(), labelType};
                        }
                        args = new Object[]{label.getLabelCode(), labelType, 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 count(DISTINCT t.patient) count from (" + sqlDoc + " union all " + sqlDocHealth + ") t";
                sql = "select count(DISTINCT t.patient) count from (" + sql + ") t";
                List<Map<String, Object>> count = jdbcTemplate.queryForList(sql, args);
@ -843,8 +828,8 @@ public class SignPatientLabelInfoService extends BaseService {
        JSONArray teams = adminTeamService.findPatientDoctorTeam(patient, doctor);
        List<String> teamCodes = new ArrayList<>();
        if(teams.length() > 0){
            for(int i = 0; i < teams.length(); i++){
        if (teams.length() > 0) {
            for (int i = 0; i < teams.length(); i++) {
                teamCodes.add(String.valueOf(teams.getJSONObject(i).getLong("id")));
            }
        } else {
@ -933,9 +918,9 @@ public class SignPatientLabelInfoService extends BaseService {
        for (SignPatientLabelInfo label : labels) {
            labelMap.put(label.getLabel(), label);
            SignPatientLabel lb = labelService.getLabelByCodeAndType(label.getLabel(),"4");
            SignPatientLabel lb = labelService.getLabelByCodeAndType(label.getLabel(), "4");
            if(!custList.contains(label.getLabel())) {
            if (!custList.contains(label.getLabel())) {
                if (lb.getLabelCode().equals("1") || lb.getLabelCode().equals("2") || teamCodes.contains(String.valueOf(lb.getTeamCode()))) {
                    label.setStatus(0);
                    labelInfoDao.save(label);
@ -975,7 +960,7 @@ public class SignPatientLabelInfoService extends BaseService {
                || Arrays.asList(diseaseArr).contains("2"))) {
            SignPatientLabelInfo mbEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, "2", "1", 1);
            if(mbEx == null) {
            if (mbEx == null) {
                // 卫计委三大分组
                int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
                SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
@ -992,8 +977,8 @@ public class SignPatientLabelInfoService extends BaseService {
            }
        } else {
            int age = IdCardUtil.getAgeForIdcard(idcard);
            String lbCode = "",lbName = "";
            if(age >= 65){
            String lbCode = "", lbName = "";
            if (age >= 65) {
                lbCode = "3";
                lbName = "65岁以上人群";
            } else {
@ -1003,7 +988,7 @@ public class SignPatientLabelInfoService extends BaseService {
            SignPatientLabelInfo wjwEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(patient, lbCode, "1", 1);
            if(wjwEx == null) {
            if (wjwEx == null) {
                // 卫计委三大分组
                int wjwAmount = labelInfoDao.deleteByPatientAndLabelTypeAndStatus(patient, "1", 1);
                SignPatientLabelInfo disLabel = new SignPatientLabelInfo();
@ -1571,7 +1556,7 @@ public class SignPatientLabelInfoService extends BaseService {
                "    AND (" + (StringUtils.isNotEmpty(labelCode) || StringUtils.isNotEmpty(labelType) ? "" : " t2.patient is null OR ") + " t2.status = 1) " +
                (StringUtils.isNotEmpty(labelCode) ? " AND t2.label = ? " : "") +
                (StringUtils.isNotEmpty(labelType) ? " AND t2.label_type = ? " : "") +
                (teamCode > 0 ? (" AND admin_team_code = " + teamCode) : "") +
                " AND admin_team_code = " + teamCode +
                "  AND (t1.name like ? or t2.label_name like ?) ";
        if (StringUtils.isNotEmpty(labelCode)) {
@ -1672,9 +1657,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
//                if("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
//                    json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
//                }
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
@ -1709,82 +1692,122 @@ public class SignPatientLabelInfoService extends BaseService {
     * @return
     */
    public JSONArray searchTeamsPatients(String filter, long teamCode, int page, int pagesize) throws Exception {
        JSONArray reArray = new JSONArray();
        Map<String, JSONArray> map = new HashMap<>();
        Map<Long, AdminTeam> teamMap = new HashMap<>();
        List<AdminTeam> teams = null;
        int start = page * pagesize;
        int size = pagesize;
        teams = new ArrayList<>();
        AdminTeam teamTemp = adminTeamService.getTeam(teamCode);
        if (teamTemp == null) {
            throw new Exception("adminTeam is not exist");
        }
        teams.add(teamTemp);
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        page = page * pagesize;
        Object[] args = new Object[]{teamCode, "%" + filter + "%"};
        String sql = "select distinct t.* from (" +
                " select " +
                "     f.patient " +
                "     ,f.name " +
                "     ,f.openid " +
                "     ,f.admin_team_code " +
                "     ,p.sex " +
                "     ,p.idcard " +
                "     ,p.photo " +
                " from " +
                "     wlyy_sign_family f,wlyy_patient p " +
                " where " +
                "      f.patient = p.code and f.admin_team_code = ? and f.status > 0 and f.name like ? ) t "
                + (page < 0 ? "" : "limit " + start + "," + size);
        String sqlTemp = "select " +
                "    DISTINCT t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                " WHERE " +
                "    t1.status > 0 " +
                " AND t1.admin_team_code = ? " +
                "  AND t1.name like ? ";
        if (teams != null) {
            for (AdminTeam team : teams) {
                teamMap.put(team.getId(), team);
                List<Map<String, Object>> result = jdbcTemplate.queryForList(sql, new Object[]{team.getId(),
                        "%" + filter + "%"});
        String sql = sqlTemp + " limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
                if (result != null && result.size() > 0) {
                    for (Map<String, Object> p : result) {
                        JSONObject pJson = new JSONObject();
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                        pJson.put("code", p.get("patient"));
                        pJson.put("name", p.get("name") != null ? p.get("name") : "");
                        pJson.put("openid", p.get("openid") != null ? p.get("openid") : "");
                        pJson.put("adminTeamCode", p.get("admin_team_code") != null ? p.get("admin_team_code") : "");
                        pJson.put("sex", p.get("sex") != null ? p.get("sex") : "");
                        pJson.put("age", p.get("idcard") != null ? IdCardUtil.getAgeForIdcard(String.valueOf(p.get("idcard"))) : "");
                        pJson.put("photo", p.get("photo") != null ? p.get("photo") : "");
                if (p == null) {
                    continue;
                }
                        List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(String.valueOf(p.get("patient")), 1);
                        pJson.put("labels", labels == null ? "" : labels);
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                        if (map.containsKey(String.valueOf(p.get("admin_team_code")))) {
                            JSONArray array = map.get(String.valueOf(p.get("admin_team_code")));
                            array.put(pJson);
                        } else {
                            JSONArray array = new JSONArray();
                            array.put(pJson);
                            map.put(String.valueOf(p.get("admin_team_code")), array);
                    if (!String.valueOf(jsonP.get("signType")).equals(String.valueOf(sign.get("type")))) {
                        jsonP.put("signType", 3);
                    }
                    if (String.valueOf(sign.get("type")).equals("2")) {
                        jsonP.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                        // 缴费情况
                        jsonP.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                        // 缴费时间
                        jsonP.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                        // 缴费类型
                        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 = redisTemplate.opsForValue().get("expenses:remind:" + p.getCode());
                            if (StringUtils.isEmpty(epTime)) {
                                jsonP.put("expensesRemindStatus", 0);
                            } else {
                                jsonP.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                            }
                        }
                    }
                    continue;
                }
            }
            if (map != null && map.size() > 0) {
                for (String key : map.keySet()) {
                    AdminTeam team = teamMap.get(Long.valueOf(key));
                    JSONObject tJson = new JSONObject();
                List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                    tJson.put("teamCode", team.getId());
                    tJson.put("teamName", team.getName());
                    tJson.put("patients", map.get(key));
                JSONObject json = new JSONObject();
                    reArray.put(tJson);
                // 设置患者标识
                json.put("code", p.getCode());
                // 设置患者姓名
                json.put("name", p.getName());
                // 设置患者手机号
                json.put("mobile", p.getMobile());
                // 设置患者微信openid
                json.put("openid", StringUtils.isNotEmpty(p.getOpenid()) ? p.getOpenid() : "");
                // 设置患者联系电话
                json.put("phone", p.getPhone());
                // 设置患者紧急联系人
                json.put("emerMobile", sign.get("emer_mobile") == null ? "" : String.valueOf(sign.get("emer_mobile")));
                // 设置患者头像
                json.put("photo", p.getPhoto());
                // 设置患者年龄
                json.put("age", DateUtil.getAgeByBirthday(p.getBirthday()));
                // 设置患者性别
                json.put("sex", p.getSex());
                // 设置签约日期
                json.put("qyrq", sign.get("apply_date") != null ? DateUtil.dateToStr((Date) sign.get("apply_date"), DateUtil.YYYY_MM_DD) : "");
                // 设置签约类型
                json.put("signType", sign.get("type") == null ? "" : sign.get("type"));
                // 身份证号
                json.put("idcard", p.getIdcard());
                // 社保号
                json.put("ssc", p.getSsc());
                if (String.valueOf(sign.get("type")).equals("2")) {
                    // 缴费情况
                    json.put("expensesStatus", sign.get("expenses_status") != null ? String.valueOf(sign.get("expenses_status")) : "0");
                    // 缴费时间
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
                    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 (StringUtils.isEmpty(epTime)) {
                            json.put("expensesRemindStatus", 0);
                        } else {
                            json.put("expensesRemindStatus", new SimpleDateFormat("yyyy-MM-dd").format(new Date()).equals(epTime) ? 1 : 0);
                        }
                    }
                } else {
                    // 缴费情况
                    json.put("expensesStatus", "1");
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
                result.put(p.getCode(), json);
            }
        }
        return reArray;
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
@ -1805,10 +1828,71 @@ public class SignPatientLabelInfoService extends BaseService {
        String sql = "";
        Object[] args = null;
        String tempsql = " select * from wlyy_sign_family where " +
                " status > 0 and admin_team_code = ? ";
        args = new Object[]{teamCode};
        sql = "select t.* from (" + tempsql + ") t limit " + start + "," + pagesize;
        if (labelType.equals("5")) {
            Calendar today = Calendar.getInstance();
            Calendar startDate = Calendar.getInstance();
            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
            sql = "select * " +
                    " from " +
                    "     wlyy_sign_family " +
                    " where status > 0 and admin_team_code = ? ";
            if (labelCode.equals("1")) {
                int week = today.get(Calendar.DAY_OF_WEEK) - 2;
                if (week == -1) {
                    week = 6;
                }
                startDate.add(Calendar.DATE, -week);
                sql += " and apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(today.getTime()) + " 23:59:59'");
            } else if (labelCode.equals("2")) {
                startDate.set(Calendar.DATE, 1);
                sql += " and apply_date between '" + (df.format(startDate.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(today.getTime()) + " 23:59:59'");
            } else if (labelCode.equals("3")) {
                startDate.add(Calendar.DATE, 30);
                sql += " and end between '" + (df.format(today.getTime()) + " 00:00:00")
                        + "' and '" + (df.format(startDate.getTime()) + " 23:59:59'");
            } else {
                throw new Exception("label is not exist");
            }
            args = new Object[]{teamCode};
        } else {
            if (labelCode.equals("0")) {
                sql = "SELECT " +
                        "    t1.* " +
                        " 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.admin_team_code = ? and repf.status > 0 and repl.label_type = ? and repl.status = 1) t2 " +
                        " on t1.patient = t2.patient " +
                        " WHERE " +
                        "    t2.patient is null " +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? ";
                args = new Object[]{teamCode, labelType, teamCode};
            } else {
                sql = "SELECT " +
                        "    t1.* " +
                        " FROM " +
                        "    wlyy_sign_family t1, " +
                        "    wlyy_sign_patient_label_info t2 " +
                        " WHERE " +
                        "    t2.label = ? " +
                        "    AND t2.label_type = ? " +
                        "    AND t2.status = 1 " +
                        "    AND t1.patient = t2.patient " +
                        "    AND t1.status > 0 " +
                        "    AND t1.admin_team_code = ? ";
                args = new Object[]{labelCode, labelType, teamCode};
            }
        }
        sql = sql + " limit " + start + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
@ -1843,24 +1927,11 @@ public class SignPatientLabelInfoService extends BaseService {
                            }
                        }
                    }
                    continue;
                }
                if (StringUtils.isNotEmpty(labelCode)) {
                    SignPatientLabelInfo labelInfoEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(p.getCode(), labelCode, labelType, 1);
                    if (labelInfoEx == null) {
                        continue;
                    }
                } else if (StringUtils.isNotEmpty(labelType)) {
                    List<SignPatientLabelInfo> labelExs = labelInfoDao.findByPatientAndLabelTypeAndStatus(p.getCode(), labelType, 1);
                    if (labelExs == null && labelExs.size() <= 0) {
                        continue;
                    }
                    continue;
                }
                List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                //List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                JSONObject json = new JSONObject();
                // 设置患者标识
@ -1896,9 +1967,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesTime", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD_HH_MM) : "");
                    // 缴费类型
                    json.put("expensesType", sign.get("expenses_type") != null ? String.valueOf(sign.get("expenses_type")) : "");
//                if("2".equals(String.valueOf(sign.get("type"))) && "1".equals(String.valueOf(sign.get("expenses_status")))){
//                    json.put("qyrq", sign.get("expenses_time") != null ? DateUtil.dateToStr((Date) sign.get("expenses_time"), DateUtil.YYYY_MM_DD) : "");
//                }
                    if (StringUtils.isEmpty(String.valueOf(json.get("expensesStatus"))) || String.valueOf(json.get("expensesStatus")).equals("0")) {
                        String epTime = "";
                        try {
@ -1917,7 +1986,7 @@ public class SignPatientLabelInfoService extends BaseService {
                    json.put("expensesStatus", "1");
                }
                // 患者标签
                json.put("labels", labels == null ? "" : labels);
                //json.put("labels", labels == null ? "" : labels);
                result.put(p.getCode(), json);
            }

+ 3 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java

@ -978,7 +978,9 @@ public class StatisticsAllService extends BaseService {
                towns = townDao.findByCityCode(area);
            } else if (level == 3) {
                Town town = townDao.findByCode(area);
                towns.add(town);
                if(town != null) {
                    towns.add(town);
                }
            }
            if (towns != null && towns.size() > 0) {

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/im/imController.java

@ -22,7 +22,7 @@ public class imController extends BaseController {
	public String sendBusinessMsg(String userId,String content)
	{
		try{
			String _url = host+"/system/sendmsg.im";
			String _url = host+"/api/v1/chats/sm";
			String param = "user_id="+userId+"&content="+content;
			String result = HttpUtil.sendPost(_url, param);
		

+ 15 - 11
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultController.java

@ -11,6 +11,7 @@ import com.yihu.wlyy.service.app.health.PatientHealthGuidanceService;
import com.yihu.wlyy.service.app.scheduling.DoctorWorkTimeService;
import com.yihu.wlyy.service.app.talk.TalkGroupService;
import com.yihu.wlyy.service.common.account.DoctorService;
import com.yihu.wlyy.util.IdCardUtil;
import com.yihu.wlyy.util.MessageType;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
@ -82,9 +83,9 @@ public class DoctorConsultController extends WeixinBaseController {
                       @RequestParam(required = false) String patient,
                       @RequestParam(required = false) String title) {
        try {
            Page<ConsultTeam> list = consultTeamService.findByDoctor(getUID(), type, id, pagesize,patient, title);
            Page<ConsultTeam> list = consultTeamService.findByDoctor(getUID(), type, id, pagesize, patient, title);
            JSONArray jsonArray = new JSONArray();
            if(list != null) {
            if (list != null) {
                for (ConsultTeam consult : list) {
                    if (consult == null) {
                        continue;
@ -111,12 +112,13 @@ public class DoctorConsultController extends WeixinBaseController {
                    json.put("doctorPhoto", doctor.getPhoto());
                    // 设置医生sex
                    json.put("doctorSex", doctor.getSex());
                    Patient p = patientService.findByCode(consult.getPatient());
                    // 设置患者头像
                    json.put("photo", consult.getPhoto());
                    json.put("photo", p.getPhoto());
                    // 设置咨询标识
                    json.put("title", consult.getSymptoms());
                    // 设置患者年龄
                    json.put("age", DateUtil.getAgeByBirthday(consult.getBirthday()));
                    json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
                    // 设置评价内容
                    json.put("comment", consult.getCommentContent());
                    // 设置评价星级
@ -128,7 +130,7 @@ public class DoctorConsultController extends WeixinBaseController {
                    // 咨询状态
                    json.put("status", consult.getStatus());
                    // 设置性别
                    json.put("sex", consult.getSex());
                    json.put("sex", p.getSex());
                    // 未读消息
                    json.put("doctorRead", consult.getDoctorRead());
                    // 设置关联指导
@ -169,6 +171,8 @@ public class DoctorConsultController extends WeixinBaseController {
                    continue;
                }
                Patient p = patientService.findByCode(consult.getPatient());
                JSONObject json = new JSONObject();
                json.put("id", consult.getId());
                // 设置咨询标识
@ -176,13 +180,13 @@ public class DoctorConsultController extends WeixinBaseController {
                // 设置患者标识
                json.put("patient", consult.getPatient());
                // 设置患者头像
                json.put("photo", consult.getPhoto());
                json.put("photo", p.getPhoto());
                // 设置咨询标识
                json.put("title", consult.getSymptoms());
                // 设置患者姓名
                json.put("name", consult.getName());
                // 设置患者年龄
                json.put("age", DateUtil.getAgeByBirthday(consult.getBirthday()));
                json.put("age", IdCardUtil.getAgeForIdcard(p.getIdcard()));
                // 设置评价内容
                json.put("comment", consult.getCommentContent());
                // 设置评价星级
@ -194,7 +198,7 @@ public class DoctorConsultController extends WeixinBaseController {
                // 咨询状态
                json.put("status", consult.getStatus());
                // 设置性别
                json.put("sex", consult.getSex());
                json.put("sex", p.getSex());
                // 未读消息
                json.put("doctorRead", consult.getDoctorRead());
                // 设置关联指导
@ -494,7 +498,7 @@ public class DoctorConsultController extends WeixinBaseController {
                        json.put("replycontent", replycontent);
                        json.put("doctorName", doctor.getName());
                        json.put("remark", "医生已为您提供问诊方案");
                       // PushMsgTask.getInstance().putWxMsg(getAccessToken(), 3, p.getOpenid(), p.getName(), json);
                        // PushMsgTask.getInstance().putWxMsg(getAccessToken(), 3, p.getOpenid(), p.getName(), json);
                    }
                    if (type == 2) {
                        return write(200, "回复成功!", "data", content);
@ -638,9 +642,9 @@ public class DoctorConsultController extends WeixinBaseController {
            consultTeamService.addFamousTeamConsult(consult, getUID(), "2");
            // 推送消息给医生
            PushMsgTask.getInstance().put(consult.getDoctor(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.D_CT_04.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.您有新的名医咨询.name(), consult.getConsult());
            if(StringUtils.isNotEmpty(images)){
            if (StringUtils.isNotEmpty(images)) {
                String[] arr = images.split(",");
                for(String img : arr) {
                for (String img : arr) {
                    PushMsgTask.getInstance().put(consult.getDoctor(), "2", MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.名医咨询.name(), MessageType.MESSAGE_TYPE_DOCTOR_NEW_FAMOUS_CONSULT_TEAM_DOCTOR.您有新的名医咨询.name(), img);
                }
            }

+ 22 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/consult/DoctorConsultPublicController.java

@ -3,7 +3,10 @@ package com.yihu.wlyy.web.doctor.consult;
import java.util.Date;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.service.app.account.DoctorInfoService;
import com.yihu.wlyy.service.common.account.PatientService;
import com.yihu.wlyy.wechat.util.WeiXinAccessTokenUtils;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
@ -41,6 +44,12 @@ public class DoctorConsultPublicController extends BaseController {
	@Autowired
	private DoctorInfoService doctorInfoService;
	@Autowired
	PatientService patientService;
	@Autowired
	WeiXinAccessTokenUtils weiXinAccessTokenUtils;
	/**
	 * 查询公共咨询记录
	 * @param type 查询类型:0全部,1我的回答
@ -219,8 +228,20 @@ public class DoctorConsultPublicController extends BaseController {
			}
			reply.setImages(images);
			if (consultPublicService.addDoctorReply(reply) != null) {
				Patient p = patientService.findByCode(cp.getPatient());
				JSONObject json = new JSONObject();
				json.put("first", "您的公共咨询有新的回复");
				json.put("toUser", p.getCode());
				json.put("consultcontent", cp.getContent());
				String replycontent = content.length() > 15 ? content.substring(0, 15) + "..." : content;
				json.put("consult", consult);
				json.put("replycontent", replycontent);
				json.put("doctorName", doctor.getName());
				json.put("remark", "");
				PushMsgTask.getInstance().putWxMsg(weiXinAccessTokenUtils.getAccessToken(), 3, p.getOpenid(), p.getName(), json);
				// 推送消息给患者
				PushMsgTask.getInstance().put(cp.getPatient(), MessageType.MESSAGE_TYPE_PATIENT_CONSULT_PUBLIC_REPLY.P_CP_01.name(), MessageType.MESSAGE_TYPE_PATIENT_CONSULT_PUBLIC_REPLY.公共咨询.name(), MessageType.MESSAGE_TYPE_PATIENT_CONSULT_PUBLIC_REPLY.医生回复了您.name(), consult);
				//PushMsgTask.getInstance().put(cp.getPatient(), MessageType.MESSAGE_TYPE_PATIENT_CONSULT_PUBLIC_REPLY.P_CP_01.name(), MessageType.MESSAGE_TYPE_PATIENT_CONSULT_PUBLIC_REPLY.公共咨询.name(), MessageType.MESSAGE_TYPE_PATIENT_CONSULT_PUBLIC_REPLY.医生回复了您.name(), consult);
				return success("回复成功!");
			} else {
				return error(-1, "回复失败!");

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/DoctorPatientGroupController.java

@ -602,7 +602,7 @@ public class DoctorPatientGroupController extends BaseController {
                // 设置患者姓名
                json.put("name", temp.getName());
                // 设置患者头像
                json.put("photo", CommonUtil.getPhoneUrl(temp.getPhoto()));
                json.put("photo", temp.getPhoto());
                // 设置患者年龄
                json.put("age", DateUtil.getAgeByBirthday(temp.getBirthday()));
                // 设置患者性别

+ 3 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -131,7 +131,7 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "过滤标签参数不为空时过滤标签类型不能为空");
            }
            page = page - 1;
            page = page > 0 ? page - 1 : 0;
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize);
            return write(200, "查询成功", "data", result);
@ -372,7 +372,7 @@ public class SignPatientLabelInfoController extends BaseController {
                teamCode = 0L;
            }
            page = page - 1;
            page = page > 0 ? page - 1 : 0;
            JSONArray result = labelInfoService.searchPatientByNameOrLabel(filter, labelCode, labelType, teamCode, exLabelCode, exLabelType, page, pagesize);
@ -393,6 +393,7 @@ public class SignPatientLabelInfoController extends BaseController {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "查询参数不能为空");
            }
            page = page > 0 ? page - 1 : 0;
            JSONArray result = labelInfoService.searchTeamsPatients(filter,teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {

+ 4 - 4
patient-co-wlyy/src/main/resources/system.properties

@ -5,8 +5,8 @@
#server_domain=wlyy
#server_url=http://www.xmtyw.cn/wlyy/
#
#im_group_server=http://120.41.253.95:3000/group/sendgroupmsg.im
#msg_push_server=http://120.41.253.95:3000/system/sendmsg.im
#im_group_server=http://120.41.253.95:3000/api/v1/chats/gm
#msg_push_server=http://120.41.253.95:3000/api/v1/chats/sm
#file upload temp path
#upload_temp_path=/var/local/temp
@ -30,8 +30,8 @@
#server_domain=ssgg
#server_url=http://ehr.yihu.com/ssgg/
#im_group_server=http://ehr.yihu.com/imwebsocket/group/sendgroupmsg.im
#msg_push_server=http://ehr.yihu.com/imwebsocket/system/sendmsg.im
#im_group_server=http://ehr.yihu.com/api/v1/chats/gm
#msg_push_server=http://ehr.yihu.com/api/v1/chats/sm
#file upload temp path
#upload_temp_path=/var/local/temp