Quellcode durchsuchen

大件水件辅件对接

qinqi vor 2 Jahren
Ursprung
Commit
b5e6040c6c
2 geänderte Dateien mit 246 neuen und 0 gelöschten Zeilen
  1. 123 0
      wwwroot/api/plc/plc_led_goodslogo_dj.ashx
  2. 123 0
      wwwroot/api/plc/plc_led_goodslogo_dj2.ashx

+ 123 - 0
wwwroot/api/plc/plc_led_goodslogo_dj.ashx

@@ -0,0 +1,123 @@
+<%@ WebHandler Language="C#" Class="plc_led_goodslogo_dj" %>
+
+using System;
+using System.Web;
+using DK.XuWei.WebMes;
+using Curtain.DataAccess;
+using Curtain.Log;
+using System.Data;
+
+
+/// <summary>
+/// 对接包装LED 扫描产品提示对应辅件
+/// xuwei
+/// 2023-10-23
+/// </summary>
+public class plc_led_goodslogo_dj : IHttpHandler
+{
+    public struct LedData
+    {
+        public int goodscode;
+        public int goodsspecification;
+        public int goodstype;
+        public string barcode;
+    }
+
+    //输入参数 【条码】
+    public string barCode = "";
+
+    public void ProcessRequest(HttpContext context)
+    {
+        try
+        {
+            context.Response.ContentType = "text/plain";
+            //输入产品条码参数
+            barCode = context.Request["barcode"] is object ? context.Request["barcode"] : "";
+
+            DataTable infoDt = new DataTable();
+            //写入PLC
+            //正式
+            SiemensS7.Open("172.19.26.237", 102);
+
+            if (context.Request["barcode"] is object)
+            {
+                using (IDataAccess conn = DataAccess.Create())
+                {
+                    infoDt = conn.ExecuteDatatable(@"
+                            SELECT
+                                TPGL.BARCODE,
+                                TPGL.GOODSCODE,
+	                            TMA.GOODSID,
+	                            TMA.LOGOID,
+	                            TMA.ACCESSORIESNAME,
+	                            TMA.ACCESSORIESCODE,
+	                            TMD.DICTIONARYVALUE
+                            FROM
+	                            TP_PM_GROUTINGDAILYDETAIL TPGL
+	                            LEFT JOIN TP_MST_ACCESSORIES TMA ON TPGL.LOGOID = TMA.LOGOID 
+                                AND TMA.GOODSID = TPGL.GOODSID
+                                LEFT JOIN TP_MST_DATADICTIONARY TMD ON TMA.ACCESSORIESTYPEID = TMD.DICTIONARYID
+                            WHERE  TMA.VALUEFLAG = 1
+                                AND TMD.VALUEFLAG = 1 
+                                AND TMD.DICTIONARYVALUE = '水件'
+                                AND TPGL.BARCODE = @barcode@
+                            ",
+                        new CDAParameter("barcode", context.Request["barcode"])
+                    );
+                    if (infoDt != null && infoDt.Rows.Count > 0 && infoDt.Rows[0] != null)
+                    {
+                        SiemensS7.Write<short>("100.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"])); 
+                        SiemensS7.Write<string>("100.6", infoDt.Rows[0]["BARCODE"].ToString());
+                        SiemensS7.Write<string>("100.20", infoDt.Rows[0]["GOODSCODE"].ToString());
+
+                        //写标识位-扫描结果
+                        SiemensS7.Write<short>("100.0", Convert.ToInt16(1));
+                    }
+
+                    context.Response.Write(SiemensS7.Read<short>("100.0"));
+                    context.Response.Write(SiemensS7.Read<short>("100.2"));
+                    context.Response.Write(SiemensS7.Read<string>("100.6",11));
+                    context.Response.Write(SiemensS7.Read<string>("100.20",11));
+
+
+                    if (Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]) != Convert.ToInt16(SiemensS7.Read<short>("100.2"))
+                            || Convert.ToInt16(1) != Convert.ToInt16(SiemensS7.Read<short>("100.0")))
+                    {
+                        SiemensS7.Write<short>("100.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"])); 
+                        SiemensS7.Write<string>("100.6", infoDt.Rows[0]["BARCODE"].ToString());
+                        SiemensS7.Write<string>("100.20", infoDt.Rows[0]["GOODSCODE"].ToString());
+
+                        //写标识位-扫描结果
+                        SiemensS7.Write<short>("100.0", Convert.ToInt16(1));
+                    }
+                    Logger.Info("写入数据完成!barcode:" + context.Request["barcode"].ToString() + "4位数据位:" + SiemensS7.Read<short>("100.0") + ",辅件编码:" + SiemensS7.Read<short>("100.2")
+                        + ",条码:" + SiemensS7.Read<string>("100.6",11)+ ",产品编码:" + SiemensS7.Read<string>("100.20",11)  + ";数据:" + new JsonResult(infoDt).ToJson());
+                }
+            }
+            else
+            {
+                //写标识位-扫描结果
+                //SiemensS7.Write<short>("400.0", Convert.ToInt16(2));
+                //context.Response.Write(SiemensS7.Read<short>("400.0"));
+                //Logger.Info("无条码!");
+            }
+
+            context.Response.Write(new JsonResult(infoDt).ToJson());
+            SiemensS7.Close();
+        }
+        catch (Exception ex)
+        {
+            Logger.Info("异常!:" + ex);
+            throw ex;
+        }
+    }
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}

