Browse Source

Merge branch 'master' of http://120.77.11.229:3000/ZTGT/PT-HJ-CP-WMS

林豪 左 2 weeks ago
parent
commit
5aec8b6f23

+ 5 - 1
wms.dto/request/cp/dto/WebPdaRequest.cs

@@ -22,7 +22,7 @@ namespace wms.dto.request.cp.dto
         public string ContGrpBarCode { get; set; }
 
         /// <summary>
-        ///  类型 1.间隔版  2.空铁托盘
+        ///  类型 1.间隔版  2.空铁托盘  4.砝码入库
         /// </summary>
         public string? Type { get; set; }
 
@@ -30,6 +30,10 @@ namespace wms.dto.request.cp.dto
         ///  是否强制入5号道
         /// </summary>
         public bool IsForcedIntoLane5 { get; set; } = false;
+        /// <summary>
+        /// 标准托盘重量
+        /// </summary>
+        public decimal Weight { get; set; }
     }
     public class TrayGroupOutRequest : BaseRequest
     {

+ 115 - 24
wms.service/Service/CPService.cs

@@ -1,6 +1,7 @@
 using AutoMapper;
 using Microsoft.Extensions.Logging;
 using Newtonsoft.Json;
+using NPOI.SS.Formula.Functions;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -872,7 +873,7 @@ namespace wms.service.Service
                             InvStateCode = InvState.InvEcecState_BuildUp.ToString(),
                             ExecStateCode = InvLockState.InvState_Normal.ToString(),
                             MatId = mater.Id,
-                            MatCode = mater.Code,
+                            MatCode = request.Type == "4" ? "FaMa" : mater.Code,
                             RFIDBarCode = request.ContGrpBarCode,
                             HWTypeCode = mater.SpoolType,
                             HWBarCode = request.ContGrpBarCode,
@@ -880,10 +881,10 @@ namespace wms.service.Service
                             MatName = mater.Name,
                             Size = 1,
                             ContGrpType = 2,
-                            TolWQty = 1    //存放托盘数量
+                            TolWQty = request.Type == "4" ? request.Weight : 1    //存放托盘数量
                         };
 
-                        if (request.IsForcedIntoLane5)
+                        if (request.IsForcedIntoLane5 || request.Type == "4")
                         {
                             nov.BatchNo = "10"; //空托盘组库尾入库库存中批号值等于十表示强制入五巷道
                         }
@@ -1315,7 +1316,7 @@ namespace wms.service.Service
                     }
                     else if (stock.ContGrpType == 2)
                     {
-                        BusType = CpTaskBusType.TaskBusType_CP_TrayStockIn.ToString();
+                        BusType = stock.MatCode == "FaMa" ? CpTaskBusType.TaskBusType_CP_WeightIn.ToString() : CpTaskBusType.TaskBusType_CP_TrayStockIn.ToString();
                     }
                     else if (stock.ContGrpType == 3)
                     {
@@ -1457,6 +1458,57 @@ namespace wms.service.Service
                     return result;
                 }
             }
+            else if (BusType == CpTaskBusType.TaskBusType_CP_WeightIn.ToString())
+            {
+                var task = new cpWCS_TaskInfo()
+                {
+                    Status = TaskStatus.NewBuild,
+                    Type = TaskType.EnterDepot,
+                    Priority = 0,
+                    Device = request.Equip,
+                    SrmStation = request.Equip,
+                    AddrFrom = request.Equip,
+                    BarCode = request.Code,
+                    AddWho = "wms",
+                    EditWho = "wms",
+                    WarehouseCode = ware.Code,
+                    AddrTo = "",
+                    Tunnel = "",
+                    MaterialCode = stock.MatCode,
+                    MatCode = stock.MatCode,
+                    BusType =  CpTaskBusType.TaskBusType_CP_WeightIn.GetDescription()
+                };
+
+                if (stock.BatchNo == "10") //空托盘组库尾入库库存中批号值等于十表示强制入五巷道
+                {
+                    task.Floor = 10; //空托盘组库尾入库任务中楼层值等于十表示强制入五巷道
+                }
+                try
+                {
+                    _db.BeginTran();
+                    var task1 = _wcstaskinfo.InsertReturnEntity(task);
+                    _wcstaskold.InsertableSplitTable(_mapper.Map<cpWCS_TaskOld>(task1));
+                    var wcsdetail = new cpWCS_TaskDtl()
+                    {
+                        ID = Guid.NewGuid(),
+                        CurPoint = request.Equip,
+                        AddTime = DateTime.Now,
+                        AddWho = "wms",
+                        Enabled = true,
+                        ParentTaskCode = task1.ID,
+                        Desc = task1.BusType
+                    };
+                    _wcstaskdtl.InsertableSplitTable(wcsdetail);
+                    _db.CommitTran();
+                }
+                catch (Exception ex)
+                {
+                    _db.RollbackTran();
+                    result.ResCode = ResponseStatusCodeEnum.DataSaveErr.GetHashCode();
+                    result.ResMsg = request.Code + ResponseStatusCodeEnum.DataSaveErr.GetDescription() + ex.Message;
+                    return result;
+                }
+            }
             return result;
         }
 
