From 5231a00695cfd27cf320a4e19a0c1417cb99128d Mon Sep 17 00:00:00 2001
From: Demo <Demo@DESKTOP-CPA90BF>
Date: 星期二, 20 二月 2024 10:23:16 +0800
Subject: [PATCH] 修改标签逻辑兼容余料退回单据,修改PDA绑定数量有误问题

---
 Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs |   67 +++++++++++++++------
 HTML/views/ASNSetting/ArrivalNotice.html     |   43 ++++++++++++++
 Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs     |    4 +
 HTML/views/ASNSetting/LabelPrintSelect.html  |   11 +++
 4 files changed, 102 insertions(+), 23 deletions(-)

diff --git a/HTML/views/ASNSetting/ArrivalNotice.html b/HTML/views/ASNSetting/ArrivalNotice.html
index 4a21c98..3c07fab 100644
--- a/HTML/views/ASNSetting/ArrivalNotice.html
+++ b/HTML/views/ASNSetting/ArrivalNotice.html
@@ -310,9 +310,13 @@
 									html = `<a class="layui-btn layui-btn-danger layui-btn-xs delClass" lay-event="del"> 
 										<i class="layui-icon layui-icon-delete"></i>鍒犻櫎</a>`; 
 								}
-								if((d.AsnType =="1" || d.AsnType == "4") && (d.Status == "0" || d.Status == "1")){  
+								if(d.AsnType =="1" && (d.Status == "0" || d.Status == "1")){  
 									html += `<a class="layui-btn layui-btn-normal layui-btn-xs addLabelClass" lay-event="Addlabel"> 
 										<i class="layui-icon layui-icon-edit"></i>鐢熸垚鏍囩</a>`; 
+								}
+								if(d.AsnType == "4"&& (d.Status == "0" || d.Status == "1")){
+									html += `<a class="layui-btn layui-btn-normal layui-btn-xs addLabelClass" lay-event="Addlabel2"> 
+										<i class="layui-icon layui-icon-edit"></i>鐢熸垚鏍囩</a>`;
 								}
 								return html;
 							} 
@@ -1220,6 +1224,43 @@
 						});
 
 						break;
+					case "Addlabel2" :
+						layer.open({
+							type: 2,
+							title: '鐢熸垚鏍囩',
+							content: 'LabelPrintSelect.html?Id='+id+'&Type=4',
+							maxmin: true,
+							area: ['480px', '615px'],
+							btn: ['纭畾','鍙栨秷'],
+							yes: function(index, layero){
+								var iframeWindow = window['layui-layer-iframe'+ index]
+								,submitID = 'layuiadmin-app-form-edit'
+								,submit = layero.find('iframe').contents().find('#'+ submitID);
+								//鐩戝惉鎻愪氦
+								iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
+									var field = data.field; //鑾峰彇鎻愪氦鐨勫瓧娈�
+									console.log(field);
+									//鎻愪氦 Ajax 鎴愬姛鍚庯紝闈欐�佹洿鏂拌〃鏍间腑鐨勬暟鎹�
+									//"&Level="+field.level+"&Type="+field.type+"&BoxType="+field.boxType+"&Qty="+field.qty+
+									var str = "Id="+id+"&IsReset="+field.reset+"&ArriveQty="+field.arriveQty+"&ProductionTime="+field.productionTime+"&ExpirationTime="+field.expirationTime+"&StoreTime="+field.storeTime;
+									
+									layer.open({
+										type: 2,
+										title: '鐢熸垚鏍囩',
+										content: 'LabelPrint.html?'+str,
+										maxmin: true,
+										area: ['660px', '660px'],
+										btn: ['鍙栨秷'],
+										
+
+									});
+								});  
+								submit.trigger('click');
+							}
+
+						});
+
+						break;
 					default:break;
 				}
 			});
diff --git a/HTML/views/ASNSetting/LabelPrintSelect.html b/HTML/views/ASNSetting/LabelPrintSelect.html
index b8a6829..b2efa30 100644
--- a/HTML/views/ASNSetting/LabelPrintSelect.html
+++ b/HTML/views/ASNSetting/LabelPrintSelect.html
@@ -116,7 +116,16 @@
                     });
 
 					var id = getQueryString('Id');
-					
+					var asnType = getQueryString('Type');
+					console.log(asnType);
+					console.log(asnType == 4);
+					if(asnType == 4){
+
+						$("#reset option[value='0']").attr("selected","selected"); //鎬у埆
+						$("#reset").attr("disabled","disabled"); 
+						form.render('select');
+					}
+
 					var param = {
 						id: parseInt(id),
 					};
diff --git a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
index 9c0ad7a..34dfa59 100644
--- a/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
+++ b/Wms/WMS.BLL/BllAsnServer/BllBoxInfoServer.cs
@@ -618,7 +618,7 @@
                 {
                     throw new Exception("鍒拌揣鏁伴噺涓嶈兘灏忎簬0!");
                 }
