xuwei 3 tahun lalu
induk
melakukan
e98b8dc307

+ 1 - 0
.gitignore

@@ -108,3 +108,4 @@ _UpgradeReport_Files/
 Backup*/
 UpgradeLog*.XML
 
+/.vs

+ 41 - 0
IMEX.mes.api.sln

@@ -0,0 +1,41 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.32929.386
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "wwwroot", "wwwroot\", "{DB74DD9E-F84B-4372-A298-41376272D607}"
+	ProjectSection(WebsiteProperties) = preProject
+		TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.0"
+		Debug.AspNetCompiler.VirtualPath = "/localhost_62172"
+		Debug.AspNetCompiler.PhysicalPath = "wwwroot\"
+		Debug.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_62172\"
+		Debug.AspNetCompiler.Updateable = "true"
+		Debug.AspNetCompiler.ForceOverwrite = "true"
+		Debug.AspNetCompiler.FixedNames = "false"
+		Debug.AspNetCompiler.Debug = "True"
+		Release.AspNetCompiler.VirtualPath = "/localhost_62172"
+		Release.AspNetCompiler.PhysicalPath = "wwwroot\"
+		Release.AspNetCompiler.TargetPath = "PrecompiledWeb\localhost_62172\"
+		Release.AspNetCompiler.Updateable = "true"
+		Release.AspNetCompiler.ForceOverwrite = "true"
+		Release.AspNetCompiler.FixedNames = "false"
+		Release.AspNetCompiler.Debug = "False"
+		VWDPort = "62172"
+		SlnRelativePath = "wwwroot\"
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Any CPU = Debug|Any CPU
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{DB74DD9E-F84B-4372-A298-41376272D607}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{DB74DD9E-F84B-4372-A298-41376272D607}.Debug|Any CPU.Build.0 = Debug|Any CPU
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {9CA3E13F-6ECD-4AFF-BB80-B7C099FAE7B3}
+	EndGlobalSection
+EndGlobal

+ 0 - 3
README.md

@@ -1,3 +0,0 @@
-# IMEX.mes.api
-
-中陶立库对接

+ 134 - 0
wwwroot/App_Code/ApiLog.cs

@@ -0,0 +1,134 @@
+using System;
+using System.Web;
+using Curtain.DataAccess;
+
+/// <summary>
+/// PLC执行日志 xuwei modify 2020-07-14 简化webapi方法
+/// </summary>
+public class ApiLog
+{
+	/// <summary>
+	/// 接口类型
+	/// </summary>
+	public enum ApiType
+	{
+		/// <summary>
+		/// WebApi
+		/// </summary>
+		WebApi,
+		/// <summary>
+		/// WebService
+		/// </summary>
+		WebService
+	}
+
+	/// <summary>
+	/// 接口请求方式
+	/// </summary>
+	public enum ApiRuquest
+	{ 
+		/// <summary>
+		/// Get方式
+		/// </summary>
+		Get,
+		/// <summary>
+		/// Post方式
+		/// </summary>
+		Post
+	}
+
+
+	/// <summary>
+	/// PLC执行操作写入日志
+	/// </summary>
+	/// <param name="name">接口名称</param>
+	/// <param name="type">接口类型</param>
+	/// <param name="request">接口请求方式</param>
+	/// <param name="url">接口地址</param>
+	/// <param name="method">接口方法名(用于WEBSERVICE)</param>
+	/// <param name="parameter">接口请求参数JSON格式</param>
+	/// <param name="status">接口请求状态</param>
+	/// <param name="result">接口请求结果</param>
+	/// <param name="apiid">接口ID用于统计</param>
+	/// <param name="barcodecount">条码数量用于统计</param>
+	public static void WriteApiLog(string name, ApiType type, ApiRuquest request, string url, string method, string parameter,
+		bool status, string result, int apiid = 0, int barcodecount = 1)
+	{
+		try
+		{
+            if (HttpContext.Current.Request.Url.Host.ToLower() == HttpContext.Current.Request.UserHostAddress.ToLower())
+            {
+                return;
+            }
+
+            using (IDataAccess conn = DataAccess.Create())
+			{
+				string sqlString = @"
+				INSERT INTO TP_MST_APILOG
+					(APIID
+					,NAME
+					,TYPE
+					,REQUEST
+					,URL
+					,METHOD
+					,PARAMETER
+					,STATUS
+					,RESULT
+					,BARCODECOUNT
+					,GUESTIP
+					,GUESTHOST)
+				VALUES
+					(@APIID@
+					,@NAME@
+					,@TYPE@
+					,@REQUEST@
+					,@URL@
+					,@METHOD@
+					,@PARAMETER@
+					,@STATUS@
+					,@RESULT@
+					,@BARCODECOUNT@
+					,@GUESTIP@
+					,@GUESTHOST@)";
+
+				CDAParameter[] paras = new CDAParameter[]
+				{
+					new CDAParameter("APIID", apiid),
+					new CDAParameter("NAME", name),
+					new CDAParameter("TYPE", type.ToString()),
+					new CDAParameter("REQUEST", request.ToString()),
+					new CDAParameter("URL", url),
+					new CDAParameter("METHOD", method),
+					new CDAParameter("PARAMETER", parameter),
+					new CDAParameter("STATUS", status ? '1' : '0'),
+					new CDAParameter("RESULT", result),
+					new CDAParameter("BARCODECOUNT", barcodecount),
+					new CDAParameter("GUESTIP", HttpContext.Current.Request.UserHostAddress),
+					new CDAParameter("GUESTHOST", HttpContext.Current.Request.UserHostName),
+				};
+
+				conn.BeginTransaction();
+				conn.ExecuteNonQuery(sqlString, paras);
+				conn.Commit();
+			}
+		}
+		catch (Exception ex)
+		{
+			throw ex;
+		}
+	}
+
+	/// <summary>
+	/// 简化的webapi写日志方法
+	/// </summary>
+	/// <param name="name"></param>
+	/// <param name="url"></param>
+	/// <param name="status"></param>
+	/// <param name="result"></param>
+	/// <param name="apiid"></param>
+	public static void WriteApiLog(string name, string url, bool status, string result, int apiid = 0, int barcodecount = 1)
+    {
+		WriteApiLog(name, ApiType.WebApi, ApiRuquest.Get, url, "", "", status, result, apiid, barcodecount);
+	}
+
+}

+ 64 - 0
wwwroot/App_Code/WCF.cs

@@ -0,0 +1,64 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System.Configuration;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+
+/// <summary>
+/// 调用MES的WCF接口通用方法 xuwei 2020-06-24
+/// </summary>
+public class WCF
+{
+    /// <summary>
+    /// MES服务器IP地址。
+    /// </summary>
+    public string IP;
+
+    /// <summary>
+    /// MES服务WCF调用参数。
+    /// </summary>
+    public JObject Para;
+
+    /// <summary>
+    /// 实例化MES服务WCF调用方法。
+    /// </summary>
+    public WCF()
+    {
+        //从Web.config读取服务器IP
+        IP = ConfigurationManager.AppSettings["MesServer"].ToString();
+        Para = new JObject();
+    }
+
+    /// <summary>
+    /// 向URL指定的WCF接口提交POST数据
+    /// </summary>
+    /// <param name="URL">完整URL,但不包括IP部分。</param>
+    /// <returns></returns>
+    public string Post(string URL = "")
+    {
+        //提交post数据
+        return JsonClient.Post(IP + URL, JsonConvert.SerializeObject(Para));
+    }
+
+    /// <summary>
+    /// 向URL指定的WCF接口提交GET数据
+    /// </summary>
+    /// <param name="URL">完整URL,但不包括IP部分。</param>
+    /// <returns></returns>
+    public string Get(string URL = "")
+    {
+        string paraStr = "?";
+        foreach(JProperty p in Para.Properties())
+        {
+            if (paraStr != "?") paraStr += "&";
+            paraStr += p.Name.ToString() + "=" + p.Value.ToString();
+        }
+        //提交post数据
+        return JsonClient.Get(IP + URL + paraStr);
+    }
+
+}

