zoukankan      html  css  js  c++  java
  • 自动生成业务编号 备份

         String sqlCode = "SELECT MAX(code) as code from gongzuo where   year(create_date) = year(NOW()) and month(create_date)=month(NOW())  ";
                    String delegateCode = jdbcTemplate.queryForObject(sqlCode, String.class);
    
                    StringB     String sqlCode = "SELECT MAX(code) as code from gongzuo where   year(create_date) = year(NOW()) and month(create_date)=month(NOW())  ";
                    String delegateCode = jdbcTemplate.queryForObject(sqlCode, String.class);
    
                    StringBuffer code = new StringBuffer("ZY");
                    code.append(DateUtils.getDataString(DateUtils.yyyyMMdd).substring(2, 6));
                    if (StringUtils.isEmpty(delegateCode)) {
                        code.append("0001");
                    } else {
                        code.append(getCode(delegateCode));
                    }
                    gongzuo.setCode(code.toString());uffer code = new StringBuffer("ZY");
                    code.append(DateUtils.getDataString(DateUtils.yyyyMMdd).substring(2, 6));
                    if (StringUtils.isEmpty(delegateCode)) {
                        code.append("0001");
                    } else {
                        code.append(getCode(delegateCode));
                    }
                    gongzuo.setCode(code.toString());
     // 后4位自定义编码 +1
        public String getCode(String code) {
            String result = "";
            code = code.substring(code.length() - 4);
            int a = Integer.parseInt(code);
            a++;
            int len = (a + "").length();
            if (len == 1) {
                result = "000" + a;
            } else if (len == 2) {
                result = "00" + a;
            } else if (len == 3) {
                result = "0" + a;
            } else {
                result = "" + a;
            }
            return result;
        }
  • 相关阅读:
    windows系统中ubuntu虚拟机安装及web项目到服务上(二)
    windows系统中ubuntu虚拟机安装及web项目到服务上(一)
    每个配置xml的含义作用
    第三天气接口使用总结
    js模式学习
    mac下php环境配置
    struts2
    MySQL常用命令
    JavaMail邮件开发
    文件上传与下载
  • 原文地址:https://www.cnblogs.com/xueblvip/p/14380593.html
Copyright © 2011-2022 走看看