Esempio n. 1
0
 private String getSortNumInMenu(String loginName, String orgType, String flag, String isHead) {
   // 判断orgType在当前角色菜单中的排序
   // 当前用户角色
   String roleCode = reportAnalysisAppMapper.getRoleCodeByUserCode(loginName);
   String sortNum = "";
   Map<String, String> params = new HashMap<String, String>();
   params.put("roleCode", roleCode);
   if (BseConstants.REPORT_ANALYSIS_ORGTYPE_SALETERM.equals(orgType)
       && "1".equals(flag)
       && !BseConstants.YES.equals(isHead)) {
     params.put("orgType", BseConstants.REPORT_ANALYSIS_ORGTYPE_ROAD);
     sortNum = reportAnalysisAppMapper.getSortNumInMenu(params);
   } else if (BseConstants.REPORT_ANALYSIS_ORGTYPE_STORE.equals(orgType)
       && BseConstants.TERMMANAGE_CODE.equals(roleCode)) {
     params.put("orgType", BseConstants.REPORT_ANALYSIS_ORGTYPE_SALE);
     sortNum = reportAnalysisAppMapper.getSortNumInMenu(params);
   } else {
     params.put("orgType", orgType);
     sortNum = reportAnalysisAppMapper.getSortNumInMenu(params);
   }
   return sortNum;
 }
