private static List <CommandParameter> CreateLableCodeInsert(LableCode c) { return(new List <CommandParameter>() { new CommandParameter( "insert into LableCode(LCode,ToLocation,PanelNo,Floor,FloorIndex,Diameter,Length,Coordinates,Cx,Cy,Cz,Crz,GetOutLCode,Remark) " + "values(@LCode,@ToLocation,@PanelNo,@Floor,@FloorIndex,@Diameter,@Length,@Coordinates,@Cx,@Cy,@Cz,@Crz,@GetOutLCode,@Remark)", new SqlParameter[] { new SqlParameter("@LCode", c.LCode), new SqlParameter("@ToLocation", c.ToLocation), c.PanelNo == null?new SqlParameter("@PanelNo", DBNull.Value):new SqlParameter("@PanelNo", c.PanelNo), new SqlParameter("@Floor", c.floor), new SqlParameter("@FloorIndex", c.floorIndex), new SqlParameter("@Diameter", c.diameter), new SqlParameter("@Length", c.length), new SqlParameter("@Coordinates", c.Coordinates), new SqlParameter("@Cx", c.cx), new SqlParameter("@Cy", c.cy), new SqlParameter("@Cz", c.cz), new SqlParameter("@Crz", c.crz), c.getOutLCode == null?new SqlParameter("@GetOutLCode", DBNull.Value):new SqlParameter("@GetOutLCode", c.getOutLCode), c.Remark == null?new SqlParameter("@Remark", DBNull.Value):new SqlParameter("@Remark", c.Remark) }) }); }
private static List <CommandParameter> CreateLableCodeInsertHistory(LableCode c) { return(new List <CommandParameter>() { new CommandParameter( "insert into LableCodeHis(LCode,ToLocation,PanelNo,Status,Floor,FloorIndex,Diameter,Length,Coordinates,Cx,Cy,Cz,Crz,GetOutLCode,Remark,[RealLocation]) " + "values(@LCode,@ToLocation,@PanelNo,@Status,@Floor,@FloorIndex,@Diameter,@Length,@Coordinates,@Cx,@Cy,@Cz,@Crz,@GetOutLCode,@Remark,@RealLocation)", new SqlParameter[] { new SqlParameter("@LCode", c.LCode), new SqlParameter("@ToLocation", c.ToLocation ?? ""), new SqlParameter("@PanelNo", c.PanelNo ?? ""), new SqlParameter("@Status", c.Status), new SqlParameter("@Floor", c.floor), new SqlParameter("@FloorIndex", c.floorIndex), new SqlParameter("@Diameter", c.diameter), new SqlParameter("@Length", c.length), new SqlParameter("@Coordinates", c.Coordinates ?? ""), new SqlParameter("@Cx", c.cx), new SqlParameter("@Cy", c.cy), new SqlParameter("@Cz", c.cz), new SqlParameter("@Crz", c.crz), new SqlParameter("@GetOutLCode", c.getOutLCode ?? ""), new SqlParameter("@Remark", c.Remark ?? ""), new SqlParameter("@RealLocation", c.RealLocation ?? "") }) }); }
public static bool Update(LableCode obj) { var cps = new List <CommandParameter>(); cps.Add(CreateLableCodeUpdate(obj)); cps.Add(CreateInsertPanel(obj.PanelNo, obj.ToLocation)); return(DataAccess.CreateDataAccess.sa.NonQueryTran(cps)); }
/// <summary> /// CatcheQ -> LableUpQ /// </summary> /// <returns></returns> public LableCode GetCacheQ() { LableCode code = null; if (CacheQ.Count > 0) { code = CacheQ.Dequeue(); } return(code); }
public static bool UpdateRealLocation(LableCode obj) { var cps = new List <CommandParameter>() { new CommandParameter(@"update lablecode set reallocation=@reallocation where lcode=@lcode", new SqlParameter[] { new SqlParameter("@lcode", obj.LCode), new SqlParameter("@reallocation", obj.RealLocation) }) }; return(DataAccess.CreateDataAccess.sa.NonQueryTran(cps)); }
/// <summary> /// WeighQ -> CacheQ /// </summary> /// <returns></returns> public LableCode GetWeighQ() { LableCode code = null; if (WeighQ.Count > 0) { code = WeighQ.Dequeue(); } if (code != null && code.ToLocation.Substring(0, 1) == "B") { CacheQ.Enqueue(code); } return(code); }
/// <summary> /// LableUpQ -> CatchAQ or CatchBQ /// </summary> /// <param name="isrun"></param> /// <returns></returns> public LableCode GetLableUpQ() { LableCode code = null; if (LableUpQ.Count > 0) { code = LableUpQ.Peek(); } if (code != null) { code.RealLocation = ""; lock (TaskQueues.LOCK_LOCHELPER) { code.RealLocation = lochelper.Convert(code.ToLocation, code.PanelNo); } if (string.IsNullOrEmpty(code.RealLocation)) { var msg = $"!来源: {nameof(GetLableUpQ)},{code.LCode} 获取真实交地失败: {code.ToLocation}"; onlog?.Invoke(msg, LogType.ROLL_QUEUE); onlog?.Invoke("请查看交地状态。", LogType.ROLL_QUEUE); return(null); } var ok = LableCode.UpdateRealLocation(code); if (!ok) { throw new Exception($"保存标签的实际交地失败"); } code = LableUpQ.Dequeue(); if (int.Parse(LableCode.ParseRealLocationNo(code.RealLocation)) < 6) { CatchAQ.Enqueue(code); } else { CatchBQ.Enqueue(code); } } return(code); }
/// <summary> /// CatchAQ -> RobotRollQ_A /// </summary> /// <returns></returns> public LableCode GetCatchAQ() { LableCode code = null; if (CatchAQ.Count > 0) { code = CatchAQ.Dequeue(); } if (code != null) { var roll = AddRobotRollQ(code.LCode, "A"); if (roll != null) { RobotRollAQ.Enqueue(roll); } } return(code); }
private static CommandParameter CreateLableCodeUpdate(LableCode obj) { return(new CommandParameter(@"UPDATE LableCode SET [PanelNo] = @PanelNo ,[Floor] = @Floor,[FloorIndex] = @FloorIndex,[Coordinates] = @Coordinates ,Cx=@Cx,Cy=@Cy,Cz=@Cz,Crz=@Crz,[GetOutLCode] = @GetOutLCode,[UpdateDate] = @UpdateDate,Status=@Status, [Remark] = @Remark WHERE SequenceNo =@SequenceNo and [LCode] = @LCode and [ToLocation] = @ToLocation", new SqlParameter[] { new SqlParameter("@PanelNo", obj.PanelNo), new SqlParameter("@Floor", obj.floor), new SqlParameter("@FloorIndex", obj.floorIndex), obj.Coordinates == null?new SqlParameter("@Coordinates", DBNull.Value):new SqlParameter("@Coordinates", obj.Coordinates), new SqlParameter("@Cx", obj.cx), new SqlParameter("@Cy", obj.cy), new SqlParameter("@Cz", obj.cz), new SqlParameter("@Crz", obj.crz), obj.getOutLCode == null?new SqlParameter("@GetOutLCode", DBNull.Value):new SqlParameter("@GetOutLCode", obj.getOutLCode), new SqlParameter("@UpdateDate", DateTime.Now), new SqlParameter("@Status", obj.Status), new SqlParameter("@Remark", obj.Remark), new SqlParameter("@SequenceNo", obj.SequenceNo), new SqlParameter("@LCode", obj.LCode), new SqlParameter("@ToLocation", obj.ToLocation) })); }
public IEnumerable <LableCode> GetBeforCacheLables(LableCode lc) { var lcs = from s in CacheQ where s.ToLocation == lc.ToLocation && s.LCode != lc.LCode select s; return(lcs.ToList()); }
/// <summary> /// /// </summary> /// <param name="side"></param> /// <param name="lcode">todo: describe lcode parameter on AddRobotRollQ</param> /// <returns></returns> private static RollPosition AddRobotRollQ(string lcode, string side) { var label = LableCode.QueryByLCode(lcode); if (label == null) { onlog?.Invoke($"!{side} {lcode}在数据库中查不到", LogType.ROLL_QUEUE); return(null); } if (label.Status >= (int)LableState.OnPanel) { onlog?.Invoke($"!{side} {label.LCode}已在板上,未加入机器人队列,交地{label.ToLocation}.", LogType.ROLL_QUEUE); return(null); } if (label.CoordinatesIsEmpty()) { onlog?.Invoke($"!{side} {label.LCode}未算位置,未加入机器人队列,交地{label.ToLocation}.", LogType.ROLL_QUEUE); return(null); } var pinfo = LableCode.GetPanel(label.PanelNo); var state = FrmMain.GetPanelState(label, pinfo); var x = label.Cx; var y = label.Cy; var z = label.Cz + RollPosition.Z_START; var rz = label.Crz; if (rz == 0) { y = RollPosition.GetToolOffSet(y); } else { x = RollPosition.GetToolOffSet(x); } if (x + y > 0) { if (rz == 0) { rz = -180; } } else { if (rz != 0) { rz = rz * -1; } } if (RollPosition.robotRSidePanel.Contains(label.RealLocation)) { rz = rz + 180; } var roll = new RollPosition(label, side, state, x, y, z, rz); onlog?.Invoke($"来源: {nameof(AddRobotRollQ)}, {side} {label.LCode} 名义交地: {label.ToLocation}, 真实交地: {label.RealLocation}, {Enum.GetName(typeof(PanelState), state)}", LogType.ROLL_QUEUE); return(roll); }
public static bool UpdateEdgeExceed(FloorPerformance fp, PanelInfo pInfo, LableCode cur, LableCode fromcache) { var cps = new List <CommandParameter>(); cps.Add(CreateLableCodeUpdate(fromcache)); switch (fp) { case FloorPerformance.BothFinish: if (fromcache.floor == pInfo.MaxFloor || clsSetting.SplintHeight < GetFloorMaxDiameter(cur.PanelNo, cur.floor + 1) + 50) //板满 { cps.Add(new CommandParameter("UPDATE Panel SET Status = @Status,MaxFloor=CurrFloor," + "UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo", new SqlParameter[] { new SqlParameter("@PanelNo", pInfo.PanelNo), new SqlParameter("@Status", LableState.PanelFill), new SqlParameter("@UpdateDate", DateTime.Now) })); cur.PanelNo = PanelGen.NewPanelNo(); cur.floor = 1; cur.floorIndex = 0; cur.Coordinates = null; cur.Crz = 0; cur.Cx = 0; cur.Cy = 0; cur.Cz = 0; cps.Add(CreateLableCodeUpdate(cur)); cps.Add(new CommandParameter("UPDATE LableCode SET Floor = @Floor,PanelNo = @NewPanelNo," + "UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo and FloorIndex=0", new SqlParameter[] { new SqlParameter("@NewPanelNo", cur.PanelNo), new SqlParameter("@PanelNo", pInfo.PanelNo), new SqlParameter("@Floor", cur.floor), new SqlParameter("@UpdateDate", DateTime.Now) })); cps.Add(CreateInsertPanel(cur.PanelNo, cur.ToLocation)); } else //层满 { cur.floor++; cps.Add(CreateLableCodeUpdate(cur)); cps.Add(new CommandParameter("UPDATE LableCode SET Floor = @Floor," + "UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo and FloorIndex=0", new SqlParameter[] { new SqlParameter("@PanelNo", pInfo.PanelNo), new SqlParameter("@Floor", cur.floor), new SqlParameter("@UpdateDate", DateTime.Now) })); cps.Add(new CommandParameter("UPDATE Panel SET CurrFloor = @CurrFloor,OddStatus = @OddStatus,EvenStatus = @EvenStatus," + "UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo", new SqlParameter[] { new SqlParameter("@PanelNo", pInfo.PanelNo), new SqlParameter("@CurrFloor", cur.floor), new SqlParameter("@OddStatus", false), new SqlParameter("@EvenStatus", false), new SqlParameter("@UpdateDate", DateTime.Now) })); } break; case FloorPerformance.None: default: break; } cps.Add(new CommandParameter("UPDATE Panel SET HasExceed=@HasExceed,UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo", new SqlParameter[] { new SqlParameter("@PanelNo", pInfo.PanelNo), new SqlParameter("@HasExceed", pInfo.HasExceed), new SqlParameter("@UpdateDate", DateTime.Now) })); return(DataAccess.CreateDataAccess.sa.NonQueryTran(cps)); }
public static bool Update(FloorPerformance fp, PanelInfo pInfo, LableCode c, LableCode c2 = null) { var cps = new List <CommandParameter>(); cps.Add(CreateLableCodeUpdate(c)); if (c2 != null) { cps.Add(new CommandParameter(@"update LableCode set FloorIndex=@FloorIndex,Coordinates=@Coordinates, Cx=@Cx,Cy=@Cy,Cz=@Cz,Crz=@Crz,Status=@Status,Remark=@Remark,UpdateDate=@UpdateDate where LCode=@LCode", new SqlParameter[] { new SqlParameter("@LCode", c2.LCode), new SqlParameter("@FloorIndex", c2.floorIndex), new SqlParameter("@Coordinates", c2.Coordinates), new SqlParameter("@Cx", c2.cx), new SqlParameter("@Cy", c2.cy), new SqlParameter("@Cz", c2.cz), new SqlParameter("@Crz", c2.crz), new SqlParameter("@Status", c2.Status), c2.Remark == null?new SqlParameter("@Remark", DBNull.Value):new SqlParameter("@Remark", c2.Remark), new SqlParameter("@UpdateDate", DateTime.Now) })); } switch (fp) { case FloorPerformance.OddFinish: case FloorPerformance.EvenFinish: cps.Add(new CommandParameter("UPDATE Panel SET CurrFloor = @CurrFloor,OddStatus = @OddStatus,EvenStatus = @EvenStatus," + "UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo", new SqlParameter[] { new SqlParameter("@PanelNo", c.PanelNo), new SqlParameter("@CurrFloor", c.floor), new SqlParameter("@OddStatus", fp == FloorPerformance.OddFinish), new SqlParameter("@EvenStatus", fp == FloorPerformance.EvenFinish), new SqlParameter("@UpdateDate", DateTime.Now) })); break; case FloorPerformance.BothFinish: if (c.floor == pInfo.MaxFloor || clsSetting.SplintHeight < GetFloorMaxDiameter(c.PanelNo, c.floor + 1) + 50) { cps.Add(new CommandParameter("UPDATE Panel SET Status = @Status,MaxFloor=CurrFloor," + "UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo", new SqlParameter[] { new SqlParameter("@PanelNo", c.PanelNo), new SqlParameter("@Status", LableState.PanelFill), new SqlParameter("@UpdateDate", DateTime.Now) })); if (pInfo.HasExceed) { var panelno = PanelGen.NewPanelNo(); cps.Add(new CommandParameter("UPDATE LableCode SET Floor = 1,PanelNo = @NewPanelNo," + "UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo and FloorIndex=0", new SqlParameter[] { new SqlParameter("@NewPanelNo", panelno), new SqlParameter("@PanelNo", pInfo.PanelNo), new SqlParameter("@UpdateDate", DateTime.Now) })); cps.Add(CreateInsertPanel(panelno, c.ToLocation)); } } else { cps.Add(new CommandParameter("UPDATE Panel SET CurrFloor = @CurrFloor,OddStatus = @OddStatus,EvenStatus = @EvenStatus," + "UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo", new SqlParameter[] { new SqlParameter("@PanelNo", c.PanelNo), new SqlParameter("@CurrFloor", c.floor + 1), new SqlParameter("@OddStatus", false), new SqlParameter("@EvenStatus", false), new SqlParameter("@UpdateDate", DateTime.Now) })); if (pInfo.HasExceed) { cps.Add(new CommandParameter("UPDATE LableCode SET Floor = @Floor," + "UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo and FloorIndex=0", new SqlParameter[] { new SqlParameter("@PanelNo", pInfo.PanelNo), new SqlParameter("@Floor", c.floor + 1), new SqlParameter("@UpdateDate", DateTime.Now) })); } } break; case FloorPerformance.None: default: break; } cps.Add(new CommandParameter("UPDATE Panel SET HasExceed=@HasExceed,UpdateDate = @UpdateDate WHERE PanelNo = @PanelNo", new SqlParameter[] { new SqlParameter("@PanelNo", pInfo.PanelNo), new SqlParameter("@HasExceed", pInfo.HasExceed), new SqlParameter("@UpdateDate", DateTime.Now) })); return(DataAccess.CreateDataAccess.sa.NonQueryTran(cps)); }
public static bool Add(LableCode c) { var cps = CreateLableCodeInsert(c); return(DataAccess.CreateDataAccess.sa.NonQueryTran(cps)); }
public static bool SaveToHistory(LableCode c) { var cps = CreateLableCodeInsertHistory(c); return(DataAccess.CreateDataAccess.sa.NonQueryTran(cps)); }