huanghongfeng
2025-01-24 829eabf256e29392ca63f6da48829dba3b075dfe
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_TaskInfoService/PartialTaskService_Outbound.cs
@@ -404,7 +404,7 @@
                    }
                    targetCodes[4] = "01";
                    string LocationCode = string.Join("-", targetCodes); //组装浅库位地址
                    Dt_LocationInfo locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode);
                    Dt_LocationInfo locationInfos = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode && (x.LocationStatus == (int)LocationStatusEnum.Free || x.LocationStatus == (int)LocationStatusEnum.InStock));
                    if (locationInfos == null)
                    {
                        return content = WebResponseContent.Instance.Error($"未找到该货位信息,货位编号:{locationInfos}");
@@ -417,7 +417,7 @@
                        }
                        else
                        {
                            Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode);
                            Dt_StockInfo dt_StockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.LocationCode == LocationCode && x.StockStatus== (int)StockStatusEmun.已入库);
                            if (dt_StockInfo == null)
                            {
                                return content = WebResponseContent.Instance.Error($"未找到该货位的库存信息,货位编号:{LocationCode}");
@@ -435,7 +435,27 @@
                                {
                                    Locationtype = 10;
                                }
                                newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo,Locationtype); //拿到了移库后的货位
                                //newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo,Locationtype); //拿到了移库后的货位
                                if (dt_StockInfo.MaterialType == (int)InventoryMaterialType.成品)
                                {
                                    string[] targetCodesst = dt_StockInfo.PalletCode.Split("*");
                                    Dt_InboundOrder dt_Inbound = _inboundService.InbounOrderService.Repository.QueryFirst(x => x.OrderName == targetCodesst[0]);
                                    if (dt_Inbound.Startingcolumn != 0 || dt_Inbound.Terminationcolumn != 0)
                                    {
                                        newLocation = _basicService.LocationInfoService.GetLocation2(locationInfos.RoadwayNo, Locationtype, dt_Inbound.Startingcolumn, dt_Inbound.Terminationcolumn);
                                    }
                                    else
                                    {
                                        newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype);
                                    }
                                }
                                else
                                {
                                    newLocation = _basicService.LocationInfoService.GetLocation(locationInfos.RoadwayNo, Locationtype);
                                }
                                if (newLocation != null)
                                {
                                    Dt_Task dt_Task = new()
@@ -469,6 +489,7 @@
                                    loca.Add(newLocation);
                                    loca.Add(locationInfos);
                                    _basicService.LocationInfoService.UpdateData(loca);
                                    BaseDal.AddData(dt_Task);
                                    _unitOfWorkManage.CommitTran();
                                    return content = WebResponseContent.Instance.OK(data: dt_Task);
                                }
@@ -804,10 +825,14 @@
                                    string TargetAdd = "";
                                    if (saveModel.DelKeys[1].ToString()=="20")
                                    {
                                        TargetAdd = "R02-001-010-001-02";
                                        TargetAdd = "R02-001-021-001-02";
                                    }else if(saveModel.DelKeys[1].ToString() == "30")
                                    {
                                        TargetAdd = "R02-001-011-001-02";
                                        TargetAdd = "R02-001-022-001-02";
                                    }
                                    else if (saveModel.DelKeys[1].ToString() == "40")
                                    {
                                        TargetAdd = "R01-002-044-001-01";
                                    }
                                    else
                                    {
@@ -859,7 +884,7 @@
                    }
                }
                //var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTask, taskdt, "下发任务入库");
                var responses = HttpHelper.Post<WebResponseContent>(ReceiveWMSTask, taskdt, "下发任务入库");
                _unitOfWorkManage.BeginTran();
                if(dtstockt.Count > 0)
                {
@@ -903,7 +928,7 @@
                    }
                    else
                    {
                        return content = WebResponseContent.Instance.Error($"出库失败,未找到对应的库存信息,库存编号:{pallid}");
                        return content = WebResponseContent.Instance.Error($"修改失败,未找到对应的库存信息,库存编号:{pallid}");
                    }
                }
