| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | using System; | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Linq; | 
					
						
							|  |  |  |  | using System.Runtime.Serialization; | 
					
						
							|  |  |  |  | using System.ServiceModel; | 
					
						
							|  |  |  |  | using System.Text; | 
					
						
							|  |  |  |  | using DeiNiu.Utils; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | using DeiNiu.wms.win.service; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | namespace DNLightSvr | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码和配置文件中的类名“LightService”。 | 
					
						
							|  |  |  |  |     [ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |     public class LightService : ILightService//,IPrintingService | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |     { | 
					
						
							|  |  |  |  |        // static log4net.ILog log = log4net.LogManager.GetLogger("light"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public delegate bool lightLable(ELabel[] lables); | 
					
						
							|  |  |  |  |         public delegate bool clsOrder(ClearOrder clearOrder); | 
					
						
							|  |  |  |  |         public clsOrder clearO = null; | 
					
						
							|  |  |  |  |         public lightLable lightUp = null; | 
					
						
							|  |  |  |  |        | 
					
						
							|  |  |  |  |         public string lightLabels(ELabel[] labels) | 
					
						
							|  |  |  |  |         {  | 
					
						
							|  |  |  |  |             if (lightUp != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (lightUp(labels)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     | 
					
						
							|  |  |  |  |                     return "success"; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return "failure"; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public string clearOrder(ClearOrder clearOrder) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (clearO != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (clearO(clearOrder)) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     return "success"; | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return "failure"; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         public string testPost(ELabel label) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             string json = getJson(label); | 
					
						
							|  |  |  |  |            // Console.Write("get the lable:  " + json ); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return json;// "succeed"; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |        public string  test() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             Console.Write("get request"); | 
					
						
							|  |  |  |  |             return "服务响应 success"; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |        public string getJson(ELabel label) | 
					
						
							|  |  |  |  |        { | 
					
						
							|  |  |  |  |            string json = String.Format("\"labelId\":{0},\"address\":{1},\"count\":{2},\"color\":{3},\"port\":{4},\"orderNo\":{5}" | 
					
						
							|  |  |  |  |              , label.labelId, label.address, label.count, label.color, label.port, label.orderNo); | 
					
						
							|  |  |  |  |          //  Console.Write("get the lable:  " + json); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |            return "{" + json + "}"; | 
					
						
							|  |  |  |  |        } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |        static string getMsg(string className, string msg) | 
					
						
							|  |  |  |  |        { | 
					
						
							|  |  |  |  |            return string.Format("{0}  {1}", className, msg); | 
					
						
							|  |  |  |  |        } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //--------------------------------------------light by order | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |        public delegate int lightOrder(string orderNo,bool isPickOrder, int partion); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |        public lightOrder lightOd = null; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |         public delegate string lightJob(int userId,string jobNo,bool isValid); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         public lightJob lightJd = null; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |         public string lightByJobNo(int userId,string jobNo,bool isValid) | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             if (lightJd != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 return lightJd(userId,jobNo,isValid); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 //success | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return "亮灯失败"; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public int lightByPickOrder(string orderNo, int partion) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |        { | 
					
						
							|  |  |  |  |            if (lightOd != null) | 
					
						
							|  |  |  |  |            { | 
					
						
							|  |  |  |  |                return lightOd(orderNo, true, partion); | 
					
						
							|  |  |  |  |                //success | 
					
						
							|  |  |  |  |            } | 
					
						
							|  |  |  |  |            return 0; | 
					
						
							|  |  |  |  |        } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |        public int lightBySaleOrder(string orderNo, int partion) | 
					
						
							|  |  |  |  |        { | 
					
						
							|  |  |  |  |            if (lightOd != null) | 
					
						
							|  |  |  |  |            { | 
					
						
							|  |  |  |  |                return lightOd(orderNo, false, partion); | 
					
						
							|  |  |  |  |                 | 
					
						
							|  |  |  |  |            } | 
					
						
							|  |  |  |  |            return 0; | 
					
						
							|  |  |  |  |        } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //---light by plate | 
					
						
							|  |  |  |  |        public delegate string lightPlate(string plateId,int part); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |        public lightPlate lightPl = null; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |        public string lightByPlate(string plateId,int partion) | 
					
						
							|  |  |  |  |        { | 
					
						
							|  |  |  |  |            if (lightPl != null) | 
					
						
							|  |  |  |  |            { | 
					
						
							|  |  |  |  |                return lightPl(plateId, partion); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |            } | 
					
						
							|  |  |  |  |            return "亮灯失败001"; | 
					
						
							|  |  |  |  |        } | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //---print service  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public delegate int printOutTaskCodes(int userId, int part, int lineId, int orderType); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public printOutTaskCodes prtOutTaskCode = null; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public void printPrenIn(string orderNo) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             throw new NotImplementedException(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public void printOnShelfA4(string orderNo) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             throw new NotImplementedException(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public void printOnShelfCode(string orderNo) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             throw new NotImplementedException(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public int printOutTaskCode(int userId, int partion, int lineId, int orderType) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (prtOutTaskCode != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return prtOutTaskCode(userId, partion, lineId, orderType); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return 0; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |         public string lightJobNo(int userId, string jobNo, bool isValid) | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             return lightByJobNo(userId,jobNo, isValid); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |         public string lightChkStk(string jobNo, bool isValid) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return lightByJobNo(0,jobNo, isValid); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         public delegate string prinPreIn(int userId,string preInNo); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public prinPreIn printPreInd = null; | 
					
						
							|  |  |  |  |         public string printStockIn(int userId, string preinNo) | 
					
						
							|  |  |  |  |         {  | 
					
						
							|  |  |  |  |             if (printPreInd != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return printPreInd(userId, preinNo); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return "打印命令已发送"; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |        public delegate string prinOutTrans(string plateId); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public prinOutTrans prinOutTransd = null; | 
					
						
							|  |  |  |  |         public string printOutTrans(string plateId)  | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (prinOutTransd != null) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return prinOutTransd(plateId); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return "打印命令已发送"; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  | } |