Пример #1
0
  public void performTask(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    String forwardURL = "";
    Message message = SessionUtil.getMessage(req);
    Connection conn = null;
    try {
      conn = getDBConnection(req);
      SfUserDTO user = (SfUserDTO) SessionUtil.getUserAccount(req);
      Request2DTO req2DTO = new Request2DTO();
      req2DTO.setDTOClassName(AmsAssetsCJYCDTO.class.getName());
      AmsAssetsCJYCDTO dtoParameter = (AmsAssetsCJYCDTO) req2DTO.getDTO(req);
      AmsAssetsQJCJYCDAO dao = new AmsAssetsQJCJYCDAO(user, dtoParameter, conn);
      ServletConfigDTO sevletConfig = SessionUtil.getServletConfigDTO(req);
      dtoParameter.setFaCategory1(SinoConfig.getFaCat1Mis());
      dtoParameter.setFaCategory2(SinoConfig.getFaCat2Mis());
      dtoParameter.setFaCategory3(SinoConfig.getFaCat3Mis());

      String action = req.getParameter("act");
      action = StrUtil.nullToString(action);
      OptionProducer op = new OptionProducer(user, conn);
      int organizationId = StrUtil.strToInt(dtoParameter.getBookTypeCode());
      String companySelect = op.getAllOrganization(organizationId, true);
      req.setAttribute("OU", companySelect);
      String monthOption = op.getFromMonthOption(dtoParameter.getFromMonth());
      String tomonthOption = op.getFromMonthOption(dtoParameter.getToMonth());
      String bookTypeCode = dtoParameter.getBookTypeCode();
      String bookSelect = op.getAllBookTypeName(bookTypeCode, true);
      String catSegment1 = dtoParameter.getCatSegment1();
      String catSegment1Servlet = op.getUseField(catSegment1, true);
      req.setAttribute("CATSEGMENT1", catSegment1Servlet);
      req.setAttribute("BOOK_TYPE_CODE", bookSelect);
      req.setAttribute("FROM_MONTH_OPTION", monthOption);
      req.setAttribute("TO_MONTH_OPTION", tomonthOption);
      req.setAttribute("AMSBJTRANSNOHDTO", dtoParameter);
      if (action.equals("")) {
        forwardURL = "/newasset/assetsQJCJYC.jsp";
      } else if (action.equals(AssetsActionConstant.QUERY_ACTION)) {
        BaseSQLProducer sqlProducer = new AmsAssetsQJCJYCModel(user, dtoParameter);
        PageQueryDAO pageDAO = new PageQueryDAO(req, conn, sqlProducer);
        pageDAO.setCalPattern(LINE_PATTERN);
        pageDAO.setCountPages(false);
        pageDAO.produceWebData();
        req.setAttribute("AMSBJTRANSNOHDTO", dtoParameter);
        forwardURL = "/newasset/assetsQJCJYC.jsp";
      } else if (action.equals(AssetsActionConstant.EXPORT_ACTION)) {
        File file = dao.exportFile();
        WebFileDownload fileDown = new WebFileDownload(req, res);
        fileDown.setFilePath(file.getAbsolutePath());
        fileDown.download();
        file.delete();
      }
    } catch (DTOException ex) {
      ex.printLog();
      message = getMessage(AssetsMessageKeys.DTO_ERROR);
      message.setIsError(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } catch (QueryException ex) {
      ex.printLog();
      message = getMessage(MsgKeyConstant.QUERY_ERROR);
      message.setIsError(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } catch (PoolPassivateException ex) {
      ex.printLog();
      message = getMessage(AssetsMessageKeys.POOL_PASSIVATE_ERROR);
      message.setIsError(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } catch (WebFileDownException ex) {
      ex.printLog();
      message = getMessage(MsgKeyConstant.COMMON_ERROR);
      message.setIsError(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } catch (DataTransException ex) {
      ex.printLog();
      message = getMessage(MsgKeyConstant.COMMON_ERROR);
      message.setIsError(true);
      forwardURL = MessageConstant.MSG_PRC_SERVLET;
    } finally {
      DBManager.closeDBConnection(conn);
      setHandleMessage(req, message);
      ServletForwarder forwarder = new ServletForwarder(req, res);
      forwarder.forwardView(forwardURL);
    }
  }
Пример #2
0
  /** 查询资产地点 */
  public void synFaLocation(Connection conn, SfUserDTO user) {
    int totalCount = 0;
    int count = 0;
    long resumeTime = 0;
    SynLogDTO logDTO = null;
    SynLogUtil logUtil = new SynLogUtil();
    long start = System.currentTimeMillis();
    try {
      logDTO = new SynLogDTO();
      logDTO.setSynType(SrvType.SRV_FA_LOCATION);
      logDTO.setCreatedBy(user.getUserId());
      logDTO.setSynMsg("同步MIS资产地点开始");
      logUtil.synLog(logDTO, conn);

      SrvAssetLocationSrv service = new SrvAssetLocationSrv();
      SrvAssetLocationDTO dtoParameter = new SrvAssetLocationDTO();
      SrvAssetLocationDAO srvAssetLocationDAO = new SrvAssetLocationDAO(user, dtoParameter, conn);
      service.setLastUpDate(SynUpdateDateUtils.getLastUpdateDate(SrvType.SRV_FA_LOCATION, conn));
      SrvProcessModel spm = new SrvProcessModel();
      SQLModel sqlModel =
          spm.getLocalCodeModel(MIS_CONSTANT.SOURCE_MIS, SinoConfig.getLoc1SetNameMis());
      SimpleQuery simp = new SimpleQuery(sqlModel, conn);
      simp.executeQuery();
      Row row = null;
      if (simp.hasResult()) {
        RowSet rs = simp.getSearchResult();
        for (int i = 0; i < rs.getSize(); i++) {
          row = rs.getRow(i);
          String cc = row.getStrValue("FLEX_VALUE");
          service.setSegment1(cc);
          service.excute();
          SrvReturnMessage srm = service.getReturnMessage();
          if (srm.getErrorFlag().equals("Y")) {
            DTOSet ds = service.getDs();
            totalCount += ds.getSize();
            if (ds.getSize() > 0) {
              count += srvAssetLocationDAO.synAssetLocation(ds, cc);
            }
          }
        }
        if (totalCount == count) { // 全部成功才更新同步类型日志,以免下次获取不到数据
          SynUpdateDateUtils.createLastUpdateDate(SrvType.SRV_FA_LOCATION, conn);
          SynUpdateDateUtils.updateLastUpdateDate(SrvType.SRV_FA_LOCATION, conn);
        }
      }
      resumeTime = System.currentTimeMillis() - start;
      logDTO = new SynLogDTO();
      logDTO.setSynType(SrvType.SRV_FA_LOCATION);
      logDTO.setCreatedBy(user.getUserId());
      logDTO.setSynMsg(
          "同步MIS资产地点结束。同步"
              + totalCount
              + "条记录,成功"
              + count
              + ",失败"
              + (totalCount - count)
              + ",耗时"
              + resumeTime
              + "毫秒");
      logUtil.synLog(logDTO, conn);
    } catch (Exception e) {
      Logger.logError(e);
    }
  }
Пример #3
0
  /**
   * 功能:查询发生变化资产地点信息
   *
   * @return SQLModel 返回页面翻页查询SQLModel
   */
  public SQLModel getPageQueryModel() {
    SQLModel sqlModel = new SQLModel();
    List sqlArgs = new ArrayList();
    String sqlStr =
        "SELECT TOTAL.LOC2_CODE,\n"
            + "       TOTAL.LOC2_DESC,\n"
            + "       TOTAL.OLD_LOC_DESC,\n"
            + "       TOTAL.COMPANY_CODE,\n"
            + "       TOTAL.ORGANIZATION_ID,\n"
            + "       TOTAL.COMPANY_NAME,\n"
            + "       TOTAL.WORKORDER_CATEGORY,\n"
            + "       TOTAL.AREA_TYPE_NAEM,\n"
            + "       TOTAL.CITY,\n"
            + "       TOTAL.COUNTY,\n"
            + "       TOTAL.LOC_TYPE\n"
            + "  FROM (SELECT EOL.LOC2_CODE,\n"
            + "               EOL.LOC2_DESC,\n"
            + "               '' OLD_LOC_DESC,\n"
            + "               EOL.COMPANY_CODE,\n";
    if (user.getIsTd().equals("N")) {
      sqlStr += " EOCM.ORGANIZATION_ID,\n";
    } else {
      sqlStr += " EOCM.MATCH_ORGANIZATION_ID ORGANIZATION_ID,\n";
    }
    sqlStr +=
        "               EOCM.COMPANY COMPANY_NAME,\n"
            + "               dbo.GET_FLEX_VALUE(EOL.OBJECT_CATEGORY, 'OBJECT_CATEGORY') WORKORDER_CATEGORY,\n"
            + "               dbo.GET_FLEX_VALUE(EOL.AREA_TYPE, 'ADDR_AREA_TYPE') AREA_TYPE_NAEM,\n"
            + "               EOL.CITY,\n"
            + "               EOL.COUNTY,\n"
            + "               '新增' LOC_TYPE\n"
            + "          FROM ETS_OBJECT_LOC2 EOL, ETS_OU_CITY_MAP EOCM\n"
            + "         WHERE EOL.COMPANY_CODE = EOCM.COMPANY_CODE\n";
    if (user.getIsTd().equals("N")) {
      sqlStr += "	AND (EOL.SHARE_TYPE='1' OR EOL.SHARE_TYPE='2')\n";
    } else {
      sqlStr += "	AND (EOL.SHARE_TYPE='3' OR EOL.SHARE_TYPE='2')\n";
    }
    sqlStr +=
        "           AND NOT EXISTS\n"
            + "         (SELECT 1\n"
            + "                  FROM M_FND_FLEX_VALUE_SETS MFFVS, M_FND_FLEX_VALUES MFFV\n"
            + "                 WHERE MFFVS.FLEX_VALUE_SET_ID = MFFV.FLEX_VALUE_SET_ID\n"
            + "                   AND MFFVS.FLEX_VALUE_SET_NAME = ?\n"
            + "                   AND EOL.LOC2_CODE = MFFV.FLEX_VALUE \n";
    if (user.getIsTd().equals("N")) {
      sqlStr +=
          "           AND MFFVS.SOURCE='MIS')\n" + "           AND EOCM.ORGANIZATION_ID = ?\n";
    } else {
      sqlStr +=
          "           AND MFFVS.SOURCE='TDMIS')\n"
              + "           AND EOCM.MATCH_ORGANIZATION_ID = ?\n";
    }
    sqlStr +=
        "        UNION ALL\n"
            + "        SELECT EOL.LOC2_CODE,\n"
            + "               EOL.LOC2_DESC,\n"
            + "               MFFV.DESCRIPTION OLD_LOC_DESC,\n"
            + "               EOL.COMPANY_CODE,\n";
    if (user.getIsTd().equals("N")) {
      sqlStr += " EOCM.ORGANIZATION_ID,\n";
    } else {
      sqlStr += " EOCM.MATCH_ORGANIZATION_ID ORGANIZATION_ID,\n";
    }
    sqlStr +=
        "               EOCM.COMPANY COMPANY_NAME,\n"
            + "               dbo.GET_FLEX_VALUE(EOL.OBJECT_CATEGORY, 'OBJECT_CATEGORY') WORKORDER_CATEGORY,\n"
            + "               dbo.GET_FLEX_VALUE(EOL.AREA_TYPE, 'ADDR_AREA_TYPE') AREA_TYPE_NAEM,\n"
            + "               EOL.CITY,\n"
            + "               EOL.COUNTY,\n"
            + "               '修改' LOC_TYPE\n"
            + "          FROM ETS_OBJECT_LOC2       EOL,\n"
            + "               M_FND_FLEX_VALUE_SETS MFFVS,\n"
            + "               M_FND_FLEX_VALUES     MFFV,\n"
            + "               ETS_OU_CITY_MAP       EOCM\n"
            + "         WHERE MFFVS.FLEX_VALUE_SET_ID = MFFV.FLEX_VALUE_SET_ID\n"
            + "           AND MFFVS.FLEX_VALUE_SET_NAME = ?\n"
            + "           AND EOL.LOC2_CODE = MFFV.FLEX_VALUE\n";
    if (user.getIsTd().equals("N")) {
      sqlStr +=
          "         AND MFFVS.SOURCE='MIS'\n"
              + "	     AND EOCM.ORGANIZATION_ID = ?"
              + "	     AND (EOL.SHARE_TYPE='1' OR EOL.SHARE_TYPE='2')\n";
    } else {
      sqlStr +=
          "         AND MFFVS.SOURCE='TDMIS'\n"
              + "	     AND EOCM.MATCH_ORGANIZATION_ID = ?"
              + "	     AND (EOL.SHARE_TYPE='3' OR EOL.SHARE_TYPE='2')\n";
    }
    sqlStr +=
        "     AND EOL.LOC2_DESC <> MFFV.DESCRIPTION\n"
            + "           AND EOL.COMPANY_CODE = EOCM.COMPANY_CODE\n"
            + "           ) TOTAL\n"
            + " WHERE NOT EXISTS (SELECT NULL\n"
            + "          FROM ETS_FA_NEW_LOC EFC\n"
            + "         WHERE EFC.LOCATION = TOTAL.LOC2_DESC\n"
            + "           AND EFC.ORGANIZATION_ID = TOTAL.ORGANIZATION_ID\n"
            + "           AND EFC.STATUS = 1\n"
            + "           AND CONVERT(INT, CONVERT(CHAR, EFC.CREATION_DATE, 112)) =\n"
            + "               CONVERT(INT, CONVERT(CHAR, GETDATE(), 112)))\n"
            + "   AND (? = '' OR TOTAL.LOC2_CODE LIKE ?)\n"
            + "   AND (? = '' OR TOTAL.LOC2_DESC LIKE ?)";
    if (user.getIsTd().equals("N")) {
      sqlArgs.add(SinoConfig.getFlexValueSetNameMis());
    } else {
      sqlArgs.add(SinoConfig.getFlexValueSetNameTD());
    }
    sqlArgs.add(dto.getOrganizationId());
    if (user.getIsTd().equals("N")) {
      sqlArgs.add(SinoConfig.getFlexValueSetNameMis());
    } else {
      sqlArgs.add(SinoConfig.getFlexValueSetNameTD());
    }
    sqlArgs.add(dto.getOrganizationId());
    sqlArgs.add(dto.getWorkorderObjectCode());
    sqlArgs.add(dto.getWorkorderObjectCode());
    sqlArgs.add(dto.getNewAssetsLocation());
    sqlArgs.add(dto.getNewAssetsLocation());

    sqlModel.setSqlStr(sqlStr);
    sqlModel.setArgs(sqlArgs);
    return sqlModel;
  }