Преглед на файлове

update for connect db of 365mc main server

alpha
Jeong Geol Kim преди 4 години
родител
ревизия
de14c0f181
променени са 3 файла, в които са добавени 51 реда и са изтрити 7 реда
  1. 2
    0
      log.txt
  2. 21
    7
      main.py
  3. 28
    0
      text.py

+ 2
- 0
log.txt Целия файл

@@ -0,0 +1,2 @@
1
+record succesfully started at Mon Dec  6 16:33:28 2021
2
+record succesfully stopped at Mon Dec  6 16:33:30 2021

+ 21
- 7
main.py Целия файл

@@ -2,16 +2,20 @@ import tkinter
2 2
 import json
3 3
 import paramiko
4 4
 import time
5
+from datetime import datetime
5 6
 from tkinter import messagebox
6 7
 import os
7 8
 
8 9
 from paramiko import file
10
+import pymssql
9 11
 
10 12
 
11 13
 window = tkinter.Tk()
12 14
 settings =[]
13 15
 customer_code = ''
14 16
 surgery_date =  str(time.strftime('%Y%m%d', time.localtime(time.time())))
17
+cnxn =  pymssql.connect('52.231.39.219' , 'mc365', 'tkadbrdhmc1!', 'tsfmc_data')
18
+cursor = cnxn.cursor()
15 19
 
16 20
 
17 21
 with open('./settings.json', encoding='utf-8')as json_file:
@@ -86,20 +90,23 @@ label_customer_code = tkinter.Label(window, text="고객번호(지점 번호 포
86 90
 def dummyexit():
87 91
     pass
88 92
 
89
-def askInformation(customer_code,surgery_date):        
93
+def askInformation(customer_code,surgery_date, customer_name):        
90 94
     cs = customer_code
91 95
     sd = surgery_date
92
-
96
+    global pk
97
+    pk = cs + sd
93 98
     if len(cs) != 9:
94 99
         err_box = messagebox.showerror("고객 번호 오류", '지점 번호를 포함한 9자리를 입력해주세요.')    
95 100
     else:
96
-        msg_box = messagebox.askquestion("입력 정보 확인", "입력하신 정보가 정확한지 확인해주세요.\n고객 번호: "+customer_code + '\n 수술일자: ' + surgery_date +'\n\nYes를 눌러 기록 시작을,\n입력 정보의 수정을 원하시면 No을 눌러 변경해주세요.')
101
+        msg_box = messagebox.askquestion("입력 정보 확인", "\n고객 이름 : " + customer_name + "\n\n고객 번호 : " + customer_code + '\n\n맞으면 Yes를 눌러 기록시작을,\n 틀리면 No를 눌러 수정해주세요.')
97 102
         #TODO: try: 형태로 고칠 것. Err 메세지도 종류 정할 것
98 103
         if msg_box == 'yes':
104
+            global start_time
105
+            start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
99 106
             err_status = True
100 107
 
101 108
             if err_status == False:
102
-                label_recording = tkinter.Label(window, text='분석 PC에 문제가 발생하였습니다.\nHOBIT LAB으로 연락 부탁드립니다.\n내선번호: 1237 \n에러 코드: REQUEST TIME OUT')
109
+                label_recording = tkinter.Label(window, text='분석 PC에 문제가 발생하였습니다.\nHOBIT LAB으로 연락 부탁드립니다.\n내선번호: 1103 \n에러 코드: REQUEST TIME OUT')
103 110
                 label_recording.pack()
104 111
             else:
105 112
                 #TODO: paramiko로 ssh 접속 후 도커 명령어 보낼 것
@@ -109,12 +116,17 @@ def askInformation(customer_code,surgery_date):
109 116
 
110 117
                 label_recording = tkinter.Label(window, text='MAIL system에 수술을 기록 중입니다.\n기록 중단을 원할 시 \n기록 종료 버튼을 눌러주세요.')
111 118
                 label_recording.pack()
112
-        
119
+
113 120
 def askQuit(cn, sd):
114 121
     customer_number = cn
115 122
     surgery_date = sd
116 123
     msg_box = messagebox.askquestion("기록 중지 확인", '기록을 중지하시겠습니까?')
117 124
     if msg_box == 'yes':
125
+        end_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
126
+        # print(str(end_time))
127
+        data =  [(pk, json_data['branch_location'], json_data['surgery_room_number'], str(start_time), str(end_time))]        
128
+        cursor.executemany("INSERT into tsfmc_mailsystem.dbo.MAIL_SURGERYCOUNT values ( %s, %s, %d, %s, %s)", data) 
129
+        cnxn.commit()
118 130
         #TODO: docker 중지 명령어 보내기
119 131
         sshQuit(customer_number, surgery_date)
120 132
         window.destroy()
@@ -122,9 +134,11 @@ def askQuit(cn, sd):
122 134
 
123 135
 
124 136
 def buttonAction(event):    
125
-    customer_code = str(entry_customer_code.get())        
137
+    customer_code = str(entry_customer_code.get())  
138
+    cursor.execute("SELECT PSNAME FROM ADM010T WHERE PSENTRY='{}';".format(customer_code)  )    
139
+    customer_name = cursor.fetchone()[0]
126 140
     if button_confirm['text'] == '입력완료':        
127
-        askInformation(customer_code, surgery_date)
141
+        askInformation(customer_code, surgery_date, customer_name)
128 142
     else:
129 143
         askQuit(customer_code,surgery_date)
130 144
 # def fillSurgeryDate():

+ 28
- 0
text.py Целия файл

@@ -0,0 +1,28 @@
1
+import pymssql
2
+
3
+# DB 서버 주소
4
+server = '52.231.39.219'
5
+# 데이터 베이스 이름
6
+database = 'tsfmc_data'
7
+# 접속 유저명
8
+username = 'mc365'
9
+# 접속 유저 패스워드
10
+password = 'tkadbrdhmc1!'
11
+
12
+# MSSQL 접속
13
+cnxn =  pymssql.connect(server , username, password, database)
14
+cursor = cnxn.cursor()
15
+ 
16
+# SQL문 실행
17
+cursor.execute("SELECT PSNAME FROM ADM010T WHERE PSENTRY='350003285';")
18
+print(cursor.fetchone()[0])
19
+# 데이타를 하나씩 Fetch하여 출력
20
+row = cursor.fetchone()
21
+
22
+while row:
23
+    print(row[3], row[4],  row[2])
24
+    row = cursor.fetchone()
25
+    break
26
+
27
+# 연결 끊기
28
+cnxn.close()

Loading…
Отказ
Запис