@@ -2336,6 +2388,11 @@ namespace wms.service.Service
                 //更新库存
                 _billnowrepository.UpdateModelColumns(p => new cpBillInvnow() { PutRow = 0, PutCol = 0, PutLayer = 0 }, p => p.InvStateCode == InvState.InvEcecState_OutGoing.ToString() && p.ContGrpBarCode == wcstask.BarCode);
                 var stocklist = _billnowrepository.GetList(p => p.ContGrpBarCode == wcstask.BarCode && p.InvStateCode == InvState.InvEcecState_OutGoing.ToString());
+                if (wcstask.BusType == CpTaskBusType.TaskBusType_CP_WeightOut.GetDescription())
+                {
+                    //更新库存
+                    _billnowrepository.UpdateModelColumns(p => new cpBillInvnow() { InvStateCode = InvState.InvEcecState_BuildUp.ToString()}, p => p.InvStateCode == InvState.InvEcecState_OutGoing.ToString() && p.ContGrpBarCode == wcstask.BarCode);
+                }
                 if (stocklist == null || !stocklist.Any())
                 {
                     result.ResCode = ResponseStatusCodeEnum.StockNotExist.GetHashCode();
@@ -5426,39 +5483,73 @@ namespace wms.service.Service
             var sysconfig = _sysconfigrepository.GetFirst(p => p.Code == "AutomaticCalibration");
             var config = _sysconfigrepository.GetFirst(p => p.Code == "AutomaticCalibration").SContent;
 
+            var isContinue = false;
             if (sysconfig != null && !string.IsNullOrEmpty(sysconfig.Default3))
             {
-                hour = Convert.ToInt16(sysconfig.Default3);
-            }
+                if (sysconfig.Default3.Contains(","))
+                {
+                    var nums = sysconfig.Default3.Split(",");
+                    for (int i = 0; i < nums.Length; i++)
+                    {
+                        hour = Convert.ToInt16(nums[i]);
+                        if (!ShouldTriggerScaleTask(config, hour))
+                        {
+                            continue;
+                        }
 
-            if (!ShouldTriggerScaleTask(config, hour))
-            {
-                result.ResCode = ResponseStatusCodeEnum.EquipInfoNotExist.GetHashCode();
-                result.ResMsg = "不在可执行范围内";
-                return result;
+                        //检查今天早上十点-十点五十九之间是否执行过
+                        DateTime now1 = DateTime.Now;
+                        // 当天 10:00 开始
+                        DateTime startTime1 = new DateTime(now1.Year, now1.Month, now1.Day, hour, 0, 0);
+                        // 当天 10:59 结束
+                        DateTime endTime1 = new DateTime(now1.Year, now1.Month, now1.Day, hour, 59, 59);
+                        if (_wcstaskold.AsQueryable().Where(p => p.AddTime >= startTime1 && p.AddTime < endTime1 && p.BusType.Contains("砝码")).SplitTable(p => p.Take(2)).Any())
+                        {
+                            continue;
+                        }
+                        isContinue = true;
+                        break;
+                    }
+                }
+                else
+                {
+                    hour = Convert.ToInt16(sysconfig.Default3);
+                    if (!ShouldTriggerScaleTask(config, hour))
+                    {
+                        result.ResCode = ResponseStatusCodeEnum.EquipInfoNotExist.GetHashCode();
+                        result.ResMsg = "不在可执行范围内";
+                        return result;
+                    }
+                    //检查今天早上十点-十点五十九之间是否执行过
+                    DateTime now = DateTime.Now;
+                    // 当天 10:00 开始
+                    DateTime startTime = new DateTime(now.Year, now.Month, now.Day, hour, 0, 0);
+                    // 当天 10:59 结束
+                    DateTime endTime = new DateTime(now.Year, now.Month, now.Day, hour, 59, 59);
+                    if (_wcstaskold.AsQueryable().Where(p => p.AddTime >= startTime && p.AddTime < endTime && p.BusType.Contains("砝码")).SplitTable(p => p.Take(2)).Any())
+                    {
+                        result.ResCode = ResponseStatusCodeEnum.EquipInfoNotExist.GetHashCode();
+                        result.ResMsg = "本周期内已执行过";
+                        return result;
+                    }
+                    isContinue = true;
+                }               
             }
-
-
-            //检查今天早上十点-十点五十九之间是否执行过
-            DateTime now = DateTime.Now;
-            // 当天 10:00 开始
-            DateTime startTime = new DateTime(now.Year, now.Month, now.Day, hour, 0, 0);
-            // 当天 10:59 结束
-            DateTime endTime = new DateTime(now.Year, now.Month, now.Day, hour, 59, 59);
-            if (_wcstaskinfo.IsAny(p => p.AddTime > startTime && p.AddTime < endTime && p.BusType == CpTaskBusType.TaskBusType_CP_WeightOut.GetDescription()))
+                       
+            if (_wcstaskinfo.IsAny(p => p.AddrTo == deviceId && p.Status == TaskStatus.NewBuild))
             {
                 result.ResCode = ResponseStatusCodeEnum.EquipInfoNotExist.GetHashCode();
-                result.ResMsg = "本周期内已执行过";
+                result.ResMsg = deviceId + "存在未执行任务,请勿重复申请";
                 return result;
             }
 
-            if (_wcstaskinfo.IsAny(p => p.AddrTo == deviceId && p.Status == TaskStatus.NewBuild))
+
+            if (!isContinue)
             {
                 result.ResCode = ResponseStatusCodeEnum.EquipInfoNotExist.GetHashCode();
-                result.ResMsg = deviceId + "存在未执行任务,请勿重复申请";
+                result.ResMsg = "不满足出库条件";
                 return result;
             }
-
             var locationlist = from loc in _baseWarecellrepository.GetList(p => p.IsStop == 0 && p.StateNum == LocationState.LocationState_Full.GetHashCode())
                                join stock in _billnowrepository.GetList(p => p.InvStateCode == InvState.InvEcecState_In.ToString() && p.ExecStateCode == InvLockState.InvState_Normal.ToString())
                                on loc.ContGrpBarCode equals stock.ContGrpBarCode

+ 20 - 0
wms.service/Service/PTService.cs

@@ -2512,6 +2512,26 @@ namespace wms.service.Service
 
             //考虑根据物料的分布情况
 
+
+            //获取不可用堆垛机所在巷道
+            var equlist = HttpUtil.GetRequest("http://10.30.35.1:8080/api/Wcs/GetAvaiableStations?name=Station");
+            var srmtunlist = JsonConvert.DeserializeObject<List<string>>(equlist);
+            var tunlist = srmtunlist.Select(p => p).ToList();
+            if (tunlist != null)
+            {
+                var resultTunenlsNew = new List<string>();
+                var resultTunenlsTemp = result.ResData.Split(',');
+                foreach (var tun in resultTunenlsTemp)
+                {
+                    if (!tunlist.Select(p => p).Contains(tun))
+                    {
+                        resultTunenlsNew.Add(tun);
+                    }
+                }
+                result.ResData = string.Join(",", resultTunenlsNew);
+            }
+
+
             //根据配置过滤禁用的巷道
             var disabletunnels = _sysconfigrepository.GetList(p => p.SType == "InStop" && !string.IsNullOrEmpty(p.SContent));
             if (disabletunnels != null && disabletunnels.Any())