111
cjs
2025-06-24 12a30243255535e3f616aa858d2a9f1e51e4d123
ams/Hanhe.iWCS.JingmenGEMTwoProtocol/ProcessHelper.cs
@@ -9,6 +9,7 @@
using MongoDB.Driver.Builders;
using MySql.Data.MySqlClient;
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -303,8 +304,9 @@
                    if (mst.CN_S_BUSS_TYPE == "3楼缓存架入叠托") PLCControl.CacheStackingMouth1013(plc.deviceType, mst.CN_S_TASK_NO, mst.CN_S_END_BIT);
                    if (mst.CN_S_BUSS_TYPE == "3楼拆盘补空") PLCControl.DiscRemoverReqUnload(plc.deviceType, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "包装线补空") PLCControl.PackingLine(plc.ip, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "3楼打包下线") PLCControl.outWare(mst.CN_S_TASK_NO, true);
                    if (mst.CN_S_BUSS_TYPE == "3楼打包下线" || mst.CN_S_BUSS_TYPE == "PDA打包下线") PLCControl.outWare(mst.CN_S_TASK_NO, true);
                    if (mst.CN_S_BUSS_TYPE == "3楼成品出库") PLCControl.productOutWare(mst.CN_S_END_BIT, mst.CN_S_TASK_NO, true);
                    if (mst.CN_S_BUSS_TYPE == "烘干机空托上线" || mst.CN_S_BUSS_TYPE == "剪切机满托上线") PLCControl.DGMachineTwo(plc, mst.CN_S_TASK_NO, true);
                }
                if (code == 6)
                {
@@ -315,9 +317,10 @@
                    if (mst.CN_S_BUSS_TYPE == "3楼缓存架入叠托") PLCControl.writeStackingMouth6(mst.CN_S_END_BIT, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "3楼拆盘补空") PLCControl.DiscRemoverUnloadComplete(plc.deviceType, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "3楼打包下线") PLCControl.outWare(mst.CN_S_TASK_NO, false);
                    if (mst.CN_S_BUSS_TYPE == "3楼打包下线" || mst.CN_S_BUSS_TYPE == "PDA打包下线") PLCControl.outWare(mst.CN_S_TASK_NO, false);
                    if (mst.CN_S_BUSS_TYPE == "包装线补空") PLCControl.PackingLineComplete(plc.ip);
                    if (mst.CN_S_BUSS_TYPE == "3楼成品出库") PLCControl.productOutWare(mst.CN_S_END_BIT, mst.CN_S_TASK_NO, false);
                    if (mst.CN_S_BUSS_TYPE == "烘干机空托上线" || mst.CN_S_BUSS_TYPE == "剪切机满托上线") PLCControl.DGMachineTwo(plc, mst.CN_S_TASK_NO, true);
                }
            }
            else CMMLog.Info($"PlcInfo中未找到该点位,点位:{mst.CN_S_END_BIT}");
@@ -362,22 +365,25 @@
                if (code == 1012)
                {
                    //卸货申请,先判断设备是否允许进料,如果是直接改参数,并通知设备
                    if (mst.CN_S_BUSS_TYPE == "3楼包装取料") PLCControl.PickUpFullDoorUnload(plc.ip, mst.CN_S_TASK_NO);//进入3楼包装取料流程1012,ip:{plc.ip},task:{mst.CN_S_TASK_NO}
                    if (mst.CN_S_BUSS_TYPE == "3楼包装取料" || mst.CN_S_BUSS_TYPE == "PDA打包下线") PLCControl.PickUpFullDoorUnload(plc.ip, mst.CN_S_TASK_NO);//进入3楼包装取料流程1012,ip:{plc.ip},task:{mst.CN_S_TASK_NO}
                    if (mst.CN_S_BUSS_TYPE == "3楼复称入缓存架" || mst.CN_S_BUSS_TYPE == "3楼复称入缓存架NG") PLCControl.SecondWeightInCache1012(plc.ip, mst.CN_S_TASK_NO);//二期:直接改参数
                    if (mst.CN_S_BUSS_TYPE == "3楼缓存架入叠托") TSHelper.GoToAGV(mst.CN_S_TASK_NO, 10, 1);
                    if (mst.CN_S_BUSS_TYPE == "3楼叠盘下线") PLCControl.StackingReqUnload(plc.deviceType, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "3楼打包下线") PLCControl.PackingLineUnload1012(plc.ip, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "烘干机满托下线" || mst.CN_S_BUSS_TYPE == "剪切机空托下线" || mst.CN_S_BUSS_TYPE == "包装机满托下线") PLCControl.DGMachine(plc,mst.CN_S_TASK_NO,true);
                }
                if (code == 4)
                {
                    //卸货完成申请,判断设备那边进料完成,改参数通知agv离开
                    if (mst.CN_S_BUSS_TYPE == "3楼包装取料") PLCControl.PickUpFullDoorComplete(plc.ip, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "3楼包装取料" || mst.CN_S_BUSS_TYPE == "PDA打包下线") PLCControl.PickUpFullDoorComplete(plc.ip, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "3楼复称入缓存架" || mst.CN_S_BUSS_TYPE == "3楼复称入缓存架NG") PLCControl.SecondWeightInCache4(plc.deviceType, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "3楼叠盘下线") PLCControl.StackingComplete(plc.deviceType, mst.CN_S_TASK_NO);
                    if (mst.CN_S_BUSS_TYPE == "3楼打包下线") PLCControl.PackingLineComplete4(plc.ip, mst.CN_S_SOURCE_NO);
                    if (mst.CN_S_BUSS_TYPE != "3楼包装取料") WMSHelper.ExecuteState(mst.CN_S_SOURCE_NO, 4);
                    if (mst.CN_S_BUSS_TYPE == "3楼缓存架入叠托NG") PLCControl.CacheStackingMouth6(plc);
                    if (mst.CN_S_BUSS_TYPE == "辅材入库") PLCControl.fcrk(plc);
                    if (mst.CN_S_BUSS_TYPE == "烘干机满托下线" || mst.CN_S_BUSS_TYPE == "剪切机空托下线" || mst.CN_S_BUSS_TYPE == "包装机满托下线") PLCControl.DGMachine(plc, mst.CN_S_TASK_NO, false);
                }
            }
            else CMMLog.Info($"点位{mst.CN_S_START_BIT}未配置");
