分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-05-25 a1c916e4b05662b45d437c02db4effd40abe6296
´úÂë¹ÜÀí/WMS/WMS_Server/WIDESEA_WMS/Common/AGVTask/HandleTask.cs
@@ -11,6 +11,7 @@
using WIDESEA_Entity.DomainModels;
using WIDESEA_WMS.IRepositories;
using WIDESEA_WMS.Repositories;
using static FreeSql.Internal.GlobalFilter;
namespace WIDESEA_WMS.Common
{
@@ -66,11 +67,18 @@
        /// <param name="task"></param>
        public static void Updateinventory(dt_agvtask task)
        {
            //string[] bindSNs = task.bindSN.Split(",");
            //int count = 0;
            //if (bindSNs.Length > 0)
            //{
            if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_Outbound.ToString() || task.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceCarry.ToString())
            VOLContext context = new VOLContext();
            Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context);
            if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_Carry.ToString())
            {
                var inventorys = inventoryRepository.Find(x => x.stationCode == task.agv_fromaddress).ToList();
                foreach (var inventory in inventorys)
                {
                    inventory.stationCode = task.agv_toaddress;
                    inventoryRepository.Update(inventory, true);
                }
            }
            else if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_Outbound.ToString() || task.agv_tasktype == AGVTaskTypeEnum.TaskType_OutsourceCarry.ToString())
            {
                string[] bindSNs = task.bindSN.Split(",");
                int count = 0;
@@ -83,7 +91,6 @@
                    if (count < 1)
                        throw new Exception("库存清除失败!SN号:" + bindSN);
                }
            }
            else if (task.agv_tasktype == AGVTaskTypeEnum.TaskType_Inbound.ToString())
            {
@@ -92,26 +99,25 @@
                List<dt_inventory> inventorys = new List<dt_inventory>();
                foreach (string bindSN in bindSNs)
                {
                    var mes_detail = freeDB.Select<dt_mes_detail>().Where(x => x.SN == bindSN).First();
                    if (mes_detail == null)
                        throw new Exception("未找到工单信息!");
                    var mes_head = freeDB.Select<dt_mes_head>().Where(x => x.jobID == mes_detail.jobID).First();
                    if (mes_head == null)
                    var mes_Work = freeDB.Select<VV_Mes_Workinfo>().Where(x => x.SN == bindSN && x.processCode == "17").First();
                    if (mes_Work == null)
                        throw new Exception("未找到工单信息!");
                    var station = freeDB.Select<dt_stationinfo>().Where(x => x.stationCode == task.agv_toaddress).First();
                    dt_inventory inventory = new dt_inventory()
                    {
                        SN = bindSN,
                        Name = mes_head.productName,
                        FigureNumber = mes_head.drawingNo,
                        Name = mes_Work.productName,
                        FigureNumber = mes_Work.drawingNo,
                        materialCode = task.agv_materbarcode,
                        HeatNumber = mes_detail.heatID,
                        BilletNumber = mes_detail.billetID,
                        HeatNumber = mes_Work.heatID,
                        drawingNoVer = mes_Work.drawingNoVer,
                        BilletNumber = mes_Work.billetID,
                        OnlineTime = task.agv_finishedtime,
                        Operator = "admin",
                        stationCode = task.agv_toaddress,
                        area = station.area,
                        jobID = mes_detail.jobID,
                        jobID = mes_Work.jobID,
                        workOrder = mes_Work.workOrder,
                        ID = Guid.NewGuid()
                    };
                    inventorys.Add(inventory);
@@ -158,15 +164,15 @@
        {
            VOLContext context = new VOLContext();
            Idt_stationinfoRepository stationinfoRepository = new dt_stationinfoRepository(context);
            var station1 = stationinfoRepository.FindFirst(t => t.stationCode == task.agv_fromaddress);
            var station2 = stationinfoRepository.FindFirst(t => t.stationCode == task.agv_toaddress);
            if (task.agv_taskstate == AGVTaskStateEnum.Complete1.ToString())
            {
                var station2 = stationinfoRepository.FindFirst(t => t.stationCode == task.agv_toaddress);
                if (station2 == null) throw new Exception("未找到终点地址!");
                ////空托任务需修改逻辑
                if (station2.stationCode.Contains("X"))
                    station2.quantity = 0;// task.agv_tasktype.Contains("TaskType_EmptyPallet") ? 0 : task.agv_qty; //task.agv_qty;
                else if (station2.area == "10" || station2.area == "11") //入库空托任务
                else if (station2.area == "10" || station2.area == "11" || (station2.stationCode.Contains("C") && task.agv_tasktype == "TaskType_EmptyPallet") || station2.stationCode.Contains("DD")) //入库空托任务
                    station2.quantity = station2.quantity + task.agv_qty;
                else
                    station2.quantity = task.agv_qty;
@@ -177,10 +183,13 @@
                station2.stationType = task.agv_materielid;
                station2.tray_status = task.agv_TrayStatus;//横放/竖放
                station2.tray_type = task.agv_Traytype;
                station2.lastUpdateTime = DateTime.Now;
                stationinfoRepository.Update(station2, true);
            }
            else if (task.agv_taskstate == AGVTaskStateEnum.Complete.ToString())
            {
                var station1 = stationinfoRepository.FindFirst(t => t.stationCode == task.agv_fromaddress);
                if (station1 == null) throw new Exception("未找到起点地址!");
                #region MyRegion
                //if (station1.stationCode.Contains("S"))
                //    station1.quantity = 0;
@@ -192,8 +201,12 @@
                //else
                //    station1.quantity = 0;
                #endregion
                if (station1.area == "10" || station1.area == "11") //出库空托任务
                if (station1.stationCode.Contains("DD"))//叠盘库位
                {
                    station1.quantity = station1.quantity - task.agv_qty;
                    station1.location_state = LocationStateEnum.Stroge.ToString();
                }
                else if (station1.area == "10" || station1.area == "11" || (station1.stationCode.Contains("C") && task.agv_tasktype == "TaskType_EmptyPallet")) //出库空托任务
                {
                    station1.location_state = LocationStateEnum.Stroge.ToString();
                    station1.quantity = station1.quantity - 1;
@@ -206,13 +219,16 @@
                {
                    station1.location_state = LocationStateEnum.Empty.ToString();
                    station1.Number = string.Empty;
                    station1.billetID = string.Empty;
                    station1.heatNumber = string.Empty;
                    station1.stationType = string.Empty;
                    station1.tray_status = string.Empty;
                    station1.remark = string.Empty;
                    if (!station1.stationCode.Contains("X") && !station1.stationCode.Contains("S") && !station1.stationCode.Contains("W01001004") && !station1.stationCode.Contains("W01001005"))
                        station1.tray_type = string.Empty;
                    //if (!station1.stationCode.Contains("X") && !station1.stationCode.Contains("S") && !station1.stationCode.Contains("W01001004") && !station1.stationCode.Contains("W01001005"))
                    //    station1.tray_type = string.Empty;
                }
                if (!station1.stationCode.Contains("DD"))
                    station1.lastUpdateTime = DateTime.Now;
                stationinfoRepository.Update(station1, true);
            }
        }