From d3470bb47c0f4627962b270f9667f420e394d0de Mon Sep 17 00:00:00 2001 From: duyongjia <adu_555@163.com> Date: 星期五, 27 十二月 2024 15:11:17 +0800 Subject: [PATCH] PDA端上传 --- 项目代码/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs | 185 +++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 173 insertions(+), 12 deletions(-) diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" index afa50f2..8cb3c4e 100644 --- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" +++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/TaskService.cs" @@ -31,6 +31,7 @@ using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; +using WIDESEA_BasicRepository; using WIDESEA_Core; using WIDESEA_Core.BaseRepository; using WIDESEA_Core.BaseServices; @@ -47,10 +48,13 @@ using WIDESEA_IRecordService; using WIDESEA_IStockRepository; using WIDESEA_IStockService; +using WIDESEA_ISystemService; using WIDESEA_ITaskInfoRepository; using WIDESEA_ITaskInfoService; +using WIDESEA_Model; using WIDESEA_Model.Models; using WIDESEA_TaskInfoRepository; +using OrderByType = SqlSugar.OrderByType; namespace WIDESEA_TaskInfoService { @@ -66,10 +70,25 @@ private readonly IStockService _stockService; private readonly ITask_HtyService _taskHtyService; private readonly ILocationInfoService _locationInfoService; - + private readonly ISys_JobService _sys_JobService; + private readonly ILabelMasterRepository _labelMasterRepository; + private readonly IOutStockLockInfoRepository _outStockLockInfoRepository; + private readonly IOutboundOrderRepository _outboundOrderRepository; + private readonly IOutboundOrderDetailRepository _outboundOrderDetailRepository; + private readonly IOutboundOrder_HtyRepository _outboundOrder_HtyRepository; + private readonly IOutboundOrderDetail_HtyRepository _outboundOrderDetail_HtyRepository; + private readonly IOutBoundOrderBYDRepository _outBoundOrderBYDRepository; + private readonly IOutboundOrderDetailBYDRepository _outboundOrderDetailByDRepository; public ITaskRepository Repository => BaseDal; - public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService) : base(BaseDal) + private Dictionary<string, OrderByType> _OutLockOrderBy = new Dictionary<string, OrderByType>() + { + + { nameof(Dt_OutStockLockInfo.CreateDate), OrderByType.Desc }, + + }; + + public TaskService(ITaskRepository BaseDal, IMapper mapper, IUnitOfWorkManage unitOfWorkManage, IBasicService basicService, IOutboundService outboundService, IInboundService inboundService, IRecordService recordService, IStockService stockService, ITask_HtyService taskHtyService, ILocationInfoService locationInfoService, ISys_JobService sys_JobService, ILabelMasterRepository labelMasterRepository, IOutStockLockInfoRepository outStockLockInfoRepository, IOutboundOrderDetailRepository outboundOrderDetailRepository, IOutBoundOrderBYDRepository outBoundOrderBYDRepository, IOutboundOrderDetailBYDRepository outboundOrderDetailByDRepository, IOutboundOrderRepository outboundOrderRepository, IOutboundOrder_HtyRepository outboundOrder_HtyRepository, IOutboundOrderDetail_HtyRepository outboundOrderDetail_HtyRepository) : base(BaseDal) { _mapper = mapper; _unitOfWorkManage = unitOfWorkManage; @@ -80,7 +99,17 @@ _stockService = stockService; _taskHtyService = taskHtyService; _locationInfoService = locationInfoService; + _sys_JobService = sys_JobService; + _labelMasterRepository = labelMasterRepository; + _outStockLockInfoRepository = outStockLockInfoRepository; + _outboundOrderDetailRepository = outboundOrderDetailRepository; + _outBoundOrderBYDRepository = outBoundOrderBYDRepository; + _outboundOrderDetailByDRepository = outboundOrderDetailByDRepository; + _outboundOrderRepository = outboundOrderRepository; + _outboundOrder_HtyRepository = outboundOrder_HtyRepository; + _outboundOrderDetail_HtyRepository = outboundOrderDetail_HtyRepository; } + /// <summary> /// 浠诲姟瀹屾垚 @@ -223,13 +252,11 @@ { try { + _unitOfWorkManage.BeginTran(); decimal beforeQuantity = 0; - - Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); - Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress); - + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); CheckCompleted(stockInfo, locationInfo); stockInfo.LocationCode = locationInfo.LocationCode; @@ -250,14 +277,81 @@ _recordService.LocationStatusChangeRecordSetvice.AddLocationStatusChangeRecord(locationInfo, beforeStatus, StockChangeType.Inbound.ObjToInt(), stockInfo.Details.FirstOrDefault()?.OrderNo ?? "", task.TaskNum); _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) + beforeQuantity, StockChangeType.Inbound,task.TaskNum); _unitOfWorkManage.CommitTran(); - return WebResponseContent.Instance.OK(); + + } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } - + + //鍘熸枡鍏ュ簱瀹屾垚鍚庯紝闇�瑕佸皢缁勭洏淇℃伅璋冪敤涓婃父WMS鍘熸枡涓婃灦缁撴灉鎺ュ彛 + #region 鍥炰紶閫昏緫澶勭悊 + try + { + PutAwayRequest request = new PutAwayRequest(); + List<PutAway> itemData = new List<PutAway>(); + request.ITEMDATA = itemData; + request.WERKS = AppSettings.Configuration["WERKS"]; + request.WH_NUMBER = AppSettings.Configuration["WERKS"]; + request.IZLID = request.WERKS + request.WH_NUMBER+ DateTime.Now.ToString("yyyyMMdd") + task.TaskNum.ToString(); + request.CREATE_DATE = task.CreateDate.ToString("yyyy-MM-dd HH:mm:ss"); + request.PSTNG_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + request.INBOUND_NO = "";//todo:鍗曞彿瑕佷粠鏉$爜涓绘暟鎹腑鑾峰彇锛屼笉鐒跺洖浼犱細鎻愮ず锛氳鏉$爜鏃犺繘浠撳崟鏁版嵁锛� + request.RECEIPT_NO = "";//todo:鍗曞彿瑕佷粠鏉$爜涓绘暟鎹腑锛屼笉鐒跺洖浼犱細鎻愮ず锛氳鏉$爜鏃犺繘浠撳崟鏁版嵁锛� + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + foreach (Dt_StockInfoDetail detail in stockInfo.Details) + { + Dt_LabelMaster labMaster = _labelMasterRepository.QueryFirst(x => x.LABEL_NO == detail.SerialNumber); + if (labMaster != null) + { + if (request.INBOUND_NO == "") + { + request.INBOUND_NO = labMaster.INBOUND_NO; + } + if (request.RECEIPT_NO == "") + { + request.RECEIPT_NO = labMaster.RECEIPT_NO; + } + PutAway putAway = new PutAway(); + putAway.MATNR = labMaster.MATNR; + putAway.BATCH = labMaster.BATCH; + putAway.LIFNR = labMaster.LIFNR; + putAway.LIKTX = labMaster.LIKTX; + putAway.RECEIPT_QTY = labMaster.BOX_QTY; + putAway.UNIT = labMaster.UNIT; + putAway.LABEL_NO = labMaster.LABEL_NO; + putAway.PACK_LABEL_NO = labMaster.Pack_LABEL_No; + putAway.PALLET_LABEL_NO = labMaster.Pallet_label_no; + putAway.TPNUM = task.PalletCode; + putAway.FLAG = "0"; + putAway.TKTXT = ""; + putAway.PO_NO = labMaster.PO_NO; + putAway.PO_ITEM_NO = labMaster.PO_ITEM_NO; + putAway.SOBKZ = labMaster.SOBKZ; + putAway.RECEIPT_ITEM_NO = labMaster.RECEIPT_ITEM_NO; + putAway.INBOUND_NO = task.TaskNum.ToString(); + //LABEL _STATUS 鏉$爜鐘舵�� 02宸叉敹鏂�(鏃犻渶璐ㄦ)03 寰呰繘浠�(宸茶川妫�)锛屽苟涓旓紝QC RESULT CODE璐ㄦ鐘舵�佷负鈥�02鈥� 鎵嶅厑璁′笂鏋� + if (labMaster.QC_RESULT_CODE=="02"&&(labMaster.LABEL_STATUS=="02"|| labMaster.LABEL_STATUS == "03")) + { + itemData.Add(putAway); + } + + } + } + if (itemData.Count > 0) + { + _sys_JobService.CallPutAway(request); + } + } + catch(Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + #endregion + return WebResponseContent.Instance.OK(); + } /// <summary> @@ -333,11 +427,15 @@ public WebResponseContent OutboundTaskCompleted(Dt_Task task) { + Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + Dt_StockInfo stockInfoCatch = stockInfo;//鍏堢紦瀛樿捣鏉ワ紝渚涘悗闈㈢殑鍥炰紶鎺ュ彛璋冪敤 try { _unitOfWorkManage.BeginTran(); decimal beforeQuantity = 0; - Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + + //Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.GetStockInfo(task.PalletCode); + //Dt_StockInfo stockInfoCatch = stockInfo;//鍏堢紦瀛樿捣鏉ワ紝渚涘悗闈㈢殑鍥炰紶鎺ュ彛璋冪敤 Dt_LocationInfo locationInfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress); @@ -369,15 +467,78 @@ _recordService.StockQuantityChangeRecordService.AddStockChangeRecord(stockInfo, stockInfo.Details, beforeQuantity, stockInfo.Details.Sum(x => x.StockQuantity) - beforeQuantity, StockChangeType.Outbound, task.TaskNum); _unitOfWorkManage.CommitTran(); - return WebResponseContent.Instance.OK(); - //return OnOutboundTaskCompleted?.Invoke(task) ?? WebResponseContent.Instance.OK(); - + } catch (Exception ex) { _unitOfWorkManage.RollbackTran(); return WebResponseContent.Instance.Error(ex.Message); } + + + //鍘熸枡鍑哄簱瀹屾垚鍚庯紝璋冪敤涓婃父绯荤粺WMS鍑哄簱瀹屾垚淇℃伅鎺ュ彛 + #region 鍥炰紶閫昏緫澶勭悊 + try + { + PickAndPostRequest request = new PickAndPostRequest(); + List<PickAndPost> itemData = new List<PickAndPost>(); + request.ITEMDATA = itemData; + request.WH_NUMBER = AppSettings.Configuration["WERKS"]; + request.SYSNOD = AppSettings.Configuration["SYSNO"]; + request.WERKS = AppSettings.Configuration["WERKS"]; + //鏆傛椂鏍规嵁鎵樼洏鍙锋煡鍑哄簱閿佸畾琛ㄤ腑Dt_OutStockLockInfo涓殑鐘舵�佷负1鐨勬渶鏂颁竴鏉�,鍥犱负鍏堥攣瀹氾紝鎵嶆湁浠诲姟锛屾墍浠ユ病鏈夊叧鑱斾换鍔″彿 + //Dt_OutStockLockInfo outStockLockInfo= _outStockLockInfoRepository.QueryFirst(x => x.PalletCode == task.PalletCode && x.Status == 1, _OutLockOrderBy); + + + Dt_OutboundOrderDetail_Hty detail = _outboundOrderDetail_HtyRepository.QueryFirst(x => x.SourceId.ToString() == task.Remark);// task.Remark瀛橀渶姹傛槑缁咺D + if (detail != null) + { + Dt_OutboundOrder_Hty outboundOrder = _outboundOrder_HtyRepository.QueryFirst(x => x.SourceId == detail.OrderId); + if (outboundOrder != null) + { + Dt_OutBoundOrderBYD outboundOrderBYD = _outBoundOrderBYDRepository.QueryFirst(x => x.REQUIREMENT_NO == outboundOrder.OrderNo); + if (outboundOrderBYD != null) + { + + Dt_OutboundOrderDetailBYD outboundOrderDetailBYD = _outboundOrderDetailByDRepository.QueryFirst(x => x.REQUIREMENT_NO == outboundOrderBYD.REQUIREMENT_NO && x.REQUIREMENT_ITEM_NO == detail.Remark);//detail.Remark 瀛橀渶姹傝 + //鏍规嵁鎵樼洏鍙锋煡绔嬪簱鐨勬潯鐮佸拰鎵规杩涜鍥炰紶 + foreach (var item in stockInfoCatch.Details) + { + PickAndPost pickpost = new PickAndPost(); + pickpost.REQUIREMENT_NO = outboundOrderDetailBYD.REQUIREMENT_NO; + pickpost.REQUIREMENT_ITEM_NO = outboundOrderDetailBYD.REQUIREMENT_ITEM_NO; + pickpost.WERKS = outboundOrderBYD.WRKS; + pickpost.SYSNOD = outboundOrderBYD.SYSNOD; + pickpost.MATNR = outboundOrderDetailBYD.MATNR; + pickpost.LIFNR = "";//娌℃湁杩斿洖锛屾殏鏃惰浆绌� + pickpost.QTY = outboundOrderDetailBYD.QTY; + pickpost.BATCH = item.BatchNo;//鍙栫珛搴撳叆搴撳簱瀛樼殑鏉$爜 + pickpost.LGORT = outboundOrderBYD.LGORT; + pickpost.BUSINESS_CODE = outboundOrderBYD.BUSINESS_CODE; + pickpost.BUSINESS_NAME = outboundOrderBYD.BUSINESS_NAME; + pickpost.STATION = outboundOrderBYD.STATION; + pickpost.SPLIT = outboundOrderBYD.SPLIT; + pickpost.LABEL_NO = item.SerialNumber;//鍙栫珛搴撳叆搴撳簱瀛樼殑鏉$爜 + pickpost.CREATE_DATE = outboundOrderBYD.CREATE_DATE; + pickpost.UPDATE_DATE = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + pickpost.STATUS = outboundOrderBYD.STATUS; + itemData.Add(pickpost); + + } + _sys_JobService.CallPickAndPost(request);//鍥炰紶 + } + + } + + } + } + catch(Exception ex) + { + return WebResponseContent.Instance.Error(ex.Message); + } + + #endregion + return WebResponseContent.Instance.OK(); } public WebResponseContent PalletOutboundTaskCompleted(Dt_Task task) -- Gitblit v1.9.3