+ 53 - 0
wwwroot/Global.asax

@@ -0,0 +1,53 @@
+<%@ Application Language="C#" %>
+<%@ Import Namespace="Curtain.DataAccess" %>
+<%@ Import Namespace="Curtain.Log" %>
+<%@ Import Namespace="DK.XuWei.WebMes" %>
+
+<script runat="server">
+
+    void Application_Start(object sender, EventArgs e)
+    {
+        // 在应用程序启动时运行的代码
+        
+        string connStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
+        DataAccess.DefaultParameterType = SQLParameterType.CDA;
+        DataAccess.DefaultDataBaseType = Curtain.DataAccess.DataBaseType.Oracle;
+        DataAccess.DefaultConnectionString = connStr;
+    }
+
+    void Application_End(object sender, EventArgs e)
+    {
+        //  在应用程序关闭时运行的代码
+
+    }
+
+    void Application_Error(object sender, EventArgs e)
+    {
+        // 在出现未处理的错误时运行的代码
+        Exception error = Server.GetLastError().GetBaseException();
+        if (error != null)
+        {
+            //记录日志
+            Logger.Error(error);
+            //输出错误信息
+            HttpContext.Current.Response.Write(new JsonResult(JsonStatus.otherError).ToJson());
+        }
+        Server.ClearError();
+    }
+
+    void Session_Start(object sender, EventArgs e)
+    {
+        // 在新会话启动时运行的代码
+
+    }
+
+    void Session_End(object sender, EventArgs e)
+    {
+        // 在会话结束时运行的代码。 
+        // 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
+        // InProc 时,才会引发 Session_End 事件。如果会话模式设置为 StateServer
+        // 或 SQLServer,则不引发该事件。
+
+    }
+
+</script>

+ 41 - 0
wwwroot/Web.config

@@ -0,0 +1,41 @@
+<?xml version="1.0"?>
+<!--
+  有关如何配置 ASP.NET 应用程序的详细信息,请访问
+  https://go.microsoft.com/fwlink/?LinkId=169433
+-->
+<configuration>
+  <connectionStrings>
+    <!--中陶-->
+    <add name="ConnectionString" connectionString="Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.8.2)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=dkmes)));User Id=mes;Password=dongke" providerName="Oracle.ManagedDataAccess.Client"/>
+  </connectionStrings>
+  <appSettings>
+    <add key="ProductCheckServer" value="http://10.0.8.2:1234"/>
+  </appSettings>
+  <system.web>
+    <customErrors mode="Off"/>
+    <compilation targetFramework="4.0" debug="true">
+      <assemblies>
+        <add assembly="System.ServiceProcess, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
+      </assemblies>
+    </compilation>
+    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID" validateRequest="false"/>
+    <httpRuntime/>
+    <!--<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" cookieless="false" timeout="1440"/>-->
+  </system.web>
+  <system.data>
+    <DbProviderFactories>
+      <remove invariant="Oracle.ManagedDataAccess.Client"/>
+      <add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client" description="Oracle Data Provider for .NET, Managed Driver" type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.122.19.1, Culture=neutral, PublicKeyToken=89b483f429c47342"/>
+    </DbProviderFactories>
+  </system.data>
+  <system.webServer>
+    <security>
+      <requestFiltering>
+        <requestLimits maxAllowedContentLength="1048576000"/>
+      </requestFiltering>
+    </security>
+    <staticContent>
+      <mimeMap fileExtension=".log" mimeType="text/plain"/>
+    </staticContent>
+  </system.webServer>
+</configuration>

+ 91 - 0
wwwroot/api/DKService/ExHGS3QR/AddWorkInfoHGS3_QR/index.ashx

@@ -0,0 +1,91 @@
+<%@ WebHandler Language="C#" Class="DKService_ExHGS3QR_AddWorkInfoHGS3_QR" %>
+
+using System;
+using System.Web;
+using System.Web.SessionState;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json.Linq;
+using Curtain.Log;
+using System.Collections;
+
+/// <summary>
+/// 给金马:扫码接口
+/// </summary>
+public class DKService_ExHGS3QR_AddWorkInfoHGS3_QR : IHttpHandler,IReadOnlySessionState
+{
+
+    public void ProcessRequest(HttpContext context)
+    {
+        context.Response.ContentType = "text/plain";
+
+        //获取参数
+        string barcode = context.Request["barcode"] is object ? context.Request["barcode"] : "";
+        string procedure_no = context.Request["procedure_no"] is object ? context.Request["procedure_no"] : "";
+        string road_no = context.Request["road_no"] is object ? context.Request["road_no"] : "0";
+        string rack = context.Request["rack"] is object ? context.Request["rack"] : "";
+        string position = context.Request["position"] is object ? context.Request["position"] : "";
+        string procedure_in = context.Request["procedure_in"] is object ? context.Request["procedure_in"] : "1";
+
+        //调用WCF接口
+        WCF wcf = new WCF();
+        wcf.Para.Add(new JProperty("barcode", barcode));
+        wcf.Para.Add(new JProperty("procedure_no", procedure_no));
+        wcf.Para.Add(new JProperty("road_no", road_no));
+        wcf.Para.Add(new JProperty("rack", rack));
+        wcf.Para.Add(new JProperty("position", position));
+        wcf.Para.Add(new JProperty("procedure_in", procedure_in));
+        string jsonStr = wcf.Get("/DKService/ExHGS3QR/AddWorkInfoHGS3_QR");
+
+        //这个接口很小的机率会带出html标签===============================================
+        if (jsonStr.IndexOf("<html>") > 0) jsonStr = jsonStr.Substring(0, jsonStr.IndexOf("<html>"));
+
+        //xuwei fix 2022-05-28 有时会带出 DOCTYPEhtml标签
+        jsonStr = jsonStr.Replace("<!DOCTYPEhtml>","");
+
+        jsonStr = jsonStr.Replace("\\u000d\\u000a", "")
+                .Replace("\\n","").Replace("\\","").Replace(" ","")
+                .Replace("产品编码:"," 产品编码 ")
+                .Replace("当前工序:"," 当前工序 ")
+                .Replace("可到工序:"," 可到工序 ")
+                .Replace("{\"d\":\"","")
+                .Replace("\"}\"}","\"}")
+                ;
+
+        Curtain.Log.Logger.Debug(context.Request.UserHostAddress + "\r\n" + context.Request.Url + "\r\n" +jsonStr);
+
+        string apiResult = "";
+
+        //处理输出结果 OK开头成功 NOK开头失败
+        JObject json = JObject.Parse(jsonStr);
+        bool apiStatus = false;
+        apiStatus = Convert.ToBoolean(json["success"]);
+        apiResult = jsonStr;
+        context.Response.Write(apiResult);
+
+        //记录接口调用日志
+        Hashtable ht = new Hashtable();
+        ht.Add("barcode", barcode);
+        ht.Add("procedure_no", procedure_no);
+        ht.Add("road_no", road_no);
+        ht.Add("rack", rack);
+        ht.Add("position", position);
+        ht.Add("procedure_in", procedure_in);
+
+        int apiId = Convert.ToInt32(procedure_no.Replace("_", "") + road_no + procedure_in);
+        barcode = barcode.Replace("2c%", ",");
+        int apiBarcodeCount = barcode.Split(',').Length;
+        string apiUrl = "http://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port.ToString() + "/api/DKService/ExHGS3QR/AddWorkInfoHGS3_QR/?" + JsonClient.ParaToString(ht);
+        ApiLog.WriteApiLog("立库_扫码", apiUrl, apiStatus, apiResult, apiId, apiBarcodeCount);
+
+    }
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}

