分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-03-06 5662395113163ac87425f23aa0bff8853be92462
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/StationTask.cs
@@ -10,6 +10,7 @@
using WIDESEA_Entity.DomainModels;
using WIDESEA_Comm;
using static System.Collections.Specialized.BitVector32;
using WIDESEA_Comm.TaskNo;
namespace WIDESEA_WCS.JobsPart.Common
{
@@ -17,7 +18,12 @@
    {
        static FreeDB freeDB = new FreeDB();
        /// <summary>
        /// åˆ›å»ºå…¥åº“任务
        /// </summary>
        public static void CreateTask()
        {
            try
        {
            VOLContext context = new VOLContext();
            Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
@@ -44,20 +50,33 @@
                    if (mesinfo.quantity <= 50 || item.stationCode.Contains("3"))    //小于50件直接出库
                    {
                        //var station =
                            dt_stationinfo TargetLocation = GetEmptyLocation(stationinfoRepository);
                        //todo å¯»æ‰¾å¯æ”¾è´§å¤–协放货台
                            if (TargetLocation != null)
                            {
                        dt_agvtask agvtask = new dt_agvtask()
                        {
                            agv_fromaddress = item.stationCode,
                            agv_id = Guid.NewGuid(),
                            agv_grade = 0,
                            agv_barcode = "",
                                    agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                    agv_grade = 1,
                            agv_createtime = DateTime.Now,
                            agv_taskstate = TaskStatus.Created.ToString(),
                            //agv_toaddress = ,
                                    agv_taskstate = "Create",
                                    agv_materielid = item.stationType,
                                    agv_qty = item.quantity,
                                    agv_tasktype = "TaskType_OutsourceInbound",
                                    agv_toaddress = TargetLocation.stationCode,
                                    agv_userid = "系统",
                                    bindSN = item.bindSN,
                                    agv_worktype = Convert.ToInt32(mesinfo.processCode),
                                    agv_materbarcode = mesinfo.materialCode,
                                    agv_barcode=item.tray_type
                        };
                        freeDB.Add(agvtask);
                                TargetLocation.location_state = LocationStateEnum.Busy.ToString();
                                freeDB.Update(TargetLocation);
                            }
                    }
                    else
                    {
@@ -70,11 +89,19 @@
                            {
                                agv_fromaddress = item.stationCode,
                                agv_id = Guid.NewGuid(),
                                agv_grade = 0,
                                agv_barcode = "",
                                    agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                    agv_grade = 1,
                                agv_createtime = DateTime.Now,
                                agv_taskstate = TaskStatus.Created.ToString(),
                                    agv_taskstate = "Create",
                                    agv_materielid = item.stationType,
                                    agv_qty = item.quantity,
                                    agv_tasktype = "TaskType_Inbound",
                                agv_toaddress = TargetLocation.stationCode,
                                    agv_userid = "系统",
                                    bindSN = item.bindSN,
                                    agv_worktype = Convert.ToInt32(mesinfo.processCode),
                                    agv_materbarcode = mesinfo.materialCode,
                                    agv_barcode=item.tray_type
                            };
                            freeDB.Add(agvtask);
@@ -84,6 +111,12 @@
                    }
                }
            }
            }
            catch (Exception ex)
            {
            }
        }
        /// <summary>
@@ -248,6 +281,22 @@
            return TargetLocation;
        }
        private static dt_stationinfo GetEmptyLocation(Idt_stationinfoRepository stationinfoRepository)
        {
            dt_stationinfo TargetLocation = null;
            List<string> target = new List<string>() { "W01001001", "W01001002", "W01001003" };
            foreach (var item in target)
            {
                TargetLocation = stationinfoRepository.FindFirst(x => x.stationCode == item && x.location_state == LocationStateEnum.Empty.ToString() && x.enable);
                if (TargetLocation != null) continue;
            }
            if (TargetLocation == null)
            {
                throw new Exception("外协入库口已满");
            }
            return TargetLocation;
        }
        /// <summary>
        /// æ ¹æ®è®¢å•数量返回库区(暂时弃用)   //更换为库位类型匹配
        /// </summary>