/**
* 根据编号规则生成规则编号
* @param rule 前缀
* @param num 数字位数
* @param orderField 排序字段
* @param table 表名
* @param sqlWhere 条件语句,不需and
* @return newNo
* @Author:
* @Date:
*/
public static String getRuleNewNo(String rule,String num, String orderField, String table, String sqlWhere){
int no=1;
int length = rule.length();
String newNo = String.format(rule + "%0"+num+"d", no);
sqlWhere = "".equals(sqlWhere) ? "" : (" and " + sqlWhere);
Object temp = (Object) Dao.getEntity("select max(" + orderField + ") from " + table + " where 1=1 " + sqlWhere);
if (temp != null) {
no = DataUtil.objToInt(temp.toString().substring(length)) + 1;
newNo = String.format(rule + "%0"+num+"d", no);
}
return newNo;
}