fix
zhangqian
2024-04-09 b1114569135bbcbab8a095ebe37f4800183d2c5f
main.go
@@ -11,10 +11,10 @@
   "apsClient/router"
   "apsClient/serf"
   "apsClient/service"
   "apsClient/service/plc_address"
   "fmt"
   "log"
   "net/http"
   _ "net/http/pprof"
   "time"
)
@@ -29,7 +29,7 @@
   }
   //加载plc写入地址
   plc_address.LoadAddressFromFile()
   //plc_address.LoadAddressFromFile()
   // 启动数据同步
   var serfStartChan = make(chan bool)
@@ -38,11 +38,14 @@
   var syncTables = []string{
      "procedures",
      "process_model",
      "production_progress",
      "work_order",
      "task_status_sync",
      "device",
      "device_plc",
      "system_status",
      "process_model_plc_address",
      "reports_to_cloud",
      "report_work",
   }
   agent := serf.InitAgent("apsClient", syncTables, sqlitex.GetDB())
@@ -54,12 +57,17 @@
      return
   }
   //从文件里读取当前生产设备id
   conf.Conf.CurrentDeviceID = service.ReadDeviceIDFromFile()
   if conf.Conf.CurrentDeviceID == "" {
      conf.Conf.CurrentDeviceID = conf.Conf.System.DeviceId
   //从文件里读取当前生产设备id获取设备列表第一个
   err := service.InitCurrentDeviceID(serf.Vasystem.ServerID)
   if err != nil {
      logx.Errorf("InitCurrentDeviceID error: %v, exit", err)
      return
   }
   go func() {
      service.ReportsSystemDeviceToCloud(serf.Vasystem.ServerID)
   }()
   // 判断当前集群状态
   logx.Infof("current agent.ClusterStatus:%v", agent.ClusterStatus)
   log.Println("current agent.ClusterStatus:", agent.ClusterStatus)