XiaXiang
6 years ago
3 changed files with 88 additions and 0 deletions
@ -0,0 +1,34 @@
|
||||
package com.fr.plugin.tabledata.modify; |
||||
|
||||
import com.fr.base.TableData; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.plugin.transform.ExecuteFunctionRecord; |
||||
import com.fr.plugin.transform.FunctionRecorder; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.fun.impl.AbstractDSModifyProvider; |
||||
|
||||
|
||||
@FunctionRecorder |
||||
public class DemoDSModify extends AbstractDSModifyProvider { |
||||
|
||||
@Override |
||||
public boolean accept( TableData ds, Calculator cal, DataModel old ) { |
||||
try{ |
||||
//每个第三方系统的表单结构都不一样~,这个实例处理的是SYS0792这个系统的
|
||||
//SYS0792表单内容是以JSON形式存放在 “第三方表单内容”(第5个字段) 这个字段里面的
|
||||
//结构为 {user:'',qnumber:'',addr:''}
|
||||
Object id = cal.eval("=$sysID"); |
||||
return "SYS0792".equals(id); |
||||
}catch(Exception e){ |
||||
|
||||
} |
||||
return false; |
||||
} |
||||
|
||||
@Override |
||||
@ExecuteFunctionRecord |
||||
public DataModel modify(TableData ds, Calculator cal, DataModel old ) { |
||||
return new DemoDataModel(old); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,54 @@
|
||||
package com.fr.plugin.tabledata.modify; |
||||
|
||||
|
||||
import com.fr.data.AbstractDataModel; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.general.data.TableDataException; |
||||
import com.fr.json.JSONObject; |
||||
|
||||
public class DemoDataModel extends AbstractDataModel { |
||||
|
||||
private DataModel old = null; |
||||
private static String[] exCols = new String[]{"user","qnumber","addr"}; |
||||
public DemoDataModel( DataModel old ){ |
||||
this.old = old; |
||||
} |
||||
|
||||
@Override |
||||
public int getColumnCount() throws TableDataException { |
||||
return old.getColumnCount()+2; |
||||
} |
||||
|
||||
@Override |
||||
public String getColumnName(int i) throws TableDataException { |
||||
if(i<5){ |
||||
return old.getColumnName(i); |
||||
} |
||||
if(i<8){ |
||||
return exCols[i-5]; |
||||
} |
||||
return old.getColumnName(i-2); |
||||
} |
||||
|
||||
@Override |
||||
public int getRowCount() throws TableDataException { |
||||
return old.getRowCount(); |
||||
} |
||||
|
||||
@Override |
||||
public Object getValueAt(int r, int c) throws TableDataException { |
||||
if( c<5 ){ |
||||
return old.getValueAt(r,c); |
||||
} |
||||
if( c<8 ){ |
||||
try{ |
||||
String val = (String) old.getValueAt(r,5); |
||||
JSONObject item = new JSONObject(val); |
||||
return item.opt(exCols[c-5]); |
||||
}catch(Exception e){ |
||||
return null; |
||||
} |
||||
} |
||||
return old.getValueAt(r,c-2); |
||||
} |
||||
} |
Loading…
Reference in new issue