123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- package devicesrv
- import (
- "Cold_Logistic/internal/pkg/common/constant"
- "Cold_Logistic/internal/server/infra/dao"
- "Cold_Logistic/internal/server/infra/thirdparty/internalservice/clod"
- "context"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/core"
- "gogs.baozhida.cn/Cold_Logistic_libs/pkg/contrib/errors"
- "strconv"
- )
- type DeviceService struct {
- store *dao.DataStore
- }
- func NewDeviceService(store *dao.DataStore) *DeviceService {
- return &DeviceService{store: store}
- }
- func (srv DeviceService) DeviceSensorList(ctx context.Context, req DeviceSensorListReqVO) (res DeviceSensorListRespVO, err error) {
- clodSrv := clod.NewBzdClodService()
- list, err := clodSrv.DeviceSensorList(ctx, req.SnCode)
- if err != nil {
- return res, errors.WithStackOnce(err)
- }
- res.SnCode = req.SnCode
- res.SnIds = list
- return res, nil
- }
- func (srv DeviceService) SnDataList(ctx context.Context, req SnDataListReqVO) (res core.PageListResponse, err error) {
- clodSrv := clod.NewBzdClodService()
- ret, err := clodSrv.DeviceSensorDataList(ctx, clod.DeviceSensorDataListParam{
- User_tokey: req.UserTokey,
- T_snid: req.SnId,
- Time_start: req.Search.TimeStart.Format(constant.TimeCriterionFormat),
- Time_end: req.Search.TimeEnd.Format(constant.TimeCriterionFormat),
- Page: strconv.Itoa(req.Page.Page),
- Page_z: strconv.Itoa(req.Page.Size),
- })
- if err != nil {
- return res, errors.WithStackOnce(err)
- }
- res.Total = ret.Num
- res.TotalPage = ret.PageSize
- res.Count = len(ret.Data)
- res.List = ret
- return res, nil
- }
|