Exemplo n.º 1
0
 /**
  * 功能:框架自动生成应急保障设备名称字典表 AMS_YJ_ITEM页面翻页查询SQLModel,请根据实际需要修改。
  *
  * @return SQLModel 返回页面翻页查询SQLModel
  * @throws SQLModelException 发生日历异常时转化为该异常抛出
  */
 public SQLModel getPageQueryModel() throws SQLModelException {
   SQLModel sqlModel = new SQLModel();
   List sqlArgs = new ArrayList();
   AmsYjItemDTO amsYjItem = (AmsYjItemDTO) dtoParameter;
   String sqlStr =
       "SELECT "
           + " CONVERT(VARCHAR,ITEM_CODE) ITEM_CODE,"
           + " ITEM_NAME,"
           + " ITEM_CATEGORY,"
           + " CREATION_DATE,"
           + " dbo.APP_GET_USER_NAME(CREATE_USER) CREATE_USER,"
           + " LAST_UPDATE_DATE,"
           + " dbo.APP_GET_USER_NAME(LAST_UPDATE_USER) LAST_UPDATE_USER,"
           + " DISABLE_DATE"
           + " FROM"
           + " AMS_YJ_ITEM"
           + " WHERE"
           + " ("
           + SyBaseSQLUtil.isNull()
           + " OR ITEM_NAME LIKE ?)";
   if (!amsYjItem.getItemCode().equals("")) {
     sqlStr += " AND ITEM_CODE = CONVERT(FLOAT,?)";
   } else {
     sqlStr += " AND CONVERT(FLOAT,?) =0 ";
   }
   sqlArgs.add(amsYjItem.getItemName());
   sqlArgs.add(amsYjItem.getItemName());
   sqlArgs.add(amsYjItem.getItemCode());
   sqlModel.setSqlStr(sqlStr);
   sqlModel.setArgs(sqlArgs);
   return sqlModel;
 }
Exemplo n.º 2
0
  /**
   * 功能:框架自动生成应急保障设备名称字典表 AMS_YJ_ITEM多条数据信息查询SQLModel,请根据实际需要修改。
   *
   * @return SQLModel 返回多条数据信息查询用SQLModel
   * @throws SQLModelException 发生日历异常时转化为该异常抛出
   */
  public SQLModel getMuxDataModel() throws SQLModelException {
    SQLModel sqlModel = new SQLModel();
    try {
      List sqlArgs = new ArrayList();
      AmsYjItemDTO amsYjItem = (AmsYjItemDTO) dtoParameter;
      String sqlStr =
          "SELECT "
              + " ITEM_CODE,"
              + " ITEM_NAME,"
              + " ITEM_CATEGORY,"
              + " CREATION_DATE,"
              + " CREATE_USER,"
              + " LAST_UPDATE_DATE,"
              + " LAST_UPDATE_USER"
              + " FROM"
              + " AMS_YJ_ITEM"
              + " WHERE"
              + " (? IS NULL OR ITEM_CODE LIKE ?)"
              + " AND (? IS NULL OR ITEM_NAME LIKE ?)"
              + " AND (? IS NULL OR ITEM_CATEGORY LIKE ?)"
              + " AND (? IS NULL OR CREATION_DATE LIKE ?)"
              + " AND (? IS NULL OR CREATE_USER LIKE ?)"
              + " AND (? IS NULL OR LAST_UPDATE_DATE LIKE ?)"
              + " AND (? IS NULL OR LAST_UPDATE_USER LIKE ?)";
      sqlArgs.add(amsYjItem.getItemCode());
      sqlArgs.add(amsYjItem.getItemCode());
      sqlArgs.add(amsYjItem.getItemName());
      sqlArgs.add(amsYjItem.getItemName());
      sqlArgs.add(amsYjItem.getItemCategory());
      sqlArgs.add(amsYjItem.getItemCategory());
      sqlArgs.add(amsYjItem.getCreationDate());
      sqlArgs.add(amsYjItem.getCreationDate());
      sqlArgs.add(amsYjItem.getCreateUser());
      sqlArgs.add(amsYjItem.getCreateUser());
      sqlArgs.add(amsYjItem.getLastUpdateDate());
      sqlArgs.add(amsYjItem.getLastUpdateDate());
      sqlArgs.add(amsYjItem.getLastUpdateUser());
      sqlArgs.add(amsYjItem.getLastUpdateUser());

      sqlModel.setSqlStr(sqlStr);
      sqlModel.setArgs(sqlArgs);
    } catch (CalendarException ex) {
      ex.printLog();
      throw new SQLModelException(ex);
    }
    return sqlModel;
  }
