瀏覽代碼

节拍优化、增加自动清理日志、设置面板修改、增加校验接口

WIN-GH9CEESPLTB\Administrator 1 月之前
父節點
當前提交
638449e98e

+ 6 - 0
MainForm/ClassFile/ProjectClass/GlobalContext.cs

@@ -44,6 +44,7 @@ namespace MainForm
         public static string MqttFileBackupLogDir = MqttLogDir + @"文件上传\文件备份";    // mqtt日志 - 文件上传日志
         public static string MqttFileTempDir = MqttLogDir + @"文件上传\临时文件";    // mqtt日志 - 文件上传日志
         public static string MqttDeviceConfigLogDir = MqttLogDir + @"装备配置\";    // mqtt日志 - 装备配置日志
+        public static string MqttClearFileDir = MqttLogDir + @"清理日志\";  // mqtt日志 - 设备状态日志
 
         public static string MqttServerPath = AppDomain.CurrentDomain.BaseDirectory + @"\ThingsMode\MqttServer.exe";
         public static string MqttServerName = "MqttServer";
@@ -136,6 +137,8 @@ namespace MainForm
         public static string AtlasAddressLeft;
         public static string AtlasAddressRight;
         public static int AtlasAddressPort;
+        public static bool IsClearLog;
+        public static int ClearLogDays;
 
         // TCP
         public static string QrCodeTCPAddress1;
@@ -381,6 +384,9 @@ namespace MainForm
                 AtlasAddressRight = IniFile.INIGetStringValue(FilePath, "Machine", "AtlasAddressRight", "");
                 AtlasAddressPort = int.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "AtlasAddressPort", ""));
 
+                IsClearLog = bool.Parse(IniFile.INIGetStringValue(FilePath, "System", "IsClearLog", ""));
+                ClearLogDays = int.Parse(IniFile.INIGetStringValue(FilePath, "System", "ClearLogDays", ""));
+
                 QrCodeTCPAddress1 = IniFile.INIGetStringValue(FilePath, "TCP", "TCPAddress1", "127.0.0.1");
                 QrCodeTCPPort1 = int.Parse(IniFile.INIGetStringValue(FilePath, "TCP", "TCPPort1", "0"));
                 QrCodeTCPAddress2 = IniFile.INIGetStringValue(FilePath, "TCP", "TCPAddress2", "127.0.0.1");

+ 168 - 0
MainForm/ClassFile/XiaomiAPI_MES/XiaomiMESHttp_ConfirmInfoVerify.cs

