From f9e3252c454e476ed1ee00b081d83751f623fc3e Mon Sep 17 00:00:00 2001
From: Zhang-Hong-Lin <a3219986988@163.com>
Date: 星期二, 11 三月 2025 09:49:31 +0800
Subject: [PATCH] 1

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs |  199 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 199 insertions(+), 0 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index 5619d95..b793c5f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -981,5 +981,204 @@
             }
             return content;
         }
+
+        public WebResponseContent AtOnceUpdate(int taskid)
+        {
+            WebResponseContent content = new WebResponseContent();
+            Dt_Task nawtask = BaseDal.QueryFirst(v => v.TaskId == taskid);
+            //鍏ュ簱
+            if (nawtask.TaskType == (int)TaskInboundTypeEnum.Inbound)
+            {
+                //鍓旈櫎鍏ュ簱
+                var station = _dt_stationInfoRepository.QueryFirst(v => v.msg == "鍓旈櫎鏋�");
+                string sourceAddress = station.Row + "-" + station.Column + "-1";
+                if (nawtask.SourceAddress.Equals(sourceAddress))
+                {
+                    var batck = _batchinfoRepository.QueryFirst(v => v.Id == 1);
+                    //鏂板缓搴撳瓨
+                    Dt_StockInfo stock = new Dt_StockInfo();
+                    stock.LocationCode = nawtask.TargetAddress;
+                    stock.StockStatus = (int)stockEnum.Free;
+                    stock.BatchNo = batck.InBatch;
+                    stock.Remark = 3;
+                    //淇敼璐т綅淇℃伅
+                    var location = _locationRepository.QueryFirst(v => v.LocationCode == nawtask.TargetAddress);
+                    location.LocationStatus = (int)LocationStatusEnum.InStock;
+                    //澶勭悊浠诲姟淇℃伅
+                    Dt_Task_hty taskhty = new Dt_Task_hty();
+                    taskhty.TaskNum = nawtask.TaskNum;
+                    taskhty.Roadway = nawtask.Roadway;
+                    taskhty.TaskType = nawtask.TaskType;
+                    taskhty.TaskState = (int)TaskInStatusEnum.Line_InFinish;
+                    taskhty.SourceAddress = nawtask.SourceAddress;
+                    taskhty.TargetAddress = nawtask.TargetAddress;
+                    taskhty.ExceptionMessage = nawtask.ExceptionMessage;
+                    taskhty.Grade = nawtask.Grade;
+                    taskhty.Dispatchertime = nawtask.Dispatchertime;
+                    taskhty.Remark = nawtask.Remark;
+                    taskhty.PalletCode = nawtask.PalletCode;
+                    taskhty.NextAddress = nawtask.NextAddress;
+                    taskhty.CurrentAddress = nawtask.CurrentAddress;
+
+                    //寮�濮嬫暟鎹簱浜嬪姟
+                    _unitOfWorkManage.BeginTran();
+                    _stockRepository.AddData(stock);
+                    _locationRepository.UpdateData(location);
+                    _taskhtyRepository.AddData(taskhty);
+                    BaseDal.DeleteData(nawtask);
+                    //鎻愪氦浜嬪姟
+                    _unitOfWorkManage.CommitTran();
+                }
+                //姝e父鍏ュ簱
+                else
+                {
+                    var batck = _batchinfoRepository.QueryFirst(v => v.Id == 1);
+                    //鏂板缓搴撳瓨
+                    Dt_StockInfo stock = new Dt_StockInfo();
+                    stock.LocationCode = nawtask.TargetAddress;
+                    stock.StockStatus = (int)stockEnum.Free;
+                    stock.BatchNo = batck.InBatch;
+                    if (nawtask.Remark == (int)MateTypeEnum.ZiChan)
+                    {
+                        stock.Remark = (int)MateTypeEnum.ZiChan;
+                    }
+                    else
+                    {
+                        stock.Remark = (int)MateTypeEnum.WaiGou;
+                    }
+                    Dt_StockInfo stockTow = new Dt_StockInfo();
+                    stockTow.LocationCode = nawtask.NextAddress;
+                    stockTow.StockStatus = (int)stockEnum.Free;
+                    stockTow.BatchNo = batck.InBatch;
+                    if (nawtask.Remark == (int)MateTypeEnum.ZiChan)
+                    {
+                        stockTow.Remark = (int)MateTypeEnum.ZiChan;
+                    }
+                    else
+                    {
+                        stockTow.Remark = (int)MateTypeEnum.WaiGou;
+                    }
+                    //淇敼璐т綅淇℃伅
+                    var location = _locationRepository.QueryFirst(v => v.LocationCode == nawtask.TargetAddress);
+                    location.LocationStatus = (int)LocationStatusEnum.InStock;
+                    //淇敼璐т綅淇℃伅
+                    var locationtow = _locationRepository.QueryFirst(v => v.LocationCode == nawtask.NextAddress);
+                    locationtow.LocationStatus = (int)LocationStatusEnum.InStock;
+                    //澶勭悊浠诲姟淇℃伅
+                    Dt_Task_hty taskhty = new Dt_Task_hty();
+                    taskhty.TaskNum = nawtask.TaskNum;
+                    taskhty.Roadway = nawtask.Roadway;
+                    taskhty.TaskType = nawtask.TaskType;
+                    taskhty.TaskState = (int)TaskInStatusEnum.Line_InFinish;
+                    taskhty.SourceAddress = nawtask.SourceAddress;
+                    taskhty.TargetAddress = nawtask.TargetAddress;
+                    taskhty.ExceptionMessage = nawtask.ExceptionMessage;
+                    taskhty.Grade = nawtask.Grade;
+                    taskhty.Dispatchertime = nawtask.Dispatchertime;
+                    taskhty.Remark = nawtask.Remark;
+                    taskhty.PalletCode = nawtask.PalletCode;
+                    taskhty.NextAddress = nawtask.NextAddress;
+                    taskhty.CurrentAddress = nawtask.CurrentAddress;
+
+                    //寮�濮嬫暟鎹簱浜嬪姟
+                    _unitOfWorkManage.BeginTran();
+                    _stockRepository.AddData(stock);
+                    _stockRepository.AddData(stockTow);
+                    _locationRepository.UpdateData(location);
+                    _locationRepository.UpdateData(locationtow);
+                    _taskhtyRepository.AddData(taskhty);
+                    BaseDal.DeleteData(nawtask);
+                    //鎻愪氦浜嬪姟
+                    _unitOfWorkManage.CommitTran();
+                }
+            }
+            //鍑哄簱
+            else if (nawtask.TaskType == (int)TaskOutboundTypeEnum.Outbound)
+            {
+                //鍓旈櫎鍑哄簱
+                var station = _dt_stationInfoRepository.QueryFirst(v => v.msg == "瑗胯法鏋跺瓙");
+                string targetAddress = station.Row + "-" + station.Column + "-1";
+                if (nawtask.TargetAddress.Equals(targetAddress))
+                {
+                    //鏌ユ壘搴撳瓨
+                    var stock = _stockRepository.QueryFirst(v => v.LocationCode == nawtask.SourceAddress);
+                    if (stock == null)
+                    {
+                        throw new Exception($"鏈壘鍒板簱瀛樹俊鎭揣浣嶅彿:銆恵nawtask.TargetAddress}銆�");
+                    }
+                    //淇敼璐т綅鐘舵��
+                    var location = _locationRepository.QueryFirst(v => v.LocationCode == nawtask.SourceAddress);
+                    location.LocationStatus = (int)LocationStatusEnum.Free;
+                    //鍑嗗鍘嗗彶浠诲姟鏁版嵁
+                    Dt_Task_hty taskhty = new Dt_Task_hty();
+                    taskhty.TaskNum = nawtask.TaskNum;
+                    taskhty.Roadway = nawtask.Roadway;
+                    taskhty.TaskType = nawtask.TaskType;
+                    taskhty.TaskState = (int)TaskOutStatusEnum.OutFinish;
+                    taskhty.SourceAddress = nawtask.SourceAddress;
+                    taskhty.TargetAddress = nawtask.TargetAddress;
+                    taskhty.ExceptionMessage = nawtask.ExceptionMessage;
+                    taskhty.Grade = nawtask.Grade;
+                    taskhty.Dispatchertime = nawtask.Dispatchertime;
+                    taskhty.Remark = nawtask.Remark;
+                    taskhty.PalletCode = nawtask.PalletCode;
+                    taskhty.NextAddress = nawtask.NextAddress;
+                    taskhty.CurrentAddress = nawtask.CurrentAddress;
+                    //寮�濮嬫暟鎹簱浜嬪姟
+
+                    _unitOfWorkManage.BeginTran();
+                    _stockRepository.DeleteData(stock);
+                    _locationRepository.UpdateData(location);
+                    _taskhtyRepository.AddData(taskhty);
+                    BaseDal.DeleteData(nawtask);
+                    //鎻愪氦浜嬪姟
+                    _unitOfWorkManage.CommitTran();
+                }
+                //姝e父鍑哄簱
+                else
+                {
+                    //鏌ユ壘搴撳瓨
+                    var stock = _stockRepository.QueryFirst(v => v.LocationCode == nawtask.SourceAddress);
+                    if (stock == null)
+                    {
+                        throw new Exception($"鏈壘鍒板簱瀛樹俊鎭揣浣嶅彿:銆恵nawtask.TargetAddress}銆�");
+                    }
+                    var Towstock = _stockRepository.QueryFirst(v => v.LocationCode == nawtask.NextAddress);
+                    //淇敼璐т綅鐘舵��
+                    var location = _locationRepository.QueryFirst(v => v.LocationCode == nawtask.SourceAddress);
+                    location.LocationStatus = (int)LocationStatusEnum.Free;
+                    //淇敼璐т綅鐘舵��
+                    var locationTow = _locationRepository.QueryFirst(v => v.LocationCode == nawtask.NextAddress);
+                    locationTow.LocationStatus = (int)LocationStatusEnum.Free;
+                    //鍑嗗鍘嗗彶浠诲姟鏁版嵁
+                    Dt_Task_hty taskhty = new Dt_Task_hty();
+                    taskhty.TaskNum = nawtask.TaskNum;
+                    taskhty.Roadway = nawtask.Roadway;
+                    taskhty.TaskType = nawtask.TaskType;
+                    taskhty.TaskState = (int)TaskOutStatusEnum.OutFinish;
+                    taskhty.SourceAddress = nawtask.SourceAddress;
+                    taskhty.TargetAddress = nawtask.TargetAddress;
+                    taskhty.ExceptionMessage = nawtask.ExceptionMessage;
+                    taskhty.Grade = nawtask.Grade;
+                    taskhty.Dispatchertime = nawtask.Dispatchertime;
+                    taskhty.Remark = nawtask.Remark;
+                    taskhty.PalletCode = nawtask.PalletCode;
+                    taskhty.NextAddress = nawtask.NextAddress;
+                    taskhty.CurrentAddress = nawtask.CurrentAddress;
+                    //寮�濮嬫暟鎹簱浜嬪姟
+
+                    _unitOfWorkManage.BeginTran();
+                    _stockRepository.DeleteData(stock);
+                    _stockRepository.DeleteData(Towstock);
+                    _locationRepository.UpdateData(location);
+                    _locationRepository.UpdateData(locationTow);
+                    _taskhtyRepository.AddData(taskhty);
+                    BaseDal.DeleteData(nawtask);
+                    //鎻愪氦浜嬪姟
+                    _unitOfWorkManage.CommitTran();
+                }
+            }
+            return content.OK("瀹屾垚");
+        }
     }
 }

--
Gitblit v1.9.3