有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

在关闭事件之前,使用Java API BMC补救方法更新“分类”

我有一个继承的项目,一个BMC补救应用程序,从未使用过这种补救方法。本项目通过补救API修改补救措施中的事件和工作指令。我完全不知道这件事

有一个流程可关闭处于已解决状态且在过去36小时内未修改的事件。有时,这些事件的“分类”字段为空,客户端希望在关闭分类之前填充该分类

这是代码的一部分:

与补救措施的连接:

public static void main(String args[]) {

        // Inicializamos el logger
        java.util.logging.LogManager.getLogManager().reset();

        try {

            // Nos conectamos a Remedy y a MySQL
            LOGGER.info("Conectando a bases de datos");
            if (!connect()) {
                throw new Exception("Fallo al conectar a Remedy o a MySQL");
            }

            // Metodo para cerrar incidecias resueltas
            remedy.cerrarIncidencias(sql.queryResueltas36h());
            
            // Desconectamos de Remedy y MySQL
            disconnect();

        } catch (Exception e) {
            LOGGER.error("Error critico: ", e);
            try {
                remedy.desconectar();
            } catch (Exception e1) {
            }
            try {
                sql.desconectar();
            } catch (Exception e1) {
            }
        }
    }

关闭事件的功能:

public void cerrarIncidencias(List<String> incs) throws Exception {
        int contador = 1;
        for (String inc : incs) {
            try {

                // Obtenemos la incidencia
                QualifierInfo qual = server.parseQualification("HPD:Help Desk", "'Incident Number' = \"" + inc + "\"");
                List<Entry> entries = server.getListEntryObjects("HPD:Help Desk", qual, 0, 0, null,
                        Constantes.CAMPOS_HPD_HELP_DESK_CERRAR_INCIDENCIA, false, null);

                // Rellenamos un comentario generico
                Entry comment = new Entry();
                comment.put(Constantes.HPD_WORKLOG_DETAILED_DESCRIPTION, new Value("Cierre automatico tras 36 horas en resuelto."));
                comment.put(Constantes.HPD_WORKLOG_INCIDENT_NUMBER, new Value(inc));
                comment.put(Constantes.HPD_WORKLOG_DESCRIPTION, new Value("----"));
                comment.put(Constantes.HPD_WORKLOG_WORKLOG_TYPE, new Value(8000));

                for (Entry entry : entries) {
                    entry.put(Constantes.HPD_HELP_DESK_STATUS, new Value(5)); // Estado a cerrado
                    if (entry.get(Constantes.HPD_HELP_DESK_ASSIGNEE_LOGIN_ID).getValue() == null) {
                        entry.put(Constantes.HPD_HELP_DESK_ASSIGNEE_LOGIN_ID, new Value("lmoren70"));
                        entry.put(Constantes.HPD_HELP_DESK_ASSIGNEE, new Value("Luis Manuel Moreno Rodriguez")); // Usuario asignado
                    }
                    server.setEntry("HPD:Help Desk", entry.getEntryId(), entry, null, 0);
                    server.createEntry("HPD:WorkLog", comment);
                    LOGGER.info("Incidencia " + inc + " cerrada con exito - " + contador + " de " + incs.size());
                }
            } catch (Exception e) {
                LOGGER.error("Incidencia " + inc + " NO se ha podido cerrar - " + contador + " de " + incs.size() + "\n"
                        + e.getMessage());
            }
            contador++;
        }
    }

查询: 我本想直接更新数据库,但这个数据库读取的是Remedy,所以我必须更新Remedy

public List<String> queryResueltas36h() {
        String query = "SELECT inc FROM vdf_tickets, vdf_groups WHERE status = 'Resuelto' AND LENGTH(inc) > 9 "
                + "AND vdf_groups.group = creator_group AND (vdf_groups.categorization = 'TES' OR vdf_groups.group IN ('TES', 'ARCA', 'NetOps TES Assurance')) "
                + "AND last_resolved_date < DATE_ADD(NOW(), INTERVAL -36 HOUR) ORDER BY inc DESC";
        List<String> incs = new ArrayList<String>();
        try {
            stmt = conn.createStatement();
            ResultSet rs = stmt.executeQuery(query);
            while (rs.next()) {
                String inc = rs.getString("inc");
                incs.add(inc);
            }
            stmt.close();
        } catch (Exception e) {
            LOGGER.error("Error al obtener lista de incidencias de la base de datos", e);
            try {
                stmt.close();
            } catch (Exception e1) {
            }
        }
        return incs;
    }

我想要的是将分类设置为“TES”,以防没有分类

我认为的一个选择是使用Selenium和Python实现自动化,而不涉及此代码,但是将所有代码都放在同一个项目中要好得多

有什么想法吗?提前谢谢


共 (1) 个答案

  1. # 1 楼答案

    你需要更新你的宫颈癌功能。但首先你需要问一下你需要更新哪些分类

    有三个级别的分类

    1. 操作分类
    2. 产品分类
    3. 分辨率分类

    因此,决定要填充哪个字段,并获取该字段的字段id。对于这个例子,我会说 1级分类,即1000000063 您需要将CAMPOS_HPD_HELP_DESK_Categorization_TIER1=1000000063添加到您的Constantes文件中

    然后在你的街区

    for (Entry entry : entries)
    

    你需要这样的东西:

    if (entry.get(Constantes.CAMPOS_HPD_HELP_DESK_CATEGORISATION_TIER1).getValue() == null) {
        entry.put(Constantes.CAMPOS_HPD_HELP_DESK_CATEGORISATION_TIER1, new Value("Your Value for Categorisation Tier 1"));
    }