@@ -0,0 +1,168 @@
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Policy;
+using System.Text;
+
+namespace MainForm.ClassFile.XiaomiAPI_MES
+{
+    /// <summary>
+    /// 小米MES - 进站接⼝
+    /// 接口地址:
+    /// 接口方法:UnitConfirmDataSetIn
+    /// </summary>
+    public class XiaomiMESHttp_ConfirmInfoVerify : XiaomiMESHttp_X5
+    {
+        #region 变量
+        /// <summary>
+        /// 接口地址
+        /// </summary>
+        protected new static string MESUrl { set; get; } = GlobalContext.StationInMESUrl;
+
+        /// <summary>
+        /// 接口方法
+        /// </summary>
+        protected new static string Method { set; get; } = "UnitConfirmInfoVerify";
+        #endregion 变量
+
+        /// <summary>
+        /// 小米MES - 校验接口
+        /// </summary>
+        /// <param name="requestBody"></param>
+        /// <returns></returns>
+        public static XmMES_ConfirmInfoVerifyResponse ConfirmInfoVerifyPostMES(XmMES_ConfirmInfoVerifyRequest_Body body)
+        {
+            XmMES_ConfirmInfoVerifyResponse ConfirmInfoVerifyResponse = new XmMES_ConfirmInfoVerifyResponse();
+
+            string bodyJson = JsonConvert.SerializeObject(body);
+            XiaomiMES_X5RequestHeader header = new XiaomiMES_X5RequestHeader();
+            header.appid = Appid;                               // 系统分配的应⽤ID
+            header.method = Method;                             // API接⼝名称
+            header.sign = GetSign_Up(Appid, bodyJson, Appkey);  // md5签名
+            header.url = MESUrl;                                // 接⼝地址
+
+            //转base64
+            dynamic requestData = new { header = header, body = bodyJson };
+            var serializedBody = JsonConvert.SerializeObject(requestData);
+            var base64EncodedBody = Convert.ToBase64String(Encoding.UTF8.GetBytes(serializedBody));
+            XiaomiMES_X5Response response = Post(MESUrl, base64EncodedBody);
+            // ZS保存日志
+            ConfirmInfoVerifyResponse.header = response.header;
+            string responseBody = response.body;
+            ConfirmInfoVerifyResponse.body = JsonConvert.DeserializeObject<XmMESConfirmInfoVerify_Body>(responseBody);
+            return ConfirmInfoVerifyResponse;
+        }
+
+        #region 入参
+        /// <summary>
+        /// 进站接⼝ - 入参
+        /// </summary>
+        public class XmMES_ConfirmInfoVerifyRequest
+        {
+            /// <summary>
+            /// 进站接⼝ - 入参 - header
+            /// </summary>
+            public XiaomiMES_X5RequestHeader header { get; set; } = new XiaomiMES_X5RequestHeader();
+
+            /// <summary>
+            /// 进站接⼝ - 入参 - body
+            /// </summary>
+            public XmMES_ConfirmInfoVerifyRequest_Body body { get; set; } = new XmMES_ConfirmInfoVerifyRequest_Body();
+        }
+
+        /// <summary>
+        /// 进站接⼝ - 入参 - Body 实体
+        /// </summary>
+        public class XmMES_ConfirmInfoVerifyRequest_Body
+        {
+            /// <summary>
+            /// 装备ID(可配置)
+            /// </summary>
+            public string machineId { get; set; } = string.Empty;
+            /// <summary>
+            /// ⼯位ID(可配置)
+            /// </summary>
+            public string stationId { get; set; } = string.Empty;
+            /// <summary>
+            /// 客⼾端本机MAC地址(格式:4C-52-62-39-CC-F0)
+            /// </summary>
+            public string clientMac { get; set; } = string.Empty;
+
+            /// <summary>
+            /// 客⼾端请求时间(格式:yyyy-MM-dd HH:mm:ss)
+            /// </summary>
+            public string clientTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
+            /// <summary>
+            /// 物料sn
+            /// </summary>
+            public string unitSn { get; set; } = string.Empty;
+            /// <summary>
+            /// 操作⼈
+            /// </summary>
+            public string userId { get; set; } = string.Empty;
+            /// <summary>
+            /// ⼯⼚id:1
+            /// </summary>
+            public long factoryId { get; set; } = 1;
+           
+        }
+        #endregion 入参
+
+        #region 出参
+        /// <summary>
+        /// 进站接⼝ - 出参
+        /// </summary>
+        public class XmMES_ConfirmInfoVerifyResponse
+        {
+            /// <summary>
+            /// header字段描述
+            /// </summary>
+            public XiaomiMES_X5ResponseHeader header { get; set; } = new XiaomiMES_X5ResponseHeader();
+
+            /// <summary>
+            /// body字段描述
+            /// </summary>
+            public XmMESConfirmInfoVerify_Body body { get; set; } = new XmMESConfirmInfoVerify_Body();
+        }
+
+        /// <summary>
+        /// 进站接⼝ - 出参 - Body
+        /// </summary>
+        public class XmMESConfirmInfoVerify_Body
+        {
+            /// <summary>
+            /// 生产参数
+            /// </summary>
+            public productionParams_body productionParams { get; set; }=new productionParams_body();
+            /// <summary>
+            /// 服务处理完成时间
+            /// </summary>
+            public string serverTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
+            /// <summary>
+            /// 请求达到服务时间
+            /// </summary>
+            public string requestTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
+
+            /// <summary>
+            /// 处理时长(毫秒)
+            /// </summary>
+            public string processTime { get; set; } = "";
+        }
+
+        public class productionParams_body {
+            /// <summary>
+            /// 生产参数名称
+            /// </summary>
+            public string productionParam { get; set; } = string.Empty;
+            /// <summary>
+            /// 参数值
+            /// </summary>
+            public string paramValue { get; set; } = string.Empty;
+
+        }
+
+        #endregion
+
+    }
+}

