分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-03-26 874ceff175a7308da045943fb7def1f6c6560a51
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/JobsPart/Common/ÐÂÎļþ¼Ð/OutboundTask_a.cs
@@ -17,7 +17,7 @@
using static FreeSql.Internal.GlobalFilter;
using static System.Collections.Specialized.BitVector32;
namespace WIDESEA_WCS.JobsPart.Common.新文件夹
namespace WIDESEA_WCS.JobsPart.Common
{
    public class OutboundTask_a
    {
@@ -35,7 +35,7 @@
                Idt_inventoryRepository inventoryRepository = new dt_inventoryRepository(context);
                Idt_agvtaskRepository agvtaskRepository = new dt_agvtaskRepository(context);
                var mes_heads = mes_HeadRepository.Find(x => x.processCode == "28").OrderBy(x => x.expectedStartTime).ToList();
                var mes_heads = mes_HeadRepository.Find(x => x.processCode == "28").OrderByDescending(x => x.CreateTime).ToList();
                foreach (var mes_head in mes_heads)
                {
                    #region æ ¹æ®å·¥å•子表查找库存
@@ -48,9 +48,12 @@
                            var Station = stationinfoRepository.Find(x => x.stationCode == inventory.stationCode).FirstOrDefault();
                            if (Station != null)
                            {
                                var stationinfos = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.quantity > 0 && x.enable && x.location_state == LocationStateEnum.Stroge.ToString()).OrderByDescending(x => x.column).ToList();
                                foreach (var stationinfo in stationinfos)
                                var stationinfo = stationinfoRepository.Find(x => x.line == Station.line && x.area == Station.area && x.enable && x.quantity > 0).OrderByDescending(x => x.column).FirstOrDefault();
                                if (stationinfo != null)
                                {
                                    if (stationinfo.location_state == LocationStateEnum.OutBusy.ToString() || stationinfo.location_state != LocationStateEnum.Stroge.ToString()) continue;
                                    if (string.IsNullOrEmpty(stationinfo.bindSN))
                                    {
                                        stationinfo.remark = "车轮SN号信息异常";
@@ -68,75 +71,73 @@
                                    }
                                    #region è´§ä½è½¦è½®å…¨éƒ¨åŒ…含在工单内则下发任务
                                    bool OK = false;
                                    //bool OK = false;
                                    foreach (var SN in lists)
                                    {
                                        OK = mes_DetailRepository.Find(x => x.jobID == mes_head.jobID && x.SN == SN).Any();
                                    }
                                    if (OK)
                                    {
                                        dt_agvtask agvtask = new dt_agvtask()
                                        {
                                            agv_fromaddress = stationinfo.stationCode,
                                            agv_id = Guid.NewGuid(),
                                            agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                            agv_grade = 1,
                                            agv_createtime = DateTime.Now,
                                            agv_taskstate = "Queue",
                                            agv_materielid = stationinfo.stationType,
                                            agv_qty = stationinfo.quantity,
                                            agv_tasktype = "TaskType_Outbound",
                                            agv_toaddress = "",
                                            agv_userid = "系统",
                                            bindSN = stationinfo.bindSN,
                                            jobID = mes_head.jobID,
                                            agv_worktype = Convert.ToInt32(mes_head.processCode),
                                            agv_materbarcode = mes_head.materialCode,
                                            agv_Traytype = stationinfo.tray_type,
                                            agv_TrayStatus = stationinfo.tray_status
                                        };
                                        stationinfo.location_state = LocationStateEnum.OutBusy.ToString();
                                        stationinfoRepository.Update(stationinfo, true);
                                        agvtaskRepository.Add(agvtask, true);
                                        WriteDBLog.Success("创建出库任务", $"任务编号:{agvtask.agv_tasknum}", "PCS");
                                        continue;
                                    }
                                    #endregion
                                        if (!mes_DetailRepository.Find(x => x.jobID == mes_head.jobID && x.SN.Contains(SN)).Any()) return;
                                    #region è´§ä½è½¦è½®æœ‰ä¸€ä¸ªåŒ…含在工单内则下发任务
                                    //foreach (var SN in lists)
                                    //{
                                    //    if (mes_DetailRepository.Find(x => x.jobID == mes_head.jobID && x.SN == SN).Any())
                                    //    {
                                    //        dt_agvtask agvtask = new dt_agvtask()
                                    //        {
                                    //            agv_fromaddress = stationinfo.stationCode,
                                    //            agv_id = Guid.NewGuid(),
                                    //            agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                    //            agv_grade = 2,
                                    //            agv_createtime = DateTime.Now,
                                    //            agv_taskstate = "Queue",
                                    //            agv_materielid = stationinfo.stationType,
                                    //            agv_qty = stationinfo.quantity,
                                    //            agv_tasktype = "TaskType_Outbound",
                                    //            agv_toaddress = "",
                                    //            agv_userid = "系统",
                                    //            bindSN = stationinfo.bindSN,
                                    //            jobID = mes_head.jobID,
                                    //            agv_worktype = Convert.ToInt32(mes_head.processCode),
                                    //            agv_materbarcode = mes_head.materialCode,
                                    //            agv_Traytype = stationinfo.tray_type,
                                    //            agv_TrayStatus = stationinfo.tray_status
                                    //        };
                                    //        stationinfo.location_state = LocationStateEnum.OutBusy.ToString();
                                    //        stationinfoRepository.Update(stationinfo, true);
                                    //        agvtaskRepository.Add(agvtask, true);
                                    //        WriteDBLog.Success("创建出库任务", $"任务编号:{agvtask.agv_tasknum}", "PCS");
                                    //        continue;
                                    //    }
                                    //}
                                    }
                                    dt_agvtask agvtask = new dt_agvtask()
                                    {
                                        agv_fromaddress = stationinfo.stationCode,
                                        agv_id = Guid.NewGuid(),
                                        agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                        agv_grade = 1,
                                        agv_createtime = DateTime.Now,
                                        agv_taskstate = "Queue",
                                        agv_materielid = stationinfo.stationType,
                                        agv_qty = stationinfo.quantity,
                                        agv_tasktype = "TaskType_Outbound",
                                        agv_toaddress = "",
                                        agv_userid = "系统",
                                        bindSN = stationinfo.bindSN,
                                        jobID = mes_head.jobID,
                                        agv_worktype = Convert.ToInt32(mes_head.processCode),
                                        agv_materbarcode = mes_head.materialCode,
                                        agv_Traytype = stationinfo.tray_type,
                                        agv_TrayStatus = stationinfo.tray_status
                                    };
                                    stationinfo.location_state = LocationStateEnum.OutBusy.ToString();
                                    stationinfoRepository.Update(stationinfo, true);
                                    agvtaskRepository.Add(agvtask, true);
                                    WriteDBLog.Success("创建出库任务", $"任务编号:{agvtask.agv_tasknum}", "PCS");
                                    continue;
                                    #endregion
                                }
                                #region è´§ä½è½¦è½®æœ‰ä¸€ä¸ªåŒ…含在工单内则下发任务
                                //foreach (var SN in lists)
                                //{
                                //    if (mes_DetailRepository.Find(x => x.jobID == mes_head.jobID && x.SN == SN).Any())
                                //    {
                                //        dt_agvtask agvtask = new dt_agvtask()
                                //        {
                                //            agv_fromaddress = stationinfo.stationCode,
                                //            agv_id = Guid.NewGuid(),
                                //            agv_tasknum = IdenxManager.GetTaskNo("KH-", "WMS"),
                                //            agv_grade = 2,
                                //            agv_createtime = DateTime.Now,
                                //            agv_taskstate = "Queue",
                                //            agv_materielid = stationinfo.stationType,
                                //            agv_qty = stationinfo.quantity,
                                //            agv_tasktype = "TaskType_Outbound",
                                //            agv_toaddress = "",
                                //            agv_userid = "系统",
                                //            bindSN = stationinfo.bindSN,
                                //            jobID = mes_head.jobID,
                                //            agv_worktype = Convert.ToInt32(mes_head.processCode),
                                //            agv_materbarcode = mes_head.materialCode,
                                //            agv_Traytype = stationinfo.tray_type,
                                //            agv_TrayStatus = stationinfo.tray_status
                                //        };
                                //        stationinfo.location_state = LocationStateEnum.OutBusy.ToString();
                                //        stationinfoRepository.Update(stationinfo, true);
                                //        agvtaskRepository.Add(agvtask, true);
                                //        WriteDBLog.Success("创建出库任务", $"任务编号:{agvtask.agv_tasknum}", "PCS");
                                //        continue;
                                //    }
                                //}
                                #endregion
                            }
                        }
                    }