- MES(B): 工单/BOM/备料/工序字典/PLC下发/拧紧/扫码报工/半成品/AGV/追溯逻辑,WMS与海康RCS客户端,看板Redis缓存API(概览/设备/进度/报警/趋势)+SSE - WMS(C): JWT滑动续签、Excel导入、盘点、内部API、种子数据、独立Postgres配置 - WMS客户端(E): Go网关8891反向代理+内嵌Vue3十页 - 工位终端(D): SQLite本地缓存+模拟拧紧源+内嵌Vue3页面 - Dashboard(A): 看板数据改接MES内部缓存API,SSE实时刷新+vite代理 - 清理各项目球形磨遗留代码,新增部署手册.md
35 lines
964 B
Go
35 lines
964 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"bj_power_workstation/internal/svc"
|
|
)
|
|
|
|
// syncFlushHandler POST /api/sync/flush 手动立即执行一轮同步,返回本次成功条数。
|
|
func syncFlushHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
count := ctx.Syncer.RunOnce(r.Context())
|
|
ok(w, map[string]any{
|
|
"count": count,
|
|
"message": "本轮同步完成",
|
|
})
|
|
}
|
|
}
|
|
|
|
// syncStatsHandler GET /api/sync/stats 返回待同步条数统计。
|
|
func syncStatsHandler(ctx *svc.ServiceContext) http.HandlerFunc {
|
|
return func(w http.ResponseWriter, r *http.Request) {
|
|
pendingTorque, err1 := ctx.Store.PendingTorqueCount()
|
|
pendingQueue, err2 := ctx.Store.PendingQueueCount()
|
|
if err1 != nil || err2 != nil {
|
|
fail(w, http.StatusInternalServerError, "查询待同步统计失败")
|
|
return
|
|
}
|
|
ok(w, map[string]any{
|
|
"pendingTorque": pendingTorque,
|
|
"pendingQueue": pendingQueue,
|
|
})
|
|
}
|
|
}
|