天翎MyApps技术社区 - 低代码平台 | 流程管理系统 | BPM软件

 找回密码
 注册成为天翎用户
查看: 2107|回复: 0

[函数] 获取流水号【函数-getSeq(countLabel,num,isYear,isMonth,isDay)】

[复制链接]
purple 发表于 2011-11-29 10:32:05 | 显示全部楼层 |阅读模式
本帖最后由 purple 于 2012-12-28 09:48 编辑

函数格式:
getSeq(countLabel,num,isYear,isMonth,isDay)
函数说明:
countLabel :字母
num :流水数几位
isYear : 年
isMonth : 月
isDay : 天
示例:
实现getSeq(countLabel,num,isYear,isMonth,isDay)函数的应用
function getSeq(countLabel,num,isYear,isMonth,isDay){
        var process = new Packages.cn.myapps.core.counter.ejb.CounterProcessBean($WEB.getApplication());
        var dateUtil = $BEANFACTORY.createObject("cn.myapps.util.DateUtil");
        var prefix = countLabel;

        var year = "";
        var month = "";
        var day = "";

        if(isYear){
                year = dateUtil.format(dateUtil.getToday(), "yy");
                prefix = prefix + year;
        }
        if(isMonth){
                month = dateUtil.format(dateUtil.getToday(), "MM");
                prefix = prefix + month;
        }
        if(isDay){
                day = dateUtil.format(dateUtil.getToday(), "DD");
                prefix = prefix + day;
        }
        var count = process.getNextValue(prefix, $WEB.getApplication(), $WEB.getDomainid());
        var val = "";
        if (count < 10) {
                for (var temp = 1; temp <= num - count.toString().length; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 100) {
                for (var temp = 1; temp <= num - count.toString().length; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 1000) {
                for (var temp = 1; temp <= num - count.toString().length; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 10000) {
                for (var temp = 1; temp <= num - count.toString().length; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 100000) {
                for (var temp = 1; temp <= num - count.toString().length; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 1000000) {
                for (var temp = 1; temp <= num - count.toString().length; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 10000000) {
                for (var temp = 1; temp <= num - count.toString().length; temp++) {
                        val += "0";
                }
                val += count;
        } else val += count;

        if(isDay){
                val = day + val;
        }
        if(isMonth){
                val = month + val;
        }
        if(isYear){
                val = year + val;
        }
        return val;
}

调用
#include " actionlib";
getSeq("countLabel","num","isYear","isMonth,isDay");

本版积分规则

QQ|手机版|天翎MyApps技术社区 ( 粤ICP备11093750号 )

GMT+8, 2026-8-12 06:41

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表