public void Update(CodeRule info)
 {
     Acctrue.Library.Data.SqlEntry.KeyValueCollection keys = new Acctrue.Library.Data.SqlEntry.KeyValueCollection();
     info.ModifiedTime = DateTime.Now;
     info.Modifier     = "test";
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("CodeRuleName", info.CodeRuleName));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("RuleStatus", info.RuleStatus));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("CodeLength", info.CodeLength));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("CodeVersions", info.CodeVersions != null ? info.CodeVersions : ""));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("CodeArguments", info.CodeArguments != null ? info.CodeArguments : ""));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("CodeExtensions", info.CodeExtensions != null ? info.CodeExtensions : ""));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("CodeRuleType", info.CodeRuleType));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("Description", info.Description));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("IsMaskCode", info.IsMaskCode));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("IsParseCode", info.IsParseCode));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("ModifiedTime", info.ModifiedTime));
     keys.Add(new Acctrue.Library.Data.SqlEntry.KeyValue("Modifier", info.Modifier));
     if (info.CodeRuleId == 0)
     {
         info.CreatedTime = DateTime.Now;
         info.Creator     = "test";
         dbContext.Insert <CodeRule>(info);
     }
     else
     {
         dbContext.Update <CodeRule>(keys, CK.K["CodeRuleId"].Eq(info.CodeRuleId));
     }
 }
        /// <summary>
        /// 获取查询申请记录
        /// </summary>
        /// <param name="applyId">申请记录Id</param>
        /// <returns></returns>

        public CodeRule GetCodeRule(int codeRuleId)
        {
            Condition where = Condition.Empty & CK.K["CodeRuleId"].Eq(codeRuleId);
            CodeRule rule = dbContext.From <CodeRule>().Where(where).Select().FirstOrDefault();

            return(rule);
        }
Beispiel #3
0
        public void loadResources(string custId, string delMatno, string boundType, string workno, string cusPo)
        {
            capacity = capacityService.queryByRelation(custId, delMatno, boundType);
            if (capacity != null)
            {
                this.countBoxQty(capacity.Capacityqty, workno, cusPo);
                this.textBox12.Text = capacity.Capacitydesc;
                this.textBox14.Text = capacity.Capacityqty.ToString();
            }

            codeRule = codeRuleService.queryRuleByCond(custId, delMatno, boundType);  //1代表Carton碼編碼規則
            if (codeRule != null)
            {
                this.textBox2.Text = codeRule.RuleDesc;
            }
            mandUnionFieldTypeList = manRelFieldTypeService.queryFieldListByCond(custId, delMatno, boundType);
            fileRelDel             = fileRelDelService.queryFileRelDelCusNo(custId, delMatno, boundType);
            //下載模板並預覽   1.查询模板是否存在, 若存在不下载  2.若不存在下载模板
            if (fileRelDel != null)
            {
                filePath = modelInfoService.previewModelFile(fileRelDel.FileNo);
                //if (filePath != null)
                //{
                //    string pictureFile = barPrint.PreviewPrintBC(filePath);
                //    this.pictureBox1.Load(pictureFile);
                //}
            }
        }
Beispiel #4
0
        /// <summary>
        /// TODO 模糊查詢編碼規則列表信息
        /// </summary>
        /// <param name="ruleNo"></param>
        /// <returns></returns>
        public List <CodeRule> queryRulesByType(string ruleNo)
        {
            List <CodeRule> codeRuleList = null;
            StringBuilder   strSql       = new StringBuilder();

            strSql.Append("SELECT uuid,rule_no,rule_desc,op_user,create_time,update_user,update_time FROM t_rule_info WHERE rule_no like @ruleNo AND del_flag is null ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ruleNo", MySqlDbType.VarChar, 900)
            };
            parameters[0].Value = "%" + ruleNo + "%";
            DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                codeRuleList = new List <CodeRule>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    CodeRule codeRule = new CodeRule();
                    codeRule.Uuid       = dr["uuid"].ToString();
                    codeRule.Ruleno     = dr["rule_no"].ToString();
                    codeRule.RuleDesc   = dr["rule_desc"].ToString();
                    codeRule.Opuser     = dr["op_user"].ToString();
                    codeRule.Createtime = dr["create_time"].ToString();
                    codeRule.UpdateUser = dr["update_user"].ToString();
                    codeRule.Updatetime = dr["update_time"].ToString();
                    codeRuleList.Add(codeRule);
                }
            }
            return(codeRuleList);
        }
Beispiel #5
0
        /// <summary>
        /// TODO 保存編碼規則信息
        /// </summary>
        /// <param name="codeRule"></param>
        /// <returns></returns>
        public bool saveCodeRule(CodeRule codeRule)
        {
            bool          saveMark = true;
            StringBuilder strSql   = new StringBuilder();

            strSql.Append("insert into t_rule_info (uuid,rule_desc,op_user,create_time)");
            strSql.Append("values(@uuid,@ruleDesc,@opuser,@createtime)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@uuid",       MySqlDbType.VarChar, 900),
                new MySqlParameter("@ruleDesc",   MySqlDbType.VarChar, 900),
                new MySqlParameter("@opuser",     MySqlDbType.VarChar, 900),
                new MySqlParameter("@createtime", MySqlDbType.VarChar, 900)
            };
            parameters[0].Value = codeRule.Uuid;
            parameters[1].Value = codeRule.RuleDesc;
            parameters[2].Value = codeRule.Opuser;
            parameters[3].Value = codeRule.Createtime;
            int rows = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                saveMark = true;
            }
            else
            {
                saveMark = false;
            }
            return(saveMark);
        }
Beispiel #6
0
        /// <summary>
        /// TODO 查詢規則編號,查詢詳細信息
        /// </summary>
        /// <param name="ruleNo"></param>
        /// <returns></returns>
        public CodeRule queryRuleById(string ruleNo)
        {
            CodeRule      codeRule = null;
            StringBuilder strSql   = new StringBuilder();

            strSql.Append("SELECT uuid,rule_no,rule_desc,op_user,create_time,update_user,update_time FROM t_rule_info where rule_no=@ruleNo AND del_flag is null");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ruleNo", MySqlDbType.VarChar, 900),
            };
            parameters[0].Value = ruleNo;
            DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                codeRule            = new CodeRule();
                codeRule.Uuid       = ds.Tables[0].Rows[0]["uuid"].ToString();
                codeRule.Ruleno     = ds.Tables[0].Rows[0]["rule_no"].ToString();
                codeRule.RuleDesc   = ds.Tables[0].Rows[0]["rule_desc"].ToString();
                codeRule.Opuser     = ds.Tables[0].Rows[0]["op_user"].ToString();
                codeRule.Createtime = ds.Tables[0].Rows[0]["create_time"].ToString();
                codeRule.UpdateUser = ds.Tables[0].Rows[0]["update_user"].ToString();
                codeRule.Updatetime = ds.Tables[0].Rows[0]["update_time"].ToString();
            }
            if (codeRule != null)
            {
                List <RuleItem> ruleItems = null;
                StringBuilder   strSql1   = new StringBuilder();
                strSql1.Append("SELECT uuid,rule_no,seq_no,rule_type,rule_value,rule_length,op_user,create_time,update_user,update_time FROM t_code_rule WHERE rule_no = @ruleNo AND del_flag is null ORDER BY seq_no ASC");
                MySqlParameter[] parameters1 =
                {
                    new MySqlParameter("@ruleNo", MySqlDbType.VarChar, 900),
                };
                parameters1[0].Value = ruleNo;
                DataSet ds1 = SQLHelper.ExecuteDataset(SQLHelper.ConnectionString, CommandType.Text, strSql1.ToString(), parameters1);
                if (ds1 != null && ds1.Tables.Count > 0 && ds1.Tables[0].Rows.Count > 0)
                {
                    ruleItems = new List <RuleItem>();
                    foreach (DataRow dr in ds1.Tables[0].Rows)
                    {
                        RuleItem ruleItem = new RuleItem();
                        ruleItem.Uuid       = dr["uuid"].ToString();
                        ruleItem.Ruleno     = dr["rule_no"].ToString();
                        ruleItem.Seqno      = dr["seq_no"].ToString();
                        ruleItem.Ruletype   = dr["rule_type"].ToString();
                        ruleItem.Rulevalue  = dr["rule_value"].ToString();
                        ruleItem.Rulelength = int.Parse(dr["rule_length"].ToString());
                        ruleItem.Opuser     = dr["op_user"].ToString();
                        ruleItem.Createtime = dr["create_time"].ToString();
                        ruleItem.UpdateUser = dr["update_user"].ToString();
                        ruleItem.Updatetime = dr["update_time"].ToString();
                        ruleItems.Add(ruleItem);
                    }
                }
                codeRule.RuleItem = ruleItems;
            }
            return(codeRule);
        }
        public string ChangeState(Dictionary <string, int> dic)
        {
            CodeRule ruleInfo = CodeRuleFactory.Instance.Get(dic["CodeRuleId"]);

            ruleInfo.RuleStatus   = (RuleStatus)dic["RuleStatus"];
            ruleInfo.Modifier     = (string)HttpContext.Current.Session["UserName"];
            ruleInfo.ModifiedTime = DateTime.Now;
            CodeRuleFactory.Instance.Update(ruleInfo);
            return(JsonConvert.SerializeObject(this.Response).ToString());
        }
        /// <summary>
        /// 载入数据信息
        /// </summary>
        public void LoadData()
        {
            //清理旧信息
            codeRules.Clear();
            segRulers.Clear();
            applyRuleProcessDict.Clear();
            ruleFeatureTags.Clear();
            //codeRuleSegDict.Clear();


            int[] ruleIds;

            try
            {
                ruleIds = Array.ConvertAll <string, int>(codeApply.CodeRulesIDs.Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s));
                #region 计算各码规则生成数量
                outerPackageRatios = Array.ConvertAll <string, int>(codeApply.OuterPackage.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries), s => int.Parse(s));
                if (outerPackageRatios.Length == 0)//默认未配置则为1比例
                {
                    outerPackageRatios = new int[] { 1 };
                }
                if (outerPackageRatios.Length < ruleIds.Length)
                {
                    throw new Exception("码申请信息设置的包装比例分组小于码规则分组!");
                }
                //singleRatioAmount = GetSingleRatioAmount(this.outerPackageRatios, this.codeApply.ApplyAmount);
                #endregion
                string featureTag = string.Empty;
                List <ApplyRuleProcess> allApplyRuleProcess = ApplyRuleProcessFactory.Instance.GetCodeRuleByApplyId(this.codeApply.ApplyId);
                for (int i = 0; i < ruleIds.Length; i++)                              //载入码规则及码规则处理状态
                {
                    CodeRule rule = CodeRuleFactory.Instance.GetCodeRule(ruleIds[i]); //码规则详细信息
                    if (rule == null)
                    {
                        throw new Exception($"码申请中使用的码规则不存在,码规则Id:{ruleIds[i]}");
                    }
                    codeRules.Add(rule);//码规则数据模型集合
                    //codeRuleSegDict.Add(rule, CodeRuleSegFactory.Instance.GetByCodeRuleId(rule.CodeRuleId));
                    SegRuler ruler = new SegRuler();
                    //码段信息
                    List <CodeRuleSeg> segs = CodeRuleSegFactory.Instance.GetByCodeRuleId(rule.CodeRuleId);

                    FormatSegs(this.codeApply, segs, out featureTag);        //根据码申请信息格式化码段参数
                    ruler.Initialization(rule, segs);                        //初始化码规则类
                    segRulers.Add(ruler);                                    //码规则类集合
                    applyRuleProcessDict.Add(ruler, allApplyRuleProcess[i]); //码申请下码规则处理信息数据模型集合
                    ruleFeatureTags.Add(ruler, featureTag);                  //码申请下码规则当前特征标签
                }
            }
            catch (Exception ex)
            {
                throw new Exception($"码申请处理模块载入码规则出现格式异常!{ex.Message}", ex);
            }
        }
        public string AddCodeRule(dynamic obj)
        {
            MyResponse.Response res = new MyResponse.Response();
            string   msg            = "";
            string   json           = JsonConvert.SerializeObject(obj);
            CodeRule config         = JsonConvert.DeserializeObject <CodeRule>(json);

            config.Creator = (string)HttpContext.Current.Session["UserName"];
            CodeRuleFactory.Instance.Add(config);
            this.Response.message = msg;
            Log("{\"LogMenu\":\"系统管理\",\"LogAction\":\"添加码规则\"}", this.UserName, this.IP);
            return(JsonConvert.SerializeObject(this.Response).ToString());
        }
        public string Update(Dictionary <string, string> dic)
        {
            CodeRule ruleInfo = DicToObject <CodeRule>(Newtonsoft.Json.JsonConvert.DeserializeObject <Dictionary <string, object> >(dic["CodeRule"]));

            ruleInfo.ModifiedTime = DateTime.Now;
            ruleInfo.Modifier     = (string)HttpContext.Current.Session["UserName"];
            if (ruleInfo.CodeRuleId == 0)
            {
                ruleInfo.Creator     = (string)HttpContext.Current.Session["UserName"];
                ruleInfo.CreatedTime = DateTime.Now;
                ruleInfo.CodeRuleId  = CodeRuleFactory.Instance.Add(ruleInfo);
            }
            else
            {
                CodeRuleFactory.Instance.Update(ruleInfo);
            }
            List <Dictionary <string, object> > delSeginfos = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(dic["DelSegs"]);

            foreach (Dictionary <string, object> seg in delSeginfos)
            {
                if (seg != null)
                {
                    CodeRuleSeg segInfo = DicToObject <CodeRuleSeg>(seg);
                    CodeRuleSegFactory.Instance.Delete(segInfo);
                }
            }

            List <Dictionary <string, object> > seginfos = JsonConvert.DeserializeObject <List <Dictionary <string, object> > >(dic["RuleSegs"]);

            foreach (Dictionary <string, object> seg in seginfos)
            {
                if (seg != null)
                {
                    CodeRuleSeg segInfo = DicToObject <CodeRuleSeg>(seg);
                    segInfo.CodeRuleId = ruleInfo.CodeRuleId;
                    if (segInfo.SegId == 0)
                    {
                        CodeRuleSegFactory.Instance.Add(segInfo);
                    }
                    else
                    {
                        CodeRuleSegFactory.Instance.Update(segInfo);
                    }
                }
            }
            Log("{\"LogMenu\":\"系统管理\",\"LogAction\":\"修改码规则[" + ruleInfo.CodeRuleName + "]\"}", this.UserName, this.IP);
            return(JsonConvert.SerializeObject(this.Response).ToString());
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            var d = new Dictionary <string, string>();

            d.Add("zto", "123");
            d.Add("sto", "456");

            var rule = new CodeRule()
            {
                RuleMap = d
            };

            Console.WriteLine(JsonConvert.SerializeObject(rule));
            Console.WriteLine(new Test().doTest <string>(2));
            Console.ReadLine();
        }
