@Override
  protected Condition getGridSpecalCondition() {
    AndCondition ac = new AndCondition();
    // 查找当前登录用户条件
    SystemContext context = (SystemContext) this.getContext();
    // 当前用户
    Actor actor = context.getUser();

    // 定义id集合
    List<Long> ids = new ArrayList<Long>();

    // 查找属于当前用户
    ids.add(actor.getId());

    // 查找拥有的上级订阅
    List<Actor> uppers =
        this.actorService.findAncestorOrganization(
            actor.getId(),
            new Integer[] {Actor.TYPE_GROUP, Actor.TYPE_DEPARTMENT, Actor.TYPE_UNIT});

    for (Actor upper : uppers) {
      ids.add(upper.getId());
    }

    // 使用in条件
    ac.add(new InCondition("e.aid", ids));

    // 不显示草稿的
    ac.add(new NotEqualsCondition("s.status_", -1));

    return ac;
  }
 @Override
 public boolean isReadonly() {
   SystemContext context = (SystemContext) this.getContext();
   // 配置权限:报表管理员,报表模板管理员、超级管理员
   return !context.hasAnyRole(
       getText("key.role.bc.report"),
       getText("key.role.bc.report.template"),
       getText("key.role.bc.admin"));
 }
  @Override
  protected Condition getGridSpecalCondition() {
    // 状态条件
    AndCondition andCondition = new AndCondition();
    if (status != null && status.length() > 0 && !my) {
      andCondition.add(new EqualsCondition("a.status_", Integer.parseInt(status)));
    }

    if (my) {
      SystemContext context = (SystemContext) this.getContext();
      // 保存的用户id键值集合
      List<Object> ids = new ArrayList<Object>();
      ids.add(context.getUser().getId());
      Long[] aids = context.getAttr(SystemContext.KEY_ANCESTORS);
      for (Long id : aids) {
        ids.add(id);
      }

      // 根据集合数量,生成的占位符字符串
      String qlStr = "";
      for (int i = 0; i < ids.size(); i++) {
        if (i + 1 != ids.size()) {
          qlStr += "?,";
        } else {
          qlStr += "?";
        }
      }
      andCondition.add(
          // 我的报表显示为状态正常的
          new EqualsCondition("a.status_", BCConstants.STATUS_ENABLED),
          new OrCondition(
                  // 如果不配置使用人,则所有人都有权限使用
                  new QlCondition(
                      "a.id not in(select r.tid from  bc_report_template_actor r)",
                      new Object[] {}),
                  // 报表的使用人
                  new QlCondition(
                      "a.id in (select r.tid from  bc_report_template_actor r where r.aid in ("
                          + qlStr
                          + "))",
                      ids))
              .setAddBracket(true));
    }

    if (andCondition.isEmpty()) return null;

    return andCondition;
  }