+ 104 - 0
wwwroot/api/DKService/ExHGS3QR/AddWorkInfoHGS3_QR/index2.ashx

@@ -0,0 +1,104 @@
+<%@ WebHandler Language="C#" Class="DKService_ExHGS3QR_AddWorkInfoHGS3_QR" %>
+
+using System;
+using System.Web;
+using System.Web.SessionState;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using Newtonsoft.Json.Linq;
+using Curtain.Log;
+using System.Collections;
+
+/// <summary>
+/// 给金马:扫码接口
+/// xuwei fix 2022-05-28 增加try catch 增加容错
+/// </summary>
+public class DKService_ExHGS3QR_AddWorkInfoHGS3_QR : IHttpHandler,IReadOnlySessionState
+{
+
+    public void ProcessRequest(HttpContext context)
+    {
+        context.Response.ContentType = "text/plain";
+
+        //获取参数
+        string barcode = context.Request["barcode"] is object ? context.Request["barcode"] : "";
+        string procedure_no = context.Request["procedure_no"] is object ? context.Request["procedure_no"] : "";
+        string road_no = context.Request["road_no"] is object ? context.Request["road_no"] : "0";
+        string rack = context.Request["rack"] is object ? context.Request["rack"] : "";
+        string position = context.Request["position"] is object ? context.Request["position"] : "";
+        string procedure_in = context.Request["procedure_in"] is object ? context.Request["procedure_in"] : "1";
+        string jsonStr = "";
+        string apiResult = "";
+        bool apiStatus = false;
+
+        try
+        {
+            //调用WCF接口
+            WCF wcf = new WCF();
+            wcf.Para.Add(new JProperty("barcode", barcode));
+            wcf.Para.Add(new JProperty("procedure_no", procedure_no));
+            wcf.Para.Add(new JProperty("road_no", road_no));
+            wcf.Para.Add(new JProperty("rack", rack));
+            wcf.Para.Add(new JProperty("position", position));
+            wcf.Para.Add(new JProperty("procedure_in", procedure_in));
+            jsonStr = wcf.Get("/DKService/ExHGS3QR/AddWorkInfoHGS3_QR");
+
+            //这个接口很小的机率会带出html标签===============================================
+            if (jsonStr.IndexOf("<html>") > 0) jsonStr = jsonStr.Substring(0, jsonStr.IndexOf("<html>"));
+
+            //xuwei fix 2022-05-28 有时会带出 DOCTYPEhtml标签
+            jsonStr = jsonStr.Replace("<!DOCTYPEhtml>","");
+
+            jsonStr = jsonStr.Replace("\\u000d\\u000a", "")
+                    .Replace("\\n","").Replace("\\","").Replace(" ","")
+                    .Replace("产品编码:"," 产品编码 ")
+                    .Replace("当前工序:"," 当前工序 ")
+                    .Replace("可到工序:"," 可到工序 ")
+                    .Replace("{\"d\":\"","")
+                    .Replace("\"}\"}","\"}")
+                    ;
+
+            //处理输出结果 OK开头成功 NOK开头失败
+            JObject json = JObject.Parse(jsonStr);
+            apiStatus = Convert.ToBoolean(json["success"]);
+        }
+        catch (Exception ex)
+        {
+            //输出错误日志文件
+            Logger.Error(ex, context.Request.UserHostAddress + "\r\n" + context.Request.Url + "\r\n" + jsonStr);
+        }
+        finally
+        {
+            //记录日志文件
+            Logger.Debug(context.Request.UserHostAddress + "\r\n" + context.Request.Url + "\r\n" +jsonStr);
+
+            apiResult = jsonStr;
+            context.Response.Write(apiResult);
+
+            //记录接口调用日志
+            Hashtable ht = new Hashtable();
+            ht.Add("barcode", barcode);
+            ht.Add("procedure_no", procedure_no);
+            ht.Add("road_no", road_no);
+            ht.Add("rack", rack);
+            ht.Add("position", position);
+            ht.Add("procedure_in", procedure_in);
+
+            int apiId = Convert.ToInt32(procedure_no.Replace("_", "") + road_no + procedure_in);
+            barcode = barcode.Replace("2c%", ",");
+            int apiBarcodeCount = barcode.Split(',').Length;
+            string apiUrl = "http://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port.ToString() + "/api/DKService/ExHGS3QR/AddWorkInfoHGS3_QR/?" + JsonClient.ParaToString(ht);
+            ApiLog.WriteApiLog("金马_扫码", apiUrl, apiStatus, apiResult, apiId, apiBarcodeCount);
+
+        }
+    }
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}

+ 465 - 0
wwwroot/api/getgoods/index.ashx