+ 76 - 0
MainForm/ClassFile/XiaomiClass/MultiDirectoryCleanupService.cs

@@ -0,0 +1,76 @@
+using BZFAStandardLib;
+using Sunny.UI.Win32;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Timers;
+
+namespace MainForm.ClassFile.XiaomiClass
+{
+
+    internal class MultiDirectoryCleanupService
+    {
+        private Timer _timer;
+        private List<string> _directoriesToClean;
+        public MultiDirectoryCleanupService()
+        {
+            // 初始化需要清理的目录列表
+            _directoriesToClean = new List<string>
+            {
+                GlobalContext.MqttDeviceStateDir,//mqtt日志 - 设备状态日志
+                GlobalContext.MqttInputBeginDir,//mqtt日志 - 节拍日志
+                GlobalContext.MqttOperateLogDir,//mqtt日志 - 用户操作日志
+                GlobalContext.MqttAlarmLogDir,//mqtt日志 - 故障日志日志
+                GlobalContext.MqttPassResultLogDir,//mqtt日志 - 过站结果日志
+                GlobalContext.MqttPassDetailLogDir,//mqtt日志 - 过站明细日志
+                GlobalContext.MqttFileUpLogDir,//mqtt日志 - 文件上传日志
+                GlobalContext.MqttFileBackupLogDir,//mqtt日志 - 文件备份
+                GlobalContext.MqttDeviceConfigLogDir,  // mqtt日志 - 装备配置日志
+                GlobalContext.WorkLogDir  // mqtt日志 - // 运行日志
+            };
+
+            // 设置定时器, 比如每天运行一次 (以毫秒为单位)
+            //_timer = new Timer(24 * 60 * 60 * 1000);
+            _timer = new Timer(1 * 60 * 60 * 1000);
+            _timer.Elapsed += OnTimerElapsed;
+        }
+
+        private void OnTimerElapsed(object sender, ElapsedEventArgs e)
+        {
+            foreach (var directory in _directoriesToClean)
+            {
+                try
+                {
+                    var files = Directory.GetFiles(directory);
+
+                    foreach (var file in files)
+                    {
+                        DateTime lastWriteTime = File.GetLastWriteTime(file);
+                        if ((DateTime.Now - lastWriteTime).TotalDays > GlobalContext.ClearLogDays)
+                        {
+                            File.Delete(file);
+                            string logPath = GlobalContext.MqttClearFileDir + "ClearFile" + DateTime.Now.ToString("yyyyMMdd") + ".txt";
+                            FileOperate.NewTxtFile(logPath, DateTime.Now + $"===>{file} 已被删除");
+
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    // 记录错误信息或采取其他措施
+                    Console.WriteLine($"无法清理目录 {directory}: {ex.Message}");
+                }
+            }
+        }
+
+        public void Start()
+        {
+            _timer.Start();
+        }
+
+    }
+
+}

+ 2 - 2
MainForm/FaForm/Dialog_MaterialVerify.cs

@@ -33,7 +33,7 @@ namespace MainForm.FaForm
             this.StartPosition = FormStartPosition.CenterParent;
             this.Shown += MainForm_Shown;
 
-            if (Code.Contains("OP30")) {
+            if (Code.Contains("OP30") || Code.Contains("OP31") || Code.Contains("OP32")) {
                 if (flag == "Left") {
                     Station.Text = "[OP31]点散热胶装备1";
                     stationid = GlobalContext.s3_1_station;
@@ -43,7 +43,7 @@ namespace MainForm.FaForm
                     stationid = GlobalContext.s3_2_station;
                 }
             }
-            if (Code.Contains("OP80"))
+            if (Code.Contains("OP80") || Code.Contains("OP81") || Code.Contains("OP82"))
             {
                 if (flag == "Left")
                 {

+ 32 - 26
MainForm/FaForm/Form_Home.cs

@@ -57,6 +57,7 @@ using System.Text.RegularExpressions;
 using System.Text;
 using SixLabors.ImageSharp;
 using static MainForm.ClassFile.XiaomiAPI_MES.XiaomiMESHttp_MaterialVerify;
+using MainForm.ClassFile.XiaomiClass;
 
 /*
  * 注:本源码对外提供,所以有些地方使用中文命名方法及变量
@@ -554,6 +555,12 @@ namespace MainForm
                     operateToIot("startup", "开启");
                     //上传装备配置
                     deviceConfigToIot("project_name", GlobalContext.Project_Code);
+                    //启动日志清理任务
+                    if (GlobalContext.IsClearLog)
+                    {
+                        var cleanupService = new MultiDirectoryCleanupService();
+                        cleanupService.Start();
+                    }
                     AddMessage(LogType.Info, "程序初始化完成");
                 }
                 catch (Exception ex)
@@ -2943,22 +2950,20 @@ namespace MainForm
 
                     // 上传开始节拍 节拍只需要PLC传1、3、4、5
                     result = SaveOEEData(plcNo, stationNameStr, deviceOEE, strProductBarcode, CarrierBarcode);
-                    //上传结束节拍
-                    switch (oEEType)
+                    if (result.Item1 == 1)
                     {
-                        case "1":
+                        if (oEEType=="1")
+                        {
                             Enum.TryParse("2", out deviceOEE);
                             result = SaveOEEData(plcNo, stationNameStr, deviceOEE, strProductBarcode, CarrierBarcode);
-                            break;
-                        case "5":
+                        }
+                        else if (oEEType=="5")
+                        {
                             Enum.TryParse("6", out deviceOEE);
                             result = SaveOEEData(plcNo, stationNameStr, deviceOEE, strProductBarcode, CarrierBarcode);
-                            break;
-                    }
+                        }
 
-                    if (result.Item1 == 1)
-                    {
-                        OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍[{deviceOEE}]上传成功!");
+                        //OnMessage(LogType.Info, $"PLC{plcNo}_{stationNameStr} 节拍[{deviceOEE}]上传成功!");
                         //写入PLC
                         IoT_DataSet_t iotData = new IoT_DataSet_t();
                         iotData.machineState = iot_data.machineState;
@@ -3629,15 +3634,15 @@ namespace MainForm
                 //绑定载具和产品
 
                 //测试注释(临时)
-                //ResponseMessage message = new ResponseMessage();
-                //message = SQLHelper.InsertCarrierBind(CarrierBarcode, sn);
-                //if (message.result == false)
-                //{
-                //    AddMessage(LogType.Error, stationNameStr + "_载具码与产品码绑定失败,错误:" + message.text);
-                //    ProgressState = false;
-                //    Thread.Sleep(10000);
-                //    return;
-                //}
+                ResponseMessage message = new ResponseMessage();
+                message = SQLHelper.InsertCarrierBind(CarrierBarcode, sn);
+                if (message.result == false)
+                {
+                    AddMessage(LogType.Error, stationNameStr + "_载具码与产品码绑定失败,错误:" + message.text);
+                    ProgressState = false;
+                    Thread.Sleep(10000);
+                    return;
+                }
 
                 // 产品SN进站
                 List<TestItem> item = new List<TestItem>();
@@ -4379,7 +4384,8 @@ namespace MainForm
                         else
                         {
                             //测试数据
-                            //stPLC_MesData.Left.mesCommFrmPLC.cmdParam = 1;
+                            //stPLC_MesData.Left.iotData.machineState = 6;
+                            //_FaultDatas = new uint[] { 2, 0, 16, 0, 0, 0, 0, 0, 0, 0 };
                             //stPLC_MesData.Left.BarcodeSet.strCarrierBarcode = "A123456";
                             //stPLC_MesData.Left.BarcodeSet.strPCBBarcode = "A1507V000239";
                             //stPLC_MesData.Left.iotData.beatAction = 1;
@@ -4808,7 +4814,7 @@ namespace MainForm
                 }
 
                 sn = strProductBarcode;
-                AddMessage(LogType.Info, $"载具码:{strProductBarcode};产品码:{sn}");
+                AddMessage(LogType.Info, $"载具码:{strCarrierBarcode};产品码:{sn}");
 
                 // 产品SN(物料码)校验
                 List<TestItem> item = new List<TestItem>();
@@ -6140,15 +6146,15 @@ namespace MainForm
                 byte mesResultFrmWeb = 0;
                 if (stPLC_MesData.mesCommFrmPLC.cmdParam == 2)
                 {
-                    result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem, workorder_code,
-                        batch_num
-                        , mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "01-SLOT-01", MachineId, StationId,
-                        PartBarcode, paramJson, inspectionItemData, "");
-                    uuid = "";
+                    //result1 = SwitctProcessData(stationNameStr, items, equipmentCode, processItem, workorder_code,
+                    //    batch_num
+                    //    , mtltmrk, plcDate_YMD, supplierCode, sn, pass, CarrierBarcode, "01-SLOT-01", MachineId, StationId,
+                    //    PartBarcode, paramJson, inspectionItemData, "");
                 }
                 else if (stPLC_MesData.mesCommFrmPLC.cmdParam == 1)
                 {
                     result1 = PCBStationOutData(stPLC_MesData.BarcodeSet, stPLC_MesData.iotData);
+                    uuid = "";
                 }
 
                 mesResultFrmWeb = (byte)(result1 == 1 ? 1 : 110);

+ 3 - 10
MainForm/FaForm/Form_Other.cs

@@ -1,4 +1,5 @@
 using EIP_Protocol;
+using MainForm.ClassFile.XiaomiClass;
 using MathNet.Numerics.RootFinding;
 using Newtonsoft.Json;
 using System;
@@ -166,16 +167,8 @@ namespace MainForm.FaForm
 
         private void button13_Click(object sender, EventArgs e)
         {
-            Form_Home home = new Form_Home();
-            int res = home.MaterialVerifyPost("123456789", "C-PFA-CPAPHD-A-BZJG-0001");
-            if (res == 1)
-            {
-                Console.WriteLine("上传成功");
-            }
-            else
-            {
-                Console.WriteLine("上传失败");
-            }
+            var cleanupService = new MultiDirectoryCleanupService();
+            cleanupService.Start();
         }
     }
 }

+ 60 - 88
MainForm/FaForm/Form_SystemSet.Designer.cs

@@ -49,6 +49,12 @@
             this.txtStation = new System.Windows.Forms.TextBox();
             this.label14 = new System.Windows.Forms.Label();
             this.groupBox1 = new System.Windows.Forms.GroupBox();
+            this.label17 = new System.Windows.Forms.Label();
+            this.txtStation2 = new System.Windows.Forms.TextBox();
+            this.label19 = new System.Windows.Forms.Label();
+            this.txtDeviceCode2 = new System.Windows.Forms.TextBox();
+            this.label21 = new System.Windows.Forms.Label();
+            this.txtWorkStation2 = new System.Windows.Forms.TextBox();
             this.label8 = new System.Windows.Forms.Label();
             this.textBoxServerHost = new System.Windows.Forms.TextBox();
             this.cbSendProcessData = new System.Windows.Forms.CheckBox();
@@ -106,18 +112,10 @@
             this.rdbS6 = new System.Windows.Forms.RadioButton();
             this.txtPLCAddress6 = new System.Windows.Forms.TextBox();
             this.groupBox6 = new System.Windows.Forms.GroupBox();
-            this.chkIsClearMes = new System.Windows.Forms.CheckBox();
-            this.chkIsClearIot = new System.Windows.Forms.CheckBox();
             this.txtClearDay = new System.Windows.Forms.TextBox();
             this.label16 = new System.Windows.Forms.Label();
             this.chkIsClearLog = new System.Windows.Forms.CheckBox();
             this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
-            this.label17 = new System.Windows.Forms.Label();
-            this.txtStation2 = new System.Windows.Forms.TextBox();
-            this.label19 = new System.Windows.Forms.Label();
-            this.txtDeviceCode2 = new System.Windows.Forms.TextBox();
-            this.label21 = new System.Windows.Forms.Label();
-            this.txtWorkStation2 = new System.Windows.Forms.TextBox();
             this.groupBox1.SuspendLayout();
             this.groupBox2.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.numMqttPort)).BeginInit();
@@ -363,6 +361,60 @@
             this.groupBox1.TabStop = false;
             this.groupBox1.Text = "产线信息维护";
             // 
+            // label17
+            // 
+            this.label17.AutoSize = true;
+            this.label17.Location = new System.Drawing.Point(540, 187);
+            this.label17.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label17.Name = "label17";
+            this.label17.Size = new System.Drawing.Size(95, 30);
+            this.label17.TabIndex = 102;
+            this.label17.Text = "⼯位Id2:";
+            // 
+            // txtStation2
+            // 
+            this.txtStation2.Location = new System.Drawing.Point(664, 181);
+            this.txtStation2.Margin = new System.Windows.Forms.Padding(4);
+            this.txtStation2.Name = "txtStation2";
+            this.txtStation2.Size = new System.Drawing.Size(250, 36);
+            this.txtStation2.TabIndex = 101;
+            // 
+            // label19
+            // 
+            this.label19.AutoSize = true;
+            this.label19.Location = new System.Drawing.Point(34, 181);
+            this.label19.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label19.Name = "label19";
+            this.label19.Size = new System.Drawing.Size(119, 30);
+            this.label19.TabIndex = 100;
+            this.label19.Text = "装备编码2:";
+            // 
+            // txtDeviceCode2
+            // 
+            this.txtDeviceCode2.Location = new System.Drawing.Point(164, 178);
+            this.txtDeviceCode2.Margin = new System.Windows.Forms.Padding(4);
+            this.txtDeviceCode2.Name = "txtDeviceCode2";
+            this.txtDeviceCode2.Size = new System.Drawing.Size(250, 36);
+            this.txtDeviceCode2.TabIndex = 99;
+            // 
+            // label21
+            // 
+            this.label21.AutoSize = true;
+            this.label21.Location = new System.Drawing.Point(1058, 187);
+            this.label21.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label21.Name = "label21";
+            this.label21.Size = new System.Drawing.Size(75, 30);
+            this.label21.TabIndex = 98;
+            this.label21.Text = "⼯站2:";
+            // 
+            // txtWorkStation2
+            // 
+            this.txtWorkStation2.Location = new System.Drawing.Point(1157, 184);
+            this.txtWorkStation2.Margin = new System.Windows.Forms.Padding(4);
+            this.txtWorkStation2.Name = "txtWorkStation2";
+            this.txtWorkStation2.Size = new System.Drawing.Size(250, 36);
+            this.txtWorkStation2.TabIndex = 97;
+            // 
             // label8
             // 
             this.label8.AutoSize = true;
@@ -1029,8 +1081,6 @@
             // 
             // groupBox6
             // 
-            this.groupBox6.Controls.Add(this.chkIsClearMes);
-            this.groupBox6.Controls.Add(this.chkIsClearIot);
             this.groupBox6.Controls.Add(this.txtClearDay);
             this.groupBox6.Controls.Add(this.label16);
             this.groupBox6.Controls.Add(this.chkIsClearLog);
@@ -1042,28 +1092,6 @@
             this.groupBox6.TabStop = false;
             this.groupBox6.Text = "日志清理";
             // 
-            // chkIsClearMes
-            // 
-            this.chkIsClearMes.AutoSize = true;
-            this.chkIsClearMes.Location = new System.Drawing.Point(664, 36);
-            this.chkIsClearMes.Margin = new System.Windows.Forms.Padding(4);
-            this.chkIsClearMes.Name = "chkIsClearMes";
-            this.chkIsClearMes.Size = new System.Drawing.Size(174, 34);
-            this.chkIsClearMes.TabIndex = 93;
-            this.chkIsClearMes.Text = "MES过站日志";
-            this.chkIsClearMes.UseVisualStyleBackColor = true;
-            // 
-            // chkIsClearIot
-            // 
-            this.chkIsClearIot.AutoSize = true;
-            this.chkIsClearIot.Location = new System.Drawing.Point(883, 36);
-            this.chkIsClearIot.Margin = new System.Windows.Forms.Padding(4);
-            this.chkIsClearIot.Name = "chkIsClearIot";
-            this.chkIsClearIot.Size = new System.Drawing.Size(164, 34);
-            this.chkIsClearIot.TabIndex = 91;
-            this.chkIsClearIot.Text = "IOT上传日志";
-            this.chkIsClearIot.UseVisualStyleBackColor = true;
-            // 
             // txtClearDay
             // 
             this.txtClearDay.Location = new System.Drawing.Point(288, 34);
@@ -1093,60 +1121,6 @@
             this.chkIsClearLog.Text = "启用";
             this.chkIsClearLog.UseVisualStyleBackColor = true;
             // 
-            // label17
-            // 
-            this.label17.AutoSize = true;
-            this.label17.Location = new System.Drawing.Point(540, 187);
-            this.label17.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label17.Name = "label17";
-            this.label17.Size = new System.Drawing.Size(95, 30);
-            this.label17.TabIndex = 102;
-            this.label17.Text = "⼯位Id2:";
-            // 
-            // txtStation2
-            // 
-            this.txtStation2.Location = new System.Drawing.Point(664, 181);
-            this.txtStation2.Margin = new System.Windows.Forms.Padding(4);
-            this.txtStation2.Name = "txtStation2";
-            this.txtStation2.Size = new System.Drawing.Size(250, 36);
-            this.txtStation2.TabIndex = 101;
-            // 
-            // label19
-            // 
-            this.label19.AutoSize = true;
-            this.label19.Location = new System.Drawing.Point(34, 181);
-            this.label19.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label19.Name = "label19";
-            this.label19.Size = new System.Drawing.Size(119, 30);
-            this.label19.TabIndex = 100;
-            this.label19.Text = "装备编码2:";
-            // 
-            // txtDeviceCode2
-            // 
-            this.txtDeviceCode2.Location = new System.Drawing.Point(164, 178);
-            this.txtDeviceCode2.Margin = new System.Windows.Forms.Padding(4);
-            this.txtDeviceCode2.Name = "txtDeviceCode2";
-            this.txtDeviceCode2.Size = new System.Drawing.Size(250, 36);
-            this.txtDeviceCode2.TabIndex = 99;
-            // 
-            // label21
-            // 
-            this.label21.AutoSize = true;
-            this.label21.Location = new System.Drawing.Point(1058, 187);
-            this.label21.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
-            this.label21.Name = "label21";
-            this.label21.Size = new System.Drawing.Size(75, 30);
-            this.label21.TabIndex = 98;
-            this.label21.Text = "⼯站2:";
-            // 
-            // txtWorkStation2
-            // 
-            this.txtWorkStation2.Location = new System.Drawing.Point(1157, 184);
-            this.txtWorkStation2.Margin = new System.Windows.Forms.Padding(4);
-            this.txtWorkStation2.Name = "txtWorkStation2";
-            this.txtWorkStation2.Size = new System.Drawing.Size(250, 36);
-            this.txtWorkStation2.TabIndex = 97;
-            // 
             // Form_SystemSet
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
@@ -1265,8 +1239,6 @@
         private System.Windows.Forms.CheckBox chkMqttPassResult;
         private System.Windows.Forms.CheckBox chkMqttUpFile;
         private System.Windows.Forms.GroupBox groupBox6;
-        private System.Windows.Forms.CheckBox chkIsClearMes;
-        private System.Windows.Forms.CheckBox chkIsClearIot;
         private System.Windows.Forms.TextBox txtClearDay;
         private System.Windows.Forms.Label label16;
         private System.Windows.Forms.CheckBox chkIsClearLog;

+ 25 - 5
MainForm/FaForm/Form_SystemSet.cs

@@ -70,11 +70,8 @@ namespace MainForm
             txtPLCAddress9.Text = IniFile.INIGetStringValue(FilePath, "Machine", "Machine9Address", GlobalContext.ConstMachine9Address);
 
             //日志配置
-            txtClearDay.Text = IniFile.INIGetStringValue(FilePath, "Machine", "ClearLogDays", "");  //清理日志天数
-            chkIsClearLog.Checked = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsClearLog", "False"));  // 是否 启用AGV            chkIsClearLog.Checked = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "IsClearLog", "False"));  // 是否 启用AGV
-            chkIsClearMes.Checked = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "ClearMes", "False"));  // 是否 启用AGV
-            chkIsClearIot.Checked = bool.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "ClearIot", "False"));  // 是否 启用AGV
-
+            txtClearDay.Text = IniFile.INIGetStringValue(FilePath, "System", "ClearLogDays", "");  //清理日志天数
+            chkIsClearLog.Checked = bool.Parse(IniFile.INIGetStringValue(FilePath, "System", "IsClearLog", "False"));  
 
             numPLCPort.Value = int.Parse(IniFile.INIGetStringValue(FilePath, "Machine", "MachinePort", "0"));
 
@@ -469,6 +466,29 @@ namespace MainForm
             }
             #endregion
 
+            #region 系统设置
+            try
+            {
+                IniFile.INIWriteValue(FilePath, "System", "IsClearLog", chkIsClearLog.Checked.ToString());  // 是否 启用AGV
+                IniFile.INIWriteValue(FilePath, "System", "ClearLogDays", txtClearDay.Text.Trim());  // Http IP地址
+
+                GlobalContext.UpdateData();
+
+                //记录修改日志
+                List<string> mesSetVlaue = new List<string>();
+                mesSetVlaue.Add(chkIsClearLog.Checked.ToString());
+                mesSetVlaue.Add(txtClearDay.Text.Trim());
+                String.Join(";", mesSetVlaue);
+                OnMessage(LogType.Info, currentRole + "修改系统值[系统设置]为[" + String.Join(";", mesSetVlaue) + "]");
+
+            }
+            catch (Exception ex)
+            {
+                string str = ex.StackTrace;
+                OnMessage(LogType.Error, "保存AGV配置出错!异常位置:" + str.Substring(str.LastIndexOf("\\") + 1, str.Length - str.LastIndexOf("\\") - 1) + ";异常信息:" + ex.Message.ToString());
+            }
+            #endregion
+
             try
             {
                 MessageBox.Show("参数保存成功!");

+ 1 - 0
MainForm/MainForm.csproj

@@ -306,6 +306,7 @@
     <Compile Include="ClassFile\XiaomiClass\AGVHelper.cs" />
     <Compile Include="ClassFile\XiaomiClass\IoTHelper.cs" />
     <Compile Include="ClassFile\XiaomiClass\MesHelper.cs" />
+    <Compile Include="ClassFile\XiaomiClass\MultiDirectoryCleanupService.cs" />
     <Compile Include="ClassFile\XiaomiClass\ProcessHelper.cs" />
     <Compile Include="FaForm\Dialog_BandBarode_S6.cs">
       <SubType>Form</SubType>