luochengPC 2 years ago
parent
commit
9f843e1ec5

BIN
__pycache__/app.cpython-36.pyc


BIN
__pycache__/batch.cpython-36.pyc


BIN
__pycache__/ezcad.cpython-36.pyc


BIN
__pycache__/inquire.cpython-36.pyc


BIN
__pycache__/log.cpython-36.pyc


BIN
__pycache__/main.cpython-36.pyc


BIN
__pycache__/output_file.cpython-36.pyc


BIN
__pycache__/param.cpython-36.pyc


BIN
__pycache__/pro.cpython-36.pyc


BIN
__pycache__/production.cpython-36.pyc


BIN
__pycache__/sql.cpython-36.pyc


BIN
__pycache__/user.cpython-36.pyc


BIN
__pycache__/user_openOpc.cpython-36.pyc


BIN
__pycache__/user_socket.cpython-36.pyc


BIN
__pycache__/var.cpython-36.pyc


+ 7 - 4
batch.py

@@ -92,10 +92,13 @@ class my_batch(Frame):
 
 
     def bitch_release_event(self, event, bitch):
     def bitch_release_event(self, event, bitch):
         if self.batch_timeout >= 1:
         if self.batch_timeout >= 1:
-            self.user_var.batch_y = bitch
-            self.batch_view.set("当前年份批号:" + self.user_var.batch_y)
-            self.user_var.order_year_str.set(self.user_var.batch_y)
-            self.user_var.batch_str.set(self.user_var.batch_y + self.user_var.batch_m + self.user_var.batch_d)
+            if self.user_var.batch_y != bitch:
+                self.user_var.batch_y = bitch
+                self.batch_view.set("当前年份批号:" + self.user_var.batch_y)
+                self.user_var.order_year_str.set(self.user_var.batch_y)
+                self.user_var.batch_str.set(self.user_var.batch_y + self.user_var.batch_m + self.user_var.batch_d)
+                self.user_var.order_update_stat = True
+                self.user_var.batch_update_stat = True
 
 
     # 控制栏
     # 控制栏
     def button_canvas_init(self):
     def button_canvas_init(self):

+ 26 - 6
log/error.log

@@ -1,25 +1,45 @@
-2021-12-14 23:59:49,626 - D:\git_workspace\sanoh\G01_0347\ezcad.py[line:28] - ERROR: 打标机软件执行异常: (2, 'ShellExecute', '系统找不到指定的文件。')
+2022-08-02 00:23:43,731 - D:\git_workspace\sanoh\G01_0347\ezcad.py[line:28] - ERROR: 打标机软件执行异常: (2, 'ShellExecute', '系统找不到指定的文件。')
 Traceback (most recent call last):
 Traceback (most recent call last):
   File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 22, in run
   File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 22, in run
     win32api.ShellExecute(0, 'open', self.exename, self.filename, self.exepath, 1)
     win32api.ShellExecute(0, 'open', self.exename, self.filename, self.exepath, 1)
 pywintypes.error: (2, 'ShellExecute', '系统找不到指定的文件。')
 pywintypes.error: (2, 'ShellExecute', '系统找不到指定的文件。')
 Stack (most recent call last):
 Stack (most recent call last):
-  File "D:\Program Files\JetBrains\PyCharm Community Edition 2020.2.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 773, in __call__
-    ret = self.original_func(*self.args, **self.kwargs)
   File "D:\Python\Python36-32\lib\threading.py", line 884, in _bootstrap
   File "D:\Python\Python36-32\lib\threading.py", line 884, in _bootstrap
     self._bootstrap_inner()
     self._bootstrap_inner()
   File "D:\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
   File "D:\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
     self.run()
     self.run()
   File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 28, in run
   File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 28, in run
     self.log_file.logger.error('打标机软件执行异常: {0}'.format(e), exc_info=True, stack_info=True)
     self.log_file.logger.error('打标机软件执行异常: {0}'.format(e), exc_info=True, stack_info=True)