Exemplo n.º 3
0
 /**
  * 功能:失效
  *
  * @return SQLModel 返回数据删除用SQLModel
  */
 public SQLModel getDataDeleteModel() {
   SQLModel sqlModel = new SQLModel();
   List sqlArgs = new ArrayList();
   AmsYjItemDTO amsYjItem = (AmsYjItemDTO) dtoParameter;
   String sqlStr =
       "UPDATE AMS_YJ_ITEM\n"
           + "SET DISABLE_DATE=GETDATE(),"
           + " LAST_UPDATE_DATE = GETDATE(),"
           + " LAST_UPDATE_USER = ?"
           + " WHERE"
           + " ITEM_CODE = CONVERT(FLOAT,?)";
   sqlArgs.add(sfUser.getUserId());
   sqlArgs.add(amsYjItem.getItemCode());
   sqlModel.setSqlStr(sqlStr);
   sqlModel.setArgs(sqlArgs);
   return sqlModel;
 }
Exemplo n.º 4
0
  /**
   * 功能:框架自动生成应急保障设备名称字典表 AMS_YJ_ITEM数据插入SQLModel,请根据实际需要修改。
   *
   * @return SQLModel 返回数据插入用SQLModel
   * @throws SQLModelException 发生日历异常时转化为该异常抛出
   */
  public SQLModel getDataCreateModel() throws SQLModelException {
    SQLModel sqlModel = new SQLModel();
    List sqlArgs = new ArrayList();
    AmsYjItemDTO amsYjItem = (AmsYjItemDTO) dtoParameter;
    String sqlStr =
        "INSERT INTO "
            + " AMS_YJ_ITEM("
            + " ITEM_CODE,"
            + " ITEM_NAME,"
            + " ITEM_CATEGORY,"
            + " CREATION_DATE,"
            + " CREATE_USER"
            + ") VALUES ("
            + " CONVERT(FLOAT,?), ?, '装备', GETDATE(), ?)";

    sqlArgs.add(amsYjItem.getItemCode());
    sqlArgs.add(amsYjItem.getItemName());
    sqlArgs.add(sfUser.getUserId());

    sqlModel.setSqlStr(sqlStr);
    sqlModel.setArgs(sqlArgs);
    return sqlModel;
  }
Exemplo n.º 5
0
  /**
   * 功能:框架自动生成应急保障设备名称字典表 AMS_YJ_ITEM数据详细信息查询SQLModel,请根据实际需要修改。
   *
   * @return SQLModel 返回数据详细信息查询用SQLModel
   */
  public SQLModel getPrimaryKeyDataModel() {
    SQLModel sqlModel = new SQLModel();
    List sqlArgs = new ArrayList();
    AmsYjItemDTO amsYjItem = (AmsYjItemDTO) dtoParameter;
    String sqlStr =
        "SELECT "
            + " ITEM_CODE,"
            + " ITEM_NAME,"
            + " ITEM_CATEGORY,"
            + " CREATION_DATE,"
            + " CREATE_USER,"
            + " LAST_UPDATE_DATE,"
            + " LAST_UPDATE_USER"
            + " FROM"
            + " AMS_YJ_ITEM"
            + " WHERE"
            + " ITEM_CODE = CONVERT(FLOAT,?)";
    sqlArgs.add(amsYjItem.getItemCode());

    sqlModel.setSqlStr(sqlStr);
    sqlModel.setArgs(sqlArgs);
    return sqlModel;
  }
