zoukankan      html  css  js  c++  java
  • 最小可用值的获取之_根据当前科目编码获取最小可用值

    Demo

        /**
         * 获取一个新的科目编码
         *
         * @param parentCode 上级科目代码
         * @author 吕嘉鸣
         */
        @Override
        public String getNewCode(String subjectTableName, Long deptId, String parentCode) {
            String oldCode = parentCode;
            parentCode = parentCode + "___";
            String newCode = sysSubjectMapper.getNewCode(subjectTableName, deptId, parentCode);
            if (null == newCode || "".equals(newCode)) {
                return oldCode + "001";
            } else {
                String tailCode = newCode.substring(newCode.length() - 3, newCode.length());
    
                newCode = oldCode + String.format("%03d", Integer.valueOf(tailCode) + 1);
            }
            return newCode;
        }
    
        /**
         * 根据当前科目编码获取最小可用值
         *
         * @param tableName 科目表名
         * @param deptId 机构id
         * @param parentCode 上级科目代码
         * @return 未使用的最小的科目编码
         * @author 吕嘉鸣(idea)
         */
    
        @Select(" SELECT code AS newCode " +
                " FROM ${tableName} AS t1 WHERE  t1.`code` LIKE #{parentCode}  AND  right(code, 3) != '999' AND t1.deleted = 0" +
                " AND not exists(select code  FROM ${tableName} AS t2 WHERE t2.dept_id = #{deptId} AND t2.deleted = 0 AND  CONVERT(t2.code,SIGNED)=CONVERT(t1.code,SIGNED)+1  ) order by CONVERT(right(code, 3),SIGNED) limit 1;")
        String getNewCode(String tableName,Long deptId,String parentCode);
    
  • 相关阅读:
    Advanced Developer's Blog
    图片文字识别
    Unit test resources
    SpringBoot-mvn插件
    flask中使用proto3
    QTA-qtaf自动化测试实践
    AttributeError: module 'virtualenv' has no attribute 'create_environment'
    qtaf dick 报错 NameError: name 'dict_values' is not defined
    24点python实现
    mysql在win下移植
  • 原文地址:https://www.cnblogs.com/ideaAI/p/14762372.html
Copyright © 2011-2022 走看看