@Override
  public List<Map<String, Object>> getAtt(String forwardDir, String judgeId, String attType) {
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    try {
      list = judgeDao.gettAtt(Integer.parseInt(judgeId), Integer.parseInt(attType));

      if (!ToolsUtil.isEmpty(list)) {
        if ("0".equals(attType)) {
          list.get(0)
              .put(
                  "att_name",
                  forwardDir
                      + "upload"
                      + File.separator
                      + "identifiedCard"
                      + File.separator
                      + list.get(0).get("att_name"));
        } else if ("1".equals(attType)) {
          list.get(0)
              .put(
                  "att_name",
                  forwardDir
                      + "upload"
                      + File.separator
                      + "certificate"
                      + File.separator
                      + list.get(0).get("att_name"));
        }
      }

    } catch (Exception exception) {
      exception.printStackTrace();
    }
    return list;
  }
 @Override
 public Map<String, Object> getJudgeById(int judgeId) {
   Map<String, Object> map = new HashMap<String, Object>();
   try {
     List<Map<String, Object>> list = judgeDao.getJudgeById(judgeId);
     if (!ToolsUtil.isEmpty(list)) {
       map.put("judgeId", list.get(0).get("judge_id"));
       map.put("id", list.get(0).get("identified_id"));
       map.put("name", list.get(0).get("identified_name"));
       map.put("gender", list.get(0).get("identified_gender"));
       map.put("nationality", list.get(0).get("identified_nationality"));
       map.put("address", list.get(0).get("identified_address"));
       map.put("birthday", list.get(0).get("identified_birthday"));
       map.put("jobId", list.get(0).get("job_id"));
       map.put("jobName", list.get(0).get("job_name"));
       map.put("districtId", list.get(0).get("district_id"));
       map.put("districtName", list.get(0).get("district_name"));
       map.put("jobAddress", list.get(0).get("judge_jobaddress"));
       map.put("judgeLevel", list.get(0).get("judge_level"));
       map.put("mobile", list.get(0).get("judge_mobile"));
       map.put("tips", list.get(0).get("judge_tips"));
       List<Object> idList = new ArrayList<Object>();
       for (int i = 0; i < list.size(); i++) {
         idList.add(list.get(i).get("level_id"));
       }
       map.put("levels", idList);
     }
   } catch (Exception exception) {
     exception.printStackTrace();
   }
   return map;
 }
  @Override
  public Integer getAllJudgesCount(
      String identifiedName, String gender, String beginTime, String endTime, String judgeStatus) {
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    Integer count = 0;
    try {
      list = judgeDao.getJudgeListCount(identifiedName, gender, beginTime, endTime, judgeStatus);
      if (!ToolsUtil.isEmpty(list)) {
        count = Integer.parseInt(list.get(0).get("count").toString());
      }
    } catch (Exception exception) {
      exception.printStackTrace();
    }

    return count;
  }
  @Override
  public boolean updateJudge(
      String judgeId,
      String jobId,
      String jobAddress,
      String districtId,
      String identifiedAddress,
      String contact,
      String judgeLevel,
      String level,
      String nationality,
      String birthday,
      String identifiedId,
      String gender) {
    try {
      YsmsJudge ysmsJudge = judgeDao.findById(Integer.parseInt(judgeId));
      if (!ToolsUtil.isEmpty(jobId)) {
        YsmsJobs job = new YsmsJobs();
        job.setJobId(Integer.parseInt(jobId));
        ysmsJudge.setYsmsJobs(job);
      }
      if (!ToolsUtil.isEmpty(districtId)) {
        YsmsDistrict district = new YsmsDistrict();
        district.setDistrictId(Integer.parseInt(districtId));
        ysmsJudge.setYsmsDistrict(district);
      }
      if (!ToolsUtil.isEmpty(identifiedAddress)) {
        ysmsJudge.setIdentifiedAddress(identifiedAddress);
      }
      if (!ToolsUtil.isEmpty(jobAddress)) {
        ysmsJudge.setJudgeJobaddress(jobAddress);
      }
      if (!ToolsUtil.isEmpty(contact)) {
        ysmsJudge.setJudgeMobile(contact);
      }
      if (!ToolsUtil.isEmpty(level)) {
        ysmsJudge.setJudgeLevel(Integer.parseInt(level));
      }
      if (!ToolsUtil.isEmpty(nationality)) {
        ysmsJudge.setIdentifiedNationality(nationality);
      }
      if (!ToolsUtil.isEmpty(birthday)) {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        ysmsJudge.setIdentifiedBirthday(sdf.parse(birthday));
      }
      if (!ToolsUtil.isEmpty(identifiedId)) {
        ysmsJudge.setIdentifiedId(identifiedId);
      }
      if (!ToolsUtil.isEmpty(gender)) {
        ysmsJudge.setIdentifiedGender(Integer.parseInt(gender));
      }
      if (!ToolsUtil.isEmpty(judgeLevel)) {
        judgeAndLevelDao.deleteLevel(Integer.parseInt(judgeId));
        Set<YsmsJudgeandlevel> ysmsJudgeandlevels = new HashSet<YsmsJudgeandlevel>();
        String[] levels = judgeLevel.split(",");
        for (String _level : levels) {
          YsmsJudgeandlevel judgeandlevel = new YsmsJudgeandlevel();
          judgeandlevel.setYsmsJudge(ysmsJudge);
          YsmsJudgelevel judgeLevelTemp = new YsmsJudgelevel();
          judgeLevelTemp.setLevelId(Integer.parseInt(_level));
          judgeandlevel.setYsmsJudgelevel(judgeLevelTemp);
          ysmsJudgeandlevels.add(judgeandlevel);
        }
        ysmsJudge.setYsmsJudgeandlevels(ysmsJudgeandlevels);
      }

      judgeDao.updateById(ysmsJudge);
    } catch (Exception e) {
      e.printStackTrace();
      return false;
    }
    return true;
  }
  @Override
  public boolean applyJudge(
      String identifiedId,
      String identifiedName,
      int identifiedGender,
      String identifiedNationality,
      Date identifiedBirthday,
      String identifiedAddress,
      int jobId,
      int districtId,
      String jobAddress,
      int judgeLevel,
      int judgeStatus,
      String judgeMobile,
      String judgeTips,
      String fileName_id,
      String fileName_level,
      String username,
      String password) {
    try {
      YsmsJudge ysmsJudge = new YsmsJudge();

      ysmsJudge.setIdentifiedId(identifiedId);
      ysmsJudge.setIdentifiedName(identifiedName);
      ysmsJudge.setIdentifiedGender(identifiedGender);
      ysmsJudge.setIdentifiedNationality(identifiedNationality);
      ysmsJudge.setIdentifiedAddress(identifiedAddress);
      ysmsJudge.setJudgeJobaddress(jobAddress);
      ysmsJudge.setJudgeMobile(judgeMobile);
      ysmsJudge.setJudgeTips(judgeTips);
      ysmsJudge.setJudgeStatus(judgeStatus);
      ysmsJudge.setJudgeLevel(judgeLevel);
      ysmsJudge.setIdentifiedBirthday(identifiedBirthday);
      ysmsJudge.setDeleteflag(0);
      YsmsDistrict district = new YsmsDistrict();
      district.setDistrictId(districtId);
      ysmsJudge.setYsmsDistrict(district);
      YsmsJobs jobs = new YsmsJobs();
      jobs.setJobId(jobId);
      ysmsJudge.setYsmsJobs(jobs);
      judgeDao.save(ysmsJudge);

      YsmsUser ysmsUser = new YsmsUser();
      ysmsUser.setDeleteflag(0);
      ysmsUser.setUserName(username);
      ysmsUser.setUserPassword(password);
      ysmsUser.setYsmsGroup(groupDao.findById(9)); // hard code
      userDao.save(ysmsUser);

      YsmsJudgeUser ju = new YsmsJudgeUser();
      ju.setYsmsJudge(ysmsJudge);
      ju.setYsmsUser(ysmsUser);
      judgeUserDao.save(ju);

      if (!ToolsUtil.isEmpty(fileName_level)) {
        YsmsJudgeAtt att = new YsmsJudgeAtt();
        att.setAttName(fileName_level);
        att.setAttType(1); // type=0 身份证 1 等级证
        att.setYsmsJudge(ysmsJudge);
        judgeDao.saveAtt(att);
      }
      if (!ToolsUtil.isEmpty(fileName_id)) {
        YsmsJudgeAtt att = new YsmsJudgeAtt();
        att.setAttName(fileName_id);
        att.setAttType(0); // type=0 身份证 1 等级证
        att.setYsmsJudge(ysmsJudge);
        judgeDao.saveAtt(att);
      }

    } catch (Exception exception) {
      exception.printStackTrace();
      return false;
    }
    return true;
  }