Exemplo n.º 6
0
 /**
  * @param req HttpServletRequest
  * @param res HttpServletResponse
  * @throws ServletException
  * @throws IOException
  */
 public void performTask(HttpServletRequest req, HttpServletResponse res)
     throws ServletException, IOException {
   String forwardURL = "";
   Message message = SessionUtil.getMessage(req);
   Connection conn = null;
   try {
     SfUserDTO user = (SfUserDTO) SessionUtil.getUserAccount(req);
     Request2DTO req2DTO = new Request2DTO();
     req2DTO.setDTOClassName(AmsYjItemDTO.class.getName());
     AmsYjItemDTO dtoParameter = (AmsYjItemDTO) req2DTO.getDTO(req);
     String action = dtoParameter.getAct();
     conn = getDBConnection(req);
     AmsYjItemDAO amsYjItemDAO = new AmsYjItemDAO(user, dtoParameter, conn);
     if (action.equals("")) {
       forwardURL = "/yj/yjItemSearch.jsp";
     } else if (action.equals(WebActionConstant.QUERY_ACTION)) {
       BaseSQLProducer sqlProducer = new AmsYjItemModel(user, dtoParameter);
       PageQueryDAO pageDAO = new PageQueryDAO(req, conn, sqlProducer);
       pageDAO.produceWebData();
       forwardURL = "/yj/yjItemSearch.jsp";
     } else if (action.equals(WebActionConstant.NEW_ACTION)) {
       AmsYjItemDTO amsYjItem = new AmsYjItemDTO();
       req.setAttribute("AMS_YJ_ITEM", amsYjItem);
       forwardURL = "/yj/yjItemDetail.jsp";
     } else if (action.equals(WebActionConstant.DETAIL_ACTION)) {
       amsYjItemDAO.setDTOClassName(AmsYjItemDTO.class.getName());
       AmsYjItemDTO amsYjItem = (AmsYjItemDTO) amsYjItemDAO.getDataByPrimaryKey();
       if (amsYjItem == null) {
         amsYjItem = new AmsYjItemDTO();
         message = getMessage(MsgKeyConstant.DATA_NOT_EXIST);
         message.setIsError(true);
       }
       req.setAttribute("AMS_YJ_ITEM", amsYjItem);
       forwardURL = "/yj/yjItemDetail.jsp";
     } else if (action.equals(WebActionConstant.CREATE_ACTION)) {
       boolean isNew = StrUtil.isEmpty(dtoParameter.getItemCode());
       YjManagerUtil yjUtil = new YjManagerUtil(user, conn);
       if (isNew) {
         dtoParameter.setItemCode(String.valueOf(yjUtil.getYjManagerMax("AMS_YJ_ITEM_SEQ")));
       }
       amsYjItemDAO.createData();
       forwardURL =
           "/servlet/com.sino.ams.yj.servlet.AmsYjItemServlet?act="
               + WebActionConstant.QUERY_ACTION
               + "&itemCode="
               + dtoParameter.getItemCode();
     } else if (action.equals(WebActionConstant.UPDATE_ACTION)) {
       amsYjItemDAO.updateData();
       forwardURL =
           "/servlet/com.sino.ams.yj.servlet.AmsYjItemServlet?act="
               + WebActionConstant.QUERY_ACTION
               + "&itemCode="
               + dtoParameter.getItemCode();
     } else if (action.equals(WebActionConstant.DELETE_ACTION)) { // 失效
       amsYjItemDAO.deleteData();
       forwardURL =
           "/servlet/com.sino.ams.yj.servlet.AmsYjItemServlet?act="
               + WebActionConstant.QUERY_ACTION;
     } else if (action.equals(AMSActionConstant.INURE_ACTION)) { // 生效
       String amsYjItem = "";
       amsYjItemDAO.enableItem(amsYjItem);
       forwardURL =
           "/servlet/com.sino.ams.yj.servlet.AmsYjItemServlet?act="
               + WebActionConstant.QUERY_ACTION;
     } else if (action.equals(WebActionConstant.EXPORT_ACTION)) { // 导出到Excel
       File file = amsYjItemDAO.exportFile();
       WebFileDownload fileDown = new WebFileDownload(req, res);
       fileDown.setFilePath(file.getAbsolutePath());
       fileDown.download();
       file.delete();
     } else if (action.equals("verifyItemName")) {
       String itemName = req.getParameter("itemName");
       boolean success = amsYjItemDAO.doVerify(itemName);
       PrintWriter out = res.getWriter();
       if (success) {
         out.print("Y");
       }
       out.flush();
       out.close();
     } else {
       message = getMessage(MsgKeyConstant.INVALID_REQ);
       message.setIsError(true);
       forwardURL = MessageConstant.MSG_PRC_SERVLET;
     }
   } catch (PoolPassivateException ex) {
     ex.printLog();
     message = getMessage(MsgKeyConstant.POOL_PASSIVATE_ERROR);
     message.setIsError(true);
     forwardURL = MessageConstant.MSG_PRC_SERVLET;
   } catch (DTOException ex) {
     ex.printLog();
     message = getMessage(MsgKeyConstant.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 (DataHandleException ex) {
     ex.printLog();
     // 请根据实际情况处理消息
     forwardURL = "保持界面录入的数据,返回到原页面,并显示上面给出的消息";
   } catch (WebFileDownException e) {
     e
         .printStackTrace(); // To change body of catch statement use File | Settings | File
                             // Templates.
   } finally {
     DBManager.closeDBConnection(conn);
     setHandleMessage(req, message);
     ServletForwarder forwarder = new ServletForwarder(req, res);
     forwarder.forwardView(forwardURL);
     // 根据实际情况修改页面跳转代码。
   }
 }