-2021-12-13 23:00:19,439 - D:\git_workspace\sanoh\G01_0347\ezcad.py[line:28] - ERROR: 打标机软件执行异常: (2, 'ShellExecute', '系统找不到指定的文件。')
+2022-08-02 00:26:10,154 - D:\git_workspace\sanoh\G01_0347\ezcad.py[line:28] - ERROR: 打标机软件执行异常: (2, 'ShellExecute', '系统找不到指定的文件。')
+Traceback (most recent call last):
+  File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 22, in run
+    win32api.ShellExecute(0, 'open', self.exename, self.filename, self.exepath, 1)
+pywintypes.error: (2, 'ShellExecute', '系统找不到指定的文件。')
+Stack (most recent call last):
+  File "D:\Python\Python36-32\lib\threading.py", line 884, in _bootstrap
+    self._bootstrap_inner()
+  File "D:\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
+    self.run()
+  File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 28, in run
+    self.log_file.logger.error('打标机软件执行异常: {0}'.format(e), exc_info=True, stack_info=True)
+2022-08-02 00:26:42,528 - D:\git_workspace\sanoh\G01_0347\ezcad.py[line:28] - ERROR: 打标机软件执行异常: (2, 'ShellExecute', '系统找不到指定的文件。')
+Traceback (most recent call last):
+  File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 22, in run
+    win32api.ShellExecute(0, 'open', self.exename, self.filename, self.exepath, 1)
+pywintypes.error: (2, 'ShellExecute', '系统找不到指定的文件。')
+Stack (most recent call last):
+  File "D:\Python\Python36-32\lib\threading.py", line 884, in _bootstrap
+    self._bootstrap_inner()
+  File "D:\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
+    self.run()
+  File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 28, in run
+    self.log_file.logger.error('打标机软件执行异常: {0}'.format(e), exc_info=True, stack_info=True)
+2022-08-02 00:27:22,063 - D:\git_workspace\sanoh\G01_0347\ezcad.py[line:28] - ERROR: 打标机软件执行异常: (2, 'ShellExecute', '系统找不到指定的文件。')
 Traceback (most recent call last):
 Traceback (most recent call last):
   File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 22, in run
   File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 22, in run
     win32api.ShellExecute(0, 'open', self.exename, self.filename, self.exepath, 1)
     win32api.ShellExecute(0, 'open', self.exename, self.filename, self.exepath, 1)
 pywintypes.error: (2, 'ShellExecute', '系统找不到指定的文件。')
 pywintypes.error: (2, 'ShellExecute', '系统找不到指定的文件。')
 Stack (most recent call last):
 Stack (most recent call last):
-  File "D:\Program Files\JetBrains\PyCharm Community Edition 2020.2.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 773, in __call__
-    ret = self.original_func(*self.args, **self.kwargs)
   File "D:\Python\Python36-32\lib\threading.py", line 884, in _bootstrap
   File "D:\Python\Python36-32\lib\threading.py", line 884, in _bootstrap
     self._bootstrap_inner()
     self._bootstrap_inner()
   File "D:\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
   File "D:\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner

+ 28 - 0
log/error.log.2022-04-05

@@ -0,0 +1,28 @@
+2021-12-14 23:59:49,626 - D:\git_workspace\sanoh\G01_0347\ezcad.py[line:28] - ERROR: 打标机软件执行异常: (2, 'ShellExecute', '系统找不到指定的文件。')
+Traceback (most recent call last):
+  File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 22, in run
+    win32api.ShellExecute(0, 'open', self.exename, self.filename, self.exepath, 1)
+pywintypes.error: (2, 'ShellExecute', '系统找不到指定的文件。')
+Stack (most recent call last):
+  File "D:\Program Files\JetBrains\PyCharm Community Edition 2020.2.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 773, in __call__
+    ret = self.original_func(*self.args, **self.kwargs)
+  File "D:\Python\Python36-32\lib\threading.py", line 884, in _bootstrap
+    self._bootstrap_inner()
+  File "D:\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
+    self.run()
+  File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 28, in run
+    self.log_file.logger.error('打标机软件执行异常: {0}'.format(e), exc_info=True, stack_info=True)
+2021-12-13 23:00:19,439 - D:\git_workspace\sanoh\G01_0347\ezcad.py[line:28] - ERROR: 打标机软件执行异常: (2, 'ShellExecute', '系统找不到指定的文件。')
+Traceback (most recent call last):
+  File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 22, in run
+    win32api.ShellExecute(0, 'open', self.exename, self.filename, self.exepath, 1)
+pywintypes.error: (2, 'ShellExecute', '系统找不到指定的文件。')
+Stack (most recent call last):
+  File "D:\Program Files\JetBrains\PyCharm Community Edition 2020.2.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_monkey.py", line 773, in __call__
+    ret = self.original_func(*self.args, **self.kwargs)
+  File "D:\Python\Python36-32\lib\threading.py", line 884, in _bootstrap
+    self._bootstrap_inner()
+  File "D:\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
+    self.run()
+  File "D:\git_workspace\sanoh\G01_0347\ezcad.py", line 28, in run
+    self.log_file.logger.error('打标机软件执行异常: {0}'.format(e), exc_info=True, stack_info=True)

+ 43 - 0
pro.py

@@ -309,9 +309,47 @@ class work_server(threading.Thread):
                     self.user_var.number_count = self.user_var.order_ok + 1
                     self.user_var.number_count = self.user_var.order_ok + 1
                     self.product_number_pro()
                     self.product_number_pro()
                     self.user_var.serial_num_working = self.user_var.serial_num_value
                     self.user_var.serial_num_working = self.user_var.serial_num_value
