|
|
@@ -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);
|
|
|
}
|