+ 123 - 0
wwwroot/api/plc/plc_led_goodslogo_dj2.ashx

@@ -0,0 +1,123 @@
+<%@ WebHandler Language="C#" Class="plc_led_goodslogo_dj2" %>
+
+using System;
+using System.Web;
+using DK.XuWei.WebMes;
+using Curtain.DataAccess;
+using Curtain.Log;
+using System.Data;
+
+
+/// <summary>
+/// 对接包装LED 扫描产品提示对应辅件
+/// xuwei
+/// 2023-10-23
+/// </summary>
+public class plc_led_goodslogo_dj2 : IHttpHandler
+{
+    public struct LedData
+    {
+        public int goodscode;
+        public int goodsspecification;
+        public int goodstype;
+        public string barcode;
+    }
+
+    //输入参数 【条码】
+    public string barCode = "";
+
+    public void ProcessRequest(HttpContext context)
+    {
+        try
+        {
+            context.Response.ContentType = "text/plain";
+            //输入产品条码参数
+            barCode = context.Request["barcode"] is object ? context.Request["barcode"] : "";
+
+            DataTable infoDt = new DataTable();
+            //写入PLC
+            //正式
+            SiemensS7.Open("172.19.26.237", 102);
+
+            if (context.Request["barcode"] is object)
+            {
+                using (IDataAccess conn = DataAccess.Create())
+                {
+                    infoDt = conn.ExecuteDatatable(@"
+                            SELECT
+                                TPGL.BARCODE,
+                                TPGL.GOODSCODE,
+	                            TMA.GOODSID,
+	                            TMA.LOGOID,
+	                            TMA.ACCESSORIESNAME,
+	                            TMA.ACCESSORIESCODE,
+	                            TMD.DICTIONARYVALUE
+                            FROM
+	                            TP_PM_GROUTINGDAILYDETAIL TPGL
+	                            LEFT JOIN TP_MST_ACCESSORIES TMA ON TPGL.LOGOID = TMA.LOGOID 
+                                AND TMA.GOODSID = TPGL.GOODSID
+                                LEFT JOIN TP_MST_DATADICTIONARY TMD ON TMA.ACCESSORIESTYPEID = TMD.DICTIONARYID
+                            WHERE  TMA.VALUEFLAG = 1
+                                AND TMD.VALUEFLAG = 1 
+                                AND TMD.DICTIONARYVALUE = '水件'
+                                AND TPGL.BARCODE = @barcode@
+                            ",
+                        new CDAParameter("barcode", context.Request["barcode"])
+                    );
+                    if (infoDt != null && infoDt.Rows.Count > 0 && infoDt.Rows[0] != null)
+                    {
+                        SiemensS7.Write<short>("101.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"])); 
+                        SiemensS7.Write<string>("101.6", infoDt.Rows[0]["BARCODE"].ToString());
+                        SiemensS7.Write<string>("101.20", infoDt.Rows[0]["GOODSCODE"].ToString());
+
+                        //写标识位-扫描结果
+                        SiemensS7.Write<short>("101.0", Convert.ToInt16(1));
+                    }
+
+                    context.Response.Write(SiemensS7.Read<short>("101.0"));
+                    context.Response.Write(SiemensS7.Read<short>("101.2"));
+                    context.Response.Write(SiemensS7.Read<string>("101.6",11));
+                    context.Response.Write(SiemensS7.Read<string>("101.20",11));
+
+
+                    if (Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"]) != Convert.ToInt16(SiemensS7.Read<short>("101.2"))
+                            || Convert.ToInt16(1) != Convert.ToInt16(SiemensS7.Read<short>("101.0")))
+                    {
+                        SiemensS7.Write<short>("101.2", Convert.ToInt16(infoDt.Rows[0]["ACCESSORIESCODE"])); 
+                        SiemensS7.Write<string>("101.6", infoDt.Rows[0]["BARCODE"].ToString());
+                        SiemensS7.Write<string>("101.20", infoDt.Rows[0]["GOODSCODE"].ToString());
+
+                        //写标识位-扫描结果
+                        SiemensS7.Write<short>("101.0", Convert.ToInt16(1));
+                    }
+                    Logger.Info("写入数据完成!barcode:" + context.Request["barcode"].ToString() + "4位数据位:" + SiemensS7.Read<short>("101.0") + ",辅件编码:" + SiemensS7.Read<short>("101.2")
+                        + ",条码:" + SiemensS7.Read<string>("101.6",11)+ ",产品编码:" + SiemensS7.Read<string>("101.20",11)  + ";数据:" + new JsonResult(infoDt).ToJson());
+                }
+            }
+            else
+            {
+                //写标识位-扫描结果
+                //SiemensS7.Write<short>("400.0", Convert.ToInt16(2));
+                //context.Response.Write(SiemensS7.Read<short>("400.0"));
+                //Logger.Info("无条码!");
+            }
+
+            context.Response.Write(new JsonResult(infoDt).ToJson());
+            SiemensS7.Close();
+        }
+        catch (Exception ex)
+        {
+            Logger.Info("异常!:" + ex);
+            throw ex;
+        }
+    }
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}