From 38583fc8402b5da6e28fcf968ee56b0590dc2d52 Mon Sep 17 00:00:00 2001 From: richard Date: Sun, 20 Oct 2019 23:07:48 +0800 Subject: [PATCH] daily commit --- .gitignore | 3 +- back_end/Dockerfile | 2 +- back_end/bot_app/__init__.py | 11 +- back_end/bot_app/fulfillment/buying_drink.py | 2 + back_end/bot_app/fulfillment/controllers.py | 7 + back_end/bot_app/fulfillment/system_pic.py | 41 ++- back_end/bot_app/fulfillment/utility.py | 50 +++- back_end/bot_app/fulfillment/whl_family.py | 151 ++++++----- back_end/config.py | 9 +- back_end/requirements.txt | 4 +- credential/qa_bot_auth.json | 12 - .../detect_intent_texts.py | 0 resources/entities/dept_code.csv | 238 ++++++++++++++++++ resources/entities/dept_code.sql | 3 + resources/entities/div_code.csv | 52 ++++ resources/entities/div_code.sql | 3 + 16 files changed, 488 insertions(+), 100 deletions(-) delete mode 100644 credential/qa_bot_auth.json rename {back_end/bot_app/fulfillment => front_end}/detect_intent_texts.py (100%) create mode 100644 resources/entities/dept_code.csv create mode 100644 resources/entities/dept_code.sql create mode 100644 resources/entities/div_code.csv create mode 100644 resources/entities/div_code.sql diff --git a/.gitignore b/.gitignore index ef63112..ac274e6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ .ipynb_checkpoints/ env/ credential -__pycache__ \ No newline at end of file +__pycache__ +back_end/config.py diff --git a/back_end/Dockerfile b/back_end/Dockerfile index 2021eeb..81d5220 100644 --- a/back_end/Dockerfile +++ b/back_end/Dockerfile @@ -1,4 +1,4 @@ -FROM python:3.6 +FROM shihxuancheng/python-oracle LABEL MAINTAINER shihxuancheng@gmail.com WORKDIR /usr/src/qa_bot diff --git a/back_end/bot_app/__init__.py b/back_end/bot_app/__init__.py index e5c1c37..9b7265e 100644 --- a/back_end/bot_app/__init__.py +++ b/back_end/bot_app/__init__.py @@ -1,17 +1,12 @@ from flask import Flask -import bot_app.fulfillment.utility as util -from bot_app.fulfillment.controllers import fulfillment +import bot_app.fulfillment.controllers as controller app = Flask(__name__) app.config.from_object('config') -app.register_blueprint(fulfillment) +controller.init_app(app) @app.route('/') def index(): - return 'Service Working!!!' - -@app.route('/test') -def test(): - return util.simple_response('Hello World Test!!') \ No newline at end of file + return 'Service Working!!!' \ No newline at end of file diff --git a/back_end/bot_app/fulfillment/buying_drink.py b/back_end/bot_app/fulfillment/buying_drink.py index a0c7d92..73c6866 100644 --- a/back_end/bot_app/fulfillment/buying_drink.py +++ b/back_end/bot_app/fulfillment/buying_drink.py @@ -74,4 +74,6 @@ def ordering_delivery_info(fulfillment): } }) +def init_app(app): + pass diff --git a/back_end/bot_app/fulfillment/controllers.py b/back_end/bot_app/fulfillment/controllers.py index dd70041..a5fbc01 100644 --- a/back_end/bot_app/fulfillment/controllers.py +++ b/back_end/bot_app/fulfillment/controllers.py @@ -54,3 +54,10 @@ def fetch_url(): print(res.json()) result = res return res + +def init_app(app): + app.register_blueprint(fulfillment) + util.init_app(app) + buying_drink.init_app(app) + system_pic.init_app(app) + whl_family.init_app(app) \ No newline at end of file diff --git a/back_end/bot_app/fulfillment/system_pic.py b/back_end/bot_app/fulfillment/system_pic.py index be1f158..d75693f 100644 --- a/back_end/bot_app/fulfillment/system_pic.py +++ b/back_end/bot_app/fulfillment/system_pic.py @@ -1,22 +1,46 @@ import bot_app.fulfillment.utility as util -''' -Intent - system_pic -''' # 查詢系統pic def looking_for_pic(fulfillment): - print(fulfillment) + # print(fulfillment) sys_code = fulfillment.get('queryResult').get('parameters').get('sys_code') + # 取得系統pic - strRes = sys_code + '負責人是Richard Shih, Grace Liu, 請問是否幫您將問題轉達給系統負責同仁?' - # 無法取得,請user重新輸入 + strsql = ''' + select * + from (select c.user_name_e,c.user_name_c, b.user_email + from sec1117 a, sec1118 b,sec1102 c + where a.user_code = b.user_code + and a.user_code=c.user_code + and a.pic_type = 'B' + and a.system_code = :sys_code + order by a.pic_seq) + where rownum <= 3 + ''' + with util.get_db_conn() as conn: + res = conn.execute(strsql,sys_code=sys_code) + res = res.fetchall() + if len(res) == 0: + strRes = '無法取得指定系統負責人,請重新輸入' + else: + strRes = sys_code + '負責人是: ' + for row in res: + strRes += row[1]+'('+row[2]+'), ' + strRes += ' 請問是否幫您將問題轉給系統負責人?' return util.simple_response(text_content=strRes) +# 取消問題轉達給pic +def cancel_forward(fulfillment): + util.reset_all_contexts(fulfillmentObj=fulfillment) + return util.simple_response(fulfillmentObj={ + 'outputContexts': fulfillment.get('queryResult').get('outputContexts') + }) + + # 確認轉達問題給pic def confirm_forward(fulfillment): - print(fulfillment) return util.simple_response(fulfillmentObj={ 'followupEventInput': { 'name': 'events_forward_issue', @@ -39,3 +63,6 @@ def forward_issue(fulfillment): strRes = '好的' + user_name + '已將您的問題 "' + issue + '" 轉達給 ' + sys_code + ' 負責人' return util.simple_response(text_content=strRes) + +def init_app(app): + pass \ No newline at end of file diff --git a/back_end/bot_app/fulfillment/utility.py b/back_end/bot_app/fulfillment/utility.py index ef0beec..f382ee3 100644 --- a/back_end/bot_app/fulfillment/utility.py +++ b/back_end/bot_app/fulfillment/utility.py @@ -1,7 +1,11 @@ - from flask import jsonify +from sqlalchemy import create_engine + +db_engine = None + + def simple_response(text_content='', fulfillmentObj=None): - if not fulfillmentObj==None: + if not fulfillmentObj == None: jsonResp = fulfillmentObj else: jsonResp = { @@ -33,7 +37,45 @@ def simple_response(text_content='', fulfillmentObj=None): return jsonify(jsonResp) -def lookup_context(fulfillment,lookup_pattern): + +def lookup_context(fulfillment, lookup_pattern): contexts = fulfillment.get('queryResult').get('outputContexts') search_key = fulfillment.get('session') + '/contexts/' + lookup_pattern - return next((x for x in contexts if x['name']== search_key),None) \ No newline at end of file + return next((x for x in contexts if x['name'] == search_key), None) + + + +# 清除所有的Output Contexts +def reset_all_contexts(fulfillmentObj=None,context_list=[]): + if 'queryResult' in fulfillmentObj.keys(): + contexts = fulfillmentObj.get('queryResult').get('outputContexts') + else: + contexts = fulfillmentObj.get('outputContexts') + + for context in contexts: + if len(context_list) > 0: + if context['name'] in context_list: + context['lifespanCount'] = 0 + else: + context['lifespanCount'] = 0 + + return fulfillmentObj + + +def get_db_conn(): + try: + conn = db_engine.connect() + return conn + except Exception as e: + print(str(e)) + + +def init_app(app, pre_connect=True): + global db_engine + db_engine = create_engine(app.config['SQLALCHEMY_DATABASE_URI'], encoding='utf8') + pre_connect = app.config['DATABASE_CONNECT_OPTIONS']['PRE_CONNECT'] + if pre_connect: + try: + conn = db_engine.connect() + except Exception as e: + print(str(e)) diff --git a/back_end/bot_app/fulfillment/whl_family.py b/back_end/bot_app/fulfillment/whl_family.py index 0bbbc17..2905099 100644 --- a/back_end/bot_app/fulfillment/whl_family.py +++ b/back_end/bot_app/fulfillment/whl_family.py @@ -1,35 +1,41 @@ -# %% import requests from bs4 import BeautifulSoup as bs +import bot_app.fulfillment.utility as util +from datetime import datetime base_url = 'http://family.wanhai.com' -loginURL = base_url + '/Login.jsp' -account = 'M1933' -password = 'Whlm1933' +account = None +password = None payload = {'Account': account, 'Password': password} meeting_rooms = None massage_rooms = None session_req = None -# session_req.post(loginURL,data=payload) +def getSession(check_login=True): + global session_req + if session_req is None: + session_req = requests.Session() + if check_login and not isLogin(): + login(account, password) + return session_req + -# %% def login(id, pw): global session_req if session_req is None: session_req = requests.Session() res = session_req.post( - loginURL, data={'Account': account, 'Password': password}) + base_url + '/Login.jsp', data={'Account': id, 'Password': pw}) + print(res.request.headers['Cookie']) -# %% def isLogin(): global session_req if session_req is None: session_req = requests.Session() - route_url = base_url + '/MainPage.jsp' + route_url = base_url + '/LeaseEquip/equipListOnePage.jsp' res = session_req.get(route_url, allow_redirects=False) if res.status_code == 200: print(res.request.headers['Cookie']) @@ -38,10 +44,10 @@ def isLogin(): return False -# %% -def getEquipList(type='MEETING'): +# 取得可用設備列表 +def get_equip_list(type='MEETING'): equipList_url = base_url + '/LeaseEquip/equipListOnePage.jsp' - result = session_req.get( + result = getSession().get( equipList_url + '?file_num=61621&account_id=' + account + '&equip_type=' + type) print(result.request.headers['Cookie']) @@ -54,8 +60,8 @@ def getEquipList(type='MEETING'): return equipDict -# %% -def getEquipName(equipId): +# 取得設備名稱 +def get_equip_name(equipId): if equipId in meeting_rooms.keys(): return meeting_rooms[equipId]['name'] elif equipId in massage_rooms.keys(): @@ -64,31 +70,30 @@ def getEquipName(equipId): return None -# %% # 查詢設備是否已被占用(by 特定日期/時段) -def isEquipInUsed(b_date, b_time, e_time, equip_type, equip_id): +def is_equip_in_use(equip_id, b_date=datetime.today(), b_time=datetime.now(), e_time=datetime.now(), + equip_type='MEETING'): if equip_type == 'MASSAGE': print('Not Support Now!!!') return False equipUsageURL = base_url + '/LeaseEquip/equipUsage.jsp' - payload = [('q_from_date', b_date), - ('q_from_time', b_time), - ('q_to_date', b_date), - ('q_to_time', e_time), + payload = [('q_from_date', datetime.strftime(b_date, '%Y%m%d')), + ('q_from_time', datetime.strftime(b_time, '%H:%M:%S')), + ('q_to_date', datetime.strftime(b_date, '%Y%m%d')), + ('q_to_time', datetime.strftime(e_time, '%H:%M:%S')), ('q_equip_type', equip_type), ('ID_keyD', equip_id)] - result = session_req.post(equipUsageURL, data=payload) + result = getSession().post(equipUsageURL, data=payload) soup = bs(result.text, 'html.parser') elements = soup.select('td > b') - if (len(elements) > 1) and (not '目前無人預約' in elements[1].text): + if (len(elements) > 1) and ('目前無人預約' not in elements[1].text): return True else: return False return False -# %% -# 查詢設備可用時段(by 特定日期 +# 查詢設備可用時段(by 特定日期) def search_available_time(equip_type, equip_id, strDate): if equip_type == 'MASSAGE': print('Not Support Now!!!') @@ -107,7 +112,6 @@ def search_available_time(equip_type, equip_id, strDate): print('{}:\n{}'.format(equip_id, soup.select('td[nowrap]')[0].text)) -# %% # 查詢可用設備(by 特定日期/時段) def search_available_equips(equip_type, strDate, b_time, e_time): if equip_type == 'MASSAGE': @@ -122,7 +126,7 @@ def search_available_equips(equip_type, strDate, b_time, e_time): ('q_equip_type', equip_type)] payload.extend([('ID_keyD', e) for e in meeting_rooms.keys()]) - result = session_req.post(equipUsageURL, data=payload) + result = getSession().post(equipUsageURL, data=payload) soup = bs(result.text, 'html.parser') equips = [equip.text.strip() for equip in soup.select( 'div[id="equips"] td[align="center"]')] @@ -138,7 +142,7 @@ def search_available_equips(equip_type, strDate, b_time, e_time): map(lambda bb: [int(x) for x in bb], periods))] # print(equips[index]) - # for pp in periodIntvs: + # for pp in periodIntvs:ontext['lifespanCount'] = 0 # print(pp,'\n') for periodIntv in periodIntvs: @@ -152,9 +156,8 @@ def search_available_equips(equip_type, strDate, b_time, e_time): print('{}\n'.format(equips[index])) -# %% # 預約設備 -def bookingEquip(equip_id, equip_type, strDate, b_time, e_time): +def booking_equip(equip_id, equip_type, strDate, b_time, e_time): if equip_type == 'MASSAGE': print('Not Support Now!!!') bookingURL = base_url + '/LeaseEquip/equipBooking_db.jsp' @@ -184,14 +187,13 @@ def bookingEquip(equip_id, equip_type, strDate, b_time, e_time): # 'to_date': '20190606', # 'select_equips': equip_id } - soup = bs(session_req.post(bookingURL, data=payload).text, 'html.parser') + soup = bs(getSession().post(bookingURL, data=payload).text, 'html.parser') print(soup.select('table tr:nth-child(2) td:nth-child(5)')[0].text) # print(soup.prettify()) -# %% # 取消預約設備 -def cancalBookingEquip(equip_type, rent_no): +def cancel_booking(equip_type, rent_no): if equip_type == 'MASSAGE': print('Not Support Now!!!') bookingURL = base_url + '/LeaseEquip/userBooking_db.jsp' @@ -209,15 +211,14 @@ def cancalBookingEquip(equip_type, rent_no): # 'q_rent_no':'', # 'q_su_id':'' } - soup = bs(session_req.post(bookingURL, data=payload).text, 'html.parser') + soup = bs(getSession().post(bookingURL, data=payload).text, 'html.parser') print(soup.prettify()) -# %% # 列出個人設備預約紀錄 -def listRentedEquips(): +def get_rented_equips(): equipList_url = base_url + '/LeaseEquip/equipListOnePage.jsp' - result = session_req.get( + result = getSession().get( equipList_url + '?file_num=61621&account_id=' + account + '&equip_type=MEETING') soup = bs(result.text, 'html.parser') elements = soup.select('form[name="dataForm1"] input[name^="i_rent_no"]') @@ -227,31 +228,53 @@ def listRentedEquips(): return rentedList -# %% -# listRentedEquips() - -# %% -# equipId = 'CF15-10F-DN-01' -# print(getEquipName(equipId)) -# inUsed = isEquipInUsed('20190606', '1900', '2000', 'MEETING', equipId) -# print('Equip in used? {}'.format(inUsed)) -# %% -# search_available_equips('MEETING', '20190624', '0900', '1200') -# %% -# search_available_time('MEETING', 'CF01-9F', '20190624') - -# %% -# if not isLogin(): -# login(account, password) -# meeting_rooms = getEquipList('MEETING') -# massage_rooms = getEquipList('MASSAGE') -# -# for x in meeting_rooms: -# print(x, meeting_rooms.get(x)) -# print('\n') -# for x in massage_rooms: -# print(x, massage_rooms.get(x)) - -# %% -if __name__ == '__main__': - pass +def list_rented_equips(fulfillment): + rented_list = get_rented_equips() + if len(rented_list) == 0: + return util.simple_response(text_content=u'您目前沒有預約任何的設備') + else: + str_rented_list = u'您預約的設備如下:\n' + str_rented_list += ', \n'.join([x[2] + ' ' + x[3] + ' ' + x[1] for x in rented_list]) + return util.simple_response(text_content=str_rented_list) + + +def list_all_meeting_rooms(fulfillment): + global meeting_rooms + str_meeting_rooms = ', \n'.join([x['id'] + x['name'] for x in meeting_rooms.values()]) + return util.simple_response(text_content=str_meeting_rooms) + + +def check_equip_in_use(fulfillment): + try: + date_pattern = '%Y-%m-%dT%H%M%S%z' + params = fulfillment.get('queryResult').get('parameters') + meeting_room = params.get('meeting_room') + date = datetime.strptime(params.get('date').replace(':', ''), date_pattern) + start_time = datetime.strptime(params.get('time-period').get('startTime').replace(':', ''), date_pattern) + end_time = datetime.strptime(params.get('time-period').get('endTime').replace(':', ''), date_pattern) + meeting_room_id = next([x['id'] for x in meeting_rooms if x['name'].find(meeting_room) >= 0], None) + + if is_equip_in_use(meeting_room_id, date, start_time, end_time): + return util.simple_response(text_content=meeting_room+u'已經被人預約') + else: + return util.simple_response(text_content=meeting_room+u'尚未被預約') + + except Exception as e: + return util.simple_response(text_content=str(e)) + pass + + +def greet_cancel(fulfillment): + util.reset_all_contexts(fulfillment) + return util.simple_response(fulfillmentObj={ + 'fulfillmentText': '好的,沒有問題!', + 'outputContexts': fulfillment.get('queryResult').get('outputContexts') + }) + + +def init_app(app): + global password, account, meeting_rooms + account = app.config['WHL_FAMILY_ID'] + password = app.config['WHL_FAMILY_PW'] + login(account, password) + meeting_rooms = get_equip_list() diff --git a/back_end/config.py b/back_end/config.py index 63fc5fe..739c298 100644 --- a/back_end/config.py +++ b/back_end/config.py @@ -8,8 +8,13 @@ BASE_DIR = os.path.abspath(os.path.dirname(__file__)) # Define the database - we are working with # SQLite for this example -SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(BASE_DIR, 'app.db') -DATABASE_CONNECT_OPTIONS = {} +SQLALCHEMY_DATABASE_URI = 'oracle+cx_oracle://whpr:w2t2pr0614@tpe3.wanhai.com:1526/whl2' +DATABASE_CONNECT_OPTIONS = { + "PRE_CONNECT": False +} + +WHL_FAMILY_ID = 'M1933' +WHL_FAMILY_PW = 'Whlm1933' # Application threads. A common general assumption is # using 2 per available processor cores - to handle diff --git a/back_end/requirements.txt b/back_end/requirements.txt index 7667f53..9cc1947 100644 --- a/back_end/requirements.txt +++ b/back_end/requirements.txt @@ -2,4 +2,6 @@ dialogflow==0.6.0 interval==1.0.0 requests==2.22.0 beautifulsoup4==4.7.1 -flask==1.0.3 \ No newline at end of file +flask==1.0.3 +cx-Oracle==7.2.2 +SQLAlchemy==1.3.8 \ No newline at end of file diff --git a/credential/qa_bot_auth.json b/credential/qa_bot_auth.json deleted file mode 100644 index 539f80a..0000000 --- a/credential/qa_bot_auth.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "type": "service_account", - "project_id": "test-bot-wsdwyh", - "private_key_id": "54df4317d1f679ce3c5a5c533c5ad64b20f5d238", - "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCij2tnfO1/kbq2\naROOVYTT1rIKMuf6G4wcUnOYaS0gLvu1w6WqO0zVN+nafIFGlAkgD7kHwJD8yv8Z\nH1/+4n3TQg5pJCthSB4NLHYwbP3p3tlVyJgdZ+MG8Qx04qLeQzaenq9l4MgL26qs\nGROVeeVfNNxugW7q2UHwmRZ89QtVhZxoHvjcmFLZD85duhifE+6JDBUe+SHUBfyl\nLIiKOD0+8c99IY+VLB+OEzFotEO1DWU7KKRIwVhW0qHChgXRzOmo1X5V1fIqyLaC\nouZkIdLK93nYkIO4S+H2j9svrMCyh3lH/iSxQtt/A+JmKnuCIed+rgKkLQJHaxes\n3uZZaLxFAgMBAAECggEAHu/tkGHxryQUZS/FNYLoBwrmklNS28IPXbqBXmGx4Vyf\nsd18s1Oa0T9VZavpTH3S6MOlQqjuzvVxLB5Q/iirqp95L6BfEyIO+hHaomezwSUU\ntqM48+u4BLOuW7ZgKa2gAPsRRXHMkJkrN5qEJB/xO7fLNcqzScW0K25vHbPjBtDb\nXqF21Uvf3IFrCc+qfS2YlommO0D2kiQP2IM8q4x0nESSyClyX37TurfbTYjQDIn9\nVR8fQG8YriWewJ8O/cxKoZ3y5fzdplj+UbFvbYJEMWl6VREvuYP+gHlfqDawtwYE\n60a8Y6tIkN9qpye7wOiPPwHgsgXsXSH/Gzjt4DXGAQKBgQDeStq6ZQJWGOVrzBHD\nS1fzAMfBb9KAmRb+Jku2K4N4LDTh9ON9CMKMCdgk10btPBrGUYaRAksUQJ3Bg3JB\nuSYr1Clj9UgDoXbkWyCgEIU5EsLF2NmuM3UOTkLslSGWSrC0Vy5MC2m63kxYusyX\nrjxCd51BHuPGBQR3eLk2VmxNRQKBgQC7NdQN45XCH30pfnuc8+vPmxAle+qGhlxc\n2SVpv1NijEDfb9VXlgY62NAktTh5OX5RTgMm0GTmOwCCEnBaSCQHTWuNFVMFkk6D\nUDm/IOkdNdY7J/axLMrB9INSLf/c5fNxseDreKsylYf1vj3xxYslY/r0PYcXG5H1\nsl2tm3wjAQKBgQCEdKAOzx9sRBt4dzniX+PBJabhqYsKG66qtBELNLR7CARe27gu\nCek63qbPlQNrWxQtNej0QSSRpcsawwNzDCsllJ8xM7e8ihq5CV/QYOexUW+Dyqoy\n9fB7HMEeDeLclhbi7svkfix7L/jYKj685xJ7HKE0a36XwOefdO0P5sFT7QKBgF0d\nf/TMjw94BBQgcjF17YNcWCKcyODScZxI8V/wpvPsWNQJ1u5yk3SvpI+th4JcQ2UD\nTXP/0T/mdvE7ZKCzIyBytJz+z0WFKQINZDuZjflWbtELppsncU4ZZTv53zqrMXQK\nipn0cgp975seXcckf3pAiXD0LX4j22x+pDOWk58BAoGAYcywt3jifvKdXbcRE+Wo\nJ/jAgWY2p722bESE2DD0hpsOEwdFPPwG8vr5reEb+PegxLsv7c4vXdemOmj52PEC\nxPDvQEmuKTnA/ORkJT3jEVKYx7Hu9KODlSDTjWM5G9HPevWuJKV6qrmXIbum6L3U\nq7w75gocGx4de/uY0w5Ysyw=\n-----END PRIVATE KEY-----\n", - "client_email": "dialogflow-joojtu@test-bot-wsdwyh.iam.gserviceaccount.com", - "client_id": "118072988943548920832", - "auth_uri": "https://accounts.google.com/o/oauth2/auth", - "token_uri": "https://oauth2.googleapis.com/token", - "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs", - "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/dialogflow-joojtu%40test-bot-wsdwyh.iam.gserviceaccount.com" -} diff --git a/back_end/bot_app/fulfillment/detect_intent_texts.py b/front_end/detect_intent_texts.py similarity index 100% rename from back_end/bot_app/fulfillment/detect_intent_texts.py rename to front_end/detect_intent_texts.py diff --git a/resources/entities/dept_code.csv b/resources/entities/dept_code.csv new file mode 100644 index 0000000..4e4d181 --- /dev/null +++ b/resources/entities/dept_code.csv @@ -0,0 +1,238 @@ +"A","A","a","SALES DIVISION","營業部" +"A1","A1","a1","文件課","文件課" +"A2","A2","a2","客戶服務課","客戶服務課" +"A3","A3","a3","星馬課","星馬課" +"A4","A4","a4","韓泰課","韓泰課" +"A5","A5","a5","香港線課","香港線課" +"A6","A6","a6","日本進口課","日本進口課" +"A7","A7","a7","日本出口課","日本出口課" +"A8D","A8D","a8d","行銷處/海外文業組","行銷處/海外文業組" +"A8H","A8H","a8h","行銷處/海外營運香港大陸組","行銷處/海外營運香港大陸組" +"A8N","A8N","a8n","行銷處/海外營運東北亞組","行銷處/海外營運東北亞組" +"A8P","A8P","a8p","行銷處/價格策略組","行銷處/價格策略組" +"A8S","A8S","a8s","行銷處/海外營運東南亞組","行銷處/海外營運東南亞組" +"A8U","A8U","a8u","行銷處/美洲業務組","行銷處/美洲業務組" +"A8W","A8W","a8w","行銷處/海外營運西南亞組","行銷處/海外營運西南亞組" +"A9","A9","a9","印菲越課","印菲越課" +"AA","AA","aa","代理課","代理課" +"AABC","AABC","aabc","CHINA TRADE DEPARTMENT","大陸課" +"AABD","AABD","aabd","DOCUMENTATION DEPARTMENT","文件課" +"AABH","AABH","aabh","香港課","香港課" +"AABHT","AABHT","aabht","HKG/THA TRADE DEPARTMENT","港泰課" +"AABI1","AABI1","aabi1","INBOUND TRADE DEPARTMENT I","進口一課" +"AABI2","AABI2","aabi2","INBOUND TRADE DEPARTMENT II","進口二課" +"AABJ","AABJ","aabj","日韓課","日韓課" +"AABJKV","AABJKV","aabjkv","日韓越課","日韓越課" +"AABP","AABP","aabp","PROJECT AND DELTA TRADE DEPARTMENT","專案業務課" +"AABS","AABS","aabs","星馬西亞課","星馬西亞課" +"AABSEW","AABSEW","aabsew","SOUTH EAST &WEST ASIA DEPARTMENT","東南西亞課" +"AABV","AABV","aabv","印菲越泰課","印菲越泰課" +"AAGLH","AAGLH","aaglh","GENERAL LONG HAUL DEPARTMENT","綜合遠洋課" +"AAMCSA","AAMCSA","aamcsa","CENTRAL & SOUTH AMERICA DEPARTMENT","中南美課" +"AAME","AAME","aame","EUROPEAN BUSINESS DEPARTMENT","歐洲業務課" +"AAMGD","AAMGD","aamgd","GLOBAL DOCUMENT&PROJECT DEPARTMENT","海外專案業務課" +"AAMH","AAMH","aamh","HKG/CHINA MARKETING DEPARTMENT","香港中國課" +"AAMI","AAMI","aami","INDIA MARKETING DEPARTMENT","印度課" +"AAMIR","AAMIR","aamir","INDIA,RED SEA MARKETING DEPARTMENT","印度紅海課" +"AAMLM","AAMLM","aamlm","LINE MANAGEMENT DEPARTMENT","航線管理課" +"AAMME","AAMME","aamme","MIDDLE EAST MARKETING DEPARTMENT","中東課" +"AAMN","AAMN","aamn","N.E.A. MARKETING DEPARTMENT","東北亞課" +"AAMNA","AAMNA","aamna","NORTH AMERICAN DEPARTMENT","美西課" +"AAMNA1","AAMNA1","aamna1","NORTH AMERICA DEPARTMENT","北美課" +"AAMR","AAMR","aamr","冷凍櫃業務課","冷凍櫃業務課" +"AAMS","AAMS","aams","東南亞課","東南亞課" +"AAMS-1","AAMS-1","aams-1","S.E.A. MARKETING SECTION I","東南亞一課" +"AAMS-2","AAMS-2","aams-2","S.E.A. MARKETING SECTION II","東南亞二課" +"AAMSA","AAMSA","aamsa","SOUTH AMERICAN DEPARTMENT","南美課" +"AAMSEB","AAMSEB","aamseb","SPECIAL EQUIPMENT BUSINESS DEPARTMENT","特殊櫃業務課" +"AAMU","AAMU","aamu","AMERICAN BUSINESS DEPARTMENT","美洲業務課" +"AAMW","AAMW","aamw","M.E./I.S.C. MARKETING DEPARTMENT","西南亞課" +"AANEA","AANEA","aanea","N.E.A. DEPARTMENT","東北亞課" +"AASEA","AASEA","aasea","S.E.A. DEPARTMENT","東南亞課" +"AB","AB","ab","特殊櫃課","特殊櫃課" +"ABC","ABC","abc","OFFICE OF THE CHAIRMAN","董事長室" +"AC","AC","ac","東北亞出口課","東北亞出口課" +"AD","AD","ad","印菲越出口課","印菲越出口課" +"AE","AE","ae","港泰出口課","港泰出口課" +"AF","AF","af","星馬出口課","星馬出口課" +"AG","AG","ag","CHINA TRADE DEPARTMENT","大陸課" +"AH","AH","ah","東南亞進口課","東南亞進口課" +"AI","AI","ai","東北亞進口課","東北亞進口課" +"AJ","AJ","aj","中東印巴課","中東印巴課" +"AK","AK","ak","N.E.A. MARKETING DEPARTMENT","東北亞課" +"AL","AL","al","星馬西亞課","星馬西亞課" +"AM","AM","am","HKG/THA TRADE DEPARTMENT","港泰課" +"AM1","AM1","am1","MARKETING DEPARTMENT","行銷部" +"AN","AN","an","印菲越課","印菲越課" +"AO1","AO1","ao1","進口課﹝東南亞/中東印巴﹞","進口課﹝東南亞/中東印巴﹞" +"AO2","AO2","ao2","進口課﹝日/韓課﹞","進口課﹝日/韓課﹞" +"AP","AP","ap","印菲越泰課","印菲越泰課" +"AQ","AQ","aq","香港課","香港課" +"AR","AR","ar","專案業務課","專案業務課" +"B","B","b","OPERATION DIVISION","作業部" +"B1","B1","b1","長 春","長 春" +"B2","B2","b2","貨損理賠課","貨損理賠課" +"B3","B3","b3","VESSEL OPERATION SECTION","運務課" +"B3-1","B3-1","b3-1","VESSEL OPERATION DEPARTMENT I","運務一課" +"B3-2","B3-2","b3-2","VESSEL OPERATION DEPARTMENT II","運務二課" +"B3-3","B3-3","b3-3","VESSEL OPERATION DEPARTMENT III","運務三課" +"B4","B4","b4","櫃務課","櫃務課" +"B5","B5","b5","代理課","代理課" +"B6","B6","b6","EQUIPMENT M&R DEPARTMENT","維修課" +"B7","B7","b7","KEELUNG OFFICE","西17" +"B8","B8","b8","場棧課","場棧課" +"BELS","BELS","bels","EQUIPMENT LOGISTICS DEPARTMENT","貨櫃調度課" +"BEMS","BEMS","bems","EQUIPMENT MANAGEMENT DEPARTMENT","貨櫃管理課" +"BKOD","BKOD","bkod","KEELUNG OPERATION DEPARTMENT","基隆作業課" +"C","C","c","代理部","代理部" +"CS","CS","cs","CUSTOMER SERVICE DIVISION","客戶服務部" +"CSD","CSD","csd","DOCUMENTATION DEPARTMENT","文件課" +"CSS","CSS","css","CUSTOMER SERVICE DEPARTMENT","客戶服務課" +"D","D","d","MARINE DEPARTMENT","船務部" +"D1","D1","d1","CREW SECTION","船員課" +"D1-1","D1-1","d1-1","CREW HUMAN RESOURCE DEPARTMENT","船員人力資源課" +"D1-1-1","D1-1-1","d1-1-1","CREW MANAGEMENT DEPARTMENT Ⅰ","船員管理一課" +"D1-2","D1-2","d1-2","CREW SERVICE DEPARTMENT","船員服務課" +"D1-2-1","D1-2-1","d1-2-1","CREW MANAGEMENT DEPARTMENT Ⅱ","船員管理二課" +"D2","D2","d2","船舶維修課","船舶維修課" +"D2-1","D2-1","d2-1","MARINE M&R SECTION I","維修一課" +"D2-2","D2-2","d2-2","MARINE M&R SECTION II","維修二課" +"D2-3","D2-3","d2-3","MARINE GENERAL AFFAIR SECTION","總務組" +"D3","D3","d3","物料保險課","物料保險課" +"D4","D4","d4","SUPPLY DEPARTMENT","物料課" +"D5","D5","d5","MARITECH DEPARTMENT","海技課" +"D6","D6","d6","CHARTERING SECTION","租船課" +"D7","D7","d7","FLEET EFFICIENCY MANAGEMENT DEPARTMENT","FLEET EFFICIENCY MANAGEMENT DEPARTMENT" +"DB","DB","db","Documentation Business Division","文件營運部" +"DBCS","DBCS","dbcs","COUNTER SERVICE DEPARTMENT","櫃檯服務課" +"DBDS","DBDS","dbds","DOCUMENTATION SERVICE DEPARTMENT","文件服務課" +"DC","DC","dc","回海勤","回海勤" +"E","E","e","FINANCE DEPARTMENT","財務部" +"E1","E1","e1","TREASURY DEPARTMENT","資金課" +"E2","E2","e2","會計課","會計課" +"E2-1","E2-1","e2-1","GENERAL ACCOUNTING DEPARTMENT","國內會計課" +"E3","E3","e3","核帳課","核帳課" +"E4","E4","e4","國外會計課","國外會計課" +"E4-1","E4-1","e4-1","INTERNATIONAL ACCOUNTING DEPARTMENTⅠ","近洋會計課" +"E4-1-1","E4-1-1","e4-1-1","INTERNATIONAL ACCOUNTING DEPARTMENT I-1","近洋會計一課" +"E4-1-2","E4-1-2","e4-1-2","INTERNATIONAL ACCOUNTING DEPARTMENT I-2","近洋會計二課" +"E4-2","E4-2","e4-2","INTERNATIONAL ACCOUNTING DEPARTMENTⅡ","遠洋會計課" +"E5","E5","e5","FINANCIAL MANAGEMENT DEPARTMENT","財務管理課" +"EN","EN","en","ENGINEERING DIVISION","工務部" +"EN1-1","EN1-1","en1-1","SHIP M & R DEPARTMENT Ⅰ","維修一課" +"EN1-2","EN1-2","en1-2","SHIP M & R DEPARTMENT Ⅱ","維修二課" +"ENMS","ENMS","enms","MACHINERY & SPARE PARTS MANAGEMENT DEPAR","機配件運籌課" +"ENST","ENST","enst","SHIP TECHNOLOGY DEPARTMENT","船舶技術課" +"F","F","f","ADMINISTRATION DIVISION","管理部" +"F1","F1","f1","GENERAL AFFAIRS DEPARTMENT","總務課" +"F2","F2","f2","PERSONNEL SERVICE DEPARTMENT","人事課" +"F2-1","F2-1","f2-1","PERSONNEL SERVICE DEPARTMENT","人事服務課" +"F2-2","F2-2","f2-2","HUMAN RESOURCEDEVELOPMENT DEPARTMENT","人力資源發展課" +"F3","F3","f3","DOCUMENTATION SECTION","文件課" +"F4","F4","f4","CUSTOMER SERVICE SECTION","客戶服務課" +"FRD","FRD","frd","FLEET RISK MANAGEMENT DEPARTMENT","船隊風險管理課" +"G1","G1","g1","台中/營業","台中/營業" +"G2","G2","g2","台中/文件","台中/文件" +"H","H","h","KAOHSIUNG BRANCH","高雄" +"H1","H1","h1","MARKETING DEPARTMENT","營業課" +"H1-1","H1-1","h1-1","營業課/文件出口組","營業課/文件出口組" +"H1-2","H1-2","h1-2","營業課/文件進口組","營業課/文件進口組" +"H1IT","H1IT","h1it","INBOUND TRADE DEPARTMENT","進口課" +"H1OT","H1OT","h1ot","OUTBOUND TRADE DEPARTMENT","出口課" +"H2","H2","h2","MARINE DEPARTMENT","船務課" +"H3","H3","h3","GENERAL AFFAIRS DEPARTMENT","總務課" +"H4","H4","h4","ADMINISTRATION DEPARTMENT","管理課" +"I","I","i","INFORMATION TECHNOLOGY DEPARTMENT","資訊科技部" +"I1","I1","i1","SYSTEM DEPARTMENT I","系統設計一課" +"I2","I2","i2","SYSTEM DEPARTMENT II","系統設計二課" +"I3A","I3A","i3a","資料運算課/資料組","資料運算課/資料組" +"I3B","I3B","i3b","資料運算課","資料運算課" +"IIA","IIA","iia","INFORMATION APPLICATION DEPARTMENT","資訊應用課" +"IQA","IQA","iqa","QUALITY ASSURANCE DEPARTMENT","系統品管課" +"ISS","ISS","iss","SYSTEM SERVICE DEPARTMENT","系統服務課" +"J","J","j","企劃室","企劃室" +"J1","J1","j1","企劃課","企劃課" +"J1A","J1A","j1a","企劃課一組","企劃課一組" +"J1B","J1B","j1b","企劃課二組","企劃課二組" +"J1C","J1C","j1c","企劃課三組","企劃課三組" +"J1D","J1D","j1d","企劃課四組","企劃課四組" +"J1E","J1E","j1e","企劃課五組","企劃課五組" +"J2","J2","j2","駐外人員","駐外人員" +"J4","J4","j4","LEGAL AFFAIRS &INSURANCE DEPARTMENT","法務保險課" +"J5","J5","j5","CHARTERING DEPARTMENT","租船課" +"JJ","JJ","jj","PLANNING DIVISION","企劃部" +"JJ1","JJ1","jj1","企劃課","企劃課" +"JJ1A","JJ1A","jj1a","企劃課一組","企劃課一組" +"JJ1B","JJ1B","jj1b","企劃課二組","企劃課二組" +"JJ1C","JJ1C","jj1c","企劃課三組","企劃課三組" +"JJ1D","JJ1D","jj1d","企劃課四組","企劃課四組" +"JJ2","JJ2","jj2","駐外人員","駐外人員" +"JJ3","JJ3","jj3","CHARTERING DEPARTMENT","租船課" +"JJ4","JJ4","jj4","LEGAL AFFAIRS&INSURANCE DEPARTMENT","法務保險課" +"JJAB","JJAB","jjab","AGENCY BUSINESS DEPARTMENT","代理行業務課" +"JJAI","JJAI","jjai","ASSET INVESTMENT DEPARTMENT","資產投資課" +"JJBCS","JJBCS","jjbcs","BUSINESS COOPERATION DEPARTMENT","聯營合作課" +"JJEB","JJEB","jjeb","ELECTRONIC BUSINESS DEPARTMENT","電子商務課" +"JJP1","JJP1","jjp1","企劃一課","企劃一課" +"JJP2","JJP2","jjp2","企劃二課","企劃二課" +"JJSDS","JJSDS","jjsds","SERVICE DEVELOPMENT DEPARTMENT","航線規劃課" +"JJST","JJST","jjst","SHIP TECHNOLOGY TEAM","船舶技術組" +"L","L","l","香 港","香 港" +"M","M","m","怡 春","怡 春" +"M1","M1","m1","貨運承攬課","貨運承攬課" +"M2","M2","m2","IAL","IAL" +"M2-KHH","M2-KHH","m2-khh","IAL/高雄","IAL/高雄" +"M2-TPE","M2-TPE","m2-tpe","IAL/台北","IAL/台北" +"M2-TXG","M2-TXG","m2-txg","IAL/台中","IAL/台中" +"M3","M3","m3","怡春/財務部","怡春/財務部" +"M4","M4","m4","怡春/管理部","怡春/管理部" +"M5","M5","m5","怡春/高雄碼頭","怡春/高雄碼頭" +"M6","M6","m6","怡春/ 資訊科技部","怡春/ 資訊科技部" +"M7","M7","m7","怡春/台中碼頭","怡春/台中碼頭" +"M8","M8","m8","怡春/船務部","怡春/船務部" +"M9","M9","m9","怡春/作業部","怡春/作業部" +"MT","MT","mt","MARINE TECHNOLOGY","海技部" +"MT1","MT1","mt1","SHIP SAFETY MANAGEMENT DEPARTMENT I","船舶管理一課" +"MT2","MT2","mt2","SHIP SAFETY MANAGEMENT DEPARTMENT II","船舶管理二課" +"MT3","MT3","mt3","FLEET EFFICIENCY MANAGEMENT DEPARTMENT","船隊效益管理課" +"MT4","MT4","mt4","FLEET RISK MANAGEMENT DEPARTMENT","船隊風險管理課" +"P","P","p","KAOHSIUNG TERMINAL","高雄碼頭" +"P1","P1","p1","CONTAINER YARD OPERATION DEPARTMENT","場務課" +"P2","P2","p2","EQUIPMENT CONTROL DEPARTMENT","管制課" +"P2-1","P2-1","p2-1","EQUIPMENT CONTROL DEPARTMENT I","管制一課" +"P2-2","P2-2","p2-2","EQUIPMENT CONTROL DEPARTMENT II","管制二課" +"P3","P3","p3","MAINTENANCE DEPARTMENT","維修課" +"P4","P4","p4","GENERAL AFFAIRS DEPARTMENT","總務課" +"P5","P5","p5","SHIPSIDE OPERATION DEPARTMENT","作業課" +"P6","P6","p6","#57W維修課","#57W維修課" +"P7","P7","p7","OCCUPATIONAL SAFETY & HEALTH","勞安管理課" +"P8","P8","p8","MARINE DEPARTMENT","船務課" +"Q","Q","q","AUDITING DIVISION","稽核室" +"SRM","SRM","srm","OCCUPATIONAL SAFETY AND HEALTH/RISK MAN","勞安風管部" +"SRM1","SRM1","srm1","LEGAL AFFAIRS & INSURANCE DEPARTMENT","法務保險課" +"SRM2","SRM2","srm2","OCCUPATIONAL SAFETY AND HEALTH DEPARTMEN","勞安管理課" +"V","V","v","OFFICE OF THE CHAIRMAN","總經理室" +"V1","V1","v1","美洲線研發處","美洲線研發處" +"V2","V2","v2","駐外代表","駐外代表" +"V3","V3","v3","MANAGEMENT RESEARCH & DEVELOPMENT UNIT","經營研究處" +"V4","V4","v4","STRATEGY RESEARCH UNIT","策略研究處" +"V5","V5","v5","EFFICIENCY IMPROVEMENT RESEARCH & DEVELO","效率提升研究處" +"V6","V6","v6","INVESTMENT RESEARCH & DEVELOPMENT UNIT","投資事業處" +"V7","V7","v7","LINE MANAGEMENT UNIT","航線管理處" +"W","W","w","TERMINAL DEPARTMENT","碼頭事業部" +"W1","W1","w1","BUSINESS PROJECT DEPARTMENT","業務課" +"W1-1","W1-1","w1-1","BUSINESS PROJECT DEPARTMENT Ⅰ","業務一課" +"W1-2","W1-2","w1-2","BUSINESS PROJECT DEPARTMENTⅡ","業務二課" +"W2","W2","w2","EFFCIENCY MANAGEMENT","場務課" +"W2-1","W2-1","w2-1","Efficiency Management Department Ⅰ","場務一課" +"W2-2","W2-2","w2-2","Efficiency Management Department Ⅱ","場務二課" +"WHCF","WHCF","whcf","基金會","基金會" +"X","X","x","TAICHUNG TERMINAL","台中碼頭" +"X1","X1","x1","ADMINISTRATION SECTION","管理課" +"X1-1","X1-1","x1-1","GENERAL AFFAIRS SECTION","總務課" +"X1-2","X1-2","x1-2","SUPPLY DEPARTMENT","物料課" +"X2","X2","x2","DOCUMENTATION SECTION","文件課" +"X3","X3","x3","COOPERATE BUSINESS DEPARTMENT","營運課" +"X4","X4","x4","OCCUPATIONAL SAFETY AND HEALTH DEPARTMEN","勞安管理課" +"Y","Y","y","其它","其它" +"Z","Z","z","離職","離職" diff --git a/resources/entities/dept_code.sql b/resources/entities/dept_code.sql new file mode 100644 index 0000000..e666ef1 --- /dev/null +++ b/resources/entities/dept_code.sql @@ -0,0 +1,3 @@ +select '"' || dept_code || '",'||'"'||dept_code||'",' || '"' || lower(dept_code) || '",' || '"' || + dept_name_e || '",' || '"' || dept_name_c || '"' + from v_sec_1004 where office_code = 'TWTPE01' \ No newline at end of file diff --git a/resources/entities/div_code.csv b/resources/entities/div_code.csv new file mode 100644 index 0000000..76f05a8 --- /dev/null +++ b/resources/entities/div_code.csv @@ -0,0 +1,52 @@ +"A","A","a","SALES DIVISION","營業部" +"AB","AB","ab","OFFICE OF THE CHAIRMAN","董事長室" +"AC","AC","ac","副董事長","副董事長" +"AE","AE","ae","副總經理室","副總經理室" +"AM","AM","am","MARKETING DIVISION","行銷部" +"B","B","b","OPERATION DIVISION","作業部" +"C","C","c","代理部","代理部" +"CS","CS","cs","CUSTOMER SERVICE DIVISION","客戶服務部" +"D","D","d","MARINE DIVISION","船務部" +"DB","DB","db","DOCUMENTATATION BUSINESS DIVISION","文件營運部" +"DC","DC","dc","海勤","海勤" +"E","E","e","FINANCE DIVISION","財務部" +"EA","EA","ea","出納室","出納室" +"EN","EN","en","ENGINEERING DIVISION","工務部" +"F","F","f","ADMINISTRATION DIVISION","管理部" +"G","G","g","TAICHUNG BRANCH","台中" +"H","H","h","KAOHSINUG BRANCH","高雄" +"I","I","i","INFORMATION TECHNOLOGY DIVISION","資訊科技部" +"J","J","j","企劃室","企劃室" +"JJ","JJ","jj","PLANNING DIVISION","企劃部" +"K","K","k","日本","日本" +"L","L","l","香港","香港" +"LO","LO","lo","吉洋","吉洋" +"M","M","m","怡春","怡春" +"M2","M2","m2","怡春/IAL","怡春/IAL" +"M2-1","M2-1","m2-1","怡春/台北","怡春/台北" +"M2-2","M2-2","m2-2","怡春/高雄","怡春/高雄" +"M2-3","M2-3","m2-3","怡春/台中","怡春/台中" +"M3","M3","m3","怡春/財務部","怡春/財務部" +"M4","M4","m4","怡春/管理部","怡春/管理部" +"M5","M5","m5","怡春/高雄碼頭","怡春/高雄碼頭" +"M6","M6","m6","怡春/資訊科技部","怡春/資訊科技部" +"M7","M7","m7","怡春/台中碼頭","怡春/台中碼頭" +"M8","M8","m8","怡春/船務部","怡春/船務部" +"M9","M9","m9","怡春/作業部","怡春/作業部" +"MT","MT","mt","MARINE TECHNOLOGY DIVISION","海技部" +"N","N","n","韓國","韓國" +"O","O","o","泰國","泰國" +"P","P","p","KAOHSIUNG TERMINAL","高雄碼頭" +"Q","Q","q","AUDITING DIVISION","稽核室" +"R","R","r","印尼","印尼" +"S","S","s","馬來西亞","馬來西亞" +"SRM","SRM","srm","OCCUPATIONAL SAFETY AND HEALTH/RISK MAN","勞安風管部" +"T","T","t","新加坡","新加坡" +"U","U","u","菲律賓","菲律賓" +"V","V","v","OFFICE OF THE PRESIDENT","總經理室" +"W","W","w","TERMINAL DIVISION","碼頭事業部" +"WHCF","WHCF","whcf","基金會","基金會" +"X","X","x","TAICHUNG TERMINAL","台中碼頭" +"Y","Y","y","其它","其它" +"Z","Z","z","離職","離職" +"ZZ","ZZ","zz","回岸勤","回岸勤" diff --git a/resources/entities/div_code.sql b/resources/entities/div_code.sql new file mode 100644 index 0000000..de8af6f --- /dev/null +++ b/resources/entities/div_code.sql @@ -0,0 +1,3 @@ +select '"' || div_code || '",'||'"'||div_code||'",' || '"' || lower(div_code) || '",' || '"' || + div_name_e || '",' || '"' || div_name_c || '"' + from v_sec_1003 where office_code = 'TWTPE01' \ No newline at end of file