Esempio n. 2
0
  @Override
  public ResponseBaseEntity<ReportAnalysisAppVo> getReportAnalysisInfoData(
      ReportAnalysisAppVo reportAnalysisAppVo, String loginName) {
    ResponseBaseEntity<ReportAnalysisAppVo> responseBaseEntity =
        new ResponseBaseEntity<ReportAnalysisAppVo>();
    if (StringUtil.isEmpty(reportAnalysisAppVo.getDataTypeBySort())
        || StringUtil.isEmpty(reportAnalysisAppVo.getTimeType())) {
      responseBaseEntity.setErrorCode(AppUtil.EXCEPTION_STATUS_BUSINESS_ERROR);
      responseBaseEntity.setErrorMessage(AppUtil.REQUEST_PARAMETERS_EXCEPTION);
    } else {
      // 自定义报表数据结果
      ReportAnalysisAppVo result = new ReportAnalysisAppVo();
      // 自定义报表数据
      UserEntity currentUser = iLoginService.getUserByLoginName(loginName);
      Set<String> functions = currentUser.getFunctionCodes();
      String deptCode = "";
      if (currentUser.getEmpEntity().getDeptEntity() != null) {
        deptCode = currentUser.getEmpEntity().getDeptEntity().getDeptCode();
      }
      // 当前用户角色
      String roleCode = reportAnalysisAppMapper.getRoleCodeByUserCode(loginName);

      // 是否返回
      if (BseConstants.YES.equals(reportAnalysisAppVo.getIsHead())) {
        if (BseConstants.REPORT_ANALYSIS_ORGTYPE_BUSINESS.equals(
                reportAnalysisAppVo.getSupOrgType())
            || functions.contains(BseConstants.REPORT_ANALYSIS_ALLDATA)) {
          reportAnalysisAppVo.setOrgCode(BseConstants.GROUPCODE);
        } else {
          reportAnalysisAppVo.setOrgCode(deptCode);
        }
        result.setIsHidden(BseConstants.YES);
      } else if (BseConstants.REPORT_ANALYSIS_ISRETURN.equals(reportAnalysisAppVo.getIsReturn())) {
        String supOrgCode = reportAnalysisAppMapper.getSupOrgCode(reportAnalysisAppVo.getOrgCode());
        reportAnalysisAppVo.setOrgCode(supOrgCode);
      }

      // 上级部门编码
      if (!StringUtil.isEmpty(reportAnalysisAppVo.getSupOrgCode())) {
        result.setSupOrgCode(reportAnalysisAppVo.getSupOrgCode());
      } else {
        result.setSupOrgCode(reportAnalysisAppVo.getOrgCode());
      }

      // 区域类型
      String[] strs = reportAnalysisAppVo.getDataTypeBySort().split("-");
      // 数据类型
      String dataType = strs[0];
      // 排序规则
      String sortType = BseConstants.getSortKey(strs[1]);
      // 查询参数
      Map<String, String> params = new HashMap<String, String>();
      params.put("dataType", dataType);
      params.put("timeType", reportAnalysisAppVo.getTimeType());
      params.put("sortType", sortType);
      if (BseConstants.REPORT_ANALYSIS_ISRETURN.equals(reportAnalysisAppVo.getIsReturn())
          && BseConstants.YES.equals(reportAnalysisAppVo.getIsHead())) {
        params.put("orgType", reportAnalysisAppVo.getSupOrgType());
      }

      // 分页
      RowBounds rb = new RowBounds(reportAnalysisAppVo.getStart(), reportAnalysisAppVo.getLimit());

      if (!BseConstants.REPORT_ANALYSIS_ISRETURN.equals(reportAnalysisAppVo.getIsReturn())) {
        params.put("supOrg", reportAnalysisAppVo.getOrgCode());
      } else if (StringUtil.isEmpty(reportAnalysisAppVo.getIsHead())) {
        params.put("supOrg", reportAnalysisAppVo.getOrgCode());
      } else if (!functions.contains(BseConstants.REPORT_ANALYSIS_ALLDATA)
          && !BseConstants.YES.equals(reportAnalysisAppVo.getIsHead())) {
        params.put("supOrg", reportAnalysisAppVo.getOrgCode());
      } else if (!functions.contains(BseConstants.REPORT_ANALYSIS_ALLDATA)
          && BseConstants.YES.equals(reportAnalysisAppVo.getIsHead())) {
        params.put("orgParent", reportAnalysisAppVo.getOrgCode());
      }

      // 是否点击
      if (BseConstants.REPORT_ANALYSIS_ISRETURN.equals(reportAnalysisAppVo.getIsReturn())
          && !functions.contains(BseConstants.REPORT_ANALYSIS_ALLDATA)
          && this.isDefaultOrgType(reportAnalysisAppVo.getSupOrgType(), roleCode)) {
        params.put("deptCode", currentUser.getEmpEntity().getDeptEntity().getDeptCode());
      } else {
        params.put("isClick", BseConstants.YES);
      }

      // 百分比取值
      if (!functions.contains(BseConstants.REPORT_ANALYSIS_ALLDATA)) {
        if (BseConstants.REPORT_ANALYSIS_ORGTYPE_SALE.equals(reportAnalysisAppVo.getOrgType())) {
          params.put("procName", BseConstants.REPORT_ANALYSIS_PERCENT_EXEC_SALE);
        } else {
          params.put("procName", BseConstants.REPORT_ANALYSIS_PERCENT_EXEC);
        }
      }
      if (!BseConstants.YES.equals(reportAnalysisAppVo.getIsHead())) {
        params.put("percent", BseConstants.REPORT_ANALYSIS_PERCENT_1);
      } else if (BseConstants.YES.equals(reportAnalysisAppVo.getIsHead())
          && functions.contains(BseConstants.REPORT_ANALYSIS_ALLDATA)) {
        params.put("percent", BseConstants.REPORT_ANALYSIS_PERCENT_3);
      } else if (BseConstants.YES.equals(reportAnalysisAppVo.getIsHead())
          && !functions.contains(BseConstants.REPORT_ANALYSIS_ALLDATA)
          && BseConstants.REPORT_ANALYSIS_ORGTYPE_BUSINESS.equals(
              reportAnalysisAppVo.getOrgType())) {
        params.put("supOrgCode", BseConstants.GROUPCODE);
        params.put("percent", BseConstants.REPORT_ANALYSIS_PERCENT_2);
        reportAnalysisAppMapper.execPercent(params);
      } else if (BseConstants.YES.equals(reportAnalysisAppVo.getIsHead())
          && !functions.contains(BseConstants.REPORT_ANALYSIS_ALLDATA)
          && this.isDefaultOrgType(reportAnalysisAppVo.getSupOrgType(), roleCode)) {
        if (BseConstants.TERMMANAGE_CODE.equals(roleCode)
            || BseConstants.convertJobCode(BseConstants.MANAGENAME).equals(roleCode)) {
          params.put("supOrgCode", deptCode);
          params.put("percent", BseConstants.REPORT_ANALYSIS_PERCENT_2);
        } else {
          params.put("supOrgCode", currentUser.getEmpEntity().getDeptEntity().getSupdeptCode());
          params.put("percent", BseConstants.REPORT_ANALYSIS_PERCENT_2);
        }
        reportAnalysisAppMapper.execPercent(params);
      } else {
        params.put("supOrgCode", deptCode);
        params.put("percent", BseConstants.REPORT_ANALYSIS_PERCENT_2);
        reportAnalysisAppMapper.execPercent(params);
      }

      List<ReportAnalysisEntity> list = reportAnalysisAppMapper.getReportAnalysisInfos(params, rb);
      Set<String> orgTypes = new HashSet<String>();
      for (ReportAnalysisEntity obj : list) {
        if (BseConstants.REPORT_ANALYSIS_ORGTYPE_SALE.equals(obj.getOrgType())) {
          Map<String, String> saleInfo = reportAnalysisAppMapper.getManagerInfo(obj.getOrgCode());
          if (saleInfo != null) {
            obj.setManagerName(saleInfo.get("empname"));
            obj.setManagerCellphone(saleInfo.get("mobile"));
          }
          obj.setIsClick(BseConstants.NO);
        } else if (BseConstants.REPORT_ANALYSIS_ORGTYPE_ROAD.equals(obj.getOrgType())
            && (BseConstants.REPORT_ANALYSIS_DATATYPE_VISIT_ASC.equals(
                    reportAnalysisAppVo.getDataTypeBySort())
                || BseConstants.REPORT_ANALYSIS_DATATYPE_VISIT_DESC.equals(
                    reportAnalysisAppVo.getDataTypeBySort()))) {
          obj.setIsClick(BseConstants.NO);
        } else if (BseConstants.REPORT_ANALYSIS_ORGTYPE_STORE.equals(obj.getOrgType())) {
          obj.setIsClick(BseConstants.NO);
        }
        obj.setSortNum(
            this.getSortNumInMenu(
                loginName, obj.getOrgType(), "1", reportAnalysisAppVo.getIsHead()));
        if (BseConstants.YES.equals(reportAnalysisAppVo.getIsHead())) {
          obj.setHead(BseConstants.YES);
        }
        orgTypes.add(obj.getOrgType());
        // 人均是否隐藏
        if (BseConstants.REPORT_ANALYSIS_ORGTYPE_STORE.equals(obj.getOrgType())
            || BseConstants.REPORT_ANALYSIS_ORGTYPE_SALE.equals(obj.getOrgType())
            || (BseConstants.REPORT_ANALYSIS_ORGTYPE_ROAD.equals(obj.getOrgType())
                && (BseConstants.REPORT_ANALYSIS_DATATYPE_VISIT_ASC.equals(
                        reportAnalysisAppVo.getDataTypeBySort())
                    || BseConstants.REPORT_ANALYSIS_DATATYPE_VISIT_DESC.equals(
                        reportAnalysisAppVo.getDataTypeBySort())))) {
          obj.setHidden(BseConstants.YES);
        }
      }
      // 统一返回的管理区域(点击大区,返回值中会有(路区(3)和团队经理(5)))
      if (list != null && list.size() > 0 && orgTypes.size() == 1) {
        result.setOrgType(list.get(0).getOrgType());
      } else if (orgTypes.size() == 2) {
        result.setOrgType(BseConstants.REPORT_ANALYSIS_ORGTYPE_ROAD);
      }
      if (BseConstants.REPORT_ANALYSIS_ISRETURN.equals(reportAnalysisAppVo.getIsReturn())) {
        result.setSupOrgType(Integer.parseInt(reportAnalysisAppVo.getSupOrgType()) - 1 + "");
      } else {
        result.setSupOrgType(reportAnalysisAppVo.getOrgType());
      }
      // 当前列表下次返回是否返回顶部赋值
      if (!StringUtil.isEmpty(reportAnalysisAppVo.getSupOrgCode())) {
        result.setIsHead(BseConstants.YES);
      } else if (BseConstants.REPORT_ANALYSIS_ISRETURN.equals(reportAnalysisAppVo.getIsReturn())
          && (Integer.valueOf(reportAnalysisAppVo.getFirstSort())
                  - Integer.valueOf(reportAnalysisAppVo.getSupOrgType())
              == -1)) {
        result.setIsHead(BseConstants.YES);
      }
      // 组织名称
      result.setOrgName(this.getOrgName(reportAnalysisAppVo.getOrgCode()));

      result.setReportAnalysisEntities(list);
      result.setTotalCount(reportAnalysisAppMapper.countReportAnalysisInfos(params, rb));

      responseBaseEntity.setResult(result);
      responseBaseEntity.setErrorCode(AppUtil.EXCEPTION_STATUS_SUCCESS);
    }
    return responseBaseEntity;
  }