From 3d3598eea1b93ed7f977d077355ebbcc1270ba38 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期日, 02 十一月 2025 12:17:33 +0800
Subject: [PATCH] 优化
---
新建文件夹/WIDESEA_WMSServer/ClassLibrary2/EquipmentAlarmInforService.cs | 182 --------------------------------------------
新建文件夹/WIDESEA_WMSServer/ClassLibrary2/MessageInfoService.cs | 1
新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs | 17 ++-
新建文件夹/WIDESEA_WMSServer/ClassLibrary2/ContainerService.cs | 2
4 files changed, 15 insertions(+), 187 deletions(-)
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/ContainerService.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/ContainerService.cs"
index bc1b6d0..b0b272b 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/ContainerService.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/ContainerService.cs"
@@ -71,7 +71,7 @@
if (item.alarm != "姝e父")
{
_messageInfoService.AddMessageInfo(MessageGroupByEnum.EquipmentAlarm,
- $"鍐锋煖{item.alarm}", item.message, MessageStatusEnum.Undisposed);
+ $"鍐锋煖{item.name}{item.alarm}", item.message, MessageStatusEnum.Undisposed);
}
}
if (containersAdd.Count > 0) BaseDal.AddData(containersAdd);
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/EquipmentAlarmInforService.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/EquipmentAlarmInforService.cs"
index 7d61267..397a3bc 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/EquipmentAlarmInforService.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/EquipmentAlarmInforService.cs"
@@ -76,7 +76,7 @@
}
if (string.Equals(item.status, nameof(DeviceStatus.Error), StringComparison.OrdinalIgnoreCase))
{
- _messageInfoService.AddMessageInfo(MessageGroupByEnum.EquipmentAlarm, item.robotName, item.status);
+ _messageInfoService.AddMessageInfo(MessageGroupByEnum.EquipmentAlarm,"灏忚溅缂栧彿"+ item.robotCode, item.status);
}
}
foreach (var item in response.data.sorters)
@@ -103,7 +103,7 @@
}
if (string.Equals(item.status, nameof(DeviceStatus.Error), StringComparison.OrdinalIgnoreCase))
{
- _messageInfoService.AddMessageInfo(MessageGroupByEnum.EquipmentAlarm, item.sorterCode, item.status);
+ _messageInfoService.AddMessageInfo(MessageGroupByEnum.EquipmentAlarm, "鍒嗘嫞鍙板悕瀛�"+ item.sorterCode, item.status);
}
}
if (equipmentAlarmInforsAdd.Count > 0) BaseDal.AddData(equipmentAlarmInforsAdd);
@@ -116,182 +116,6 @@
return content;
}
- /// <summary>
- /// 鏌ョ湅绔嬪簱灏忚溅鎶ヨ淇℃伅
- /// </summary>
- /// <returns></returns>
- public WebResponseContent getDeviceStatus1()
- {
- try
- {
- var url = "http://172.16.1.2:8080/cube/taskInfo/getDeviceStatus?token=wH5zdAUCv2BEHJIinmowyki8cdc5ge8fAwFDcYZs0bVldNgmORt0O0l4GJTDv1dglRdMxb9xDK5Qb3NJAqL1Li2GkfdVa3KnIkfrQZtsP7UXhMmUz6xEuztG6d5svAJO9HENLb8JWVqCfpO2EWV6ebo/g5tJ9x7kbwwAxvCBrWdiEJv09FvaRQ== ";
- var result = HttpHelper.Get(url);
- var response = JsonConvert.DeserializeObject<AGVResponse<DeviceStatusData>>(result);
-
- // 妫�鏌ユ帴鍙e搷搴旀槸鍚︽垚鍔�
- if (response == null || response.code != "0")
- {
- return new WebResponseContent { Status = false, Message = $"WCS鎺ュ彛璋冪敤澶辫触: {response?.msg}" };
- }
-
- var syncTime = DateTime.Now;
- var AddEquipList = new List<Dt_EquipmentAlarmInfor>();
- var UpdateEquipList = new List<Dt_EquipmentAlarmInfor>();
- var alarmList = new List<(string deviceType, string deviceName, string deviceCode)>();
-
- // 鏀堕泦鎵�鏈夎澶囩紪鐮侊紝涓�娆℃�ф煡璇�
- var allDeviceCodes = new List<string>();
- if (response.data?.robot != null && response.data.robot.Count > 0)
- {
- allDeviceCodes.AddRange(response.data.robot.Select(x => x.robotCode));
- }
- if (response.data?.sorters != null && response.data.sorters.Count > 0)
- {
- allDeviceCodes.AddRange(response.data.sorters.Select(x => x.sorterCode));
- }
-
- // 涓�娆℃�ф煡璇㈡墍鏈夊凡瀛樺湪鐨勮澶囪褰�
- var existingRecords = allDeviceCodes.Any()
- ? BaseDal.QueryData(x => allDeviceCodes.Contains(x.RobotCode))
- .ToDictionary(x => x.RobotCode, x => x)
- : new Dictionary<string, Dt_EquipmentAlarmInfor>();
-
- // 澶勭悊鏈哄櫒浜鸿澶囨暟鎹�
- if (response.data?.robot != null && response.data.robot.Count > 0)
- {
- foreach (var robot in response.data.robot)
- {
- ProcessDevice(robot.robotCode, robot.robotName, robot.status, "鏈哄櫒浜�",
- existingRecords, AddEquipList, UpdateEquipList, alarmList, syncTime);
- }
- }
-
- // 澶勭悊鍒嗘嫞鍙拌澶囨暟鎹�
- if (response.data?.sorters != null && response.data.sorters.Count > 0)
- {
- foreach (var sorter in response.data.sorters)
- {
- ProcessDevice(sorter.sorterCode, sorter.sorterName, sorter.status, "鍒嗘嫞鍙�",
- existingRecords, AddEquipList, UpdateEquipList, alarmList, syncTime);
- }
- }
-
- // 寮�鍚簨鍔�
- //_unitOfWorkManage.BeginTran();
- try
- {
- // 鎵归噺鎿嶄綔
- if (AddEquipList.Count > 0)
- {
- BaseDal.AddData(AddEquipList);
- }
- if (UpdateEquipList.Count > 0)
- {
- BaseDal.UpdateData(UpdateEquipList);
- }
-
- // 鎻愪氦浜嬪姟
- //_unitOfWorkManage.CommitTran();
-
- // 澶勭悊鎶ヨ淇℃伅
- ProcessAlarmMessages(alarmList);
-
- var totalCount = AddEquipList.Count + UpdateEquipList.Count;
- return new WebResponseContent
- {
- Status = true,
- Message = $"鍚屾鎴愬姛锛屾柊澧� {AddEquipList.Count} 鏉★紝鏇存柊 {UpdateEquipList.Count} 鏉★紝鍏卞鐞� {totalCount} 鏉¤澶囪褰曘��"
- };
- }
- catch (Exception ex)
- {
- //_unitOfWorkManage.RollbackTran();
- return new WebResponseContent
- {
- Status = false,
- Message = $"鏁版嵁淇濆瓨澶辫触: {ex.Message}"
- };
- }
- }
- catch (Exception ex)
- {
- return new WebResponseContent
- {
- Status = false,
- Message = $"鑾峰彇璁惧鐘舵�佸け璐�: {ex.Message}"
- };
- }
- }
-
- /// <summary>
- /// 澶勭悊鍗曚釜璁惧璁板綍
- /// </summary>
- private void ProcessDevice(string deviceCode, string deviceName, string status, string deviceType,
- Dictionary<string, Dt_EquipmentAlarmInfor> existingRecords,
- List<Dt_EquipmentAlarmInfor> addList,
- List<Dt_EquipmentAlarmInfor> updateList,
- List<(string deviceType, string deviceName, string deviceCode)> alarmList,
- DateTime syncTime)
- {
- if (existingRecords.TryGetValue(deviceCode, out var existingRecord))
- {
- // 妫�鏌ョ姸鎬佹槸鍚﹀彂鐢熷彉鍖栵紝閬垮厤涓嶅繀瑕佺殑鏇存柊鍜岄噸澶嶆姤璀�
- bool statusChanged = existingRecord.Status != status;
-
- // 鏇存柊鐜版湁璁板綍
- existingRecord.RobotName = deviceName;
- existingRecord.Status = status;
- existingRecord.SyncTime = syncTime;
- existingRecord.ModifyDate = syncTime;
- existingRecord.Modifier = "System";
-
- updateList.Add(existingRecord);
-
- // 鍙湁鐘舵�佸彉涓篹rror鏃舵墠鎶ヨ
- if (statusChanged && status == "error")
- {
- alarmList.Add((deviceType, deviceName, deviceCode));
- }
- }
- else
- {
- // 鍒涘缓鏂拌褰�
- var newRecord = new Dt_EquipmentAlarmInfor
- {
- RobotName = deviceName,
- RobotCode = deviceCode,
- Status = status,
- SyncTime = syncTime,
- CreateDate = syncTime,
- Creater = "System"
- };
- addList.Add(newRecord);
-
- // 鏂拌澶囩姸鎬佷负error鏃舵姤璀�
- if (status == "error")
- {
- alarmList.Add((deviceType, deviceName, deviceCode));
- }
- }
- }
-
- /// <summary>
- /// 澶勭悊鎶ヨ淇℃伅
- /// </summary>
- private void ProcessAlarmMessages(List<(string deviceType, string deviceName, string deviceCode)> alarmList)
- {
- foreach (var alarm in alarmList)
- {
- string alarmTitle = alarm.deviceType == "鏈哄櫒浜�"
- ? "灏忚溅鍚嶇О:" + alarm.deviceName
- : "鍒嗘嫞鍙板悕绉�:" + alarm.deviceName;
-
- string alarmMessage = alarm.deviceType == "鏈哄櫒浜�"
- ? $"灏忚溅缂栧彿銆恵alarm.deviceCode}銆戝彂鐢熼敊璇�"
- : $"缂栧彿銆恵alarm.deviceCode}銆戝彂鐢熼敊璇�";
-
- _messageInfoService.AddMessageInfo(MessageGroupByEnum.EquipmentAlarm, alarmTitle, alarmMessage, MessageStatusEnum.Emergency);
- }
- }
+
}
}
\ No newline at end of file
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/MessageInfoService.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/MessageInfoService.cs"
index 55e2047..7ab47d9 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/MessageInfoService.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/ClassLibrary2/MessageInfoService.cs"
@@ -135,6 +135,7 @@
}
}
var messinfo = BaseDal.QueryData(x => x.MessageStatus < MessageStatusEnum.Wait.ObjToInt());
+ messagesinfo = messagesinfo.Where(x => !messinfo.Select(x => x.Id).Contains(x.Id)).ToList();
foreach (var item in messinfo)
{
Message message = new Message()
diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs"
index bb3deea..9679eb4 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/extend/Check.cs"
@@ -254,15 +254,15 @@
#endregion
#region 鍒ゆ柇褰撳墠鐗╂枡鎵规鐨勭洏鐐逛换鍔℃槸鍚﹀叏閮ㄥ畬鎴�
- List<Dt_SupplyTask> supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt() && x.WarehouseCode == supplyTask.WarehouseCode).ToList();
- List<Dt_SupplyTask> supplyTasks1 = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt()).ToList();
+ List<Dt_SupplyTask> supplyTasks = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt() && x.WarehouseCode == supplyTask.WarehouseCode && x.TaskId != supplyTask.TaskId).ToList();
+ List<Dt_SupplyTask> supplyTasks1 = _supplyTaskService.Repository.QueryData(x => x.MaterielCode == supplyTask.MaterielCode && x.BatchNo == supplyTask.BatchNo && x.TaskStatus == SupplyStatusEnum.NewCheck.ObjToInt() && x.TaskId != supplyTask.TaskId).ToList();
Dt_Inventory_Batch inventory_Batch = new Dt_Inventory_Batch();
List<Dt_InventoryInfo> inventoryInfos = new List<Dt_InventoryInfo>();
if (supplyTasks1.Count < 1)
{
#region 鏌ユ壘搴撳瓨
- inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no);
- var SupplyQuantitys = inventoryInfos.Sum(x => x.SupplyQuantity);
+ inventoryInfos = _inventoryInfoService.Repository.QueryData(x => x.BatchNo == cabinOrderDetail.Batch_num && x.MaterielCode == cabinOrderDetail.Goods_no && x.Id != inventoryInfo.Id);
+ var SupplyQuantitys = inventoryInfos.Sum(x => x.SupplyQuantity) + supplyTask.SupplyQuantity;
#endregion
#region 搴撳瓨鎵规
@@ -276,6 +276,9 @@
item.SupplyQuantity = 0;
item.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
}
+ inventoryInfo.StockQuantity = supplyTask.SupplyQuantity;
+ inventoryInfo.SupplyQuantity = 0;
+ inventoryInfo.StockStatus = StockStatusEmun.鍏ュ簱瀹屾垚.ObjToInt();
}
else
{
@@ -295,19 +298,19 @@
});
_deliveryOrderDetailServices.Repository.DeleteAndMoveIntoHty(cabinOrder.Details, OperateTypeEnum.鑷姩瀹屾垚);
cabinOrder.Details = null;
- Repository.DeleteAndMoveIntoHty(cabinOrder, OperateTypeEnum.鑷姩瀹屾垚);
+ BaseDal.DeleteAndMoveIntoHty(cabinOrder, OperateTypeEnum.鑷姩瀹屾垚);
#endregion
}
else
{
- Repository.UpdateData(cabinOrder);
+ BaseDal.UpdateData(cabinOrder);
_deliveryOrderDetailServices.Repository.UpdateData(cabinOrderDetail);
}
#endregion
_inventoryInfoService.UpdateData(inventoryInfo);
_supplyTaskService.Repository.DeleteAndMoveIntoHty(supplyTask, OperateTypeEnum.鑷姩瀹屾垚);
- if (inventoryInfos.Count > 1)
+ if (inventoryInfos.Count >= 1)
{
_inventoryInfoService.UpdateData(inventoryInfos);
_inventory_BatchServices.UpdateData(inventory_Batch);
--
Gitblit v1.9.3