我希望在 Maximo 中实现一个自定义图表,该图表会提取 Assets mbo 值并填充在 Assets 应用程序上可见的图表。像这样:
我可以成功地渲染图表并从硬编码的 Assets Mbo 中提取数据,但我无法弄清楚如何使图表为单个 Assets 动态化。例如, Assets AB100001 是从列表选项卡中选择的,但 Assets AB234560 被硬编码到 jsp 代码中,因此 Assets AB234560 中的数据将呈现在每个图表上,针对每个 Assets 。
我的 jsp 代码类似于此示例,该开发人员正在获取仪表数据并将其显示在相同类型的 jsp 图表上:
<%@ include file="../common/componentheader.jsp"%>
<%
String width = component.getProperty("width");
String height = component.getProperty("height");
String assetnum = boundComponent.getString();
MboSetRemote readingsSet = s.getMboSet("MEASUREMENT");
readingsSet.setWhere("ASSETNUM = '11450' and METERNAME = 'O-PRESSUR'");
readingsSet.reset();
String readingData = "[";
for (MboRemote r = readingsSet.moveFirst(); r != null; r = readingsSet.moveNext())
{
readingData += "{'Offset_ms':" + r.getDate("MeasureDate").getTime() +
",'Value':" + r.getDouble("MeasurementValue") + "},";
};
readingData += "]";
%>
这几乎正是我所需要的,除了你会注意到他在第 3 行中使用 setWhere 时对 Assets 编号进行了硬编码:
readingsSet.setWhere("ASSETNUM = '11450' and METERNAME = 'O-PRESSUR'");
有没有办法在 setWhere 函数中使用绑定(bind)变量来动态拉取assetnum,而不是使用字符串'11450'?
链接到具有这种情况的博客文章:http://vietmaximo.blogspot.com/2018/03/maximo-custom-control-part-iv-create.html
最佳答案
在开头附近,我们看到这一行:
String assetnum = boundComponent.getString();
OP 说
boundComponent.getString();
正在返回 Undefined
.一些研究表明,这段代码应该更好地工作:String assetnum = boundComponent.getDataBean().getMbo().getString("ASSETNUM");
然后这条线
readingsSet.setWhere("ASSETNUM = '11450' and METERNAME = 'O-PRESSUR'");
应该变成这样
SqlFormat readingWhere = new SqlFormat("ASSETNUM = :1 and METERNAME = 'O-PRESSUR'");
readingWhere.setObject(1, "ASSET", "ASSETNUM", assetnum);
readingSet.setWhere(readingWhere.format())
关于jsp - 使用自定义 JSP 组件和 Mbo 库创建动态图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58881817/