Fosi Fossil Service
Small teams. Open source. Built on Fossil.

IaC / SwiftFlow

High-performance WMS with wave picking, smart routing, and real-time inventory visibility.

Public | Owner: IaC | Default branch: trunk | Last update: 2026-10-23 14:37

Artifact b842d7fed6626e77879584b363ca5c753b8f3817a6d3b17be6dacdb7ccbdfe21:


import app.{type Context}
import gleam/erlang/process
import gleam/int
import logging
import sync_inbounds
import sync_orders
import sync_purchase_receipts
import sync_report

pub fn start(ctx: Context) -> process.Pid {
  process.spawn(fn() { loop(ctx) })
}

fn loop(ctx: Context) -> Nil {
  case sync_orders.run(ctx, "poll") {
    Ok(report) ->
      logging.log(
        logging.Info,
        "订单轮询完成,抓取 "
          <> int.to_string(report.fetched)
          <> " 笔,写入 "
          <> int.to_string(report.upserted)
          <> " 笔",
      )
    Error(sync_report.SyncBusy) ->
      logging.log(logging.Info, "订单轮询跳过,已有同步正在进行")
    Error(err) ->
      logging.log(logging.Error, "订单轮询失败: " <> sync_report.describe(err))
  }
  case sync_inbounds.run(ctx, "poll") {
    Ok(report) ->
      logging.log(
        logging.Info,
        "采购订单轮询完成,抓取 "
          <> int.to_string(report.fetched)
          <> " 笔,写入 "
          <> int.to_string(report.upserted)
          <> " 笔",
      )
    Error(sync_report.SyncBusy) ->
      logging.log(logging.Info, "采购订单轮询跳过,已有同步正在进行")
    Error(err) ->
      logging.log(logging.Error, "采购订单轮询失败: " <> sync_report.describe(err))
  }
  case sync_purchase_receipts.run(ctx, "poll") {
    Ok(report) ->
      logging.log(
        logging.Info,
        "采购入库单轮询完成,抓取 "
          <> int.to_string(report.fetched)
          <> " 笔,写入 "
          <> int.to_string(report.upserted)
          <> " 笔",
      )
    Error(sync_report.SyncBusy) ->
      logging.log(logging.Info, "采购入库单轮询跳过,已有同步正在进行")
    Error(err) ->
      logging.log(logging.Error, "采购入库单轮询失败: " <> sync_report.describe(err))
  }
  process.sleep(ctx.config.order_poll_ms)
  loop(ctx)
}

Clone

You can clone this repository with the following command:

fossil clone https://fosi.dev/IaC/SwiftFlow

Contribute

The best way to contribute is through e-mail. See the project documentation for more details.