diff --git a/余材替代程序/SinglePlateHandle/SinglePlateHandle/SurMatSubController.cs b/余材替代程序/SinglePlateHandle/SinglePlateHandle/SurMatSubController.cs index 22e4396..9cd314f 100644 --- a/余材替代程序/SinglePlateHandle/SinglePlateHandle/SurMatSubController.cs +++ b/余材替代程序/SinglePlateHandle/SinglePlateHandle/SurMatSubController.cs @@ -192,8 +192,8 @@ namespace ibk.IPD.Controller.IPD_PS //手动匹配钢板 private static IList gTB_PLATE_MANUAL = new List(); - - //取样判断信息记录 物理性能 取样 + + ////取样判断信息记录 物理性能 取样 private static ConcurrentBag gTPM = new ConcurrentBag(); //手动匹配钢板 @@ -1525,20 +1525,30 @@ namespace ibk.IPD.Controller.IPD_PS DateTime DATE_2 = DateTime.Now; TimeSpan timeDifference_1 = DATE_2 - DATE_1; logger.InfoFormat("多线程获取数据用时:{0}", timeDifference_1); - + //gTPM = new ConcurrentBag();//初始化匹配过程信息 物理,化学,取样,标准 logger.InfoFormat("******* 开始统计匹配数据 *******"); DateTime DATE_3 = DateTime.Now; - gTPM = new ConcurrentBag();//初始化匹配过程信息 物理,化学,取样,标准 - foreach (BP_ORDER_ITEM order in orderEntities) { + //测试 //logger.InfoFormat("订单:{0}-{1}", order.ORD_NO, order.ORD_ITEM); #region 线程 tasks[intTask] = Task.Factory.StartNew(() => { + //gTPM = new ConcurrentBag();//初始化匹配过程信息 物理,化学,取样,标准 + + // 方法1:TryTake 清空(推荐) + //while (gTPM.TryTake(out _)) { } + //Console.WriteLine($"{order.ORD_NO}-{order.ORD_ITEM} 清空后: {gTPM.Count}"); // 0 + + // 方法2:Interlocked.Exchange 替换 + var newBag = new ConcurrentBag(); + var oldBag = Interlocked.Exchange(ref gTPM, newBag); + //logger.Info($"{order.ORD_NO}-{order.ORD_ITEM} 替换后: {gTPM.Count}"); // 0 + decimal decLen = ConverDataToDecimal(order.ORD_LEN); if (order.SIZE_KND == "02" && ConverDataToDecimal(order.ORD_LEN_MIN) != 0) { @@ -2508,7 +2518,7 @@ namespace ibk.IPD.Controller.IPD_PS else { IsWG = true; - logger.InfoFormat("钢板:{0},订单号:{1}-{2},仓库:{3},货位:{4},替代方式:{5}", itemGP_PLATE.PLATE_NO, order.ORD_NO, order.ORD_ITEM, itemGP_PLATE.CUR_INV, itemGP_PLATE.LOC, itemGP_PLATE.SUB_FULL); + //logger.InfoFormat("钢板:{0},订单号:{1}-{2},仓库:{3},货位:{4},替代方式:{5}", itemGP_PLATE.PLATE_NO, order.ORD_NO, order.ORD_ITEM, itemGP_PLATE.CUR_INV, itemGP_PLATE.LOC, itemGP_PLATE.SUB_FULL); } } else @@ -4027,7 +4037,7 @@ namespace ibk.IPD.Controller.IPD_PS else { IsWG = true; - logger.InfoFormat("钢板:{0},订单号:{1}-{2},仓库:{3},货位:{4},替代方式:{5}", itemGP_PLATE.PLATE_NO, order.ORD_NO, order.ORD_ITEM, itemGP_PLATE.CUR_INV, itemGP_PLATE.LOC, itemGP_PLATE.SUB_FULL); + //logger.InfoFormat("钢板:{0},订单号:{1}-{2},仓库:{3},货位:{4},替代方式:{5}", itemGP_PLATE.PLATE_NO, order.ORD_NO, order.ORD_ITEM, itemGP_PLATE.CUR_INV, itemGP_PLATE.LOC, itemGP_PLATE.SUB_FULL); } } else @@ -15780,6 +15790,17 @@ namespace ibk.IPD.Controller.IPD_PS { #region 记录临时数据 + string strinfo = "匹配数据成功-->钢板号:" + + prP_PLATE.PLATE_NO + ";订单号:" + + prorder.ORD_NO + "-" + prorder.ORD_ITEM + + ";过程数据:" + gTPM.Count() + ";判断数据:" + + gTPM.Where(p => + p.PLATE_NO == prP_PLATE.PLATE_NO + && p.ORD_NO==prorder.ORD_NO + && p.ORD_ITEM == prorder.ORD_ITEM).Count(); + + //logger.Info("匹配数据成功-->钢板号:"+ prP_PLATE.PLATE_NO + ";订单号:" + prorder.ORD_NO + "-" + prorder.ORD_ITEM); + logger.Info(strinfo); TEMP_DATA td = new TEMP_DATA(); //标记是否切割替代 true标记 @@ -17032,7 +17053,7 @@ namespace ibk.IPD.Controller.IPD_PS } catch (Exception ex) { - throw; + logger.Info("添加数据报错:" + ex.ToString()); } diff --git a/余材替代程序/SinglePlateHandle/SinglePlateHandle/bin/Debug/SinglePlateHandle.exe b/余材替代程序/SinglePlateHandle/SinglePlateHandle/bin/Debug/SinglePlateHandle.exe index f5b3de7..61d6339 100644 Binary files a/余材替代程序/SinglePlateHandle/SinglePlateHandle/bin/Debug/SinglePlateHandle.exe and b/余材替代程序/SinglePlateHandle/SinglePlateHandle/bin/Debug/SinglePlateHandle.exe differ diff --git a/余材替代程序/SinglePlateHandle/SinglePlateHandle/bin/Debug/SinglePlateHandle.pdb b/余材替代程序/SinglePlateHandle/SinglePlateHandle/bin/Debug/SinglePlateHandle.pdb index 99414d3..8f43630 100644 Binary files a/余材替代程序/SinglePlateHandle/SinglePlateHandle/bin/Debug/SinglePlateHandle.pdb and b/余材替代程序/SinglePlateHandle/SinglePlateHandle/bin/Debug/SinglePlateHandle.pdb differ diff --git a/余材替代程序/SinglePlateHandle/SinglePlateHandle/obj/Debug/SinglePlateHandle.exe b/余材替代程序/SinglePlateHandle/SinglePlateHandle/obj/Debug/SinglePlateHandle.exe index f5b3de7..61d6339 100644 Binary files a/余材替代程序/SinglePlateHandle/SinglePlateHandle/obj/Debug/SinglePlateHandle.exe and b/余材替代程序/SinglePlateHandle/SinglePlateHandle/obj/Debug/SinglePlateHandle.exe differ diff --git a/余材替代程序/SinglePlateHandle/SinglePlateHandle/obj/Debug/SinglePlateHandle.pdb b/余材替代程序/SinglePlateHandle/SinglePlateHandle/obj/Debug/SinglePlateHandle.pdb index 99414d3..8f43630 100644 Binary files a/余材替代程序/SinglePlateHandle/SinglePlateHandle/obj/Debug/SinglePlateHandle.pdb and b/余材替代程序/SinglePlateHandle/SinglePlateHandle/obj/Debug/SinglePlateHandle.pdb differ