Exemplo n.º 1
0
  /**
   * 审核处理
   *
   * @return
   */
  @RequestMapping(
      value = "auditDetailView",
      method = {RequestMethod.GET, RequestMethod.POST})
  public ModelAndView auditDetailView(HttpServletRequest request) {
    ModelAndView modelView = createModelAndViewWithSign("audit_detail", request);
    // 获取请假申请信息
    String id = HttpRequestUtil.getInst().getString("id");
    // 1、获取报销信息
    Expense expense = expenseService.getExpenseById(id);
    if (null == expense) {
      throw new VyiyunBusinessException("记录已被撤销或不存在!");
    }
    // 如果已审核
    if (CommonAppType.Status.已报销.value().equals(expense.getStatus())) {
      return expenseDetailView(request);
    }
    // 获取报销费用
    ExpenseFee expenseFee = new ExpenseFee();
    expenseFee.setExpenseId(id);
    List<ExpenseFee> listExpenseFee = expenseFeeService.getExpenseFee(expenseFee);
    if (!CollectionUtils.isEmpty(listExpenseFee)) {
      List<Map<String, Object>> dataMap = new ArrayList<Map<String, Object>>();
      Map<String, Object> temp = null;
      SystemStatusCache<Object> systemStatusCache =
          SystemCacheUtil.getInstance().getSystemStatusCache();
      for (ExpenseFee ex : listExpenseFee) {
        temp = ex.getPersistentState();
        temp.put(
            "categoryDisplay",
            systemStatusCache.getSystemStatusValue(
                HttpRequestUtil.getInst().getCurrentCorpId(), "CostCategory", ex.getCategory()));
        dataMap.add(temp);
      }
      modelView.addObject("listExpenseFee", dataMap);
    }
    // 获取当前审核人
    modelView.addObject("expenseInfo", expense);
    WeixinUser weixinUser = HttpRequestUtil.getInst().getCurrentWeixinUser();
    // 2、已审核人 报销人 待审核人 待带报销人
    // 获取当前审核人
    EntityAccount entityAccount = new EntityAccount();
    entityAccount.setEntityId(id);
    entityAccount.setEntityType(CommonAppType.EntityType.BX.value());
    entityAccount.setInvalid(false);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("orderBy", "UpdateTime desc");
    // 判断当前报销审批是否完成
    List<EntityAccount> entityAccountList =
        (List<EntityAccount>) entityAccountService.getEntityAccount(entityAccount);
    // 待审核
    StringBuffer alreadyUser = new StringBuffer();
    // 权限用户
    List<EntityAccount> entityAccounts = new ArrayList<EntityAccount>();

    if (!CollectionUtils.isEmpty(entityAccountList)) {
      for (EntityAccount ea : entityAccountList) {
        // 获取有效数据
        if (!ea.getInvalid()) {
          if (CommonAppType.PersonType.SH.value().equals(ea.getPersonType())) {
            if (!ea.getDealResult().equals("0")) {
              alreadyUser.append(",").append(ea.getAccountName());
            } else if (ea.getDealResult().equals("0")) {
              entityAccounts.add(ea);
            }
          } else if (CommonAppType.PersonType.CW.value().equals(ea.getPersonType())) {
            if (!ea.getDealResult().equals("0")) {
              alreadyUser.append(",").append(ea.getAccountName());
            } else if (ea.getDealResult().equals("0")
                && CommonAppType.Status.待报销.value().equals(expense.getStatus())) {
              entityAccounts.add(ea);
            }
          }
        }
      }

      // 当前审核人必须是一位
      if (entityAccounts.size() == 1) {
        modelView.addObject("entityAccount", entityAccounts.get(0));
        modelView.addObject("auditor", entityAccounts.get(0).getAccountName());
      } else if (entityAccounts.size() > 1) {
        throw new VyiyunException("数据错误,当前审核人必须是一位!");
      } else if (entityAccounts.isEmpty()) {
        return expenseDetailView(request);
      }
      // 当前非审核人
      if (!entityAccounts.get(0).getAccountId().equals(weixinUser.getUserid())) {
        return expenseDetailView(request);
      }
      if (alreadyUser.length() > 0) {
        alreadyUser.deleteCharAt(0);
      }
      modelView.addObject("alreadyUser", alreadyUser);
      modelView.addObject("shList", entityAccountList);
    } else {
      return expenseDetailView(request);
    }
    // 3、获取报销附件
    // 处理附件信息
    List<Accessory> accessoryList = accessoryService.getAccessoryByEntityId(id);
    if (!CollectionUtils.isEmpty(accessoryList)) {
      modelView.addObject("accessoryInfor", accessoryList);
    }
    // BUG #62 修改 zb.shen 2015年12月25日 start.
    modelView.addObject("flag", HttpRequestUtil.getInst().getString("flag"));
    // BUG #62 修改 zb.shen 2015年12月25日 end.
    return modelView;
  }
