Example #1
0
 public void load(Object myaction) throws Exception {
   DepartAction action = (DepartAction) myaction;
   if (action.getDepart() != null) {
     String departid = action.getDepart().getDepartid();
     if (departid != null) {
       TSysDepart object = (TSysDepart) getBaseDao().findById(TSysDepart.class, departid);
       action.setTsysDepart(object);
     }
     String updepartid = action.getDepart().getUpdepartid();
     if (updepartid != null) {
       TSysDepart object = (TSysDepart) getBaseDao().findById(TSysDepart.class, updepartid);
       object.setDepartid(null);
       object.setDepartcode(null);
       object.setDepartname(null);
       action.setTsysDepart(object);
     }
   }
 }
Example #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');
  }