aKeyAlarmRecordService.go 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package service
  2. import (
  3. "fmt"
  4. "iot_manager_service/app/record/dao"
  5. "iot_manager_service/app/record/edge_service"
  6. )
  7. var AKeyAlarmRecordService = new(aKeyAlarmRecordService)
  8. type aKeyAlarmRecordService struct{}
  9. func (s aKeyAlarmRecordService) List(searchValue string, start string, end string, id int, current int, size int) ([]dao.AkeyAlarmRecord, error) {
  10. var record dao.AkeyAlarmRecord
  11. offset := (current - 1) * size
  12. limit := size
  13. records, err := record.GetRecords(offset, limit, start, end, searchValue, id)
  14. if err != nil {
  15. return nil, err
  16. }
  17. return records, nil
  18. }
  19. func (s aKeyAlarmRecordService) Detail(id int) (*dao.AkeyAlarmRecord, error) {
  20. record := &dao.AkeyAlarmRecord{
  21. ID: id,
  22. }
  23. return record.Get()
  24. }
  25. func (s aKeyAlarmRecordService) Refresh() {
  26. // TODO:边缘数据
  27. up := edge_service.RecordAlarmSos{}
  28. maxId, maxUpDateTime := dao.AkeyAlarmRecord{}.GetMaxIdAndUpDateTime()
  29. recordLightUpDatas, err := up.SyncRecord(maxId, maxUpDateTime)
  30. //fmt.Printf("recordLightUpDatas = %v", recordLightUpDatas)
  31. dao.AkeyAlarmRecord{}.BatchCreate(recordLightUpDatas)
  32. if err != nil {
  33. fmt.Printf("Refresh err.Error() = %v", err)
  34. return
  35. }
  36. }
  37. func (s aKeyAlarmRecordService) UpdateRemark(id int, remark string) error {
  38. record := dao.AkeyAlarmRecord{ID: id}
  39. record.Remark = remark
  40. err := record.Update()
  41. if err != nil {
  42. return err
  43. }
  44. return nil
  45. }