From 699fa153dbce0964f31cd73c8bfc5d1fe2f78ef2 Mon Sep 17 00:00:00 2001
From: yxj <yxj@hz-kingdee.com>
Date: 星期四, 20 十一月 2025 17:04:46 +0800
Subject: [PATCH] 新增器具调拨申请单模块所需调用方法,凯贝东方通信客户外箱码生成规则修改

---
 WarM/条码打印/Gy_BarCodeBill_automaticallyByPLC_New.cs |  113 +++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 86 insertions(+), 27 deletions(-)

diff --git "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs" "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs"
index e9bd5a0..6e4fbaa 100644
--- "a/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs"
+++ "b/WarM/\346\235\241\347\240\201\346\211\223\345\215\260/Gy_BarCodeBill_automaticallyByPLC_New.cs"
@@ -15,6 +15,8 @@
 using System.Management;
 using System.Net.NetworkInformation;
 using System.Printing;
+using WebAPI;
+using Newtonsoft.Json;
 
 namespace WarM
 {
@@ -424,21 +426,28 @@
             }
 
             this.Sub_SaveBill();
+            LogService.Write("==============================================================================================");
+            LogService.Write("鑾峰彇鎵撳嵃鍒楄〃銆�" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "銆�");
             Display();
+            LogService.Write("鑾峰彇鎵撳嵃鍒楄〃缁撴潫銆�" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "銆�");
+            LogService.Write("==============================================================================================");
 
-            //璁剧疆鎵撳嵃妯℃澘锛屾墦鍗�
-            grdList.Rows[0].Cells[0].Value = "*";
-            Report = new GridppReport();
-            Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf");  //here .
-            Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
-            Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
-            Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
-            if (comboBox_PrinterParams.Text != "")
+            if (radioButton_IsPrint_Yes.Checked == true)
             {
-                Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
+                //璁剧疆鎵撳嵃妯℃澘锛屾墦鍗�
+                grdList.Rows[0].Cells[0].Value = "*";
+                Report = new GridppReport();
+                Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf");  //here .
+                Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
+                Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
+                Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
+                if (comboBox_PrinterParams.Text != "")
+                {
+                    Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
+                }
+                Report.Print(false);
             }
-            Report.Print(false);
-
+            
             Display4();
         }
         //淇濆瓨鍗曟嵁
@@ -843,6 +852,7 @@
                         HWhID = ClsPub.isLong(grdSub.Rows[i].Cells[HWhID2Col].Value);
                         HSPID = ClsPub.isLong(grdSub.Rows[i].Cells[HSPID2Col].Value);
                         HRemark = ClsPub.isStrNull(grdSub.Rows[i].Cells[HRemark2Col].Value);
+                        HRemark = "PLC鑷姩鐢熸垚";
                         HMaterName = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterName2Col].Value);
                         HMaterModel = ClsPub.isStrNull(grdSub.Rows[i].Cells[HMaterModel2Col].Value);
                         HPinfan = ClsPub.isStrNull(grdSub.Rows[i].Cells[HPinfan2Col].Value);
@@ -949,14 +959,14 @@
                 string LIU = "";
                 int LEN = 4;
                 DataSet ds;
-                string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + HDate + "' order by 鎵瑰彿 desc";
+                string sql = "select * from h_v_IF_BarCodeBillList Where HMaterID = " + grdMain.Rows[0].Cells[HMaterIDCol].Value + " and HSTOCKORGID = " + HOrgID + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + HDate + "' and 澶囨敞 = 'PLC鑷姩鐢熸垚' order by 鎵瑰彿 desc";
                 ds = oCn.RunProcReturn(sql, "h_v_IF_BarCodeBillList");
                 if (ds != null)
                 {
                     long count = 0;
                     if (ds.Tables[0].Rows.Count > 0)
                     {
-                        count = ClsPub.isLong(ds.Tables[0].Rows[0]["鎵瑰彿"].ToString().Replace(sYear + sPeriod + sDay, ""));
+                        count = ClsPub.isLong(ds.Tables[0].Rows[0]["鎵瑰彿"].ToString().Replace(sYear + sPeriod + sDay+" ", ""));
                     }
                     LIU += count + 1;
                     while (LIU.Length < LEN)  //濡傛灉娴佹按鍙峰皬浜�6浣嶆暟鍓嶉潰琛�0
@@ -970,7 +980,7 @@
                 }
 
                 //鎷兼帴鎵瑰彿
-                HBatchNo = sYear + sPeriod + sDay + LIU;
+                HBatchNo = sYear + sPeriod + sDay+" " + LIU;
             }
 
 
@@ -1035,7 +1045,29 @@
             //鎷兼帴鎵瑰彿
             HBarCode_MaxNo = sYear + sPeriod + sDay + LIU;
 
-            return HBarCode_MaxNo;
+            long HBarCode_MaxNo_long = long.Parse(HBarCode_MaxNo);
+
+            while (true)
+            {
+                int HCount_BarCodeBillList = 0;
+                int HCount_SubBarCodeBill = 0;
+                string sql_confirm = "select * from h_v_IF_BarCodeBillList where 鏉$爜缂栧彿 = '" + (ClsPub.isStrNull(grdSub.Rows[0].Cells[HMaterModel2Col].Value) + HBarCode_MaxNo_long.ToString()) + "' and 鏉$爜绫诲瀷 = '鍞竴鏉$爜'" + " and CONVERT(varchar(100),鏉$爜鏃ユ湡, 23) = '" + HDate + "'";
+                ds = oCn.RunProcReturn(sql_confirm, "h_v_IF_BarCodeBillList");
+                HCount_BarCodeBillList = ds.Tables[0].Rows.Count;
+                sql_confirm = "select * from Gy_BarCodeBill_SWELL_SubBarCodeBill Where HBarCode = '" + (ClsPub.isStrNull(grdSub.Rows[0].Cells[HMaterModel2Col].Value) + HBarCode_MaxNo_long.ToString()) + "' and HBarCodeType = '鍞竴鏉$爜'" + " and CONVERT(varchar(100),HMakeDate, 23) = '" + HDate + "'";
+                ds = oCn.RunProcReturn(sql_confirm, "Gy_BarCodeBill_SWELL_SubBarCodeBill");
+                HCount_SubBarCodeBill = ds.Tables[0].Rows.Count;
+                if (HCount_BarCodeBillList + HCount_SubBarCodeBill > 0)
+                {
+                    HBarCode_MaxNo_long += 1;
+                }
+                else
+                {
+                    break;
+                }
+            }
+
+            return HBarCode_MaxNo_long.ToString();
         }
         #endregion
 
