@Override
  public boolean addJudge(
      String userPassword,
      String userName,
      String judgeName,
      String judgeGender,
      String judgeLevel,
      String identifiedId,
      String phonenum) {

    try {

      YsmsJudge ysmsJudge = new YsmsJudge();

      ysmsJudge.setDeleteflag(0);
      ysmsJudge.setIdentifiedName(judgeName);
      ysmsJudge.setIdentifiedGender(Integer.parseInt(judgeGender));
      ysmsJudge.setJudgeStatus(2);
      ysmsJudge.setIdentifiedId(identifiedId);
      ysmsJudge.setJudgeMobile(phonenum);
      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);

      YsmsUser ysmsUser = new YsmsUser();
      ysmsUser.setUserName(userName);
      ysmsUser.setUserPassword(userPassword);
      ysmsUser.setDeleteflag(0);
      // HARD CODE
      YsmsGroup ysmsGroup = groupDao.findById(9);
      ysmsUser.setYsmsGroup(ysmsGroup);

      // 先保存,进入持久态获取Id
      userDao.save(ysmsUser);
      judgeDao.save(ysmsJudge);

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

    } catch (Exception exception) {
      exception.printStackTrace();
      return false;
    }
    return true;
  }
  @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;
  }