需要根据场次编号的字母得到下一个字母, 来生成场次编号。
比如: 目前最大的字母是 d 那么, 生成的下一个字母就是 e , 依次类推。
查询得到字符 char 类型可以直接转化成 int 类型, 得到的数值是该字符的ASCII值。
那么得到代码:
//字符编码如: 001a1 ,, 002b3 之类。
public int getNumOfsim(SimSuite simtuit) {
// TODO Auto-generated method stub\
String sql = " select MAX(S_NO) from xxxxxxx m WHERE m.suite_id IN ("+
"SELECT t.suite_id FROM xxxxxxx t "+
"where t.ac_type_code= '" + simtuit.getAcType() + "' and t.fixed_year='" +simtuit.getFixedYear()+"'"+" and t.train_com="+simtuit.getTrainCom()
+" and t.batch_no='"+simtuit.getBatchNo()+"')";
String maxSno = (String) jdbcTemplate.queryForObject(sql, String.class);
if(maxSno == null || maxSno.length()<3){
return 0;
}
//取倒数第二位
char maxChar = maxSno.charAt(maxSno.length()-2);
int rst = maxChar;
return rst-96;
}