Ejemplo n.º 4
0
  // 保存一个附件记录
  private Attach saveAttachLog(
      HttpServletRequest request,
      String localFile,
      String ptype,
      String puid,
      SystemContext context,
      String extend,
      long size,
      Calendar now,
      String path,
      boolean absolute) {
    // 剔除文件名中的路径部分
    int li = localFile.lastIndexOf("/");
    if (li == -1) li = localFile.lastIndexOf("\\");
    if (li != -1) localFile = localFile.substring(li + 1);

    // 创建附件记录
    Attach attach = new Attach();
    attach.setAuthor(context.getUserHistory());
    attach.setPtype(ptype);
    attach.setPuid(puid);
    attach.setFormat(extend);
    attach.setFileDate(now);
    attach.setPath(path);
    attach.setSize(size);
    attach.setSubject(localFile);
    attach.setAppPath(!absolute);
    attach = this.getAttachService().save(attach);

    // 创建附件上传日志
    AttachHistory history = new AttachHistory();
    history.setPtype(Attach.class.getSimpleName());
    history.setPuid(attach.getId().toString());
    history.setType(AttachHistory.TYPE_UPLOAD);
    history.setAuthor(context.getUserHistory());
    history.setFileDate(now);
    history.setPath(path);
    history.setAppPath(false);
    history.setFormat(attach.getFormat());
    history.setSubject(attach.getSubject());
    String[] c = WebUtils.getClient(request);
    history.setClientIp(c[0]);
    history.setClientInfo(c[2]);
    this.getAttachService().saveHistory(history);

    return attach;
  }
  @Override
  public String save() throws Exception {
    SystemContext context = this.getSystyemContext();

    // 设置最后更新人的信息
    Cert4RoadTransport e = this.getE();
    e.setModifier(context.getUserHistory());
    e.setModifiedDate(Calendar.getInstance());
    this.getCrudService().save(e);

    // 保存证件与车辆的关联表信息
    if (carId != null) {
      this.certService.carNCert4Save(carId, getE().getId());
    }

    return "saveSuccess";
  }
  /**
   * 结案操作
   *
   * @param fromBusinessId
   * @param closeDate
   * @return
   */
  public Case4InfractBusiness doCloseFile(Long fromBusinessId, Calendar closeDate) {
    Case4InfractBusiness business = this.caseBusinessDao.load(fromBusinessId);
    if (business == null) throw new CoreException("要处理的营运违章已不存在!businessId=" + fromBusinessId);

    // 更新营运违章相关信息
    business.setStatus(CaseBase.STATUS_CLOSED);

    // 设置创建人信息和最后修改人信息
    SystemContext context = SystemContextHolder.get();
    business.setModifier(context.getUserHistory());
    business.setModifiedDate(Calendar.getInstance());

    // 设置结案人,结案日期
    business.setCloserId(context.getUserHistory().getId());
    business.setCloserName(context.getUserHistory().getName());
    business.setCloseDate(closeDate);

    return this.caseBusinessDao.save(business);
  }
 @Override
 public boolean isReadonly() {
   SystemContext context = (SystemContext) this.getContext();
   // 配置权限:电子邮件管理角色或系统管理员
   return !context.hasAnyRole(getText("key.role.bc.email.manage"), getText("key.role.bc.admin"));
 }
  // 同步附件
  private void syscAttach(Case4InfractBusiness cib, String procInstId, String taskId) {
    if (cib == null || procInstId == null || procInstId.length() == 0) return;

    List<Attach> attachs =
        attachService.findByPtype(Case4InfractBusiness.ATTACH_TYPE, cib.getUid());
    if (attachs == null || attachs.size() == 0) return;

    for (Attach attach : attachs) {
      // 复制附件到流程附件位置中----开始---
      // 扩展名
      String extension = StringUtils.getFilenameExtension(attach.getPath());
      // 文件存储的相对路径(年月),避免超出目录内文件数的限制
      String subFolder = DateUtils.formatCalendar(Calendar.getInstance(), "yyyyMM");
      // 上传文件存储的绝对路径
      String appRealDir = Attach.DATA_REAL_PATH + File.separator + FlowAttach.DATA_SUB_PATH;
      // 所保存文件所在的目录的绝对路径名
      String realFileDir = appRealDir + File.separator + subFolder;
      // 不含路径的文件名
      String fileName =
          DateUtils.formatCalendar(Calendar.getInstance(), "yyyyMMddHHmmssSSSS") + "." + extension;
      // 所保存文件的绝对路径名
      String realFilePath = realFileDir + File.separator + fileName;
      // 构建文件要保存到的目录
      File _fileDir = new File(realFileDir);
      if (!_fileDir.exists()) {
        if (logger.isFatalEnabled()) logger.fatal("mkdir=" + realFileDir);
        _fileDir.mkdirs();
      }
      // 直接复制附件
      if (logger.isInfoEnabled()) logger.info("pure copy file");

      // 附件路径
      String path = Attach.DATA_REAL_PATH + File.separator + attach.getPath();

      // 从附件目录下的指定文件复制到attachment目录下
      try {
        FileCopyUtils.copy(new FileInputStream(new File(path)), new FileOutputStream(realFilePath));
      } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
      }

      // 复制附件到流程附件位置中----结束---

      // 插入流程附件记录信息
      FlowAttach flowAttach = new FlowAttach();
      flowAttach.setUid(idGeneratorService.next(FlowAttach.ATTACH_TYPE));
      flowAttach.setType(FlowAttach.TYPE_ATTACHMENT); // 类型:1-附件,2-意见
      flowAttach.setPid(procInstId); // 流程id
      flowAttach.setPath(subFolder + File.separator + fileName); // 附件路径,物理文件保存的相对路径
      flowAttach.setExt(extension); // 扩展名
      flowAttach.setSubject(attach.getSubject()); // 标题
      flowAttach.setSize(attach.getSize());
      flowAttach.setFormatted(false); // 附件是否需要格式化

      if (taskId == null) {
        flowAttach.setCommon(true); // 公共附件
      } else {
        flowAttach.setCommon(false); // 任务附件
        flowAttach.setTid(taskId);
      }

      // 创建人,最后修改人信息
      SystemContext context = SystemContextHolder.get();
      flowAttach.setAuthor(context.getUserHistory());
      flowAttach.setModifier(context.getUserHistory());
      flowAttach.setFileDate(Calendar.getInstance());
      flowAttach.setModifiedDate(Calendar.getInstance());
      this.flowAttachService.save(flowAttach);
    }
  }
