简体   繁体   English

将“分类”更新为 Java API BMC 关闭事件前的补救措施

[英]Update “categorization” with Java API BMC Remedy before closing incident

I have an inherited project, a BMC Remedy application and never worked with this Remedy stuff.我有一个继承的项目,一个 BMC Remedy 应用程序,但从未使用过这个 Remedy 东西。 This project modifies Incidents and Work Orders from remedy through the Remedy API.该项目通过补救措施 API 修改事故和工单。 I have literally no idea on this.我对此一无所知。

There's a process that closes incidents that are in resolved state and have not been modified in the last 36 hours.有一个流程可以关闭已解决的 state 中且在过去 36 小时内未修改的事件。 Sometimes, those incidents have the 'categorization' field empty, and the client wants to fill this categorization before closing it.有时,这些事件的“分类”字段为空,客户希望在关闭之前填写此分类。

This is part of the code:这是代码的一部分:

Connection to Remedy:连接到补救措施:

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) {
            }
        }
    }

Function to closing incidents: Function 关闭事件:

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++;
        }
    }

Query: I thought to do an update directly to the database BUT this database reads from Remedy, so I have to update Remedy.查询:我想直接对数据库进行更新,但是这个数据库是从 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;
    }

What I want is to put the categorization to 'TES', in case there's no categorization.我想要的是把分类放到“TES”,以防没有分类。

One option I thought is to do an automation with Selenium and Python and not touching this code, but is far better to have all in the same project.我认为的一个选择是使用 Selenium 和 Python 进行自动化,并且不触及此代码,但将所有代码都放在同一个项目中要好得多。

Any ideas?有任何想法吗? Thanks in advance!提前致谢!

You need to update your cerrarIncidencias function.您需要更新您的 cerrarIncidencias function。 But first you need to ask what categorisation you need to update.但首先您需要询问您需要更新的分类。

There are three levels of categorisation.分类分为三个层次。

  1. Operational Categorisation业务分类
  2. Product Categorisation产品分类
  3. Resolution Categorisation分辨率分类

So decide which one you want to populate and get the field id for that field.因此,决定您要填充哪个字段并获取该字段的字段 ID。 For this example, I will say Categorisation Tier 1 which is 1000000063 You'll need to add to CAMPOS_HPD_HELP_DESK_CATEGORISATION_TIER1=1000000063 to your Constantes file.对于此示例,我将说 Categorization Tier 1 为 1000000063 您需要将 CAMPOS_HPD_HELP_DESK_CATEGORISATION_TIER1=1000000063 添加到您的 Constantes 文件中。

Then in your block然后在你的街区

for (Entry entry : entries)

You need something like:你需要类似的东西:

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"));
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM