From 2a945ca2b50122f6cc24ad0d5100e45ae42237fa Mon Sep 17 00:00:00 2001
From: Demo <Demo@DESKTOP-CPA90BF>
Date: 星期五, 02 二月 2024 10:09:51 +0800
Subject: [PATCH] 修改

---
 Wms/WMS.BLL/BllAsnServer/BllLabelBoxNoServer.cs | 1113 +++++++++++++++++++++++++++-------------------------------
 1 files changed, 518 insertions(+), 595 deletions(-)

diff --git a/Wms/WMS.BLL/BllAsnServer/BllLabelBoxNoServer.cs b/Wms/WMS.BLL/BllAsnServer/BllLabelBoxNoServer.cs
index 5cde872..489034f 100644
--- a/Wms/WMS.BLL/BllAsnServer/BllLabelBoxNoServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/BllLabelBoxNoServer.cs
@@ -1,10 +1,12 @@
 锘縰sing System;
 using System.Collections.Generic;
+using System.Linq;
 using System.Linq.Expressions;
 using System.Text;
 using Model.ModelDto.BllAsnDto;
 using Model.ModelVm.BllAsnVm;
 using SqlSugar;
+using Utility.Tools;
 using WMS.DAL;
 using WMS.Entity.BllAsnEntity;
 using WMS.Entity.Context;
@@ -138,667 +140,588 @@
             }
         }
 
+        //鑾峰彇鏍囩淇℃伅(鐢熸垚鏍囩)
+        public List<LabelBoxDto> AddLabelBoxReturn(int imId, string isReset,decimal arriveQty, string skuName, string standard, string packStandard, string skuNo,
+            string supplierLot, string productionTime, string expirationTime, string storeTime, int userId)
+        {
+            try
+            {
+                #region 蹇呭~楠岃瘉
 
-        ///// <summary>
-        /////  鑾峰彇鐗╂枡鏍囩淇℃伅JC06
-        ///// </summary>
-        ///// <param name="imId"></param>
-        ///// <param name="isPrint">鏄惁閲嶆柊鐢熸垚鑷湁鎵规 0:鍚� 1:鏄� </param>
-        ///// <param name="createUser">鍒涘缓浜�</param>
-        ///// <param name="number">绠卞唴鏁伴噺锛堜竴绾ф爣绛惧繀濉級</param>
-        ///// <param name="productionDate">鐢熶骇鏃ユ湡</param>
-        ///// <param name="supplierName">鐢熶骇鍘傚</param>
-        ///// <param name="supplierLot">鐢熶骇鍘傚鎵瑰彿</param>
-        ///// <param name="inspectTime">鏈夋晥鏈�</param>
-        ///// <param name="expirationTime">淇濊川鏈�</param>
-        ///// <param name="bQNum">澶栫鏍囩鏁伴噺</param>
-        ///// <param name="skuNum">鍒拌揣鏁伴噺</param>
-        ///// <returns></returns>
-        //public List<LabelPrint5Model> GetImport5Id(string imId, string isPrint, string createUser, decimal number, string productionDate,
-        //    string supplierName, string supplierLot, string inspectTime, string expirationTime, int? bQNum, string skuNum)
-        //{
-        //    try
-        //    {
-        //        using (LinqModelDataContext DataContext = new LinqModelDataContext(DataConnection.GetDataConnection))
-        //        {
-        //            #region 蹇呭~楠岃瘉
+                //if (string.IsNullOrWhiteSpace(productionDate))
+                //{
+                //    throw new Exception("鐢熶骇鏃ユ湡闇�蹇呭~锛屼笉鑳戒负绌�");
+                //}
 
-        //            if (string.IsNullOrWhiteSpace(productionDate))
-        //            {
-        //                throw new Exception("鐢熶骇鏃ユ湡闇�蹇呭~锛屼笉鑳戒负绌�");
-        //            }
+                //var twoSeletOne = true;//鏈夋晥鏈熴�佸楠屾湡浜岄�変竴
+                //if (string.IsNullOrWhiteSpace(expirationTime))
+                //{
+                //    twoSeletOne = false;
+                //}
+                //if (string.IsNullOrWhiteSpace(inspectTime))
+                //{
+                //    twoSeletOne = false;
+                //}
 
-        //            var twoSeletOne = true;//鏈夋晥鏈熴�佸楠屾湡浜岄�変竴
-        //            if (string.IsNullOrWhiteSpace(expirationTime))
-        //            {
-        //                twoSeletOne = false;
-        //            }
-        //            if (string.IsNullOrWhiteSpace(inspectTime))
-        //            {
-        //                twoSeletOne = false;
-        //            }
+                //if (twoSeletOne)
+                //{
+                //    throw new Exception("鏈夋晥鏈熴�佸楠屾湡鏈�濂藉~鍐欎竴涓�");
+                //}
+                //if (string.IsNullOrWhiteSpace(supplierName))
+                //{
+                //    throw new Exception("鐢熶骇鍘傚闇�蹇呭~锛屼笉鑳戒负绌�");
+                //}
+                //if (string.IsNullOrWhiteSpace(supplierLot))
+                //{
+                //    throw new Exception("鍘傚鎵瑰彿闇�蹇呭~锛屼笉鑳戒负绌�");
+                //}
 
-        //            if (twoSeletOne)
-        //            {
-        //                throw new Exception("鏈夋晥鏈熴�佸楠屾湡鏈�濂藉~鍐欎竴涓�");
-        //            }
-        //            if (string.IsNullOrWhiteSpace(supplierName))
-        //            {
-        //                throw new Exception("鐢熶骇鍘傚闇�蹇呭~锛屼笉鑳戒负绌�");
-        //            }
-        //            if (string.IsNullOrWhiteSpace(supplierLot))
-        //            {
-        //                throw new Exception("鍘傚鎵瑰彿闇�蹇呭~锛屼笉鑳戒负绌�");
-        //            }
+                //if (bQNum <= 0)
+                //{
+                //    throw new Exception("澶栫鏍囩鏁伴噺涓嶈兘涓虹┖鎴栧皬浜庣瓑浜�0");
+                //}
 
-        //            if (bQNum <= 0)
-        //            {
-        //                throw new Exception("澶栫鏍囩鏁伴噺涓嶈兘涓虹┖鎴栧皬浜庣瓑浜�0");
-        //            }
+                #endregion
 
-        //            #endregion
-        //            #region MyRegion
+                #region 鍗曟嵁銆佺墿鏂欍�佸寘瑁呫�佹爣绛句俊鎭幏鍙�
 
-        //            var list = DataContext.View_ImportNotify.FirstOrDefault(a => a.ImportId == imId && a.IsDel == 0);
-        //            List<LabelPrint5Model> printModel = new List<LabelPrint5Model>();
+                var asnList = Db.Queryable<BllArrivalNoticeDetail>().First(m => m.Id == imId && m.IsDel == "0");
+                if (asnList == null)
+                {
+                    throw new Exception("鏈煡璇㈠埌鍗曟嵁鏄庣粏淇℃伅");
+                }
+                var asn = Db.Queryable<BllArrivalNotice>().First(m => m.ASNNo == asnList.ASNNo && m.IsDel == "0");
+                if (asn == null)
+                {
+                    throw new Exception("鏈煡璇㈠埌鍗曟嵁淇℃伅");
+                }
+                //鐗╂枡
+                var sku = Db.Queryable<SysMaterials>().First(m => m.IsDel == "0" && m.SkuNo == asnList.SkuNo);
+                var pack = Db.Queryable<SysPackag>().First(m => m.IsDel == "0" && m.PackagNo == asnList.PackagNo);
+                if (pack == null)
+                {
+                    throw new Exception("鏈煡璇㈠埌褰撳墠鍗曟嵁涓墿鏂欑殑鍖呰淇℃伅");
+                }
+                //鏍囩琛�
+                var label = Db.Queryable<BllLabelBoxNo>().Where(m => m.IsDel == "0" && m.ASNDetailNo == imId).ToList();
+                 
 
-        //            if (list == null)
-        //            {
-        //                throw new Exception("鏈煡璇㈠埌鍗曟嵁淇℃伅");
-        //            }
-        //            var goodMap = DataContext.GoodMapAndMes.FirstOrDefault(m => m.WmsGoodCode == list.GoodsCode && m.IsDel == 0);
-        //            var mesGood = "AAAA";
-        //            if (goodMap != null)
-        //            {
-        //                mesGood = goodMap.MesGoodCode;
-        //            }
-        //            //鐗╂枡
-        //            var good = DataContext.WmsBaseGoods.FirstOrDefault(m => m.GoodsDeleteFlag == 0 && m.GoodsCode == list.GoodsCode);
-        //            var pack = DataContext.WmsBasePackaging.FirstOrDefault(m => m.IsDel == 0 && m.Id == good.GoodsPackaging);
-        //            if (pack == null)
-        //            {
-        //                throw new Exception("鏈煡璇㈠埌褰撳墠鍗曟嵁涓墿鏂欑殑鍖呰淇℃伅");
-        //            }
-        //            //鏍囩琛�
-        //            var labelData = DataContext.LabelPrint.Where(m => m.ImportId == imId).ToList();
+                #endregion
 
-        //            if (bQNum == null)
-        //            {
-        //                bQNum = 0;
-        //            }
-        //            var bNum = 0;//绠辩墿鍝佹暟閲�
-        //            var zNum = 0;//鏀墿鍝佹暟閲�
-        //            var packLevel = 0;
-        //            var isGo = false;
+                #region 鍖呰鏌ヨ
 
-        //            #endregion
+                var bNum = 0;//绠辩墿鍝佹暟閲�
+                var zNum = 0;//鏀墿鍝佹暟閲�
+                var packLevel = 0;
+                var isGo = true;
 
-        //            #region 鍖呰鏌ヨ
+                if (pack.L5Num.HasValue)
+                {
+                    if (pack.L5Name != "鎵�")
+                    {
+                        isGo = false;
+                        packLevel = 5;
+                        bNum = Convert.ToInt32(pack.L5Num);
+                    }
+                }
+                if (pack.L4Num.HasValue && isGo)
+                {
+                    if (pack.L4Name != "鎵�")
+                    {
+                        isGo = false;
+                        packLevel = 4;
+                        bNum = Convert.ToInt32(pack.L4Num);
+                    }
+                }
+                if (pack.L3Num.HasValue && isGo)
+                {
+                    if (pack.L4Name != "鎵�")
+                    {
+                        isGo = false;
+                        packLevel = 3;
+                        bNum = Convert.ToInt32(pack.L3Num);
+                    }
+                }
+                if (pack.L2Num.HasValue)
+                {
+                    packLevel = 2;
+                    bNum = Convert.ToInt32(pack.L2Num);
 
-        //            //if (!string.IsNullOrWhiteSpace(pack.FivelevelNum))
-        //            //{
-        //            //    if (pack.FivelevelUnit != "鎵�")
-        //            //    {
-        //            //        isGo = false;
-        //            //        packLevel = 5;
-        //            //        bNum = Convert.ToInt32(pack.FivelevelNum);
-        //            //    }
-        //            //}
-        //            //if (!string.IsNullOrWhiteSpace(pack.FourlevelNum) && isGo)
-        //            //{
-        //            //    if (pack.FourlevelUnit != "鎵�")
-        //            //    {
-        //            //        isGo = false;
-        //            //        packLevel = 4;
-        //            //        bNum = Convert.ToInt32(pack.FourlevelNum);
-        //            //    }
-        //            //}
-        //            //if (!string.IsNullOrWhiteSpace(pack.ThreelevelNum) && isGo)
-        //            //{
-        //            //    if (pack.ThreelevelUnit != "鎵�")
-        //            //    {
-        //            //        isGo = false;
-        //            //        packLevel = 3;
-        //            //        bNum = Convert.ToInt32(pack.ThreelevelNum);
-        //            //    }
-        //            //}
-        //            if (!string.IsNullOrWhiteSpace(pack.TwolevelNum))
-        //            {
-        //                packLevel = 2;
-        //                bNum = Convert.ToInt32(pack.TwolevelNum);
+                }
+                if (pack.L1Num.HasValue)
+                {
+                    if (packLevel == 0)
+                    {
+                        packLevel = 1;
+                        bNum = Convert.ToInt32(pack.L1Num);
+                    }
+                    zNum = Convert.ToInt32(pack.L1Num);
+                }
 
-        //            }
-        //            if (!string.IsNullOrWhiteSpace(pack.OnelevelNum))
-        //            {
-        //                if (packLevel == 0)
-        //                {
-        //                    packLevel = 1;
-        //                    bNum = Convert.ToInt32(pack.OnelevelNum);
-        //                }
-        //                zNum = Convert.ToInt32(pack.OnelevelNum);
-        //            }
+                if (packLevel <= 1)//鍖呰绛夌骇灏忎簬1锛屾寜鐓�1绾ф爣绛炬墦鍗�
+                {
+                    packLevel = 1;
+                }
 
-        //            if (packLevel <= 1)//鍖呰绛夌骇灏忎簬1锛屾寜鐓�1绾ф爣绛炬墦鍗�
-        //            {
-        //                packLevel = 1;
-        //            }
+                #endregion
 
-        //            #endregion
+                if (packLevel == 1)
+                {
+                    #region 涓�绾у寘瑁�
 
-        //            if (packLevel == 1)
-        //            {
-        //                #region 涓�绾у寘瑁�
+                    // 鏍规嵁鐢ㄦ埛杈撳叆鐨勭鏁伴噺璁$畻闇�瑕佺殑鏉$爜鏁�
+                    var labQty = label.Sum(m => m.Qty);
+                    var qty = asnList.Qty - labQty;//褰撳墠鍗曟嵁鍓╀綑闇�瑕佹墦鍗扮殑鐗╂枡鏁伴噺(涓嶆槸鏍囩鏁伴噺)
+                    if (qty <= 0)
+                    {
+                        throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏍囩宸叉墦鍗板畬姣曪紝濡傛湁闇�瑕佽琛ユ墦");
+                    }
 
-        //                // 鏍规嵁鐢ㄦ埛杈撳叆鐨勭鏁伴噺璁$畻闇�瑕佺殑鏉$爜鏁�
-        //                var labQty = labelData.Sum(m => m.Qty);
-        //                var qty = Convert.ToDecimal(list.ImportQuantity) - (decimal)labQty;//褰撳墠鍗曟嵁鍓╀綑闇�瑕佹墦鍗扮殑鏁伴噺
-        //                if (qty <= 0)
-        //                {
-        //                    throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏍囩宸叉墦鍗板畬姣曪紝濡傛湁闇�瑕佽琛ユ墦");
-        //                }
+                    #region 鍒拌揣鏁伴噺
+                    
+                    if (arriveQty - qty > 0)
+                    {
+                        throw new Exception("鍒拌揣鏁伴噺澶т簬鏈墦鏍囩鏁伴噺锛岃閲嶆柊杈撳叆鍒拌揣鏁伴噺骞舵牳瀹�!");
+                    }
+                    else
+                    {
+                        qty = arriveQty;
+                    }
 
-        //                #region 澧炲姞鍒拌揣鏁伴噺
-        //                if (skuNum != "")
-        //                {
-        //                    if (qty - Convert.ToDecimal(skuNum) < 0)
-        //                    {
-        //                        throw new Exception("鍒拌揣鏁伴噺澶т簬鏈墦鏍囩鏁伴噺锛岃閲嶆柊杈撳叆鍒拌揣鏁伴噺!");
-        //                    }
-        //                    else
-        //                    {
-        //                        qty = Convert.ToDecimal(skuNum);
-        //                    }
-        //                }
-        //                #endregion
+                    #endregion
 
-        //                int labelNum = 1; //鐢熶骇鏉$爜鏁伴噺
-        //                if (number > 0)
-        //                {
-        //                    labelNum = int.Parse(Math.Ceiling(qty / number).ToString());//鏍囩鏁伴噺
-        //                }
-        //                else
-        //                {
-        //                    throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏄竴绾у寘瑁咃紝璇疯緭鍏ョ鍐呮暟閲忎笖澶т簬0");
-        //                }
+                    int labelNum = 1; //鐢熶骇鏉$爜鏁伴噺
+                    if (zNum > 0)
+                    {
+                        labelNum = int.Parse(Math.Ceiling(qty / zNum).ToString());//鏍囩鏁伴噺
+                    }
+                    else
+                    {
+                        throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏄竴绾у寘瑁咃紝鏈煡璇㈠埌涓�绾у寘瑁呬俊鎭�");
+                    }
 
-        //                if (bQNum >= 1)//鎵撳嵃鏍囩鏁伴噺鏄惁澶т簬1 (鏈夋墦鍗版爣绛炬暟閲�)
-        //                {
-        //                    if (bQNum > 100)
-        //                    {
-        //                        throw new Exception("鎵撳嵃鏍囩鏁伴噺寤鸿鍦�100寮犱互鍐�");
-        //                    }
-        //                    if (bQNum < labelNum) //鎵撳嵃鐨勬爣绛炬暟閲忓ぇ浜庣瓑浜庡墿浣欒兘鎵撳嵃鐨勫紶鏁伴噺
-        //                    {
-        //                        labelNum = (int)bQNum;
-        //                    }
-        //                }
+                    #region 鑾峰彇/鐢熸垚鎵规鍙�
 
-        //                if (labelNum > 100)
-        //                {
-        //                    labelNum = 100;
-        //                }
+                    string maxLotNoStr = ""; //鎵规鍙�
+                    string maxBoxCode = ""; //绠辩爜鍙�
+                    // 鐢熸垚鑷紪鎵瑰彿
+                    string toDayTime = DateTime.Now.ToString("yyyyMMdd");
+                    var diJiJian = 0;
 
-        //                string maxCodestr = "";
-        //                string maxboxcode = "";
-        //                // 鐢熸垚鑷紪鎵瑰彿
-        //                string toDayTime = DateTime.Now.ToString("yyyyMMdd");
-        //                var diJiJian = 0;
-        //                if (isPrint == "0")
-        //                {
-        //                    var maxCode = DataContext.LabelPrint.Where(b => b.ImportId == imId).ToList().Max(a => a.ImportLotNo);
-        //                    var boxCode1 = DataContext.LabelPrint.Where(b => b.ImportId == imId).ToList().Max(a => a.LabelStream);
-        //                    maxCodestr = maxCode;
-        //                    maxboxcode = boxCode1;
-        //                    if (string.IsNullOrWhiteSpace(maxCodestr))
-        //                    {
-        //                        maxCodestr = toDayTime.Substring(2, 6) + "0001";
-        //                    }
-        //                    else
-        //                    {
-        //                        var q = DataContext.LabelPrint
-        //                            .Where(m => m.ImportId == imId && m.ImportLotNo == maxCodestr)
-        //                            .GroupBy(m => m.LabelStream).ToList();
-        //                        diJiJian = q.Count;
-        //                    }
-        //                }
-        //                else
-        //                {
-        //                    var maxCode = DataContext.LabelPrint.Max(a => a.ImportLotNo);                        // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿
-        //                    if (string.IsNullOrWhiteSpace(maxCode))
-        //                    {
-        //                        maxCodestr = toDayTime.Substring(2, 6) + "0001";
-        //                    }
-        //                    else
-        //                    {
-        //                        var lotStr = maxCode.Substring(0, 6);
-        //                        var timeStr = toDayTime.Substring(2, 6);
-        //                        if (lotStr == timeStr)
-        //                        {
-        //                            maxCodestr = toDayTime.Substring(2, 6) + (int.Parse(maxCode.Substring(6, 4)) + 1).ToString().PadLeft(4, '0');
-        //                        }
-        //                        else
-        //                        {
-        //                            maxCodestr = timeStr + "0001";
-        //                        }
+                    var maxLotNo = label.Max(a => a.LotNo);
+                    var maxBoxNo = label.Max(a => a.BoxNo);
+                    if (isReset == "0")
+                    {
+                       
+                        maxLotNoStr = maxLotNo;
+                        maxBoxCode = maxBoxNo;
+                        if (string.IsNullOrWhiteSpace(maxLotNoStr))
+                        {
+                            maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
+                        } 
+                    }
+                    else
+                    {
+                        var maxCode = Db.Queryable<BllLabelBoxNo>().Max(a => a.LotNo);                        // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿
+                        if (string.IsNullOrWhiteSpace(maxCode))
+                        {
+                            maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
+                        }
+                        else
+                        {
+                            var lotStr = maxCode.Substring(0, 6);
+                            var timeStr = toDayTime.Substring(2, 6);
+                            if (lotStr == timeStr)
+                            {
+                                maxLotNoStr = toDayTime.Substring(2, 6) + (int.Parse(maxCode.Substring(6, 4)) + 1).ToString().PadLeft(4, '0');
+                            }
+                            else
+                            {
+                                maxLotNoStr = timeStr + "0001";
+                            }
 
-        //                    }
-        //                }
-        //                var sapNo = "";
-        //                if (!string.IsNullOrWhiteSpace(list.OuterBillCode) && !string.IsNullOrWhiteSpace(list.SequenceNo))
-        //                {
-        //                    sapNo = list.OuterBillCode + "-" + list.SequenceNo;
-        //                }
+                        }
+                    }
 
-        //                for (int i = 1; i <= labelNum; i++)
-        //                {
-        //                    // 鐗╂枡鏉$爜淇℃伅璧嬪��
-        //                    LabelPrint5Model model = new LabelPrint5Model();
-        //                    model.ImportId = imId;
-        //                    model.OuterBillCode = list.OuterBillCode;
-        //                    model.ImportBillCode = list.ImportBillCode;
-        //                    model.SkuNo = list.GoodsCode;
-        //                    model.SkuName = list.GoodsName;
-        //                    model.QtyCount = (int)bQNum;                          // 鎬讳欢鏁�
+                    #endregion
 
-        //                    model.SupplierName = supplierName;                        // 鐢熶骇鍘傚
-        //                    model.ProductionDate = productionDate;                      // 鐢熶骇鏃ユ湡
-        //                    model.SapSkuNo = sapNo;                            // SAP浠g爜  SAP鍗曞彿+琛屽彿
-        //                    model.Standard = good.GoodsStandard;                            // 瑙勬牸
-        //                    model.SupplierLot = supplierLot;                         // 鍘傚鎵瑰彿
+                    var modelList = new List<LabelBoxDto>();
+                    
+                    for (int i = 1; i <= labelNum; i++)
+                    {
+                        // 鐗╂枡鏉$爜淇℃伅璧嬪��
+                        LabelBoxDto model = new LabelBoxDto();
+                        model.AsnDetailNo = imId;  
+                        model.SkuNo = asnList.SkuNo;
+                        model.SkuName = asnList.SkuName;
+                        
+                        model.SupplierName = asn.CustomerName;                        // 渚涘簲鍟�
+                        
+                        model.Standard = asnList.Standard;                            // 瑙勬牸
+                        model.PackageStandard = packStandard;
+                        model.SupplierLot = supplierLot;                         // 鍘傚鎵瑰彿 
+                        model.LotNo = maxLotNoStr;                      //鎵规
 
-        //                    model.LotNo = maxCodestr;                      //鎵规
+                        model.ProductionTime = DateTime.Parse(productionTime);          // 鐢熶骇鏃ユ湡 
+                        model.StoreTime = DateTime.Parse(storeTime);                     // 鍌ㄥ瓨鏈熻嚦
+                        model.ExpirationTime = DateTime.Parse(expirationTime);          // 鏈夋晥鏈熻嚦/璐瓨鏈� 
+                        if (i == labelNum)
+                        {
+                            // 鏈�鍚庝竴涓潯鐮�
+                            var s = zNum * (i - 1);
+                            if (zNum > qty - s)
+                            {
+                                model.Qty = qty - s;// 鏁伴噺
+                            }
+                            else
+                            {
+                                model.Qty = zNum;// 鏁伴噺
+                            }
+                        }
+                        else
+                        {
+                            model.Qty = zNum;         // 鏁伴噺
+                        }
+                         
 
+                        if (maxBoxCode == "")
+                        {
+                            var str = model.LotNo + "000001";
+                            model.BoxNo = str;                 // 鏀彿     鎵瑰彿+ 娴佹按  2302010001000001
+                            maxBoxCode = model.BoxNo;
+                        }
+                        else
+                        {
+                            model.BoxNo = maxBoxCode.Substring(0, 10) + (int.Parse(maxBoxCode.Substring(10, 6)) + 1).ToString().PadLeft(6, '0');
+                            maxBoxCode = model.BoxNo;
+                        }
+                        model.ImgStr = BarcodeHelper.GetCodeBarBase64(model.BoxNo, 80, 50);//Utility.Extra.BarcodeHelper.GetQrCodeBase64(model.BoxCode, 85, 85);
 
-        //                    model.InspectTime = inspectTime;                     // 澶嶉獙鏈熻嚦
-        //                    model.ExpirationTime = expirationTime;                  // 鏈夋晥鏈熻嚦/璐瓨鏈�
-        //                    model.ExpirationType = good.GoodsTemp;                  // 璐瓨鏉′欢
-        //                    if (i == labelNum)
-        //                    {
-        //                        // 鏈�鍚庝竴涓潯鐮�
-        //                        var s = number * (i - 1);
-        //                        if (number > qty - s)
-        //                        {
-        //                            model.Qty = qty - s;// 鏁伴噺
-        //                        }
-        //                        else
-        //                        {
-        //                            model.Qty = number;// 鏁伴噺
-        //                        }
-        //                    }
-        //                    else
-        //                    {
-        //                        model.Qty = number;                                                         // 鏁伴噺
-        //                    }
+                        // 娣诲姞鍒發ist闆嗗悎
+                        modelList.Add(model);
+                        
+                        var guid = Guid.NewGuid().ToString("N");
+                        // 灏嗘潯鐮佷繚瀛樺埌鍘熸枡鏉$爜琛�
+                        var labelModel = new BllLabelBoxNo()
+                        {
+                            ASNNo = asnList.ASNNo,
+                            ASNDetailNo = asnList.Id,
+                            BoxNo = model.BoxNo, 
+                            ParentBoxNo = "",
+                            Qty = model.Qty,
+                            SkuNo = model.SkuNo,
+                            SkuName = model.SkuName,
+                            Standard = model.Standard,
+                            PackageStandard = model.PackageStandard,
 
-        //                    model.QtyOrd = i + diJiJian;                                               // 绗嚑浠�
+                            LotNo = model.LotNo,
+                            SupplierName = asn.CustomerName,   
+                            ProductionTime = model.ProductionTime, 
+                            SupplierLot = model.SupplierLot,
+                            StoreTime = model.StoreTime,
+                            ExpirationTime = model.ExpirationTime,
+                            IsUse = "0",
+                            Level = "1",
 
-        //                    if (maxboxcode == "")
-        //                    {
-        //                        var str = mesGood.PadRight(16, ' ') + model.LotNo.PadRight(12, ' ') + "0001";
-        //                        model.BoxCode = str;                 // 鏀彿     鎵瑰彿+绗嚑绠�
-        //                        maxboxcode = model.BoxCode;
-        //                    }
-        //                    else
-        //                    {
-        //                        model.BoxCode = maxboxcode.Substring(0, 28) + (int.Parse(maxboxcode.Substring(28, 4)) + 1).ToString().PadLeft(4, '0');
-        //                        maxboxcode = model.BoxCode;
-        //                    }
-        //                    model.imageStr = Utility.Extra.BarcodeHelper.GetQrCodeBase64(model.BoxCode, 85, 85);
+                            CreateUser = userId,
+                            CreateTime = DateTime.Now, 
+                        };
 
-        //                    // 娣诲姞鍒發ist闆嗗悎
-        //                    printModel.Add(model);
+                        Db.Insertable(labelModel).ExecuteCommand();
 
-        //                    //if (number <= 0)
-        //                    //{
-        //                    //    return printModel;
-        //                    //}
-        //                    var guid = Guid.NewGuid().ToString("N");
-        //                    // 灏嗘潯鐮佷繚瀛樺埌鍘熸枡鏉$爜琛�
-        //                    var LabelModel = new LabelPrint
-        //                    {
-        //                        LabelID = guid,
-        //                        LabelStream = model.BoxCode,
-        //                        GoodsCode = model.SkuNo,
-        //                        GoodsName = model.SkuName,
-        //                        GoodsStandard = model.Standard,
-        //                        ImportLotNo = model.LotNo,
-        //                        SupplierName = model.SupplierName,
-        //                        ImportId = model.ImportId,
-        //                        OuterBillCode = model.OuterBillCode,
-        //                        ImportBillCode = model.ImportBillCode,
-        //                        ProductionDate = model.ProductionDate,
-        //                        SapSkuNo = model.SapSkuNo,
-        //                        Qty = model.Qty,
-        //                        SupplierLot = model.SupplierLot,
-        //                        InspectTime = model.InspectTime,
-        //                        ExpirationTime = model.ExpirationTime,
-        //                        QtyCount = model.QtyCount,
-        //                        QtyOrd = model.QtyOrd,
-        //                        ExpirationType = model.ExpirationType,
-        //                        BoxNum = number,// model.Qty,
-
-        //                        BulkTank = model.Qty == number ? 0 : 1,//闆跺ご绠�
-        //                        BulkCase = 0,//闆跺ご鐩�
-
-        //                        CreateUser = createUser,
-        //                        CreateTime = DateTime.Now,
-        //                        IsUse = 0
-        //                    };
+                    } 
 
-        //                    DataContext.LabelPrint.InsertOnSubmit(LabelModel);
+                    #endregion
+                }
+                else //(packLevel == 2)
+                {
+                    #region 浜岀骇鍖呰
 
-        //                }
-        //                DataContext.SubmitChanges();
-        //                #endregion
-        //            }
-        //            else //(packLevel == 2)
-        //            {
-        //                #region 浜岀骇鍖呰
+                    // 鏍规嵁鐢ㄦ埛杈撳叆鐨勭鏁伴噺璁$畻闇�瑕佺殑鏉$爜鏁�
+                    var labQty = label.Sum(m => m.Qty);
+                    var qty2 = asnList.Qty - labQty;
+                    if (qty2 <= 0)
+                    {
+                        throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏍囩宸叉墦鍗板畬姣曪紝濡傛湁闇�瑕佽琛ユ墦");
+                    }
 
-        //                // 鏍规嵁鐢ㄦ埛杈撳叆鐨勭鏁伴噺璁$畻闇�瑕佺殑鏉$爜鏁�
-        //                var labQty = labelData.Sum(m => m.Qty);
-        //                var qty2 = Convert.ToDecimal(list.ImportQuantity) - (decimal)labQty;
-        //                if (qty2 <= 0)
-        //                {
-        //                    throw new Exception("褰撳墠鍗曟嵁鐗╂枡鏍囩宸叉墦鍗板畬姣曪紝濡傛湁闇�瑕佽琛ユ墦");
-        //                }
+                    #region 澧炲姞鍒拌揣鏁伴噺
+                    
+                    if (arriveQty - qty2 > 0)
+                    {
+                        throw new Exception("鍒拌揣鏁伴噺澶т簬鏈墦鏍囩鏁伴噺锛岃閲嶆柊杈撳叆鍒拌揣鏁伴噺!");
+                    }
+                    else
+                    {
+                        qty2 = arriveQty;
+                    }
+                    #endregion
 
-        //                #region 澧炲姞鍒拌揣鏁伴噺
-        //                if (skuNum != "")
-        //                {
-        //                    if (qty2 - Convert.ToDecimal(skuNum) < 0)
-        //                    {
-        //                        throw new Exception("鍒拌揣鏁伴噺澶т簬鏈墦鏍囩鏁伴噺锛岃閲嶆柊杈撳叆鍒拌揣鏁伴噺!");
-        //                    }
-        //                    else
-        //                    {
-        //                        qty2 = Convert.ToDecimal(skuNum);
-        //                    }
-        //                }
-        //                #endregion
+                    int labelNum2 = 1; //鐢熶骇绠辨潯鐮佹暟閲�
 
-        //                int labelNum2 = 1; //鐢熶骇绠辨潯鐮佹暟閲�
+                    labelNum2 = int.Parse(Math.Ceiling(qty2 / bNum).ToString());
 
-        //                labelNum2 = int.Parse(Math.Ceiling(qty2 / bNum).ToString());
+                     
 
-        //                if (bQNum >= 1)//鎵撳嵃鏍囩鏁伴噺鏄惁澶т簬1 (鏈夋墦鍗版爣绛炬暟閲�)
-        //                {
-        //                    if (bQNum > 100)
-        //                    {
-        //                        throw new Exception("鎵撳嵃鏍囩鏁伴噺寤鸿鍦�100寮犱互鍐�");
-        //                    }
-        //                    if (bQNum < labelNum2) //鎵撳嵃鐨勬爣绛炬暟閲忓ぇ浜庣瓑浜庡墿浣欒兘鎵撳嵃鐨勫紶鏁伴噺
-        //                    {
-        //                        labelNum2 = (int)bQNum;
-        //                    }
-        //                }
+                    var ss = bNum / zNum; //姣忕鏀爣绛炬暟閲�
+                    var labelNumZ2 = Math.Ceiling((decimal)ss);
 
-        //                //var bCount = Math.Floor(qty2 / bNum); //鏁寸鐨勬暟閲� 
-        //                //var zCount = qty2 - bCount* bNum; //鍓╀綑鏁伴噺
+                    if (labelNum2 * labelNumZ2 > 100)
+                    {
+                        if (labelNumZ2 <= 100)
+                        {
+                            labelNum2 = (int)Math.Floor((decimal)(100 / labelNumZ2));
+                        }
+                        else
+                        {
+                            labelNum2 = 1;
+                        }
+                    }
 
-        //                var ss = bNum / zNum; //姣忕鏀爣绛炬暟閲�
-        //                var labelNumZ2 = Math.Ceiling((decimal)ss);
+                    string maxCodestr2 = "";    //鎵规
+                    string maxboxcode2 = "";    //绠辩爜
+                    string maxboxcode3 = "";    //鏀爜
+                                                // 鐢熸垚鑷紪鎵瑰彿
+                    string toDayTime2 = DateTime.Now.ToString("yyyyMMdd");
+                    var diJiJian = 0;
+                    //if (isReset == "0")
+                    //{
+                    //    var maxCode = DataContext.LabelPrint.Where(b => b.ImportId == imId).ToList().Max(a => a.ImportLotNo);
+                    //    var boxCode1 = DataContext.LabelPrint.Where(b => b.ImportId == imId).ToList().Max(a => a.LabelStream);
+                    //    var boxCode2 = DataContext.LabelPrint.Where(b => b.ImportId == imId).ToList().Max(a => a.BoxCode1);//鏀彿
+                    //    maxCodestr2 = maxCode;
+                    //    maxboxcode2 = boxCode1;
+                    //    maxboxcode3 = boxCode2;
+                    //    if (string.IsNullOrWhiteSpace(maxCodestr2))
+                    //    {
+                    //        maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
+                    //    }
+                    //    else
+                    //    {
+                    //        var q = DataContext.LabelPrint
+                    //            .Where(m => m.ImportId == imId && m.ImportLotNo == maxCodestr2)
+                    //            .GroupBy(m => m.LabelStream).ToList();
+                    //        diJiJian = q.Count;
+                    //    }
+                    //}
+                    //else
+                    //{
+                    //    var maxCode = DataContext.LabelPrint.Max(a => a.ImportLotNo);                        // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿
+                    //    if (string.IsNullOrWhiteSpace(maxCode))
+                    //    {
+                    //        maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
+                    //    }
+                    //    else
+                    //    {
+                    //        var lotStr = maxCode.Substring(0, 6);
+                    //        var timeStr = toDayTime2.Substring(2, 6);
+                    //        if (lotStr == timeStr)
+                    //        {
+                    //            maxCodestr2 = timeStr + (int.Parse(maxCode.Substring(6, 4)) + 1).ToString().PadLeft(4, '0');
+                    //        }
+                    //        else
+                    //        {
+                    //            maxCodestr2 = timeStr + "0001";
+                    //        }
 
-        //                if (labelNum2 * labelNumZ2 > 100)
-        //                {
-        //                    if (labelNumZ2 <= 100)
-        //                    {
-        //                        labelNum2 = (int)Math.Floor((decimal)(100 / labelNumZ2));
-        //                    }
-        //                    else
-        //                    {
-        //                        labelNum2 = 1;
-        //                    }
-        //                }
+                    //    }
+                    //} 
+                    //for (int i = 1; i <= labelNum2; i++)//绠辩爜鏍囩
+                    //{
+                    //    // 鐗╂枡鏉$爜淇℃伅璧嬪��
+                    //    LabelPrint5Model model = new LabelPrint5Model();
+                    //    model.ImportId = imId;
+                    //    model.OuterBillCode = list.OuterBillCode;
+                    //    model.ImportBillCode = list.ImportBillCode;
+                    //    model.SkuNo = list.GoodsCode;
+                    //    model.SkuName = list.GoodsName;
+                    //    model.QtyCount = (int)bQNum;                          // 鎬讳欢鏁�
 
-        //                string maxCodestr2 = "";    //鎵规
-        //                string maxboxcode2 = "";    //绠辩爜
-        //                string maxboxcode3 = "";    //鏀爜
-        //                                            // 鐢熸垚鑷紪鎵瑰彿
-        //                string toDayTime2 = DateTime.Now.ToString("yyyyMMdd");
-        //                var diJiJian = 0;
-        //                if (isPrint == "0")
-        //                {
-        //                    var maxCode = DataContext.LabelPrint.Where(b => b.ImportId == imId).ToList().Max(a => a.ImportLotNo);
-        //                    var boxCode1 = DataContext.LabelPrint.Where(b => b.ImportId == imId).ToList().Max(a => a.LabelStream);
-        //                    var boxCode2 = DataContext.LabelPrint.Where(b => b.ImportId == imId).ToList().Max(a => a.BoxCode1);//鏀彿
-        //                    maxCodestr2 = maxCode;
-        //                    maxboxcode2 = boxCode1;
-        //                    maxboxcode3 = boxCode2;
-        //                    if (string.IsNullOrWhiteSpace(maxCodestr2))
-        //                    {
-        //                        maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
-        //                    }
-        //                    else
-        //                    {
-        //                        var q = DataContext.LabelPrint
-        //                            .Where(m => m.ImportId == imId && m.ImportLotNo == maxCodestr2)
-        //                            .GroupBy(m => m.LabelStream).ToList();
-        //                        diJiJian = q.Count;
-        //                    }
-        //                }
-        //                else
-        //                {
-        //                    var maxCode = DataContext.LabelPrint.Max(a => a.ImportLotNo);                        // 鑾峰彇浠婂ぉ鏈�澶ф壒娆″彿
-        //                    if (string.IsNullOrWhiteSpace(maxCode))
-        //                    {
-        //                        maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
-        //                    }
-        //                    else
-        //                    {
-        //                        var lotStr = maxCode.Substring(0, 6);
-        //                        var timeStr = toDayTime2.Substring(2, 6);
-        //                        if (lotStr == timeStr)
-        //                        {
-        //                            maxCodestr2 = timeStr + (int.Parse(maxCode.Substring(6, 4)) + 1).ToString().PadLeft(4, '0');
-        //                        }
-        //                        else
-        //                        {
-        //                            maxCodestr2 = timeStr + "0001";
-        //                        }
+                    //    model.SupplierName = supplierName;                        // 鐢熶骇鍘傚
+                    //    model.ProductionDate = productionDate;                      // 鐢熶骇鏃ユ湡
+                    //    model.SapSkuNo = sapNo;                            // SAP浠g爜
+                    //    model.Standard = good.GoodsStandard;                            // 瑙勬牸
+                    //    model.SupplierLot = supplierLot;                         // 鍘傚鎵瑰彿
 
-        //                    }
-        //                }
-        //                var sapNo = "";
-        //                if (!string.IsNullOrWhiteSpace(list.OuterBillCode) && !string.IsNullOrWhiteSpace(list.SequenceNo))
-        //                {
-        //                    sapNo = list.OuterBillCode + "-" + list.SequenceNo;
-        //                }
-        //                for (int i = 1; i <= labelNum2; i++)//绠辩爜鏍囩
-        //                {
-        //                    // 鐗╂枡鏉$爜淇℃伅璧嬪��
-        //                    LabelPrint5Model model = new LabelPrint5Model();
-        //                    model.ImportId = imId;
-        //                    model.OuterBillCode = list.OuterBillCode;
-        //                    model.ImportBillCode = list.ImportBillCode;
-        //                    model.SkuNo = list.GoodsCode;
-        //                    model.SkuName = list.GoodsName;
-        //                    model.QtyCount = (int)bQNum;                          // 鎬讳欢鏁�
+                    //    model.LotNo = maxCodestr2;                      //鎵规
 
-        //                    model.SupplierName = supplierName;                        // 鐢熶骇鍘傚
-        //                    model.ProductionDate = productionDate;                      // 鐢熶骇鏃ユ湡
-        //                    model.SapSkuNo = sapNo;                            // SAP浠g爜
-        //                    model.Standard = good.GoodsStandard;                            // 瑙勬牸
-        //                    model.SupplierLot = supplierLot;                         // 鍘傚鎵瑰彿
 
-        //                    model.LotNo = maxCodestr2;                      //鎵规
+                    //    model.InspectTime = inspectTime;                     // 澶嶉獙鏈熻嚦
+                    //    model.ExpirationTime = expirationTime;                  // 鏈夋晥鏈熻嚦/璐瓨鏈�
+                    //    model.ExpirationType = good.GoodsTemp;                  // 璐瓨鏉′欢
+                    //    if (i == labelNum2)
+                    //    {
+                    //        // 鏈�鍚庝竴涓潯鐮�
+                    //        var s = bNum * (i - 1);
+                    //        if (bNum > qty2 - s)
+                    //        {
+                    //            model.Qty = qty2 - s;// 鏁伴噺
+                    //        }
+                    //        else
+                    //        {
+                    //            model.Qty = bNum;// 鏁伴噺
+                    //        }
+                    //    }
+                    //    else
+                    //    {
+                    //        model.Qty = bNum;                                                         // 鏁伴噺
+                    //    }
 
+                    //    model.QtyOrd = i + diJiJian;                                               // 绗嚑浠�
+                    //    if (maxboxcode2 == "")
+                    //    {
+                    //        maxboxcode2 = "B" + model.LotNo + i.ToString().PadLeft(5, '0');
+                    //        model.BoxCode = maxboxcode2;                                // 绠卞彿     鎵瑰彿+绗嚑绠�
+                    //    }
+                    //    else
+                    //    {
+                    //        maxboxcode2 = maxboxcode2.Substring(0, 11) + (int.Parse(maxboxcode2.Substring(11, 5)) + 1).ToString().PadLeft(5, '0');
+                    //        model.BoxCode = maxboxcode2;
+                    //    }
+                    //    model.imageStr = Utility.Extra.BarcodeHelper.GetQrCodeBase64(model.BoxCode, 85, 85);
 
-        //                    model.InspectTime = inspectTime;                     // 澶嶉獙鏈熻嚦
-        //                    model.ExpirationTime = expirationTime;                  // 鏈夋晥鏈熻嚦/璐瓨鏈�
-        //                    model.ExpirationType = good.GoodsTemp;                  // 璐瓨鏉′欢
-        //                    if (i == labelNum2)
-        //                    {
-        //                        // 鏈�鍚庝竴涓潯鐮�
-        //                        var s = bNum * (i - 1);
-        //                        if (bNum > qty2 - s)
-        //                        {
-        //                            model.Qty = qty2 - s;// 鏁伴噺
-        //                        }
-        //                        else
-        //                        {
-        //                            model.Qty = bNum;// 鏁伴噺
-        //                        }
-        //                    }
-        //                    else
-        //                    {
-        //                        model.Qty = bNum;                                                         // 鏁伴噺
-        //                    }
+                    //    // 娣诲姞鍒發ist闆嗗悎
+                    //    printModel.Add(model);
 
-        //                    model.QtyOrd = i + diJiJian;                                               // 绗嚑浠�
-        //                    if (maxboxcode2 == "")
-        //                    {
-        //                        maxboxcode2 = "B" + model.LotNo + i.ToString().PadLeft(5, '0');
-        //                        model.BoxCode = maxboxcode2;                                // 绠卞彿     鎵瑰彿+绗嚑绠�
-        //                    }
-        //                    else
-        //                    {
-        //                        maxboxcode2 = maxboxcode2.Substring(0, 11) + (int.Parse(maxboxcode2.Substring(11, 5)) + 1).ToString().PadLeft(5, '0');
-        //                        model.BoxCode = maxboxcode2;
-        //                    }
-        //                    model.imageStr = Utility.Extra.BarcodeHelper.GetQrCodeBase64(model.BoxCode, 85, 85);
+                    //    if (i == labelNum2)
+                    //    {
+                    //        var isGo2 = false;
+                    //        var sl = 0;
+                    //        for (int j = 1; j <= labelNumZ2; j++)
+                    //        {
+                    //            if (isGo2)
+                    //            {
+                    //                break;
+                    //            }
+                    //            var d = zNum;
+                    //            if (i == labelNum2)
+                    //            {
+                    //                var s = bNum * (i - 1);
+                    //                var s2 = zNum * (j - 1);
+                    //                if (zNum >= qty2 - s - s2)
+                    //                {
+                    //                    d = (int)(qty2 - s - s2);    // 鏁伴噺
+                    //                    isGo2 = true;
+                    //                }
+                    //            }
+                    //            sl++;
+                    //        }
+                    //        labelNumZ2 = sl;
+                    //    }
 
-        //                    // 娣诲姞鍒發ist闆嗗悎
-        //                    printModel.Add(model);
+                    //    for (int j = 1; j <= labelNumZ2; j++)//鏈�灏忓崟浣嶆爣绛�
+                    //    {
+                    //        if (isGo)
+                    //        {
+                    //            break;
+                    //        }
+                    //        var d = zNum;
+                    //        if (i == labelNum2)
+                    //        {
+                    //            var s = bNum * (i - 1);
+                    //            var s2 = zNum * (j - 1);
+                    //            if (zNum >= qty2 - s - s2)
+                    //            {
+                    //                d = (int)(qty2 - s - s2);    // 鏁伴噺
+                    //                isGo = true;
+                    //            }
+                    //        }
+                    //        // 鐗╂枡鏉$爜淇℃伅璧嬪��
+                    //        LabelPrint5Model model2 = new LabelPrint5Model();
+                    //        model2.ImportId = imId;
+                    //        model2.OuterBillCode = list.OuterBillCode;
+                    //        model2.ImportBillCode = list.ImportBillCode;
+                    //        model2.SkuNo = list.GoodsCode;
+                    //        model2.SkuName = list.GoodsName;
+                    //        model2.QtyCount = (int)labelNumZ2;                          // 鎬讳欢鏁�(int)labelNumZ2
 
-        //                    if (i == labelNum2)
-        //                    {
-        //                        var isGo2 = false;
-        //                        var sl = 0;
-        //                        for (int j = 1; j <= labelNumZ2; j++)
-        //                        {
-        //                            if (isGo2)
-        //                            {
-        //                                break;
-        //                            }
-        //                            var d = zNum;
-        //                            if (i == labelNum2)
-        //                            {
-        //                                var s = bNum * (i - 1);
-        //                                var s2 = zNum * (j - 1);
-        //                                if (zNum >= qty2 - s - s2)
-        //                                {
-        //                                    d = (int)(qty2 - s - s2);    // 鏁伴噺
-        //                                    isGo2 = true;
-        //                                }
-        //                            }
-        //                            sl++;
-        //                        }
-        //                        labelNumZ2 = sl;
-        //                    }
+                    //        model2.SupplierName = supplierName;                        // 鐢熶骇鍘傚
+                    //        model2.ProductionDate = productionDate;                      // 鐢熶骇鏃ユ湡
+                    //        model2.SapSkuNo = sapNo;                            // SAP浠g爜
+                    //        model2.Standard = good.GoodsStandard;                            // 瑙勬牸
+                    //        model2.SupplierLot = supplierLot;                         // 鍘傚鎵瑰彿
 
-        //                    for (int j = 1; j <= labelNumZ2; j++)//鏈�灏忓崟浣嶆爣绛�
-        //                    {
-        //                        if (isGo)
-        //                        {
-        //                            break;
-        //                        }
-        //                        var d = zNum;
-        //                        if (i == labelNum2)
-        //                        {
-        //                            var s = bNum * (i - 1);
-        //                            var s2 = zNum * (j - 1);
-        //                            if (zNum >= qty2 - s - s2)
-        //                            {
-        //                                d = (int)(qty2 - s - s2);    // 鏁伴噺
-        //                                isGo = true;
-        //                            }
-        //                        }
-        //                        // 鐗╂枡鏉$爜淇℃伅璧嬪��
-        //                        LabelPrint5Model model2 = new LabelPrint5Model();
-        //                        model2.ImportId = imId;
-        //                        model2.OuterBillCode = list.OuterBillCode;
-        //                        model2.ImportBillCode = list.ImportBillCode;
-        //                        model2.SkuNo = list.GoodsCode;
-        //                        model2.SkuName = list.GoodsName;
-        //                        model2.QtyCount = (int)labelNumZ2;                          // 鎬讳欢鏁�(int)labelNumZ2
+                    //        model2.LotNo = maxCodestr2;                      //鎵规
 
-        //                        model2.SupplierName = supplierName;                        // 鐢熶骇鍘傚
-        //                        model2.ProductionDate = productionDate;                      // 鐢熶骇鏃ユ湡
-        //                        model2.SapSkuNo = sapNo;                            // SAP浠g爜
-        //                        model2.Standard = good.GoodsStandard;                            // 瑙勬牸
-        //                        model2.SupplierLot = supplierLot;                         // 鍘傚鎵瑰彿
 
-        //                        model2.LotNo = maxCodestr2;                      //鎵规
+                    //        model2.InspectTime = inspectTime;                     // 澶嶉獙鏈熻嚦
+                    //        model2.ExpirationTime = expirationTime;                  // 鏈夋晥鏈熻嚦/璐瓨鏈�
+                    //        model2.ExpirationType = good.GoodsTemp;                  // 璐瓨鏉′欢
+                    //        model2.Qty = d;                                                         // 鏁伴噺
 
+                    //        model2.QtyOrd = j;                                               // 绗嚑浠�
+                    //        if (maxboxcode3 == "")
+                    //        {
+                    //            var str = mesGood.PadRight(16, ' ') + model.LotNo.PadRight(12, ' ') + "0001";
+                    //            model2.BoxCode = str;                 // 鏀彿     鎵瑰彿+绗嚑绠�
+                    //            maxboxcode3 = model2.BoxCode;
+                    //        }
+                    //        else
+                    //        {
+                    //            model2.BoxCode = maxboxcode3.Substring(0, 28) + (int.Parse(maxboxcode3.Substring(28, 4)) + 1).ToString().PadLeft(4, '0');
+                    //            maxboxcode3 = model2.BoxCode;
+                    //        }
 
-        //                        model2.InspectTime = inspectTime;                     // 澶嶉獙鏈熻嚦
-        //                        model2.ExpirationTime = expirationTime;                  // 鏈夋晥鏈熻嚦/璐瓨鏈�
-        //                        model2.ExpirationType = good.GoodsTemp;                  // 璐瓨鏉′欢
-        //                        model2.Qty = d;                                                         // 鏁伴噺
+                    //        model2.imageStr = Utility.Extra.BarcodeHelper.GetQrCodeBase64(model2.BoxCode, 85, 85);
+                    //        // 娣诲姞鍒發ist闆嗗悎
 
-        //                        model2.QtyOrd = j;                                               // 绗嚑浠�
-        //                        if (maxboxcode3 == "")
-        //                        {
-        //                            var str = mesGood.PadRight(16, ' ') + model.LotNo.PadRight(12, ' ') + "0001";
-        //                            model2.BoxCode = str;                 // 鏀彿     鎵瑰彿+绗嚑绠�
-        //                            maxboxcode3 = model2.BoxCode;
-        //                        }
-        //                        else
-        //                        {
-        //                            model2.BoxCode = maxboxcode3.Substring(0, 28) + (int.Parse(maxboxcode3.Substring(28, 4)) + 1).ToString().PadLeft(4, '0');
-        //                            maxboxcode3 = model2.BoxCode;
-        //                        }
+                    //        if (printModel.Count(m => m.BoxCode.Length > 17) <= 100)//鎺掗櫎寰呯鐮佸垽鏂敮鐮佹槸鍚﹀皬浜�100
+                    //        {
+                    //            printModel.Add(model2);
+                    //        }
+                    //        var guid = Guid.NewGuid().ToString("N");
+                    //        // 灏嗘潯鐮佷繚瀛樺埌鍘熸枡鏉$爜琛�
+                    //        var LabelModel2 = new LabelPrint
+                    //        {
+                    //            LabelID = guid,
+                    //            LabelStream = model.BoxCode,
+                    //            BoxCode1 = model2.BoxCode,
+                    //            GoodsCode = model2.SkuNo,
+                    //            GoodsName = model2.SkuName,
+                    //            GoodsStandard = model2.Standard,
+                    //            ImportLotNo = model2.LotNo,
+                    //            SupplierName = model2.SupplierName,
+                    //            ImportId = model2.ImportId,
+                    //            OuterBillCode = model2.OuterBillCode,
+                    //            ImportBillCode = model2.ImportBillCode,
+                    //            ProductionDate = model2.ProductionDate,
+                    //            SapSkuNo = model2.SapSkuNo,
+                    //            Qty = model2.Qty,
+                    //            SupplierLot = model2.SupplierLot,
+                    //            InspectTime = model2.InspectTime,
+                    //            ExpirationTime = model2.ExpirationTime,
+                    //            QtyCount = model2.QtyCount,
+                    //            QtyOrd = model2.QtyOrd,
+                    //            ExpirationType = model2.ExpirationType,
+                    //            BoxNum = bNum,//model.Qty,
 
-        //                        model2.imageStr = Utility.Extra.BarcodeHelper.GetQrCodeBase64(model2.BoxCode, 85, 85);
-        //                        // 娣诲姞鍒發ist闆嗗悎
+                    //            BulkTank = model.Qty == bNum ? 0 : 1,//闆跺ご绠�
+                    //            BulkCase = 0,//闆跺ご鐩�
 
-        //                        if (printModel.Count(m => m.BoxCode.Length > 17) <= 100)//鎺掗櫎寰呯鐮佸垽鏂敮鐮佹槸鍚﹀皬浜�100
-        //                        {
-        //                            printModel.Add(model2);
-        //                        }
-        //                        var guid = Guid.NewGuid().ToString("N");
-        //                        // 灏嗘潯鐮佷繚瀛樺埌鍘熸枡鏉$爜琛�
-        //                        var LabelModel2 = new LabelPrint
-        //                        {
-        //                            LabelID = guid,
-        //                            LabelStream = model.BoxCode,
-        //                            BoxCode1 = model2.BoxCode,
-        //                            GoodsCode = model2.SkuNo,
-        //                            GoodsName = model2.SkuName,
-        //                            GoodsStandard = model2.Standard,
-        //                            ImportLotNo = model2.LotNo,
-        //                            SupplierName = model2.SupplierName,
-        //                            ImportId = model2.ImportId,
-        //                            OuterBillCode = model2.OuterBillCode,
-        //                            ImportBillCode = model2.ImportBillCode,
-        //                            ProductionDate = model2.ProductionDate,
-        //                            SapSkuNo = model2.SapSkuNo,
-        //                            Qty = model2.Qty,
-        //                            SupplierLot = model2.SupplierLot,
-        //                            InspectTime = model2.InspectTime,
-        //                            ExpirationTime = model2.ExpirationTime,
-        //                            QtyCount = model2.QtyCount,
-        //                            QtyOrd = model2.QtyOrd,
-        //                            ExpirationType = model2.ExpirationType,
-        //                            BoxNum = bNum,//model.Qty,
+                    //            CreateUser = createUser,
+                    //            CreateTime = DateTime.Now,
+                    //            IsUse = 0
+                    //        };
 
-        //                            BulkTank = model.Qty == bNum ? 0 : 1,//闆跺ご绠�
-        //                            BulkCase = 0,//闆跺ご鐩�
+                    //        DataContext.LabelPrint.InsertOnSubmit(LabelModel2);
+                    //    }
 
-        //                            CreateUser = createUser,
-        //                            CreateTime = DateTime.Now,
-        //                            IsUse = 0
-        //                        };
 
-        //                        DataContext.LabelPrint.InsertOnSubmit(LabelModel2);
-        //                    }
+                    //} 
 
+                    #endregion
+                }
 
-        //                }
-        //                DataContext.SubmitChanges();
+                //return printModel;
 
-        //                #endregion
-        //            }
 
-        //            return printModel;
-        //        }
-        //    }
-        //    catch (Exception ex)
-        //    {
-        //        throw new Exception(ex.Message);
-        //    }
-        //}
+                throw new NotImplementedException();
+            }
+            catch (Exception e)
+            { 
+                throw new Exception(e.Message);
+            }
+        }
 
 
     }

--
Gitblit v1.8.0