| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- <%@ WebHandler Language="C#" Class="AddCheckBarcode_WCF" %>
- using System.Web;
- using System.Data;
- using System.Web.SessionState;
- using System.Web.Configuration;
- using Newtonsoft.Json;
- using Newtonsoft.Json.Linq;
- using System.Collections;
- using Curtain.DataAccess;
- using Curtain.Log;
- using DK.XuWei.WebMes;
- /// <summary>
- /// 从WCF接口获取 成检保存
- /// xuwei 2019-11-11
- /// </summary>
- public class AddCheckBarcode_WCF : IHttpHandler, IReadOnlySessionState
- {
- public void ProcessRequest(HttpContext context)
- {
- //处理提交数据
- if(context.Request["productionDataEntitys"] is object)
- {
- //提交到接口
- WCF wcf = new WCF();
- wcf.Para = wcf.LoadParaBySession();
- wcf.Para.Add(new JProperty("procedureID", context.Request["procedureID"]));
- wcf.Para.Add(new JProperty("productionDataEntitys",JArray.Parse(context.Request["productionDataEntitys"])));
- string barcode = context.Request["barcode"];
- string jsonStr = "";
- if (string.IsNullOrWhiteSpace(barcode))
- {
- jsonStr = ("{'success':false,'message':'数据不完整,请刷新页面重新提交!','rows':'" + jsonStr + "'}").Replace("'","\"");
- Logger.Info(jsonStr+ ";保存信息:"+ context.Request["productionDataEntitys"]);
- }
- else
- {
- jsonStr = wcf.Post("/DKService/PDAModuleService/AddCheckBarcode");
- if(jsonStr != "")
- {
- //成检重复提交判断 2020-06-28 xuwei
- if(jsonStr == "重复提交")
- {
- jsonStr = ("{'success':false,'message':'重复提交!','rows':'" + jsonStr + "'}").Replace("'","\"");
- }
- else if(jsonStr.IndexOf("PLC写入失败") >=0 )
- {
- jsonStr = ("{'success':false,'message':'PLC写入失败!','rows':'" + jsonStr + "'}").Replace("'","\"");
- }
- else
- {
- jsonStr = ("{'success':true,'message':'操作成功!','rows':'" + jsonStr + "'}").Replace("'","\"");
- //20230313 重查询该品的大小件,更改返工工序
- using (IDataAccess conn = DataAccess.Create())
- {
- if (!string.IsNullOrEmpty(context.Request["barcode"]+""))
- {
- DataTable dtMatnr = conn.ExecuteDatatable(@"
- SELECT p.productiondataid
- FROM tp_pm_productiondata p
- LEFT JOIN tp_mst_goods g
- ON g.goodsid = p.goodsid
- LEFT JOIN tp_mst_goodstype t
- ON t.goodstypeid = g.goodstypeid
- WHERE p.barcode = @BARCODE@
- AND p.valueflag = '1'
- AND p.goodsleveltypeid = 6
- AND p.reworkprocedureid = 57
- AND instr(t.goodstypecode, '001001') > 0 ",
- new CDAParameter("BARCODE", context.Request["barcode"])
- );
- //大件
- if (dtMatnr.Rows.Count > 0)
- {
- int resultup = conn.ExecuteNonQuery(@"
- UPDATE tp_pm_productiondatain pdi
- SET pdi.reworkprocedureid = 138
- ,pdi.reworkprocedurename = '重烧接收'
- WHERE pdi.productiondataid = @productiondataid@
- ", new CDAParameter("productiondataid",dtMatnr.Rows[0]["productiondataid"])
- );
- int resultup1 = conn.ExecuteNonQuery(@"
- UPDATE tp_pm_productiondata pdi
- SET pdi.reworkprocedureid = 138
- ,pdi.reworkprocedurename = '重烧接收'
- WHERE pdi.productiondataid = @productiondataid@
- ", new CDAParameter("productiondataid",dtMatnr.Rows[0]["productiondataid"])
- );
- int resultup2 = conn.ExecuteNonQuery(@"
- UPDATE tp_pm_inproduction pi
- SET pi.reworkprocedureid = 138
- WHERE pi.barcode = @BARCODE@
- ", new CDAParameter("BARCODE", context.Request["barcode"])
- );
- }
- else
- {
- DataTable dtMatnr1 = conn.ExecuteDatatable(@"
- SELECT p.productiondataid
- FROM tp_pm_productiondata p
- LEFT JOIN tp_mst_goods g
- ON g.goodsid = p.goodsid
- LEFT JOIN tp_mst_goodstype t
- ON t.goodstypeid = g.goodstypeid
- WHERE p.barcode = @BARCODE@
- AND p.valueflag = '1'
- AND p.goodsleveltypeid = 6
- AND p.reworkprocedureid = 138
- AND instr(t.goodstypecode, '001002') > 0 ",
- new CDAParameter("BARCODE", context.Request["barcode"])
- );
- //小件
- if (dtMatnr1.Rows.Count > 0)
- {
- int resultup = conn.ExecuteNonQuery(@"
- UPDATE tp_pm_productiondatain pdi
- SET pdi.reworkprocedureid = 57
- ,pdi.reworkprocedurename = '4-5重烧交接'
- WHERE pdi.productiondataid = @productiondataid@
- ", new CDAParameter("productiondataid",dtMatnr1.Rows[0]["productiondataid"])
- );
- int resultup1 = conn.ExecuteNonQuery(@"
- UPDATE tp_pm_productiondata pdi
- SET pdi.reworkprocedureid = 57
- ,pdi.reworkprocedurename = '4-5重烧交接'
- WHERE pdi.productiondataid = @productiondataid@
- ", new CDAParameter("productiondataid",dtMatnr1.Rows[0]["productiondataid"])
- );
- int resultup2 = conn.ExecuteNonQuery(@"
- UPDATE tp_pm_inproduction pi
- SET pi.reworkprocedureid = 57
- WHERE pi.barcode = @BARCODE@
- ", new CDAParameter("BARCODE", context.Request["barcode"])
- );
- }
- }
- }
- }
- }
- }
- else
- {
- jsonStr = ("{'success':false,'message':'操作失败!','rows':'" + jsonStr + "'}").Replace("'","\"");
- }
-
- }
- context.Response.Write(jsonStr);
- }
- else
- {
- string jsonStr = ("{'success':false,'message':'操作失败!','rows':''}").Replace("'","\"");
- context.Response.Write(jsonStr);
- }
- }
- public bool IsReusable
- {
- get
- {
- return false;
- }
- }
- }
|