Browse Source

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

chenweida 8 years ago
parent
commit
7d165a2e5c
16 changed files with 1204 additions and 20 deletions
  1. 8 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java
  2. 564 3
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/label/SignPatientLabelInfoService.java
  3. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/ExpensesRemindService.java
  4. 2 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/statistics/StatisticsAllService.java
  5. 43 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java
  6. 30 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/area/AreaService.java
  7. 133 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/verified/VerifiedService.java
  8. 76 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DesUtils.java
  9. 44 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/area/AreaController.java
  10. 36 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/hospital/HospitalCommonController.java
  11. 77 0
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/verified/VerifiedController.java
  12. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/account/DoctorController.java
  13. 150 4
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java
  14. 35 6
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java
  15. 3 2
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/SignTeamController.java
  16. 1 1
      patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

+ 8 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/repository/patient/SignFamilyDao.java

@ -311,4 +311,12 @@ public interface SignFamilyDao extends PagingAndSortingRepository<SignFamily, Lo
	@Query("select a.patient from SignFamily a where a.doctor = ?1 and a.type = 2 and a.status > 0 and a.doctorHealth is null")
	List<String> findNohealthByDoctor(String doctor);
	/**
	 * 获取团队中有效的患者
	 * @param teamCode
	 * @param status
	 * @return
	 */
	List<SignFamily> findByAdminTeamIdAndStatus(long teamCode,int status);
}

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

