根据规则生成第一个新的顺序号
//根据规则生成第一个新的顺序号
public static String getSerial(Connection conn,ZjLogger logger,ModuleUtil moduleUtil) {
//获取时间戳
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String timeString = formatter.format(currentTime);
//按条件查出最大的顺序号
String number = "0000";
String serial = timeString+number;
String qryMax="select max(TRANSFER_NO) from PBC_TRANSFER_APPLY_INNER where substr(TRANSFER_NO,0,8) =? ";
List<SQLPara> sqlParas = new ArrayList<SQLPara>();
sqlParas.add(new SQLPara("substr(TRANSFER_NO,0,8)",Types.VARCHAR,timeString));
try {
CachedRowSet codeResult = DbOperate.executeQueryByParamName(qryMax, sqlParas, conn, logger);
codeResult.last();
Integer a = codeResult.getRow();
codeResult.beforeFirst();
while(codeResult.next()&&a>0) {
serial = codeResult.getString("max(TRANSFER_NO)");
Long temp =Long.parseLong(serial);
temp=temp+1;
//生成6位顺序号
serial = temp.toString();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
logger.debug("serial:"+serial);
return serial;
}