From d778670d3432cb05f973a81eae8b510e0aeaab10 Mon Sep 17 00:00:00 2001 From: "ruoxing.wang" <88384874@qq.com> Date: Fri, 6 Dec 2024 14:58:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E6=96=99=E7=9C=8B=E6=9D=BF,=E5=A2=9E?= =?UTF-8?q?=E5=8A=A027=E5=8F=B7=E6=96=99=E7=AD=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AddMaterial/App_Code/Function.cs | 1358 +++++++++++++++++++++++------ AddMaterial/App_Code/JsonModel.cs | 17 + AddMaterial/App_Code/Model.cs | 48 +- AddMaterial/Default1.html | 89 ++ AddMaterial/Default2.html | 88 ++ AddMaterial/DefaultNew.html | 73 ++ AddMaterial/DefaultX.html | 98 +++ AddMaterial/Handler.ashx | 491 ++++++++--- 8 files changed, 1905 insertions(+), 357 deletions(-) create mode 100644 AddMaterial/App_Code/JsonModel.cs create mode 100644 AddMaterial/Default1.html create mode 100644 AddMaterial/Default2.html create mode 100644 AddMaterial/DefaultNew.html create mode 100644 AddMaterial/DefaultX.html diff --git a/AddMaterial/App_Code/Function.cs b/AddMaterial/App_Code/Function.cs index 64a58ca..93d6ef5 100644 --- a/AddMaterial/App_Code/Function.cs +++ b/AddMaterial/App_Code/Function.cs @@ -32,7 +32,7 @@ public class Function left join tb_Station d on c.StationID = d.StationID --WHERE datediff(dd,b.Time1,GETDATE())=0 - order by a.CylinderNo + order by a.CylinderNo asc, b.Time1 desc "; DataTable dt1 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); if (dt1 != null && dt1.Rows.Count > 0) @@ -60,7 +60,11 @@ public class Function model.Drum = dt1.Rows[i]["CylinderNo"].ToString(); model.Station = dt1.Rows[i]["StationNo"].ToString(); model.BatchNo = batchNo; - model.Time1 = dt1.Rows[i]["Time1"].ToString(); + model.Time1 = Tools.NumericParse.StringToDateTime(dt1.Rows[i]["Time1"].ToString(), false).ToString("yyyy-MM-dd HH:mm:ss"); + if (model.Time1 == "0001-01-01 00:00:00") + { + model.Time1 = ""; + } if (dt2 != null && dt2.Rows.Count > 0) { model.MaterialName = dt2.Rows[0]["ProductName"].ToString(); @@ -87,6 +91,97 @@ public class Function } } + public static List GetDataX() + { + List list = new List(); + try + { + for (int i = 0; i < 22; i++) + { + Model aa = new Model(); + string a = "00"+ (i+1).ToString(); + aa.Drum = "LT" + a.Substring(a.Length - 2, 2); + list.Add(aa); + } + Model bb = new Model(); + bb.Drum = "LT26"; + list.Add(bb); + + Model bb2 = new Model(); + bb2.Drum = "LT27"; + list.Add(bb2); + + foreach (Model mm in list) + { + string sql = @" + select top 1 * from tb_CylinderAndRaw where DrumBarCode = '" + mm.Drum + @"' order by Time1 desc + "; + DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + if (dt != null && dt.Rows.Count > 0) + { + string str = dt.Rows[0]["BarCode"].ToString(); + string stockNo = ""; + string batchNo = ""; + string partNo = ""; + GetCode(str, out stockNo, out batchNo, out partNo); + + string sql_mat = " select ProductName from tb_Product where PartNo = '" + partNo + "' "; + object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql_mat, null); + if (aa != null) + { + mm.MaterialName = aa.ToString(); + } + + mm.Time1 = dt.Rows[0]["Time1"].ToString(); + mm.BatchNo = batchNo; + } + + mm.Station = ""; + mm.ProductName = ""; + string sql_s = @" select * + from tb_StationAndCylinder + where CylinderNo = '"+ mm.Drum +@"' "; + DataTable dts = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_s, null); + if (dts != null && dts.Rows.Count > 0) + { + for (int i = 0; i < dts.Rows.Count; i++) + { + if (!string.IsNullOrWhiteSpace(dts.Rows[i]["StationNo"].ToString())) + { + mm.Station += dts.Rows[i]["StationNo"].ToString() + ","; + } + + + DataTable dt_product = GetProductName(dts.Rows[i]["StationNo"].ToString()); + if (dt_product != null && dt_product.Rows.Count > 0) + { + if (!string.IsNullOrWhiteSpace(dt_product.Rows[0]["Plan"].ToString())) + { + mm.ProductName += dt_product.Rows[0]["Plan"].ToString() + ","; + } + + } + } + } + + if (mm.Station.Length >= 1) + { + mm.Station = mm.Station.Remove(mm.Station.Length - 1, 1); + } + if (mm.ProductName.Length >= 1) + { + mm.ProductName = mm.ProductName.Remove(mm.ProductName.Length - 1, 1); + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogManager(ex); + LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + } + return list; + } + /// /// 根据注塑机查询计划要生产的产品信息 /// @@ -97,26 +192,46 @@ public class Function DataTable res = new DataTable(); try { - string sql = @" - select top 1 ProductName as [Plan] from tb_Product where StockNo = ( - select top 1 StockNo from tb_InjectionPlan where StationID = ( + string sql = @" + select top 1 StockNo,PartNo from tb_InjectionPlan where StationID = ( select StationID from tb_Station where StationNo = '" + machineCode + @"' ) AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC - ) - "; - res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); - - if (res == null || res.Rows.Count < 1) + "; + DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + if (dt != null && dt.Rows.Count > 0) { - string sql2 = @" select top 1 ProductName as [Plan] from tb_Product where PartNo = ( + string stockNos = dt.Rows[0]["StockNo"].ToString(); + string parts = dt.Rows[0]["PartNo"].ToString(); + if (parts.Contains(",")) + { + string[] part = parts.Split(','); + if (part.Length >= 2) + { + string sql2 = " select ProductName as [Plan] from tb_Product where PartNo in ('" + part[0] + @"','" + part[1] + "')"; + res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); + if (res != null && res.Rows.Count > 0) + { + string xx = ""; + for (int i = 0; i < res.Rows.Count; i++) + { + xx += res.Rows[i]["Plan"].ToString().Trim() + ","; + } + res.Rows[0]["Plan"] = xx.Substring(0, xx.Length - 1); + } + } + } + else + { + string sql2 = @" select top 1 ProductName as [Plan] from tb_Product where PartNo in ( select top 1 PartNo from tb_InjectionPlan where StationID = ( select StationID from tb_Station where StationNo = '" + machineCode + @"' ) AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC ) "; - res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); + res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); + } } return res; @@ -225,7 +340,7 @@ public class Function stockNo = dtt.Rows[0]["StockNo"].ToString(); partNo = dtt.Rows[0]["PartNo"].ToString(); } - if (stockNo.Contains(",")) + if (stockNo.Contains(",") || partNo.Contains(",")) { //生产多个产品 #region 生产计划 @@ -267,8 +382,10 @@ public class Function #region 完成数量等 - string[] stocks = stockNo.Split(','); - string[] parts = partNo.Split(','); + string[] stocks = { "","" }; + stocks = stockNo.Split(','); + string[] parts = { "","" }; + parts = partNo.Split(','); DataTable dt4 = new DataTable(); string sql4 = ""; @@ -285,35 +402,707 @@ public class Function FROM tb_Product_Injection WHERE StationID = '" + stationID + @"' AND (StockNo = '" + stocks[0] + @"' OR PartNo = '" + parts[0] + @"') - AND ProductDate = '" + date + @"' - AND ClassName = '" + GetWorkClass() + @"' + --AND ProductDate = '" + date + @"' + --AND ClassName = '" + GetWorkClass() + @"' AND PlanID = '" + injectionPlanID + @"' "; dt4 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql4, null); + if (stocks.Length < 2) + { + stocks = new string[] { stocks[0], "" }; + } + if (parts.Length < 2) + { + parts = new string[] { parts[0], "" }; + } sql5 = @" SELECT ISNULL(SUM(ISNULL(ProductCount,0)),0) ProductCount, ISNULL(SUM(ISNULL(BadCount,0)),0) BadCount FROM tb_Product_Injection WHERE StationID = '" + stationID + @"' AND (StockNo = '" + stocks[1] + @"' OR PartNo = '" + parts[1] + @"') - AND ProductDate = '" + date + @"' - AND ClassName = '" + GetWorkClass() + @"' + --AND ProductDate = '" + date + @"' + --AND ClassName = '" + GetWorkClass() + @"' AND PlanID = '" + injectionPlanID + @"' "; dt5 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql5, null); - if (dt4 != null && dt4.Rows.Count > 0) + if (dt4 != null && dt4.Rows.Count > 0) + { + int prca = 0; int badca = 0; int prcb = 0; int badcb = 0; + decimal prca_decimal = 0; decimal badca_decimal = 0; decimal prcb_decimal = 0; decimal badcb_decimal = 0; + Decimal.TryParse(dt4.Rows[0]["ProductCount"].ToString(), out prca_decimal); + Decimal.TryParse(dt4.Rows[0]["BadCount"].ToString(), out badca_decimal); + Int32.TryParse(Math.Ceiling(prca_decimal).ToString(), out prca); + Int32.TryParse(Math.Floor(badca_decimal).ToString(), out badca); + + //Int32.TryParse(dt4.Rows[0]["ProductCount"].ToString(), out prca); + //Int32.TryParse(dt4.Rows[0]["BadCount"].ToString(), out badca); + if (dt5 != null && dt5.Rows.Count > 0) + { + Decimal.TryParse(dt4.Rows[0]["ProductCount"].ToString(), out prcb_decimal); + Decimal.TryParse(dt4.Rows[0]["BadCount"].ToString(), out badcb_decimal); + Int32.TryParse(Math.Ceiling(prcb_decimal).ToString(), out prcb); + Int32.TryParse(Math.Floor(badcb_decimal).ToString(), out badcb); + + //Int32.TryParse(dt5.Rows[0]["ProductCount"].ToString(), out prcb); + //Int32.TryParse(dt5.Rows[0]["BadCount"].ToString(), out badcb); + } + + prcb = 0; + badcb = 0; + + model.CompleteCount = (prca + prcb).ToString(); + model.PassCount = (prca + prcb - badca - badcb).ToString(); + + int passc = 0; + double compc = 0.0; + Int32.TryParse(model.PassCount, out passc); + Double.TryParse(model.CompleteCount, out compc); + if (compc == 0.0) + { + model.CompleteRate = "0.0%"; + } + else + { + model.CompleteRate = (passc / compc * 100).ToString("0.00") + "%"; + } + } + + #endregion + + #endregion + + #region 20200928注销 + // string sql = @" + // select a.CylinderNo, d.StationNo, d.StationID, b.BarCode, b.Time1 + // from tb_Cylinder a + // left join tb_CylinderAndRaw b + // on a.CylinderID = b.CylinderID and b.Time2 is null + // left join tb_StationAndCylinder c + // on a.CylinderID = c.CylinderID and c.Time2 is null + // left join tb_Station d + // on c.StationID = d.StationID + // where d.StationNo = '" + stationNo + @"' + // "; + // DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + + // if (dt != null && dt.Rows.Count > 0) + // { + // model.Drum = dt.Rows[0]["CylinderNo"].ToString(); + // model.Time1 = dt.Rows[0]["Time1"].ToString(); + + // string batchNo = ""; + // GetCode(dt.Rows[0]["BarCode"].ToString(), out stockNo, out batchNo, out partNo); + + // model.BatchNo = batchNo; + + // #region 查询原料信息 + + // DataTable dt2 = new DataTable(); + // string sql2 = ""; + // sql2 = " select PartNo, PartName, ProductName from tb_Product where PartNo = '" + partNo + "' "; + // dt2 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); + // if (dt2 != null && dt2.Rows.Count > 0) + // { + // model.MaterialName = dt2.Rows[0]["ProductName"].ToString(); + // } + + // #endregion + + // } + #endregion + + #region 原料相关 + + string sql_mat = @" + select distinct a.DrumBarCode,REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') as BarCode,c.ProductName as MatName + from + ( + select distinct CylinderID + from tb_StationAndCylinder + where StationNo = '" + stationNo + @"' + ) b + join tb_CylinderAndRaw a + on b.CylinderID = a.CylinderID + join tb_Product c + on REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') = c.PartNo + "; + DataTable dt_mat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_mat, null); + if (dt_mat != null && dt_mat.Rows.Count > 0) + { + for (int i = 0; i < dt_mat.Rows.Count; i++) + { + model.Drum += dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + ","; + model.MaterialName += dt_mat.Rows[i]["MatName"].ToString().Trim() + ","; + + string sql_bat = @" + select top 1 * + from tb_CylinderAndRaw + where DrumBarCode = '" + dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + @"' and BarCode like '" + dt_mat.Rows[i]["BarCode"].ToString().Trim() + @"%' order by Time1 desc + "; + DataTable dt_bat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_bat, null); + if (dt_bat != null && dt_bat.Rows.Count > 0) + { + string codeStr = dt_bat.Rows[0]["BarCode"].ToString(); + model.Time1 = dt_bat.Rows[0]["Time1"].ToString(); + + string stockNoa = ""; + string batchNoa = ""; + string partNoa = ""; + GetCode(codeStr, out stockNoa, out batchNoa, out partNoa); + model.BatchNo = batchNoa; + } + } + model.Drum = model.Drum.Remove(model.Drum.Length - 1, 1); + model.MaterialName = model.MaterialName.Remove(model.MaterialName.Length - 1, 1); + } + + + #endregion + } + else + { + //生产一个产品 + DataTable dtPlan = new DataTable(); + + #region 查询生产计划 +// string sqlPlan1 = @" +// select top 1 ProductName as [Plan],StockNo,PartNo from tb_Product where StockNo = ( +// select top 1 StockNo from tb_InjectionPlan where StationID = ( +// select StationID from tb_Station where StationNo = '" + stationNo + @"' ) +// AND (IsFinish IS NULL OR IsFinish = 0) +// ORDER BY BeginTime ASC +// ) +// "; +// dtPlan = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlPlan1, null); + + if (dtPlan == null || dtPlan.Rows.Count < 1) + { + string sqlPlan2 = @" select top 1 ProductName as [Plan],StockNo,PartNo from tb_Product where PartNo = ( + select top 1 PartNo from tb_InjectionPlan where StationID = ( + select StationID from tb_Station where StationNo = '" + stationNo + @"' ) + AND (IsFinish IS NULL OR IsFinish = 0) + ORDER BY BeginTime ASC + ) + "; + dtPlan = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlPlan2, null); + } + if (dtPlan != null && dtPlan.Rows.Count > 0) + { + model.PartNo = dtPlan.Rows[0]["PartNo"].ToString(); + stockNo = dtPlan.Rows[0]["StockNo"].ToString(); + partNo = dtPlan.Rows[0]["PartNo"].ToString(); + } + + #endregion + + #region 查询产品信息 + + DataTable dtProduct = GetProductName(stationNo); + if (dtProduct != null && dtProduct.Rows.Count > 0) + { + model.ProductName = dtProduct.Rows[0][0].ToString(); + } + #endregion + + #region 查询数量 + + #region 查询StationID + + string stationID = ""; + string sqlStationID = " select StationID from tb_Station where StationNo = '" + stationNo + "' "; + stationID = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqlStationID, null).ToString(); + + #endregion + + + #region 计划数量 + DataTable dt3 = new DataTable(); + string sql3 = ""; + if (!string.IsNullOrWhiteSpace(stockNo) || !string.IsNullOrWhiteSpace(partNo)) + { + sql3 = @" SELECT InjectionPlanID, PlanCount FROM tb_InjectionPlan WHERE StationID = '" + stationID + @"' AND (StockNo = '" + stockNo + + "'or PartNo = '" + partNo + "') AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC "; + dt3 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql3, null); + } + string injectionPlanID = ""; + if (dt3 != null && dt3.Rows.Count > 0) + { + model.PlanCount = dt3.Rows[0]["PlanCount"].ToString(); + injectionPlanID = dt3.Rows[0]["InjectionPlanID"].ToString(); + } + #endregion + + #region 完成数量等 + + DataTable dt4 = new DataTable(); + string sql4 = ""; + + string date = DateTime.Now.ToString("yyyy-MM-dd"); + if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 8) + { + date = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); + } + + if (!string.IsNullOrWhiteSpace(stockNo) || !string.IsNullOrWhiteSpace(partNo)) + { + sql4 = @" SELECT ISNULL(SUM(ISNULL(ProductCount,0)),0) ProductCount, ISNULL(SUM(ISNULL(BadCount,0)),0) BadCount + FROM tb_Product_Injection + WHERE StationID = '" + stationID + @"' + AND (StockNo = '" + stockNo + @"' or PartNo = '" + partNo + @"') + --AND ProductDate = '" + date + @"' + --AND ClassName = '" + GetWorkClass() + @"' + AND PlanID = '" + injectionPlanID + @"' + "; + dt4 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql4, null); + } + + if (dt4 != null && dt4.Rows.Count > 0) + { + model.CompleteCount = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(dt4.Rows[0]["ProductCount"].ToString()))).ToString(); + + + int prc = 0; int badc = 0; + Int32.TryParse(Math.Ceiling(Convert.ToDecimal(dt4.Rows[0]["ProductCount"].ToString())).ToString(), out prc); + Int32.TryParse(Math.Ceiling(Convert.ToDecimal(dt4.Rows[0]["BadCount"].ToString())).ToString(), out badc); + //Int32.TryParse(dt4.Rows[0]["BadCount"].ToString(), out badc); + model.PassCount = (prc - badc).ToString(); + + int passc = 0; + double compc = 0.0; + Int32.TryParse(model.PassCount, out passc); + Double.TryParse(model.CompleteCount, out compc); + if (compc == 0.0) + { + model.CompleteRate = "0.0%"; + } + else + { + model.CompleteRate = (passc / compc * 100).ToString("0.00") + "%"; + } + } + + + #endregion + + #region 查询剩余计划零件号和计划数量 + + //string sql_plan = @" select PartNo, PlanCount from tb_InjectionPlan where StationID = '" + dt.Rows[0]["StationID"].ToString() + "' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC "; + string sql_plan = @" + SELECT tb_Product.ProductName ProductName, PlanCount from tb_InjectionPlan + JOIN tb_Product ON tb_Product.PartNo = tb_InjectionPlan.PartNo + WHERE StationID = '" + stationID + @"' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC + "; + DataTable dt_plan = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_plan, null); + if (dt_plan != null && dt_plan.Rows.Count > 0) + { + if (dt_plan.Rows.Count >= 2) + { + //model.PartNo2 = dt_plan.Rows[1]["PartNo"].ToString(); + model.PartNo2 = dt_plan.Rows[1]["ProductName"].ToString(); + model.PlanCount2 = dt_plan.Rows[1]["PlanCount"].ToString(); + } + if (dt_plan.Rows.Count >= 3) + { + //model.PartNo3 = dt_plan.Rows[2]["PartNo"].ToString(); + model.PartNo3 = dt_plan.Rows[2]["ProductName"].ToString(); + model.PlanCount3 = dt_plan.Rows[2]["PlanCount"].ToString(); + } + } + + #endregion + + #endregion + + #region 20200929注销 + // string sql = @" + // select a.CylinderNo, d.StationNo, d.StationID, b.BarCode, b.Time1 + // from tb_Cylinder a + // left join tb_CylinderAndRaw b + // on a.CylinderID = b.CylinderID and b.Time2 is null + // left join tb_StationAndCylinder c + // on a.CylinderID = c.CylinderID and c.Time2 is null + // left join tb_Station d + // on c.StationID = d.StationID + // where d.StationNo = '" + stationNo + @"' + // "; + // DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + + // if (dt != null && dt.Rows.Count > 0) + // { + // model.Drum = dt.Rows[0]["CylinderNo"].ToString(); + // model.Time1 = dt.Rows[0]["Time1"].ToString(); + + // string batchNo = ""; + // GetCode(dt.Rows[0]["BarCode"].ToString(), out stockNo, out batchNo, out partNo); + + // model.BatchNo = batchNo; + + // #region 查询原料信息 + + // DataTable dt2 = new DataTable(); + // string sql2 = ""; + // if (!string.IsNullOrWhiteSpace(stockNo) || !string.IsNullOrWhiteSpace(partNo)) + // { + // sql2 = " select PartNo, PartName, ProductName from tb_Product where StockNo = '" + stockNo + "' or PartNo = '" + partNo + "' "; + // } + // dt2 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); + // if (dt2 != null && dt2.Rows.Count > 0) + // { + // model.MaterialName = dt2.Rows[0]["ProductName"].ToString(); + // } + //} + + // #endregion + #endregion + + #region 原料相关 + + string sql_mat = @" + select distinct a.DrumBarCode,REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') as BarCode,c.ProductName as MatName + from + ( + select distinct CylinderID + from tb_StationAndCylinder + where StationNo = '" + stationNo + @"' + ) b + join tb_CylinderAndRaw a + on b.CylinderID = a.CylinderID + join tb_Product c + on REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') = c.PartNo + "; + DataTable dt_mat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_mat, null); + if (dt_mat != null && dt_mat.Rows.Count > 0) + { + for (int i = 0; i < dt_mat.Rows.Count; i++) + { + model.Drum += dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + ","; + model.MaterialName += dt_mat.Rows[i]["MatName"].ToString().Trim() + ","; + + string sql_bat = @" + select top 1 * + from tb_CylinderAndRaw + where DrumBarCode = '" + dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + @"' and BarCode like '" + dt_mat.Rows[i]["BarCode"].ToString().Trim() + @"%' order by Time1 desc + "; + DataTable dt_bat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_bat, null); + if (dt_bat != null && dt_bat.Rows.Count > 0) + { + string codeStr = dt_bat.Rows[0]["BarCode"].ToString(); + model.Time1 = dt_bat.Rows[0]["Time1"].ToString(); + + string stockNoa = ""; + string batchNoa = ""; + string partNoa = ""; + GetCode(codeStr, out stockNoa, out batchNoa, out partNoa); + model.BatchNo = batchNoa; + } + } + model.Drum = model.Drum.Remove(model.Drum.Length - 1, 1); + model.MaterialName = model.MaterialName.Remove(model.MaterialName.Length - 1, 1); + } + + + #endregion + + #region 存储报表数据 + + Function.InsertInjectPlanReport(injectionPlanID, model.ProductName, model.MaterialName, model.Drum, model.BatchNo, model.Time1); + + #endregion + + } + + res = JSONHelper.ObjectToJSON(model); + return res; + } + catch (Exception ex) + { + LogHelper.WriteLogManager(ex); + LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + return res; + } + } + + public static List GetDataY() + { + List list = new List(); + try + { + for (int i = 22; i <= 24; i++) + { + Model aa = new Model(); + string a = "00" + (i + 1).ToString(); + aa.Drum = "LT" + a.Substring(a.Length - 2, 2); + list.Add(aa); + } + + foreach (Model mm in list) + { + string sql = @" + select top 1 * from tb_CylinderAndRaw where DrumBarCode = '" + mm.Drum + @"' order by Time1 desc + "; + DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + if (dt != null && dt.Rows.Count > 0) + { + string str = dt.Rows[0]["BarCode"].ToString(); + string stockNo = ""; + string batchNo = ""; + string partNo = ""; + GetCode(str, out stockNo, out batchNo, out partNo); + + string sql_mat = " select ProductName from tb_Product where PartNo = '" + partNo + "' "; + object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql_mat, null); + if (aa != null) + { + mm.MaterialName = aa.ToString(); + } + + mm.Time1 = dt.Rows[0]["Time1"].ToString(); + mm.BatchNo = batchNo; + } + + mm.Station = ""; + mm.ProductName = ""; + string sql_s = @" select * + from tb_StationAndCylinder + where CylinderNo = '" + mm.Drum + @"' "; + DataTable dts = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_s, null); + if (dts != null && dts.Rows.Count > 0) + { + for (int i = 0; i < dts.Rows.Count; i++) + { + if (!string.IsNullOrWhiteSpace(dts.Rows[i]["StationNo"].ToString())) + { + mm.Station += dts.Rows[i]["StationNo"].ToString() + ","; + } + + + DataTable dt_product = GetProductName(dts.Rows[i]["StationNo"].ToString()); + if (dt_product != null && dt_product.Rows.Count > 0) + { + if (!string.IsNullOrWhiteSpace(dt_product.Rows[0]["Plan"].ToString())) + { + mm.ProductName += dt_product.Rows[0]["Plan"].ToString() + ","; + } + + } + } + } + + if (mm.Station.Length >= 1) + { + mm.Station = mm.Station.Remove(mm.Station.Length - 1, 1); + } + if (mm.ProductName.Length >= 1) + { + mm.ProductName = mm.ProductName.Remove(mm.ProductName.Length - 1, 1); + } + } + } + catch (Exception ex) + { + LogHelper.WriteLogManager(ex); + LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + } + return list; + } + + /// + /// 天兴美德16号机 + /// + /// + public static string GetPlanTable16() + { + string res = ""; + PlanModel model = new PlanModel(); + try + { + #region 工位号 + + string stationNo = ConfigurationManager.AppSettings["StationNo"].ToString(); + model.Station = stationNo; + + #endregion + + string stockNo = ""; + string partNo = ""; + string stockNosql = @" select top 1 StockNo,PartNo from tb_InjectionPlan where StationID = ( + select StationID from tb_Station where StationNo = '" + stationNo + @"' ) + AND (IsFinish IS NULL OR IsFinish = 0) + ORDER BY BeginTime ASC "; + DataTable dtt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, stockNosql, null); + if (dtt != null && dtt.Rows.Count > 0) + { + stockNo = dtt.Rows[0]["StockNo"].ToString(); + partNo = dtt.Rows[0]["PartNo"].ToString(); + } + if (stockNo.Contains(",") || partNo.Contains(",")) + { + //生产多个产品 + #region 生产计划 + + model.PartNo = dtt.Rows[0]["PartNo"].ToString(); + + #endregion + + #region 产品信息 + + model.ProductName = DF.GetProNameBySP(stockNo, partNo); + + #endregion + + #region 数量 + + #region 计划数量 + + #region 查询StationID + + string stationID = ""; + string sqlStationID = " select StationID from tb_Station where StationNo = '" + stationNo + "' "; + stationID = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqlStationID, null).ToString(); + + #endregion + + DataTable dt3 = new DataTable(); + string sql3 = ""; + sql3 = @" SELECT InjectionPlanID, PlanCount,CompleteCount,BadCount,Qty FROM tb_InjectionPlan WHERE StationID = '" + stationID + @"' AND ( StockNo = '" + stockNo + + "' OR PartNo = '" + partNo + "' ) AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC "; + dt3 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql3, null); + string injectionPlanID = ""; + if (dt3 != null && dt3.Rows.Count > 0) + { + model.PlanCount = dt3.Rows[0]["PlanCount"].ToString(); + injectionPlanID = dt3.Rows[0]["InjectionPlanID"].ToString(); + model.CompleteCount = dt3.Rows[0]["Qty"].ToString(); + model.PassCount = dt3.Rows[0]["CompleteCount"].ToString(); + int passc = 0; + double compc = 0.0; + Int32.TryParse(model.PassCount, out passc); + Double.TryParse(model.CompleteCount, out compc); + if (compc == 0.0) + { + model.CompleteRate = "0.0%"; + } + else + { + model.CompleteRate = (passc / compc * 100).ToString("0.00") + "%"; + } + } + #endregion + + #endregion + + #region 原料相关 + + string sql_mat = @" + select distinct a.DrumBarCode,REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') as BarCode,c.ProductName as MatName + from + ( + select distinct CylinderID + from tb_StationAndCylinder + where StationNo = '" + stationNo + @"' + ) b + join tb_CylinderAndRaw a + on b.CylinderID = a.CylinderID + join tb_Product c + on REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') = c.PartNo + "; + DataTable dt_mat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_mat, null); + if (dt_mat != null && dt_mat.Rows.Count > 0) + { + for (int i = 0; i < dt_mat.Rows.Count; i++) + { + model.Drum += dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + ","; + model.MaterialName += dt_mat.Rows[i]["MatName"].ToString().Trim() + ","; + + string sql_bat = @" + select top 1 * + from tb_CylinderAndRaw + where DrumBarCode = '" + dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + @"' and BarCode like '" + dt_mat.Rows[i]["BarCode"].ToString().Trim() + @"%' order by Time1 desc + "; + DataTable dt_bat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_bat, null); + if (dt_bat != null && dt_bat.Rows.Count > 0) + { + string codeStr = dt_bat.Rows[0]["BarCode"].ToString(); + model.Time1 = dt_bat.Rows[0]["Time1"].ToString(); + + string stockNoa = ""; + string batchNoa = ""; + string partNoa = ""; + GetCode(codeStr, out stockNoa, out batchNoa, out partNoa); + model.BatchNo = batchNoa; + } + } + model.Drum = model.Drum.Remove(model.Drum.Length - 1, 1); + model.MaterialName = model.MaterialName.Remove(model.MaterialName.Length - 1, 1); + } + + + #endregion + } + else + { + //生产一个产品 + DataTable dtPlan = new DataTable(); + + #region 查询生产计划 + + if (dtPlan == null || dtPlan.Rows.Count < 1) + { + string sqlPlan2 = @" select top 1 ProductName as [Plan],StockNo,PartNo from tb_Product where PartNo = ( + select top 1 PartNo from tb_InjectionPlan where StationID = ( + select StationID from tb_Station where StationNo = '" + stationNo + @"' ) + AND (IsFinish IS NULL OR IsFinish = 0) + ORDER BY BeginTime ASC + ) + "; + dtPlan = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlPlan2, null); + } + if (dtPlan != null && dtPlan.Rows.Count > 0) + { + model.PartNo = dtPlan.Rows[0]["PartNo"].ToString(); + stockNo = dtPlan.Rows[0]["StockNo"].ToString(); + partNo = dtPlan.Rows[0]["PartNo"].ToString(); + } + + #endregion + + #region 查询产品信息 + + DataTable dtProduct = GetProductName(stationNo); + if (dtProduct != null && dtProduct.Rows.Count > 0) { - int prca = 0; int badca = 0; int prcb = 0; int badcb = 0; - Int32.TryParse(dt4.Rows[0]["ProductCount"].ToString(), out prca); - Int32.TryParse(dt4.Rows[0]["BadCount"].ToString(), out badca); - if (dt5 != null && dt5.Rows.Count > 0) - { - Int32.TryParse(dt5.Rows[0]["ProductCount"].ToString(), out prcb); - Int32.TryParse(dt5.Rows[0]["BadCount"].ToString(), out badcb); - } - model.CompleteCount = (prca + prcb).ToString(); - model.PassCount = (prca + prcb - badca - badcb).ToString(); + model.ProductName = dtProduct.Rows[0][0].ToString(); + } + #endregion + + #region 查询数量 + + #region 查询StationID + + string stationID = ""; + string sqlStationID = " select StationID from tb_Station where StationNo = '" + stationNo + "' "; + stationID = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqlStationID, null).ToString(); + + #endregion + + #region 计划数量 + DataTable dt3 = new DataTable(); + string sql3 = ""; + if (!string.IsNullOrWhiteSpace(stockNo) || !string.IsNullOrWhiteSpace(partNo)) + { + sql3 = @" SELECT InjectionPlanID, PlanCount,CompleteCount,BadCount,Qty FROM tb_InjectionPlan WHERE StationID = '" + stationID + @"' AND (StockNo = '" + stockNo + + "'or PartNo = '" + partNo + "') AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC "; + dt3 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql3, null); + } + string injectionPlanID = ""; + if (dt3 != null && dt3.Rows.Count > 0) + { + model.PlanCount = dt3.Rows[0]["PlanCount"].ToString(); + injectionPlanID = dt3.Rows[0]["InjectionPlanID"].ToString(); + model.CompleteCount = dt3.Rows[0]["Qty"].ToString(); + model.PassCount = dt3.Rows[0]["CompleteCount"].ToString(); int passc = 0; double compc = 0.0; Int32.TryParse(model.PassCount, out passc); @@ -327,274 +1116,290 @@ public class Function model.CompleteRate = (passc / compc * 100).ToString("0.00") + "%"; } } - - #endregion - #endregion - string sql = @" - select a.CylinderNo, d.StationNo, d.StationID, b.BarCode, b.Time1 - from tb_Cylinder a - left join tb_CylinderAndRaw b - on a.CylinderID = b.CylinderID and b.Time2 is null - left join tb_StationAndCylinder c - on a.CylinderID = c.CylinderID and c.Time2 is null - left join tb_Station d - on c.StationID = d.StationID - where d.StationNo = '" + stationNo + @"' - "; - DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + #region 查询剩余计划零件号和计划数量 - if (dt != null && dt.Rows.Count > 0) + //string sql_plan = @" select PartNo, PlanCount from tb_InjectionPlan where StationID = '" + dt.Rows[0]["StationID"].ToString() + "' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC "; + string sql_plan = @" + SELECT tb_Product.ProductName ProductName, PlanCount from tb_InjectionPlan + JOIN tb_Product ON tb_Product.PartNo = tb_InjectionPlan.PartNo + WHERE StationID = '" + stationID + @"' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC + "; + DataTable dt_plan = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_plan, null); + if (dt_plan != null && dt_plan.Rows.Count > 0) { - model.Drum = dt.Rows[0]["CylinderNo"].ToString(); - model.Time1 = dt.Rows[0]["Time1"].ToString(); - - string batchNo = ""; - GetCode(dt.Rows[0]["BarCode"].ToString(), out stockNo, out batchNo, out partNo); - - model.BatchNo = batchNo; - - #region 查询原料信息 - - DataTable dt2 = new DataTable(); - string sql2 = ""; - sql2 = " select PartNo, PartName, ProductName from tb_Product where StockNo = '" + stocks[0] + "' or PartNo = '" + parts[0] + "' "; - dt2 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); - if (dt2 != null && dt2.Rows.Count > 0) + if (dt_plan.Rows.Count >= 2) { - model.MaterialName = dt2.Rows[0]["ProductName"].ToString(); - - sql2 = " select PartNo, PartName, ProductName from tb_Product where StockNo = '" + stocks[1] + "' or PartNo = '" + parts[1] + "' "; - dt2 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); - model.MaterialName = model.MaterialName + "," + dt2.Rows[0]["ProductName"].ToString(); + //model.PartNo2 = dt_plan.Rows[1]["PartNo"].ToString(); + model.PartNo2 = dt_plan.Rows[1]["ProductName"].ToString(); + model.PlanCount2 = dt_plan.Rows[1]["PlanCount"].ToString(); + } + if (dt_plan.Rows.Count >= 3) + { + //model.PartNo3 = dt_plan.Rows[2]["PartNo"].ToString(); + model.PartNo3 = dt_plan.Rows[2]["ProductName"].ToString(); + model.PlanCount3 = dt_plan.Rows[2]["PlanCount"].ToString(); } - - #endregion - } - } - else - { - //生产一个产品 - DataTable dtPlan = new DataTable(); - #region 查询生产计划 - string sqlPlan1 = @" - select top 1 ProductName as [Plan],StockNo,PartNo from tb_Product where StockNo = ( - select top 1 StockNo from tb_InjectionPlan where StationID = ( - select StationID from tb_Station where StationNo = '" + stationNo + @"' ) - AND (IsFinish IS NULL OR IsFinish = 0) - ORDER BY BeginTime ASC - ) - "; - dtPlan = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlPlan1, null); + #endregion - if (dtPlan == null || dtPlan.Rows.Count < 1) - { - string sqlPlan2 = @" select top 1 ProductName as [Plan],StockNo,PartNo from tb_Product where PartNo = ( - select top 1 PartNo from tb_InjectionPlan where StationID = ( - select StationID from tb_Station where StationNo = '" + stationNo + @"' ) - AND (IsFinish IS NULL OR IsFinish = 0) - ORDER BY BeginTime ASC - ) + #endregion + + #region 原料相关 + + string sql_mat = @" + select distinct a.DrumBarCode,REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') as BarCode,c.ProductName as MatName + from + ( + select distinct CylinderID + from tb_StationAndCylinder + where StationNo = '" + stationNo + @"' + ) b + join tb_CylinderAndRaw a + on b.CylinderID = a.CylinderID + join tb_Product c + on REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') = c.PartNo "; - dtPlan = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sqlPlan2, null); - } - if (dtPlan != null && dtPlan.Rows.Count > 0) + DataTable dt_mat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_mat, null); + if (dt_mat != null && dt_mat.Rows.Count > 0) + { + for (int i = 0; i < dt_mat.Rows.Count; i++) { - model.PartNo = dtPlan.Rows[0]["PartNo"].ToString(); - stockNo = dtPlan.Rows[0]["StockNo"].ToString(); - partNo = dtPlan.Rows[0]["PartNo"].ToString(); + model.Drum += dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + ","; + model.MaterialName += dt_mat.Rows[i]["MatName"].ToString().Trim() + ","; + + string sql_bat = @" + select top 1 * + from tb_CylinderAndRaw + where DrumBarCode = '" + dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + @"' and BarCode like '" + dt_mat.Rows[i]["BarCode"].ToString().Trim() + @"%' order by Time1 desc + "; + DataTable dt_bat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_bat, null); + if (dt_bat != null && dt_bat.Rows.Count > 0) + { + string codeStr = dt_bat.Rows[0]["BarCode"].ToString(); + model.Time1 = dt_bat.Rows[0]["Time1"].ToString(); + + string stockNoa = ""; + string batchNoa = ""; + string partNoa = ""; + GetCode(codeStr, out stockNoa, out batchNoa, out partNoa); + model.BatchNo = batchNoa; + } } + model.Drum = model.Drum.Remove(model.Drum.Length - 1, 1); + model.MaterialName = model.MaterialName.Remove(model.MaterialName.Length - 1, 1); + } - #endregion - #region 查询产品信息 + #endregion - DataTable dtProduct = GetProductName(stationNo); - if (dtProduct != null && dtProduct.Rows.Count > 0) - { - model.ProductName = dtProduct.Rows[0][0].ToString(); - } - #endregion + #region 存储报表数据 - #region 查询数量 + Function.InsertInjectPlanReport(injectionPlanID, model.ProductName, model.MaterialName, model.Drum, model.BatchNo, model.Time1); - #region 查询StationID + #endregion - string stationID = ""; - string sqlStationID = " select StationID from tb_Station where StationNo = '" + stationNo + "' "; - stationID = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqlStationID, null).ToString(); + } - #endregion + res = JSONHelper.ObjectToJSON(model); + return res; + } + catch (Exception ex) + { + LogHelper.WriteLogManager(ex); + LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + return res; + } + } + /// + /// 214 Trunk Box + /// + /// + public static string GetPlanTable17() + { + string res = ""; + PlanModel model = new PlanModel(); - #region 计划数量 - DataTable dt3 = new DataTable(); - string sql3 = ""; - if (!string.IsNullOrWhiteSpace(stockNo)) - { - sql3 = @" SELECT InjectionPlanID, PlanCount FROM tb_InjectionPlan WHERE StationID = '" + stationID + @"' AND StockNo = '" + stockNo + - "' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC "; - } - else if (!string.IsNullOrWhiteSpace(partNo)) - { - sql3 = @" SELECT InjectionPlanID, PlanCount FROM tb_InjectionPlan WHERE StationID = '" + stationID + @"' AND PartNo = '" + partNo + - "' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC "; - } - dt3 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql3, null); - string injectionPlanID = ""; - if (dt3 != null && dt3.Rows.Count > 0) - { - model.PlanCount = dt3.Rows[0]["PlanCount"].ToString(); - injectionPlanID = dt3.Rows[0]["InjectionPlanID"].ToString(); - } - #endregion + try + { + #region 工位号 - #region 完成数量等 + string stationNo = ConfigurationManager.AppSettings["StationNo"].ToString(); + model.Station = stationNo; - DataTable dt4 = new DataTable(); - string sql4 = ""; + #endregion - string date = DateTime.Now.ToString("yyyy-MM-dd"); - if (DateTime.Now.Hour >= 0 && DateTime.Now.Hour < 8) - { - date = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd"); - } + string stockNo = ""; + string partNo = ""; + string stockNosql = @" select top 1 StockNo,PartNo from tb_InjectionPlan where StationID = ( + select StationID from tb_Station where StationNo = '" + stationNo + @"' ) + AND (IsFinish IS NULL OR IsFinish = 0) + ORDER BY BeginTime ASC "; + DataTable dtt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, stockNosql, null); + if (dtt != null && dtt.Rows.Count > 0) + { + stockNo = dtt.Rows[0]["StockNo"].ToString(); + partNo = dtt.Rows[0]["PartNo"].ToString(); + } - if (!string.IsNullOrWhiteSpace(stockNo)) - { - sql4 = @" SELECT ISNULL(SUM(ISNULL(ProductCount,0)),0) ProductCount, ISNULL(SUM(ISNULL(BadCount,0)),0) BadCount - FROM tb_Product_Injection - WHERE StationID = '" + stationID + @"' - AND StockNo = '" + stockNo + @"' - AND ProductDate = '" + date + @"' - AND ClassName = '" + GetWorkClass() + @"' - AND PlanID = '" + injectionPlanID + @"' - "; - } - else if (!string.IsNullOrWhiteSpace(partNo)) - { - sql4 = @" SELECT ISNULL(SUM(ISNULL(ProductCount,0)),0) ProductCount, ISNULL(SUM(ISNULL(BadCount,0)),0) BadCount - FROM tb_Product_Injection - WHERE StationID = '" + stationID + @"' - AND PartNo = '" + partNo + @"' - AND ProductDate = '" + date + @"' - AND ClassName = '" + GetWorkClass() + @"' - AND PlanID = '" + injectionPlanID + @"' - "; - } - dt4 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql4, null); - if (dt4 != null && dt4.Rows.Count > 0) - { - model.CompleteCount = dt4.Rows[0]["ProductCount"].ToString(); + #region 生产计划 + model.PartNo = partNo; - int prc = 0; int badc = 0; - Int32.TryParse(dt4.Rows[0]["ProductCount"].ToString(), out prc); - Int32.TryParse(dt4.Rows[0]["BadCount"].ToString(), out badc); - model.PassCount = (prc - badc).ToString(); + #endregion - int passc = 0; - double compc = 0.0; - Int32.TryParse(model.PassCount, out passc); - Double.TryParse(model.CompleteCount, out compc); - if (compc == 0.0) - { - model.CompleteRate = "0.0%"; - } - else - { - model.CompleteRate = (passc / compc * 100).ToString("0.00") + "%"; - } - } + #region 产品信息 + model.ProductName = DF.GetProNameBySP(stockNo, partNo); - #endregion + #endregion - #region 查询剩余计划零件号和计划数量 + #region 查询StationID - //string sql_plan = @" select PartNo, PlanCount from tb_InjectionPlan where StationID = '" + dt.Rows[0]["StationID"].ToString() + "' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC "; - string sql_plan = @" - SELECT tb_Product.ProductName ProductName, PlanCount from tb_InjectionPlan - JOIN tb_Product ON tb_Product.StockNo = tb_InjectionPlan.StockNo - WHERE StationID = '" + stationID + @"' AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC - "; - DataTable dt_plan = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_plan, null); - if (dt_plan != null && dt_plan.Rows.Count > 0) - { - if (dt_plan.Rows.Count >= 2) - { - //model.PartNo2 = dt_plan.Rows[1]["PartNo"].ToString(); - model.PartNo2 = dt_plan.Rows[1]["ProductName"].ToString(); - model.PlanCount2 = dt_plan.Rows[1]["PlanCount"].ToString(); - } - if (dt_plan.Rows.Count >= 3) - { - //model.PartNo3 = dt_plan.Rows[2]["PartNo"].ToString(); - model.PartNo3 = dt_plan.Rows[2]["ProductName"].ToString(); - model.PlanCount3 = dt_plan.Rows[2]["PlanCount"].ToString(); - } - } + string stationID = ""; + string sqlStationID = " select StationID from tb_Station where StationNo = '" + stationNo + "' "; + stationID = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sqlStationID, null).ToString(); - #endregion + #endregion - #endregion + #region 塑件生产相关信息 - string sql = @" - select a.CylinderNo, d.StationNo, d.StationID, b.BarCode, b.Time1 - from tb_Cylinder a - left join tb_CylinderAndRaw b - on a.CylinderID = b.CylinderID and b.Time2 is null - left join tb_StationAndCylinder c - on a.CylinderID = c.CylinderID and c.Time2 is null - left join tb_Station d - on c.StationID = d.StationID - where d.StationNo = '" + stationNo + @"' - "; - DataTable dt = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + DataTable dt3 = new DataTable(); + string sql3 = ""; + sql3 = @" SELECT InjectionPlanID, PlanCount,CompleteCount FROM tb_InjectionPlan WHERE StationID = '" + stationID + @"' AND ( StockNo = '" + stockNo + + "' OR PartNo = '" + partNo + "' ) AND (IsFinish is null or IsFinish = 0) ORDER BY BeginTime ASC "; + dt3 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql3, null); + string injectionPlanID = ""; + if (dt3 != null && dt3.Rows.Count > 0) + { + model.PlanCount = dt3.Rows[0]["PlanCount"].ToString(); + model.CompleteCount = dt3.Rows[0]["CompleteCount"].ToString(); + injectionPlanID = dt3.Rows[0]["InjectionPlanID"].ToString(); + } - if (dt != null && dt.Rows.Count > 0) - { - model.Drum = dt.Rows[0]["CylinderNo"].ToString(); - model.Time1 = dt.Rows[0]["Time1"].ToString(); + //塑件报废数 + string sql4 = @"SELECT COUNT(ID) as BadCount FROM [BBMPT1].[dbo].[tb_Bad_Injection] WHIT (NOLOCK) + WHERE StationID='" + stationID + @"' AND PlanID='" + injectionPlanID + @"'"; + DataTable dt4 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql4, null); + if (dt4 != null && dt4.Rows.Count > 0) + { + model.BadCount1 = dt4.Rows[0]["BadCount"].ToString(); + } + + //塑件合格率 + int badc = 0; + int compc = 0; + Int32.TryParse(model.BadCount1, out badc); + Int32.TryParse(model.CompleteCount, out compc); + if (compc == 0.0) + { + model.CompleteRate = "0.0%"; + } + else + { + model.CompleteRate = Math.Round(Convert.ToDouble(compc - badc) / Convert.ToDouble(compc)*100, 2).ToString() + "%"; + } - string batchNo = ""; - GetCode(dt.Rows[0]["BarCode"].ToString(), out stockNo, out batchNo, out partNo); + #endregion - model.BatchNo = batchNo; + #region 总成相关 - #region 查询原料信息 + model.PlanCount2 = model.PlanCount; - DataTable dt2 = new DataTable(); - string sql2 = ""; - if (!string.IsNullOrWhiteSpace(stockNo)) - { - sql2 = " select PartNo, PartName, ProductName from tb_Product where StockNo = '" + stockNo + "' "; - } - else if (!string.IsNullOrWhiteSpace(partNo)) - { - sql2 = " select PartNo, PartName, ProductName from tb_Product where PartNo = '" + partNo + "' "; - } - dt2 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql2, null); - if (dt2 != null && dt2.Rows.Count > 0) - { - model.MaterialName = dt2.Rows[0]["ProductName"].ToString(); - } + //总成合格数 + + string sql5 = @"SELECT COUNT(dbo.tb_ZPRecord.OneBarCode) AS ZcPassCount + FROM dbo.tb_ZPRecord LEFT OUTER JOIN + dbo.tb_BarCode5 ON dbo.tb_ZPRecord.OneBarCode = dbo.tb_BarCode5.OneBarCode + WHERE dbo.tb_ZPRecord.OneBarCode LIKE '" + stockNo + @"%' AND tb_BarCode5.PlanID='" + + injectionPlanID + @"' + AND tb_ZPRecord.PrintType=0 "; + DataTable dt5 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql5, null); + if (dt5 != null && dt5.Rows.Count > 0) + { + model.ZcPassCount = dt5.Rows[0]["ZcPassCount"].ToString(); + } - #endregion + //总成报废数 + string sql6 = @"SELECT COUNT(ID) as BadCount FROM [BBMPT1].[dbo].[tb_Bad_Injection] WHIT (NOLOCK) + WHERE StationID='ab38fdad-28ba-4711-8e49-3669d1abaad8' AND PlanID='" + injectionPlanID + @"'"; + DataTable dt6 = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql6, null); + if (dt6 != null && dt6.Rows.Count > 0) + { + model.BadCount2 = dt6.Rows[0]["BadCount"].ToString(); + } - #region 存储报表数据 + //总成合格率 + int badzc = 0; + int compzc = 0; + Int32.TryParse(model.BadCount2, out badzc); + Int32.TryParse(model.ZcPassCount, out compzc); + if (badzc + compzc == 0) + { + model.ZcCompleteRate = "0.0%"; + model.ZcCompleteCount = "0"; + } + else + { + model.ZcCompleteRate = Math.Round(Convert.ToDouble(compzc) / Convert.ToDouble(badzc + compzc) * 100,2) + "%"; + model.ZcCompleteCount = (badzc + compzc).ToString(); + } - Function.InsertInjectPlanReport(injectionPlanID, model.ProductName, model.MaterialName, model.Drum, model.BatchNo, model.Time1); + #endregion - #endregion + #region 原料相关 + + string sql_mat = @" + select distinct a.DrumBarCode,REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') as BarCode,c.ProductName as MatName + from + ( + select distinct CylinderID + from tb_StationAndCylinder + where StationNo = '" + stationNo + @"' + ) b + join tb_CylinderAndRaw a + on b.CylinderID = a.CylinderID + join tb_Product c + on REPLACE(SUBSTRING(a.BarCode,1,charindex('.',a.BarCode)),'.','') = c.PartNo + "; + DataTable dt_mat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_mat, null); + if (dt_mat != null && dt_mat.Rows.Count > 0) + { + for (int i = 0; i < dt_mat.Rows.Count; i++) + { + model.Drum += dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + ","; + model.MaterialName += dt_mat.Rows[i]["MatName"].ToString().Trim() + ","; + + string sql_bat = @" + select top 1 * + from tb_CylinderAndRaw + where DrumBarCode = '" + dt_mat.Rows[i]["DrumBarCode"].ToString().Trim() + @"' and BarCode like '" + dt_mat.Rows[i]["BarCode"].ToString().Trim() + @"%' order by Time1 desc + "; + DataTable dt_bat = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql_bat, null); + if (dt_bat != null && dt_bat.Rows.Count > 0) + { + string codeStr = dt_bat.Rows[0]["BarCode"].ToString(); + model.Time1 = dt_bat.Rows[0]["Time1"].ToString(); + + string stockNoa = ""; + string batchNoa = ""; + string partNoa = ""; + GetCode(codeStr, out stockNoa, out batchNoa, out partNoa); + model.BatchNo = batchNoa; } } + model.Drum = model.Drum.Remove(model.Drum.Length - 1, 1); + model.MaterialName = model.MaterialName.Remove(model.MaterialName.Length - 1, 1); + } + - res = JSONHelper.ObjectToJSON(model); - return res; + #endregion + + res = JSONHelper.ObjectToJSON(model); + return res; } catch (Exception ex) { @@ -603,7 +1408,6 @@ public class Function return res; } } - public static void InsertInjectPlanReport(string injectionPlanID, string ProductName, string MaterialName, string Drum, string BatchNo, string Time1) { @@ -1158,4 +1962,54 @@ public class Function return false; } } + + public static string GetDatetime() + { + string res = ""; + try + { + string sql = @" + select Convert(varchar(20),GETDATE(),120) + "; + object aa = SqlHelper.ExecuteScalar(SqlHelper.SqlConnString, CommandType.Text, sql, null); + if (aa != null) + { + res = aa.ToString(); + } + else + { + res = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + } + } + catch (Exception ex) + { + LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); + } + return res; + } + + public static DataTable GetPaintRecord(out string errorReason) + { + DataTable res = new DataTable(); + try + { + //string sql = @" + // select PaintCode,BucketCode,CreateTime, CASE [State] WHEN 0 THEN '空闲' WHEN 1 THEN '绑定' WHEN 2 THEN '清洗' END AS BucketState + // from tb_AddColorRecord order by BucketCode + // "; + string sql = @"select a.PaintCode,a.BucketCode,a.CreateTime, CASE a.[State] WHEN 0 THEN '空闲' WHEN 1 THEN '绑定' WHEN 2 THEN '清洗' END AS BucketState,ISNULL(b.PaintName,'') AS PaintName + from tb_AddColorRecord a LEFT OUTER JOIN dbo.tb_PaintInfo b ON a.PaintCode=b.PaintCode + ORDER by BucketCode "; + res = SqlHelper.GetDataDateTable(SqlHelper.SqlConnString, CommandType.Text, sql, null); + + errorReason = ""; + return res; + } + catch (Exception ex) + { + LogHelper.WriteLogManager(ex); + errorReason = ex.Message; + return res; + } + } } \ No newline at end of file diff --git a/AddMaterial/App_Code/JsonModel.cs b/AddMaterial/App_Code/JsonModel.cs new file mode 100644 index 0000000..4996f57 --- /dev/null +++ b/AddMaterial/App_Code/JsonModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +/// +/// JsonModel 的摘要说明 +/// +public class JsonModel +{ + public JsonModel() + { + // + // TODO: 在此处添加构造函数逻辑 + // + } +} \ No newline at end of file diff --git a/AddMaterial/App_Code/Model.cs b/AddMaterial/App_Code/Model.cs index 1204a9e..9fd0e84 100644 --- a/AddMaterial/App_Code/Model.cs +++ b/AddMaterial/App_Code/Model.cs @@ -64,23 +64,49 @@ public class PlanModel /// 零件号 /// public string PartNo { get; set; } + /// /// 计划数量 /// public string PlanCount { get; set; } + /// /// 生产数量 /// public string CompleteCount { get; set; } + /// /// 合格数量 /// public string PassCount { get; set; } + + /// + /// 塑件报废数 + /// + public string BadCount1 { get; set; } + /// /// 合格率 /// public string CompleteRate { get; set; } + /// + /// 总成生产数量 + /// + public string ZcCompleteCount { get; set; } + /// + /// 总成数量 + /// + public string ZcPassCount { get; set; } + /// + /// 总成合格率 + /// + public string ZcCompleteRate { get; set; } + + /// + /// 总成报废数 + /// + public string BadCount2 { get; set; } /// /// 零件号 @@ -108,11 +134,29 @@ public class StockModel } -public class PaintInfoModel +public class JsonModel where T : class { - public string BucketCode { get; set; } + //接口调用是否成功,0不成功,1成功 + public string Result { get; set; } + //接口调用返回值类型 + public string ResultType { get; set; } + //返回结果行数 + public string ResultRowsCount { get; set; } + //接口调用不成原因 + public string ErrReason { get; set; } + + public List DataList = new List(); +} +public class PaintRecordModel +{ public string PaintCode { get; set; } + public string BucketCode { get; set; } + public string CreateTime { get; set; } + + public string BucketState { get; set; } + + public string PaintName { get; set; } } \ No newline at end of file diff --git a/AddMaterial/Default1.html b/AddMaterial/Default1.html new file mode 100644 index 0000000..20f9b1e --- /dev/null +++ b/AddMaterial/Default1.html @@ -0,0 +1,89 @@ + + + + + 注塑车间塑料粒子加料目视看板 + + + + + + + + + + + + + + + +
+
注塑车间塑料粒子加料目视看板
+
+
+
+
+
+
+
+ + diff --git a/AddMaterial/Default2.html b/AddMaterial/Default2.html new file mode 100644 index 0000000..73ce8e3 --- /dev/null +++ b/AddMaterial/Default2.html @@ -0,0 +1,88 @@ + + + + + 注塑车间塑料粒子加料目视看板 + + + + + + + + + + + + + + + +
+
注塑车间塑料粒子加料目视看板
+
+
+
+
+
+
+
+ + diff --git a/AddMaterial/DefaultNew.html b/AddMaterial/DefaultNew.html new file mode 100644 index 0000000..857e17c --- /dev/null +++ b/AddMaterial/DefaultNew.html @@ -0,0 +1,73 @@ + + + + + 注塑车间塑料粒子加料目视看板 + + + + + + + + + + + + + + + +
+
注塑车间塑料粒子加料目视看板
+
+
+
+
+ + diff --git a/AddMaterial/DefaultX.html b/AddMaterial/DefaultX.html new file mode 100644 index 0000000..f7459c7 --- /dev/null +++ b/AddMaterial/DefaultX.html @@ -0,0 +1,98 @@ + + + + + 注塑车间塑料粒子加料目视看板 + + + + + + + + + + + + + + + +
+
注塑车间塑料粒子加料目视看板
+
+
+
+
+
+
+
+ + diff --git a/AddMaterial/Handler.ashx b/AddMaterial/Handler.ashx index 76b1591..6a91deb 100644 --- a/AddMaterial/Handler.ashx +++ b/AddMaterial/Handler.ashx @@ -47,9 +47,21 @@ public class Handler : IHttpHandler { case "GetTableX": GetTableX(Convert.ToInt16(j)); break; + case "GetTableY": + GetTableY(Convert.ToInt16(j)); + break; case "GetPlanTable": GetPlanTable(); break; + case "GetDatetime": + GetDatetime(); + break; + case "GetPlanTable16": + GetPlanTable16(); + break; + case "GetPlanTable17": + GetPlanTable17(); + break; default: break; } @@ -716,112 +728,239 @@ public class Handler : IHttpHandler { string GetTableX1(int k) { string html = ""; - List list = Function.GetData(); + //List list = Function.GetData(); + List list = Function.GetDataX(); int tmp = 0; if (list.Count > 0) { for (int j = 0; j <= 5; j++) { html += ""; - for (int i = 0; i <= 4; i++) + + if (k != 20) + //if (k == 0) { - if (k < 20) - { - switch (j) + for (int i = 0; i <= 4; i++) { - case 0: - tmp = k + i; - if ((tmp == 0) || (tmp == 10) || (tmp == 20)) - { - html += ""; - } - if (tmp % 2 == 0) - { - html += ""; - } - else - { - html += ""; - } - break; - case 1: - tmp = k + i; - if ((tmp == 0) || (tmp == 10) || (tmp == 20)) - { - html += ""; - } - if (tmp % 2 == 0) - { - html += ""; - } - else - { - html += ""; - } - break; - case 2: - tmp = k + i; - if ((tmp == 0) || (tmp == 10) || (tmp == 20)) - { - html += ""; - } - if (tmp % 2 == 0) - { - html += ""; - } - else - { - html += ""; - } - break; - case 3: - tmp = k + i; - if ((tmp == 0) || (tmp == 10) || (tmp == 20)) - { - html += ""; - } - if (tmp % 2 == 0) - { - html += ""; - } - else - { - html += ""; - } - break; - case 4: - tmp = k + i; - if ((tmp == 0) || (tmp == 10) || (tmp == 20)) - { - html += ""; - } - if (tmp % 2 == 0) - { - html += ""; - } - else - { - html += ""; - } - break; - case 5: - tmp = k + i; - if ((tmp == 0) || (tmp == 10) || (tmp == 20)) - { - html += ""; - } - if (tmp % 2 == 0) - { - html += ""; - } - else - { - html += ""; - } - break; + switch (j) + { + case 0: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 1: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 2: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 3: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 4: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 5: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + } } + } + else + { + for (int i = 0; i <= 3; i++) + { + switch (j) + { + case 0: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 1: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 2: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 3: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 4: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + case 5: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + + break; + } } } + html += ""; } } @@ -835,7 +974,8 @@ public class Handler : IHttpHandler { string GetTableX2(int k) { string html = "
" + "烘干料筒" + "" + list[tmp].Drum + "" + list[tmp].Drum + "" + "注塑机号" + "" + list[tmp].Station + "" + list[tmp].Station + "" + "产品名称" + "" + list[tmp].ProductName + "" + list[tmp].ProductName + "" + "原料名称" + "" + list[tmp].MaterialName + "" + list[tmp].MaterialName + "" + "加料批次" + "" + list[tmp].BatchNo + "" + list[tmp].BatchNo + "" + "加料时间" + "" + list[tmp].Time1 + "" + list[tmp].Time1 + "" + "烘干料筒" + "" + list[tmp].Drum + "" + list[tmp].Drum + "" + "注塑机号" + "" + list[tmp].Station + "" + list[tmp].Station + "" + "产品名称" + "" + list[tmp].ProductName + "" + list[tmp].ProductName + "" + "原料名称" + "" + list[tmp].MaterialName + "" + list[tmp].MaterialName + "" + "加料批次" + "" + list[tmp].BatchNo + "" + list[tmp].BatchNo + "" + "加料时间" + "" + list[tmp].Time1 + "" + list[tmp].Time1 + "" + "烘干料筒" + "" + list[tmp].Drum + "" + list[tmp].Drum + "" + "注塑机号" + "" + list[tmp].Station + "" + list[tmp].Station + "" + "产品名称" + "" + list[tmp].ProductName + "" + list[tmp].ProductName + "" + "原料名称" + "" + list[tmp].MaterialName + "" + list[tmp].MaterialName + "" + "加料批次" + "" + list[tmp].BatchNo + "" + list[tmp].BatchNo + "" + "加料时间" + "" + list[tmp].Time1 + "" + list[tmp].Time1 + "
"; - List list = Function.GetData(); + //List list = Function.GetData(); + List list = Function.GetDataX(); int tmp = 0; if (list.Count >= 5) { @@ -844,7 +984,7 @@ public class Handler : IHttpHandler { html += ""; for (int i = 5; i < 10; i++) { - if(k<20) + if (k < 20) { switch (j) { @@ -940,7 +1080,7 @@ public class Handler : IHttpHandler { break; } } - + } html += ""; } @@ -952,18 +1092,142 @@ public class Handler : IHttpHandler { return html; } + + void GetTableX(int k) { string result1 = GetTableX1(k); string result2 = GetTableX2(k); - //defaultX result = new defaultX(); - //result.result1 = result1; - //result.result2 = result2; - //Response.Write(Tools.JSONTools.ScriptSerialize(result)); - //Response.End(); + Response.Write(result1 + ";" + result2); Response.End(); } + + void GetTableY(int k) + { + string result1 = GetTableY1(k); + //string result2 = GetTableX2(k); + + Response.Write(result1 ); + Response.End(); + } + + string GetTableY1(int k) + { + string html = "
"; + //List list = Function.GetData(); + List list = Function.GetDataY(); + int tmp = 0; + if (list.Count > 0) + { + for (int j = 0; j <= 5; j++) + { + html += ""; + for (int i = 0; i <= 2; i++) + { + switch (j) + { + case 0: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + break; + case 1: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + break; + case 2: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + break; + case 3: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + break; + case 4: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + break; + case 5: + tmp = k + i; + if ((tmp == 0) || (tmp == 10) || (tmp == 20)) + { + html += ""; + } + if (tmp % 2 == 0) + { + html += ""; + } + else + { + html += ""; + } + break; + } + } + html += ""; + } + } + html += "
" + "烘干料筒" + "" + list[tmp].Drum + "" + list[tmp].Drum + "" + "注塑机号" + "" + list[tmp].Station + "" + list[tmp].Station + "" + "产品名称" + "" + list[tmp].ProductName + "" + list[tmp].ProductName + "" + "原料名称" + "" + list[tmp].MaterialName + "" + list[tmp].MaterialName + "" + "加料批次" + "" + list[tmp].BatchNo + "" + list[tmp].BatchNo + "" + "加料时间" + "" + list[tmp].Time1 + "" + list[tmp].Time1 + "
"; + + //Response.Write(html); + //Response.End(); + return html; + } #endregion @@ -972,6 +1236,27 @@ public class Handler : IHttpHandler { Response.Write(Function.GetPlanTable()); Response.End(); } + + + void GetPlanTable16() + { + Response.Write(Function.GetPlanTable16()); + Response.End(); + } + + void GetPlanTable17() + { + Response.Write(Function.GetPlanTable17()); + Response.End(); + } + + + void GetDatetime() + { + string aa = "
" + Function.GetDatetime() + "
"; + Response.Write(aa); + Response.End(); + } } //public class defaultX