|
|
@@ -30,6 +30,7 @@ public class plc_led_data : IHttpHandler
|
|
|
public string barCode = "";
|
|
|
|
|
|
string procedure_no;
|
|
|
+ string fentiprocedure_no;
|
|
|
string procedure_in;
|
|
|
string road_no;
|
|
|
string rack;
|
|
|
@@ -45,7 +46,7 @@ public class plc_led_data : IHttpHandler
|
|
|
//输入输出参数初始化 计件
|
|
|
barCode = context.Request["barcode"] is object ? context.Request["barcode"] : "";
|
|
|
procedure_no = context.Request["procedure_no"] is object ? context.Request["procedure_no"] : "1_1_1";
|
|
|
-
|
|
|
+ fentiprocedure_no = "1_1_2";
|
|
|
procedure_in = "1";
|
|
|
road_no = "0";
|
|
|
rack = "";
|
|
|
@@ -76,6 +77,7 @@ public class plc_led_data : IHttpHandler
|
|
|
WHEN instr(gt.goodstypename, '连体') = 1 THEN 1
|
|
|
WHEN instr(gt.goodstypename, '智能') = 1 THEN 2
|
|
|
END AS goodstypename
|
|
|
+ ,CASE WHEN g.goodsid in (178,177,164,163,166,150,149) THEN '分体' ELSE '大件' END AS pritetype
|
|
|
,gdd.barcode
|
|
|
,g.goodscode
|
|
|
FROM tp_pm_groutingdailydetail gdd
|
|
|
@@ -129,78 +131,87 @@ public class plc_led_data : IHttpHandler
|
|
|
+ "," + SiemensS7.Read<short>("400.4") + "," + SiemensS7.Read<short>("400.6") + "," + SiemensS7.Read<short>("400.10") + "," + SiemensS7.Read<string>("400.24", 11) + ";数据:" + new JsonResult(infoDt).ToJson());
|
|
|
}
|
|
|
//调用标准计件方法===============================
|
|
|
- WCF wcf = new WCF();
|
|
|
- wcf.Para.Add(new JProperty("barcode", barCode.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", barCode.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)));
|
|
|
- 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("PLC_扫码", apiUrl, apiStatus, apiResult, apiId, apiBarcodeCount);
|
|
|
- //===============================================
|
|
|
- int i = 0;
|
|
|
- //包装打印是否成功
|
|
|
- if (Convert.ToBoolean(json["success"]) == true)
|
|
|
- {
|
|
|
- SiemensS7.Write<short>("420.0", Convert.ToInt16(1));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SiemensS7.Write<short>("420.0", Convert.ToInt16(2));
|
|
|
- }
|
|
|
- context.Response.Write(SiemensS7.Read<short>("420.0"));
|
|
|
- i = Convert.ToInt16(SiemensS7.Read<short>("420.0"));
|
|
|
- if (i == 2)
|
|
|
+ if (infoDt != null && infoDt.Rows.Count > 0 && infoDt.Rows[0] != null)
|
|
|
{
|
|
|
- //PLC补推
|
|
|
- SiemensS7.Write<short>("420.0", Convert.ToInt16(2));
|
|
|
- }
|
|
|
- else if(i==1){
|
|
|
- //PLC补推
|
|
|
- SiemensS7.Write<short>("420.0", Convert.ToInt16(1));
|
|
|
+ if (infoDt.Rows[0]["pritetype"].ToString() == "分体")
|
|
|
+ {
|
|
|
+ procedure_no = fentiprocedure_no;
|
|
|
+ }
|
|
|
+
|
|
|
+ WCF wcf = new WCF();
|
|
|
+ wcf.Para.Add(new JProperty("barcode", barCode.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", barCode.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)));
|
|
|
+ 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("PLC_扫码", apiUrl, apiStatus, apiResult, apiId, apiBarcodeCount);
|
|
|
+ //===============================================
|
|
|
+ int i = 0;
|
|
|
+ //包装打印是否成功
|
|
|
+ if (Convert.ToBoolean(json["success"]) == true)
|
|
|
+ {
|
|
|
+ SiemensS7.Write<short>("420.0", Convert.ToInt16(1));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ SiemensS7.Write<short>("420.0", Convert.ToInt16(2));
|
|
|
+ }
|
|
|
+ context.Response.Write(SiemensS7.Read<short>("420.0"));
|
|
|
+ i = Convert.ToInt16(SiemensS7.Read<short>("420.0"));
|
|
|
+ if (i == 2)
|
|
|
+ {
|
|
|
+ //PLC补推
|
|
|
+ SiemensS7.Write<short>("420.0", Convert.ToInt16(2));
|
|
|
+ }
|
|
|
+ else if(i==1){
|
|
|
+ //PLC补推
|
|
|
+ SiemensS7.Write<short>("420.0", Convert.ToInt16(1));
|
|
|
+ }
|
|
|
+ Logger.Info("写入数据完成!barcode:" + context.Request["barcode"].ToString() + "一位数据位:" + SiemensS7.Read<short>("420.0"));
|
|
|
+
|
|
|
}
|
|
|
- Logger.Info("写入数据完成!barcode:" + context.Request["barcode"].ToString() + "一位数据位:" + SiemensS7.Read<short>("420.0"));
|
|
|
}
|
|
|
else
|
|
|
{
|