| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.mapper.RectifierPowerHistoryMapper; |
| | | import com.whyc.mapper.RectifierPowerMapper; |
| | | import com.whyc.pojo.CentralMonitorSysST; |
| | | import com.whyc.pojo.RectifierPowerRT; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Wrapper; |
| | | import java.util.HashMap; |
| | | import java.util.LinkedList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class RectifierPowerService { |
| | | |
| | | @Resource |
| | | private RectifierPowerMapper mapper; |
| | | |
| | | @Resource |
| | | private RectifierPowerHistoryMapper historyMapper; |
| | | |
| | | @Resource |
| | | private CommonMapper commonMapper; |
| | | |
| | | public Response<IPage<RectifierPowerRT>> getAll(int pageNum, int pageSize) { |
| | | IPage<RectifierPowerRT> rectifierPowerRTIPage = mapper.selectPage(new Page<>(pageNum, pageSize), null); |
| | |
| | | RectifierPowerRT rectifierPowerRT = mapper.selectOne(query); |
| | | return new Response<RectifierPowerRT>().set(1,rectifierPowerRT); |
| | | } |
| | | |
| | | public Response<PageInfo<RectifierPowerRT>> getHistory(int pageNum, int pageSize, int devId) { |
| | | List<String> tableNames = commonMapper.getTableName("db_3.5mw_motor_history", "tb_rectifier_power_" + devId); |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<RectifierPowerRT> rectifierPowerRTs = historyMapper.getHistory(tableNames); |
| | | PageInfo<RectifierPowerRT> rectifierPowerRTPageInfo = new PageInfo<>(rectifierPowerRTs); |
| | | return new Response<PageInfo<RectifierPowerRT>>().set(1,rectifierPowerRTPageInfo); |
| | | } |
| | | |
| | | public Response<Map<String, List>> getField() { |
| | | Map<String,List> fieldMap = new HashMap(); |
| | | List<String> fieldNames = new LinkedList(); |
| | | fieldNames.add("整流电源电压"); |
| | | fieldNames.add("整流电源电流"); |
| | | |
| | | List<String> fieldValues = new LinkedList(); |
| | | fieldValues.add("rectifier_vol"); |
| | | fieldValues.add("rectifier_curr"); |
| | | |
| | | fieldMap.put("fieldNames",fieldNames); |
| | | fieldMap.put("fieldValues",fieldValues); |
| | | return new Response<Map<String,List>>().set(1,fieldMap); |
| | | } |
| | | |
| | | public Response updatePowerState(int devId,int rectifierPowerState) { |
| | | UpdateWrapper<RectifierPowerRT> wrapper = Wrappers.update(); |
| | | wrapper.set("rectifier_power_state",rectifierPowerState).eq("dev_id",devId); |
| | | |
| | | mapper.update(null,wrapper); |
| | | return new Response().setMsg(1,"更新成功"); |
| | | } |
| | | } |