@@ -0,0 +1,465 @@
+<%@ WebHandler Language="C#" Class="index" %>
+
+using System;
+using System.Web;
+using System.Web.SessionState;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+using System.Data;
+using Newtonsoft.Json.Linq;
+using System.Collections;
+using Curtain.Log;
+using System.Collections.Generic;
+using Oracle.ManagedDataAccess.Client;
+using System.Text.RegularExpressions;
+
+public class index : IHttpHandler
+{
+	//输入参数 【条码】
+	public string barCode = "";
+	//输入参数 【入库:in】【撤销入库:cancelin】 入库操作预留
+	public string wmsAction = "";
+	string procedure_no;
+	string procedure_in;
+	string road_no;
+	string rack;
+	string position;
+	//入库是否成功标识
+	bool WarehostingFlag;
+	//入库返回失败提示
+	public string message = "";
+
+	//输出参数
+	public JObject resultJson = null;
+
+	public void ProcessRequest(HttpContext context)
+	{
+		context.Response.ContentType = "text/plain";
+		//输入输出参数初始化
+		barCode = context.Request["barcode"] is object ? context.Request["barcode"] : "";
+		wmsAction = context.Request["wmsAction"] is object ? context.Request["wmsAction"] : "";
+		procedure_no = context.Request["procedure_no"] is object ? context.Request["procedure_no"] : "1_1_1";
+
+		if (wmsAction.ToLower() == "in") procedure_in = "1";
+		if (wmsAction.ToLower() == "cancelin") procedure_in = "-1";
+
+		road_no = "0";
+		rack = "";
+		position = "";
+		resultJson = new JObject(
+			new JProperty("success", true),
+			new JProperty("message", ""),
+			new JProperty("goods", new JObject(
+					new JProperty("GoodsName", ""),
+					new JProperty("GoodsCode", ""),
+					new JProperty("GoodsSpecification", ""),
+					new JProperty("GoodsModel", ""),
+					new JProperty("GoodsType", ""),
+					new JProperty("GoodsLineType", ""),
+					new JProperty("GlazeType", ""),
+					new JProperty("PlateLimitnum", ""),
+					new JProperty("Logo", ""),
+					new JProperty("Buildingno", ""),
+					new JProperty("GoodsLevelName", ""),
+					new JProperty("KingdeeCode", "")
+				)
+			)
+		 );
+
+		using (IDataAccess conn = DataAccess.Create())
+		{
+			//开启事务
+			conn.BeginTransaction();
+
+			//获取业务数据,无入库动作才获取产品信息
+			if (Convert.ToBoolean(resultJson["success"]) == true)
+			{
+				if (barCode != "" && wmsAction == "")
+				{
+					getGoodsData(conn, barCode);
+				}
+				else
+				{
+					if (barCode == "")
+					{
+						resultJson["success"] = false;
+						resultJson["message"] = "缺少条码参数!";
+					}
+				}
+			}
+
+			//执行 【入库:in】【撤销入库:cancelin】 操作 入库撤销操作预留
+			if (Convert.ToBoolean(resultJson["success"]) == true)
+			{
+				if (wmsAction == "in" || wmsAction == "cancelin")
+				{
+					string[] arrayBarcode = barCode.Split(',');
+					for (int i = 0; i < arrayBarcode.Length; i++)
+					{
+						//调用标准计件方法===============================
+						WCF wcf = new WCF();
+						wcf.Para.Add(new JProperty("barcode", arrayBarcode[i].ToString()));
+						wcf.Para.Add(new JProperty("procedure_no", procedure_no));
+						wcf.Para.Add(new JProperty("road_no", road_no));
+						wcf.Para.Add(new JProperty("rack", rack));
+						wcf.Para.Add(new JProperty("position", position));
+						wcf.Para.Add(new JProperty("procedure_in", procedure_in));
+						string jsonStr = wcf.Get("/DKService/ExHGS3QR/AddWorkInfoHGS3_QR");
+
+						//这个接口很小的机率会带出html标签===============================================
+						if (jsonStr.IndexOf("<html>") > 0) jsonStr = jsonStr.Substring(0, jsonStr.IndexOf("<html>"));
+						if (jsonStr.IndexOf("<!DOCTYPEhtml>") > 0) jsonStr = jsonStr.Substring(0, jsonStr.IndexOf("<!DOCTYPEhtml>"));
+						//xuwei fix 2022-05-28 有时会带出 DOCTYPEhtml标签
+						jsonStr = jsonStr.Replace("<!DOCTYPEhtml>", "");
+
+						jsonStr = jsonStr.Replace("\\u000d\\u000a", "")
+								.Replace("\\n", "").Replace("\\", "").Replace(" ", "")
+								.Replace("产品编码:", " 产品编码 ")
+								.Replace("当前工序:", " 当前工序 ")
+								.Replace("可到工序:", " 可到工序 ")
+								.Replace("{\"d\":\"", "")
+								.Replace("\"}\"}", "\"}")
+								.Replace("<!DOCTYPEhtml>", "")
+								;
+
+						Curtain.Log.Logger.Debug(context.Request.UserHostAddress + "\r\n" + context.Request.Url + "\r\n" + jsonStr);
+
+						string apiResult = "";
+						//处理输出结果 OK开头成功 NOK开头失败
+						JObject json = JObject.Parse(jsonStr);
+						bool apiStatus = false;
+						apiStatus = Convert.ToBoolean(json["success"]);
+						apiResult = jsonStr;
+						//HttpContext.Current.Response.Write(apiResult);
+
+						//记录接口调用日志
+						Hashtable ht = new Hashtable();
+						ht.Add("barcode", arrayBarcode[i].ToString());
+						ht.Add("procedure_no", procedure_no);
+						ht.Add("road_no", road_no);
+						ht.Add("rack", rack);
+						ht.Add("position", position);
+						ht.Add("procedure_in", procedure_in);
+
+						int apiId = Convert.ToInt32(procedure_no.Replace("_", "") + road_no + Math.Abs(Convert.ToInt32(procedure_in)));
+						arrayBarcode[i] = arrayBarcode[i].Replace("2c%", ",");
+						int apiBarcodeCount = arrayBarcode[i].Split(',').Length;
+						string apiUrl = "http://" + HttpContext.Current.Request.Url.Host + ":" + HttpContext.Current.Request.Url.Port.ToString() + "/api/DKService/ExHGS3QR/AddWorkInfoHGS3_QR/?" + JsonClient.ParaToString(ht);
+						ApiLog.WriteApiLog("立库_扫码", apiUrl, apiStatus, apiResult, apiId, apiBarcodeCount);
+						//===============================================
+
+						if (Convert.ToBoolean(json["success"]) == true)
+						{
+							WarehostingFlag = true;
+							//message += "条码[" + arrayBarcode[i] + "]入库成功,";
+							doWmsAction(conn, arrayBarcode[i], wmsAction, WarehostingFlag);
+						}
+						else
+						{
+							if (wmsAction == "in")
+							{
+								WarehostingFlag = false;
+								message += json["message"].ToString() + ",";
+								doWmsAction(conn, arrayBarcode[i], wmsAction, WarehostingFlag);
+							}
+							else if (wmsAction == "cancelin")
+							{
+								//resultJson["success"] = false;
+								//resultJson["message"] = "产品撤销入库失败!";
+							}
+						}
+					}
+				}
+			}
+
+			//提交事务
+			if (Convert.ToBoolean(resultJson["success"]) == true)
+			{
+				conn.Commit();
+			}
+			else
+			{
+				conn.Rollback();
+			}
+
+			//输出JSON数据
+			context.Response.Write(resultJson.ToString());
+		}
+	}
+
+	//获取业务数据
+	private void getGoodsData(IDataAccess conn, string barCode)
+	{
+		//业务数据读取
+		DataTable dt = conn.ExecuteDatatable(@"
+						SELECT
+							T.GOODSNAME,
+							T.GOODSCODE,
+							T.GOODSSPECIFICATION,
+							T.GOODSMODEL,
+							T.GOODSTYPENAME,
+						  T.GOODS_LINE_TYPE,
+							T.DICTIONARYVALUE,
+							T.PLATELIMITNUM,
+							T.LOGONAME,
+							T.BUILDINGNO,
+							T.GOODSLEVELNAME,
+							TMGK.KingdeeCode
+						FROM
+							(
+			            SELECT DISTINCT
+							TPGD.GOODSNAME,
+	                        TPGD.GOODSCODE,
+	                        TMG.GOODSSPECIFICATION,
+	                        TMG.GOODSMODEL,
+	                        TMGT.GOODSTYPENAME,
+                        CASE
+		                        TMG.GOODS_LINE_TYPE 
+		                        WHEN 0 THEN
+		                        '普通' ELSE '高压' 
+	                        END AS GOODS_LINE_TYPE,
+	                        TMDC.DICTIONARYVALUE,
+	                        1 AS PLATELIMITNUM,
+	                        TML.LOGONAME,
+	                        (
+	                        CASE
+			
+			                        WHEN TPPC.PROCEDUREID = 35 THEN
+			                        '重烧' 
+			                        WHEN TPPC.PROCEDUREID != 35 THEN
+			                        ( CASE WHEN TPG.BUILDINGNO = '1#' THEN '一期' WHEN TPG.BUILDINGNO = '2#' THEN '二期' WHEN TPG.BUILDINGNO = '3#' THEN '三期' END ) 
+			                        END 
+			                        ) AS BUILDINGNO,
+			                        TMGL.GOODSLEVELNAME,
+			                        NULL AS KingdeeCode 
+		                        FROM
+			                        TP_PM_GROUTINGDAILYDETAIL TPGD
+															LEFT JOIN TP_PM_GlazetypeRecord TPGR ON TPGR.GROUTINGDAILYDETAILID =  TPGD.GROUTINGDAILYDETAILID
+			                        LEFT JOIN TP_MST_GOODS TMG ON TPGD.GOODSID = TMG.GOODSID
+			                        LEFT JOIN TP_MST_GOODSTYPE TMGT ON TMG.GOODSTYPEID = TMGT.GOODSTYPEID
+			                        LEFT JOIN TP_MST_DATADICTIONARY TMDC ON TPGR.NEWGLAZETYPEID = TMDC.DICTIONARYID
+			                        LEFT JOIN TP_MST_LOGO TML ON TPGD.LOGOID = TML.LOGOID
+			                        LEFT JOIN TP_PC_GROUTINGLINE TPG ON TPGD.GROUTINGLINEID = TPG.GROUTINGLINEID
+			                        LEFT JOIN TP_MST_GOODSLEVEL TMGL ON TPGD.GOODSLEVELTYPEID = TMGL.GOODSLEVELTYPEID
+			                        LEFT JOIN TP_PM_PRODUCTIONDATA TPPD ON TPGD.BARCODE = TPPD.BARCODE
+			                        LEFT JOIN TP_PC_PROCEDURE TPPC ON TPPD.PROCEDUREID = TPPC.PROCEDUREID 
+		                        WHERE
+			                        (
+			                        CASE
+					                        WHEN(
+					                        SELECT
+						                        COUNT( * ) 
+					                        FROM
+						                        TP_PM_PRODUCTIONDATA TPPD
+						                        LEFT JOIN TP_PC_PROCEDURE TPPC ON TPPD.PROCEDUREID = TPPC.PROCEDUREID
+					                        WHERE
+						                        TPPD.PROCEDUREID = 35
+						                        AND TPPD.BARCODE = @BARCODE@
+						                        ) = 1 THEN
+						                        35 ELSE TPPD.PROCEDUREID
+					                        END
+					                        ) = TPPD.PROCEDUREID
+					                        AND TPGD.VALUEFLAG = 1
+					                        AND TMDC.DICTIONARYTYPE = 'TPC002'
+				                        AND TPPD.BARCODE = @BARCODE@
+										) T
+										LEFT JOIN TP_MST_GOODSKINGDEECODE TMGK ON T.GOODSCODE = TMGK.GOODSCODE
+										AND T.DICTIONARYVALUE = TMGK.GLAZETYPE
+										AND T.LOGONAME = TMGK.LOGONAME
+			",
+			new CDAParameter("BARCODE", barCode)
+		);
+
+		if (dt.Rows.Count > 0)
+		{
+			resultJson["success"] = true;
+			resultJson["message"] = "数据读取成功!";
+			resultJson["goods"]["GoodsName"] = dt.Rows[0]["GOODSNAME"].ToString();
+			resultJson["goods"]["GoodsCode"] = dt.Rows[0]["GOODSCODE"].ToString();
+			resultJson["goods"]["GoodsSpecification"] = dt.Rows[0]["GOODSSPECIFICATION"].ToString();
+			resultJson["goods"]["GoodsModel"] = dt.Rows[0]["GOODSMODEL"].ToString();
+			resultJson["goods"]["GoodsType"] = dt.Rows[0]["GOODSTYPENAME"].ToString();
+			resultJson["goods"]["GoodsLineType"] = dt.Rows[0]["GOODS_LINE_TYPE"].ToString();
+			resultJson["goods"]["GlazeType"] = dt.Rows[0]["DICTIONARYVALUE"].ToString();
+			resultJson["goods"]["PlateLimitnum"] = dt.Rows[0]["PLATELIMITNUM"].ToString();
+			resultJson["goods"]["Logo"] = dt.Rows[0]["LOGONAME"].ToString();
+			resultJson["goods"]["Buildingno"] = dt.Rows[0]["BUILDINGNO"].ToString();
+			resultJson["goods"]["GoodsLevelName"] = dt.Rows[0]["GOODSLEVELNAME"].ToString();
+			resultJson["goods"]["KingdeeCode"] = dt.Rows[0]["KingdeeCode"].ToString();
+		}
+		else
+		{
+			resultJson["success"] = false;
+			resultJson["message"] = "条码错误或不存在此产品!";
+		}
+
+		//写日志
+		///writeLog(conn);
+	}
+
+	//入库方法
+	private void doWmsAction(IDataAccess conn, string barCode, string action, bool WarehostingFlag)
+	{
+		int Count = 0;
+		string sql;
+		CDAParameter[] para;
+		//入库操作(条码支持多个,用逗号分开)
+		if (action == "in")
+		{
+			//入库操作
+			#region 入库校验有一个不成功,则全部入库失败
+			//DataTable dt = conn.ExecuteDatatable(@"SELECT WMSACTION,BARCODE FROM TP_PM_GOODSWHETHERWAREHOUSING WHERE BARCODE = @BARCODE@ AND VALUEFLAG = 1",
+			//    new CDAParameter("BARCODE", arrayBarcode[i].ToString())
+			//    );
+			////入库
+			//if (dt.Rows.Count != 0)
+			//{
+			//    if (dt.Rows[0]["WMSACTION"].ToString() == "0")
+			//    {
+			//        sql = @"UPDATE TP_PM_GOODSWHETHERWAREHOUSING SET WMSACTION=@WMSACTION@ WHERE BARCODE = @BARCODE@";
+			//        para = new CDAParameter[]{
+			//    new CDAParameter("BARCODE",arrayBarcode[i].ToString()),
+			//    new CDAParameter("WMSACTION",1)
+			//    };
+			//        Count += conn.ExecuteNonQuery(sql, para);
+			//    }
+			//    else
+			//    {
+			//        resultJson["success"] = false;
+			//        resultJson["message"] = "产品入库失败!条码为:" + dt.Rows[0]["BARCODE"] + "的产品已经入库";
+			//        return;
+			//    }
+			//}
+			//else
+			//{
+			//    sql = @"INSERT INTO TP_PM_GOODSWHETHERWAREHOUSING(BARCODE,WMSACTION)VALUES(@BARCODE@,@WMSACTION@)";
+			//    para = new CDAParameter[]{
+			//    new CDAParameter("BARCODE",arrayBarcode[i].ToString()),
+			//    new CDAParameter("WMSACTION",1)
+			//    };
+			//    Count += conn.ExecuteNonQuery(sql, para);
+			//}
+			#endregion
+
+			#region 失败的不入库 成功的入库
+			try
+			{
+				if (WarehostingFlag == true)
+				{
+					sql = @"INSERT INTO TP_PM_GOODSWHETHERWAREHOUSING(BARCODE,WMSACTION)VALUES(@BARCODE@,@WMSACTION@)";
+					para = new CDAParameter[]{
+					new CDAParameter("BARCODE",barCode),
+					new CDAParameter("WMSACTION",1),
+					};
+					Count = conn.ExecuteNonQuery(sql, para);
+				}
+				if (Count == 1)
+				{
+					message += "条码[" + barCode + "]入库成功,";
+					resultJson["success"] = true;
+					resultJson["message"] = message;
+				}
+				else
+				{
+					resultJson["success"] = true;
+					resultJson["message"] = message;
+				}
+			}
+			catch (Exception)
+			{
+				message += "条码[" + barCode + "] 已经入库了,";
+				resultJson["success"] = true;
+				resultJson["message"] = message;
+				return;
+			}
+			#endregion
+		}
+
+		//入库撤销操作 预留内容(条码支持多个,用逗号分开)
+		if (action == "cancelin")
+		{
+			//调用计件撤销方法===============================
+			//DataTable dt = conn.ExecuteDatatable(@"SELECT WMSACTION,BARCODE FROM TP_PM_GOODSWHETHERWAREHOUSING WHERE BARCODE = @BARCODE@ AND VALUEFLAG = 1",
+			//new CDAParameter("BARCODE", barCode)
+			//);
+			//if (dt.Rows.Count != 0)
+			//{
+			//    if (dt.Rows[0]["WMSACTION"].ToString() == "0")
+			//    {
+			//        resultJson["success"] = false;
+			//        resultJson["message"] = "产品撤销入库失败!条码为:" + dt.Rows[0]["BARCODE"] + "的产品已经撤销入库";
+			//        return;
+			//    }
+			//    sql = @"UPDATE TP_PM_GOODSWHETHERWAREHOUSING SET WMSACTION=@WMSACTION@ WHERE BARCODE = @BARCODE@";
+			//    para = new CDAParameter[]{
+			//        new CDAParameter("BARCODE",barCode),
+			//        new CDAParameter("WMSACTION",0)
+			//        };
+			//    Count += conn.ExecuteNonQuery(sql, para);
+			//}
+			//else
+			//{
+			//    resultJson["success"] = false;
+			//    resultJson["message"] = "产品撤销入库失败!条码不存在";
+			//    return;
+			//}
+		}
+		//if (Count == arrayBarcode.Length)
+		//{
+		//    if (action == "in")
+		//    {
+		//        resultJson["success"] = true;
+		//        resultJson["message"] = "产品入库成功!";
+		//    }
+		//    else if (action == "cancelin")
+		//    {
+		//        resultJson["success"] = true;
+		//        resultJson["message"] = "产品撤销入库成功!";
+		//    }
+		//}
+		//else
+		//{
+		//    if (action == "in")
+		//    {
+		//        resultJson["success"] = false;
+		//        resultJson["message"] = "产品入库失败!";
+		//    }
+		//    else if (action == "cancelin")
+		//    {
+		//        resultJson["success"] = false;
+		//        resultJson["message"] = "产品撤销入库失败!";
+		//    }
+		//}
+
+		//===============================================
+
+
+		//写日志
+		//writeLog(conn);
+	}
+
+	//日志记录(访问者IP,访问链接,访问参数,返回结果,访问时间)
+	//private void writeLog(IDataAccess conn)
+	//{
+	//    if(Convert.ToBoolean(resultJson["success"]) == true)
+	//    {
+	//        Logger.Info("IP:" + HttpContext.Current.Request.UserHostAddress + " "+"访问链接:"+ HttpContext.Current.Request.UrlReferrer +" "+ " " +
+	//                    "条码:" + barCode + " 入库标识:"+ wmsAction +" " +" 输出:" + resultJson.ToString());
+	//    }
+	//    else
+	//    {
+	//        Logger.Info("IP:" + HttpContext.Current.Request.UserHostAddress +"访问链接:"+ HttpContext.Current.Request.UrlReferrer + " " +
+	//                    "条码:"+ barCode +" 入库标识:"+ wmsAction +" "+ resultJson["message"] + "输出:" + resultJson.ToString());
+	//    }
+
+	//}
+
+	public bool IsReusable
+	{
+		get
+		{
+			return false;
+		}
+	}
+
+}