@@ -692,9 +698,10 @@
                if (plc.Count > 0)
                {
                    #region 判断输送线模式 变更注释
                    //bool action = true;
                    //foreach(var a in plc)
                    //{
                    //    bool action = false;
                    //    var modeResult = OITcpHelper.RegisterReadOutPut(new OITcpHelper.RegisterReadOutPutModel
                    //    {
                    //        dataNum = 1,
@@ -707,7 +714,6 @@
                    //        CMMLog.Debug($"OutWareTask:读取滚筒机{a.ip}通道号为:{a.readAddr + 3}的值为:{modeResult.result[0]}");
                    //        if (modeResult.result[0] == 2)
                    //        {
                    //            action = false;
                    //            CMMLog.Debug($"OutWareTask:输送线为 入库模式,输送线点位:{a.location}");
                    //            break;
                    //        }
@@ -719,24 +725,25 @@
                    //            {
                    //                if (modelInfo.Mode == "入库模式")
                    //                {
                    //                    action = false;
                    //                    CMMLog.Debug($"OutWareTask:中间表 ModeList为 入库模式");
                    //                    break;
                    //                }
                    //                else
                    //                {
                    //                    action = true;
                    //                }
                    //            }
                    //            else
                    //            {
                    //                action = false;
                    //                CMMLog.Debug("OutWareTask:中间表 ModeList 为空");
                    //                break;
                    //            }
                    //        }
                    //    }
                    //    if (!action)
                    //    {
                    //        return false;
                    //    }
                    //};
                    //if (!action)
                    //{
                    //    return false;
                    //}
                    #endregion
@@ -1316,5 +1323,64 @@
            return WeekNumInMonth;
        }
        internal static bool UpdateTaskState(string taskNo, int state)
        {
            var result = false;
            try
            {
                string taskState = state == 3 ? "开始取货" : state == 4 ? "取货完成" : state == 5 ? "开始卸货" : state == 6 ? "卸货完成" : state == 2 ? "完成" : "";
                CMMLog.Info($"SQLServer 更新任务状态:任务号:{taskNo},更改状态:{taskState}");
                if (!string.IsNullOrEmpty(taskState)) result = new SqlHelper<SQL_TN_I_TASK_MST>().ExecuteSql($"update dbo.tn_am_task_mst set CN_S_STATUS='{taskState}' where CN_S_TASK_NO='{taskNo}'");
            }
            catch (Exception ex)
            {
                CMMLog.Error($"SQLServer 更新任务状态异常:{ex.Message}");
            }
            return result;
        }
        /// <summary>
        /// SQL-AMS任务主表
        /// </summary>
        [SugarTable("dbo.tn_am_task_mst")]
        public class SQL_TN_I_TASK_MST
        {
            public string CN_S_BATCH_NO { get; set; }
            public int CN_S_ORDER_NO { get; set; }
            public string CN_S_TASK_NO { get; set; }
            public string CN_S_SOURCE_SYS { get; set; }
            public string CN_S_SOURCE_NO { get; set; }
            public string CN_S_PROCESS_CODE { get; set; }
            public string CN_S_TASK_TYPE { get; set; }
            public string CN_S_START_AREA { get; set; }
            public string CN_S_START_AREA_NAME { get; set; }
            public string CN_S_START_BIT { get; set; }
            public int CN_N_START_AGVBIT { get; set; }
            public string CN_S_END_AREA { get; set; }
            public string CN_S_END_AREA_NAME { get; set; }
            public string CN_S_END_BIT { get; set; }
            public int CN_N_END_AGVBIT { get; set; }
            public string CN_S_STATUS { get; set; }
            public string CN_S_BEF_STATUS { get; set; }
            public string CN_S_BEFORE_NO { get; set; }
            public string CN_S_AFTER_NO { get; set; }
            public string CN_T_START_WORKING { get; set; }
            public string CN_T_END_WORKING { get; set; }
            public int CN_N_PRIORITY { get; set; }
            public int CN_N_CUR_STEP { get; set; }
            public string CN_S_CREATOR { get; set; }
            public string CN_S_CREATOR_NAME { get; set; }
            public string CN_T_CREATE { get; set; }
            public string CN_S_MENDER { get; set; }
            public string CN_S_MODIFY_NAME { get; set; }
            public string CN_T_MODIFY { get; set; }
            public string CN_S_TASK_MODEL { get; set; }
            public string CN_S_EXT1 { get; set; }
            public string CN_S_EXT2 { get; set; }
            public string CN_S_EXT3 { get; set; }
            public string CN_N_AGV_NO { get; set; }
            public string CN_S_TRANSPORT_INFO { get; set; }
        }
    }
}