示例#1
0
  public List<?> search(Object myaction, Pager pager) throws Exception {
    DepartAction action = (DepartAction) myaction;
    TSysDepart tSysDepart = action.getTsysDepart();
    TDepartDetail tDepartDetail = action.getDepartDetail();
    String sqlcolumn =
        "select a.departid,a.departname, "
            + "(select c.departname from T_Sys_Depart c where c.departid=a.updepartid) as updepartid,"
            + "b.linkman,b.linktel,b.email,b.fax ";
    String sql =
        " from T_Sys_Depart a left join T_Depart_Detail b on a.departid=b.departid where a.departid like '"
            + action.getDepartID()
            + "%' and a.sfsn='1'";

    if (tSysDepart != null) {
      if (StringUtils.isNotBlank(tSysDepart.getDepartname())) {
        sql += " and a.departname like '%" + tSysDepart.getDepartname() + "%'";
      }
      if (StringUtils.isNotBlank(tSysDepart.getDepartid())) {
        sql += " and a.departid like '" + tSysDepart.getDepartid() + "%'";
      }
      if (StringUtils.isNotBlank(tSysDepart.getUpdepartid())) {
        sql +=
            " and a.updepartid in (select c.departid from T_Sys_Depart c where c.departname like '%"
                + tSysDepart.getUpdepartid()
                + "%')";
      }
    }
    if (tDepartDetail != null) {
      if (StringUtils.isNotBlank(tDepartDetail.getLinkman())) {
        sql += " and b.linkman like '%" + tDepartDetail.getLinkman() + "%'";
      }
    }
    long c = DBUtil.count(" select count(*) as c " + sql);
    pager.setTotalRows(c);
    sql = sqlcolumn + sql + "  order by a.departid ,a.cc desc ";
    List<?> list = DBUtil.queryPageList(pager, sql);
    return list;
  }
示例#2
0
  public void saveOrUpdate(Object myaction) throws Exception {
    DepartAction action = (DepartAction) myaction;
    TSysDepart object = action.getTsysDepart();
    object.setUpdepartid(action.getUpdepartid());
    if (object.getDepartname() != null && object.getDepartnamePy() == null) {
      object.setDepartnamePy(Char2spell.getPYString(object.getDepartname()));
    }
    TDepartDetail tDepartDetail = action.getDepartDetail();

    String proceduceName = SQLConfigUtil.getProcName("procd.changeDepart");
    if (object.getDepartid() == null || "".equals(object.getDepartid())) {
      String deptid = getNewDepartid(action.getUpdepartid());
      /**
       * String deptid=""; String sql="select max(departid) from t_sys_depart where
       * updepartid='"+object.getUpdepartid()+"'"; String id=(String)DBUtil.queryField(sql);
       * if(id==null) { deptid=object.getUpdepartid()+"001"; } else { Long nl=Long.parseLong(id)+1L;
       * deptid=String.valueOf(nl); }
       */
      object.setDepartid(deptid);
      if ("0".equals(object.getUpdepartid())) {
        object.setCc("1");
        object.setDeparttype("1");
      } else {
        // 查询上级部门
        TSysDepart updepart =
            (TSysDepart) getBaseDao().findById(TSysDepart.class, action.getUpdepartid());
        if (updepart == null) return;
        object.setCc(String.valueOf(Integer.parseInt(updepart.getCc()) + 1));
        object.setDeparttype(getDeparttype(updepart.getDeparttype()));
      }
      getBaseDao().save(object);
      tDepartDetail.setDepartid(deptid);
      getBaseDao().save(tDepartDetail);
      BusinessLogUtil.log(
          action.getLoginUser().getUserLoginId(),
          SysConstants.CZDX_T_SYS_DEPART,
          SysConstants.LOG_ACTION_SAVE);
      action.setSuccessFlag("1");

      DBUtil.execUniProcNoneQuery(proceduceName, deptid, "1"); // 调用存储过程更新相关业务数据
    } else {
      // 动态更新
      TSysDepart olddepart =
          (TSysDepart) getBaseDao().findById(TSysDepart.class, object.getDepartid());
      // 如果不为空则更新部门名称
      if (StringUtils.isNotBlank(object.getDepartname())) {
        olddepart.setDepartname(object.getDepartname());
      }
      // 如果不为空则更新上级部门ID
      if (StringUtils.isNotBlank(action.getUpdepartid())) {
        olddepart.setUpdepartid(action.getUpdepartid());
      }
      // 如果不为空则更新部门ID
      // if(StringUtils.isNotBlank(action.getTsysDepart().getDepartid())){
      // olddepart.setDepartid(action.getTsysDepart().getDepartid());
      // }
      olddepart.setSfsn(object.getSfsn());
      olddepart.setState(object.getState());
      getBaseDao().update(olddepart);
      BusinessLogUtil.log(
          action.getLoginUser().getUserLoginId(),
          SysConstants.CZDX_T_SYS_DEPART,
          SysConstants.LOG_ACTION_UPDATE);
      // 动态更新
      TDepartDetail olddetail =
          (TDepartDetail) getBaseDao().findById(TDepartDetail.class, object.getDepartid());
      // 如果不为空则更新部门ID
      // if(StringUtils.isNotBlank(action.getTsysDepart().getDepartid())){
      // tDepartDetail.setDepartid(action.getTsysDepart().getDepartid());
      // }
      if (olddetail == null) {
        olddetail = new TDepartDetail();
        olddetail.setDepartid(object.getDepartid());
        // throw new Exception("数据不完整,缺少此部门的扩展信息数据。请联系技术人员解决此问题!");
      }
      olddetail.setAccount1(tDepartDetail.getAccount1());
      olddetail.setAccount2(tDepartDetail.getAccount2());
      olddetail.setHh(tDepartDetail.getHh());
      olddetail.setHh2(tDepartDetail.getHh2());
      olddetail.setZhmc(tDepartDetail.getZhmc());
      olddetail.setZhmc2(tDepartDetail.getZhmc2());
      olddetail.setAddress(tDepartDetail.getAddress());
      olddetail.setBank1(tDepartDetail.getBank1());
      olddetail.setBank2(tDepartDetail.getBank2());
      olddetail.setEmail(tDepartDetail.getEmail());
      olddetail.setFax(tDepartDetail.getFax());
      olddetail.setLinkman(tDepartDetail.getLinkman());
      olddetail.setLinktel(tDepartDetail.getLinktel());
      olddetail.setPostcode(tDepartDetail.getPostcode());
      //
      getBaseDao().saveOrUpdate(olddetail);
      //
      action.setSuccessFlag("1");
      DBUtil.execUniProcNoneQuery(proceduceName, object.getDepartid(), "2"); // 调用存储过程更新相关业务数据
    }

    DBUtil.execOracleProcQueryString("prc_sys_init(?,?,?)", CommonQuery.getThisSchoolYear(), '0');
  }