Ejemplo n.º 9
0
 // @Override
 // public boolean isReadonly() {
 // // 模板管理员或系统管理员
 // SystemContext context = (SystemContext) this.getContext();
 // // 配置权限:模板管理员
 // return !context.hasAnyRole(getText("key.role.bc.netdisk"),
 // getText("key.role.bc.admin"));
 // }
 // 公共硬盘管理权限
 public boolean isPublicHardDiskManagement() {
   // 模板管理员或系统管理员
   SystemContext context = (SystemContext) this.getContext();
   // 配置权限:公共管理员
   return context.hasAnyRole(getText("key.role.bc.netdisk.public"), getText("key.role.bc.admin"));
 }
Ejemplo n.º 10
0
  @Override
  protected Condition getGridSpecalCondition() {
    OrCondition orCondition = new OrCondition();
    AndCondition operateFoldersCondition = new AndCondition();
    AndCondition publicFoldersCondition = new AndCondition();
    // 状态条件
    Condition statusCondition = null;
    Condition typeCondition = null;
    // Condition userCondition = null;
    Condition authorityCondition = null;
    Condition eliminateCondition = null;
    // Condition tierCondition = null;

    // 状态
    if (status != null && status.length() > 0) {
      String[] ss = status.split(",");
      if (ss.length == 1) {
        statusCondition = new EqualsCondition("f.status_", new Integer(ss[0]));
      } else {
        statusCondition = new InCondition("f.status_", StringUtils.stringArray2IntegerArray(ss));
      }
    }
    // 文件夹类型
    typeCondition = new EqualsCondition("f.type_", NetdiskFile.TYPE_FOLDER);
    // 当前用户只能查看自己上传的文件
    SystemContext context = (SystemContext) this.getContext();
    // userCondition = new EqualsCondition("f.author_id", context
    // .getUserHistory().getId());

    // 文件夹不能隶属于自己
    if (folderId != null) {
      eliminateCondition = new NotEqualsCondition("f.id", folderId);
    }
    // 父级文件夹不能隶属子级
    // 当前用户有权限查看的文件
    Serializable[] ids = this.netdiskFileService.getUserSharFileId2All(context.getUser().getId());
    // 查找当前文件的父级
    // 可以操作的文件夹id
    List<Object> operateId = new ArrayList<Object>();
    if (folderId != null) {
      Serializable[] myselfAndChildId = this.netdiskFileService.getMyselfAndChildFileId(folderId);
      // 排除自己与子文件id后来的数组
      List<Object> eliminateId = new ArrayList<Object>();
      if (ids != null) {
        for (Serializable id : ids) {
          boolean isIn = false;
          for (Serializable pid : myselfAndChildId) {
            if (id.equals(pid)) {
              isIn = true;
              break;
            }
          }
          if (!isIn) {
            eliminateId.add(id);
          }
        }
        // 找出可操作的id
        if (!eliminateId.isEmpty()) {
          for (int i = 0; i < eliminateId.size(); i++) {
            // 查看当前文件是否设置访问权限,如果有就根据当前的权限来判断
            NetdiskShare myNetdiskShare =
                this.netdiskFileService.getNetdiskShare(
                    context.getUser().getId(), Long.valueOf(eliminateId.get(i).toString()));
            // 如果是自己的建的文件夹也操作
            NetdiskFile netdiskFile =
                this.netdiskFileService.load(Long.valueOf(eliminateId.get(i).toString()));
            if (netdiskFile.getAuthor().getId().equals(context.getUserHistory().getId())) {
              operateId.add(eliminateId.get(i));
            } else if (myNetdiskShare != null) {
              if (haveAuthority(myNetdiskShare.getRole(), 0)) {
                // 如果有权限就添加
                operateId.add(eliminateId.get(i));
              }
            } else {
              // 获取当前的文件和父级文件
              Serializable[] ParentIds =
                  this.netdiskFileService.getMyselfAndParentsFileId(
                      Long.valueOf(eliminateId.get(i).toString()));
              // 判断当前文件或父级文件夹该用户是否拥有编辑权限
              for (Serializable pid : ParentIds) {
                boolean isOwer = false;
                NetdiskFile nf = this.netdiskFileService.load(pid);
                Set<NetdiskShare> netdiskShare = nf.getFileVisitors();
                if (!netdiskShare.isEmpty()) {
                  Iterator<NetdiskShare> n = netdiskShare.iterator();
                  while (n.hasNext()) {
                    NetdiskShare ns = n.next();
                    if (ns.getAid().equals(context.getUser().getId())) {
                      if (haveAuthority(ns.getRole(), 0)) {
                        // 如果有权限就添加
                        operateId.add(eliminateId.get(i));
                        isOwer = true;
                        break;
                      }
                    }
                  }
                  if (isOwer) {
                    break;
                  }
                }
              }
            }
          }
        }
      }

      // 组装条件
      String qlStr4File = "";
      if (operateId.size() != 0) {
        for (int i = 0; i < operateId.size(); i++) {
          if (i + 1 != operateId.size()) {
            qlStr4File += "?,";
          } else {
            qlStr4File += "?";
          }
        }
      }
      authorityCondition =
          orCondition
              .add(
                  (operateId.size() != 0
                      ? new QlCondition("f.id in (" + qlStr4File + ")", operateId)
                      : null))
              .setAddBracket(true);
    }
    // 如果是公共硬盘管理员可以选择公共硬盘的文件夹
    Condition publicCondition = null;
    if (this.isPublicHardDiskManagement()) {
      publicCondition = new EqualsCondition("f.folder_type", NetdiskFile.FOLDER_TYPE_PUBLIC);
    }

    // 可以操作的文件夹不为空和有权限的
    if (operateId.size() != 0 && publicCondition != null) {
      return ConditionUtils.mix2OrCondition(
          operateFoldersCondition
              .add(statusCondition, typeCondition, eliminateCondition, authorityCondition)
              .setAddBracket(true),
          publicFoldersCondition
              .add(statusCondition, publicCondition, typeCondition)
              .setAddBracket(true));
      // 没有公共硬盘管理权限的
    } else if (operateId.size() != 0 && publicCondition == null) {
      return operateFoldersCondition.add(
          statusCondition, typeCondition, eliminateCondition, authorityCondition);
      // 没有可以操作的文件但有公共权限的
    } else if (operateId.size() == 0 && publicCondition != null) {
      return publicFoldersCondition.add(statusCondition, publicCondition, typeCondition);
    } else {
      return null;
    }
  }
