| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using DeiNiu.wms.Data.Model; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using System.Transactions; | 
					
						
							|  |  |  |  | using DeiNiu.Utils; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace DeiNiu.wms.Logical | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     public class lNode : lbase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         Node _obj; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         public lNode() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             | 
					
						
							|  |  |  |  |             initialize(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public lNode(int operId):base(operId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             initialize(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public Node getNode | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return _obj; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 		 | 
					
						
							|  |  |  |  | 		/// <summary> | 
					
						
							|  |  |  |  | 		/// get all data | 
					
						
							|  |  |  |  | 		/// </summary> | 
					
						
							|  |  |  |  |         public DataSet getAllData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |            return _obj.Query(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// get all data | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public DataSet getAllActiveData() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return _obj.QueryActived(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 		/// <summary> | 
					
						
							|  |  |  |  | 		/// get a record by id | 
					
						
							|  |  |  |  | 		/// </summary> | 
					
						
							|  |  |  |  |         public void initialize(int id) | 
					
						
							|  |  |  |  | 		{ | 
					
						
							|  |  |  |  |             _obj = id != 0 ? new Node(id) : new Node(); | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  | 		/// get a record by id 0 | 
					
						
							|  |  |  |  | 		/// </summary> | 
					
						
							|  |  |  |  |         public void initialize() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             initialize(0); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// get a record by id | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         public void initialize(DataRow dr) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             _obj =   new Node(dr); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  |         //begin cust db operation, query, excute sql etc. | 
					
						
							|  |  |  |  |         public DataSet Query(string goodsName, int rownumStart, int rownumEnd) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (rownumEnd > rownumStart && rownumStart > 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 _obj.rownumStart = rownumStart; | 
					
						
							|  |  |  |  |                 _obj.rownumEnd = rownumEnd; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             DataSet ds = string.IsNullOrEmpty(goodsName) ? _obj.Query()  : _obj.QueryByName(goodsName) ; | 
					
						
							|  |  |  |  |             return ds; | 
					
						
							|  |  |  |  |         //    return string.IsNullOrEmpty(goodsName) ? _obj.Query().Tables[0] : _obj.QueryByName(goodsName).Tables[0]; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public int getCntByName(string name) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return _obj.getCntByName(name); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         private bool valid() | 
					
						
							|  |  |  |  |         {  | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// query dic that has flag | 
					
						
							|  |  |  |  |         /// used for building combox | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  |         /// <returns></returns> | 
					
						
							|  |  |  |  |         public DataTable QueryByFlags() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return _obj.QueryByFlags();  | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public DataTable getDesks() | 
					
						
							|  |  |  |  |         {  | 
					
						
							|  |  |  |  |             return _obj.QueryByFlags( new int[]{4001,4002});  | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public bool initialDesk() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             WmsOutDesk desk = new WmsOutDesk(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             DataTable dt = desk.Query().Tables[0]; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 WmsOutDesk d = new WmsOutDesk(dr); | 
					
						
							|  |  |  |  |                 d.Delete(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             Node nd = new Node();  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             dt = nd.QueryByFlag(4001); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 try | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     nd = new Node(dr); | 
					
						
							|  |  |  |  |                     desk = new WmsOutDesk(); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     desk.color =  Convert.ToInt32(nd.name.Trim()); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                     desk.deskName = nd.description; | 
					
						
							|  |  |  |  |                     desk.ip = "127.0.0.1"; | 
					
						
							|  |  |  |  |                     desk.deskType = (int)enumDeskType.复核; | 
					
						
							|  |  |  |  |                     desk.Add(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 catch | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     continue; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             Dictionary<int, int> SEEDS_DESK_PORTS = new Dictionary<int, int>(); | 
					
						
							|  |  |  |  |             Dictionary<int, int> SEEDS_DESK_LABEL_START_ID = new Dictionary<int, int>(); | 
					
						
							|  |  |  |  |             Dictionary<int, int> SEEDS_DESK_PICKS_COUNT_MAX = new Dictionary<int, int>(); | 
					
						
							|  |  |  |  |             Dictionary<int, int> SEEDS_DESK_PICKS_COUNT_MIN = new Dictionary<int, int>(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             dt = nd.QueryByFlag(4004);//标签起始编号 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Node n = new Node(dr); | 
					
						
							|  |  |  |  |                 try | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     SEEDS_DESK_LABEL_START_ID[ Convert.ToInt32(n.name)] =  Convert.ToInt32(n.value); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 catch { } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             dt = nd.QueryByFlag(4005);//播种台分播客户最大数量 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Node n = new Node(dr); | 
					
						
							|  |  |  |  |                 try | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     SEEDS_DESK_PICKS_COUNT_MAX[ Convert.ToInt32(n.name)] =  Convert.ToInt32(n.value); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 catch { } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             dt = nd.QueryByFlag(4007);//播种台分播客户最少数量 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Node n = new Node(dr); | 
					
						
							|  |  |  |  |                 try | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     SEEDS_DESK_PICKS_COUNT_MIN[ Convert.ToInt32(n.name)] =  Convert.ToInt32(n.value); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 catch { } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             dt = nd.QueryByFlag(4003);//播种台端口号 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 Node n = new Node(dr); | 
					
						
							|  |  |  |  |                 try | 
					
						
							|  |  |  |  |                 { | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     SEEDS_DESK_PORTS[ Convert.ToInt32(n.name)] =  Convert.ToInt32(n.value); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  |                 catch { } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |             dt = nd.QueryByFlag(4002); //播种 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach (DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 try | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     nd = new Node(dr); | 
					
						
							|  |  |  |  |                     desk = new WmsOutDesk(); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     desk.color =  Convert.ToInt32(nd.name.Trim()); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                     desk.deskName = nd.value; | 
					
						
							|  |  |  |  |                     desk.ip = "127.0.0.1"; | 
					
						
							|  |  |  |  |                     if(SEEDS_DESK_PORTS.ContainsKey( desk.color)){ | 
					
						
							|  |  |  |  |                        desk.port = SEEDS_DESK_PORTS[desk.color]; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (SEEDS_DESK_PICKS_COUNT_MAX.ContainsKey(desk.color)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         desk.seedsCount = SEEDS_DESK_PICKS_COUNT_MAX[desk.color]; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (SEEDS_DESK_LABEL_START_ID.ContainsKey(desk.color)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         desk.startLabelId = SEEDS_DESK_LABEL_START_ID[desk.color]; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     if (SEEDS_DESK_PICKS_COUNT_MIN.ContainsKey(desk.color)) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         desk.seedsMinCount = SEEDS_DESK_PICKS_COUNT_MIN[desk.color]; | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     desk.deskType = (int)enumDeskType.播种; | 
					
						
							|  |  |  |  |                     desk.Add(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 catch | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     continue; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  | } |