递归这个方法应用很普遍,理解起来也很简单,方法在执行过程中调用了自己本身。
//查询事项的工程编号
public String getGcbhBySxid(CommonService commonService,String sxunid){
String gcbh="";
ZdylNdjhSxfj ndjhSxfj=commonService.get(ZdylNdjhSxfj.class, sxunid);
if(!"GC".equals(ndjhSxfj.getSxlx())){
return getGcbhBySxid(commonService,ndjhSxfj.getParunid());
}else{
gcbh=ndjhSxfj.getSxmc();
}
Object[] obj=gcbh.split("、");
gcbh=(String) obj[0];
return gcbh;
}
注意递归中有return 值