Пример #1
0
    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"]
Пример #2
0
    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]
Пример #3
0
    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 +
                         " 설정을 불러오는데 실패했습니다.")
Пример #4
0
    def parse(self, fromDate, toDate):

        headers_common = {
            'Content-Length': '32',
            'Accept': '*/*',
            'X-Requested-With': 'XMLHttpRequest',
            'User-Agent':
            'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.87 Safari/537.36',
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'Origin': 'http://203.247.141.92:8080',
            'Referer': 'http://203.247.141.92:8080/SmartLogen/login',
            'Accept-Encoding': 'gzip, deflate',
            'Accept-Language': 'ko,ko-KR;q=0.9,en-US;q=0.8,en;q=0.7,ja;q=0.6',
            'Connection': 'close'
        }

        url = 'http://203.247.141.92:8080/SmartLogen/OrderRecordSelect'
        try:
            post = {
                'branchCd': self.loginData1,
                'tradeCd': self.loginData2,
                'fromDate': fromDate,
                'toDate': toDate,
                'personNm': '',
                'ziphaGb': 'A',
                'delieverGb': 'A',
                'unsongjangGb': 'F'
            }

        except:
            Logger.error("로젠 로그인 설정이 잘못 되었습니다. ID : ", self.loginData1,
                         " PASSWORD : "******""
            prod_eas = ""
            print("@!#!@# splited_prods : ", splited_prods)
            for prod in splited_prods:
                pd = prod.strip().split(' ')
                prod_datas += str(pd[0]) + "\n"
                if (len(pd) != 2):
                    prod_eas += str(1) + "\n"
                else:
                    try:
                        ea = int(str(pd[1].replace('개', '')))
                        prod_eas += str(pd[1].replace('개', '')) + "\n"
                    except:
                        prod_datas += pd[1] + "\n"
                        prod_eas += str(1) + "\n" + str(1) + "\n"

            data = Data()

            data.carriageNumber = main_id
            data.IO_DATE = date_str
            data.CUST_DES = sangho_name
            data.phoneNumber = phone
            data.PROD_DES = prod_datas.strip()
            data.QTY = prod_eas.strip()
            data.address = address

            dataList.append(data)

            print("!@#!@# data : ", data)
        return dataList
Пример #5
0
    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