/*
   * (non-Javadoc)
   *
   * @see com.changpeng.common.action.AbstractAction#go()
   */
  @Override
  protected String go() throws Exception {
    // TODO Auto-generated method stub

    //		BasicService basicService=(BasicService) this.getBean("basicService");

    sysUser.setCityid(this.datavisible.getCityid());
    sysUser.setProvinceid(this.datavisible.getProvinceid());
    sysUser.setOfficeid(this.datavisible.getOfficeid());

    SysGroup group = null;
    if (sysUser.getOfficeid() != 0) {
      group = new SysGroup();
      group.setGroupid(sysUser.getOfficeid());
      sysUser.setSysGroup(group);
    } else if (sysUser.getCityid() != 0) {
      group = new SysGroup();
      group.setGroupid(sysUser.getCityid());
      sysUser.setSysGroup(group);
    } else if (sysUser.getProvinceid() != 0) {
      group = new SysGroup();
      group.setGroupid(sysUser.getProvinceid());
      sysUser.setSysGroup(group);
    }

    service.updateUser(sysUser);

    this.message = "管理员信息修改成功,请确认";
    this.nextPage = "sysUserList.pl";
    return SUCCESS;
  }
  @Override
  public String input() throws Exception {

    LOG.debug("this.getLoginUser().getSysGroup():::" + this.getLoginUser().getSysGroup());

    if (this.getLoginUser().getSysGroup() == null
        || this.getLoginUser().getSysGroup().getGrouptype() != 1) {
      this.message = "你不是公证处管理员,请返回";
      this.nextPage = "gongzhengchuEditSelf!input.pl";
      return "message";
    }

    sysGroup = (SysGroup) bservice.get(SysGroup.class, this.getLoginUser().getOfficeid());
    oldloginname = sysGroup.getGroupenname();
    properties =
        (OfficeProperties) bservice.get(OfficeProperties.class, this.getLoginUser().getOfficeid());

    if (sysGroup.getGrouptype() != 1) {
      this.message = "你修改的不是公证处信息,请返回";
      // this.nextPage = "gongzhengchuList.pl";
      return "message";
    }

    isedit = true;

    if (properties == null) {
      properties = new OfficeProperties();
      propertiesedit = false;
    } else {
      propertiesedit = true;
    }

    set("sysGroup", sysGroup);
    set("properties", properties);

    return INPUT;
  }
  /*
   * (non-Javadoc)
   *
   * @see com.changpeng.common.action.AbstractAction#go()
   */
  @Override
  protected String go() throws Exception {

    if (sysGroup.getGroupenname() == null || sysGroup.getGroupenname().equals("")) {
      this.message = "公证处执业证号不能为空,请输入";
      // this.nextPage = "gongzhengchuList.pl";
      return "message";
    }

    sysGroup.setDelflag(false);

    if (upload != null && upload.length() != 0) {
      try {

        if (upload.length() > 1000 * 1024) {
          debug("删除上传图片成功否:" + upload.delete());
          this.message = "上传的图片大小超出了规定的最大大小1000K,请重新选择";

          return "message";
        }
        int index = fileName.lastIndexOf(".");
        String name = System.currentTimeMillis() + fileName.substring(index);

        String indexDir = com.changpeng.common.Constants.PHOTO_SAVE_PATH + "office/";
        File filedir = new File(indexDir);

        if (!filedir.exists()) {
          boolean s = filedir.mkdirs();
          debug("文件路径:::" + indexDir + "创建成功..." + s);
        }

        File file = new File(indexDir + System.getProperty("file.separator") + name);
        upload.renameTo(file);

        _LOG.debug("=================" + indexDir);
        properties.setPhoto("office/" + name);
        properties.setFilename(fileName);
      } catch (Exception e) {
        debug("照片上传失败..." + e);
        // e.printStackTrace();
      }
    }

    int s = groupservice.updateTheOffice(oldloginname, sysGroup);
    if (s == 0) {
      this.opResult = "公证处自己修改公证处信息修改登录帐号";
    }
    if (s == 3) {
      this.opResult = "公证处自己修改公证处信息同时新增一个公证处帐号";
    } else if (s == 1) {
      this.opResult = "公证处自己修改公证处信息,但该执业证号已经被其他所使用,修改为该所";
    } else if (s == 2) {
      this.opResult = "公证处自己修改公证处信息,帐号不变化";
    }
    // bservice.update(sysGroup);
    this.message = "公证处信息修改成功";

    if (!propertiesedit) {
      System.out.println(properties);
      properties.setCreatetime(new java.sql.Timestamp(System.currentTimeMillis()));
      properties.setCreateusername(this.getLoginUser().getUsername());
      properties.setGroupid(sysGroup.getGroupid());
      bservice.save(properties);
    } else {
      bservice.update(properties);
    }

    this.nextPage = "gongzhengchuEditSelf!input.pl";

    CommonDatas.getGroups();
    System.out.println("刷新下group的信息");
    // return "toparent";
    return SUCCESS;
  }