+ 31 - 0
wwwroot/api/test/callWebService.ashx

@@ -0,0 +1,31 @@
+<%@ WebHandler Language="C#" Class="test" %>
+
+using System;
+using System.Web;
+using System.Xml;
+using System.Xml.Linq;
+using DK.XuWei.WebMes;
+using System.Collections;
+
+public class test : IHttpHandler {
+
+    public void ProcessRequest (HttpContext context) {
+        context.Response.ContentType = "text/plain";
+
+        //ServiceReference1.WebServiceSoapClient c = new ServiceReference1.WebServiceSoapClient();
+        //string result = c.HelloWorld(" OK!");
+        //context.Response.Write(result);
+
+        Hashtable ht = new Hashtable();
+        ht.Add("name", "abc");
+        XmlDocument xml = XmlClient.Soap("http://localhost:57652/api/test/testWebService.asmx", "HelloWorld", ht);
+        context.Response.Write(xml.DocumentElement.InnerText);
+    }
+
+    public bool IsReusable {
+        get {
+            return false;
+        }
+    }
+
+}

+ 129 - 0
wwwroot/api/test/callWebServiceSap.ashx

@@ -0,0 +1,129 @@
+<%@ WebHandler Language="C#" Class="callWebServiceSap" %>
+
+using System;
+using System.Web;
+using System.Xml;
+using System.Xml.Linq;
+using DK.XuWei.WebMes;
+using System.Collections;
+
+using System.Collections.Generic;
+using System.Dynamic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml.Serialization;
+using System.Web.Services.Description;
+
+public class callWebServiceSap : IHttpHandler {
+
+    public void ProcessRequest (HttpContext context) {
+        context.Response.ContentType = "text/plan";
+
+        string postData = @"
+<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:sap-com:document:sap:rfc:functions'>
+   <soapenv:Header/>
+   <soapenv:Body>
+      <urn:ZPPFM008>
+         <!--Optional:-->
+         <TABLE_IN>
+            <!--Zero or more repetitions:-->
+            <item>
+               <WERKS>1</WERKS>
+               <GROES>1</GROES>
+               <MATNR>1</MATNR>
+               <ZGHNU>1</ZGHNU>
+               <ZJDNU>1</ZJDNU>
+               <ZSCNU>1</ZSCNU>
+               <VBELN>1</VBELN>
+               <POSNR>1</POSNR>
+               <ZKSSJ>1</ZKSSJ>
+               <ZJSRQ>1</ZJSRQ>
+               <ZCLNG>1</ZCLNG>
+               <ZSPNG>1</ZSPNG>
+               <ZQCNG>1</ZQCNG>
+               <ZHSNG>1</ZHSNG>
+               <ZGBNG>1</ZGBNG>
+               <ZBZBS>1</ZBZBS>
+               <ZTYPE>1</ZTYPE>
+               <ZMSG>1</ZMSG>
+               <MJAHR>1</MJAHR>
+               <MBLNR1>1</MBLNR1>
+               <ZTYPE1>1</ZTYPE1>
+               <ZMSG1>1</ZMSG1>
+               <MBLNR2>1</MBLNR2>
+               <ZTYPE2>1</ZTYPE2>
+               <ZMSG2>1</ZMSG2>
+               <MBLNR3>1</MBLNR3>
+               <ZTYPE3>1</ZTYPE3>
+               <ZMSG3>1</ZMSG3>
+               <MBLNR4>1</MBLNR4>
+               <ZTYPE4>1</ZTYPE4>
+               <ZMSG4>1</ZMSG4>
+            </item>
+         </TABLE_IN>
+         <!--Optional:-->
+         <TABLE_OUT>
+            <!--Zero or more repetitions:-->
+            <item>
+               <WERKS>1</WERKS>
+               <GROES>1</GROES>
+               <MATNR>1</MATNR>
+               <ZGHNU>1</ZGHNU>
+               <ZJDNU>1</ZJDNU>
+               <ZSCNU>1</ZSCNU>
+               <VBELN>1</VBELN>
+               <POSNR>1</POSNR>
+               <ZKSSJ>1</ZKSSJ>
+               <ZJSRQ>1</ZJSRQ>
+               <ZCLNG>1</ZCLNG>
+               <ZSPNG>1</ZSPNG>
+               <ZQCNG>1</ZQCNG>
+               <ZHSNG>1</ZHSNG>
+               <ZGBNG>1</ZGBNG>
+               <ZBZBS>1</ZBZBS>
+               <ZTYPE>1</ZTYPE>
+               <ZMSG>1</ZMSG>
+               <MJAHR>1</MJAHR>
+               <MBLNR1>1</MBLNR1>
+               <ZTYPE1>1</ZTYPE1>
+               <ZMSG1>1</ZMSG1>
+               <MBLNR2>1</MBLNR2>
+               <ZTYPE2>1</ZTYPE2>
+               <ZMSG2>1</ZMSG2>
+               <MBLNR3>1</MBLNR3>
+               <ZTYPE3>1</ZTYPE3>
+               <ZMSG3>1</ZMSG3>
+               <MBLNR4>1</MBLNR4>
+               <ZTYPE4>1</ZTYPE4>
+               <ZMSG4>1</ZMSG4>
+            </item>
+         </TABLE_OUT><ZSUM>1</ZSUM>
+         <!--Optional:-->
+         
+      </urn:ZPPFM008>
+   </soapenv:Body>
+</soapenv:Envelope>
+        ";
+
+        postData = postData.Replace("'", "\"");
+        string url = "http://S4DEVAPP.hegii.com:8080/sap/bc/srt/rfc/sap/zppfm008/240/zppfm008/zppfm008_bind";
+        NetworkCredential credential = new NetworkCredential("hgsapdk", "Sapdk#240");
+        XmlDocument xml = SoapClient.Post(url, postData, credential);
+
+        context.Response.Write(xml.InnerXml + "\n\n");
+        string ztype = xml.DocumentElement["soap-env:Body"]["n0:ZPPFM008Response"]["ZTYPE"].InnerXml;
+        string zmsg = xml.DocumentElement["soap-env:Body"]["n0:ZPPFM008Response"]["ZMSG"].InnerXml;
+        context.Response.Write("ZTYPE:" + ztype + " ");
+        context.Response.Write("ZMSG:" + zmsg + " ");
+    }
+
+    public bool IsReusable {
+        get {
+            return false;
+        }
+    }
+
+}

