莫海杰 před 2 měsíci
rodič
revize
fc12fed11a

+ 17 - 0
SCADA_DAQ/Customer/Models/MoveInventoryVo.cs

@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SCADA_DAQ.Customer.Models
+{
+    public class MoveInventoryVo
+    { 
+        public string FromWarehouseCode { get; set; }
+        public decimal FormQty { get; set; }
+        public decimal MoveQty { get; set; }
+        public string ToWarehouseCode { get; set; }
+        public string ItemCode { get; set; }
+    }
+}

+ 48 - 7
SCADA_DAQ/Customer/Service/Wcs_WebInventoryService.cs

@@ -34,15 +34,15 @@ namespace SCADA_DAQ.Customer.Service
         public RpcResponse<object> AddEditInventoryTableRow(int action, AppBCInventoryVo row)
         {
             var res = new RpcResponse<object>();
-            var list = Env.DAL.App_BC_Inventory.GetData<App_BC_Inventory>(t => t.WarehouseCode_Str == row.WarehouseCode && t.ItemCode_Str == row.ItemCode);
-            if (list != null && list.Count > 0)
-            {
-                res.IsSucceed = false;
-                res.Message = $"已存在 仓库{row.WarehouseCode}物料号{row.ItemCode}, 修改货架号即可";
-                return res;
-            }
             if (action == 1)
             {
+                var list = Env.DAL.App_BC_Inventory.GetData<App_BC_Inventory>(t => t.WarehouseCode_Str == row.WarehouseCode && t.ItemCode_Str == row.ItemCode);
+                if (list != null && list.Count > 0)
+                {
+                    res.IsSucceed = false;
+                    res.Message = $"已存在 仓库{row.WarehouseCode}物料号{row.ItemCode}, 修改货架号即可";
+                    return res;
+                }
                 var ok = Env.DAL.App_BC_Inventory.Insert(
                     new UpdateItem(T_Col_Name.App_BC_Inventory.ItemName_Str, row.ItemName),
                     new UpdateItem(T_Col_Name.App_BC_Inventory.ItemCode_Str, row.ItemCode),
@@ -99,6 +99,47 @@ namespace SCADA_DAQ.Customer.Service
             return res;
         }
 
+        public RpcResponse<object> MoveInventory(MoveInventoryVo moveInventory)
+        {
+            var res = new RpcResponse<object>();
+            var toInventoryList = Env.DAL.App_BC_Inventory.GetData<AppBCInventoryModel>(t => t.ItemCode == moveInventory.ItemCode && t.WarehouseCode == moveInventory.ToWarehouseCode);
+            List<AppBCInventoryModel> inventoryList;
+            if (toInventoryList != null && toInventoryList.Count == 0)
+            {
+                res.IsSucceed = false;
+                res.Message = $"不存在仓库{moveInventory.ToWarehouseCode} 物料号{moveInventory.ItemCode}, 请添加";
+                return res;
+            }
+            else
+            {
+                inventoryList = new List<AppBCInventoryModel>()
+                {
+                    new AppBCInventoryModel
+                    {
+                        ItemCode = moveInventory.ItemCode,
+                        WarehouseCode = moveInventory.FromWarehouseCode,
+                        Qty = moveInventory.FormQty - moveInventory.MoveQty,
+                    },
+                    new AppBCInventoryModel{
+                        ItemCode = moveInventory.ItemCode,
+                        WarehouseCode = moveInventory.ToWarehouseCode,
+                        Qty = toInventoryList[0].Qty + moveInventory.MoveQty,
+                    }
+                };
+            }
+            var dbres = Env.DAL.BatchUpdateOrInsert(
+              inventoryList,
+              t => new { t.ItemCode, t.WarehouseCode },   //更新条件
+              null,
+              t => new { t.Qty }   //更新字段
+            );   //批量更新
+            if (dbres == true)
+            {
+                res.Message = "移动成功";
+            }
+            return res;
+        }
+
         // 获取二维图
         //public RpcResponse<object> GetInventoryView(int row)
         //{

+ 37 - 22
SCADA_DAQ/Customer/Service/Wcs_WebOperationService.cs

@@ -41,29 +41,44 @@ namespace SCADA_DAQ.Customer.Service
                 res.Message = "3号线未清除任务,加入失败";
                 return res;
             }
-            if (CustomerEnv.OperationCrane1List.Any(i => i.StartLayer == operation.StartLayer && i.StartCol == operation.StartCol && i.StartRow == operation.StartRow))
+            if (operation.MachineTaskId == 5 || operation.MachineTaskId == 3)
             {
-                res.IsSucceed = false;
-                res.Message = "任务重复添加,加入失败";
-                return res;
-            }
-            if (CustomerEnv.OperationCrane2List.Any(i => i.StartLayer == operation.StartLayer && i.StartCol == operation.StartCol && i.StartRow == operation.StartRow))
-            {
-                res.IsSucceed = false;
-                res.Message = "任务重复添加,加入失败";
-                return res;
-            }
-            if ((CustomerEnv.CurrentOperationLine1 != null) && (CustomerEnv.CurrentOperationLine1.StartRow == operation.StartRow) && (CustomerEnv.CurrentOperationLine1.StartCol == operation.StartCol) && (CustomerEnv.CurrentOperationLine1.StartLayer == operation.StartLayer))
-            {
-                res.IsSucceed = false;
-                res.Message = "任务重复添加,加入失败";
-                return res;
-            }
-            if ((CustomerEnv.CurrentOperationLine2 != null) && (CustomerEnv.CurrentOperationLine2.StartRow == operation.StartRow) && (CustomerEnv.CurrentOperationLine2.StartCol == operation.StartCol) && (CustomerEnv.CurrentOperationLine2.StartLayer == operation.StartLayer))
-            {
-                res.IsSucceed = false;
-                res.Message = "任务重复添加,加入失败";
-                return res;
+                if (CustomerEnv.OperationCrane1List.Any(i => i.StartLayer == operation.StartLayer && i.StartCol == operation.StartCol && i.StartRow == operation.StartRow))
+                {
+                    res.IsSucceed = false;
+                    res.Message = "堆垛机1任务列表存在重复任务,加入失败";
+                    return res;
+                }
+                if (CustomerEnv.OperationCrane2List.Any(i => i.StartLayer == operation.StartLayer && i.StartCol == operation.StartCol && i.StartRow == operation.StartRow))
+                {
+                    res.IsSucceed = false;
+                    res.Message = "堆垛机2任务列表存在重复任务,加入失败";
+                    return res;
+                }
+                if ((CustomerEnv.CurrentOperationLine1 != null) && (CustomerEnv.CurrentOperationLine1.StartRow == operation.StartRow) && (CustomerEnv.CurrentOperationLine1.StartCol == operation.StartCol) && (CustomerEnv.CurrentOperationLine1.StartLayer == operation.StartLayer))
+                {
+                    res.IsSucceed = false;
+                    res.Message = "与当前输送线1任务重复,加入失败";
+                    return res;
+                }
+                if ((CustomerEnv.CurrentOperationLine2 != null) && (CustomerEnv.CurrentOperationLine2.StartRow == operation.StartRow) && (CustomerEnv.CurrentOperationLine2.StartCol == operation.StartCol) && (CustomerEnv.CurrentOperationLine2.StartLayer == operation.StartLayer))
+                {
+                    res.IsSucceed = false;
+                    res.Message = "与当前输送线2任务重复,加入失败";
+                    return res;
+                }
+                if ((CustomerEnv.CurrentOperationLine3 != null) && (CustomerEnv.CurrentOperationLine3.StartRow == operation.StartRow) && (CustomerEnv.CurrentOperationLine3.StartCol == operation.StartCol) && (CustomerEnv.CurrentOperationLine3.StartLayer == operation.StartLayer))
+                {
+                    res.IsSucceed = false;
+                    res.Message = "与当前输送线3任务重复,加入失败";
+                    return res;
+                }
+                if ((CustomerEnv.CurrentOperationLine4 != null) && (CustomerEnv.CurrentOperationLine4.StartRow == operation.StartRow) && (CustomerEnv.CurrentOperationLine4.StartCol == operation.StartCol) && (CustomerEnv.CurrentOperationLine4.StartLayer == operation.StartLayer))
+                {
+                    res.IsSucceed = false;
+                    res.Message = "与当前输送线4任务重复,加入失败";
+                    return res;
+                }
             }
             if (operation.Crane == 1)
             {

+ 6 - 2
SCADA_DAQ/Customer/Service/Wcs_WmsService.cs

@@ -543,14 +543,18 @@ namespace SCADA_DAQ.Customer.Service
             var operationCrane2List = sourceLocationList.Where(i => i.Crane == 2).ToList();
             operationCrane1List.ForEach(t =>
             {
-                if (!CustomerEnv.OperationCrane1List.Any(i => i.StartLayer == t.StartLayer && i.StartCol == t.StartCol && i.StartRow == t.StartRow))
+                var hasLine1Task = CustomerEnv.CurrentOperationLine1 != null && t.StartRow == CustomerEnv.CurrentOperationLine1.StartRow && t.StartCol == CustomerEnv.CurrentOperationLine1.StartCol && t.StartLayer == CustomerEnv.CurrentOperationLine1.StartLayer;
+                var hasLine2Task = CustomerEnv.CurrentOperationLine2 != null && t.StartRow == CustomerEnv.CurrentOperationLine2.StartRow && t.StartCol == CustomerEnv.CurrentOperationLine2.StartCol && t.StartLayer == CustomerEnv.CurrentOperationLine2.StartLayer;
+                if (!CustomerEnv.OperationCrane1List.Any(i => i.StartLayer == t.StartLayer && i.StartCol == t.StartCol && i.StartRow == t.StartRow) && !hasLine1Task && !hasLine2Task)
                 {
                     CustomerEnv.OperationCrane1List.Add(t);
                 }
             });
             operationCrane2List.ForEach(t =>
             {
-                if (!CustomerEnv.OperationCrane2List.Any(i => i.StartLayer == t.StartLayer && i.StartCol == t.StartCol && i.StartRow == t.StartRow))
+                var hasLine3Task = CustomerEnv.CurrentOperationLine3 != null && t.StartRow == CustomerEnv.CurrentOperationLine3.StartRow && t.StartCol == CustomerEnv.CurrentOperationLine3.StartCol && t.StartLayer == CustomerEnv.CurrentOperationLine3.StartLayer;
+                var hasLine4Task = CustomerEnv.CurrentOperationLine4 != null && t.StartRow == CustomerEnv.CurrentOperationLine4.StartRow && t.StartCol == CustomerEnv.CurrentOperationLine4.StartCol && t.StartLayer == CustomerEnv.CurrentOperationLine4.StartLayer;
+                if (!CustomerEnv.OperationCrane2List.Any(i => i.StartLayer == t.StartLayer && i.StartCol == t.StartCol && i.StartRow == t.StartRow) && !hasLine3Task && !hasLine4Task)
                 {
                     CustomerEnv.OperationCrane2List.Add(t);
                 }