@ -508,6 +508,10 @@ public class SignPatientLabelInfoService extends BaseService {
        return result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
    /**
     * 查询某个标签类型的所有标签居民数统计
     *
@ -649,6 +653,158 @@ public class SignPatientLabelInfoService extends BaseService {
        return result;
    }
    /**
     *
     */
    public int getPatientAmountByTeam(Long teamCode) throws Exception{
        List<SignFamily> signFamilies =  signFamilyDao.findByAdminTeamIdAndStatus(teamCode, 1);
        return signFamilies.size();
    }
    /**
     * 查询某个标签类型的所有标签居民数统计,或者所有类型
     *
     * @param labelType 标签类型
     * @param teamCode  标签类型为4时,不能为空
     * @return
     */
    public JSONArray getPatientAmountByTeamGroupLable(Long teamCode,String labelType) throws Exception {
        Boolean isAll = false;
        List<SignPatientLabel> labels = new ArrayList<>();
        if("0".equals(labelType)){
            labels =  labelService.getTeamAllLabels(teamCode);
            isAll = true;
        }else{
            labels = labelService.getLabelsByTypeAndTeam(labelType,teamCode);
        }
        JSONArray result = new JSONArray();
        SignPatientLabel labelNo = new SignPatientLabel();
        if (!labelType.equals("5")) {
            labelNo.setLabelCode("0");
            labelNo.setLabelName(labelType.equals("1") ? "未分组" : "未标注");
            labelNo.setStatus(1);
            labelNo.setIsSystem(1);
            labelNo.setLabelType(labelType);
            labelNo.setSort(999999999);
            labels.add(labelNo);
        }
        if (labels != null) {
            for (SignPatientLabel label : labels) {
                if(isAll){//查询所有
                 labelType  =  label.getLabelType();
                }
                JSONObject json = new JSONObject();
                json.put("labelCode", label.getLabelCode());
                json.put("labelName", label.getLabelName());
                json.put("isSystem", label.getIsSystem());
                int amount = 0;
                String sql = "";
                Object[] args = null;
                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 " +
                            (teamCode > 0 ? " and admin_team_code = ? " : "");
                    if (label.getLabelCode().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 (label.getLabelCode().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 (label.getLabelCode().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");
                    }
                    if (teamCode > 0) {
                        args = new Object[]{teamCode,teamCode};
                    } else {
                        args = new Object[]{};
                    }
                } else {
                    if (label.getLabelCode().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.status > 0 and repl.label_type = ?) t2 " +
                                " on t1.patient = t2.patient " +
                                " WHERE" +
                                "     t2.patient is null " +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    AND t1.admin_team_code = ? " : "");
                        if (teamCode > 0) {
                            args = new Object[]{labelType, teamCode, labelType,teamCode};
                        } else {
                            args = new Object[]{labelType,labelType};
                        }
                    } else {
                        sql = " SELECT " +
                                "     t1.* " +
                                " FROM" +
                                "     wlyy_sign_family t1, " +
                                "     wlyy_sign_patient_label_info t2 " +
                                " WHERE" +
                                "     t1.patient = t2.patient " +
                                "     AND t2.label = ? " +
                                "     AND t2.label_type = ? " +
                                "     AND t2.status = 1 " +
                                "     AND t1.status > 0 " +
                                (teamCode > 0 ? "    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};
                        }
                    }
                }
                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")) {
                    amount = Integer.valueOf(String.valueOf(count.get(0).get("count")));
                }
                json.put("amount", amount);
                if (label.getLabelCode().equals("0") && labelType.equals("1") && amount < 1) {
                    continue;
                }
                result.put(json);
            }
        }
        return result;
    }
    /**
     * 设置患者标签
@ -834,9 +990,9 @@ public class SignPatientLabelInfoService extends BaseService {
     * @param labelType 标签类型
     * @return
     */
    public JSONArray getPatientLabelByLabelTypeAndTeamCode(String patient, String labelType,Long teamCode) {
    public JSONArray getPatientLabelByLabelTypeAndTeamCode(String patient, String labelType, Long teamCode, String doctor) {
        List<SignPatientLabelInfo> labels = new ArrayList<>();
        JSONArray result =  new JSONArray();
        JSONArray result = new JSONArray();
        if (StringUtils.isEmpty(labelType)) {
            labels = labelInfoDao.findByPatientAndStatus(patient, 1);
@ -844,7 +1000,21 @@ public class SignPatientLabelInfoService extends BaseService {
            labels = labelInfoDao.findByPatientAndLabelTypeAndStatus(patient, labelType, 1);
        }
        if(labels != null && labels.size() > 0) {
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        SignFamily jtSign = signFamilyDao.findSignByPatient(patient, 2);
        Long ssTeam = 0L;
        Long jtTeam = 0L;
        if (ssSign != null && (doctor.equals(ssSign.getDoctor()) ||
                doctor.equals(ssSign.getDoctorHealth()))) {
            ssTeam = ssSign.getAdminTeamId();
        }
        if (jtSign != null && (doctor.equals(jtSign.getDoctor()) ||
                doctor.equals(jtSign.getDoctorHealth()))) {
            jtTeam = jtSign.getAdminTeamId();
        }
        if (labels != null && labels.size() > 0) {
            for (SignPatientLabelInfo label : labels) {
                JSONObject json = new JSONObject(label);
@ -1146,6 +1316,10 @@ public class SignPatientLabelInfoService extends BaseService {
        return reArray;
    }
    /**
     * 添加居民到某个标签
     *
@ -1289,4 +1463,391 @@ public class SignPatientLabelInfoService extends BaseService {
        return 1;
    }
    /***BEGIN EXIT DOCTOR***/
    /**
     * 根据患者姓名或标签名称查询
     *
     * @param filter
     * @return
     * @throws Exception
     */
    public JSONArray searchPatientByNameOrLabel(String filter,
                                                String labelCode, String labelType, long teamCode,
                                                String exLabelCode,
                                                String exLabelType,
                                                int page, int pagesize) throws Exception {
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        page = page * pagesize;
        Object[] args = null;
        String sqlTemp = "select " +
                "    t1.* " +
                " FROM " +
                "    wlyy_sign_family t1 " +
                (StringUtils.isNotEmpty(labelCode) || StringUtils.isNotEmpty(labelType) ?
                        " join " : " left join ") +
                "    wlyy_sign_patient_label_info t2 " +
                " ON t1.patient = t2.patient " +
                " WHERE " +
                "    t1.status > 0 " +
                "    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 (t1.name like ? or t2.label_name like ?) ";
        if (StringUtils.isNotEmpty(labelCode)) {
            args = new Object[]{labelCode, labelType, "%" + filter + "%", "%" + filter + "%"};
        } else if (StringUtils.isEmpty(labelCode) && StringUtils.isNotEmpty(labelType)) {
            args = new Object[]{labelType, "%" + filter + "%", "%" + filter + "%"};
        } else {
            args = new Object[]{ "%" + filter + "%", "%" + filter + "%"};
        }
       String sql = "select DISTINCT t.* from (" + sqlTemp+ ") t limit " + page + "," + pagesize;
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    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 (StringUtils.isNotEmpty(exLabelCode)) {
                    SignPatientLabelInfo labelInfoEx = labelInfoDao.findByPatientAndLabelAndLabelTypeAndStatus(p.getCode(), exLabelCode, exLabelType, 1);
                    if (labelInfoEx != null) {
                        continue;
                    }
                } else if (StringUtils.isNotEmpty(exLabelType)) {
                    List<SignPatientLabelInfo> labelExs = labelInfoDao.findByPatientAndLabelTypeAndStatus(p.getCode(), exLabelType, 1);
                    if (labelExs != null && labelExs.size() > 0) {
                        continue;
                    }
                }
                List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                JSONObject json = new JSONObject();
                // 设置患者标识
                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("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 {
                            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 result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
    /**
     * 查询所有团队下患者
     *
     * @param filter 搜索关键字
     * @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);
        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);
        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 + "%"});
                if (result != null && result.size() > 0) {
                    for (Map<String, Object> p : result) {
                        JSONObject pJson = new JSONObject();
                        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") : "");
                        List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(String.valueOf(p.get("patient")), 1);
                        pJson.put("labels", labels == null ? "" : labels);
                        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 (map != null && map.size() > 0) {
                for (String key : map.keySet()) {
                    AdminTeam team = teamMap.get(Long.valueOf(key));
                    JSONObject tJson = new JSONObject();
                    tJson.put("teamCode", team.getId());
                    tJson.put("teamName", team.getName());
                    tJson.put("patients", map.get(key));
                    reArray.put(tJson);
                }
            }
        }
        return reArray;
    }
    /**
     * 获取团队下的患者(非当前医生而是整个团队)
     *
     * @param teamCode
     * @param page
     * @param pagesize
     * @return
     * @throws Exception
     */
    public JSONArray getPatientByTeamCodeExitDoctor(long teamCode, String labelCode, String labelType, int page, int pagesize) throws Exception {
        Map<String, JSONObject> result = new HashMap<>();
        List<Map<String, Object>> signList = new ArrayList<>();
        int start = page * pagesize;
        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;
        signList = jdbcTemplate.queryForList(sql, args);
        if (signList != null && signList.size() > 0) {
            for (Map<String, Object> sign : signList) {
                Patient p = patientDao.findByCode(sign.get("patient") == null ? "" : sign.get("patient").toString());
                if (p == null) {
                    continue;
                }
                if (result.containsKey(p.getCode())) {
                    JSONObject jsonP = result.get(p.getCode());
                    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 (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;
                    }
                }
                List<SignPatientLabelInfo> labels = labelInfoDao.findByPatientAndStatus(sign.get("patient").toString(), 1);
                JSONObject json = new JSONObject();
                // 设置患者标识
                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("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 {
                            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 result.size() > 0 ? new JSONArray(result.values()) : new JSONArray();
    }
}

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/sign/ExpensesRemindService.java

@ -174,7 +174,7 @@ public class ExpensesRemindService extends BaseService {
                isMobileExist = true;
                JSONObject result = smsService.sendMsg(p.getMobile(), doc.getName() + "医生提醒您:为完成家庭医生签约," +
                        "尽早为您提供家庭医生服务,请尽快到" + hos.getName() + "(地址:" + hos.getAddress() + ")缴费");
                if (result != null && result.getInt("result") == 1) {
                if (result != null && result.getInt("result") == 0) {
                    mFlag = true;
                }
                if (result != null) {

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

@ -364,12 +364,12 @@ public class StatisticsAllService extends BaseService {
        JSONObject signRate = new JSONObject();
        signRate.put("sign", total);
        signRate.put("people", num);
        signRate.put("rate", df.format((total * 1.0000) / num));
        signRate.put("rate", df.format((total * 1.0000) / num * 100));
        json.put("signRate",signRate);
        JSONObject signTaskRate = new JSONObject();
        signTaskRate.put("sign", total);
        signTaskRate.put("people", taskNum);
        signTaskRate.put("rate", df.format((total * 1.0000) / taskNum));
        signTaskRate.put("rate", df.format((total * 1.0000) / taskNum * 100));
        json.put("signTaskRate",signTaskRate);
        return json;

+ 43 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/app/team/AdminTeamService.java

@ -4,13 +4,16 @@ import com.yihu.wlyy.entity.doctor.profile.Doctor;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeam;
import com.yihu.wlyy.entity.doctor.team.admin.AdminTeamMember;
import com.yihu.wlyy.entity.patient.Patient;
import com.yihu.wlyy.entity.patient.SignFamily;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamDao;
import com.yihu.wlyy.repository.doctor.DoctorAdminTeamMemberDao;
import com.yihu.wlyy.repository.doctor.DoctorDao;
import com.yihu.wlyy.repository.doctor.DoctorTeamMemberDao;
import com.yihu.wlyy.repository.patient.SignFamilyDao;
import com.yihu.wlyy.service.BaseService;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -42,6 +45,9 @@ public class AdminTeamService extends BaseService {
    @Autowired
    DoctorTeamMemberDao signingTeamMemberDao;
    @Autowired
    SignFamilyDao signFamilyDao;
    /**
     * 获取团队数量。
     *
@ -322,4 +328,41 @@ public class AdminTeamService extends BaseService {
        return teamsTogether;
    }
    /**
     * 查询居民与医生的签约团队
     *
     * @param patient 居民
     * @param doctor  医生
     * @return
     */
    public JSONArray findPatientDoctorTeam(String patient, String doctor) {
        JSONArray result = new JSONArray();
        SignFamily ssSign = signFamilyDao.findSignByPatient(patient, 1);
        SignFamily jtSign = signFamilyDao.findSignByPatient(patient, 2);
        if (ssSign != null && (doctor.equals(ssSign.getDoctor())
                || doctor.equals(ssSign.getDoctorHealth()))) {
            AdminTeam team = getTeam(ssSign.getAdminTeamId());
            result.put(new JSONObject(team));
        }
        if (jtSign != null && (doctor.equals(jtSign.getDoctor())
                || doctor.equals(jtSign.getDoctorHealth()))) {
            AdminTeam team = getTeam(jtSign.getAdminTeamId());
            result.put(new JSONObject(team));
        }
        return result;
    }
    /**
     * 查询机构下团队
     *
     * @param hospital
     * @return
     */
    public List<AdminTeam> findHospitalTeams(String hospital){
        return teamDao.findByOrgCode(hospital);
    }
}

+ 30 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/common/area/AreaService.java

@ -0,0 +1,30 @@
package com.yihu.wlyy.service.common.area;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.repository.address.TownDao;
import com.yihu.wlyy.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 * Created by lyr-pc on 2016/11/22.
 */
@Service
public class AreaService extends BaseService {
    @Autowired
    TownDao townDao;
    /**
     * 查询城市城镇
     *
     * @param city
     * @return
     */
    public List<Town> getCityTowns(String city){
        return townDao.findByCityCode(city);
    }
}

+ 133 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/service/third/verified/VerifiedService.java

@ -0,0 +1,133 @@
package com.yihu.wlyy.service.third.verified;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yihu.wlyy.entity.dict.SystemDict;
import com.yihu.wlyy.service.system.SystemDictService;
import com.yihu.wlyy.service.third.ehr.EhrService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.DesUtils;
import com.yihu.wlyy.util.HttpClientUtil;
import com.yihu.wlyy.util.SystemConf;
import org.apache.axis.encoding.Base64;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONArray;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
 * Created by hzp on 2016/11/21.
 * 实名认证接口
 */
@Service
public class VerifiedService {
    //基卫服务地址
    private String jwUrl = SystemConf.getInstance().getJwUrl();
    //授权码
    private String appkey = "9683dbd88e0111e69beb0050569a506a";
    //对称加密
    private String desKey = "5063ebf54d76b16551e175fc71b0e5c7";
    @Autowired
    private ObjectMapper objectMapper = new ObjectMapper();
    /**
     * 获取随机数
     * @return
     * @throws Exception
     */
    private JSONObject getRandomNumber()  throws Exception
    {
        JSONObject data =  new JSONObject();
        String url = "http://auth.xmca.com.cn:9846/identification/api/v1.0/getRandomNumber.json";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("sessionID", "1"));
        params.add(new BasicNameValuePair("appKey", appkey));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        JSONObject responseJson = new JSONObject(response);
        if("200".equals(responseJson.optString("code")))
        {
            data = responseJson.getJSONObject("data");
        }
        else{
            throw new Exception("获取随机数失败:"+responseJson.optString("message"));
        }
        return data;
    }
    /**
     * 对称加密
     */
    private String getDesString(String str)  throws Exception
    {
        return DesUtils.encode(str,desKey);
    }
    /********************************************************************************************************************/
    /**
     * 身份认证
     */
    public void faceVerified(String idcard, String username, String picData) throws Exception {
        JSONObject random = getRandomNumber();
        String businessSerial = random.optString("businessSerial");
        String randomNumber = random.optString("randomNumber");
        String sessionID = random.optString("sessionID");
        String url = "http://auth.xmca.com.cn:9846/identification/api/v1.0/authenticate.json";
        List<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("idcard", getDesString(idcard)));
        params.add(new BasicNameValuePair("username", getDesString(username)));
        //params.add(new BasicNameValuePair("validityStartDate", validityStartDate));
        //validityEndDate
        params.add(new BasicNameValuePair("authenMode", "8"));
        params.add(new BasicNameValuePair("picData", picData));
        //authenData
        //idData
        params.add(new BasicNameValuePair("businessSerial", businessSerial));
        params.add(new BasicNameValuePair("sessionID", sessionID));
        params.add(new BasicNameValuePair("appKey", appkey));
        String response = HttpClientUtil.post(url, params, "UTF-8");
        JSONObject responseJson = new JSONObject(response);
        if("200".equals(responseJson.optString("code")))
        {
            JSONObject data = responseJson.getJSONObject("data");
            String result = responseJson.optString("authenResult");
            if(!result.startsWith("00"))
            {
               if(result.startsWith("1"))
               {
                   throw new Exception("DN及保留数据匹配失败!");
               }
                else if(result.startsWith("01")){
                   throw new Exception("人像匹配失败!");
               }
            }
        }
        else{
            throw new Exception("身份认证失败:"+responseJson.optString("message"));
        }
    }
}

+ 76 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/DesUtils.java

@ -0,0 +1,76 @@
/**
 * Copyright 2015 Software innovation and R & D center. All rights reserved.
 * File Name: DesUtils.java
 * Encoding UTF-8
 * Version: 0.0.1
 * History:	2016年10月31日
 */
package com.yihu.wlyy.util;
import org.apache.shiro.codec.Base64;
import java.security.Key;
import javax.crypto.Cipher;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESedeKeySpec;
import javax.crypto.spec.IvParameterSpec;
/**
 * 3des加密解密(base64)
 * @author: qigui.su
 * @version Revision: 0.0.1
 * @Date: 2016年10月31日
 */
public class DesUtils {
	 // 向量  
    private final static String iv = "01234567" ;  
    // 加解密统一使用的编码方式  
    private final static String encoding = "utf-8" ;  
       
    /** 
     * 3DES加密 
     * @author: qigui.su
     * @param plainText 内容
     * @param key 密匙不小于24
     * @return
     * @throws Exception
     */
    public static String encode(String plainText,String key) throws Exception {  
        Key deskey = null ;  
        DESedeKeySpec spec = new DESedeKeySpec(key.getBytes());  
        SecretKeyFactory keyfactory = SecretKeyFactory.getInstance( "DESede" );  
        deskey = keyfactory.generateSecret(spec);  
       
        Cipher cipher = Cipher.getInstance( "DESede/CBC/PKCS5Padding" );  
        IvParameterSpec ips = new IvParameterSpec(iv.getBytes());  
        cipher.init(Cipher.ENCRYPT_MODE, deskey, ips);  
        byte [] encryptData = cipher.doFinal(plainText.getBytes(encoding));  
        return Base64.encodeToString(encryptData);
    }  
       
    /** 
     * 3des解密
     * @author: qigui.su
     * @param encryptText 内容
     * @param key 密匙不小于24位
     * @return
     * @throws Exception
     */
    public static String decode(String encryptText, String key) throws Exception {  
        Key deskey = null ;  
        DESedeKeySpec spec = new DESedeKeySpec(key.getBytes());   
        SecretKeyFactory keyfactory = SecretKeyFactory.getInstance( "DESede" );  
        deskey = keyfactory.generateSecret(spec);  
        Cipher cipher = Cipher.getInstance( "DESede/CBC/PKCS5Padding" );  
        IvParameterSpec ips = new IvParameterSpec(iv.getBytes());  
        cipher.init(Cipher.DECRYPT_MODE, deskey, ips);  
       
        byte [] decryptData = cipher.doFinal(Base64.decode(encryptText));  
       
        return new String(decryptData, encoding);  
    }  
}

+ 44 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/area/AreaController.java

@ -0,0 +1,44 @@
package com.yihu.wlyy.web.common.area;
import com.yihu.wlyy.entity.address.Town;
import com.yihu.wlyy.service.app.label.SignPatientLabelInfoService;
import com.yihu.wlyy.service.common.area.AreaService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by lyr-pc on 2016/11/22.
 */
@RestController
@RequestMapping(value = "/area")
@Api(description = "城市、城镇管理")
public class AreaController extends BaseController {
    @Autowired
    AreaService areaService;
    /**
     * 查询城市下的城镇
     *
     * @param city 城市
     * @return
     */
    @RequestMapping(value = "/{city}/towns", method = RequestMethod.GET)
    public String getCityTowns(@PathVariable String city) {
        try {
            List<Town> towns = areaService.getCityTowns(city);
            return write(200, "查询成功", "data", towns == null ? new ArrayList<Town>() : towns);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 36 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/hospital/HospitalCommonController.java

@ -0,0 +1,36 @@
package com.yihu.wlyy.web.common.hospital;
import com.yihu.wlyy.entity.organization.Hospital;
import com.yihu.wlyy.service.app.hospital.HospitalService;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.List;
/**
 * Created by lyr-pc on 2016/11/22.
 */
@RestController
@RequestMapping(value = "/hospitals")
@Api(description = "医院管理")
public class HospitalCommonController extends BaseController {
    @Autowired
    HospitalService hospitalService;
    @RequestMapping(value = "/{town}/community_hospitals",method = RequestMethod.GET)
    @ApiOperation(value = "查询城镇下社区")
    public String getTownHospitals(@PathVariable String town) {
        try {
            List<Hospital> hospitals = hospitalService.getHositalByTownCode(town);
            return write(200, "查询成功", "data", hospitals == null ? new ArrayList<Hospital>() : hospitals);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
}

+ 77 - 0
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/verified/VerifiedController.java

@ -0,0 +1,77 @@
package com.yihu.wlyy.web.common.verified;
import com.yihu.wlyy.service.third.verified.VerifiedService;
import com.yihu.wlyy.util.DateUtil;
import com.yihu.wlyy.util.ImageCompress;
import com.yihu.wlyy.util.SystemConf;
import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.apache.commons.io.FileUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import sun.misc.BASE64Encoder;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
@Controller
@RequestMapping(value = "/verified", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
@Api(description = "实名认证")
public class VerifiedController extends BaseController {
	@Autowired
	private VerifiedService verifiedService;
	/**
	 * 人脸识别
	 */
	@RequestMapping(value = "face", method = RequestMethod.POST)
	@ResponseBody
	public String face(
			@ApiParam(name="idcard",value="身份证号码",defaultValue = "350628198802200051")
			@RequestParam(value="idcard",required = true) String idcard,
			@ApiParam(name="username",value="姓名",defaultValue = "黄展鹏")
			@RequestParam(value="username",required = true) String username,
			@ApiParam(name="picData",value="图片Base64转化后的输入流",defaultValue = "")
			@RequestBody String picData) throws Exception {
		try {
			/*// 将图片文件转化为字节数组字符串,并对其进行Base64编码处理
			String imgFile = "D:/1.jpg";// 待处理的图片
			InputStream in = null;
			byte[] data = null;
			// 读取图片字节数组
			try {
				in = new FileInputStream(imgFile);
				data = new byte[in.available()];
				in.read(data);
				in.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
			// 对字节数组Base64编码
			BASE64Encoder encoder = new BASE64Encoder();
			picData = encoder.encode(data);*/
			verifiedService.faceVerified(idcard,username,picData);
			return write(200, "人脸识别成功!");
		} catch (Exception e) {
			e.printStackTrace();
			return error(-1, e.getMessage());
		}
	}
}

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

@ -556,7 +556,7 @@ public class DoctorController extends BaseController {
                // 设置医生姓名
                json.put("name", temp.getName());
                // 设置医生头像
                json.put("photo", CommonUtil.getPhoneUrl(temp.getPhoto()));
                json.put("photo", temp.getPhoto());
                // 设置医生性别
                json.put("sex", temp.getSex());
                // 设置省名称

+ 150 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/patient/SignPatientLabelInfoController.java

@ -79,7 +79,7 @@ public class SignPatientLabelInfoController extends BaseController {
    }
    /**
     * 获取团队下的居民
     * 获取团队下的居民(当前医生下)
     *
     * @param teamCode
     * @param page
@ -109,6 +109,38 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    /**
     * 获取团队下的居民
     *
     * @param teamCode
     * @param page
     * @param pagesize
     * @return
     */
    @RequestMapping(value = "/team_patient")
    public String getTeamPatient(@RequestParam(required = true)Long teamCode,
                                       @RequestParam(required = false) String labelCode,
                                       @RequestParam(required = false) String labelType,
                                 @RequestParam(required = true)int page, @RequestParam(required = true)int pagesize) {
        try {
            if (teamCode == null || teamCode < 1) {
                return error(-1, "团队cdoe不能为空");
            }
            if (!StringUtils.isEmpty(labelCode) && StringUtils.isEmpty(labelType)) {
                return error(-1, "过滤标签参数不为空时过滤标签类型不能为空");
            }
            page = page - 1;
            JSONArray result = labelInfoService.getPatientByTeamCodeExitDoctor(teamCode, labelCode, labelType, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    /**
     * 查询某个团队的某个标签类型下各标签患者数
     *
@ -135,6 +167,49 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    /**
     * 查询某个团队的某个标签类型下各标签患者数/分组统计
     *
     * @param labelType 标签类型
     * @param teamCode  团队code
     * @return
     */
    @RequestMapping(value = "/label_team_amount")
    public String getPatientAmountByTeam(@RequestParam(required = false)String labelType, @RequestParam(required = true) Long teamCode) {
        try {
            if (StringUtils.isEmpty(labelType)) {
                labelType="0";
            }
            if (teamCode == null) {
                teamCode = 0L;
            }
            JSONArray result = labelInfoService.getPatientAmountByTeamGroupLable(teamCode,labelType);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    /**
     * 查询某个团队的患者数/汇总
     *
     * @param teamCode  团队code
     * @return
     */
    @RequestMapping(value = "/team_amount")
    public String getAmountByTeam(@RequestParam(required = true) Long teamCode) {
        try {
            int result = labelInfoService.getPatientAmountByTeam(teamCode);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            return error(-1, "查询失败");
        }
    }
    /**
     * 患者标签更新
     *
@ -192,7 +267,7 @@ public class SignPatientLabelInfoController extends BaseController {
                return error(-1, "患者不能为空");
            }
            JSONArray labels = labelInfoService.getPatientLabelByLabelTypeAndTeamCode(patient, labelType,teamCode);
            JSONArray labels = labelInfoService.getPatientLabelByLabelTypeAndTeamCode(patient, labelType,teamCode,getUID());
            return write(200, "查询成功", "data", labels);
        } catch (Exception e) {
@ -202,7 +277,7 @@ public class SignPatientLabelInfoController extends BaseController {
    }
    /**
     * 查询某个患者的某类标签
     * 查询某个患者的某类标签根据团队和当前医生
     *
     * @param filter 过滤字段
     * @return
@ -243,8 +318,12 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    @RequestMapping(value = "/patient_search_all", method = RequestMethod.GET)
    @ApiOperation("根据姓名搜索所有团队下居民")
    @ApiOperation("根据姓名搜索所有团队下居民(根据团队和当前医生)")
    public String searchPatients(@RequestParam(required = true) String filter,
                                 @RequestParam(required = false, defaultValue = "0") long teamCode,
                                 @RequestParam(required = false, defaultValue = "0") int page,
@ -263,6 +342,73 @@ public class SignPatientLabelInfoController extends BaseController {
        }
    }
    /**
     * 查询某个患者的某类标签(根据团队)
     *
     * @param filter 过滤字段
     * @return
     */
    @RequestMapping(value = "/patient_search_exitdoc")
    public String searchPatientByNameOrLabelExitDoc(@RequestParam(required = true) String filter,
                                             @RequestParam(required = false) String labelCode,
                                             @RequestParam(required = false) String labelType,
                                             @RequestParam(required = true) Long teamCode,
                                             @RequestParam(required = false) String exLabelCode,
                                             @RequestParam(required = false) String exLabelType,
                                             @RequestParam(required = true) int page, @RequestParam(required = true) int pagesize) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "搜索字段不能为空");
            }
            if (!StringUtils.isEmpty(labelCode) && StringUtils.isEmpty(labelType)) {
                return error(-1, "标签参数不为空时标签类型不能为空");
            }
            if (!StringUtils.isEmpty(exLabelCode) && StringUtils.isEmpty(exLabelType)) {
                return error(-1, "过滤标签参数不为空时过滤标签类型不能为空");
            }
            if (teamCode == null) {
                teamCode = 0L;
            }
            page = page - 1;
            JSONArray result = labelInfoService.searchPatientByNameOrLabel(filter, labelCode, labelType, teamCode, exLabelCode, exLabelType, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/patient_search_all_exitdoc", method = RequestMethod.GET)
    @ApiOperation("根据姓名搜索所有团队下居民(根据团队)")
    public String searchPatientsExitDoc(@RequestParam(required = true) String filter,
                                 @RequestParam(required = true, defaultValue = "0") long teamCode,
                                 @RequestParam(required = false, defaultValue = "0") int page,
                                 @RequestParam(required = false, defaultValue = "15") int pagesize) {
        try {
            if (StringUtils.isEmpty(filter)) {
                return error(-1, "查询参数不能为空");
            }
            JSONArray result = labelInfoService.searchTeamsPatients(filter,teamCode, page, pagesize);
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    /**
     * 添加居民到某个标签
     *

+ 35 - 6
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/doctor/team/AdminTeamController.java

@ -15,6 +15,7 @@ import com.yihu.wlyy.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.json.JSONArray;
import org.json.JSONObject;
@ -74,7 +75,7 @@ public class AdminTeamController extends BaseController {
    @RequestMapping(value = "/remove", method = RequestMethod.POST)
    @ApiOperation(value = "删除团队信息")
    public String deleteTeam(@RequestParam("teamId") long teamId){
    public String deleteTeam(@RequestParam("teamId") long teamId) {
        try {
            teamService.deleteTeam(teamId);
@ -162,7 +163,7 @@ public class AdminTeamController extends BaseController {
//  @ApiOperation(value = "获取团队成员,排除自己和专科医生")
    public String getTeamMembersExcludedThisAndLevel3(@PathVariable("team_id") long teamId) {
        try {
            List<Doctor> members = memberService.getMembers(teamId,super.getUID());
            List<Doctor> members = memberService.getMembers(teamId, super.getUID());
            return write(200, "OK", "data", new JSONArray(copyBeans(members, "id", "code", "name", "hospital",
                    "jobName", "level", "sex", "photo")));
@ -211,7 +212,7 @@ public class AdminTeamController extends BaseController {
    public String getLeaderTeam(@PathVariable("doctor_code") String doctorCode) {
        try {
            AdminTeam team = teamService.findByLeaderCode(doctorCode);
            if(team == null){
            if (team == null) {
                return error(-2, "没有找到数据!");
            }
            return write(200, "OK", "data", new JSONObject(team));
@ -238,7 +239,7 @@ public class AdminTeamController extends BaseController {
    @ApiOperation(value = "根据患者代码,获取医生团队信息")
    public String getTeam(@PathVariable("patient_code") String patientCode) {
        try {
           Map<String, Object> team = teamService.getPatientSigningTeam(patientCode,super.getUID());
            Map<String, Object> team = teamService.getPatientSigningTeam(patientCode, super.getUID());
            return write(200, "OK", "data", new JSONObject(team));
        } catch (Exception e) {
@ -272,7 +273,7 @@ public class AdminTeamController extends BaseController {
            page = page <= 0 ? 0 : page - 1;
            List<Patient> patients = memberService.getMemberSigningPatients(teamId, healthDoctorCode, page, size);
            List<Map<String, Object>> simplifiedPatients = new ArrayList<>();
            for (Patient patient : patients){
            for (Patient patient : patients) {
                Map<String, Object> simplified = new HashMap<>();
                simplified.put("code", patient.getCode());
                simplified.put("name", patient.getName());
@ -280,7 +281,7 @@ public class AdminTeamController extends BaseController {
                simplified.put("photo", patient.getPhoto());
                simplified.put("age", IdCardUtil.getAgeForIdcard(patient.getIdcard()));
                List<SignPatientLabelInfo>  diseases = signPatientLabelInfoService.getPatientLabelByLabelType(patient.getCode(),"3");
                List<SignPatientLabelInfo> diseases = signPatientLabelInfoService.getPatientLabelByLabelType(patient.getCode(), "3");
                List<String> simplifiedDisease = diseases.stream().map(SignPatientLabelInfo::getLabelName).collect(Collectors.toList());
@ -296,4 +297,32 @@ public class AdminTeamController extends BaseController {
        }
    }
    @RequestMapping(value = "/teams/patient", method = RequestMethod.GET)
    @ApiOperation(value = "查询居民与当前医生的签约团队")
    public String getPatientAndDoctorTeam(@RequestParam String patient) {
        try {
            if (StringUtils.isEmpty(patient)) {
                return error(-1, "居民不能为空");
            }
            JSONArray result = teamService.findPatientDoctorTeam(patient, getUID());
            return write(200, "查询成功", "data", result);
        } catch (Exception e) {
            e.printStackTrace();
            return error(-1, "查询失败");
        }
    }
    @RequestMapping(value = "/teams/{hospital}", method = RequestMethod.GET)
    @ApiOperation(value = "查询机构下的团队")
    public String getHospitalTeams(@PathVariable  String hospital){
        try{
            List<AdminTeam> teams =  teamService.findHospitalTeams(hospital);
            return write(200,"查询成功","data",teams);
        }catch (Exception e){
            e.printStackTrace();
            return error(-1,"查询失败");
        }
    }
}

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

@ -11,6 +11,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yihu.wlyy.entity.doctor.profile.Doctor;
@ -75,9 +76,9 @@ public class SignTeamController extends BaseController {
     * @param doctor 医生标识
     * @return
     */
    @RequestMapping(value = "info", method = RequestMethod.GET)
    @RequestMapping(value = "info")
    @ResponseBody
    public String info(String doctor) {
    public String info(@RequestParam(required = true,value = "doctor")String doctor) {
        try {
            Doctor temp = doctorInfoService.findDoctorByCode(doctor);
            if (temp != null) {

+ 1 - 1
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/patient/account/PatientController.java

@ -84,7 +84,7 @@ public class PatientController extends WeixinBaseController {
                // 设置患者姓名
                json.put("name", temp.getName());
                // 设置患者头像
                json.put("photo", CommonUtil.getPhoneUrl(temp.getPhoto()));
                json.put("photo", temp.getPhoto());
                // 设置患者年龄
                json.put("birthday", DateUtil.dateToStrShort(temp.getBirthday()));
                // 设置患者性别