更新;“分类”;在关闭事件之前使用Java API BMC补救措施

更新;“分类”;在关闭事件之前使用Java API BMC补救措施,java,api,remedy,bmc,Java,Api,Remedy,Bmc,我有一个继承的项目,一个BMC补救应用程序,从未使用过这种补救方法。本项目通过补救API修改补救措施中的事件和工作指令。我完全不知道这件事 有一个流程可关闭处于已解决状态且在过去36小时内未修改的事件。有时,这些事件的“分类”字段为空,客户端希望在关闭分类之前填充该分类 这是代码的一部分: 与补救措施的连接: public static void main(String args[]) { // Inicializamos el logger java.util

我有一个继承的项目,一个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++;
        }
    }
关闭事件的功能:

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++;
        }
    }
public void cerraincidencias(列表incs)引发异常{
int contador=1;
用于(字符串公司:incs){
试一试{
//意外事件
QualifierInfo qual=server.parseQualification(“HPD:Help Desk”,“事件编号”=\“”+inc+“\”);
List entries=server.getListEntryObjects(“HPD:帮助台”),qual,0,0,null,
Constantes.CAMPOS_HPD_HELP_DESK_CERRAR_INCIDENCIA,假,空);
//通用汽车公司
条目注释=新条目();
注释.put(constants.HPD\u WORKLOG\u详细说明,新值(“Cierre automatico tras 36 horas en resuelto”);
注释.放置(Constantes.HPD_WORKLOG_事件编号,新值(inc));
comment.put(constants.HPD_WORKLOG_DESCRIPTION,新值(“---”);
comment.put(constants.HPD_WORKLOG_WORKLOG_TYPE,新值(8000));
对于(条目:条目){
entry.put(constants.HPD_HELP_DESK_STATUS,新值(5));//Estado a cerrado
if(entry.get(constants.HPD\u HELP\u DESK\u assignment\u LOGIN\u ID).getValue()==null){
entry.put(constants.HPD_HELP_DESK_assignment_LOGIN_ID,新值(“lmoren70”);
entry.put(constants.HPD_HELP_DESK_assigner,新值(“路易斯·曼努埃尔·莫雷诺·罗德里格斯”);//Usuario asignado
}
setEntry(“HPD:帮助台”,entry.getEntryId(),entry,null,0);
createEntry(“HPD:WorkLog”,注释);
LOGGER.info(“Incidencia”+inc+“cerrada con exito-”+contador+“de”+incs.size());
}
}捕获(例外e){
LOGGER.error(“Incidencia”+inc+“NO se ha poddo 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;
    }
public List queryResueltas36h(){
String query=“从vdf_票据、vdf_组中选择inc,其中状态='Resuelto'和长度(inc)>9”
+“和vdf_groups.group=creator_group和(vdf_groups.categorization='TES'或vdf_groups.group IN('TES','ARCA','NetOps TES Assurance'))”
+“和上一次解决的日期<日期添加(现在(),间隔-36小时)inc DESC订单”;
List incs=new ArrayList();
试一试{
stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(查询);
while(rs.next()){
字符串inc=rs.getString(“inc”);
加上(公司);
}
stmt.close();
}捕获(例外e){
记录器错误(“基准事件发生率错误”,e);
试一试{
stmt.close();
}捕获(异常e1){
}
}
返回INC;
}
我想要的是将分类设置为“TES”,以防没有分类

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


有什么想法吗?提前谢谢

您需要更新您的宫颈癌功能。但首先,您需要询问需要更新哪些分类

有三个级别的分类

  • 业务分类
  • 产品分类
  • 分辨率分类
  • 因此,决定要填充哪个字段并获取该字段的字段id。对于这个例子,我会说 分类一级,即1000000063 您需要将CAMPOS_HPD_HELP_DESK_Categorization_TIER1=1000000063添加到您的Constants文件中

    然后在你的街区

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

    谢谢你的回答!我终于用selenium实现了自动化,现在正在生产中,但您的解决方案似乎像我所想的那样简单。所以我会记下它,我会把它留到将来我肯定我会用它的