mirror of
https://github.com/serty2005/rmser.git
synced 2026-02-04 19:02:33 -06:00
Настройки работают
Иерархия групп работает Полностью завязано на пользователя и серверы
This commit is contained in:
@@ -557,13 +557,26 @@ func (c *Client) FetchStoreOperations(presetID string, from, to time.Time) ([]St
|
||||
// CreateIncomingInvoice отправляет накладную в iiko
|
||||
func (c *Client) CreateIncomingInvoice(inv invoices.Invoice) (string, error) {
|
||||
// 1. Маппинг Domain -> XML DTO
|
||||
|
||||
// Статус по умолчанию NEW, если не передан
|
||||
status := inv.Status
|
||||
if status == "" {
|
||||
status = "NEW"
|
||||
}
|
||||
|
||||
// Комментарий по умолчанию, если пустой
|
||||
comment := inv.Comment
|
||||
if comment == "" {
|
||||
comment = "Loaded via RMSER OCR"
|
||||
}
|
||||
|
||||
reqDTO := IncomingInvoiceImportXML{
|
||||
DocumentNumber: inv.DocumentNumber,
|
||||
DateIncoming: inv.DateIncoming.Format("02.01.2006"),
|
||||
DefaultStore: inv.DefaultStoreID.String(),
|
||||
Supplier: inv.SupplierID.String(),
|
||||
Status: "NEW",
|
||||
Comment: "Loaded via RMSER OCR",
|
||||
Status: status,
|
||||
Comment: comment,
|
||||
}
|
||||
|
||||
if inv.ID != uuid.Nil {
|
||||
@@ -758,6 +771,49 @@ func (c *Client) UpdateProduct(product ProductFullDTO) (*ProductFullDTO, error)
|
||||
return result.Response, nil
|
||||
}
|
||||
|
||||
// GetServerInfo пытается получить информацию о сервере (имя, версия) без авторизации.
|
||||
// Использует endpoint /resto/getServerMonitoringInfo.jsp
|
||||
func GetServerInfo(baseURL string) (*ServerMonitoringInfoDTO, error) {
|
||||
// Формируем URL. Убираем слэш в конце, если есть.
|
||||
url := strings.TrimRight(baseURL, "/") + "/resto/getServerMonitoringInfo.jsp"
|
||||
|
||||
logger.Log.Info("RMS: Requesting server info", zap.String("url", url))
|
||||
|
||||
client := &http.Client{Timeout: 5 * time.Second}
|
||||
resp, err := client.Get(url)
|
||||
if err != nil {
|
||||
logger.Log.Error("RMS: Monitoring connection failed", zap.Error(err))
|
||||
return nil, fmt.Errorf("connection error: %w", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read body error: %w", err)
|
||||
}
|
||||
|
||||
logger.Log.Info("RMS: Monitoring Response",
|
||||
zap.Int("status", resp.StatusCode),
|
||||
zap.String("body", string(bodyBytes)))
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, fmt.Errorf("status code %d", resp.StatusCode)
|
||||
}
|
||||
|
||||
var info ServerMonitoringInfoDTO
|
||||
|
||||
// Пробуем JSON (так как в логе пришел JSON)
|
||||
if err := json.Unmarshal(bodyBytes, &info); err != nil {
|
||||
// Если вдруг JSON не прошел, можно попробовать XML как фоллбек (для старых версий)
|
||||
logger.Log.Warn("RMS: JSON decode failed, trying XML...", zap.Error(err))
|
||||
if xmlErr := xml.Unmarshal(bodyBytes, &info); xmlErr != nil {
|
||||
return nil, fmt.Errorf("decode error (json & xml failed): %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
// FetchSuppliers загружает список поставщиков через XML API
|
||||
func (c *Client) FetchSuppliers() ([]suppliers.Supplier, error) {
|
||||
// Endpoint /resto/api/suppliers
|
||||
|
||||
Reference in New Issue
Block a user