Z Ws Object Send
Z Ws Object Send
SAVE
from com.ibm.tivoli.maximo.interaction.process import InteractionProcesser
def importScript():
script = None
from psdi.server import MXServer
mxserver = MXServer.getMXServer()
sysuser = mxserver.getSystemUserInfo()
impSet = mxserver.getMboSet("AUTOSCRIPT",sysuser)
impSet.setWhere("AUTOSCRIPT='IMPORTS'")
imp = impSet.moveFirst()
if imp != None:
script = imp.getString("SOURCE")
impSet.close()
return script
exec(importScript())
def zwoesristatus(wonum, status, ldstatus):
esristatusSet = getMboSet("ZWOESRISTATUS")
esristatusSet.setWhere(toSQL("WONUM='?'",wonum))
esristatus = esristatusSet.moveFirst()
if esristatus == None:
esristatus = esristatusSet.add()
esristatus.setValue("WONUM",wonum,2)
esristatus.setValue("STATUS", status, 2)
esristatus.setValue("STATUS_LONGDESCRIPTION", ldstatus, 2)
saveClose(esristatusSet)
def sendWOStatus(log,wo):
ztype = wo.getMboSet("ZTYPES").moveFirst()
ztypewo = wo.getMboSet("ZTYPESWO").moveFirst()
from java.text import SimpleDateFormat
xmlDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
wsSet = wo.getMboSet('ZWSWO1')
header = wsSet.add()
header.setValue("TRACKINGID",str(Date().getTime()),11)
header.setValue("CREATIONTIME", xmlDate.format(Date()),11)
header.setValue("LOGIN", wo.getString("CHANGEBY"), 11)
history = header.getMboSet("ZWSWO3").add()
#TIBCO
history.setValue("OWNER", wo.getString("CHANGEBY"), 11)
history.setValue("DOMAIN", 'APP_MAXIMO', 11)
history.setValue("TYPE", 'Interfaces', 11)
history.setValue("SERVICENAME",'ZWOESRISTATUS.STATUS.ACTION', 11)
history.setValue("ACTION", 'ACTION', 11)
history.setValue("VERSION", '1.0', 11)
history.setValue("TIMESTAMP", header.getString("CREATIONTIME"), 11)
history.setValue("COMPONENT", 'ZWOTRACK', 11)
history.setValue("TRANSPORT", '', 11)
history.setValue("SUBJECT", '', 11)
history.setValue("STEP", '1', 11)
history.setValue("APPLICATION", 'MAXIMO', 11)
history.setValue("TRACKINGID", header.getString("TRACKINGID"), 11)
#WORKORDER
ot = header.getMboSet("ZWSWO16").add()
if not wo.isNull("ZCODEMPRESA"):
xmlDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
wsSet = wo.getMboSet('ZWSPC1')
header = wsSet.add()
header.setValue("TRACKINGID",str(Date().getTime()),11)
header.setValue("CREATIONTIME", xmlDate.format(Date()),11)
header.setValue("LOGIN", wo.getString("CHANGEBY"), 11)
#TIBCO
history = header.getMboSet("ZWSPC3").add()
history.setValue("OWNER", wo.getString("CHANGEBY"), 11)
history.setValue("DOMAIN", 'APP_MAXIMO', 11)
history.setValue("TYPE", 'Interfaces', 11)
history.setValue("SERVICENAME",'ZWSPC', 11)
history.setValue("ACTION", 'ACTION', 11)
history.setValue("VERSION", '1.0', 11)
history.setValue("TIMESTAMP", header.getString("CREATIONTIME"), 11)
history.setValue("COMPONENT", 'ZWOTRACK', 11)
history.setValue("TRANSPORT", '', 11)
history.setValue("SUBJECT", '', 11)
history.setValue("STEP", '1', 11)
history.setValue("APPLICATION", 'MAXIMO', 11)
history.setValue("TRACKINGID", header.getString("TRACKINGID"), 11)
#WORKORDER
ot = header.getMboSet("ZWSPC16").add()
ot.setValue("EMPRESA_CODEMPRESA", wo.getString("ZCODEMPRESA"), 11)
ot.setValue("ZWSPC16_CODATIVIDADE", 'JB002', 11) #recepcao do resultado da f
atibilidade
ot.setValue("ZWSPC16_CODPROCESSOCONS7441", wo.getString("ZCODPROCESSOCONSTRU
CAOPAI"), 11)
ot.setValue("ZWSPC16_CODAPRECIACAO", wo.getString("ZSRFATIBILIDADE.ZRESULTAD
O"), 11)
ot.setValue("ZWSPC16_COMENTARIOS", None, 11)
interaction = InteractionProcesser('ZWSPC')
close(wsSet)
interaction.invokeservice(wo)
def sendAtivoReply(log,zp_eai_header):
from java.text import SimpleDateFormat
xmlDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
ci = getMbo("CI","1=1")
ciSet = ci.getMboSet('ZWSATIVOREPLAY1')
header = ciSet.add()
header.setValue("TRACKINGID",str(Date().getTime()),11)
header.setValue("CREATIONTIME", xmlDate.format(Date()),11)
header.setValue("LOGIN", wo.getString("CHANGEBY"), 11)
#TIBCO
history = header.getMboSet("ZWSATIVOREPLAY3").add()
history.setValue("OWNER", 'MAXADMIN', 11)
history.setValue("DOMAIN", 'APP_MAXIMO', 11)
history.setValue("TYPE", 'Interfaces', 11)
history.setValue("SERVICENAME",'ZWSPC', 11)
history.setValue("ACTION", 'ACTION', 11)
history.setValue("VERSION", '1.0', 11)
history.setValue("TIMESTAMP", header.getString("CREATIONTIME"), 11)
history.setValue("COMPONENT", 'ZWOTRACK', 11)
keySet.reset()
keyvalue = keySet.moveFirst()
close(keySet)
if keyvalue == None:
return
zws_exp_sync = getMbo("ZWS_EXP_SYNC",toSQL("ZWS_EXP_SYNCID=?",keyvalue.getSt
ring("VALUE")))
close(zws_exp_sync)
if zws_exp_sync == None:
return
wo = getMbo("WORKORDER","1=1")
wsSet = wo.getMboSet('ZWSPCREPLY1')
header = wsSet.add()
header.setValue("TRACKINGID",str(Date().getTime()),11)
header.setValue("CREATIONTIME", xmlDate.format(Date()),11)
header.setValue("LOGIN", wo.getString("CHANGEBY"), 11)
#TIBCO
history = header.getMboSet("ZWSPCREPLY3").add()
history.setValue("OWNER", wo.getString("CHANGEBY"), 11)
history.setValue("DOMAIN", 'APP_MAXIMO', 11)
history.setValue("TYPE", 'Interfaces', 11)
history.setValue("SERVICENAME",'ZWSPC', 11)
history.setValue("ACTION", 'ACTION', 11)
history.setValue("VERSION", '1.0', 11)
history.setValue("TIMESTAMP", header.getString("CREATIONTIME"), 11)
history.setValue("COMPONENT", 'ZWOTRACK', 11)
history.setValue("TRANSPORT", '', 11)
history.setValue("SUBJECT", '', 11)
history.setValue("STEP", '1', 11)
history.setValue("APPLICATION", 'MAXIMO', 11)
history.setValue("TRACKINGID", zp_eai_header.getString("TRACKINGID"), 11)
ot = header.getMboSet("ZWSPCREPLY16").add()
ot.setValue("ZWSPCREPLY16_CODSTATUS", zp_eai_header.getString("NCODE"), 11)
ot.setValue("ZWSPCREPLY16_DESCSTATUS", zp_eai_header.getString("NDESCRIPTION
"), 11)
ot.setValue("EMPRESA_CODEMPRESA", zws_exp_sync.getString("CODEMPRESA"), 11)
ot.setValue("ZWSPCREPLY16_CODPROCESS9592", zws_exp_sync.getString("CODPROCES
SOCONSTRUCAOPAI"), 11)
ot.setValue("ZWSPCREPLY16_CODPROCESS", zws_exp_sync.getString("CODPROCESSOCO
NSTRUCAO"), 11)
interaction = InteractionProcesser('ZWSPCREPLY')
close(wsSet)
close(wo)
log.start()
interaction.invokeservice(wo)
log.stop()
def sentOtReplay(log,zp_eai_header):
from java.text import SimpleDateFormat
xmlDate = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss")
keySet = zp_eai_header.getMboSet("ZP_EAI_LOG_KEYS")
keySet.setWhere("FIELD='ZWS_OT_SYNCID'")
keySet.reset()
keyvalue = keySet.moveFirst()
close(keySet)
if keyvalue == None:
return
zws_ot_sync = getMbo("ZWS_OT_SYNC",toSQL("ZWS_OT_SYNCID=?",keyvalue.getStrin
g("VALUE")))
close(zws_ot_sync)
if zws_ot_sync == None:
return
wo = getMbo("WORKORDER","1=1")
wsSet = wo.getMboSet('ZWSWOREPLY1')
header = wsSet.add()
header.setValue("TRACKINGID",str(Date().getTime()),11)
header.setValue("CREATIONTIME", xmlDate.format(Date()),11)
header.setValue("LOGIN", wo.getString("CHANGEBY"), 11)
#TIBCO
history = header.getMboSet("ZWSWOREPLY3").add()
history.setValue("OWNER", wo.getString("CHANGEBY"), 11)
history.setValue("DOMAIN", 'APP_MAXIMO', 11)
history.setValue("TYPE", 'Interfaces', 11)
history.setValue("SERVICENAME",'ZWSPC', 11)
history.setValue("ACTION", 'ACTION', 11)
history.setValue("VERSION", '1.0', 11)
history.setValue("TIMESTAMP", header.getString("CREATIONTIME"), 11)
history.setValue("COMPONENT", 'ZWOTRACK', 11)
history.setValue("TRANSPORT", '', 11)
history.setValue("SUBJECT", '', 11)
history.setValue("STEP", '1', 11)
history.setValue("APPLICATION", 'MAXIMO', 11)
history.setValue("TRACKINGID", zp_eai_header.getString("TRACKINGID"), 11)
ot = header.getMboSet("ZWSWOREPLY16").add()
ot.setValue("ZWSWOREPLY16_CODSTATUS", zp_eai_header.getString("NCODE"), 11)
ot.setValue("ZWSWOREPLY16_DESCSTATUS", zp_eai_header.getString("NDESCRIPTION
"), 11)
ot.setValue("PROCESSOCONSTRUCAO_CODP1113", zws_ot_sync.getString("CODEXPEDIE
NTEPAI"), 11)
ot.setValue("PROCESSOCONSTRUCAO_CODP", zws_ot_sync.getString("CODEXPEDIENTER
AMAL"), 11)
ot.setValue("ZWSWOREPLY16_CODORDEMTR", zws_ot_sync.getString("CODIGOORDEM"),
11)
ot.setValue("EMPRESA_CODEMPRESA", zws_ot_sync.getString("CODEMPRESA"), 11)
interaction = InteractionProcesser('ZWSWOREPLY')
close(wsSet)
close(wo)
log.start()
interaction.invokeservice(wo)
log.stop()
objectname = mbo.getString("OBJECTNAME")
objectid = mbo.getString("OBJECTID")
status = mbo.getString("STATUS")
wsname = mbo.getString("WSNAME")
delete = False
if wsname == 'OT' and status == 'PEND':
zwoesristatus(objectid,'SEND',None)
log.save()
close(zp_eai_header)
delete = True
#envio do status da Fatibilidade
if wsname == 'FAT' and status == 'SENT':
wo = getMbo("WORKORDER",toSQL("WONUM='?'",objectid))
if wo != None:
log = Log()
log.setOutbound('ZWSObjectSend(FAT)')
log.setKeyValue('codOrdemTrabalho',objectid)
try:
sendWOFat(log,wo)
except:
type, value, traceback = sys.exc_info()
if 'BMXAA4214E' not in value.message:
log.setError(sys)
else:
log.setError(None)
log.save()
close(wo)
delete = True
#envio do status do AVA
if wsname == 'AVA' and status == 'SENT':
wo = getMbo("WORKORDER",toSQL("WONUM='?'",objectid))
if wo != None:
log = Log()
log.setOutbound('ZWSObjectSend(AVA)')
log.setKeyValue('codOrdemTrabalho',objectid)
try:
sendWOAva(log,wo)
except:
type, value, traceback = sys.exc_info()
if 'BMXAA4214E' not in value.message:
log.setError(sys)
else:
log.setError(None)
log.save()
close(wo)
delete = True
if wsname == 'ZWS_CI_SYNC' and status == 'SENT':
zp_eai_header = getMbo("ZP_EAI_LOG_HEADER",toSQL("ZP_EAI_LOG_HEADERID=?",obj
ectid))
if zp_eai_header != None:
log = Log()
log.setOutbound('ZWSATIVOREPLAY')
log.setKeyValue('ZP_EAI_LOG_HEADERID',objectid)
try:
sendAtivoReply(log,zp_eai_header)
except:
type, value, traceback = sys.exc_info()
if 'BMXAA4214E' not in value.message:
log.setError(sys)
else:
log.setError(None)
log.save()
close(zp_eai_header)
delete = True
if delete:
mbo.delete(11)