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);
    
  • 相关阅读:
    【NOI2008】志愿者招募
    【NOI2015】小园丁和老司机
    【TJOI2007】小朋友
    【HNOI2008】神奇的国度
    【CTSC2014】企鹅QQ
    【CQOI2014】通配符匹配
    【JSOI2008】火星人
    【SCOI2007】压缩
    【ZJOI2009】对称的正方形
    【LOJ#6066】同构子树
  • 原文地址:https://www.cnblogs.com/ideaAI/p/14762372.html
Copyright © 2011-2022 走看看