123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617 |
- import time
- from fastapi import FastAPI
- import sys
- import os
- import datetime
- import ast
- from fastapi.responses import JSONResponse, FileResponse
- from fastapi.middleware.cors import CORSMiddleware
- from pydantic import BaseModel
- import uvicorn
- from fastapi.staticfiles import StaticFiles
- import markdown
- from fastapi import Request, APIRouter
- from fastapi.responses import HTMLResponse
- from fastapi.templating import Jinja2Templates
- templates = Jinja2Templates(directory="templates")
- def openfile(filename):
- filepath = os.path.join("page/", filename)
- with open(filepath, "r", encoding="utf-8") as input_file:
- text = input_file.read()
- html = markdown.markdown(text)
- data = {
- "page": html
- }
- return data
- description = """
- 長慶運通系統設計
- ## Items
- You can **read items**.
- ## Users
- 
- You will be able to:
- * **Create users** (_not implemented_).
- * **Read users** (_not implemented_).
- """
- app = FastAPI(description=description)
- app.mount("/imgs", StaticFiles(directory="imgs"), name="imgs")
- origins = [
- "http://www.googo.org",
- "http://www.googo.org:8080",
- "http://0.0.0.0:8080",
- "http://googo.org:8080",
- "http://googo.org",
- "http://139.162.121.30"
- ]
- #uvicorn main:app --host 0.0.0.0 --port 8001
- app.add_middleware(
- CORSMiddleware,
- allow_origins=origins,
- allow_credentials=True,
- allow_methods=["*"],
- allow_headers=["*"],
- )
- @app.get("/page/{page_name}", response_class=HTMLResponse)
- async def show_page(request: Request, page_name: str):
- data = openfile(page_name+".md")
- print(data)
- return templates.TemplateResponse("page.html", {"request": request, "data": data})
- class q_req(BaseModel):
- domain_name: str
- class kw_req(BaseModel):
- fullurl: str
- shorturl: str
- class upload_orders_item(BaseModel):
- objtype: str
- channel_id: str
- customer_contract_id: str
- shipment_type:str
- ship_date:str
- class shipping_details(BaseModel):
- filed_date: str
- channel_id: str
- customer_contract_id: str
- shipment_type:str
- ship_date:str
-
- @app.post("/op_doc/upload_orders",
- summary="訂單明細上傳",
- description=
- """
- parameters:
- 訂單明細上傳(Excel格式)
- - current_insite: 收單營業所
- - transport_type: 配送類別
- - transport_id: 通路代碼
- - transport_site: 入單營業所
- - transport_contract_id: 客契代碼
- - transport_no: 配送單號
-
- - shipment_no: 運單號碼
- - shipment_type: 運單種類(一單到底/換單)
- - shipment_2: 是否二配
- - shipment_date: 出貨日期
-
- - package_id: 袋號
- - order_id: 訂單編號
- - sender_data: 送件人資料
- {
- sender_name: 送件人姓名
- sender_mobileno: 送件人手機號碼
- sender_addr: 送件人地址
- sender_spot_id: 超商代碼
- sender_spot_name: 超商名稱
- sender_spot_addr: 超商地址
- ...
- }
-
- - recipient_data: 收件人資料
- {
- recipient_name: 收件人姓名
- recipient_mobileno: 收件人手機號碼
- recipient_addr: 收件人地址
- recipient_spot_id: 超商代碼
- recipient_spot_name: 超商名稱
- recipient_spot_addr: 超商地址
- ...
- }
- - package: 貨件內容
- {
- package_charge: 代收貨款
- package_weight: 貨件重量
- package_contemt: 內容物
- ...
- }
- - dInDtime: 建檔日期
- - dInUser: 建檔人
- - dInFilename: 檔案名稱
- ...
-
- return:
- {'success':'1'/'0'} 上傳成功/失敗
- """
- )
- async def upload_orders(req:upload_orders_item):
- return "OK"
- @app.post("/op_doc/query_shipping_details",
- response_model=shipping_details,
- summary="出貨明細查詢",
- description=
- """
- parameters:
- 查詢條件
- {
- ...
- }
-
- return:
- dataset
- [{
- - dInDtime: 建檔日期
- - transport_site: 入單營業所
- - current_insite: 收單營業所
- - transport_type: 配送類別
- - transport_name: 通路商
- - shipment_type: 運單種類
- - shipment_2: 二配
- - dInUser: 建檔人
- - dInFilename: 檔案名稱
- - upload_dtime: 上傳時間
- - upload_account: 傳送帳號
- }]
- """
- )
- async def query_shipping_details():
- return None
- @app.post("/stock_taking/shipment_out",
- response_model=shipping_details,
- summary="出貨面單",
- description=
- """
- parameters:
- - transport_id: 通路代碼
- - shipment_no: 運單號碼
-
- return:
- - sender_data: 送件人資料
- {
- sender_name: 送件人姓名
- sender_mobileno: 送件人手機號碼
- sender_addr: 送件人地址
- sender_spot_id: 超商代碼
- sender_spot_name: 超商名稱
- sender_spot_addr: 超商地址
- ...
- },
- - recipient_data: 收件人資料
- {
- recipient_name: 收件人姓名
- recipient_mobileno: 收件人手機號碼
- recipient_addr: 收件人地址
- recipient_spot_id: 超商代碼
- recipient_spot_name: 超商名稱
- recipient_spot_addr: 超商地址
- ...
- },
- - package: 貨件內容
- {
- package_charge: 代收貨款
- package_weight: 貨件重量
- package_contemt: 內容物
- ...
- }
-
- """
- )
- async def shipment_out():
- return None
- @app.post("/stock_taking/bag_in",
- response_model=shipping_details,
- summary="袋進倉",
- description=
- """
- parameters:
- - package_id: 袋號
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def bag_in():
- return None
- @app.post("/stock_taking/wh_in",
- response_model=shipping_details,
- summary="進站",
- description=
- """
- parameters:
- - transport_id: 通路代碼
- - transport_no: 配送單號
- - if_cancel: 取消刷件
- - insite_comment: 其他說明
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def wh_in():
- return None
- @app.post("/stock_taking/wh_out",
- response_model=shipping_details,
- summary="出站",
- description=
- """
- parameters:
- - transport_id: 通路代碼
- - transport_no: 配送單號
- - transport_next: 下一站代碼
- - if_cancel: 取消刷件
- - insite_comment: 其他說明
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def wh_out():
- return None
- @app.post("/stock_taking/deliver_out",
- response_model=shipping_details,
- summary="配送",
- description=
- """
- parameters:
- - transport_id: 通路代碼
- - transport_no: 配送單號
- - if_cancel: 取消刷件
- - insite_comment: 其他說明
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def deliver_out():
- return None
- @app.post("/stock_taking/sign",
- response_model=shipping_details,
- summary="簽收",
- description=
- """
- parameters:
- - transport_type: 配送類別
- - transport_id: 通路代碼
- - transport_no: 配送單號
- - transport_sign_status: 簽收類別(成功/異常)
- - transport_sign: 簽收人(本人/代收/警衛)
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def sign():
- return None
- @app.post("/stock_taking/whout_again",
- response_model=shipping_details,
- summary="二次出貨",
- description=
- """
- parameters:
- - transport_id: 通路代碼
- - shipment_no: 運單號碼
-
- return:
- - sender_data: 送件人資料
- {
- sender_name: 送件人姓名
- sender_mobileno: 送件人手機號碼
- sender_addr: 送件人地址
- sender_spot_id: 超商代碼
- sender_spot_name: 超商名稱
- sender_spot_addr: 超商地址
- ...
- },
- - recipient_data: 收件人資料
- {
- recipient_name: 收件人姓名
- recipient_mobileno: 收件人手機號碼
- recipient_addr: 收件人地址
- recipient_spot_id: 超商代碼
- recipient_spot_name: 超商名稱
- recipient_spot_addr: 超商地址
- ...
- },
- - package: 貨件內容
- {
- package_charge: 代收貨款
- package_weight: 貨件重量
- package_contemt: 內容物
- ...
- }
-
- """
- )
- async def whout_again():
- return None
- @app.post("/stock_taking/s_return",
- response_model=shipping_details,
- summary="退貨",
- description=
- """
- parameters:
- - transport_site: 營業所
- - transport_id: 通路代碼
- - transport_no: 配送單號
- - stock_id: 倉別(長慶倉庫)
- - stock_storage_id: 儲區
- - if_cancel: 取消刷件
- - insite_comment: 其他說明
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def s_return():
- return None
- @app.post("/stock_taking/reprint",
- response_model=shipping_details,
- summary="重印面單",
- description=
- """
- parameters:
- - transport_id: 通路代碼
- - shipment_no: 運單號碼
-
- return:
- - sender_data: 送件人資料
- {
- sender_name: 送件人姓名
- sender_mobileno: 送件人手機號碼
- sender_addr: 送件人地址
- sender_spot_id: 超商代碼
- sender_spot_name: 超商名稱
- sender_spot_addr: 超商地址
- ...
- },
- - recipient_data: 收件人資料
- {
- recipient_name: 收件人姓名
- recipient_mobileno: 收件人手機號碼
- recipient_addr: 收件人地址
- recipient_spot_id: 超商代碼
- recipient_spot_name: 超商名稱
- recipient_spot_addr: 超商地址
- ...
- },
- - package: 貨件內容
- {
- package_charge: 代收貨款
- package_weight: 貨件重量
- package_contemt: 內容物
- ...
- }
- """
- )
- async def reprint():
- return None
- @app.post("/stock_taking/batch_print",
- response_model=shipping_details,
- summary="面單批次列印",
- description=
- """
- parameters:
- 查詢條件
- {
- ...
- }
-
- return:
- dataset
- [
- - sender_data: 送件人資料
- {
- sender_name: 送件人姓名
- sender_mobileno: 送件人手機號碼
- sender_addr: 送件人地址
- sender_spot_id: 超商代碼
- sender_spot_name: 超商名稱
- sender_spot_addr: 超商地址
- ...
- },
- - recipient_data: 收件人資料
- {
- recipient_name: 收件人姓名
- recipient_mobileno: 收件人手機號碼
- recipient_addr: 收件人地址
- recipient_spot_id: 超商代碼
- recipient_spot_name: 超商名稱
- recipient_spot_addr: 超商地址
- ...
- },
- - package: 貨件內容
- {
- package_charge: 代收貨款
- package_weight: 貨件重量
- package_contemt: 內容物
- ...
- }
- ]
- """
- )
- async def batch_print():
- return None
- @app.post("/stock_taking/print_return",
- response_model=shipping_details,
- summary="刷退條碼",
- description=
- """
- parameters:
- - transport_id: 通路代碼
- - transport_no: 配送單號
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def print_return():
- return None
- @app.post("/ELPC/stock_in",
- response_model=shipping_details,
- summary="入庫",
- description=
- """
- parameters:
- - transport_id: 通路代碼
- - transport_no: 配送單號
- - stock_id: 倉別(長慶倉庫)
- - stock_storage_id: 儲區
- - if_cancel: 取消刷件
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def stock_in():
- return None
- @app.post("/ELPC/shelf",
- response_model=shipping_details,
- summary="上架",
- description=
- """
- parameters:
- - transport_id: 通路代碼
- - transport_no: 配送單號
- - stock_id: 倉別(長慶倉庫)
- - stock_storage_id: 儲區
- - if_cancel: 取消刷件
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def shelf():
- return None
- @app.post("/ELPC/stock_out",
- response_model=shipping_details,
- summary="出庫",
- description=
- """
- parameters:
- - stock_id: 倉庫(長慶倉庫)
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def stock_out():
- return None
- @app.post("/ELPC/stock_move",
- response_model=shipping_details,
- summary="移動儲位",
- description=
- """
- parameters:
- - stock_id: 倉別(長慶倉庫)
- - source_stock_storage_id: 來源儲區
- - target_stock_storage_id: 目的儲區
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def stock_move():
- return None
- @app.post("/ELPC/outstock",
- response_model=shipping_details,
- summary="下架",
- description=
- """
- parameters:
- - transport_site: 下架營業站
- - transport_id: 通路代碼
- - stock_id: 倉別(長慶倉庫)
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def outstock():
- return None
- @app.post("/ELPC/stock_check",
- response_model=shipping_details,
- summary="出庫檢核",
- description=
- """
- parameters:
- 匯入檢核單號(Excel格式)
- dataset
- [
- - transport_no: 配送單號
- ]
-
- return:
- {'success':'1'/'0'} 資料正常/異常
- """
- )
- async def outstock():
- return None
- if __name__ == "__main__":
- uvicorn.run("main:app", host="0.0.0.0", port=9898)
|