69 lines
2.1 KiB
Go
69 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
)
|
|
|
|
// GetKingdeeMonitorConfig returns the Kingdee ERP monitor configuration.
|
|
func (a *App) GetKingdeeMonitorConfig() interface{} {
|
|
result, err := a.getHelperJSON("/api/kingdee/monitor/config")
|
|
if err != nil {
|
|
return map[string]interface{}{"success": false, "message": err.Error()}
|
|
}
|
|
return result
|
|
}
|
|
|
|
// SaveKingdeeMonitorConfig persists the Kingdee ERP monitor configuration.
|
|
func (a *App) SaveKingdeeMonitorConfig(jsonData string) (bool, string) {
|
|
var payload map[string]interface{}
|
|
if err := json.Unmarshal([]byte(jsonData), &payload); err != nil {
|
|
return false, fmt.Sprintf("解析金蝶监听配置失败: %v", err)
|
|
}
|
|
result, err := a.postHelperJSON("/api/kingdee/monitor/config", payload)
|
|
if err != nil {
|
|
if result != nil {
|
|
return helperResultOK(result)
|
|
}
|
|
return false, err.Error()
|
|
}
|
|
return helperResultOK(result)
|
|
}
|
|
|
|
// GetKingdeeMonitorStatus returns the Kingdee monitor runtime state.
|
|
func (a *App) GetKingdeeMonitorStatus() interface{} {
|
|
result, err := a.getHelperJSON("/api/kingdee/monitor/status")
|
|
if err != nil {
|
|
return map[string]interface{}{"success": false, "message": err.Error()}
|
|
}
|
|
return result
|
|
}
|
|
|
|
// TestKingdeeMonitorConnection verifies Kingdee WebAPI credentials.
|
|
func (a *App) TestKingdeeMonitorConnection(jsonData string) interface{} {
|
|
var payload map[string]interface{}
|
|
if err := json.Unmarshal([]byte(jsonData), &payload); err != nil {
|
|
return map[string]interface{}{"success": false, "message": fmt.Sprintf("解析金蝶连接配置失败: %v", err)}
|
|
}
|
|
result, err := a.postHelperJSON("/api/kingdee/monitor/test-connection", payload)
|
|
if err != nil {
|
|
if result != nil {
|
|
return result
|
|
}
|
|
return map[string]interface{}{"success": false, "message": err.Error()}
|
|
}
|
|
return result
|
|
}
|
|
|
|
// RunKingdeeMonitorOnce triggers a manual Kingdee order scan.
|
|
func (a *App) RunKingdeeMonitorOnce() interface{} {
|
|
result, err := a.postHelperJSON("/api/kingdee/monitor/run-once", map[string]interface{}{})
|
|
if err != nil {
|
|
if result != nil {
|
|
return result
|
|
}
|
|
return map[string]interface{}{"success": false, "message": err.Error()}
|
|
}
|
|
return result
|
|
}
|