Beispiel #12
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (this.textBox2.Text == null || this.textBox2.Text.Trim() == "")
            {
                MessageBox.Show("規則描述不能為空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.textBox2.Focus();
                return;
            }
            if (this.dataGridView1.RowCount == 0)
            {
                MessageBox.Show("規則不能為空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (this.textBox1.Text != null && this.textBox1.Text.Trim() != "")
            {
                MessageBox.Show("該規則已經保存,請勿重複保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            CodeRule codeR = new CodeRule();

            codeR.RuleDesc = this.textBox2.Text;
            List <RuleItem> list = new List <RuleItem>();

            for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
            {
                RuleItem ruleItem = new RuleItem();
                ruleItem.Seqno      = this.dataGridView1.Rows[i].Cells[2].Value == null ? "": this.dataGridView1.Rows[i].Cells[2].Value.ToString();
                ruleItem.Ruletype   = this.dataGridView1.Rows[i].Cells[3].Value == null ? "":this.dataGridView1.Rows[i].Cells[3].Value.ToString();
                ruleItem.Rulevalue  = this.dataGridView1.Rows[i].Cells[4].Value == null ? "" : this.dataGridView1.Rows[i].Cells[4].Value.ToString();
                ruleItem.Rulelength = int.Parse(this.dataGridView1.Rows[i].Cells[5].Value == null ? "0": this.dataGridView1.Rows[i].Cells[5].Value.ToString());
                list.Add(ruleItem);
            }
            codeR.RuleItem = list;
            string saveResult = codeRuleService.saveRuleInfo(codeR);

            if (saveResult != null)
            {
                this.textBox1.Text = saveResult;
                MessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("保存失敗!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Beispiel #13
0
        private void button1_Click(object sender, EventArgs e)
        {
            string   queryValue = this.textBox1.Text;
            CodeRule codeR      = codeRuleService.queryRuleById(queryValue);

            if (codeR != null)
            {
                this.textBox2.Text            = codeR.RuleDesc;
                this.textBox3.Text            = codeR.Opuser;
                this.textBox4.Text            = codeR.Createtime;
                this.dataGridView1.DataSource = codeR.RuleItem;


                //DGV 改變列名,列寬
                this.dataGridView1.Columns[0].Visible    = false;
                this.dataGridView1.Columns[0].Width      = 0;
                this.dataGridView1.Columns[1].HeaderText = "規則編號";
                this.dataGridView1.Columns[1].Width      = 80;
                this.dataGridView1.Columns[2].HeaderText = "流水編號";
                this.dataGridView1.Columns[2].Width      = 80;
                this.dataGridView1.Columns[3].HeaderText = "規則類型";
                this.dataGridView1.Columns[3].Width      = 80;
                this.dataGridView1.Columns[4].HeaderText = "規則值";
                this.dataGridView1.Columns[4].Width      = 80;
                this.dataGridView1.Columns[5].HeaderText = "規則長度";
                this.dataGridView1.Columns[5].Width      = 80;
                this.dataGridView1.Columns[6].HeaderText = "操作用戶";
                this.dataGridView1.Columns[6].Width      = 80;
                this.dataGridView1.Columns[7].HeaderText = "創建時間";
                this.dataGridView1.Columns[7].Width      = 140;
                this.dataGridView1.Columns[8].HeaderText = "修改時間";
                this.dataGridView1.Columns[8].Width      = 140;
                this.dataGridView1.Columns[9].Visible    = false;
                this.dataGridView1.Columns[9].Width      = 0;
            }
        }
Beispiel #14
0
        public void loadResources(string custId, string delMatno, string boundType, string workno, string cusPo)
        {
            capacity = capacityService.queryByRelation(custId, delMatno, boundType);
            if (capacity != null)
            {
                this.countBoxQty(capacity.Capacityqty, workno, cusPo);
                //this.numericUpDown1.Value = getPrintCeiling(int.Parse(ctCodeInfo.Orderqty), int.Parse(ctCodeInfo.Woquantity));
                this.textBox16.Text   = capacity.Capacitydesc;
                this.textBox19.Text   = capacity.Capacityqty.ToString();
                ctCodeInfo.CapacityNo = capacity.Capacityno;
            }
            else
            {
                this.countBoxQty(1, workno, cusPo);
            }

            codeRule = codeRuleService.queryRuleByCond(custId, delMatno, boundType);  //1代表Carton碼編碼規則
            if (codeRule != null)
            {
                this.textBox15.Text = codeRule.RuleDesc;
                ctCodeInfo.Ruleno   = codeRule.Ruleno;
            }
            mandUnionFieldTypeList = manRelFieldTypeService.queryFieldListByCond(custId, delMatno, boundType);
            fileRelDel             = fileRelDelService.queryFileRelDelCusNo(custId, delMatno, boundType);
            //下載模板並預覽   1.查询模板是否存在, 若存在不下载  2.若不存在下载模板
            if (fileRelDel != null)
            {
                ctCodeInfo.Modelno = fileRelDel.FileNo;
                filePath           = modelInfoService.previewModelFile(fileRelDel.FileNo);
                if (filePath != null)
                {
                    string pictureFile = barPrint.PreviewPrintBC(filePath);
                    this.pictureBox1.Load(pictureFile);
                }
            }
        }
Beispiel #15
0
        /// <summary>
        /// 存储各码规则生成码
        /// </summary>
        public void CodesStore()
        {
            List <List <string> >            rulersResult = new List <List <string> >();
            List <string>                    allCode      = new List <string>();
            Dictionary <string, RuleProcess> ruleLastCode = new Dictionary <string, RuleProcess>();

            if (applyRuleProcessDict.Values.Where(s => s.Status < ApplyRuleStatus.Generated).Count() > 0)
            {
                throw new Exception($"码申请Id:{this.codeApply.ApplyId}存储码信息过程中,发现中各码规则未完成码申请。");
            }

            //    if (applyRuleProcessDict.Values.Where(s => s.Status != ApplyRuleStatus.Generated).Count() > 0)
            //{
            //    if (applyRuleProcessDict.Values.Where(s => s.Status == ApplyRuleStatus.Stored).Count() > 0)
            //    { }
            //    else
            //    {
            //        throw new Exception($"码申请Id:{this.codeApply.ApplyId}存储码信息过程中,发现中各码规则未完成码申请。");
            //    }

            //}
            if (applyRuleProcessDict.Values.Where(s => s.Status == ApplyRuleStatus.Generated).Count() > 0)
            {
                int outterFileCount = CodeDownloadFactory.Instance.GetOutterCodeFileCount(this.codeApply.ApplyId);//当前申请已存在的外码文件数量
                for (int i = 0; i < this.segRulers.Count; i++)
                {
                    if (applyRuleProcessDict[this.segRulers[i]].Status == ApplyRuleStatus.Generated)
                    {
                        byte[] originalCodeData;
                        #region 加载码规则最后码信息(序列码段序列位置)
                        RuleProcess ruleProcess = null;
                        if (ruleLastCode.ContainsKey(this.codeRules[i].CodeRuleId + "|" + this.ruleFeatureTags[this.segRulers[i]]))
                        {
                            ruleProcess = ruleLastCode[this.codeRules[i].CodeRuleId + "|" + this.ruleFeatureTags[this.segRulers[i]]];
                        }
                        else
                        {
                            ruleProcess = RuleProcessFactory.Instance.GetRuleProcess(this.codeRules[i].CodeRuleId, this.ruleFeatureTags[this.segRulers[i]]);
                            if (ruleProcess == null)
                            {
                                ruleProcess = new RuleProcess()
                                {
                                    CodeRuleId = this.codeRules[i].CodeRuleId, FeatureTag = this.ruleFeatureTags[this.segRulers[i]], LastCode = string.Empty
                                };
                                RuleProcessFactory.Instance.Add(ruleProcess);
                            }
                            ruleLastCode.Add(this.codeRules[i].CodeRuleId + "|" + this.ruleFeatureTags[this.segRulers[i]], ruleProcess);
                        }
                        if (ruleProcess.LastCode != null && ruleProcess.LastCode != "")
                        {
                            this.segRulers[i].LastCode = ruleProcess.LastCode;
                        }
                        #endregion
                        rulersResult.Add(this.segRulers[i].GetCodes(applyRuleProcessDict[this.segRulers[i]].AttributeInfo, this.codeApply.ApplyAmount * this.outerPackageRatios[i], out originalCodeData));
                        ruleProcess.LastCode = rulersResult[i][rulersResult[i].Count - 1];

                        if (originalCodeData != null && i >= outterFileCount)//判断有原始码数据且之前没有保存(内部码无原始码数据)
                        {
                            OutterCodeFileRecord outterFile = new OutterCodeFileRecord();
                            outterFile.ApplyId = codeApply.ApplyId;
                            outterFile.Content = originalCodeData;
                            CodeDownloadFactory.Instance.AddOutterCodeFiledRecord(outterFile);
                        }
                    }
                }
                if (this.segRulers.Count > 1)
                {
                    for (int i = 0; i < this.codeApply.ApplyAmount; i++)
                    {
                        for (int j = 0; j < this.segRulers.Count; j++)
                        {
                            for (int k = 0; k < this.outerPackageRatios[j]; k++)
                            {
                                allCode.Add(rulersResult[j][i * this.outerPackageRatios[j] + k]);
                            }
                        }
                    }
                }
                else
                {
                    allCode = rulersResult[0];
                }

                Dictionary <string, string> header = new Dictionary <string, string>();
                header.Add("ApplyId", this.codeApply.ApplyId.ToString());
                header.Add("CorpCode", this.codeApply.CorpCode);
                header.Add("UseCorpCode", this.codeApply.UseCorpCode);
                header.Add("Amount", allCode.Count.ToString());

                CodeRule LastRule = codeRules[codeRules.Count - 1];
                if (LastRule.CodeExtensions != "" || LastRule.CodeExtensions != null)
                {
                    header.Add("UrlFormat", LastRule.CodeExtensions.Split('{')[0]);
                }

                string codeFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));
                try
                {
                    using (StreamWriter sw = new StreamWriter(codeFileName, false, Encoding.UTF8))
                    {
                        sw.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(header));
                        foreach (string code in allCode)
                        {
                            //单行添加URL
                            if (LastRule.CodeArguments == "ADD")
                            {
                                sw.WriteLine(string.Format(LastRule.CodeExtensions, code));
                            }
                            else
                            {
                                sw.WriteLine(code);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    try
                    {
                        File.Delete(codeFileName);
                    }
                    catch { }
                    throw new Exception($"码申请Id:{ this.codeApply.ApplyId }存储码信息过程中,发生成存储临时码文件异常:{ex.Message}", ex);
                }
                finally
                {
                }
                string zipFileName = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N"));

                InnerCodeFileRecord record = new InnerCodeFileRecord();
                record.ApplyId = codeApply.ApplyId;

                try
                {
                    Tools.ZipFile(codeFileName, zipFileName);


                    using (FileStream fs = new FileStream(zipFileName, FileMode.Open))
                    {
                        byte[] contentBytes = new byte[fs.Length];
                        fs.Read(contentBytes, 0, (int)fs.Length);
                        record.Content = contentBytes;
                        //record.Content = Convert.ToBase64String(contentBytes);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception($"码申请Id:{ this.codeApply.ApplyId }存储码信息过程中,发生压缩码文件异常:{ex.Message}", ex);
                }
                finally
                {
                    try
                    {
                        File.Delete(codeFileName);
                        File.Delete(zipFileName);
                    }
                    catch { }
                }
                CodeDownloadFactory.Instance.AddInnerCodeFiledRecord(record);

                //更新申请码规则状态
                for (int i = 0; i < this.segRulers.Count; i++)
                {
                    if (applyRuleProcessDict[this.segRulers[i]].Status == ApplyRuleStatus.Generated)
                    {
                        applyRuleProcessDict[this.segRulers[i]].FirstCode = rulersResult[i][0];
                        applyRuleProcessDict[this.segRulers[i]].EndCode   = rulersResult[i][rulersResult[i].Count - 1];
                        applyRuleProcessDict[this.segRulers[i]].Status    = ApplyRuleStatus.Stored;
                        ApplyRuleProcessFactory.Instance.Update(applyRuleProcessDict[this.segRulers[i]]);
                    }
                }

                //更新码规则最后码状态信息
                foreach (RuleProcess process in ruleLastCode.Values)
                {
                    RuleProcessFactory.Instance.Update(process);
                }
            }
        }
Beispiel #16
0
        public static Carton generateCartonNo(Carton carton, CodeRule codeRule, DateTime currentTime)
        {
            StringBuilder cartonNo = new StringBuilder();

            if (codeRule != null)
            {
                foreach (RuleItem ruleItem in codeRule.RuleItem)
                {
                    int ruleInt = ruleItem.Rulelength;
                    switch (ruleItem.Ruletype)
                    {
                    case "T001":
                        string poOrWorkNo = "";
                        if (carton.Cuspo != null && carton.Cuspo != "")
                        {
                            poOrWorkNo = carton.Cuspo;
                        }
                        else
                        {
                            poOrWorkNo = carton.Workno;
                        }
                        cartonNo.Append(poOrWorkNo.Substring(0, ruleInt));
                        break;

                    case "T002":
                        cartonNo.Append(GenerateTimeCode(ruleInt, currentTime));
                        break;

                    case "T003":
                        cartonNo.Append(carton.Cusmatno.Trim().Substring(0, ruleInt));
                        break;

                    case "T004":
                        string assistT004 = carton.Offino.Trim().Substring(0, ruleInt);
                        cartonNo.Append(assistT004);
                        break;

                    //case "T005":
                    //    string assistT005 = "A10";
                    //    if (carton.Verno.Length > ruleInt)
                    //    {
                    //        assistT005 = carton.Verno.Trim().Substring(0, ruleInt);
                    //    }
                    //    cartonNo.Append(assistT005);
                    //    break;
                    case "T006":            //流水碼34進制
                        break;

                    case "T007":
                        cartonNo.Append(ruleItem.Rulevalue);
                        break;

                    case "T008":
                        string subOperation = extractString(carton.SoOrder, ruleInt);
                        cartonNo.Append(subOperation);
                        break;

                    case "T009":
                        //机种号3-7位
                        cartonNo.Append(carton.Delmatno.Substring(2, 5));
                        break;

                    case "T010":
                        cartonNo.Append(carton.ProdLineVal);
                        break;

                    case "T011":
                        //流水码十六进制
                        string maxCarton    = cartonService.getMaxCartonNo(cartonNo.ToString());
                        string prefixCarton = cartonNo.ToString();
                        if (maxCarton == null || maxCarton == "")
                        {
                            string seqCode = "1";
                            for (int numLength = seqCode.Length; numLength < Convert.ToInt32(ruleItem.Rulelength); numLength++)
                            {
                                seqCode = "0" + seqCode;
                            }
                            cartonNo.Append(seqCode);
                        }
                        else
                        {
                            //獲取流水號
                            string subCode      = maxCarton.Substring(prefixCarton.Length, Convert.ToInt32(ruleItem.Rulelength));
                            int    cartonSeq    = convert16CodeTo10(subCode);
                            string carton16Code = Convert16Code(cartonSeq + 1);
                            string seqNo        = "";
                            for (int i = carton16Code.Length; i < Convert.ToInt32(ruleItem.Rulelength); i++)
                            {
                                seqNo += 0;
                            }
                            carton16Code = seqNo + carton16Code;
                            cartonNo.Append(carton16Code);
                        }
                        break;

                    case "T012":
                        String prefix = cartonNo.ToString();
                        int    modNum = 0;
                        foreach (char result in prefix.ToCharArray())
                        {
                            string exchangeInt = result.ToString();
                            int    numExchange = inverseBase43Code[exchangeInt];
                            modNum += numExchange;
                        }
                        int    modReuslt = modNum % 43;
                        string modString = base43Code[modReuslt];
                        cartonNo.Append(modString);
                        break;

                    case "T013":                    //十進制流水碼
                        string maxCarton10    = cartonService.getMaxCartonNo(cartonNo.ToString());
                        string prefixCarton10 = cartonNo.ToString();
                        if (maxCarton10 == null || maxCarton10 == "")
                        {
                            string seqCode = "1";
                            for (int numLength = seqCode.Length; numLength < Convert.ToInt32(ruleItem.Rulelength); numLength++)
                            {
                                seqCode = "0" + seqCode;
                            }
                            cartonNo.Append(seqCode);
                        }
                        else
                        {
                            //獲取流水號
                            string subCode10    = maxCarton10.Substring(prefixCarton10.Length, Convert.ToInt32(ruleItem.Rulelength));
                            int    cartonSeq10  = int.Parse(subCode10);
                            string carton10Code = (cartonSeq10 + 1).ToString();
                            string seqNo        = "";
                            for (int i = carton10Code.Length; i < Convert.ToInt32(ruleItem.Rulelength); i++)
                            {
                                seqNo += 0;
                            }
                            carton10Code = seqNo + carton10Code;
                            cartonNo.Append(carton10Code);
                        }

                        break;

                    case "T015":                    //年月日進制表示
                        cartonNo.Append(getInsuprTime(currentTime));
                        break;

                    case "T016":                                                          //浪潮批次号
                        string woBatchNo  = woBatchService.getBatchNoByWO(carton.Workno); //查询工单批次号
                        string batchSeqNo = "1";
                        if (woBatchNo != null && !woBatchNo.Equals(""))
                        {
                            carton.BatchNo = woBatchNo;
                            cartonNo.Clear();
                            cartonNo.Append(woBatchNo);
                        }
                        else
                        {
                            string        queryCond = getInsuprTime(currentTime) + "Q";
                            List <String> batchNos  = woBatchService.queryBatchNos(queryCond);
                            if (batchNos != null && batchNos.Count > 0)
                            {
                                int maxNo = 0;
                                foreach (string batchNo in batchNos)
                                {
                                    int tempMathNo = InverseBase34Code[batchNo.Substring(batchNo.Length - 1, 1)];
                                    if (tempMathNo > maxNo)
                                    {
                                        maxNo = tempMathNo;
                                    }
                                }
                                batchSeqNo = Base34Code[maxNo + 1];
                            }
                            cartonNo.Append(batchSeqNo);
                            carton.BatchNo = cartonNo.ToString();
                            //保存工单批次
                            WoBatch woBatch = new WoBatch();
                            woBatch.BatchNo = carton.BatchNo;
                            woBatch.Workno  = carton.Workno;
                            woBatchService.saveWoBatch(woBatch);                        //占用工单批次
                        }
                        break;

                    case "T017":                    //批次号
                        string selfBatchNo = cartonService.queryBatchNoWorkNo(cartonNo.ToString(), carton.Workno);
                        string batchCustom = "1";
                        if (selfBatchNo != null)
                        {
                            batchCustom = selfBatchNo.Substring(cartonNo.Length, ruleItem.Rulelength);
                        }
                        else
                        {
                            selfBatchNo = cartonService.queryInspurMaxBoxNo(cartonNo.ToString(), carton.Cusno);
                            if (selfBatchNo != null)
                            {
                                string tempBatchNo = selfBatchNo.Substring(cartonNo.Length, ruleItem.Rulelength);
                                int    tempMathNo  = int.Parse(tempBatchNo);
                                batchCustom = (tempMathNo + 1).ToString();
                            }
                            string tempZero = "";
                            for (int i = batchCustom.Length; i < ruleItem.Rulelength; i++)
                            {
                                tempZero = 0 + tempZero;
                            }
                            batchCustom = tempZero + batchCustom;
                        }
                        cartonNo.Append(batchCustom);
                        carton.BatchNo = cartonNo.ToString();
                        break;

                    case "T018":                    //年月日進制表示
                        StringBuilder h3cTime       = new StringBuilder();
                        string        h3cYearString = currentTime.Year.ToString();
                        int           h3cYearInt    = int.Parse(h3cYearString.Substring(h3cYearString.Length - 2)); //獲取兩位年
                        int           h3cInt        = currentTime.Month;
                        string        h3cDD         = currentTime.ToString("dd");                                   //获得两位日
                        h3cTime.Append(h3cYearInt);
                        h3cTime.Append(Base33Code[h3cInt]);
                        h3cTime.Append(h3cDD);
                        cartonNo.Append(h3cTime.ToString());

                        break;

                    case "T019":                    //工单十进制流水
                        string maxCartonWO    = cartonService.getMaxCartonNoByWO(carton.Workno);
                        string prefixCartonWO = cartonNo.ToString();
                        if (maxCartonWO == null || maxCartonWO == "")
                        {
                            string seqCode = "1";
                            for (int numLength = seqCode.Length; numLength < ruleItem.Rulelength; numLength++)
                            {
                                seqCode = "0" + seqCode;
                            }
                            cartonNo.Append(seqCode);
                        }
                        else
                        {
                            //獲取流水號
                            string subCode10    = maxCartonWO.Substring(prefixCartonWO.Length, ruleItem.Rulelength);
                            int    cartonSeq10  = int.Parse(subCode10);
                            string carton10Code = (cartonSeq10 + 1).ToString();
                            string seqNo        = "";
                            for (int i = carton10Code.Length; i < ruleItem.Rulelength; i++)
                            {
                                seqNo += 0;
                            }
                            carton10Code = seqNo + carton10Code;
                            cartonNo.Append(carton10Code);
                        }
                        break;

                    case "T020":
                        string extractResult = extractString(carton.Woquantity, ruleInt);
                        cartonNo.Append(extractResult);
                        break;

                    case "T021":
                        cartonNo.Append(carton.Ct1);
                        break;

                    case "T022":                                                // 顺达标准-流水号
                        string maxBoxNo       = cartonService.getMaxCartonNo("103100");
                        string prefixCartonNo = cartonNo.ToString();
                        if (maxBoxNo == null || maxBoxNo == "")
                        {
                            string seqCode = "1";
                            for (int numLength = seqCode.Length; numLength < Convert.ToInt32(ruleItem.Rulelength); numLength++)
                            {
                                seqCode = "0" + seqCode;
                            }
                            cartonNo.Append(seqCode);
                        }
                        else
                        {
                            //獲取流水號
                            string subCode10    = maxBoxNo.Substring(prefixCartonNo.Length, Convert.ToInt32(ruleItem.Rulelength));
                            int    cartonSeq10  = int.Parse(subCode10);
                            string carton10Code = (cartonSeq10 + 1).ToString();
                            string seqNo        = "";
                            for (int i = carton10Code.Length; i < Convert.ToInt32(ruleItem.Rulelength); i++)
                            {
                                seqNo += 0;
                            }
                            carton10Code = seqNo + carton10Code;
                            cartonNo.Append(carton10Code);
                        }
                        break;
                    }
                }
            }
            carton.CartonNo = cartonNo.ToString();
            return(carton);
        }
Beispiel #17
0
        public static String gennerateQualityNo(string ruleNo)
        {
            StringBuilder qualityNo = new StringBuilder();
            CodeRule      codeRule  = codeRuleService.queryRuleById(ruleNo);

            if (codeRule != null)
            {
                foreach (RuleItem ruleItem in codeRule.RuleItem)
                {
                    int ruleInt = ruleItem.Rulelength;
                    switch (ruleItem.Ruletype)
                    {
                    case "T001":

                        break;

                    case "T002":
                        qualityNo.Append(GenerateTimeCode(ruleInt));
                        break;

                    case "T003":

                        break;

                    case "T004":
                        break;

                    case "T005":
                        break;

                    case "T006":            //流水碼34進制
                        break;

                    case "T007":
                        qualityNo.Append(ruleItem.Rulevalue);
                        break;

                    case "T008":
                        break;

                    case "T009":
                        //机种号3-7位
                        break;

                    case "T010":
                        break;

                    case "T011":
                        //流水码十六进制
                        string maxQualityNo    = qualityInfoService.queryMaxQualityNo(qualityNo.ToString());
                        string prefixQualityNo = qualityNo.ToString();
                        if (maxQualityNo == null || maxQualityNo == "")
                        {
                            string seqCode = "1";
                            for (int numLength = seqCode.Length; numLength < Convert.ToInt32(ruleItem.Rulelength); numLength++)
                            {
                                seqCode = "0" + seqCode;
                            }
                            qualityNo.Append(seqCode);
                        }
                        else
                        {
                            //獲取流水號
                            string subCode       = maxQualityNo.Substring(prefixQualityNo.Length, Convert.ToInt32(ruleItem.Rulelength));
                            int    qualitySeq    = convert16CodeTo10(subCode);
                            string quality16Code = Convert16Code(qualitySeq + 1);
                            string seqNo         = "";
                            for (int i = quality16Code.Length; i < Convert.ToInt32(ruleItem.Rulelength); i++)
                            {
                                seqNo += 0;
                            }
                            quality16Code = seqNo + quality16Code;
                            qualityNo.Append(quality16Code);
                        }
                        break;

                    case "T012":                    //43码
                        String prefix = qualityNo.ToString();
                        int    modNum = 0;
                        foreach (char result in prefix.ToCharArray())
                        {
                            string exchangeInt = result.ToString();
                            int    numExchange = inverseBase43Code[exchangeInt];
                            modNum += numExchange;
                        }
                        int    modReuslt = modNum % 43;
                        string modString = base43Code[modReuslt];
                        qualityNo.Append(modString);
                        break;

                    case "T013":                    //十進制流水碼
                        string maxQuality10    = qualityInfoService.queryMaxQualityNo(qualityNo.ToString());
                        string prefixQuality10 = qualityNo.ToString();
                        if (maxQuality10 == null || maxQuality10 == "")
                        {
                            string seqCode = "1";
                            for (int numLength = seqCode.Length; numLength < Convert.ToInt32(ruleItem.Rulelength); numLength++)
                            {
                                seqCode = "0" + seqCode;
                            }
                            qualityNo.Append(seqCode);
                        }
                        else
                        {
                            //獲取流水號
                            string subCode10     = maxQuality10.Substring(prefixQuality10.Length, Convert.ToInt32(ruleItem.Rulelength));
                            int    qualitySeq10  = int.Parse(subCode10);
                            string quality10Code = (qualitySeq10 + 1).ToString();
                            string seqNo         = "";
                            for (int i = quality10Code.Length; i < Convert.ToInt32(ruleItem.Rulelength); i++)
                            {
                                seqNo += 0;
                            }
                            quality10Code = seqNo + quality10Code;
                            qualityNo.Append(quality10Code);
                        }

                        break;

                    case "T015":                    //年月日進制表示
                        qualityNo.Append(getInsuprTime());
                        break;

                    case "T016":                            //浪潮批次号
                        break;

                    case "T017":                    //批次号
                        break;

                    case "T018":                    //年月日進制表示
                        StringBuilder h3cTime       = new StringBuilder();
                        string        h3cYearString = DateTime.Now.Year.ToString();
                        int           h3cYearInt    = int.Parse(h3cYearString.Substring(h3cYearString.Length - 2)); //獲取兩位年
                        int           h3cInt        = DateTime.Now.Month;
                        string        h3cDD         = DateTime.Now.ToString("dd");                                  //获得两位日
                        h3cTime.Append(h3cYearInt);
                        h3cTime.Append(Base33Code[h3cInt]);
                        h3cTime.Append(h3cDD);
                        qualityNo.Append(h3cTime.ToString());

                        break;

                    case "T019":                    //工单十进制流水
                        break;

                    case "T020":

                        break;
                    }
                }
            }
            return(qualityNo.ToString());
        }
Beispiel #18
0
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                if (this.textBox1.Text == null || this.textBox1.Text.Trim() == "")
                {
                    this.textBox1.Focus();
                    return;
                }
                Carton carton = cartonService.queryCartonByCartonNo(this.textBox1.Text.Trim());
                if (carton != null)
                {
                    if (!carton.CartonStatus.Equals("0"))
                    {
                        MessageBox.Show("該裝箱單碼已綁定,請檢查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        this.textBox1.Text = "";
                        this.textBox1.Focus();
                        return;
                    }
                    if (this.dataGridView1.Rows.Count == 0)
                    {
                        // 1.檢查是否綁定棧板模板
                        fileRelDel = fileRelDelService.queryFileRelDelCusNo(carton.Cusno, carton.Delmatno, "2");
                        if (fileRelDel == null)
                        {
                            MessageBox.Show("請聯繫管理員綁定標籤模板!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.textBox1.Text = "";
                            this.textBox1.Focus();
                            CommonAuxiliary.playFail();
                            return;
                        }
                        //2. 檢查是否綁定編碼規則
                        codeRule = codeRuleService.queryRuleByCond(carton.Cusno, carton.Delmatno, "2");                 //2代表Pallet碼編碼規則
                        if (codeRule == null)
                        {
                            MessageBox.Show("請聯繫管理員綁定編碼規則!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.textBox1.Text = "";
                            this.textBox1.Focus();
                            CommonAuxiliary.playFail();
                            return;
                        }
                        //3.查询标签参数信息
                        mandUnionFieldTypeList = manRelFieldTypeService.queryFieldListByCond(carton.Cusno, carton.Delmatno, "2");
                        if (mandUnionFieldTypeList == null)
                        {
                            MessageBox.Show("未找到該客戶出貨料號對應的打印字段規則信息,請維護相關信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.textBox1.Text = "";
                            this.textBox1.Focus();
                            CommonAuxiliary.playFail();
                            return;
                        }
                        //4.查询标准栈板容量
                        capacity = capacityService.queryByRelation(carton.Cusno, carton.Delmatno, "2");
                        pallet   = new Pallet();
                        if (capacity != null)
                        {
                            pallet.CapacityNo   = capacity.Capacityno;
                            this.textBox12.Text = capacity.Capacitydesc;
                            this.textBox14.Text = capacity.Capacityqty.ToString();
                        }
                        firstCarton        = carton;
                        this.textBox2.Text = carton.Workno;
                        initRow(carton);
                        //初始化信息
                        this.textBox3.Text = this.dataGridView1.Rows.Count.ToString();
                        this.textBox4.Text = firstCarton.Woquantity;
                        //根據工單號查詢已裝箱數量;
                        this.textBox6.Text  = firstCarton.Cusname;
                        this.textBox7.Text  = firstCarton.Cusno;
                        this.textBox8.Text  = firstCarton.Delmatno;
                        this.textBox9.Text  = firstCarton.Cusmatno;
                        this.textBox15.Text = firstCarton.Cuspo;
                        this.textBox5.Text  = carton.CartonQty.ToString();
                        this.textBox13.Text = codeRule.RuleDesc;

                        //下载打印模板 並初始化Carton 基本信息

                        pallet.Workno   = firstCarton.Workno;
                        pallet.Delmatno = firstCarton.Delmatno;                             //浪潮默認規則 編號R007         棧板規則使用默認編碼規則
                        pallet.Cusmatno = firstCarton.Cusmatno;
                        pallet.Cuspo    = firstCarton.Cuspo;
                        pallet.Cusname  = firstCarton.Cusname;
                        pallet.SoOrder  = firstCarton.SoOrder;
                        pallet.Cusno    = firstCarton.Cusno;
                        pallet.Modelno  = fileRelDel.FileNo;
                        pallet.Ruleno   = codeRule.Ruleno;

                        //pallet = GeneratePallet.generatePalletNo(pallet);
                        ////顯示棧板號:
                        //this.textBox10.Text = pallet.PalletNo;
                        //this.textBox11.Text = pallet.BatchNo;
                        //下載模板並預覽   1.查询模板是否存在, 若存在不下载  2.若不存在下载模板
                        filePath = modelInfoService.previewModelFile(pallet.Modelno);
                        //if (filePath != null)
                        //{
                        //    string pictureFile = barPrint.PreviewPrintBC(filePath);
                        //    this.pictureBox1.Load(pictureFile);
                        //}
                        CommonAuxiliary.playSuccess();
                    }
                    else
                    {
                        //第二箱掃描  檢查是否混棧板,同工單,檢查箱號是否同工單號
                        if (("1").Equals(this.comboBox1.SelectedValue.ToString()))
                        {
                            if (carton.Workno.Trim().Equals(this.firstCarton.Workno.Trim()))
                            {
                                if (!checkRepeat(carton.CartonNo))
                                {
                                    initRow(carton);
                                    this.textBox3.Text = this.dataGridView1.Rows.Count.ToString();
                                    this.textBox5.Text = countQty(cartonList).ToString();
                                    CommonAuxiliary.playSuccess();
                                }
                                else
                                {
                                    this.textBox1.Text = "";
                                    this.textBox1.Focus();
                                    CommonAuxiliary.playFail();
                                    return;
                                }
                            }
                            else
                            {
                                MessageBox.Show("装箱单的工单号不同,请检查是否需要混栈板包装!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                this.textBox1.Text = "";
                                this.textBox1.Focus();
                                CommonAuxiliary.playFail();
                                return;
                            }
                        }
                        else
                        {
                            //混棧板  只檢查箱號是否重複
                            if (!checkRepeat(carton.CartonNo))
                            {
                                initRow(carton);
                                this.textBox3.Text = this.dataGridView1.Rows.Count.ToString();
                                this.textBox5.Text = countQty(cartonList).ToString();
                                CommonAuxiliary.playSuccess();
                            }
                            else
                            {
                                this.textBox1.Text = "";
                                this.textBox1.Focus();
                                CommonAuxiliary.playFail();
                                return;
                            }
                        }
                    }
                    //判斷是否混棧板.
                    if (("1").Equals(this.comboBox1.SelectedValue.ToString()))
                    {
                        if (capacity != null)
                        {
                            //扫码数量等于容量时打印标签
                            if (this.dataGridView1.Rows.Count == capacity.Capacityqty)
                            {
                                printCarton();
                            }
                        }
                        else
                        {
                            if (this.dataGridView1.Rows.Count == 100)
                            {
                                printCarton();
                            }
                        }
                    }
                }
                else
                {
                    this.textBox1.Text = "";
                }
            }
        }
 public int Add(CodeRule info)
 {
     info.CreatedTime = info.ModifiedTime = DateTime.Now;
     dbContext.Insert(info);
     return(info.CodeRuleId);
 }
Beispiel #20
0
 private void textBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (this.textBox1.Text == null || this.textBox1.Text.Trim() == "")
         {
             this.textBox1.Focus();
             return;
         }
         CTCode ctcode = ctCodeService.queryCTCodeByCtcode(this.textBox1.Text.Trim());
         if (ctcode == null)
         {
             this.textBox1.Text = "";
             this.textBox1.Focus();
             CommonAuxiliary.playFail();
             return;
         }
         if (cartonService.exists(ctcode.Ctcode))
         {
             MessageBox.Show("該CT碼已綁定,請檢查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.textBox1.Text = "";
             this.textBox1.Focus();
             CommonAuxiliary.playFail();
             return;
         }
         if (this.dataGridView1.Rows.Count == 0)
         {
             if (firstScan == null || !(firstScan.Workno.Equals(ctcode.Workno) && firstScan.Delmatno.Equals(ctcode.Delmatno) && firstScan.Cusno.Equals(ctcode.Cusno)))
             {
                 codeRule = codeRuleService.queryRuleByCond(ctcode.Cusno, ctcode.Delmatno, "1");  //1代表Carton碼編碼規則
                 if (codeRule == null)
                 {
                     MessageBox.Show("请联系管理员,绑定装箱单编码规则!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.textBox1.Text = "";
                     this.textBox1.Focus();
                     CommonAuxiliary.playFail();
                     return;
                 }
                 //查询标签模板
                 fileRelDel = fileRelDelService.queryFileRelDelCusNo(ctcode.Cusno, ctcode.Delmatno, "1");
                 if (fileRelDel == null)
                 {
                     MessageBox.Show("请联系管理员,绑定标签模板!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.textBox1.Text = "";
                     this.textBox1.Focus();
                     CommonAuxiliary.playFail();
                     return;
                 }
                 //查询标签参数信息
                 mandUnionFieldTypeList = manRelFieldTypeService.queryFieldListByCond(ctcode.Cusno, ctcode.Delmatno, "1");
                 if (mandUnionFieldTypeList == null)
                 {
                     MessageBox.Show("未找到該客戶出貨料號對應的打印字段規則信息,請維護相關信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.textBox1.Text = "";
                     this.textBox1.Focus();
                     CommonAuxiliary.playFail();
                     return;
                 }
                 //裝箱容量查詢
                 capacity = capacityService.queryByRelation(ctcode.Cusno, ctcode.Delmatno, "1");
                 if (capacity != null)
                 {
                     this.textBox11.Text = capacity.Capacityqty.ToString();
                     this.textBox12.Text = capacity.Capacitydesc;
                 }
                 firstScan = ctcode;
                 //下載模板並預覽   1.查询模板是否存在, 若存在不下载  2.若不存在下载模板
                 filePath = modelInfoService.previewModelFile(fileRelDel.FileNo);
             }
             firstScan = ctcode;
             initRow(ctcode);
             //初始化信息
             this.textBox2.Text = ctcode.Workno;
             this.textBox4.Text = ctcode.Woquantity;
             //根據工單號查詢已裝箱數量;
             this.textBox6.Text  = ctcode.Cusname;
             this.textBox7.Text  = ctcode.Cusno;
             this.textBox8.Text  = ctcode.Delmatno;
             this.textBox9.Text  = ctcode.Cusmatno;
             this.textBox13.Text = codeRule.RuleDesc;
             this.textBox5.Text  = cartonService.getCartonQtyByWO(ctcode.Workno);
             this.textBox14.Text = ctcode.Quantity.ToString();
             this.textBox3.Text  = this.dataGridView1.Rows.Count.ToString();
             this.label18.Text   = this.dataGridView1.Rows.Count.ToString();
             CommonAuxiliary.playSuccess();
             //if (filePath != null)
             //{
             //    string pictureFile = barPrint.PreviewPrintBC(filePath);
             //    this.pictureBox1.Load(pictureFile);
             //}
         }
         else
         {
             // 判断当前条码出货料号和工单以及客户编号是否一致
             if (ctcode.Workno.Trim().Equals(firstScan.Workno.Trim()) && ctcode.Delmatno.Equals(firstScan.Delmatno) && ctcode.Cusno.Equals(firstScan.Cusno))
             {
                 if (!checkRepeat(ctcode.Ctcode))
                 {
                     initRow(ctcode);
                     this.textBox3.Text  = this.dataGridView1.Rows.Count.ToString();
                     this.label18.Text   = this.dataGridView1.Rows.Count.ToString();
                     this.textBox14.Text = countQty(ctCodeList).ToString();
                     CommonAuxiliary.playSuccess();
                 }
                 else
                 {
                     this.textBox1.Text = "";
                     this.textBox1.Focus();
                     CommonAuxiliary.playFail();
                 }
             }
             else
             {
                 MessageBox.Show("底座条码工单/客户编号不一致,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.textBox1.Text = "";
                 this.textBox1.Focus();
                 CommonAuxiliary.playFail();
                 return;
             }
         }
         if (capacity != null)
         {
             //扫码包装数量等于容量时打印标签
             if (countQty(ctCodeList) == capacity.Capacityqty)
             {
                 printCarton();
             }
         }
     }
 }
Beispiel #21
0
        public static Pallet generatePalletNo(Pallet pallet, CodeRule codeRule)
        {
            StringBuilder palletNo = new StringBuilder();

            if (codeRule != null)
            {
                foreach (RuleItem ruleItem in codeRule.RuleItem)
                {
                    int ruleInt = ruleItem.Rulelength;
                    switch (ruleItem.Ruletype)
                    {
                    case "T001":
                        string poOrWorkNo = "";
                        if (pallet.Cuspo != null && pallet.Cuspo != "")
                        {
                            poOrWorkNo = pallet.Cuspo;
                        }
                        else
                        {
                            poOrWorkNo = pallet.Workno;
                        }
                        palletNo.Append(poOrWorkNo.Substring(0, ruleInt));
                        break;

                    case "T002":
                        palletNo.Append(GenerateTimeCode(ruleInt));
                        break;

                    case "T003":
                        palletNo.Append(pallet.Cusmatno.Trim().Substring(0, ruleInt));
                        break;

                    case "T004":
                        break;

                    case "T005":
                        break;

                    case "T006":            //流水碼34進制
                        break;

                    case "T007":
                        palletNo.Append(ruleItem.Rulevalue);
                        break;

                    case "T008":
                        string subOperation = extractString(pallet.SoOrder, ruleInt);
                        palletNo.Append(subOperation);
                        break;

                    case "T009":
                        //机种号3-7位
                        palletNo.Append(pallet.Delmatno.Substring(2, 5));
                        break;

                    case "T010":
                        break;

                    case "T011":
                        //流水码十六进制
                        string maxPallet    = palletService.queryMaxPalletNo(palletNo.ToString());
                        string prefixPallet = palletNo.ToString();
                        if (maxPallet == null || maxPallet == "")
                        {
                            string seqCode = "1";
                            for (int numLength = seqCode.Length; numLength < Convert.ToInt32(ruleItem.Rulelength); numLength++)
                            {
                                seqCode = "0" + seqCode;
                            }
                            palletNo.Append(seqCode);
                        }
                        else
                        {
                            //獲取流水號
                            string subCode      = maxPallet.Substring(prefixPallet.Length, Convert.ToInt32(ruleItem.Rulelength));
                            int    palletSeq    = convert16CodeTo10(subCode);
                            string pallet16Code = Convert16Code(palletSeq + 1);
                            string seqNo        = "";
                            for (int i = pallet16Code.Length; i < Convert.ToInt32(ruleItem.Rulelength); i++)
                            {
                                seqNo += 0;
                            }
                            pallet16Code = seqNo + pallet16Code;
                            palletNo.Append(pallet16Code);
                        }
                        break;

                    case "T012":
                        String prefix = palletNo.ToString();
                        int    modNum = 0;
                        foreach (char result in prefix.ToCharArray())
                        {
                            string exchangeInt = result.ToString();
                            int    numExchange = inverseBase43Code[exchangeInt];
                            modNum += numExchange;
                        }
                        int    modReuslt = modNum % 43;
                        string modString = base43Code[modReuslt];
                        palletNo.Append(modString);
                        break;

                    case "T013":                    //十進制流水碼
                        string maxPallet10    = palletService.queryMaxPalletNo(palletNo.ToString());
                        string prefixPallet10 = palletNo.ToString();
                        if (maxPallet10 == null || maxPallet10 == "")
                        {
                            string seqCode = "1";
                            for (int numLength = seqCode.Length; numLength < Convert.ToInt32(ruleItem.Rulelength); numLength++)
                            {
                                seqCode = "0" + seqCode;
                            }
                            palletNo.Append(seqCode);
                        }
                        else
                        {
                            //獲取流水號
                            string subCode10    = maxPallet10.Substring(prefixPallet10.Length, Convert.ToInt32(ruleItem.Rulelength));
                            int    palletSeq10  = int.Parse(subCode10);
                            string pallet10Code = (palletSeq10 + 1).ToString();
                            string seqNo        = "";
                            for (int i = pallet10Code.Length; i < Convert.ToInt32(ruleItem.Rulelength); i++)
                            {
                                seqNo += 0;
                            }
                            pallet10Code = seqNo + pallet10Code;
                            palletNo.Append(pallet10Code);
                        }

                        break;

                    case "T015":                    //年月日進制表示
                        palletNo.Append(getInsuprTime());
                        break;

                    case "T016":                            //浪潮批次号


                        string woBatchNo  = woBatchService.getBatchNoByWO(pallet.Workno);               //查询工单批次号
                        string batchSeqNo = "1";
                        if (woBatchNo != null && !woBatchNo.Equals(""))
                        {
                            pallet.BatchNo = woBatchNo;
                            palletNo.Clear();
                            palletNo.Append(woBatchNo);
                        }
                        else
                        {
                            string        queryCond = getInsuprTime() + "Q";
                            List <String> batchNos  = woBatchService.queryBatchNos(queryCond);
                            if (batchNos != null && batchNos.Count > 0)
                            {
                                int maxNo = 0;
                                foreach (string batchNo in batchNos)
                                {
                                    int tempMathNo = InverseBase34Code[batchNo.Substring(batchNo.Length - 1, 1)];
                                    if (tempMathNo > maxNo)
                                    {
                                        maxNo = tempMathNo;
                                    }
                                }
                                batchSeqNo = Base34Code[maxNo + 1];
                            }
                            palletNo.Append(batchSeqNo);
                            pallet.BatchNo = palletNo.ToString();
                            //保存工单批次
                            WoBatch woBatch = new WoBatch();
                            woBatch.BatchNo = pallet.BatchNo;
                            woBatch.Workno  = pallet.Workno;
                            woBatchService.saveWoBatch(woBatch);                        //占用工单批次
                        }
                        break;

                    case "T017":                    //批次号
                        //string selfBatchNo = cartonService.queryBatchNoWorkNo(cartonNo.ToString(), carton.Workno);
                        //string batchCustom = "1";
                        //if (selfBatchNo != null)
                        //{
                        //    batchCustom = selfBatchNo.Substring(cartonNo.Length, ruleItem.Rulelength);
                        //}
                        //else
                        //{
                        //    selfBatchNo = cartonService.queryInspurMaxBoxNo(cartonNo.ToString(), carton.Cusno);
                        //    if (selfBatchNo != null)
                        //    {
                        //        string tempBatchNo = selfBatchNo.Substring(cartonNo.Length, ruleItem.Rulelength);
                        //        int tempMathNo = int.Parse(tempBatchNo);
                        //        batchCustom = (tempMathNo + 1).ToString();
                        //    }
                        //    string tempZero = "";
                        //    for (int i = batchCustom.Length; i < ruleItem.Rulelength; i++)
                        //    {
                        //        tempZero = 0 + tempZero;
                        //    }
                        //    batchCustom = tempZero + batchCustom;
                        //}
                        //cartonNo.Append(batchCustom);
                        //carton.BatchNo = cartonNo.ToString();
                        break;

                    case "T018":                    //年月日進制表示
                        StringBuilder h3cTime       = new StringBuilder();
                        string        h3cYearString = DateTime.Now.Year.ToString();
                        int           h3cYearInt    = int.Parse(h3cYearString.Substring(h3cYearString.Length - 2)); //獲取兩位年
                        int           h3cInt        = DateTime.Now.Month;
                        string        h3cDD         = DateTime.Now.ToString("dd");                                  //获得两位日
                        h3cTime.Append(h3cYearInt);
                        h3cTime.Append(Base33Code[h3cInt]);
                        h3cTime.Append(h3cDD);
                        //             ctCode.Append(inspurTime.ToString());
                        palletNo.Append(h3cTime.ToString());

                        break;

                    case "T019":                    //工单十进制流水
                    case "T020":

                        break;
                    }
                }
            }
            pallet.PalletNo = palletNo.ToString();
            return(pallet);
        }
Beispiel #22
0
        public List <CTCode> generateCTNumber(CTCode ctCodeInfo, int printQty, DateTime currentTime)
        {
            bool          judgeSerial = false;                                      //判断是否需要流水号
            List <CTCode> listCode    = new List <CTCode>();
            StringBuilder ctCode      = new StringBuilder();
            CodeRule      codeRule    = codeRuleService.queryRuleById(ctCodeInfo.Ruleno);

            if (codeRule != null)
            {
                foreach (RuleItem ruleItem in codeRule.RuleItem)
                {
                    int ruleInt = ruleItem.Rulelength;
                    switch (ruleItem.Ruletype)
                    {
                    case "T001":
                        string poOrWorkNo = "";
                        if (ctCodeInfo.Cuspo != null && ctCodeInfo.Cuspo != "")
                        {
                            poOrWorkNo = ctCodeInfo.Cuspo;
                        }
                        else
                        {
                            poOrWorkNo = ctCodeInfo.Workno;
                        }
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + poOrWorkNo.Substring(0, ruleInt);
                            }
                        }
                        else
                        {
                            ctCode.Append(poOrWorkNo.Substring(0, ruleInt));
                        }
                        break;

                    case "T002":
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + GenerateTimeCode(ruleInt, currentTime);
                            }
                        }
                        else
                        {
                            ctCode.Append(GenerateTimeCode(ruleInt, currentTime));
                        }
                        break;

                    case "T003":
                        string assistStr = "";
                        if (ctCodeInfo.Cusmatno.Length > ruleInt)
                        {
                            assistStr = ctCodeInfo.Cusmatno.Trim().Substring(0, ruleInt);
                        }
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + assistStr;
                            }
                        }
                        else
                        {
                            ctCode.Append(assistStr);
                        }
                        break;

                    case "T004":
                        if (ctCodeInfo.Offino.Trim().Length > ruleInt)
                        {
                            string assistT004 = ctCodeInfo.Offino.Trim().Substring(0, ruleInt);

                            if (listCode.Count > 1)
                            {
                                for (int i = 0; i < listCode.Count; i++)
                                {
                                    listCode[i].Ctcode = listCode[i].Ctcode + assistT004;
                                }
                            }
                            else
                            {
                                ctCode.Append(assistT004);
                            }
                        }
                        else
                        {
                            if (listCode.Count > 1)
                            {
                                for (int i = 0; i < listCode.Count; i++)
                                {
                                    listCode[i].Ctcode = listCode[i].Ctcode + ctCodeInfo.Offino.Trim();
                                }
                            }
                            else
                            {
                                ctCode.Append(ctCodeInfo.Offino.Trim());
                            }
                        }
                        break;

                    case "T005":
                        string assistT005 = "";
                        if (ctCodeInfo.Verno.Length > ruleInt)
                        {
                            assistT005 = ctCodeInfo.Verno.Trim().Substring(0, ruleInt);
                        }

                        if (listCode.Count >= 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + assistT005;
                            }
                        }
                        else
                        {
                            ctCode.Append(assistT005);
                        }
                        break;

                    case "T006":
                        judgeSerial = true;
                        string maxCode  = printM.getMaxCTCode(ctCode.ToString());
                        string prefixCT = ctCode.ToString();
                        if (maxCode == null || maxCode == "")
                        {
                            for (int i = 1; i <= printQty; i++)
                            {
                                CTCode ctCodeIn = new CTCode();
                                ctCodeIn = exchangeCT(ctCodeIn, ctCodeInfo);
                                string seqNo   = "";
                                string tempCT  = "";
                                string seqCode = Convert34Code(i);
                                for (int numLength = seqCode.Length; numLength < ruleInt; numLength++)
                                {
                                    seqNo += "0";
                                }
                                seqNo          += seqCode;
                                tempCT          = prefixCT + seqNo;
                                ctCodeIn.Ctcode = tempCT;
                                listCode.Add(ctCodeIn);
                            }
                            if (printQty == 1)
                            {
                                ctCode.Clear();
                                ctCode.Append(listCode[0].Ctcode);
                            }
                        }
                        else
                        {
                            //獲取流水號
                            string subCode = maxCode.Substring(ctCode.Length, ruleInt);
                            int    ctNo    = convert34CodeTo10(subCode);
                            for (int i = 0; i < printQty; i++)
                            {
                                CTCode ctCodeIn = new CTCode();
                                ctCodeIn = exchangeCT(ctCodeIn, ctCodeInfo);
                                ctNo++;
                                string ct34Code = Convert34Code(ctNo);
                                string temStr   = "";
                                string tempCT   = "";
                                for (int j = ct34Code.Length; j < ruleInt; j++)
                                {
                                    temStr += 0;
                                }
                                ct34Code        = temStr + ct34Code;
                                tempCT          = prefixCT + ct34Code;
                                ctCodeIn.Ctcode = tempCT;
                                listCode.Add(ctCodeIn);
                            }
                            if (printQty == 1)
                            {
                                ctCode.Clear();
                                ctCode.Append(listCode[0].Ctcode);
                            }
                        }
                        break;

                    case "T007":
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + ruleItem.Rulevalue;
                            }
                        }
                        else
                        {
                            ctCode.Append(ruleItem.Rulevalue);
                        }
                        break;

                    case "T008":
                        string subOperation = this.extractString(ctCodeInfo.SoOrder, ruleInt);
                        //ctCode.Append(subOperation);
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + subOperation;
                            }
                        }
                        else
                        {
                            ctCode.Append(subOperation);
                        }
                        break;

                    case "T013":                    //十進制流水碼
                        judgeSerial = true;
                        string maxTenCode  = printM.getMaxCTCode(ctCode.ToString());
                        string prefixTenCT = ctCode.ToString();
                        if (maxTenCode == null || maxTenCode == "")
                        {
                            for (int i = 1; i <= printQty; i++)
                            {
                                CTCode ctCodeIn = new CTCode();
                                ctCodeIn = exchangeCT(ctCodeIn, ctCodeInfo);
                                string seqNo   = "";
                                string tempCT  = "";
                                string seqCode = i.ToString();
                                for (int numLength = seqCode.Length; numLength < ruleInt; numLength++)
                                {
                                    seqNo += "0";
                                }
                                seqNo          += seqCode;
                                tempCT          = prefixTenCT + seqNo;
                                ctCodeIn.Ctcode = tempCT;
                                listCode.Add(ctCodeIn);
                            }
                            if (printQty == 1)
                            {
                                ctCode.Clear();
                                ctCode.Append(listCode[0].Ctcode);
                            }
                        }
                        else
                        {
                            //獲取流水號
                            string subCode = maxTenCode.Substring(ctCode.Length, ruleInt);
                            int    ctNo    = int.Parse(subCode);
                            for (int i = 0; i < printQty; i++)
                            {
                                CTCode ctCodeIn = new CTCode();
                                ctCodeIn = exchangeCT(ctCodeIn, ctCodeInfo);
                                ctNo++;
                                string ct34Code = ctNo.ToString();
                                string temStr   = "";
                                string tempCT   = "";
                                for (int j = ct34Code.Length; j < ruleInt; j++)
                                {
                                    temStr += 0;
                                }
                                ct34Code        = temStr + ct34Code;
                                tempCT          = prefixTenCT + ct34Code;
                                ctCodeIn.Ctcode = tempCT;
                                listCode.Add(ctCodeIn);
                            }
                            if (printQty == 1)
                            {
                                ctCode.Clear();
                                ctCode.Append(listCode[0].Ctcode);
                            }
                        }
                        break;

                    case "T014":                    //年月日進制表示
                        StringBuilder timeString = new StringBuilder();
                        string        yearString = currentTime.Year.ToString();
                        int           yearInt    = int.Parse(yearString.Substring(yearString.Length - 2)); //獲取兩位年
                        int           monthInt   = currentTime.Month;
                        int           dayInt     = currentTime.Day;
                        timeString.Append(Base31Code[yearInt]);
                        timeString.Append(Base31Code[monthInt]);
                        timeString.Append(Base31Code[dayInt]);
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + timeString.ToString();
                            }
                        }
                        else
                        {
                            ctCode.Append(timeString.ToString());
                        }
                        break;

                    case "T015":                    //浪潮年月日進制表示
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + getInsuprTime();
                            }
                        }
                        else
                        {
                            ctCode.Append(getInsuprTime());
                        }
                        break;

                    case "T016":                                                              //浪潮批次号
                        string woBatchNo  = woBatchService.getBatchNoByWO(ctCodeInfo.Workno); //查询工单批次号
                        string batchSeqNo = "1";
                        if (woBatchNo == null || woBatchNo.Equals(""))
                        {
                            string        queryCond = getInsuprTime() + "Q";
                            List <String> batchNos  = woBatchService.queryBatchNos(queryCond);
                            if (batchNos != null && batchNos.Count > 0)
                            {
                                int maxNo = 0;
                                foreach (string batch in batchNos)
                                {
                                    int tempMathNo = InverseBase34Code[batch.Substring(batch.Length - 1, 1)];
                                    if (tempMathNo > maxNo)
                                    {
                                        maxNo = tempMathNo;
                                    }
                                }
                                batchSeqNo = Base34Code[maxNo + 1];
                            }
                            if (listCode.Count > 1)
                            {
                                for (int i = 0; i < listCode.Count; i++)
                                {
                                    listCode[i].Ctcode = listCode[i].Ctcode + batchSeqNo;
                                }
                                woBatchNo = listCode[0].Ctcode;
                            }
                            else
                            {
                                ctCode.Append(batchSeqNo);
                                woBatchNo = ctCode.ToString();
                            }
                            //保存工单批次
                            WoBatch woBatch = new WoBatch();
                            woBatch.BatchNo = woBatchNo;
                            woBatch.Workno  = ctCodeInfo.Workno;
                            woBatchService.saveWoBatch(woBatch);                        //占用工单批次
                        }
                        else
                        {
                            if (listCode.Count > 1)
                            {
                                for (int i = 0; i < listCode.Count; i++)
                                {
                                    listCode[i].Ctcode = "";
                                    listCode[i].Ctcode = woBatchNo;
                                }
                            }
                            else
                            {
                                ctCode.Clear();
                                ctCode.Append(woBatchNo);
                            }
                        }

                        break;
                    }
                }
            }
            if (!judgeSerial)
            {
                for (int i = 1; i <= printQty; i++)
                {
                    CTCode ctCodeIn = new CTCode();
                    ctCodeIn        = exchangeCT(ctCodeIn, ctCodeInfo);
                    ctCodeIn.Ctcode = ctCode.ToString();
                    listCode.Add(ctCodeIn);
                }
            }
            if (printQty == 1)
            {
                listCode[0].Ctcode = ctCode.ToString();
            }
            return(listCode);
        }