+ 107 - 0
wwwroot/api/test/getIP/index.ashx

@@ -0,0 +1,107 @@
+<%@ WebHandler Language="C#" Class="getIP" %>
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using System.Runtime.InteropServices;
+using System.Diagnostics;
+using System.Text.RegularExpressions;
+
+public class getIP : IHttpHandler
+{
+
+    public void ProcessRequest(HttpContext context)
+    {
+        context.Response.ContentType = "text/html";
+        context.Response.Write("HostAddress:"+context.Request.UserHostAddress +"<br>");
+        context.Response.Write("HostName:"+context.Request.UserHostName +"<br>");
+        context.Response.Write("Agent:"+context.Request.UserAgent +"<br>");
+        context.Response.Write("REMOTE_ADDR:"+context.Request.ServerVariables["REMOTE_ADDR"] +"<br>");
+        context.Response.Write("HTTP_X_FORWARDED_FOR:"+context.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] +"<br>");
+        
+        string ip = context.Request.ServerVariables["REMOTE_ADDR"];
+        context.Response.Write("MAC:"+GetClientMac(ip) +"<br>");
+        context.Response.Write("MAC2:"+GetClientMac(ip) +"<br>");
+
+    }
+
+    [DllImport("Iphlpapi.dll")]
+    private static extern int SendARP(Int32 dest, Int32 host, ref Int64 mac, ref Int32 length);
+    [DllImport("Ws2_32.dll")]
+    private static extern Int32 inet_addr(string ip);
+
+    public static string GetClientMac(string IP)
+    {
+        Int32 ldest = inet_addr(IP);
+        Int64 macinfo = new Int64();
+        Int32 len = 6;
+        int res = SendARP(ldest, 0, ref macinfo, ref len);
+        string mac_src = macinfo.ToString("X");
+
+        while (mac_src.Length < 12)
+        {
+            mac_src = mac_src.Insert(0, "0");
+        }
+        string mac_dest = "";
+        for (int i = 0; i < 11; i++)
+        {
+            if (0 == (i % 2))
+            {
+                if (i == 10)
+                {
+                    mac_dest = mac_dest.Insert(0, mac_src.Substring(i, 2));
+                }
+                else
+                {
+                    mac_dest = "-" + mac_dest.Insert(0, mac_src.Substring(i, 2));
+                }
+            }
+        }
+        return mac_dest;
+    }
+
+     //跨网段取Mac
+     public string GetMac(string IP)
+     {
+         string dirResults = "";
+         ProcessStartInfo psi = new ProcessStartInfo();
+         Process proc = new Process();
+         psi.FileName = "nbtstat";
+         psi.RedirectStandardInput = false;
+         psi.RedirectStandardOutput = true;
+         psi.Arguments = "-A " + IP;
+         psi.UseShellExecute = false;
+         proc = Process.Start(psi);
+         dirResults = proc.StandardOutput.ReadToEnd();
+         proc.WaitForExit();
+         dirResults = dirResults.Replace("\r", "").Replace("\n", "").Replace("\t", "");
+         Regex reg = new Regex("Mac[ ]{0,}Address[ ]{0,}=[ ]{0,}(?<key>((.)*?))__MAC", RegexOptions.IgnoreCase | RegexOptions.Compiled);
+         Match mc = reg.Match(dirResults + "__MAC");
+ 
+         if (mc.Success)
+         { return mc.Groups["key"].Value; }
+         else
+         {
+             reg = new Regex("Host not found", RegexOptions.IgnoreCase | RegexOptions.Compiled);
+             mc = reg.Match(dirResults);
+             if (mc.Success)
+             {
+                 return "Host not found!";
+             }
+             else
+             { return ""; }
+         }
+     }
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}

