| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- <%@ WebHandler Language="C#" Class="plc_led_data_old" %>
- using System;
- using System.Web;
- using System.Collections.Generic;
- using Curtain.Net.Sockets;
- using DK.XuWei.WebMes;
- using Curtain.DataAccess;
- using Curtain.Log;
- using System.Data;
- /// <summary>
- /// 对接LED看板,用于成检显示产品属性信息
- /// xuwei
- /// 2023-08-08
- /// </summary>
- public class plc_led_data_old : IHttpHandler
- {
- public struct LedData
- {
- public int goodscode;
- public int goodsspecification;
- public int goodstype;
- public string barcode;
- }
- public void ProcessRequest(HttpContext context)
- {
- context.Response.ContentType = "text/plain";
- List<LedData> ledData = new List<LedData>();
- int scanFlag = 0;
- //写入PLC
- //SiemensS7.Open("172.19.26.241", 102);
- ////移位标识
- //int moveFlag = Convert.ToInt16(SiemensS7.Read<short>("1.2"));
- //context.Response.Write(SiemensS7.Read<short>("1.2"));
- //context.Response.Write(moveFlag);
- //Logger.Info("moveFlag: " + moveFlag +" ;barcode: " + context.Request["barcode"]);
- //if (context.Application["led_data"] is object)
- //{
- // ledData = (List<LedData>)context.Application["led_data"];
- //}
- ////条码转换生产数据
- //if (moveFlag == 1 && ledData.Count > 0)
- //{
- // ledData.RemoveAt(0);
- // //写业务数据
- // if (ledData.Count > 0)
- // {
- // for (int i = 0; i < ledData.Count; i++)
- // {
- // if (i == 0)
- // {
- // SiemensS7.Write<short>("1.6", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.8", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.10", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.14", ledData[i].barcode);
- // }
- // //context.Response.Write(SiemensS7.Read<string>("1.14",11));
- // if (i == 1)
- // {
- // SiemensS7.Write<short>("1.26", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.28", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.30", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.34", ledData[i].barcode);
- // }
- // if (i == 2)
- // {
- // SiemensS7.Write<short>("1.46", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.48", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.50", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.54", ledData[i].barcode);
- // }
- // if (i == 3)
- // {
- // SiemensS7.Write<short>("1.66", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.68", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.70", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.74", ledData[i].barcode);
- // }
- // if (i == 4)
- // {
- // SiemensS7.Write<short>("1.86", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.88", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.90", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.94", ledData[i].barcode);
- // }
- // }
- // }
- // else
- // {
- // //写业务数据
- // SiemensS7.Write<short>("1.6", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.8", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.10", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.14", "00000000000");
- // SiemensS7.Write<short>("1.26", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.28", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.30", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.34", "00000000000");
- // SiemensS7.Write<short>("1.46", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.48", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.50", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.54", "00000000000");
- // SiemensS7.Write<short>("1.66", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.68", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.70", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.74", "00000000000");
- // SiemensS7.Write<short>("1.86", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.88", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.90", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.94", "00000000000");
- // }
- // //写标识位-扫描结果
- // SiemensS7.Write<short>("1.0", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.2", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.4", Convert.ToInt16(1));
- // context.Application["led_data"] = ledData;
- //}
- //else if (moveFlag == 2)
- //{
- // ledData = new List<LedData>();
- // //写业务数据
- // SiemensS7.Write<short>("1.6", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.8", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.10", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.14", "00000000000");
- // SiemensS7.Write<short>("1.26", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.28", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.30", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.34", "00000000000");
- // SiemensS7.Write<short>("1.46", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.48", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.50", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.54", "00000000000");
- // SiemensS7.Write<short>("1.66", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.68", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.70", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.74", "00000000000");
- // SiemensS7.Write<short>("1.86", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.88", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.90", Convert.ToInt16(0));
- // SiemensS7.Write<string>("1.94", "00000000000");
- // //写标识位-扫描结果
- // SiemensS7.Write<short>("1.0", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.2", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.4", Convert.ToInt16(1));
- // context.Application["led_data"] = ledData;
- //}
- //else if (moveFlag == 0)
- //{
- // if (context.Request["barcode"] is object)
- // {
- // using (IDataAccess conn = DataAccess.Create())
- // {
- // DataTable infoDt = conn.ExecuteDatatable(@"
- // SELECT lgi.ledgoodsid
- // ,CASE
- // WHEN instr(g.goodsspecification, '305') = 1 THEN 1
- // WHEN instr(g.goodsspecification, '400') = 1 THEN 2
- // WHEN instr(g.goodsspecification, '地排') = 1 THEN 3
- // WHEN instr(g.goodsspecification, '横排') = 1 THEN 4
- // END AS goodsspecification
- // ,CASE
- // WHEN instr(gt.goodstypename, '连体') = 1 THEN 1
- // WHEN instr(gt.goodstypename, '智能') = 1 THEN 2
- // END AS goodstypename
- // ,gdd.barcode
- // FROM tp_pm_groutingdailydetail gdd
- // LEFT JOIN tp_mst_goods g
- // ON gdd.goodsid = g.goodsid
- // LEFT JOIN tp_mst_goodstype gt
- // ON gt.goodstypeid = g.goodstypeid
- // LEFT JOIN tp_mst_ledgoodsinfo lgi
- // ON lgi.goodscode = g.goodscode
- // WHERE gdd.barcode = @barcode@
- // ",
- // new CDAParameter("barcode", context.Request["barcode"])
- // );
- // if (infoDt != null && infoDt.Rows.Count > 0 && infoDt.Rows[0] != null)
- // {
- // if (ledData.Count < 5)
- // {
- // //for (int i = 0; i < ledData.Count; i++)
- // //{
- // // if (ledData[i].barcode == infoDt.Rows[0]["barcode"].ToString())
- // // {
- // // scanFlag = 1;
- // // }
- // //}
- // if (scanFlag == 0)
- // {
- // ledData.Add(new LedData()
- // {
- // goodscode = Convert.ToInt32(infoDt.Rows[0]["ledgoodsid"]),
- // goodsspecification = Convert.ToInt32(infoDt.Rows[0]["goodsspecification"]),
- // goodstype = Convert.ToInt32(infoDt.Rows[0]["goodstypename"]),
- // barcode = infoDt.Rows[0]["barcode"].ToString()
- // });
- // }
- // }
- // else
- // {
- // scanFlag = 1;
- // }
- // }
- // }
- // context.Application["led_data"] = ledData;
- // if (scanFlag == 0) {
- // //写业务数据
- // for (int i = 0; i < ledData.Count; i++)
- // {
- // if (i == 0)
- // {
- // SiemensS7.Write<short>("1.6", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.8", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.10", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.14", ledData[i].barcode);
- // }
- // //context.Response.Write(SiemensS7.Read<string>("1.14",11));
- // if (i == 1)
- // {
- // SiemensS7.Write<short>("1.26", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.28", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.30", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.34", ledData[i].barcode);
- // }
- // if (i == 2)
- // {
- // SiemensS7.Write<short>("1.46", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.48", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.50", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.54", ledData[i].barcode);
- // }
- // if (i == 3)
- // {
- // SiemensS7.Write<short>("1.66", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.68", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.70", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.74", ledData[i].barcode);
- // }
- // if (i == 4)
- // {
- // SiemensS7.Write<short>("1.86", Convert.ToInt16(ledData[i].goodscode));
- // SiemensS7.Write<short>("1.88", Convert.ToInt16(ledData[i].goodsspecification));
- // SiemensS7.Write<short>("1.90", Convert.ToInt16(ledData[i].goodstype));
- // SiemensS7.Write<string>("1.94", ledData[i].barcode);
- // }
- // }
- // //写标识位-扫描结果
- // SiemensS7.Write<short>("1.0", Convert.ToInt16(1));
- // SiemensS7.Write<short>("1.2", Convert.ToInt16(0));
- // SiemensS7.Write<short>("1.4", Convert.ToInt16(0));
- // }
- // else if (scanFlag == 1)
- // {
- // //写标识位-扫描结果
- // SiemensS7.Write<short>("1.0", Convert.ToInt16(2));
- // SiemensS7.Write<short>("1.2", Convert.ToInt16(0));
- // }
- // }
- // else
- // {
- // //写标识位-扫描结果
- // SiemensS7.Write<short>("1.0", Convert.ToInt16(2));
- // }
- //}
- //context.Response.Write(new JsonResult(ledData).ToJson());
- //SiemensS7.Close();
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
|