From 0a62180f002d8a601b6b3c46af3a6b4583f9acf6 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期二, 14 四月 2026 18:06:59 +0800
Subject: [PATCH] 添加库区查询接口返回字段:区域
---
代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs | 457 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 440 insertions(+), 17 deletions(-)
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
index c7efb17..ade4182 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_TaskInfoService/TaskService.cs"
@@ -198,6 +198,10 @@
content = CJCarryTaske(task, item.taskType);
objects.Add(content.Data);
break;
+ case (int)TaskTypeEnum.STUPTBY:
+ content = HKSTUPTP(task, item.taskType);
+ objects.Add(content.Data);
+ break;
#endregion
default:
objects.Add(new
@@ -388,7 +392,7 @@
bool isAGV = dt_Task.TaskType == (int)TaskTypeEnum.CPInbound || dt_Task.TaskType == (int)TaskTypeEnum.CPOutbound;
//娴峰悍
- bool isHK = dt_Task.TaskType == (int)TaskTypeEnum.F01 || dt_Task.TaskType == (int)TaskTypeEnum.RK3F || dt_Task.TaskType == (int)TaskTypeEnum.CK3F || dt_Task.TaskType == (int)TaskTypeEnum.Q1TSJ4 || dt_Task.TaskType == (int)TaskTypeEnum.STU0003 || dt_Task.TaskType == (int)TaskTypeEnum.F02 || dt_Task.TaskType == (int)TaskTypeEnum.CHUKU1 || dt_Task.TaskType == (int)TaskTypeEnum.Q3RK || dt_Task.TaskType == (int)TaskTypeEnum.Q3CK;
+ bool isHK = dt_Task.TaskType == (int)TaskTypeEnum.F01 || dt_Task.TaskType == (int)TaskTypeEnum.RK3F || dt_Task.TaskType == (int)TaskTypeEnum.CK3F || dt_Task.TaskType == (int)TaskTypeEnum.Q1TSJ4 || dt_Task.TaskType == (int)TaskTypeEnum.STU0003 || dt_Task.TaskType == (int)TaskTypeEnum.F02 || dt_Task.TaskType == (int)TaskTypeEnum.CHUKU1 || dt_Task.TaskType == (int)TaskTypeEnum.Q3RK || dt_Task.TaskType == (int)TaskTypeEnum.Q3CK||dt_Task.TaskType == (int)TaskTypeEnum.STUPTBY;
//淇敼鍘熸湰浠诲姟浼樺厛绾�
dt_Task.Grade = updateTaskPriority.taskPriority;
#region 鍑箰澹�
@@ -452,11 +456,15 @@
initPriority = updateTaskPriority.taskPriority//浼樺厛绾�
};
Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(HIKROBOTTaskGrade));
- if (apiInfo == null) throw new Exception("鏈壘鍒板洓鍚戣溅AGV浠诲姟涓嬪彂鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�");
- string response = HttpHelper.Post(apiInfo.ApiAddress, Hkrequest.Serialize());
+ if (apiInfo == null) throw new Exception("鏈壘鍒版捣搴稟GV浠诲姟涓嬪彂鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�");
+ var headers = new Dictionary<string, string>
+ {
+ { "X-lr-request-id", DateTimeOffset.Now.ToUnixTimeSeconds().ToString() + dt_Task.WMSTaskNum }
+ };
+ string response = HttpHelper.Post(apiInfo.ApiAddress, Hkrequest.Serialize(), headers: headers);
HIKROBOTReturn hIKROBOTReturn = response.DeserializeObject<HIKROBOTReturn>();
content.OK(data: hIKROBOTReturn);
- if (hIKROBOTReturn.code == "SUCCESS0" && hIKROBOTReturn.message == "鎴愬姛")
+ if (hIKROBOTReturn.code == "SUCCESS" && hIKROBOTReturn.message == "鎴愬姛")
{
BaseDal.UpdateData(dt_Task);
content.OK("淇敼{dt_Task.WMSTaskNum}浠诲姟浼樺厛绾ф垚鍔�", dt_Task);
@@ -514,6 +522,16 @@
var rgv = new List<Dt_RGVLocationInfo>();
var kls = new List<Dt_KLSLocationInfo>();
var hk = new List<Dt_HKLocationInfo>();
+ List<Dt_StationInfo> pk = new List<Dt_StationInfo>();
+ if (wMSUpdateLocationArea==null)
+ {
+ return content.Error("璇锋眰鍙傛暟涓嶈兘涓虹┖");
+ }
+ var validWarehouseIds = new[] { 1, 2, 3, 4 };
+ if (!validWarehouseIds.Contains(wMSUpdateLocationArea.WarehouseId))
+ {
+ return content.Error($"鏃犳晥鐨勪粨搴揑D锛歿wMSUpdateLocationArea.WarehouseId}锛屾湁鏁堝�间负锛�1-鎴愬搧搴擄紝2-闈㈡枡搴擄紝3-璐у簱锛�4-瑁佸壀搴�");
+ }
if (wMSUpdateLocationArea.WarehouseId == 1)
{
var rgvList = _rGVLocationInfoService.Repository.QueryData(x => wMSUpdateLocationArea.LocationCodes.Contains(x.LocationCode)).ToList();
@@ -522,6 +540,7 @@
item.WarehouseId = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
}
rgv.AddRange(rgvList);
+ _rGVLocationInfoService.Repository.UpdateData(rgv);
}
if (wMSUpdateLocationArea.WarehouseId == 2)
{
@@ -532,6 +551,7 @@
item.WarehouseId = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
}
kls.AddRange(KLSLocationInfoList);
+ _kLSLocationInfoService.Repository.UpdateData(kls);
}
if (wMSUpdateLocationArea.WarehouseId == 3)
{
@@ -541,12 +561,18 @@
item.WarehouseId = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
}
hk.AddRange(hkList);
+ _hKLocationInfoService.Repository.UpdateData(hk);
}
- Db.Ado.BeginTran();
- _rGVLocationInfoService.UpdateData(rgv);
- _kLSLocationInfoService.UpdateData(kls);
- _hKLocationInfoService.UpdateData(hk);
- Db.Ado.CommitTran();
+ if (wMSUpdateLocationArea.WarehouseId == 4)
+ {
+ var pkList = _stationInfo.Repository.QueryData(x => wMSUpdateLocationArea.LocationCodes.Contains(x.StationCode)).ToList();
+ foreach (var item in pkList)
+ {
+ item.StationRegion = wMSUpdateLocationArea.UpdateAreaCode.ObjToInt();
+ }
+ pk.AddRange(pkList);
+ _stationInfo.Repository.UpdateData(pk);
+ }
content.OK();
}
catch (Exception ex)
@@ -1129,7 +1155,8 @@
LoctionCode = item.LocationCode,
LocationStatus = item.LocationStatus,
EnableStatus = item.EnableStatus,
- PalletCode = item.PalletCode
+ PalletCode = item.PalletCode,
+ AreaCode=item.WarehouseId
});
}
@@ -1149,7 +1176,8 @@
LoctionCode = item.LocationCode,
LocationStatus = item.LocationStatus,
EnableStatus = item.EnableStatus,
- PalletCode = item.PalletCode
+ PalletCode = item.PalletCode,
+ AreaCode = item.WarehouseId
});
}
content.OK(data: list);
@@ -1183,7 +1211,8 @@
LoctionCode = item.LocationCode,
LocationStatus = item.LocationStatus,
EnableStatus = item.EnableStatus,
- PalletCode = item.PalletCode
+ PalletCode = item.PalletCode,
+ AreaCode = item.WarehouseId
});
}
content.OK(data: list);
@@ -1203,6 +1232,27 @@
LoctionCode = item.StationCode,
LocationStatus = value ? 100 : 0,
EnableStatus = 0,
+ });
+ }
+ content.OK(data: list);
+ }
+ else if (getLocationInfo.WarehouseId == 6)
+ {
+ List<Dt_StationInfo> StationInfo = new List<Dt_StationInfo>();
+ if (!string.IsNullOrEmpty(getLocationInfo.AreaCode))
+ StationInfo = _stationInfo.Repository.QueryData(x => x.StationRegion == getLocationInfo.AreaCode.ObjToInt());
+ else
+ StationInfo = _stationInfo.Repository.QueryData();
+ foreach (var item in StationInfo)
+ {
+ list.Add(new
+ {
+ LoctionCode = item.StationCode,
+ LocationStatus = item.StationStatus,
+ EnableStatus = item.IsOccupied,
+ PalletCode = item.PalletCode,
+ AreaCode = item.StationRegion
+
});
}
content.OK(data: list);
@@ -1239,11 +1289,11 @@
public WebResponseContent InboundElevatorExit(string LocationCode, string containerCode)
{
WebResponseContent content = new WebResponseContent();
- inboundElevatorExitDTO inboundElevator=new inboundElevatorExitDTO();
+ inboundElevatorExitDTO inboundElevator = new inboundElevatorExitDTO();
try
{
Dt_ApiInfo? apiInfo = _apiInfoService.Repository.QueryFirst(x => x.ApiCode == nameof(inboundElevatorExitDTO)) ?? throw new Exception("鏈壘鍒�4F鎻愬崌鏈哄嚭鍙f墭鐩樺彿涓婃姤WMS鎺ュ彛閰嶇疆淇℃伅锛佽妫�鏌ユ帴鍙i厤缃�");
- inboundElevator.containerCode= containerCode;
+ inboundElevator.containerCode = containerCode;
inboundElevator.toLocationCode = LocationCode;
string response = HttpHelper.Post(apiInfo.ApiAddress, inboundElevator.Serialize());
content.OK(data: response);
@@ -1280,6 +1330,9 @@
string dataJson = wMSReturn.result.ToString();
Exists? exists = JsonConvert.DeserializeObject<Exists>(dataJson);
if (exists == null) throw new Exception($"WMS杩斿洖缁撴灉鐨剅esult杞崲澶辫触");
+ //濡傛灉鎴愬姛灏变笉杩斿洖
+ if (exists.taskExists) return WebResponseContent.Instance.OK();
+ //濡傛灉澶辫触浜嗗氨杩斿洖exists.errorAreaCode
return WebResponseContent.Instance.OK(exists.errorAreaCode);
}
catch (Exception ex)
@@ -1301,6 +1354,41 @@
throw new NotImplementedException();
}
/// <summary>
+ /// 骞冲簱璐т綅涓婁笅鏋跺鍣�
+ /// </summary>
+ /// <param name="wMSUpOrDown"></param>
+ /// <returns></returns>
+ public WebResponseContent UpOrDownContainer(WMSUpOrDownContainerDTO wMSUpOrDown)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ Dt_StationInfo stationInfo = _stationInfo.Repository.QueryFirst(x => x.StationCode == wMSUpOrDown.locationCode) ?? throw new Exception($"鏈壘鍒拌揣浣嶃�恵wMSUpOrDown.locationCode}銆戜俊鎭�");
+ if (wMSUpOrDown.direction == 1)
+ {
+ stationInfo.StationStatus = LocationStatusEnum.InStock.ObjToInt();
+ stationInfo.PalletCode = wMSUpOrDown.containerCode;
+ }
+ else
+ {
+ stationInfo.StationStatus = LocationStatusEnum.Free.ObjToInt();
+ stationInfo.PalletCode = "";
+ }
+ _stationInfo.UpdateData(stationInfo);
+ content.OK();
+ }
+ catch (Exception ex)
+ {
+ content.Error(ex.Message);
+ }
+ finally
+ {
+ _trackloginfoService.AddTrackLog(wMSUpOrDown, content, "骞冲簱璐т綅涓婁笅鏋跺鍣�", "", "");
+ }
+ return content;
+ }
+
+ /// <summary>
/// 瀹瑰櫒娴佸姩璇锋眰
/// </summary>
/// <param name="wMSContainerFlow"></param>
@@ -1308,6 +1396,7 @@
/// <exception cref="NotImplementedException"></exception>
public WebResponseContent ContainerRequest(WMSContainerFlow wMSContainerFlow)
{
+ WebResponseContent content = new WebResponseContent();
try
{
Dt_StationManger stationManger = _stationMangerService.Repository.QueryFirst(x => x.StationCode == wMSContainerFlow.slotCode) ?? throw new Exception($"鏈壘鍒扮珯鍙般�恵wMSContainerFlow.slotCode}銆戜俊鎭�");
@@ -1315,20 +1404,26 @@
if (wMSContainerFlow.direction == "200")
{
stationManger.IsOccupied = LocationStatusEnum.Free.ObjToInt();
+ stationManger.Remark = "";
FOURBOToccupyStation fOURBOToccupyStation = new FOURBOToccupyStation()
{
stationCode = wMSContainerFlow.slotCode,
};
string response = HttpHelper.Post(apiInfo.ApiAddress, fOURBOToccupyStation.Serialize());
FOURBOTReturn fOURBOTReturn = response.DeserializeObject<FOURBOTReturn>();
+ content.OK(data: fOURBOTReturn);
if (fOURBOTReturn.returnCode != 0) throw new Exception(fOURBOTReturn.returnUserMsg);
_stationMangerService.UpdateData(stationManger);
}
- return WebResponseContent.Instance.OK();
+ return content.OK();
}
catch (Exception ex)
{
- return WebResponseContent.Instance.Error(ex.Message);
+ return content.Error(ex.Message);
+ }
+ finally
+ {
+ _trackloginfoService.AddTrackLog(wMSContainerFlow, content, "瀹瑰櫒娴佸姩璇锋眰", "", "");
}
}
/// <summary>
@@ -1381,11 +1476,21 @@
//task.TaskState = (int)TaskStatusEnum.Execut;
//BaseDal.UpdateData(task);
#endregion
+
+ #region 涓婃灦涓渶瑕佸皢绔欏彴鐘舵�佹敼涓哄崰鐢� 缁戝畾瀹瑰櫒缂栫爜
+ stationManger.IsOccupied = LocationStatusEnum.Lock.ObjToInt();
+ stationManger.Remark = iQC.ContainerCode;
+ _stationMangerService.UpdateData(stationManger);
+ #endregion
return WebResponseContent.Instance.OK();
}
catch (Exception ex)
{
return WebResponseContent.Instance.Error(ex.Message);
+ }
+ finally
+ {
+ _trackloginfoService.AddTrackLog(iQC, content, "IQC璐ㄦ缁撴灉鍙嶉", "", "");
}
}
@@ -1397,6 +1502,7 @@
/// <exception cref="NotImplementedException"></exception>
public WebResponseContent multiSetNodeStatus(FOURBOTStorageStatusNotify fOURBOTStorageStatusNotify)
{
+ WebResponseContent content = new WebResponseContent();
try
{
var Agvlocation = _rGVLocationInfoService.Repository.QueryData(x => fOURBOTStorageStatusNotify.storageCode.Contains(x.LocationCode));
@@ -1405,12 +1511,16 @@
item.EnableStatus = (int)(fOURBOTStorageStatusNotify.disable == 0 ? EnableStatusEnum.Normal : EnableStatusEnum.Disable);
}
_rGVLocationInfoService.UpdateData(Agvlocation);
- return WebResponseContent.Instance.OK();
+ return content.OK();
}
catch (Exception ex)
{
return WebResponseContent.Instance.Error(ex.Message);
+ }
+ finally
+ {
+ _trackloginfoService.AddTrackLog(fOURBOTStorageStatusNotify, content, "鎵归噺鏇存柊鍌ㄤ綅鐘舵��", "", "");
}
}
@@ -1440,7 +1550,320 @@
}
}
+ /// <summary>
+ /// 鏍¢獙浠诲姟鐩稿叧鐨勫簱浣嶇姸鎬佸拰缁戝畾鍏崇郴
+ /// </summary>
+ /// <param name="taskType">浠诲姟绫诲瀷</param>
+ /// <param name="taskDTO">浠诲姟DTO</param>
+ /// <returns>杩斿洖璧风偣搴撲綅鍜岀粓鐐瑰簱浣嶄俊鎭�</returns>
+ /// <exception cref="Exception">鏍¢獙澶辫触鏃舵姏鍑哄紓甯�</exception>
+ private WebResponseContent ValidateLocationForTask(int taskType, TaskDTO taskDTO)
+ {
+ WebResponseContent content = new WebResponseContent();
+ try
+ {
+ #region
+ // 鍏ュ簱绫讳换鍔★紙闇�瑕佹牎楠岀粓鐐瑰簱浣嶏級
+ if (taskType == (int)TaskTypeEnum.CK3F || taskType == (int)TaskTypeEnum.F03)
+ {
+ var toStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode)
+ ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱浣嶃�恵taskDTO.toLocationCode}銆戯紒");
+
+ if (toStation.StationStatus != (int)LocationStatusEnum.Free)
+ throw new Exception($"缁堢偣搴撲綅銆恵taskDTO.toLocationCode}銆戝簱浣嶇姸鎬佷笉鍙叆搴擄紒");
+ }
+ // 鍑哄簱绫讳换鍔★紙闇�瑕佹牎楠岃捣鐐瑰簱浣嶏級
+ else if (taskType == (int)TaskTypeEnum.RK3F || taskType == (int)TaskTypeEnum.F04)
+ {
+ var fromStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode)
+ ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
+
+ if (fromStation.StationStatus != (int)LocationStatusEnum.InStock)
+ throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
+
+ if (fromStation.PalletCode != taskDTO.containerCode)
+ throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戠粦瀹氭枡绠卞彿銆恵fromStation.PalletCode}銆戜笌浠诲姟鏂欑鍙枫�恵taskDTO.containerCode}銆戜笉鍖归厤锛�");
+ }
+ // 绉诲簱绫讳换鍔★紙闇�瑕佸悓鏃舵牎楠岃捣鐐瑰拰缁堢偣锛�
+ else if (taskType == (int)TaskTypeEnum.F02)
+ {
+ // 鏍¢獙缁堢偣搴撲綅
+ var toStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.toLocationCode)
+ ?? throw new Exception($"鏈壘鍒扮粓鐐瑰簱浣嶃�恵taskDTO.toLocationCode}銆戯紒");
+
+ if (toStation.StationStatus != (int)LocationStatusEnum.Free)
+ throw new Exception($"缁堢偣搴撲綅銆恵taskDTO.toLocationCode}銆戝簱浣嶇姸鎬佷笉鍙叆搴擄紒");
+
+ // 鏍¢獙璧风偣搴撲綅
+ var fromStation = _stationInfo.Repository.QueryFirst(x => x.StationName == taskDTO.fromLocationCode)
+ ?? throw new Exception($"鏈壘鍒拌捣鐐瑰簱浣嶃�恵taskDTO.fromLocationCode}銆戯紒");
+
+ if (fromStation.StationStatus != (int)LocationStatusEnum.InStock)
+ throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戝綋鍓嶅簱浣嶇姸鎬佷笉鍙嚭搴擄紒");
+
+ if (fromStation.PalletCode != taskDTO.containerCode)
+ throw new Exception($"璧风偣搴撲綅銆恵taskDTO.fromLocationCode}銆戠粦瀹氭枡绠卞彿銆恵fromStation.PalletCode}銆戜笌浠诲姟鏂欑鍙枫�恵taskDTO.containerCode}銆戜笉鍖归厤锛�");
+ }
+ #endregion
+ return content.OK();
+ }
+ catch (Exception ex)
+ {
+
+ return content.Error(ex.Message);
+ }
+ }
+
+
+
+ /// <summary>
+ /// 鏇存柊搴撲綅鍚敤绂佺敤鐘舵��
+ /// </summary>
+ /// <param name="upLocationStatusDTO"></param>
+ /// <returns></returns>
+ public WebResponseContent UpLocationStatus(UpLocationStatusDTO upLocationStatusDTO)
+ {
+ WebResponseContent content = new WebResponseContent();
+ List<object> resultList = new List<object>();
+
+ try
+ {
+ // 鍙傛暟楠岃瘉
+ if (upLocationStatusDTO == null)
+ {
+ return content.Error("璇锋眰鍙傛暟涓嶈兘涓虹┖");
+ }
+
+ if (upLocationStatusDTO.LocationNubList == null || upLocationStatusDTO.LocationNubList.Length == 0)
+ {
+ return content.Error("璐т綅缂栧彿鍒楄〃涓嶈兘涓虹┖");
+ }
+
+ // 鏍规嵁 EnableStatus 鐨勫�煎垽鏂槸鍚敤杩樻槸绂佺敤
+ // 0=鍚敤锛�3=绂佺敤
+ bool isEnable = (upLocationStatusDTO.EnableStatus == 0);
+ int targetStatus = isEnable ? (int)EnableStatusEnum.Normal : (int)EnableStatusEnum.Disable;
+
+ var updatedList = new List<object>(); // 鐢ㄤ簬鎵归噺鏇存柊
+ var notFoundLocations = new List<string>();
+
+ // 鎴愬搧搴� (WarehouseId = 1)
+ if (upLocationStatusDTO.WarehouseId == 1)
+ {
+ var locationsToUpdate = new List<Dt_RGVLocationInfo>();
+
+ foreach (var locationCode in upLocationStatusDTO.LocationNubList)
+ {
+ var agv = _rGVLocationInfoService.Repository.QueryFirst(x => x.LocationCode == locationCode);
+ if (agv != null)
+ {
+ agv.EnableStatus = targetStatus;
+ locationsToUpdate.Add(agv);
+
+ resultList.Add(new
+ {
+ LoctionCode = agv.LocationCode,
+ EnableStatus = agv.EnableStatus,
+ });
+ }
+ else
+ {
+ notFoundLocations.Add(locationCode);
+ }
+ }
+
+ if (locationsToUpdate.Any())
+ {
+ _rGVLocationInfoService.UpdateData(locationsToUpdate);
+
+ string message = $"鎴愬姛鏇存柊 {locationsToUpdate.Count} 涓揣浣嶇殑鐘舵��";
+ if (notFoundLocations.Any())
+ {
+ message += $"锛屾湭鎵惧埌璐т綅锛歿string.Join(",", notFoundLocations)}";
+ }
+ content.OK(data: resultList, message: message);
+ }
+ else
+ {
+ return content.Error($"鏈壘鍒颁换浣曞彲鏇存柊鐨勮揣浣嶃�傛湭鎵惧埌鐨勮揣浣嶏細{string.Join(",", notFoundLocations)}");
+ }
+ }
+ // 闈㈡枡搴� (WarehouseId = 2)
+ else if (upLocationStatusDTO.WarehouseId == 2)
+ {
+ var locationsToUpdate = new List<Dt_KLSLocationInfo>();
+
+ foreach (var locationCode in upLocationStatusDTO.LocationNubList)
+ {
+ var kls = _kLSLocationInfoService.Repository.QueryFirst(x => x.LocationCode == locationCode);
+ if (kls != null)
+ {
+ kls.EnableStatus = targetStatus;
+ locationsToUpdate.Add(kls);
+
+ resultList.Add(new
+ {
+ LoctionCode = kls.LocationCode,
+ EnableStatus = kls.EnableStatus,
+ });
+ }
+ else
+ {
+ notFoundLocations.Add(locationCode);
+ }
+ }
+
+ if (locationsToUpdate.Any())
+ {
+ _kLSLocationInfoService.UpdateData(locationsToUpdate);
+
+ string message = $"鎴愬姛鏇存柊 {locationsToUpdate.Count} 涓揣浣嶇殑鐘舵��";
+ if (notFoundLocations.Any())
+ {
+ message += $"锛屾湭鎵惧埌璐т綅锛歿string.Join(",", notFoundLocations)}";
+ }
+ content.OK(data: resultList, message: message);
+ }
+ else
+ {
+ return content.Error($"鏈壘鍒颁换浣曞彲鏇存柊鐨勮揣浣嶃�傛湭鎵惧埌鐨勮揣浣嶏細{string.Join(",", notFoundLocations)}");
+ }
+ }
+ // 瑁佸壀搴� (WarehouseId = 3)
+ else if (upLocationStatusDTO.WarehouseId == 3)
+ {
+ var locationsToUpdate = new List<Dt_HKLocationInfo>();
+
+ foreach (var locationCode in upLocationStatusDTO.LocationNubList)
+ {
+ var hk = _hKLocationInfoService.Repository.QueryFirst(x => x.LocationCode == locationCode);
+ if (hk != null)
+ {
+ hk.EnableStatus = targetStatus;
+ locationsToUpdate.Add(hk);
+
+ resultList.Add(new
+ {
+ LoctionCode = hk.LocationCode,
+ EnableStatus = hk.EnableStatus,
+ });
+ }
+ else
+ {
+ notFoundLocations.Add(locationCode);
+ }
+ }
+
+ if (locationsToUpdate.Any())
+ {
+ _hKLocationInfoService.UpdateData(locationsToUpdate);
+
+ string message = $"鎴愬姛鏇存柊 {locationsToUpdate.Count} 涓揣浣嶇殑鐘舵��";
+ if (notFoundLocations.Any())
+ {
+ message += $"锛屾湭鎵惧埌璐т綅锛歿string.Join(",", notFoundLocations)}";
+ }
+ content.OK(data: resultList, message: message);
+ }
+ else
+ {
+ return content.Error($"鏈壘鍒颁换浣曞彲鏇存柊鐨勮揣浣嶃�傛湭鎵惧埌鐨勮揣浣嶏細{string.Join(",", notFoundLocations)}");
+ }
+ }
+ // 3-4骞冲簱
+ else if (upLocationStatusDTO.WarehouseId == 4)
+ {
+ var locationsToUpdate = new List<Dt_StationInfo>();
+
+ foreach (var locationCode in upLocationStatusDTO.LocationNubList)
+ {
+ var station = _stationInfo.Repository.QueryFirst(x => x.StationCode == locationCode);
+ if (station != null)
+ {
+ station.IsOccupied = upLocationStatusDTO.EnableStatus==0?0:1;
+ locationsToUpdate.Add(station);
+
+ resultList.Add(new
+ {
+ LoctionCode = station.StationCode,
+ EnableStatus = station.IsOccupied,
+ });
+ }
+ else
+ {
+ notFoundLocations.Add(locationCode);
+ }
+ }
+
+ if (locationsToUpdate.Any())
+ {
+ _stationInfo.UpdateData(locationsToUpdate);
+
+ string message = $"鎴愬姛鏇存柊 {locationsToUpdate.Count} 涓揣浣嶇殑鐘舵��";
+ if (notFoundLocations.Any())
+ {
+ message += $"锛屾湭鎵惧埌璐т綅锛歿string.Join(",", notFoundLocations)}";
+ }
+ content.OK(data: resultList, message: message);
+ }
+ else
+ {
+ return content.Error($"鏈壘鍒颁换浣曞彲鏇存柊鐨勮揣浣嶃�傛湭鎵惧埌鐨勮揣浣嶏細{string.Join(",", notFoundLocations)}");
+ }
+ }
+ else if (upLocationStatusDTO.WarehouseId == 5)
+ {
+ var locationsToUpdate = new List<Dt_StationManger>();
+
+ foreach (var locationCode in upLocationStatusDTO.LocationNubList)
+ {
+ var station = _stationMangerService.Repository.QueryFirst(x => x.StationCode == locationCode);
+ if (station != null)
+ {
+ station.IsOccupied = upLocationStatusDTO.EnableStatus == 0 ? 0 : 1;
+ locationsToUpdate.Add(station);
+
+ resultList.Add(new
+ {
+ LoctionCode = station.StationCode,
+ EnableStatus = station.IsOccupied,
+ });
+ }
+ else
+ {
+ notFoundLocations.Add(locationCode);
+ }
+ }
+
+ if (locationsToUpdate.Any())
+ {
+ _stationMangerService.UpdateData(locationsToUpdate);
+
+ string message = $"鎴愬姛鏇存柊 {locationsToUpdate.Count} 涓揣浣嶇殑鐘舵��";
+ if (notFoundLocations.Any())
+ {
+ message += $"锛屾湭鎵惧埌绔欏彴锛歿string.Join(",", notFoundLocations)}";
+ }
+ content.OK(data: resultList, message: message);
+ }
+ else
+ {
+ return content.Error($"鏈壘鍒颁换浣曞彲鏇存柊鐨勭珯鍙般�傛湭鎵惧埌鐨勭珯鍙帮細{string.Join(",", notFoundLocations)}");
+ }
+ }
+ else
+ {
+ return content.Error($"涓嶆敮鎸佺殑浠撳簱绫诲瀷锛歿upLocationStatusDTO.WarehouseId}");
+ }
+
+ return content;
+ }
+ catch (Exception ex)
+ {
+ return content.Error($"鏇存柊绔欏彴鐘舵�佸け璐ワ細{ex.Message}");
+ }
+ }
}
}
--
Gitblit v1.9.3