Ejemplo n.º 11
0
  public String doStartFlow(String key, Long[] ids, boolean flag_status) {
    // 声明变量
    Map<String, Object> variables;
    TempDriver tempDriver;
    // 流程模块关系domain
    WorkflowModuleRelation workflowModuleRelation;
    // 声明返回的流程实例id 多个逗号隔开
    String procInstIds = "";

    // 循环Id数组
    for (Long id : ids) {
      tempDriver = this.tempDriverDao.load(id);
      // 记录同步的详细关键信息
      String desc = "";
      if (flag_status) {
        desc += "将" + tempDriver.getName() + "的招聘信息状态从";
        switch (tempDriver.getStatus()) {
          case TempDriver.STATUS_RESERVE:
            desc += "待聘";
            break;
          case TempDriver.STATUS_CHECK:
            desc += "审批中";
            break;
          case TempDriver.STATUS_PASS:
            desc += "聘用";
            break;
          case TempDriver.STATUS_GIVEUP:
            desc += "未聘用";
            break;
        }
        desc += "修改为审批中";
        // 更新司机的状态为审批中
        tempDriver.setStatus(TempDriver.STATUS_CHECK);
        this.tempDriverDao.save(tempDriver);
      }
      SystemContext sc = SystemContextHolder.get();
      sc.setAttr(ExcutionLog.SYNC_INFO_FLAG, true);
      sc.setAttr(ExcutionLog.SYNC_INFO_VALUE, desc);

      variables = new HashMap<String, Object>();

      // 入职审批流程加载全部信息
      if ("CarManEntry".equals(key)) {
        this.returnParam(tempDriver, variables);
      } else {
        variables.put("tempDriver_id", tempDriver.getId());
        variables.put("name", tempDriver.getName());
        variables.put("certIdentity", tempDriver.getCertIdentity());
      }

      // 发起流程
      String procInstId = this.workflowService.startFlowByKey(key, variables);
      procInstIds += procInstId + ",";
      // 增加流程关系
      workflowModuleRelation = new WorkflowModuleRelation();
      workflowModuleRelation.setMid(id);
      workflowModuleRelation.setPid(procInstId);
      workflowModuleRelation.setMtype(TempDriver.WORKFLOW_MTYPE);
      this.workflowModuleRelationService.save(workflowModuleRelation);
    }

    return procInstIds;
  }
 @Override
 public boolean isReadonly() {
   // 车辆证件管理员或系统管理员
   SystemContext context = (SystemContext) this.getContext();
   return !context.hasAnyRole(getText("key.role.bs.cert4car"), getText("key.role.bc.admin"));
 }