-
+                Db.BeginTran();
                 if (packLevel == 1)
                 {
                     #region 涓�绾у寘瑁�
@@ -664,17 +664,31 @@
                     
                     if (isReset == "0")
                     {
-                        var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
-                        if (labelCount.Count <=0)
+                        //鍒ゆ柇鍗曟嵁鏄惁鏄綑鏂欓��鍥炲崟
+                        if (asn.Type == "4")
                         {
-                            throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
+                            maxLotNoStr = asnList.LotNo;
+                            maxBoxCode = label.Where(m=>m.LotNo == maxLotNoStr).Max(a => a.BoxNo);
+                            if (string.IsNullOrWhiteSpace(maxLotNoStr))
+                            {
+                                throw new Exception("杞﹂棿浣欐枡閫�鍥炲崟鎹壒娆′笉鑳戒负绌�");
+                            }
                         }
-                        maxLotNoStr = label.Max(a => a.LotNo);
-                        maxBoxCode = label.Max(a => a.BoxNo);
-                        if (string.IsNullOrWhiteSpace(maxLotNoStr))
+                        else
                         {
-                            maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
+                            var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
+                            if (labelCount.Count <= 0)
+                            {
+                                throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
+                            }
+                            maxLotNoStr = label.Max(a => a.LotNo);
+                            maxBoxCode = label.Max(a => a.BoxNo);
+                            if (string.IsNullOrWhiteSpace(maxLotNoStr))
+                            {
+                                maxLotNoStr = toDayTime.Substring(2, 6) + "0001";
+                            }
                         }
+                        
                     }
                     else
                     {
@@ -814,21 +828,33 @@
                     string toDayTime2 = DateTime.Now.ToString("yyyyMMdd");
                     if (isReset == "0")
                     {
-                        var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
-                        if (labelCount.Count <= 0)
+                        //鍒ゆ柇鍗曟嵁鏄惁鏄綑鏂欓��鍥炲崟
+                        if (asn.Type == "4")
                         {
-                            throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
+                            maxCodestr2 = asnList.LotNo;
+                            maxboxcode2 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo);
+                            maxboxcode3 = label.Where(m => m.LotNo == maxCodestr2).Max(a => a.BoxNo3);//鏀彿
+                            if (string.IsNullOrWhiteSpace(maxCodestr2))
+                            {
+                                throw new Exception("杞﹂棿浣欐枡閫�鍥炲崟鎹壒娆′笉鑳戒负绌�");
+                            }
                         }
-                        var maxCode = label.Max(a => a.LotNo);
-                        var boxCode1 = label.Max(a => a.BoxNo);//绠卞彿
-                        var boxCode2 = label.Max(a => a.BoxNo3);//鏀彿
-                        maxCodestr2 = maxCode;
-                        maxboxcode2 = boxCode1;
-                        maxboxcode3 = boxCode2;
-                        if (string.IsNullOrWhiteSpace(maxCodestr2))
+                        else
                         {
-                            maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
+                            var labelCount = label.Where(m => m.ASNDetailNo == imId).ToList();
+                            if (labelCount.Count <= 0)
+                            {
+                                throw new Exception("褰撳墠鍗曟嵁鏄庣粏杩樻湭鐢熸垚鏍囩锛岃閫夋嫨閲嶇疆鎵规閫夐」涓衡�樻槸鈥欙紱");
+                            }
+                            maxCodestr2 = label.Max(a => a.LotNo); ;
+                            maxboxcode2 = label.Max(a => a.BoxNo);//绠卞彿;
+                            maxboxcode3 = label.Max(a => a.BoxNo3);//鏀彿;
+                            if (string.IsNullOrWhiteSpace(maxCodestr2))
+                            {
+                                maxCodestr2 = toDayTime2.Substring(2, 6) + "0001";
+                            }
                         }
+                        
                     }
                     else
                     {
@@ -988,7 +1014,7 @@
                         Db.Updateable(asnList).ExecuteCommand();
                     } 
                 }
-                
+                Db.CommitTran();
                 return modelList;
 
 
@@ -996,6 +1022,7 @@
             }
             catch (Exception e)
             {
+                Db.RollbackTran();
                 throw new Exception(e.Message);
             }
         }
diff --git a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
index 37514c7..51103b6 100644
--- a/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
+++ b/Wms/WMS.BLL/BllPdaServer/PdaAsnServer.cs
@@ -1916,6 +1916,7 @@
                         throw new Exception("-1:褰撳墠鎵樼洏姝e湪鎵ц涓紝缁戝畾澶辫触锛岃鏍稿疄!");
                     }
                     bindId = bind.Id;
+                    bind.Qty += model.SkuQty;
                 }
 
                 #region 绠辩爜淇℃伅
@@ -1950,6 +1951,7 @@
 
                 // 鏇存敼绠辨敮鍏崇郴琛�
                 decimal factQty = 0.00m;//鎵樼洏鎬绘暟閲�
+                //鎴愬搧缁勬墭
                 if (model.SkuQty == 0)
                 {
                     var boxGroup = boxInfoList.GroupBy(m => m.BoxNo).ToList();
@@ -2009,7 +2011,7 @@
                 var sqlString = string.Empty;
                 if (factQty == 0)
                 {
-                    sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{bind.Qty}' where id = '{model.AsnDetailId}';";
+                    sqlString += $"update BllArrivalNoticeDetail set FactQty = FactQty + '{model.SkuQty}' where id = '{model.AsnDetailId}';";
                 }
                 else
                 {

--
Gitblit v1.8.0