酷酷七友软件定做 酷酷七友软件

软件开发

Ems连号算法公布

 Ems连号算法公布 

ems和顺丰一样,单号是不连的,这样在开发快递单方面的软件时,想自动算出下一个号还真麻烦,找了下网上的,好像没人公布这些算法呀,ems这是中国人搞中国人?还是商业利益问题??不懂,我公布出来应该可以帮到一些人吧

public static string getNextExpId(string oId)
        {
            string str1 = "";
          
              //先判断是否ems
            if (myMatch(oId, "^E[ -Z 9}C[A-Z]+$", 0) != "")
            {
              string s_oNum =userHelper.myMatch(oId, "\\d+", 0);//获取旧的id数字部分
              long tmp_Num =long.Parse(s_oNum.Substring(0, 8))+1;
              str1 = oId.Replace(s_oNum, tmp_Num.ToString());//新ems号

                long num_1 = 8 * long.Parse(str1.Substring(2, 1));
               long num_4 = 2 * long.Parse(str1.Substring(5, 1));
                long num_5 = 3 * long.Parse(str1.Substring(6, 1));
                long num_6 = 5 * long.Parse(str1.Substring(7, 1));
                long num_7 = 9 * long.Parse(str1.Substring(8, 1));
                long num_8 = 7 * long.Parse(str1.Substring(9, 1));
                long num_sum = num_1 + num_2 + num_5 + num_6 + num_7 + num_8;
                long num_mod = num_sum % 11;

                long num_result = 11 - num_mod;
                if (num_result == 11)
                {
                    num_result = 5;
                }
                else if (num_result == 10)
                {
                    num_result = 0;
                }
            return    str1.Insert(3, num_result.ToString());      
            }
           //普通单
         str1=  userHelper.myMatch(oId, "\1+", 0);//取数字部分
        return oId.Replace(str1, (long.Parse(str1) + 1).ToString());
        }