public ChartDataPile GetChartDataWorkshop(string txt, string line, string sum) { var connection = CRUD.GetOpenConnection(); //Random random = new Random(); //List<string> sr = new List<string> { "外纸箱", "小纸盒", "说明书", "空托盘", "成品", "返料" }; //for (int i = 1; i < 1201; i++) //{ // var a = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss dddd").ToDate().AddDays(random.Next(0, 365)).AddHours(random.Next(0, 100)).AddMinutes(random.Next(0, 100)).AddSeconds(random.Next(0, 800)).ToString("yyyy-MM-dd HH:mm:ss dddd"); // var b = a.ToDate().AddSeconds(random.Next(200, 800)).ToString("yyyy-MM-dd HH:mm:ss dddd"); // var c = b.ToDate().AddSeconds(random.Next(800, 1400)).ToString("yyyy-MM-dd HH:mm:ss dddd"); // var y = c.ToDate().AddSeconds(random.Next(1400, 1800)).ToString("yyyy-MM-dd HH:mm:ss dddd"); // connection.Execute($"INSERT INTO `wcs`.`workshoplog`(`Id`, `WSnum`, `WScommand`, `WSanswer`, `WStime`, `WHPrepare`, `AGVstart`, `AGVend`) VALUES ({i}, {random.Next(9, 13)}, '{sr[random.Next(0, 6)]}', 10, '{a}', '{b}', '{c}', '{y}')"); //} List <workshoplog_model> d = connection.Query <workshoplog_model>($"SELECT * FROM `wcs`.`workshoplog` WHERE `WScommand` = '{txt}' AND `WSnum` = '{line}' LIMIT 0,{sum}").AsList(); ChartDataPile cdp = new ChartDataPile(); foreach (workshoplog_model w in d) { { if (w.WScommand == "成品" || w.WScommand == "返料") { if (!string.IsNullOrWhiteSpace(w.WStime) && !string.IsNullOrWhiteSpace(w.AGVstart) && !string.IsNullOrWhiteSpace(w.AGVend)) { cdp.xAxisTitle.Add($"{w.WStime.Substring(5, 11)}"); cdp.timeA.Add($"{(w.AGVstart.ToDateStr() - w.WStime.ToDateStr()).TotalSeconds}".ToInt()); cdp.timeB.Add(0); cdp.timeC.Add($"{(w.AGVend.ToDateStr() - w.AGVstart.ToDateStr()).TotalSeconds}".ToInt()); } } else { if (!string.IsNullOrWhiteSpace(w.WStime) && !string.IsNullOrWhiteSpace(w.WHPrepare) && !string.IsNullOrWhiteSpace(w.AGVstart) && !string.IsNullOrWhiteSpace(w.AGVend)) { cdp.xAxisTitle.Add($"{w.WStime.Substring(5, 11)}"); cdp.timeA.Add($"{(w.AGVstart.ToDateStr() - w.WStime.ToDateStr()).TotalSeconds}".ToInt()); cdp.timeB.Add($"{(w.AGVstart.ToDateStr() - w.WHPrepare.ToDateStr()).TotalSeconds}".ToInt()); cdp.timeC.Add($"{(w.AGVend.ToDateStr() - w.AGVstart.ToDateStr()).TotalSeconds}".ToInt()); } } } } return(cdp); }
public ChartDataPile ViveStack([FromQuery] string txt, string line, string sum) { ChartDataPile dt = db.GetChartDataWorkshop(txt, line, sum); return(dt); }