equipment.go 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. package service
  2. import (
  3. "context"
  4. "lims_zju/common"
  5. "lims_zju/model"
  6. )
  7. type DeviceStatistics struct{}
  8. type ReadData struct {
  9. Data interface{} `json:"data"`
  10. }
  11. // GetDeviceStatistics 获取实验设备数据使用信息
  12. func (d *DeviceStatistics) GetDeviceStatistics(ctx context.Context, req *model.BaseModel) (
  13. *model.DeviceStatistics, error) {
  14. list := make([]model.DeviceStatistics, 0)
  15. err := common.ReadJson(&list, "data", "common/data1.json")
  16. if err != nil {
  17. return nil, err
  18. }
  19. for _, v := range list {
  20. if v.LaboratoryId == req.LaboratoryId {
  21. return &v, nil
  22. }
  23. }
  24. return nil, nil
  25. }
  26. // GetExperimentalData 获取实验数据
  27. func (d *DeviceStatistics) GetExperimentalData(ctx context.Context, req *model.BaseModel) (
  28. *model.ExperimentalDatas, error) {
  29. list := make([]model.ExperimentalDatas, 0)
  30. err := common.ReadJson(&list, "data", "common/data1.json")
  31. if err != nil {
  32. return nil, err
  33. }
  34. for _, v := range list {
  35. if v.LaboratoryId == req.LaboratoryId {
  36. return &v, nil
  37. }
  38. }
  39. return nil, nil
  40. }
  41. // GetAppointment 获取预约信息
  42. func (d *DeviceStatistics) GetAppointment(ctx context.Context, req *model.BaseModel) (
  43. *model.Appointment, error) {
  44. list := make([]model.Appointment, 0)
  45. err := common.ReadJson(&list, "data", "common/data1.json")
  46. if err != nil {
  47. return nil, err
  48. }
  49. for _, v := range list {
  50. if v.LaboratoryId == req.LaboratoryId {
  51. return &v, nil
  52. }
  53. }
  54. return nil, nil
  55. }
  56. // GetPeakHours 获取高峰时段
  57. func (d *DeviceStatistics) GetPeakHours(ctx context.Context, req *model.BaseModel) (
  58. *model.PeakHours, error) {
  59. list := make([]model.PeakHours, 0)
  60. err := common.ReadJson(&list, "data", "common/data1.json")
  61. if err != nil {
  62. return nil, err
  63. }
  64. for _, v := range list {
  65. if v.LaboratoryId == req.LaboratoryId {
  66. return &v, nil
  67. }
  68. }
  69. return nil, nil
  70. }
  71. // GetHighEquipment 获取高频使用设备
  72. func (d *DeviceStatistics) GetHighEquipment(ctx context.Context, req *model.BaseModel) (
  73. *model.HighEquipment, error) {
  74. list := make([]model.HighEquipment, 0)
  75. err := common.ReadJson(&list, "data", "common/data1.json")
  76. if err != nil {
  77. return nil, err
  78. }
  79. for _, v := range list {
  80. if v.LaboratoryId == req.LaboratoryId {
  81. return &v, nil
  82. }
  83. }
  84. return nil, nil
  85. }