| | |
| | | package com.flightfeather.uav.lightshare.service.impl |
| | | |
| | | import com.flightfeather.uav.common.utils.DateUtil |
| | | import com.flightfeather.uav.domain.entity.CompanyDevice |
| | | import com.flightfeather.uav.domain.entity.ElectricMinuteValue |
| | | import com.flightfeather.uav.domain.entity.toAirData |
| | | import com.flightfeather.uav.domain.mapper.CompanyDeviceMapper |
| | | import com.flightfeather.uav.domain.mapper.ElectricMinuteValueMapper |
| | | import com.flightfeather.uav.lightshare.bean.BaseResponse |
| | | import com.flightfeather.uav.lightshare.bean.DataHead |
| | | import com.flightfeather.uav.lightshare.bean.DataVo |
| | | import com.flightfeather.uav.lightshare.service.ElectricityService |
| | | import com.flightfeather.uav.socket.bean.AirData |
| | | import com.github.pagehelper.PageHelper |
| | | import org.springframework.stereotype.Service |
| | | import tk.mybatis.mapper.entity.Example |
| | | import java.text.SimpleDateFormat |
| | | |
| | | @Service |
| | | class ElectricityServiceImpl(private val electricMinuteValueMapper: ElectricMinuteValueMapper) : ElectricityService { |
| | | class ElectricityServiceImpl( |
| | | private val electricMinuteValueMapper: ElectricMinuteValueMapper, private val companyDeviceMapper: CompanyDeviceMapper |
| | | ) : ElectricityService { |
| | | |
| | | private var dateFormatter = SimpleDateFormat("yyyy-MM-dd HH:mm:ss") |
| | | |
| | |
| | | } |
| | | return BaseResponse(true, head = DataHead(pageInfo.pageNum, pageInfo.pages), data = result) |
| | | } |
| | | |
| | | override fun getMinuteData2(deviceCode: String, startTime: String?, endTime: String?, page: Int?, perPage: Int?): BaseResponse<List<DataVo>> { |
| | | val result = mutableListOf<DataVo>() |
| | | getMinuteData(deviceCode, startTime, endTime, page, perPage).run { |
| | | data?.forEach { |
| | | result.add(DataVo( |
| | | DateUtil.instance.dateToString(it.mvDataTime, DateUtil.DateStyle.YYYY_MM_DD_HH_MM_SS), |
| | | it.mvStatCode, |
| | | it.toAirData() |
| | | )) |
| | | } |
| | | return BaseResponse(success, head = head, data = result) |
| | | } |
| | | } |
| | | |
| | | override fun getByCompany(cId: String): BaseResponse<List<ElectricMinuteValue>> { |
| | | val result = mutableListOf<ElectricMinuteValue>() |
| | | companyDeviceMapper.selectByExample(Example(CompanyDevice::class.java).apply { |
| | | createCriteria().andEqualTo("cdCompanyId", cId) |
| | | }).forEach { |
| | | val p = PageHelper.startPage<ElectricMinuteValue>(1, 1) |
| | | electricMinuteValueMapper.selectByExample(Example(ElectricMinuteValue::class.java).apply { |
| | | createCriteria().andEqualTo("mvStatCode", it?.cdDeviceCode) |
| | | orderBy("mvDataTime").desc() |
| | | })?.let { |
| | | if (it.isNotEmpty()) { |
| | | it[0]?.let {e-> result.add(e) } |
| | | } |
| | | } |
| | | } |
| | | |
| | | return BaseResponse(true, data = result) |
| | | } |
| | | } |