关于为maximo应用程序增加操作类及操作方法的操作:
(1)首先进入应用程序设计器,打开相应的应用程序;
(2)在界面中打开"选择操作"的下拉菜单(位于界面的最上方);
(3)选择"切换显示所有控件",将隐藏的系统对象显示出来;
(4)点击"presentation"控件,然后点击"控制属性"按钮,(该按钮在界面的最上面),打开"演示属性"窗口;
(5)为App Bean类设置值:如ibmcust.webclient.beans.yum.OrderinforAppBean,该类需要继承AppBean,我这里选择的是继承StatefulAppBean;
(6)然后可以为该类增加insert,save,delete,等功能方法,需要override 父类里的这些相关方法;
(7)编写完成后,可以将该类放到maximo.ear中的maximouiweb.war目录下的WEB-INF/classes目录下或打成jar放到lib目录下(打成jar后需要重新启动服务器);
类例代码:
package ibmcust.webclient.beans.yum;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import psdi.mbo.MboRemote;
import psdi.mbo.MboSetRemote;
import psdi.util.MXException;
import psdi.webclient.beans.common.StatefulAppBean;
import psdi.webclient.system.controller.Utility;
public class OrderinforAppBean extends StatefulAppBean{
private final String APPLYER = "APPLYER";
private final String ORDERSTATUSNAME = "ORDERSTATUSNAME";
private final String DEGREENAME = "DEGREENAME";
private final String CREATEDATE = "CREATEDATE";
private final String DEFAULTDEGREE = "普通";
private final String STATEDRAFT = "Draft";
private final String STATENEW = "New";
private final String STATEPEDDING = "Pending";
private final String STATECLOSE = "Closed";
private final String STATECANCEL = "Cancel";
private final String MAXORDERCODE = "MAXORDERCODE";
private final String SEQUENCENUMBER = "SEQUENCENUMBER";
public int INSERT() throws MXException, RemoteException{
int ret = super.INSERT();
String username = this.getMXSession().getUserName();
this.setValue(APPLYER, username);
this.setValue(ORDERSTATUSNAME,STATEDRAFT);
this.setValue(DEGREENAME,DEFAULTDEGREE);
this.setValue(CREATEDATE,getCurrentDatetime());
this.setValue("ISREADONLY", "N");
return ret;
}
public int SAVE() throws MXException, RemoteException {
String SequenceNumber = this.getString(SEQUENCENUMBER);
if(SequenceNumber == null || SequenceNumber.equals("")){
MboRemote currMbo = (MboRemote) this.getMbo();
MboSetRemote msr = currMbo.getMboSet(MAXORDERCODE);
String maxNumber = "";
if(msr.isEmpty()){
} else {
MboRemote yumRemote = msr.getMbo(0);
maxNumber = yumRemote.getString(SEQUENCENUMBER);
}
maxNumber = getSequenNumber(maxNumber);
this.setValue(SEQUENCENUMBER,maxNumber);
}
String status = this.getString(ORDERSTATUSNAME);
if(status.equals(STATEDRAFT)){
this.setValue("EDITER", this.getMXSession().getUserName());
}else{}
int ret = super.SAVE();
return ret;
}
public int DELETE() throws MXException, RemoteException {
if(!this.getString(ORDERSTATUSNAME).equals(this.STATEDRAFT)){
Utility.showMessageBox(sessionContext.getCurrentEvent() ,
"信息",
"维修单已发送,不允许删除!",
0);
return -1;
}else{}
return super.DELETE();
}
public void PENDING() throws MXException,RemoteException{
String status = this.getString(this.ORDERSTATUSNAME);
if(status != null && !status.equals(this.STATENEW) && !status.equals(this.STATEPEDDING)){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"当前状态的工作单不允许进行派单操作!",0);
return;
}else{}
String station = this.getString("STATIONCODE");
if(station == null || station.equals("")){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"工作站未选择!",
0);
return;
}else{}
String engineer = this.getString("ENGINEERCODE");
if(engineer == null || engineer.equals("")){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"维修工程师未选择!",
0);
return;
}else{}
Date resTime = this.getDate("RESPONSETIME");
if(resTime == null){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"响应时间为空!",
0);
return;
}else{}
this.setValue(ORDERSTATUSNAME,STATEPEDDING);
this.setValue("ASSIGNER", this.getMXSession().getUserName());
this.SAVE();
}
public void CLOSE() throws MXException,RemoteException{
String state = this.getString(this.ORDERSTATUSNAME);
if(!state.equals(this.STATEPEDDING)){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"未进行派单操作!",
0);
return;
}else{}
String station = this.getString("STATIONCODE");
if(station == null || station.equals("")){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"工作站未选择!",
0);
return;
}else{}
String engineer = this.getString("ENGINEERCODE");
if(engineer == null || engineer.equals("")){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"维修工程师未选择!",
0);
return;
}else{}
Date arrTime = this.getDate("ARRIVETIME");
if(arrTime == null){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"实际到场时间为空!",
0);
return;
}else{}
Date colTime = this.getDate("CLOSETIME");
if(colTime == null){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"服务完成时间为空!",
0);
return;
}else{}
this.setValue(ORDERSTATUSNAME,this.STATECLOSE);
this.SAVE();
this.getMbo().setFlag(7L, true);
}
public void CANCEL() throws MXException,RemoteException{
String canReason = this.getString("CANCELREASON");
if(canReason == null || canReason.equals("")){
Utility.showMessageBox(this.sessionContext.getCurrentEvent(),
"错误",
"请填写取消原因!",
0);
return;
}
this.setValue("CANCELTIME",this.getCurrentDatetime());
this.setValue(ORDERSTATUSNAME, this.STATECANCEL);
this.SAVE();
this.getMbo().setFlag(7L, true);
}
public void SENDOR() throws MXException, RemoteException{
if(!this.getString(ORDERSTATUSNAME).equals(this.STATEDRAFT)){
Utility.showMessageBox(sessionContext.getCurrentEvent() ,
"信息",
"维修单已发送!",
0);
return;
}else{}
this.setValue(ORDERSTATUSNAME, this.STATENEW);
this.setValue("SENDDATE",getCurrentDatetime());
this.SAVE();
this.getMbo().setFlag(7L, true);
}
public String getSequenNumber(String num1) throws RemoteException, MXException{
String num = "";
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Date curDate = this.getDate("CREATEDATE");
String currDate = sdf.format(curDate);
if(num1 == null || num1.equals("")){
num = currDate + "001";
}else{
num = num1.substring(8,num1.length());
int temp = Integer.parseInt(num) + 1;
int len = Integer.toString(temp).length();
switch(len){
case 1:
num = "00" + Integer.toString(temp);
break;
case 2:
num = "0" + Integer.toString(temp);
break;
default:
num = Integer.toString(temp);
break;
}
num = currDate + num;
}
return num;
}
public boolean setReadOnlyState() throws RemoteException, MXException{
boolean lb = false;
String state = this.getString(ORDERSTATUSNAME);
if(state.equals(this.STATENEW)){
this.getMbo().setFlag(7L, true);
lb = true;
}else{}
return lb;
}
/**
* get current date time
* @return data format(yyyy-MM-dd hh:mm:ss)
*/
public String getCurrentDatetime(){
//SimpleDateFormat sm = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Calendar now = Calendar.getInstance();
String time = now.get(Calendar.YEAR)+"-"+(now.get(Calendar.MONTH)+1)+"-"+now.get(Calendar.DAY_OF_MONTH)+" "
+now.get(Calendar.HOUR_OF_DAY)+":"+now.get(Calendar.MINUTE)+":"+now.get(Calendar.SECOND);
return time;
}
}