@@ -919,7 +944,51 @@
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return content = WebResponseContent.Instance.Error($"出库失败,报错信息:{ex.Message}");
                return content = WebResponseContent.Instance.Error($"修改失败,报错信息:{ex.Message}");
                throw;
            }
        }
        public WebResponseContent ManualOutbound4(SaveModel saveModel)
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                List<Dt_StockInfo> dtstockt = new List<Dt_StockInfo>();
                List<Dt_StockInfo> stocktData = _stockService.StockInfoService.Repository.QueryData(x => x.StockStatus == (int)StockStatusEmun.已入库);
                string json = saveModel.DelKeys[0].ToString();
                List<int> palletCodes = JsonConvert.DeserializeObject<List<int>>(json);
                foreach (int pallid in palletCodes)
                {
                    Dt_StockInfo stockt = stocktData.FirstOrDefault(x => x.Id == pallid);
                    if (stockt != null)
                    {
                        stockt.Mgeneratetime = DateTime.Parse(saveModel.DelKeys[1].ToString());
                        dtstockt.Add(stockt);
                    }
                    else
                    {
                        return content = WebResponseContent.Instance.Error($"修改失败,未找到对应的库存信息,库存编号:{pallid}");
                    }
                }
                _unitOfWorkManage.BeginTran();
                if (dtstockt.Count > 0)
                {
                    _stockService.StockInfoService.Repository.UpdateData(dtstockt);
                }
                _unitOfWorkManage.CommitTran();
                content = WebResponseContent.Instance.OK($"修改成功");
                return content;
            }
            catch (Exception ex)
            {
                _unitOfWorkManage.RollbackTran();
                return content = WebResponseContent.Instance.Error($"修改失败,报错信息:{ex.Message}");
                throw;
            }
        }
@@ -1217,6 +1286,7 @@
                    BaseDal.DeleteData(task);
                    BaseDal.DeleteAndMoveIntoHty(task, OperateType.人工删除);
                    WriteLog.GetLog("任务日志").Write($"出库任务取消成功,托盘条码:{task.PalletCode}", $"任务取消");
                    WebResponseContent webResponseContent = HttpHelper.Post<WebResponseContent>(ReceiveWCSTask, task.TaskNum, "任务删除");
                    return content = WebResponseContent.Instance.Error($"出库任务取消成功");
                }
@@ -1239,6 +1309,42 @@
                    BaseDal.DeleteData(task);
                    BaseDal.DeleteAndMoveIntoHty(task, OperateType.人工删除);
                    WriteLog.GetLog("任务日志").Write($"入库任务取消成功,托盘条码:{task.PalletCode}", $"任务取消");
                    WebResponseContent webResponseContent = HttpHelper.Post<WebResponseContent>(ReceiveWCSTask, task.TaskNum, "任务删除");
                    return content = WebResponseContent.Instance.Error($"入库任务取消成功");
                }
                else if (task.TaskType == (int)TaskTypeEnum.RelocationIn)    //库内移库
                {
                    //处理出库的逻辑
                    Dt_LocationInfo locationinfo = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.TargetAddress);
                    if (locationinfo.LocationStatus == LocationStatusEnum.Lock.ObjToInt() || locationinfo.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt())
                    {
                        locationinfo.LocationStatus = LocationStatusEnum.Free.ObjToInt();
                    }
                    _basicService.LocationInfoService.Repository.UpdateData(locationinfo);
                    Dt_LocationInfo locationinfo2 = _basicService.LocationInfoService.Repository.QueryFirst(x => x.LocationCode == task.SourceAddress);
                    if (locationinfo2.LocationStatus == LocationStatusEnum.Lock.ObjToInt())
                    {
                        locationinfo2.LocationStatus = LocationStatusEnum.InStock.ObjToInt();
                    }
                    if (locationinfo2.LocationStatus == LocationStatusEnum.PalletLock.ObjToInt())
                    {
                        locationinfo2.LocationStatus = LocationStatusEnum.Pallet.ObjToInt();
                    }
                    _basicService.LocationInfoService.Repository.UpdateData(locationinfo2);
                    Dt_StockInfo stockInfo = _stockService.StockInfoService.Repository.QueryFirst(x => x.PalletCode == task.PalletCode);
                    stockInfo.StockStatus = (int)StockStatusEmun.已入库;
                    _stockService.StockInfoService.Repository.UpdateData(stockInfo);
                    Dt_StockInfoDetail stocktdetail = _stockService.StockInfoDetailService.Repository.QueryFirst(x => x.StockId == stockInfo.Id);
                    if (stocktdetail != null)
                    {
                        stocktdetail.Status = (int)StockStatusEmun.已入库;
                        _stockService.StockInfoDetailService.Repository.UpdateData(stocktdetail);
                    }
                    BaseDal.DeleteData(task);
                    BaseDal.DeleteAndMoveIntoHty(task, OperateType.人工删除);
                    WriteLog.GetLog("任务日志").Write($"入库任务取消成功,托盘条码:{task.PalletCode}", $"任务取消");
                    WebResponseContent webResponseContent = HttpHelper.Post<WebResponseContent>(ReceiveWCSTask, task.TaskNum, "任务删除");
                    return content = WebResponseContent.Instance.Error($"入库任务取消成功");
                }
                else