@@ -1205,7 +1237,7 @@
                 if (!clearPrinterTask(ref msg))
                 {
                     MessageBox.Show(msg);
-                    return;
+                    produceQty = 0;
                 }
             }
 
@@ -1215,20 +1247,27 @@
                 this.Sub_SaveBill();
 
                 //鑾峰彇闇�瑕佹墦鍗扮殑鏁版嵁
+                LogService.Write("==============================================================================================");
+                LogService.Write("鑾峰彇鎵撳嵃鍒楄〃銆�" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "銆�");
                 Display();
+                LogService.Write("鑾峰彇鎵撳嵃鍒楄〃缁撴潫銆�" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "銆�");
+                LogService.Write("==============================================================================================");
 
-                //璁剧疆鎵撳嵃妯℃澘锛屾墦鍗�
-                grdList.Rows[0].Cells[0].Value = "*";
-                Report = new GridppReport();
-                Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf");  //here .
-                Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
-                Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
-                Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
-                if (comboBox_PrinterParams.Text != "")
+                if (radioButton_IsPrint_Yes.Checked == true)
                 {
-                    Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
+                    //璁剧疆鎵撳嵃妯℃澘锛屾墦鍗�
+                    grdList.Rows[0].Cells[0].Value = "*";
+                    Report = new GridppReport();
+                    Report.LoadFromFile(DBUtility.ClsPub.AppPath + @"\" + textBox_PrintModelParams.Text + ".grf");  //here .
+                    Report.BeforePostRecord += new _IGridppReportEvents_BeforePostRecordEventHandler(ReportBeforePostRecord);
+                    Report.FetchRecord += new _IGridppReportEvents_FetchRecordEventHandler(ReportFetchRecordByDataTable);
+                    Report.PrintEnd += new _IGridppReportEvents_PrintEndEventHandler(ReportPrintEnd);
+                    if (comboBox_PrinterParams.Text != "")
+                    {
+                        Report.Printer.PrinterName = comboBox_PrinterParams.Text.Replace("(榛樿)", "");
+                    }
+                    Report.Print(false);
                 }
-                Report.Print(false);
 
                 if (i == produceQty - 1)
                 {
@@ -1243,6 +1282,8 @@
         //鑾峰彇闇�瑕佹墦鍗扮殑鏁版嵁骞跺瓨鏀惧湪瀛愯〃grdList
         private void Display()
         {
+            LogService.Write("鎵撳嵃鍒楄〃鎼滅储璇彞锛氥�恠elect * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " order by HItemID銆�");
+
             //璁剧疆妗f鍒楄〃閫夐」鍗¤〃鏍兼暟鎹�
             DataSet DSet = oCn.RunProcReturn("select * from h_v_IF_BarCodeBillList Where HinterID=" + HInterID.ToString() + " order by HItemID", "h_v_IF_BarCodeBillList", ref DBUtility.ClsPub.sExeReturnInfo);
             //鐢熸垚棣栬鏍囬
@@ -1259,6 +1300,8 @@
             DBUtility.Xt_BaseBillFun.DisplayGrid(grdList, this.Name + "grdList", s, FrCol);
             //鐢荤嚎
             //GraphLine();
+
+            LogService.Write("鎵撳嵃鍒楄〃鏁版嵁锛氥��" + JsonConvert.SerializeObject(DSet.Tables[0]) + "銆�");
         }
 
         //鑾峰彇宸ュ崟褰撳ぉ鐗╂枡鐢熸垚鐨勬潯鐮佽褰�
@@ -2215,6 +2258,7 @@
                 {
                     sMoney = ClsPub.isDoule(grdMain.Rows[sRow].Cells[HQtyCol].Value) / ClsPub.isDoule(grdMain.Rows[sRow].Cells[HMinQtyCol].Value);
                 }
+                sMoney = Math.Round(sMoney, 10);    // 淇濈暀10浣嶅皬鏁拌繘琛屽洓鑸嶄簲鍏�
                 sMoney = Math.Ceiling(sMoney);
                 grdMain.Rows[sRow].Cells[HBQtyCol].Value = sMoney;
             }
@@ -2514,6 +2558,21 @@
         #endregion
         #endregion
 
-        
+        #region 寤虹珛閫氳鍚庯紝涓嶆柇鍚戞湇鍔″櫒鍙戦�佹暟鎹紝鐢ㄤ簬甯姪鏈嶅姟绔‘瀹氳繛鎺ョ姸鎬�
+        private void timer4_Tick(object sender, EventArgs e)
+        {
+            if (getTargetInternetStatus()&& socket!=null && socket.Connected)
+            {
+                try
+                {
+                    socket.Send(Encoding.ASCII.GetBytes("1"));
+                }
+                catch (Exception ex)
+                {
+
+                }
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1