def __init__(self): config = configparser.ConfigParser() try: config.read(self.configFilePath) if (self.lozenHeader in config): self.lozenId = config[self.lozenHeader][self.lozenIdKey] self.lozenPwd = config[self.lozenHeader][self.lozenPwdKey] else: Logger.error("LOZEN 로그인 정보 불러오기 실패 : " + self.configFilePath + " 설정을 불러오는데 실패했습니다.") Logger.info("ecount login") config.read(self.ecountId) if (self.ecountHeader in config): self.ecountId = config[self.ecountHeader][self.ecountIdKey] self.ecountPwd = config[self.ecountHeader][self.ecountPwdKey] self.ecountComCode = config[self.ecountHeader][ self.ecountComKey] self.ecountApiKey = config[self.ecountHeader][ self.ecountApiKeyKey] Logger.debug("apikey: " + self.ecountApiKey) else: Logger.error("ECOUNT 로그인 정보 불러오기 실패 : " + self.configFilePath + " 설정을 불러오는데 실패했습니다.") except: Logger.error("로그인 정보 불러오기 실패 : " + self.configFilePath + " 설정을 불러오는데 실패했습니다.")
def registrationList(self, dataList): Logger.info("CarriageData List Registraion") Logger.debug("regist Data List : " + str(dataList)) check_resp = [] c = False for d in dataList: a = self.registration(d) if not a[0]: check_resp.append( str(a[1]) + "data : " + str(d.CUST_DES) + " : " + str(d.PROD_DES)) msg = QMessageBox() if len(check_resp) > 0: msg.setWindowTitle("판매 등록 실패") msg.setIcon(QMessageBox.Critical) msg.setText("판매 등록에 실패 했습니다. 아래 리스트를 확인해주세요.\n" + "\n".join(check_resp)) else: msg.setWindowTitle("판매 등록 성공") msg.setIcon(QMessageBox.Information) msg.setText("판매 등록에 성공 했습니다.") msg.setDefaultButton(QMessageBox.Escape) msg.exec_()
def lozenLogin(self): Logger.info("lozenLogin") url = 'http://203.247.141.92:8080/SmartLogen/UserLogin' post = {'userid': self.config.lozenId, 'userpw': self.config.lozenPwd} try: response = self.login_session.post(url, data=post, headers=self.headers_common) except: Logger.error("lozen 로그인 중 네트워크 연결에 문제가 있습니다. ") sys.exit() Logger.debug("response" + response.text) login_data = response.text.split('Ξ') self.lozenLoginData1 = login_data[1] self.lozenLoginData2 = login_data[3]
def ecountLogin(self): Logger.info("ecountLogin") url = 'https://oapi.ecounterp.com/OAPI/V2/Zone' Logger.debug("COM_CODE : " + self.config.ecountComCode) headers = {'Content-Type': 'application/json; charset=utf-8'} post = {'COM_CODE': self.config.ecountComCode} try: response = requests.post(url, data=json.dumps(post), headers=headers) except: Logger.error("ecount 로그인 중 네트워크 연결에 문제가 있습니다. ") sys.exit() Logger.debug("response" + response.text) Logger.debug("Data : " + response.json()["Data"]["ZONE"]) self.ZONE = response.json()["Data"]["ZONE"] url = 'https://oapi{ZONE}.ecounterp.com/OAPI/V2/OAPILogin'.format( ZONE=self.ZONE) post = { 'COM_CODE': self.config.ecountComCode, 'USER_ID': self.config.ecountId, 'API_CERT_KEY': self.config.ecountApiKey, 'LAN_TYPE': 'ko-KR', 'ZONE': self.ZONE } response = requests.post(url, data=json.dumps(post), headers=headers) self.SESSION_ID = response.json()["Data"]["Datas"]["SESSION_ID"]
def registration(self, data): Logger.info("CarriageData Registraion") print("!@#!@# data : ", data) post = """{ "SaleList": [""" for i in range(len(data.PROD_CD)): post += """ {{ "Line": "0", "BulkDatas": {{ "IO_DATE": "{IO_DATE}", "UPLOAD_SER_NO": "", "CUST": "{CUST}", "CUST_DES": "{CUST_DES2}", "WH_CD": "00002", "PROD_CD": "{PROD_CD}", "PROD_DES": "{PROD_DES}", "QTY": "{QTY}", "U_MEMO3": "{CUST_DES1} / {PHONE}", "U_MEMO4": "{ADDRESS}", "U_MEMO5": "{ECT}", }} }} """.format( IO_DATE=data.IO_DATE, CUST=data.CUST, CUST_DES2=data.CUST_DES if str(data.CUST) != "TRA2008008" else "택배발송", # UPLOAD_SER_NO=data.UPLOAD_SER_NO CUST_DES1=data.CUST_DES, PROD_CD=data.PROD_CD[i], PROD_DES=data.PROD_DES[i], QTY=data.QTY[i], PHONE=data.phoneNumber, ADDRESS=data.address, ECT="") if (i != len(data.PROD_CD) - 1): post += """, """ post += """] }""" post = post.encode("utf-8") Logger.debug("post: " + str(post)) response = requests.post(self.registrationUrl, data=post, headers=self.headers) Logger.debug("response : " + response.text) status = response.json()["Status"] success_cnt = "" fail_cnt = "" error_msg = "" if (status == "200"): success_cnt = response.json()["Data"]["SuccessCnt"] fail_cnt = response.json()["Data"]["FailCnt"] if (fail_cnt == 0): return (True, success_cnt) else: return ( False, response.json()["Data"]["ResultDetails"][0]["TotalError"]) else: error_msg = response.json()["Error"]["Message"] return (False, error_msg)
def my_setdata(self, value): Logger.debug("my setdata " + str(value)) self.setData(Qt.UserRole, value) Logger.debug("row " + str(self.row())) Logger.debug("self.data : " + str(self.data(Qt.UserRole)))
def __checkbox_change(self, checkvalue): # print("myclass...check change... ", checkvalue) self.mycheckvalue = checkvalue Logger.debug("checkbox row= " + str(self.get_row())) Logger.debug("checkValue : " + str(self.mycheckvalue)) Logger.debug("self " + str(self.objectName))
def run(self): # try: Logger.debug("downloadPath : " + self.downloadPath) options = webdriver.ChromeOptions() options.add_argument("headless") options.add_argument("disable-gpu") options.add_argument("lang=ko_KR") # 한국어! options.add_argument( "user-agent=Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36" ) options.add_experimental_option( "prefs", { "download.default_directory": self.downloadPath, "download.prompt_for_download": False, "download.directory_upgrade": True, "safebrowsing.enabled": True }) driver = webdriver.Chrome("./lib/chromedriver.exe", chrome_options=options) driver.get( "https://logincc.ecounterp.com/ECERP/LOGIN/ERPLogin?vrqa=mMQ%2Bk8KPqxYEwADSAix%2FmA%3D%3D&vrqb=5456564d5d47535b5b465b4d504d5b4c0f1053535c400f4c5d025d450a4c06545c175d4d005609405a40555b584c4044&vrqc=1" ) driver.implicitly_wait(5) #로그인 driver.find_element_by_xpath( "/html/body/div[6]/form/div[1]/div/div[2]/div[1]/div[1]/input" ).send_keys(self.config.ecountComCode) driver.find_element_by_xpath( "/html/body/div[6]/form/div[1]/div/div[2]/div[1]/div[2]/input" ).send_keys(self.config.ecountId) driver.find_element_by_xpath( "/html/body/div[6]/form/div[1]/div/div[2]/div[1]/div[3]/input[1]" ).send_keys(self.config.ecountPwd) driver.find_element_by_id("save").click() driver.implicitly_wait(1) try: #로그인정보 등록안함 클릭 driver.find_element_by_xpath( "/html/body/div[7]/div[2]/div/div[3]/div/button[2]").click() except: Logger.warn("로그인 정보 등록 되어있음") driver.implicitly_wait(5) #재고1 -> 기초등록 -> 품목등록 Logger.debug("재고1 클릭") driver.find_element_by_xpath( "/html/body/div[7]/div/div[2]/div[2]/div[1]/ul/li[4]/a").click() driver.implicitly_wait(1) Logger.debug("기초등록 클릭") driver.find_element_by_xpath( "/html/body/div[7]/div/div[2]/div[2]/div[2]/ul[4]/li[1]/a").click( ) time.sleep(3) Logger.debug("품목등록 클릭") driver.find_element_by_xpath( "/html/body/div[7]/div/div[2]/div[2]/div[3]/ul/li[4]/a").click() driver.implicitly_wait(5) time.sleep(3) Logger.debug("엑셀 클릭") excelElement = driver.find_element_by_xpath( "/html/body/div[8]/div/div[4]/div[3]/div/div[1]/div[8]/div/button") driver.execute_script("arguments[0].click();", excelElement) driver.implicitly_wait(5) Logger.debug("거래처 등록 클릭") driver.find_element_by_xpath( "/html/body/div[7]/div/div[2]/div[2]/div[3]/ul/li[1]/a").click() driver.implicitly_wait(5) time.sleep(8) Logger.debug("엑셀 클릭") excelElement = driver.find_element_by_xpath( "/html/body/div[8]/div/div[4]/div[3]/div/div[1]/div[6]/div/button[1]" ) driver.execute_script("arguments[0].click();", excelElement) driver.implicitly_wait(5) time.sleep(5) driver.close() customDataFilePath = Path(self.downloadPath).joinpath( self.customDataFileName) Logger.debug(customDataFilePath) check_file = customDataFilePath.is_file() Logger.debug(check_file) prodDataFilePath = Path(self.downloadPath).joinpath( self.prodDataFileName) Logger.debug(prodDataFilePath) check_file = check_file and prodDataFilePath.is_file() Logger.debug(check_file) if check_file: Logger.info("read excel") df = pd.read_excel(customDataFilePath, sheet_name='거래처등록', header=1, index_col='거래처명', dtype={'거래처코드': str}) Logger.debug("df.A : " + str(df['거래처코드'])) self.customData = df['거래처코드'] df = pd.read_excel(prodDataFilePath, sheet_name='품목등록', header=1, index_col='품목명', dtype={'품목코드': str}) Logger.debug("df.A : " + str(df['품목코드'])) self.prodData = df['품목코드'] print("!@#!@# prodData : ", self.prodData) tempSearchKey = df['검색창내용'] tempV = [] tempI = [] self.searchDict = {} for idx, value in tempSearchKey.items(): if (type(value) == type('')): for key in value.split(' '): tempV.append(self.prodData[idx]) tempI.append(key) self.searchDict[key] = idx # self.prodData.append(pd.Series([self.prodData[idx]], index=[key])) self.searchData = pd.Series(tempV, index=tempI) customDataFilePath.unlink() prodDataFilePath.unlink() if type(self.customData) == type(None) or type( self.prodData) == type(None): Logger.error("품목, 거래처 목록을 다운로드 중 문제가 발생하였습니다.") return False else: return True else: customDataFilePath.unlink() prodDataFilePath.unlink() Logger.error("다운로드 실패 : " + self.customDataFileName + ", " + self.prodDataFileName) return False