Jelajahi Sumber

光瓷重量接口修改

ztl 2 tahun lalu
induk
melakukan
0b79a27c29
1 mengubah file dengan 41 tambahan dan 5 penghapusan
  1. 41 5
      wwwroot/api/PorcelainWeight2.ashx

+ 41 - 5
wwwroot/api/PorcelainWeight2.ashx

@@ -12,16 +12,21 @@ using DK.XuWei.WebMes;
 /// </summary>
 public class mesPackingIndex : IHttpHandler
 {
-    string procedureid;
+    public string procedureid = "";
+    public string StartTime = "";
+    public string EndTime = "";
     public void ProcessRequest(HttpContext context)
     {
         context.Response.ContentType = "text/plain";
-        procedureid = context.Request["PROCEDUREID"].ToString();
+        procedureid = context.Request["PROCEDUREID"] is object ? context.Request["PROCEDUREID"] : "";
+        StartTime = context.Request["StartTime"] is object ? context.Request["StartTime"] : "";
+        EndTime = context.Request["EndTime"] is object ? context.Request["EndTime"] : "";
+        DataTable dt = new DataTable();
         using (IDataAccess conn = DataAccess.Create())
         {
-            if (procedureid != null)
+            if (procedureid != "" && StartTime == "" && EndTime == "")
             {
-                DataTable dt = new DataTable();
+               
                 dt = conn.ExecuteDatatable(@"
                SELECT
 	                SUM( T.LUSTERWAREWEIGHT * T.count ) LUSTERWAREWEIGHT
@@ -47,8 +52,39 @@ public class mesPackingIndex : IHttpHandler
                 var LUSTERWAREWEIGHT = dt.Rows[0]["LUSTERWAREWEIGHT"].ToString();
                 context.Response.Write(new JsonResult(LUSTERWAREWEIGHT).ToJson());
             }
+            else if (procedureid != "" && StartTime != "" && EndTime != "")
+                {
+                    dt = conn.ExecuteDatatable(@"
+               SELECT
+	                SUM( T.LUSTERWAREWEIGHT * T.count ) LUSTERWAREWEIGHT
+                FROM
+	                (
+	                SELECT
+		                TPPD.GOODSCODE,
+		                TMG.LUSTERWAREWEIGHT,
+		                COUNT( * ) count 
+	                FROM
+		                TP_PM_PRODUCTIONDATA TPPD
+		                LEFT JOIN TP_MST_GOODS TMG ON TPPD.GOODSID = TMG.GOODSID 
+	                WHERE
+		                TPPD.PROCEDUREID = @PROCEDUREID@
+		                AND TPPD.CREATETIME >= TO_date(@StartTime@,'yy-mm-dd hh24:mi:ss')
+						AND TPPD.CREATETIME <= TO_date(@EndTime@,'yy-mm-dd hh24:mi:ss')
+	                GROUP BY
+		                TPPD.GOODSCODE,
+	                TMG.LUSTERWAREWEIGHT
+									) T
+				",
+                    new CDAParameter("PROCEDUREID", procedureid),
+                    new CDAParameter("StartTime", StartTime+"00:00:00"),
+                    new CDAParameter("EndTime", EndTime+"23:59:59")
+            );
+                var LUSTERWAREWEIGHT = dt.Rows[0]["LUSTERWAREWEIGHT"].ToString();
+                context.Response.Write(new JsonResult(LUSTERWAREWEIGHT).ToJson());
+                }
             else {
-                context.Response.Write("请输入对应工序id");
+                    string meagss = "传入的参数不正确";
+                context.Response.Write(new JsonResult(meagss).ToJson());
             }
         }
     }