+                elif (airng_r == True and airng_w == True) or (airok_r == True and airok_w == True):
+                    print("no start to working")
+                    self.user_var.airdata_work_stat = 'working'
+                    self.user_var.serial_num = self.user_var.order_ok + self.user_var.order_ng + 1
+                    self.user_var.number_count = self.user_var.order_ok + 1
+                    self.product_number_pro()
+                    self.user_var.serial_num_working = self.user_var.serial_num_value
 
 
     # def database_pro(self):
     # def database_pro(self):
 
 
+    def update_batch_tbl(self):
+        sqlstr = "UPDATE batch_tbl SET end_time={0}, stat={1} WHERE stat = {2}".format(
+                                                        int(time.time()), True, False)
+        self.sqlclient.sql_action_all(sqlstr)
+
+    def insert_batch_tbl(self):
+        sqlstr = "INSERT INTO batch_tbl "
+        sqlstr = sqlstr + "(year, begin_time, end_time, stat)"
+        sqlstr = sqlstr + " VALUES ('{0}', '{1}', '{2}', {3})".format(
+            self.user_var.batch_y,
+            int(time.time()),
+            int(time.time()),
+            False
+        )
+        self.sqlclient.sql_action_all(sqlstr)
+
+    def batch_tbl_check(self):
+        sqlstr = 'SELECT year FROM batch_tbl WHERE stat=False ORDER by begin_time DESC'
+        results = self.sqlclient.sql_inquire_all(sqlstr)
+        if results != None and len(results) > 0:
+            idx = 0
+            for row in results:
+                if idx == 0:
+                    if row[0] >= 'A' and row[0] <= 'Z':
+                        self.user_var.batch_y = row[0]
+                        self.user_var.order_year_str.set(self.user_var.batch_y)
+                        self.user_var.batch_str.set(
+                        self.user_var.batch_y + self.user_var.batch_m + self.user_var.batch_d)
+        else:
+            self.insert_batch_tbl()
+
     def update_data_tbl(self, status):
     def update_data_tbl(self, status):
         sqlstr = 'UPDATE product_data_tbl SET '
         sqlstr = 'UPDATE product_data_tbl SET '
         if status == True:
         if status == True:
@@ -613,6 +651,7 @@ class work_server(threading.Thread):
             time.sleep(1)
             time.sleep(1)
 
 
         if self.exit_stat == False:
         if self.exit_stat == False:
+            self.batch_tbl_check()
             self.batch_pro()
             self.batch_pro()
             self.order_tbl_check()
             self.order_tbl_check()
             # self.param_tbl_check()
             # self.param_tbl_check()
@@ -621,6 +660,10 @@ class work_server(threading.Thread):
             with main.threadlock:
             with main.threadlock:
                 if self.user_var.product_load == True:
                 if self.user_var.product_load == True:
                     self.product_name_set()
                     self.product_name_set()
+                if self.user_var.batch_update_stat == True:
+                    self.user_var.batch_update_stat = False
+                    self.update_batch_tbl()
+                    self.insert_batch_tbl()
                 self.product_name_check()
                 self.product_name_check()
                 self.plc_conn_check()
                 self.plc_conn_check()
                 self.opc_data_pro()
                 self.opc_data_pro()

+ 9 - 0
sql/sql.txt

@@ -11,6 +11,15 @@ CREATE TABLE IF NOT EXISTS user_tbl(
 
 
 INSERT INTO user_tbl (name,password) VALUES('admin', '123456');
 INSERT INTO user_tbl (name,password) VALUES('admin', '123456');
 
 
+CREATE TABLE IF NOT EXISTS batch_tbl(
+   id INT UNSIGNED AUTO_INCREMENT,
+   year CHAR(1) NOT NULL,
+   begin_time BIGINT NOT NULL,
+   end_time BIGINT,
+   stat BOOL NOT NULL,
+   PRIMARY KEY ( id )
+)ENGINE=InnoDB DEFAULT CHARSET=utf8;
+
 CREATE TABLE IF NOT EXISTS order_tbl(
 CREATE TABLE IF NOT EXISTS order_tbl(
    id INT UNSIGNED AUTO_INCREMENT,
    id INT UNSIGNED AUTO_INCREMENT,
    order_num VARCHAR(30) NOT NULL,
    order_num VARCHAR(30) NOT NULL,

+ 1 - 0
var.py

@@ -116,6 +116,7 @@ class Var_value(Frame):
         self.order_targe = 0
         self.order_targe = 0
         self.order_sng = 0
         self.order_sng = 0
         self.order_update_stat = False
         self.order_update_stat = False
+        self.batch_update_stat = False
 
 
         # 批号
         # 批号
         self.number_type = '2LN'
         self.number_type = '2LN'