| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | |
| | | |
| | | } |
| | | |
| | | public MotorState getByDeviceId(int deviceId){ |
| | | QueryWrapper<MotorState> wrapper = Wrappers.query(); |
| | | wrapper.eq("device_id",deviceId); |
| | | MotorState motorState = motorStateMapper.selectOne(wrapper); |
| | | return motorState; |
| | | } |
| | | |
| | | public boolean delete(int deviceId){ |
| | | return motorStateMapper.deleteById(deviceId)>0; |
| | | } |
| | | |
| | | /** |
| | | * 通过设备id,开始结束时间获取设备历史数据 |
| | | * @param deviceId |
| | | * @param startTime |
| | | * @param endTime |
| | | * @return |
| | | */ |
| | | public List<MotorState> getHistoryData(String deviceId,String startTime,String endTime){ |
| | | //获取时间拼接数据表名 |
| | | String dateStr = startTime.substring(0,10).replace('-','_'); |
| | | String tableName="tb_motor_state_realdata_"+deviceId+"_"+dateStr; |
| | | List<MotorState> data = motorStateMapper.getDataByTime(tableName,startTime,endTime); |
| | | return data; |
| | | } |
| | | |
| | | } |