| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |  | 
					
						
							|  |  |  |  | /// <summary> | 
					
						
							|  |  |  |  | ///LOGIC CLASS FOR TABLE t_wmsStockPandian | 
					
						
							|  |  |  |  | ///By wm with codesmith.  | 
					
						
							|  |  |  |  | ///on 07/27/2018 | 
					
						
							|  |  |  |  | /// </summary> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 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 | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     [Serializable] | 
					
						
							|  |  |  |  |     public class lWmsStockPandian   :lbase | 
					
						
							|  |  |  |  |     { | 
					
						
							|  |  |  |  |         | 
					
						
							|  |  |  |  |         public lWmsStockPandian() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |              initialize(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |         WmsStockPandian _obj; | 
					
						
							|  |  |  |  |         public  WmsStockPandian getWmsStockPandian | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (_obj == null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     _obj = new WmsStockPandian(); | 
					
						
							|  |  |  |  |                     | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                _obj.operater = operId; | 
					
						
							|  |  |  |  |                 return _obj; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         WmsStockPandianResult _pandianItem; | 
					
						
							|  |  |  |  |         public WmsStockPandianResult getWmsStockPandianResult | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if (_pandianItem == null) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     _pandianItem = new WmsStockPandianResult(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 _pandianItem.operater = operId; | 
					
						
							|  |  |  |  |                 return _pandianItem; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |        public lWmsStockPandian(int operId) | 
					
						
							|  |  |  |  |             : base(operId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             initialize(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |    | 
					
						
							|  |  |  |  | 		/// <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 WmsStockPandian(id) : new WmsStockPandian(); | 
					
						
							|  |  |  |  |             _obj.operater = operId;  | 
					
						
							|  |  |  |  | 		} | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         /// <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 WmsStockPandian(dr); | 
					
						
							|  |  |  |  |             _obj.operater = operId;  | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |         protected override DeiNiu.Data.BaseObject.BaseModel getModel() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return _obj; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |   | 
					
						
							|  |  |  |  |         //begin cust db operation, query, excute sql etc. | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |       | 
					
						
							|  |  |  |  |         /// <summary> | 
					
						
							|  |  |  |  |         /// update in a transaction scrop | 
					
						
							|  |  |  |  |         /// </summary> | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public void update() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             if (valid()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 using (TransactionScope scope = new TransactionScope()) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //Node tmp = new Node(); | 
					
						
							|  |  |  |  |                     //tmp.parentid = 1; | 
					
						
							|  |  |  |  |                     //tmp.name = "test trans" + DateTime.Now; | 
					
						
							|  |  |  |  |                     //tmp.description = "this is for transTest"; | 
					
						
							|  |  |  |  |                     //tmp.Add(); | 
					
						
							|  |  |  |  |                     _obj.Update(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     scope.Complete(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |         private bool valid() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         public string createPanOrder(int panType, bool noticeErp, int createBy,string inputValues, string stockCondition) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  |             WmsStockPandian pandian = new WmsStockPandian();  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             pandian.orderNo = Utils.Util.getOrderNo(Utils.enumCreateOrderType.pandianOrder,pandian.getNextSeq(enumCreateOrderType.pandianOrder)); | 
					
						
							|  |  |  |  |             pandian.condition = stockCondition; | 
					
						
							|  |  |  |  |             pandian.createby = createBy; | 
					
						
							|  |  |  |  |             pandian.operater = operId; | 
					
						
							|  |  |  |  |             pandian.type = panType; | 
					
						
							|  |  |  |  |             pandian.inputValus =  inputValues; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             pandian.noticeErp = noticeErp; | 
					
						
							|  |  |  |  |             pandian.status = 0; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             pandian.Add(); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             return pandian.orderNo; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |        public bool canStartNewPandian() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return getWmsStockPandian.canStartNewPandian(); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         public bool startPandian(string orderNo) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             WmsStockPandian pandian = new WmsStockPandian(orderNo); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             if (pandian.ID == 0 ||  pandian.status !=(int) enumPandianStatus.未开始 || !canStartNewPandian() ) | 
					
						
							|  |  |  |  |             {  | 
					
						
							|  |  |  |  |             | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             pandian.clean(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |            using (TransactionScope scope = new TransactionScope()) | 
					
						
							|  |  |  |  |            { | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 pandian.status = (int)enumPandianStatus.开始采集; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 string sqlWhere =pandian.getCondition(pandian.condition); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 sqlWhere += pandian.getPlusCondition();   | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |                 logPandian.Debug(" condition: " + sqlWhere); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |               int cnt=  pandian.createDetailMirror(sqlWhere); | 
					
						
							|  |  |  |  |                  | 
					
						
							|  |  |  |  |               | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 pandian.updateStockStatus(enumStockLocationStatus.盘点锁定, sqlWhere); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                pandian.startTime = pandian.getDateTime(); | 
					
						
							|  |  |  |  |                pandian.Update(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                 WmsFlow wmsflow = new WmsFlow(); | 
					
						
							|  |  |  |  |                 wmsflow.operater = operId; | 
					
						
							|  |  |  |  |                 wmsflow.orderNo = pandian.orderNo; | 
					
						
							|  |  |  |  |                 wmsflow.flowNo = pandian.orderNo; | 
					
						
							|  |  |  |  |                 wmsflow.type = (int)EnumFlowTaskType.盘点采集; | 
					
						
							|  |  |  |  |                 wmsflow.typeName = EnumFlowTaskType.盘点采集.ToString(); | 
					
						
							|  |  |  |  |                 wmsflow.task = pandian.orderNo; // Util.getOrderNo(enumCreateOrderType.pickJobNo, _obj.getNextSeq(enumCreateOrderType.pickJobNo));   | 
					
						
							|  |  |  |  |                 wmsflow.taskCnt = cnt;  | 
					
						
							|  |  |  |  |                 wmsflow.Add();  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 scope.Complete(); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |            } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  |             WmsConstants.CURRENT_PANDIAN_ORDER = orderNo; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |          return true; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public bool delPandian(string orderNo) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             WmsStockPandian pandian = new WmsStockPandian(orderNo); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (pandian.ID > 0 && pandian.status == (int)enumPandianStatus.未开始) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return pandian.Delete() >0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public bool finishPandian(string orderNo) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2024-04-12 09:43:41 +08:00
										 |  |  |  |             log.Debug("to stop pandian " + orderNo); | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  |             WmsConstants.CURRENT_PANDIAN_ORDER = ""; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             WmsStockPandian pandian = new WmsStockPandian(orderNo); | 
					
						
							|  |  |  |  |             pandian.operater = operId; | 
					
						
							|  |  |  |  |             pandian.status = (int)enumPandianStatus.盘点结束; | 
					
						
							|  |  |  |  |             pandian.endTime = pandian.getDateTime(); | 
					
						
							|  |  |  |  |             bool ret = true; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             using (TransactionScope scope = new TransactionScope()) | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             { | 
					
						
							|  |  |  |  |                 ret = pandian.Update() > 0; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 ret = ret && pandian.finishPandian(orderNo, pandian.getCondition(pandian.condition)); | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 if (WmsConstants.ERP_NOTICE_STOCK_IN && pandian.noticeErp) | 
					
						
							|  |  |  |  |                 {   | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     WmsOrderRequest wor = pandian.createErpOrder(); | 
					
						
							|  |  |  |  |                     new lWmsOutPickRequest(operId).noticeErpOrder(wor); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2024-04-12 09:43:41 +08:00
										 |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     log.Debug("------------------------- not to notice erp pandian result."); | 
					
						
							|  |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 WmsFlow flow = new WmsFlow(pandian.orderNo); | 
					
						
							|  |  |  |  |                 flow.finishedCnt = flow.taskCnt; | 
					
						
							|  |  |  |  |                 flow.state = (int)enumFlowTaskStatus.已完成;  | 
					
						
							|  |  |  |  |                 flow.Update(); | 
					
						
							|  |  |  |  |                 scope.Complete(); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             WmsConstants.CURRENT_PANDIAN_ORDER = ""; | 
					
						
							| 
									
										
										
										
											2024-04-12 09:43:41 +08:00
										 |  |  |  |             log.Debug(" completed pandian " + orderNo); | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             return ret; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal bool adjustPandianStock(string orderNo, bool isRollBack) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             WmsStockPandianAdjust wpa; | 
					
						
							|  |  |  |  |             WmsStock wstk; | 
					
						
							|  |  |  |  |             decimal factor = isRollBack ? 1  : -1 ; | 
					
						
							|  |  |  |  |             DataTable dt = getWmsStockPandian.getPandianBanlanceDetail(orderNo); | 
					
						
							|  |  |  |  |             WmsStockPandian wsp = new WmsStockPandian(orderNo); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             wsp.adjustStatus =isRollBack ?(int)enumPandianAdjustStatus.未校正 : (int)enumPandianAdjustStatus.已校正; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             wsp.operater = operId; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             DataView dv = dt.DefaultView; | 
					
						
							|  |  |  |  |             dv.Sort = "data " + (isRollBack ? "desc" : "asc"); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             using (TransactionScope scope = new TransactionScope()) | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 wsp.Update();  | 
					
						
							|  |  |  |  |                 lWmsStock lstk = new lWmsStock(operId); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (wsp.type == (int)enumPandianType.全仓盘点) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     // delete pandian stk | 
					
						
							| 
									
										
										
										
											2024-04-12 09:43:41 +08:00
										 |  |  |  |                     lstk.cleanPandiane(); | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                     lstk.deleteLocByType(enumWhLocVol.盘点); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     lstk.deleteLocByType(enumWhLocVol.虚拟); | 
					
						
							|  |  |  |  |                     | 
					
						
							|  |  |  |  |                     lstk.deleteLocBySkuId(0); | 
					
						
							| 
									
										
										
										
											2024-04-12 09:43:41 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                 if (isRollBack) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     getWmsStockPandian.deleteAdjust(orderNo); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                | 
					
						
							|  |  |  |  |                | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 foreach (DataRowView dr in dv) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 { | 
					
						
							|  |  |  |  |                     WmsStockRecord r = new WmsStockRecord(); | 
					
						
							|  |  |  |  |                       | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     wpa = new WmsStockPandianAdjust(dr.Row); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                     wpa.operater = operId; | 
					
						
							|  |  |  |  |                      | 
					
						
							|  |  |  |  |                     r.count = wpa.count; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     //删除旧库存记录  | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                     wstk = new WmsStock( wpa.locationId,wpa.skuId,wpa.goodsId); | 
					
						
							|  |  |  |  |                     decimal oldCount = wstk.count - wstk.countOut; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                     wstk.Delete(); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                     wstk = new WmsStock(dr.Row); | 
					
						
							|  |  |  |  |                     wstk.operater = operId; | 
					
						
							|  |  |  |  |                     logPandian.Debug(string.Format("isRollback? {0}, wpa.data {1}", isRollBack, wpa.data)); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                     decimal adjustCnt = wstk.count - oldCount; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                     if (!isRollBack) | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         r.description = "盘点调整"; | 
					
						
							|  |  |  |  |                         wpa.Add();  | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                         if (wpa.data == 0) //mirror | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                         { | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                              | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                             r.count = r.count * -1; //减库存 | 
					
						
							|  |  |  |  |                         } | 
					
						
							|  |  |  |  |                         else | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                         {  | 
					
						
							|  |  |  |  |                             | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                             wstk.Add(); | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                             if (wsp.type != (int)enumPandianType.全仓盘点) | 
					
						
							|  |  |  |  |                             { | 
					
						
							|  |  |  |  |                                 lstk.logPandianStock(wpa.skuId, r.goodsId, adjustCnt); | 
					
						
							|  |  |  |  |                             } | 
					
						
							|  |  |  |  |                           | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                             logPandian.Debug("applied pandian result..." + wstk); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  |                     else  //回退 | 
					
						
							|  |  |  |  |                     { | 
					
						
							|  |  |  |  |                         r.description = "回退调整"; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                         if (wpa.data == 1)//采集 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                         {  | 
					
						
							|  |  |  |  |                             r.count = r.count * -1;//减库存 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                             if (wsp.type != (int)enumPandianType.全仓盘点) | 
					
						
							|  |  |  |  |                             { | 
					
						
							|  |  |  |  |                                 lstk.logPandianStock(wpa.skuId, r.goodsId, adjustCnt * -1); | 
					
						
							|  |  |  |  |                             } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                         } | 
					
						
							|  |  |  |  |                         else | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                         {  | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                             wstk.Add(); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                             logPandian.Debug("rollback pandian result..." + wstk); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                         } | 
					
						
							|  |  |  |  |                     } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     r.goodsId = wpa.goodsId.Trim(); | 
					
						
							|  |  |  |  |                     r.locationId = wpa.locationId.Trim(); | 
					
						
							|  |  |  |  |                     r.productDate = wpa.productDate; | 
					
						
							|  |  |  |  |                     r.validDate = wpa.validDate; | 
					
						
							|  |  |  |  |                     r.orderNo = wpa.orderNo.Trim();                 | 
					
						
							|  |  |  |  |                     r.rectype = (int)enumStockRecordType.盘点调整; | 
					
						
							|  |  |  |  |                     r.operater = this.operId; | 
					
						
							|  |  |  |  |                     r.Add(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 scope.Complete(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return true; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         internal bool newPandianItem(string orderNo, string locationId, int mirrroId, string goodsId, string prdDate, string batch, decimal count) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             logPandian.Debug(string.Format(" new pandian item:  orderNo {0},locationId {1},mirrroId {2},goodsId {3},prdDate {4},batch{5},count {6}", orderNo, locationId, mirrroId, goodsId, prdDate, batch, count)); | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  |             WmsStockPandian wsp = null; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  |             if (string.IsNullOrEmpty(orderNo)) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |               wsp=  getWmsStockPandian.getCurrentPandianOrder(); | 
					
						
							|  |  |  |  |             }else | 
					
						
							|  |  |  |  |              wsp = new WmsStockPandian(orderNo); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             if(wsp.status != (int)enumPandianStatus.开始采集) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 return false; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             int skuId = 0; | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             string skuCode = ""; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             WmsStockPandianResult wr; | 
					
						
							|  |  |  |  |             string dtValid = prdDate; | 
					
						
							|  |  |  |  |             WmsGoods wg = new WmsGoods(goodsId); | 
					
						
							|  |  |  |  |             if (wg.ID ==0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                throw new Exception("未知商品"); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |           //  DateTime dtprd = Util.pareseDateString(prdDate); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             dtValid = (getValidDate(prdDate, wg.goodsId)).ToShortDateString(); | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             /* | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             Dictionary<string, string> skuValues = new Dictionary<string, string>(); | 
					
						
							|  |  |  |  |             skuValues[WmsConstants.SKU_RESEVRED_BATCH_ATTNAME] = batch; | 
					
						
							|  |  |  |  |             skuValues[WmsConstants.SKU_RESEVRED_EXPIREDATE_ATTNAME] = dtValid; | 
					
						
							|  |  |  |  |             skuValues[WmsConstants.SKU_RESEVRED_PRDDATE_ATTNAME] = dtprd.ToShortDateString(); | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             */ | 
					
						
							|  |  |  |  |             Dictionary<int, string> dic = new lLot().getSKU(prdDate, wg.goodsId,batch); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach (int i in dic.Keys) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 skuId = i; | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 skuCode=dic[i]; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |                 break; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             wr = new WmsStockPandianResult(orderNo, locationId, skuId,wg.goodsId); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             logPandian.Debug(" to add new pandian item: " + wr); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             wr.goodsId = wg.goodsId; | 
					
						
							|  |  |  |  |             wr.validDate = dtValid; | 
					
						
							|  |  |  |  |             wr.batch = batch; | 
					
						
							| 
									
										
										
										
											2024-04-12 09:43:41 +08:00
										 |  |  |  |            // wr.mirrorId = mirrroId; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             wr.productDate = prdDate; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             wr.orderNo = orderNo; | 
					
						
							|  |  |  |  |             wr.locationId = locationId.ToUpper(); | 
					
						
							|  |  |  |  |             wr.skuId = skuId; | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             wr.skuCode = skuCode; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (wg.isWeightOut() && WmsConstants. PANDIAN_WEIGHT_SUM)  //称重的商品累加重量,一个商品可能多次称重 | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 wr.avCount += count; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 wr.avCount = count; | 
					
						
							|  |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             wr.operater = operId; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             int cnt = 0; | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-16 09:29:04 +08:00
										 |  |  |  |             using (TransactionScope scope = new TransactionScope()) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-04-16 09:29:04 +08:00
										 |  |  |  |                 if (wr.ID > 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     cnt = wr.Update(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-16 09:29:04 +08:00
										 |  |  |  |                     WmsStockPandianStockMirror sm = new WmsStockPandianStockMirror(); | 
					
						
							|  |  |  |  |                     sm.skuId = wr.skuId; | 
					
						
							|  |  |  |  |                     sm.batch = wr.batch; | 
					
						
							|  |  |  |  |                     sm.goodsId = wr.goodsId; | 
					
						
							|  |  |  |  |                     sm.locationId = wr.locationId; | 
					
						
							|  |  |  |  |                     sm.orderNo = wr.orderNo; | 
					
						
							|  |  |  |  |                     sm.productDate = wr.productDate; | 
					
						
							|  |  |  |  |                     sm.validDate = wr.validDate; | 
					
						
							|  |  |  |  |                     sm.skuCode = wr.skuCode; | 
					
						
							|  |  |  |  |                     // sm.shelfCount = wr.avCount; | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-16 09:29:04 +08:00
										 |  |  |  |                     wr.mirrorId = sm.Add(); | 
					
						
							| 
									
										
										
										
											2024-03-06 20:48:05 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-16 09:29:04 +08:00
										 |  |  |  |                     cnt = wr.Add(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 flowTaskCount(wr.orderNo, wr.goodsId, count); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 scope.Complete(); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             logPandian.Debug(" done... new pandian result: " + wr  +" , success? " +(cnt > 0)); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             return cnt > 0; | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         internal bool stopPandianPick(string orderNo) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             WmsStockPandian pandian = new WmsStockPandian(orderNo); | 
					
						
							|  |  |  |  |             pandian.operater = operId; | 
					
						
							|  |  |  |  |             pandian.status = (int)enumPandianStatus.采集结束;   | 
					
						
							|  |  |  |  |             return pandian.Update() > 0; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal DataTable getPandianResultItem(string orderNo, string locationId) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         {  | 
					
						
							|  |  |  |  |             return getWmsStockPandianResult.getPandianItem(orderNo,locationId); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal int postPandianItem(int mirrorId, decimal count) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             logPandian.Debug("post item mirrorId  "+ mirrorId + ",  count " + count); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             WmsStockPandianStockMirror wps = new WmsStockPandianStockMirror(mirrorId); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             WmsStockPandian wsp = new WmsStockPandian(wps.orderNo); | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             if (wsp.status != (int)enumPandianStatus.开始采集 && wsp.status != (int)enumPandianStatus.采集结束) | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 logPandian.Debug("pandian status " + wsp.status); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |                 return 0; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             WmsFlow flow = new WmsFlow(wps.orderNo); | 
					
						
							| 
									
										
										
										
											2024-04-16 09:29:04 +08:00
										 |  |  |  |              | 
					
						
							|  |  |  |  |             WmsStockPandianResult wr = new WmsStockPandianResult(wps.orderNo, wps.locationId, wps.skuId,wps.goodsId); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             using (TransactionScope scope = new TransactionScope()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 flow.finishedCnt++; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 flow.Update(); | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-16 09:29:04 +08:00
										 |  |  |  |                 flowTaskCount(wps.orderNo,wps.goodsId, count); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 logPandian.Debug(" result item exists ? " +( wr.ID>0)); | 
					
						
							|  |  |  |  |                 | 
					
						
							|  |  |  |  |                 wr.avCount = count; | 
					
						
							|  |  |  |  |                 if (wr.ID == 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     wr.batch = wps.batch; | 
					
						
							|  |  |  |  |                     wr.goodsId = wps.goodsId; | 
					
						
							|  |  |  |  |                     wr.productDate = wps.productDate; | 
					
						
							|  |  |  |  |                     wr.validDate = wps.validDate; | 
					
						
							|  |  |  |  |                     wr.skuCode = wps.skuCode; | 
					
						
							|  |  |  |  |                     wr.skuId = wps.skuId; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                     wr.locationId = wps.locationId; | 
					
						
							|  |  |  |  |                     wr.orderNo = wps.orderNo; | 
					
						
							|  |  |  |  |                     wr.operater = operId; | 
					
						
							|  |  |  |  |                     wr.mirrorId = mirrorId; | 
					
						
							|  |  |  |  |                     wr.Add(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 else | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     wr.Update(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 scope.Complete(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |               | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             return 100; | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal DataTable getPandianTargetItem(string orderNo, string locationId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             WmsStockPandian wsp = new WmsStockPandian(orderNo); | 
					
						
							|  |  |  |  |             if (wsp.status != (int)enumPandianStatus.开始采集) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return new DataTable("Noitem"); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return getWmsStockPandian.getPandianTargetItem(orderNo, locationId); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         internal DataTable getPandianTargetItems(string orderNo ) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             return getWmsStockPandian.getPandianTargetItems(orderNo ); | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |         public DataTable getPandianTasksByLoc(string locationId) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             WmsLocation loc = new WmsLocation(locationId); | 
					
						
							|  |  |  |  |             if (loc.ID == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return new DataTable("noItems"); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             _obj = getWmsStockPandian.getCurrentPandianOrder(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if(_obj.ID == 0) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return new DataTable("noItems"); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             enumPandianStatus status = (enumPandianStatus)_obj.status; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             DataTable dt = new DataTable("noItems"); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if(_obj.adjustStatus == (int)enumPandianAdjustStatus.已校正) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return dt; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             if (status == enumPandianStatus.开始采集) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 dt = getWmsStockPandian.getPandianTasksByLoc(loc.part, loc.channel, loc.shelf); | 
					
						
							|  |  |  |  |             }else if(status == enumPandianStatus.采集结束) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 dt = getWmsStockPandian.getPandianRunningDiff(loc.part); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             else | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return dt; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |             if (!WmsConstants.PANDIAN_SHOW_CNT) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 dt.Columns.Remove("avCount"); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return dt; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-16 09:29:04 +08:00
										 |  |  |  |         void flowTaskCount(string panOrder,string goodsId,decimal count) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 string task = EnumFlowTaskType.盘点采集 + operId + Utils.Util.getShortDateString(getWmsStockPandian.getDateTime());// this.wmsStock.getDateTime | 
					
						
							|  |  |  |  |                 WmsFlow wmsFlow = new WmsFlow(task); | 
					
						
							|  |  |  |  |                 if (wmsFlow.ID == 0) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     wmsFlow.type = (int)EnumFlowTaskType.盘点采集;   // ;  (int)EnumFlowTaskType.日常理货; | 
					
						
							|  |  |  |  |                     wmsFlow.typeName = EnumFlowTaskType.盘点采集.ToString(); | 
					
						
							|  |  |  |  |                     wmsFlow.task = task; | 
					
						
							|  |  |  |  |                     wmsFlow.orderNo = panOrder; | 
					
						
							|  |  |  |  |                     wmsFlow.state = (int)enumFlowTaskStatus.进行中; | 
					
						
							|  |  |  |  |                     wmsFlow.Add(); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 wmsFlow.finishedTasksPlus(operId, count / new WmsGoods(goodsId).minOperateCount, true); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 log.Error(er); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |           | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |     | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |     | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         //---test pandian | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public void testPandian() | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             logTest.Debug("start pandian process test..."); | 
					
						
							|  |  |  |  |             //create order | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             int type =new Random().Next(0,3); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             string orderNo =   createPanOrder(type, true, 282, "whType = #0;state = #0;", ""); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             logTest.Debug(" created pandian order " + orderNo); | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |       | 
					
						
							| 
									
										
										
										
											2023-11-21 19:18:23 +08:00
										 |  |  |  |             logTest.Debug("start pandian pick....." + startPandian(orderNo)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             DataTable dt= getPandianTargetItems(orderNo); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             foreach(DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 WmsStockPandianStockMirror wps = new WmsStockPandianStockMirror(dr); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 postPandianItem(wps.ID, wps.shelfCount); | 
					
						
							|  |  |  |  |                 //newPandianItem(orderNo,wps.locationId,wps.ID,) | 
					
						
							|  |  |  |  |                   | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             logTest.Debug("stopped  pandian pick " + stopPandianPick(orderNo));  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             logTest.Debug("adjusted  pandian  result  " + adjustPandianStock(orderNo, false)); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             logTest.Debug("finish  pandian    " + finishPandian(orderNo )); | 
					
						
							|  |  |  |  |            | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |     } | 
					
						
							|  |  |  |  |      | 
					
						
							|  |  |  |  |      | 
					
						
							|  |  |  |  | } | 
					
						
							|  |  |  |  |   |