后台
Date date = new Date(); SimpleDateFormat dmDate = new SimpleDateFormat("yyyyMMdd"); // 获取当前时间 String dateran = dmDate.format(date); String sql = " select case when main_number is null then '0001' else substr(max(substr(main_number,7))+1,7) end main_number " + " from aviation_info where DATE_FORMAT(create_date,'%Y%m%d') = DATE_FORMAT(now(),'%Y%m%d') "; String maxnum = jdbcTemplate.queryForObject(sql,String.class); String mainNumber = "HKZD"+dateran+maxnum; aviationInfo.setMainNumber(mainNumber); aviationInfoService.save(aviationInfo);