+ 19 - 0
wwwroot/api/test/testWebService.asmx

@@ -0,0 +1,19 @@
+<%@ WebService Language="C#" Class="WebService" %>
+
+using System;
+using System.Web;
+using System.Web.Services;
+using System.Web.Services.Protocols;
+
+[WebService(Namespace = "http://tempuri.org/")]
+[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
+// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。 
+[System.Web.Script.Services.ScriptService]
+public class WebService  : System.Web.Services.WebService {
+
+    [WebMethod]
+    public string HelloWorld(string name) {
+        return "Hello World" + name;
+    }
+    
+}

+ 48 - 0
wwwroot/api/test/update/getProcedure.ashx

@@ -0,0 +1,48 @@
+<%@ WebHandler Language="C#" Class="getProcedure" %>
+
+using System;
+using System.Web;
+using System.Web.SessionState;
+using System.Data;
+using System.Text;
+using System.Collections;
+using System.Collections.Generic;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+
+public class getProcedure : IHttpHandler, IReadOnlySessionState
+{
+    public void ProcessRequest(HttpContext context)
+    {
+        context.Response.ContentType = "text/plain";
+        using(IDataAccess conn = DataAccess.Create())
+        {
+            DataTable dt = conn.ExecuteDatatable(@"
+                SELECT 
+                    PROCEDUREID AS ID,
+                    PROCEDURECODE AS CODE,
+                    PROCEDURENAME AS NAME
+                FROM 
+                    TP_PC_PROCEDURE
+                WHERE 
+                    VALUEFLAG = '1'
+                    AND PROCEDURENAME LIKE '1#%'
+                ORDER BY 
+                    NODENO
+            ");
+            context.Response.Write(dt.ToJson());
+        }
+
+    }
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}

+ 136 - 0
wwwroot/api/test/update/index.html

@@ -0,0 +1,136 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <title>东科测试接口</title>
+    <link rel="shortcut icon" href="/img/logo.png" />
+    <link rel="bookmark" href="/img/logo.png" />
+    <link rel="stylesheet" type="text/css" href="/Plugins/iview/iview.css">
+    <script type="text/javascript" src="/Plugins/iview/vue.min.js"></script>
+    <script type="text/javascript" src="/Plugins/iview/iview.min.js"></script>
+    <script type="text/javascript" src="/Plugins/axios/axios.min.js"></script>
+</head>
+<body style="background: #f5f7f9;font-size:14px;">
+
+    <div class="layout" id="app">
+        <Layout>
+            <Header>
+                <i-Menu mode="horizontal" theme="dark" active-name="1" style="color:white;">
+                    <i-MenuItem name="1" style="padding-left:20px;font-size:16px">
+                        <img src="/img/logo3.png" style="height:24px;position:absolute;top:14px;left:8px;" />
+                        <span style="padding-left:20px">东科软件</span>
+                    </i-MenuItem>
+                </i-Menu>
+            </Header>
+            <Content>
+                <row style="padding: 20px">
+                    <i-Col :sm="24" :md="12">
+                        <Card shadow style="margin:10px;">
+                            <p slot="title">库位编码</p>
+                            <p>
+                                1_1_1 阴干库(入)<br />
+                                3_3_2 烘干库(入)<br />
+                                3_3_3 烘干库(出)<br />
+                                3_3_4 干坯库(入)<br />
+                                3_3_5 毛坏库(入)<br />
+                                3_2_2 精坯库(入)<br />
+                                3_2_3 精坯库(出)<br />
+                                3_2_4 釉坯库(入)<br />
+                                3_2_5 釉坯库(出)<br />
+                            </p>
+                            <p>
+                                <br />
+                                '60000269701',
+                                '60000269702',
+                                '60000269703',
+                                '60000269704',
+                                '60000269705',
+                                '60000269706',
+                                '60000269707',
+                                '60000269708',
+                                '60000269709',
+                                '60000269710'
+                                <br /><br />
+                            </p>
+                        </Card>
+                    </i-Col>
+                    <i-Col :sm="24" :md="12">
+                        <Card shadow style="margin:10px;">
+                            <p slot="title">东科接口测试(WCF)</p>
+                            <p>
+                                <b>测试 包装入库(验证)</b><br />
+                                <a href="http://10.0.8.2:1233/DKService/ExHGS3QR/AddWorkInfoHGS3_QR?barcode=60000269701&procedure_no=1_1_1&road_no=1&rack=123&position=123&procedure_in=0" target="_blank">
+                                    http://10.0.8.2:1233/DKService/ExHGS3QR/AddWorkInfoHGS3_QR?barcode=60000269701&procedure_no=1_1_1&road_no=1&rack=123&position=123&procedure_in=0 
+                                </a><br />
+                                <b>测试 包装入库(计件)</b><br />
+                                <a href="http://10.0.8.2:1233/DKService/ExHGS3QR/AddWorkInfoHGS3_QR?barcode=60000269701&procedure_no=1_1_1&road_no=1&rack=123&position=123&procedure_in=1" target="_blank">
+                                    http://10.0.8.2:1233/DKService/ExHGS3QR/AddWorkInfoHGS3_QR?barcode=60000269701&procedure_no=1_1_1&road_no=1&rack=123&position=123&procedure_in=1
+                                </a>
+                                <br /><br />
+                            </p>
+                        </Card>
+                        <Card shadow style="margin:10px;">
+                            <p slot="title">东科接口测试(WEB)</p>
+                            <p>
+                                <b>测试 包装入库(验证)</b><br />
+                                                  <a href="http://10.0.8.2:9010/api/getgoods/index.ashx?barcode=60000269701&wmsAction=in&procedure_no=1_1_1&road_no=1&rack=123&position=123&procedure_in=0" target="_blank">
+                                                      http://10.0.8.2:9010/api/getgoods/index.ashx?barcode=60000269701&wmsAction=in&procedure_no=1_1_1&road_no=1&rack=123&position=123&procedure_in=0
+                                                  </a><br />
+                                <b>测试 包装入库(计件)</b><br />
+                                                  <a href="http://10.0.8.2:9010/api/DKService/ExHGS3QR/AddWorkInfoHGS3_QR/index.ashx?barcode=20300786516&procedure_no=1_1_1&road_no=1&rack=123&position=123&procedure_in=1" target="_blank">
+                                                      http://10.0.8.2:9010/api/DKService/ExHGS3QR/AddWorkInfoHGS3_QR/index.ashx?barcode=20300786516&procedure_no=1_1_1&road_no=1&rack=123&position=123&procedure_in=1
+                                                  </a>
+                                <br /><br />
+                            </p>
+                        </Card>
+                    </i-Col>
+
+                </row>
+            </Content>
+            <Footer>
+                <row type="flex" justify="center">
+                    版权所有:© 2020 沈阳东科云信软件有限公司
+                </row>
+            </Footer>
+        </Layout>
+    </div>
+
+    <script>
+        new Vue({
+            el: '#app',
+            data: {
+                procedureList: [],
+                procedureId: '0'
+            },
+            created: function () {
+                var prop = this;
+                //获取工序
+                axios.get('/api/test/update/getProcedure.ashx')
+                    .then(function (req) {
+                        prop.procedureList = req['data'];
+                    });
+            },
+            methods: {
+                //更新工序ID
+                updateProcedureId: function () {
+                    var prop = this;
+                    if (prop.procedureId == '0') {
+                        prop.$Message.error('请选择工序节点!');
+                    }
+                    else {
+                        axios.get('/api/test/update/update.ashx?m=updateProcedureIds&PROCEDUREID=' + prop.procedureId)
+                            .then(function (req) {
+                                if (req.data.success == true) {
+                                    prop.$Message.success('工序ID更新成功!');
+                                }
+                                else {
+                                    prop.$Message.error('工序ID更新失败!');
+                                }
+                            });
+                    }
+                }
+            }
+        })
+    </script>
+</body>
+</html>

+ 90 - 0
wwwroot/api/test/update/update.ashx

@@ -0,0 +1,90 @@
+<%@ WebHandler Language="C#" Class="update" %>
+
+using System;
+using System.Web;
+using System.Web.SessionState;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Data;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+
+public class update : IHttpHandler, IReadOnlySessionState
+{
+    public void ProcessRequest(HttpContext context)
+    {
+        context.Response.ContentType = "text/plain";
+
+        if (context.Request["m"] is object)
+        {
+            using (IDataAccess conn = DataAccess.Create())
+            {
+                switch (context.Request["m"].ToString())
+                {
+                    case "updateProcedureId":
+                        {
+                            //更新工序ID
+                            int result = conn.ExecuteNonQuery(@"
+				                UPDATE TP_PM_INPRODUCTION 
+				                SET
+					                FLOWPROCEDUREID = @FLOWPROCEDUREID@,
+					                PROCEDUREID = @PROCEDUREID@
+				                WHERE 
+					                BARCODE = @BARCODE@
+				                ",
+                                new CDAParameter("BARCODE", context.Request["BARCODE"].ToString()),
+                                new CDAParameter("FLOWPROCEDUREID", context.Request["PROCEDUREID"].ToString()),
+                                new CDAParameter("PROCEDUREID", context.Request["PROCEDUREID"].ToString())
+                            );
+
+                            context.Response.Write(new JsonResult( JsonStatus.success).ToJson());
+                            break;
+                        }
+                    case "updateProcedureIds":
+                        {
+                            //更新工序ID
+                            int result = conn.ExecuteNonQuery(@"
+				                UPDATE TP_PM_INPRODUCTION 
+				                SET
+					                FLOWPROCEDUREID = @FLOWPROCEDUREID@,
+					                PROCEDUREID = @PROCEDUREID@
+				                WHERE 
+					                BARCODE IN
+                                        (
+                                        '60000269701',
+                                        '60000269702',
+                                        '60000269703',
+                                        '60000269704',
+                                        '60000269705'
+                                        )
+				                ",
+                                new CDAParameter("FLOWPROCEDUREID", context.Request["PROCEDUREID"].ToString()),
+                                new CDAParameter("PROCEDUREID", context.Request["PROCEDUREID"].ToString())
+                            );
+
+                            context.Response.Write(new JsonResult( JsonStatus.success).ToJson());
+                            break;
+                        }
+                    default:
+                        {
+                            context.Response.Write(new JsonResult( JsonStatus.error).ToJson());
+                            break;
+                        }
+                }
+            }
+        }
+        else
+        {
+            context.Response.Write(new JsonResult(JsonStatus.loginError).ToJson());
+        }
+    }
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}

+ 37 - 0
wwwroot/test/test.ashx

@@ -0,0 +1,37 @@
+<%@ WebHandler Language="C#" Class="test" %>
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using System.Configuration;
+using Curtain.DataAccess;
+using DK.XuWei.WebMes;
+
+public class test : IHttpHandler
+{
+
+    public void ProcessRequest(HttpContext context)
+    {
+        context.Response.ContentType = "text/plain";
+        WCF wcf = new WCF();
+        wcf.Para.Add(new JProperty("barcode", "10000000001"));
+        wcf.Para.Add(new JProperty("procedure_no", "110"));
+        wcf.Para.Add(new JProperty("road_no", "0"));
+        wcf.Para.Add(new JProperty("rack", ""));
+        wcf.Para.Add(new JProperty("position", ""));
+        wcf.Para.Add(new JProperty("procedure_in", "1"));
+        string jsonStr = wcf.Get("/DKService/ExHGS3QR/AddWorkInfoHGS3_QR");
+    }
+
+    public bool IsReusable
+    {
+        get
+        {
+            return false;
+        }
+    }
+
+}

+ 1 - 0
wwwroot/test/url.txt

@@ -0,0 +1 @@
+http://10.0.8.2:9300/api/DKService/ExHGS3QR/AddWorkInfoHGS3_QR/?road_no=0&barcode=10000000001&procedure_in=1&rack=&position=&procedure_no=110