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

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

[其他] 平台出现重复的单号!(cm)

[复制链接]
JT38180318 发表于 2014-5-9 14:11:43 | 显示全部楼层 |阅读模式
本帖最后由 Jarod 于 2014-7-9 18:49 编辑

如题,系统运行短短1月余,查看数据库,发现竟然有很多重复的单号产生!
1.jpg
2.jpg
3.jpg

请赶紧解决该问题,谢谢!
 楼主| JT38180318 发表于 2014-5-9 14:33:23 | 显示全部楼层
本帖最后由 JT38180318 于 2014-5-9 14:42 编辑

这个是平台获取单号的函数,是早期项目初建时,天翎平台员工过来本公司驻地开发时创建的:

/**
* 返回“前缀 + 增长序列号”
*
* @return 返回“前缀 + 增长序列号”
*
* @param headText
*            作为前缀的字符串
* @param isYear
*            boolean型,前缀中是否包含年份
* @param isMonth
*            boolean型,前缀中是否包含月份
* @param isDay
*            boolean型,前缀中是否包含日期
* @param digit
*            数值型,指定增长序列号的位数
*/
function countNextBySplit(headText, isYear, isMonth, isDay, digit,splittext) {
    var process = new Packages.cn.myapps.core.counter.ejb.CounterProcessBean($WEB
            .getApplication());

    var dateUtil = $BEANFACTORY.createObject("cn.myapps.util.DateUtil");

    var countLabel = headText;
    if (isYear) {
        countLabel += dateUtil.format(dateUtil.getToday(), "yy");
    }
    if (isMonth) {
        countLabel += dateUtil.format(dateUtil.getToday(), "MM");
    }
    if (isDay) {
        countLabel += dateUtil.format(dateUtil.getToday(), "dd");
    }
    var count = process.getNextValue(countLabel, $WEB.getApplication(), $WEB
                    .getDomainid());
    var val = "";
    if (count < 10) {
        for (var temp = 1; temp <= digit - count.toString().length; temp++) {
            val += "0";
        }
        val += count;
    } else if (count < 100) {
        for (var temp = 1; temp <= digit - count.toString().length; temp++) {
            val += "0";
        }
        val += count;
    } else if (count < 1000) {
        for (var temp = 1; temp <= digit - count.toString().length; temp++) {
            val += "0";
        }
        val += count;
    } else if (count < 10000) {
        for (var temp = 1; temp <= digit - count.toString().length; temp++) {
            val += "0";
        }
        val += count;
    } else if (count < 100000) {
        for (var temp = 1; temp <= digit - count.toString().length; temp++) {
            val += "0";
        }
        val += count;
    } else if (count < 1000000) {
        for (var temp = 1; temp <= digit - count.toString().length; temp++) {
            val += "0";
        }
        val += count;
    } else if (count < 10000000) {
        for (var temp = 1; temp <= digit - count.toString().length; temp++) {
            val += "0";
        }
        val += count;
    } else{
        val += count;
    }
    if(isNotNull(splittext)){
        countLabel += splittext;
    }
    var retvar = countLabel + val;
    return retvar;
}
david 发表于 2014-5-12 10:03:36 | 显示全部楼层
请楼主提供一下程序版本(具体版本号)。因为你们有三个项目(交通运输、闭环、OA)共用一个帐号发帖,在发帖时请注明项目名称或者留下联系方式。
 楼主| JT38180318 发表于 2014-5-12 10:07:46 | 显示全部楼层
本帖最后由 JT38180318 于 2014-5-12 10:08 编辑

闭环系统,sp8,2014年4月5日版
(联系人:陈敏,86010123-257)
david 发表于 2014-5-13 09:49:45 | 显示全部楼层
楼主您好,obpm平台自2011年起就已经使用countNext2函数了。楼主可以参阅以下帖子使用countNext2函数生成唯一单号。
http://www.teemlink.com/bbs/viewthread.php?tid=158778
http://www.teemlink.com/bbs/viewthread.php?tid=161025

有问题再沟通。
 楼主| JT38180318 发表于 2014-5-13 10:32:47 | 显示全部楼层
本帖最后由 JT38180318 于 2014-5-13 10:34 编辑

出现重复单号使用的计算函数:
var count = process.getNextValue(countLabel, $WEB.getApplication(), $WEB.getDomainid());

听我同事说:“countNext2好像就是调用这个 process.getNextValue”。
如果是这样,那只是把目前我们计算的方法封装了一下,实现的方式没变,那就还是可能产生重复单号啊!

请确认下。
david 发表于 2014-5-13 10:53:45 | 显示全部楼层
您好,咨询过研发的同事,使用countNext2确认不会产生重复单号。请知悉。
 楼主| JT38180318 发表于 2014-5-13 11:00:02 | 显示全部楼层
本帖最后由 JT38180318 于 2014-5-13 12:38 编辑

好的                   。
 楼主| JT38180318 发表于 2014-5-13 11:19:22 | 显示全部楼层
本帖最后由 JT38180318 于 2014-5-13 11:26 编辑

刚才在平台去查询了baselib.js文件,发现countNext2的确如我同事所说,只是把目前使用的生成方式封装一下而已呀!
1.jpg
源代码如下:
(请你们研发的同事仔细测试一下,在我们的测试环境的确没有发现生成重发单号,但是生产环境的不同用户同一时间并发操作几率增高不少,用该种方法一个月已经产生几十次重复单号!)
/**
* 返回“前缀 + 增长序列号”
*
* @return 返回“前缀 + 增长序列号”
*
* @param headText
*            作为前缀的字符串
* @param isYear
*            boolean型,前缀中是否包含年份
* @param isMonth
*            boolean型,前缀中是否包含月份
* @param isDay
*            boolean型,前缀中是否包含日期
* @param digit
*            数值型,指定增长序列号的位数
*/
function countNext2(headText, isYear, isMonth, isDay, digit) {
        var process = new Packages.cn.myapps.core.counter.ejb.CounterProcessBean($WEB
                        .getApplication());

        var dateUtil = $BEANFACTORY.createObject("cn.myapps.util.DateUtil");

        var countLabel = headText;
        if (isYear) {
                countLabel += dateUtil.format(dateUtil.getToday(), "yy");
        }
        if (isMonth) {
                countLabel += dateUtil.format(dateUtil.getToday(), "MM");
        }
        if (isDay) {
                countLabel += dateUtil.format(dateUtil.getToday(), "dd");
        }
        var count = process.getNextValue(countLabel, $WEB.getApplication(), $WEB
                                        .getDomainid());
        var val = "";
        if (count < 10) {
                for (var temp = 1; temp <= digit - 1; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 100) {
                for (var temp = 1; temp <= digit - 2; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 1000) {
                for (var temp = 1; temp <= digit - 3; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 10000) {
                for (var temp = 1; temp <= digit - 4; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 100000) {
                for (var temp = 1; temp <= digit - 5; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 1000000) {
                for (var temp = 1; temp <= digit - 6; temp++) {
                        val += "0";
                }
                val += count;
        } else if (count < 10000000) {
                for (var temp = 1; temp <= digit - 7; temp++) {
                        val += "0";
                }
                val += count;
        } else
                val += count;
        var retvar = countLabel + val;
        return retvar;
}
david 发表于 2014-5-13 16:46:40 | 显示全部楼层
您好,咨询过研发,研发说两种的运行方式不一样。请您参考5楼的帖子实现单号自动编号。有问题再沟通。

本版积分规则

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

GMT+8, 2026-8-13 16:20

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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