姜永辉 10 mēneši atpakaļ
vecāks
revīzija
4804878a06

+ 15 - 0
wwwroot/mes/rpt/rpt.ashx

@@ -707,7 +707,22 @@ public class rpt : IHttpHandler, IReadOnlySessionState
                         }
                         break;
                     }
+case "getgoodsleve":
+                    {
+                        //获取产品型号 全部
+                        using (IDataAccess conn = DataAccess.Create())
+                        {
+                            DataTable dt = conn.ExecuteDatatable(@"
+                                SELECT GOODSLEVELID,GOODSLEVELNAME FROM TP_MST_GOODSLEVEL WHERE GOODSLEVELID IN(1,2,3,4,5,6,7,8,9)
+                            "   );
 
+                            if (context.Request["select"] is object)
+                                context.Response.Write(dt.ToJson());
+                            else
+                                context.Response.Write(new JsonResult(dt).ToJson());
+                        }
+                        break;
+                    }
                 default:
                     {
                         break;

+ 92 - 60
wwwroot/mes/rpt/rpt041/rpt.ashx

@@ -18,90 +18,122 @@ public class rpt : IHttpHandler, IReadOnlySessionState
         context.Response.ContentType = "text/plain";
         using (IDataAccess conn = DataAccess.Create())
         {
+            //获取查询条件
+            List<CDAParameter> sqlPara = new List<CDAParameter>();
             string sqlStr = @"
 				SELECT
 	goods.GOODSCODE,
 	goods.GOODSNAME,
 	d.DICTIONARYVALUE,
-	logo.LOGONAME ,
-	pfirst.createtime  PFIRSTCREATETIME, 
-	pfirst.usercode  PFIRSTUSERCODE,
-	pfirst.username  PFIRSTUSERNAME, 
-    (SELECT GOODSLEVELNAME FROM TP_MST_GOODSLEVEL WHERE GOODSLEVELID= pfirst.goodsleveltypeid) PFIRSTGOODSLEVE ,
-	(SELECT GOODSLEVELNAME FROM TP_MST_GOODSLEVEL WHERE GOODSLEVELID= pd.goodsleveltypeid) PDGOODSLEVE ,
-	pd.createtime  PDCREATETIME, 
- 	pd.usercode PDUSERCODE,
- 	pd.username PDUSERNAME,
-	pd.BARCODE 
-FROM
-	tp_pm_productiondata_semicheck sec
-	INNER JOIN tp_pm_productiondata pd ON sec.productiondataid = pd.productiondataid
-	LEFT JOIN tp_pm_productiondata pfirst ON pfirst.groutingdailydetailid = pd.groutingdailydetailid 
-	AND pfirst.checkflag = '1' 
-	AND pfirst.procedureid IN ( 13, 35 )
-	LEFT JOIN TP_MST_GOODS goods ON goods.GOODSCODE = pd.GOODSCODE
-	LEFT JOIN TP_MST_LOGO logo ON logo.LOGOID = pd.LOGOID 
-	LEFT JOIN tp_pm_groutingdailydetail g ON g.groutingdailydetailid = pfirst.groutingdailydetailid
-	LEFT JOIN tp_mst_datadictionary d ON g.glazetypeid = d.dictionaryid  
-WHERE
-	sec.valueflag = 1 ";
+	logo.LOGONAME,
+	pfirst.createtime PFIRSTCREATETIME,
+	pfirst.usercode PFIRSTUSERCODE,
+	pfirst.username PFIRSTUSERNAME,
+	( SELECT GOODSLEVELNAME FROM TP_MST_GOODSLEVEL WHERE GOODSLEVELID = pfirst.goodsleveltypeid ) PFIRSTGOODSLEVE,
+	( SELECT GOODSLEVELNAME FROM TP_MST_GOODSLEVEL WHERE GOODSLEVELID = pd.goodsleveltypeid ) PDGOODSLEVE,
+CASE
+		
+		WHEN pd.usercode IS NULL AND pd.createtime IS NULL THEN '合计' 
+		WHEN pd.usercode IS NOT NULL  AND pd.createtime IS NULL THEN
+				'小计' ELSE TO_CHAR( pd.createtime, 'YYYY-MM-DD HH24:MI:SS' ) 
+				END AS PDCREATETIME,
+			pd.usercode PDUSERCODE,
+		CASE
+				
+				WHEN pd.username IS NULL THEN
+				TO_NCHAR( COUNT( * ) ) ELSE pd.username 
+			END AS PDUSERNAME,
+			pd.BARCODE 
+		FROM
+			(
+			SELECT
+				sc.*,
+				ROW_NUMBER ( ) OVER ( PARTITION BY sc.productiondataid, TRUNC( sc.CREATETIME ) ORDER BY sc.CREATETIME DESC ) AS rn 
+			FROM
+				tp_pm_productiondata_semicheck sc 
+			) sec
+			INNER JOIN tp_pm_productiondata pd ON sec.productiondataid = pd.productiondataid 
+			AND sec.rn = 1
+			LEFT JOIN tp_pm_productiondata pfirst ON pfirst.groutingdailydetailid = pd.groutingdailydetailid 
+			AND pfirst.checkflag = '1' 
+			AND pfirst.procedureid IN ( 13, 35 )
+			LEFT JOIN TP_MST_GOODS goods ON goods.GOODSCODE = pd.GOODSCODE
+			LEFT JOIN TP_MST_LOGO logo ON logo.LOGOID = pd.LOGOID
+			LEFT JOIN tp_pm_groutingdailydetail g ON g.groutingdailydetailid = pfirst.groutingdailydetailid
+			LEFT JOIN tp_mst_datadictionary d ON g.glazetypeid = d.dictionaryid 
+		WHERE
+			sec.valueflag = 1 ";
             if (context.Request["firstdatebeginMaster"].ToString() != "")
             {
                 sqlStr += " and pfirst.CREATETIME>=@firstdatebeginMaster@";
+                sqlPara.Add(new CDAParameter("firstdatebeginMaster", Convert.ToDateTime(context.Request["firstdatebeginMaster"]), DataType.DateTime));
+
             }
             if (context.Request["firstdateendMaster"].ToString() != "")
             {
                 sqlStr += " and pfirst.CREATETIME<=@firstdateendMaster@";
+                sqlPara.Add(new CDAParameter("firstdateendMaster", Convert.ToDateTime(context.Request["firstdateendMaster"]).AddSeconds(1), DataType.DateTime));
+
             }
             if (context.Request["twodatebeginMaster"].ToString() != "")
             {
                 sqlStr += " and sec.CREATETIME>=@twodatebeginMaster@";
+                sqlPara.Add(new CDAParameter("twodatebeginMaster", Convert.ToDateTime(context.Request["twodatebeginMaster"]), DataType.DateTime));
+
             }
             if (context.Request["twodateendMaster"].ToString() != "")
             {
                 sqlStr += " and sec.CREATETIME<=@twodateendMaster@";
-            }
-            ////预备出以后的查询条件 
-            //if (context.Request["GOODSCODE"].ToString() != "")
-            //{
-            //    sqlStr += " and goods.GOODSCODE=@GOODSCODE@";
-
-            //}
-            //if (context.Request["BARCODE"].ToString() != "")
-            //{
-            //    sqlStr += " and pd.BARCODE =@BARCODE@";
-
-            //}
-            ////首检工号
-            //if (context.Request["usercode"].ToString() != "")
-            //{
-            //    sqlStr += " and pfirst.usercode =@usercode@";
-            //}
-            ////复检工号
-            //if (context.Request["usercode2"].ToString() != "")
-            //{
-            //    sqlStr += " and pd.usercode =@usercode2@";
-            //}
-            //获取查询条件
-            List<CDAParameter> sqlPara = new List<CDAParameter>();
-            sqlPara.Add(new CDAParameter("firstdatebeginMaster", Convert.ToDateTime(context.Request["firstdatebeginMaster"]), DataType.DateTime));
-            sqlPara.Add(new CDAParameter("firstdateendMaster", Convert.ToDateTime(context.Request["firstdateendMaster"]).AddSeconds(1), DataType.DateTime));
-            sqlPara.Add(new CDAParameter("twodatebeginMaster", Convert.ToDateTime(context.Request["twodatebeginMaster"]), DataType.DateTime));
-            sqlPara.Add(new CDAParameter("twodateendMaster", Convert.ToDateTime(context.Request["twodateendMaster"]).AddSeconds(1), DataType.DateTime));
-
-
+                sqlPara.Add(new CDAParameter("twodateendMaster", Convert.ToDateTime(context.Request["twodateendMaster"]).AddSeconds(1), DataType.DateTime));
 
+            }
+            //产品编码 
+            if (context.Request["GOODSCODE"].ToString() != "")
+            {
+                sqlStr += " and goods.GOODSCODE=@GOODSCODE@";
+                sqlPara.Add(new CDAParameter("GOODSCODE", context.Request["GOODSCODE"]));
+            }
+            //产品条码
+            if (context.Request["BARCODE"].ToString() != "")
+            {
+                sqlStr += " and pd.BARCODE =@BARCODE@";
+                sqlPara.Add(new CDAParameter("BARCODE", context.Request["BARCODE"]));
+            }
+            //首检工号
+            if (context.Request["pfirstusercode"].ToString() != "")
+            {
+                sqlStr += " and pfirst.usercode =@pfirstusercode@";
+                sqlPara.Add(new CDAParameter("pfirstusercode", context.Request["pfirstusercode"]));
+            }
+            //复检工号
+            if (context.Request["pdusercode"].ToString() != "")
+            {
+                sqlStr += " and pd.usercode =@pdusercode@";
+                sqlPara.Add(new CDAParameter("pdusercode", context.Request["pdusercode"]));
+            }
+            //首检质量
+            if (context.Request["pfirstgoodleve"].ToString() != "")
+            {
+                sqlStr += " and pfirst.goodsleveltypeid =@pfirstgoodleve@";
+                sqlPara.Add(new CDAParameter("pfirstgoodleve", context.Request["pfirstgoodleve"]));
+            }//复检质量
+            if (context.Request["pdgoodleve"].ToString() != "")
+            {
+                sqlStr += " and pd.goodsleveltypeid =@pdgoodleve@";
+                sqlPara.Add(new CDAParameter("pdgoodleve", context.Request["pdgoodleve"]));
+            }
+            sqlStr += " GROUP BY GROUPING SETS (" +
+                "( goods.GOODSCODE, goods.GOODSNAME," +
+                    "d.DICTIONARYVALUE, logo.LOGONAME," +
+                    "pfirst.createtime, pfirst.usercode," +
+                    "pfirst.username, pfirst.goodsleveltypeid," +
+                    "pd.goodsleveltypeid, pd.createtime," +
+                    "pd.usercode, pd.username, pd.BARCODE " +
+                "), ( pD.usercode ), ( )  ) ";
             //获取分页数据    
             int total = 0;
             DataTable dt = conn.ExecuteDatatable(sqlStr, sqlPara.ToArray());
-            if (dt.Rows.Count > 0)
-            {
-                DataRow dr = dt.NewRow();
-                dr[6] = "合计";
-                dr[7] = dt.Rows.Count;
-                dr[8] = dt.Rows.Count;
-                dt.Rows.Add(dr);
-            }
+
             string jsonStr = new JsonResult(dt) { total = total }.ToJson();
             context.Response.Write(jsonStr);
         }

+ 17 - 0
wwwroot/mes/rpt/rpt041/rpt_index.html

@@ -24,13 +24,30 @@
 						<input class="easyui-datetimebox" id="firstdatebeginMaster" name="firstdatebeginMaster" data-options="required:true,prompt:'开始日期必须填写!',tipPosition:'top'" style="width:180px; height:32px;">
 						-
 						<input class="easyui-datetimebox" id="firstdateendMaster" name="firstdateendMaster" data-options="required:true,prompt:'截止日期必须填写',tipPosition:'top'" style="width:180px; height:32px;">
+						产品编码:
+						<input class="easyui-combobox" id="GOODSCODE" name="GOODSCODE" data-options="required:false,prompt:'',tipPosition:'top',url:'../rpt.ashx?m=getGoods&select=1',method:'get',valueField:'GOODSCODE',textField:'GOODSCODE',panelHeight:'300px',editable:'true'" style="width:120px;height:32px;">
+						首检工号:
+						<input class="easyui-combobox" id="pfirstusercode" name="pfirstusercode" data-options="required:false,prompt:'',tipPosition:'top',url:'../rpt.ashx?m=getUser&select=1',method:'get',valueField:'USERCODE',textField:'USERCODE',panelHeight:'300px',editable:'true'" style="width:120px;height:32px;">
+						复检工号:
+						<input class="easyui-combobox" id="pdusercode" name="pdusercode" data-options="required:false,prompt:'',tipPosition:'top',url:'../rpt.ashx?m=getUser&select=1',method:'get',valueField:'USERCODE',textField:'USERCODE',panelHeight:'300px',editable:'true'" style="width:120px;height:32px;">
+
+					</div>
+					<div style="padding-top:10px">
 						复检日期:
 						<input class="easyui-datetimebox" id="twodatebeginMaster" name="twodatebeginMaster" data-options="required:true,prompt:'开始日期必须填写!',tipPosition:'top'" style="width:180px; height:32px;">
 						-
 						<input class="easyui-datetimebox" id="twodateendMaster" name="twodateendMaster" data-options="required:true,prompt:'截止日期必须填写',tipPosition:'top'" style="width:180px; height:32px;">
 
+						首检质量:
+						<input class="easyui-combobox" id="pfirstgoodleve" name="pfirstgoodleve" data-options="required:false,prompt:'',tipPosition:'top',url:'../rpt.ashx?m=getgoodsleve&select=1',method:'get',valueField:'GOODSLEVELID',textField:'GOODSLEVELNAME',panelHeight:'300px',editable:'true'" style="width:120px;height:32px;">
+						复检质量:
+						<input class="easyui-combobox" id="pdgoodleve" name="pdgoodleve" data-options="required:false,prompt:'',tipPosition:'top',url:'../rpt.ashx?m=getgoodsleve&select=1',method:'get',valueField:'GOODSLEVELID',textField:'GOODSLEVELNAME',panelHeight:'300px',editable:'true'" style="width:120px;height:32px;">
+						产品条码:
+						<input class="easyui-textbox" id="BARCODE" name="BARCODE" data-options="required:false,prompt:'',tipPosition:'top',url:'../rpt.ashx?m=getUser&select=1',method:'get',valueField:'USERCODE',textField:'USERCODE',panelHeight:'300px',editable:'true'" style="width:120px;height:32px;">
+
 						<a href="javascript:void(0)" id="btnSearchSubmit" title="清空" class="easyui-linkbutton" plain="false" onclick="$('#ffMaster').form('clear')">清空</a>
 						<a href="javascript:void(0)" id="btnSearchSubmit" title="搜索" class="easyui-linkbutton" plain="false" onclick="tbSearchSubmit()">搜索</a>
+
 					</div>
 				</form>
 			</div>