I have a work order (WO) in Maximo:
- The WO has
Latitude(Y)
andLongitude(X)
coordinates in the Service Address tab. - The WO has a custom
zone
field.
And there is a spatial table (polygon layer) in a separate GIS database.
I want to do spatial query to return an attribute from the polygon record that it intersects and use it to populate zone
in the WO.
How can I do this?
(Maximo 7.6.1.1 including Maximo Spatial)
Create a Jython automation script that executes at the desired event (via an object launch point).
Adapt the code in the Library Scripts section of Maximo 76 Scripting Features (pdf):
LIBHTTPCLIENT: (a reusable Jython library script)
Assorted Notes:
JSONObject
package.I had problems using a URL with
HTTPS
in it -- and problems with a URL that used a domain name in it.https://exampleGIS.com/arcgis/rest/services/Example/Zones/MapServer/15/query?geometry=666666.0312127020%2C4444444.7001941890&geometryType=esriGeometryPoint&spatialRel=esriSpatialRelIntersects&outFields=ZONE&returnGeometry=false&f=pjson
But this worked:
http://hostname.port/arcgis/rest/services/Example/Zones/MapServer/15/query?geometry=666666.0312127020%2C4444444.7001941890&geometryType=esriGeometryPoint&spatialRel=esriSpatialRelIntersects&outFields=ZONE&returnGeometry=false&f=pjson
.Sorry, but all I can say is what worked and what didn't work. I can't provide details as to why one thing worked and the other didn't.
Good luck to whoever else tries this! It was more difficult than it needed to be.
To do this live in Maximo using an automation script is possible or by writing custom code into Spatial (more challenging). You want to use the /MapServer/identify tool and post the geometry xy, coordinate system, and the layer you want to query. identify window
You will have to format the geometry object correctly and test your post from the window. I usually grab the post from the network section of developer tools once I get it to work and change the output format to json and use it in my code.
You may actually not need to touch your Maximo environment at all. How about just using a trigger on your work orders table ? That trigger can then automatically fill the zone ID from a simple select statement that matches x and y with the zones in the zones table. Here is how that could look like.
This assumes that your work orders are in a table like this:
and the zones in a table like this
Then the trigger would be like this
Some assumptions:
The
x
andy
columns contain coordinates in WGS84 longitude/latitude (not in some projection or some other long/lat coordinate system)Zones don't overlap: a work order point is always therefore in one and only one zone. If not, then the query may return multiple results, which you then need to handle.
Zones fully cover the territory your work orders can take place in. If a work order location can be outside all your zones, then you also need to handle that (the query would return no result).
The
x
andy
columns are always filled. If they are optional, then you also need to handle that case (setzone_id
toNULL
if eitherx
ory
isNULL
)After that, each time a new work order is inserted in the
work_orders
table, thezone_id
column will be automatically updated.You can initialize
zone_id
in your existing work orders with a simple update:This will make the trigger run for each row in the table ... It may take some time to complete if the table is large.