import java.text.DecimalFormat;
public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException {
if (first) {
first = false;
}
Object[] r = getRow();
if (r == null) {
setOutputDone();
return false;
}
r = createOutputRow(r, data.outputRowMeta.size());
String GMSFHM = get(Fields.In, "GMSFHM").getString(r);
String XM = get(Fields.In, "XM").getString(r);
String YXX = get(Fields.In, "YXX").getString(r);
String rawId = GMSFHM+"_"+XM+"_"+YXX;
int hashCode = rawId.hashCode();
//在下方的参数tab中设置的参数
int regions = Integer.valueOf(getParameter("regions"));
int regionCode = Math.abs(hashCode) % regions;
//格式化分区号
DecimalFormat df = new DecimalFormat("00");
String ID = df.format(regionCode)+"_"+rawId;
get(Fields.Out, "ID").setValue(r, ID);
putRow(data.outputRowMeta, r);
return true;
}