agricloud / foodprint

1 stars 0 forks source link

履歷查詢:foodprint 與 footpaint 之間的 service 互動 #49

Closed smlsunxie closed 10 years ago

smlsunxie commented 10 years ago

domain 說明

batch

    static belongsTo = [
        item: Item,

    ]

    static hasMany = [
        batchRoutes: BatchRoute,
        batchSources: BatchSource
    ]

batchSource

    /*
    * 最接近的直接上層批號
    */
    static belongsTo = [batch: Batch]

    /*
    * 目前子批號
    */
    Batch childBatch

    /*
    * 是否是最底層批號(原物料)
    */
    Boolean isEndBatch = false

由成品查往物料

ex: batch.batchSource[0].childBatch.batchSource[2].childBatch

由物料查往成品

  1. 先查出 batch
  2. 在查 BatchSouce.findAllByChildBatch(batch)
  3. 每個 BatchSouce,可以往上查詢如: BatchSouce.batch
  4. 要在查上一階在將第二步驟的 batch 換成 BatchSouce.parent,直到查不到為止

    新增專案 foodpaint 與 foodprint 各自服務範圍說明

foodprint 專注在履歷最終結果呈現 由另一個服務,foodpaint(暫定) 專注在追朔關係與資料來源處理,也就包括現階段必要的 erp 資料,各單據所必要的欄位

會這樣設計考量到:

如過沒有第三方來源 foodprint 可以獨力運作 需要第三方來源,統一由 foodpaint 處理 而 foodprint 只需要對 foodpaint 進行 service 溝通

因此傳回 foodprint 只有最終履歷的資料,也就是 batch 以及供給的物料,還有檢驗以及收集資料的相關履歷

footprint 只提供最低限度的履歷資料建立作業:

本來考慮直接將 erp 的資料轉換為 batch與 batchSource,轉換邏輯太過複雜,配合撰寫資料匯入邏輯不易,需要投入時間釐清規格與實作,而直接與erp 對應的 domain 匯入將可以更直接產出需要的結果。

兩個系統間的溝通說明

從 foodprint 發起

  1. 前端 request 透過批號傳入參數,進行查詢該批號的物料組成來源
  2. 透過 rest client 向 foodpaint 送出請求 http://localhost:8180/footprint/queryBatchReport/batchId

    由 foodpaint 處理

  3. 透過傳入的 batchId 開始查詢 erp domain,取得物料供給狀況 轉為 batch 與 batchSource 取得最源頭的物料供給關係
  4. 以 json 格式 回傳

    回到 foodprint 進行顯示

  5. 接收 batch 及 batchSource 資料後檢查 foodprint 有沒有對應的 batch 及 batchSource,若無則將傳入的資料先寫入至 db ,接著在透過 bootstrap #47 ,或者透過樹狀呈現 #48
pipibabe commented 10 years ago

完成foodpaint準備履歷資料部分