Exemplo n.º 2
0
  /**
   * 报销信息
   *
   * @return
   */
  @RequestMapping(
      value = "expenseDetailView",
      method = {RequestMethod.GET, RequestMethod.POST})
  public ModelAndView expenseDetailView(HttpServletRequest request) {
    ModelAndView modelView = createModelAndViewWithSign("expense_detail", request);
    // 获取请假申请信息
    String id = HttpRequestUtil.getInst().getString("id");
    String flag = HttpRequestUtil.getInst().getString("flag");
    // 这里给详情页面标示 页面来源路径 主要解决审批后退回问题
    if (StringUtils.isNotEmpty(flag)) {
      modelView.addObject("flag", flag);
    }
    // 1、获取报销信息
    Expense expense = expenseService.getExpenseById(id);
    if (null == expense) {
      throw new VyiyunBusinessException("记录已被撤销或不存在!");
    }
    modelView.addObject("expenseInfo", expense);
    modelView.addObject(
        "stautsDisplay",
        SystemCacheUtil.getInstance()
            .getSystemStatusCache()
            .getSystemStatusName("Status", expense.getStatus()));
    WeixinUser weixinUser = HttpRequestUtil.getInst().getCurrentWeixinUser();

    // 2、已审核人 报销人 待审核人 待带报销人
    String corpId = HttpRequestUtil.getInst().getCurrentCorpId();
    // 获取当前审核人
    EntityAccount entityAccount = new EntityAccount();
    entityAccount.setEntityId(id);
    entityAccount.setEntityType(CommonAppType.EntityType.BX.value());

    Map<String, Object> params = new HashMap<String, Object>();
    params.put("orderBy", "UpdateTime desc");
    // 判断当前报销审批是否完成
    // 这里会有两条数据
    List<EntityAccount> entityAccountList =
        (List<EntityAccount>) entityAccountService.getEntityAccount(entityAccount);
    // 审核
    List<EntityAccount> auditorList = new ArrayList<EntityAccount>();
    // 财务
    List<EntityAccount> principalList = new ArrayList<EntityAccount>();
    // 权限用户
    List<String> permissionUsers = new ArrayList<String>();
    // 拒绝
    EntityAccount refuse = null;

    if (!CollectionUtils.isEmpty(entityAccountList)) {
      for (EntityAccount ea : entityAccountList) {
        // 获取有效数据
        if (!ea.getInvalid()) {
          if (CommonAppType.PersonType.CW.value().equals(ea.getPersonType())) {
            principalList.add(ea);
            if (CommonAppType.CommandType.退回.value().equals(ea.getDealResult())) {
              refuse = ea;
            }
          } else if (CommonAppType.PersonType.SH.value().equals(ea.getPersonType())) {
            auditorList.add(ea);
          }
        }
        // 后续考虑
        permissionUsers.add(ea.getAccountId());
      }

      modelView.addObject("auditorList", auditorList);
      modelView.addObject("principalList", principalList);
      modelView.addObject("shList", entityAccountList);
    }
    // 3、获取报销附件
    // 处理附件信息
    List<Accessory> accessoryList = accessoryService.getAccessoryByEntityId(id);
    if (!CollectionUtils.isEmpty(accessoryList)) {
      modelView.addObject("accessoryInfor", accessoryList);
    }

    if (weixinUser.getUserid().equals(expense.getUserId())) {
      // 4、判断当前人是否为报销者且报销状态审核中 即 报销人可以催办
      if (!CommonAppType.Status.已报销.value().equals(expense.getStatus())) {
        modelView.addObject("userType", "0");
      }
    }
    // 获取报销费用
    ExpenseFee expenseFee = new ExpenseFee();
    expenseFee.setExpenseId(id);
    List<ExpenseFee> listExpenseFee = expenseFeeService.getExpenseFee(expenseFee);
    if (!CollectionUtils.isEmpty(listExpenseFee)) {
      List<Map<String, Object>> dataMap = new ArrayList<Map<String, Object>>();
      Map<String, Object> temp = null;
      SystemStatusCache<Object> systemStatusCache =
          SystemCacheUtil.getInstance().getSystemStatusCache();
      for (ExpenseFee ex : listExpenseFee) {
        temp = ex.getPersistentState();
        temp.put(
            "categoryDisplay",
            systemStatusCache.getSystemStatusValue(corpId, "CostCategory", ex.getCategory()));
        dataMap.add(temp);
      }
      modelView.addObject("listExpenseFee", dataMap);
    }
    // 批复结果
    // 报销已完成
    if (CommonAppType.Status.已报销.value().equals(expense.getStatus())) {
      modelView.addObject("expenseStatus", CommonAppType.Status.已报销.value());
      // modelView.addObject("remark", principalList.get(0).getRemark());
    } else // 报销已完成
    if (CommonAppType.Status.报销退回.value().equals(expense.getStatus())) {
      // 获取最后审批结果
      modelView.addObject("expenseStatus", CommonAppType.Status.报销退回.value());
      if (null != refuse) {
        modelView.addObject("remark", refuse.getRemark());
      }
    }
    // BUG #62 修改 zb.shen 2015年12月25日 start.
    modelView.addObject("flag", HttpRequestUtil.getInst().getString("flag"));
    // BUG #62 修改 zb.shen 2015年12月25日 end.
    return modelView;
  }