| | |
| | | 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.AFERectifierHistoryMapper; |
| | | import com.whyc.mapper.AFERectifierMapper; |
| | | import com.whyc.mapper.CommonMapper; |
| | | import com.whyc.pojo.AFEInverterState; |
| | | import com.whyc.pojo.AFERectifierState; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.sql.Wrapper; |
| | | import java.util.List; |
| | | |
| | | @Service |
| | | public class AFERectifierService { |
| | | |
| | | @Resource |
| | | private AFERectifierMapper mapper; |
| | | |
| | | @Resource |
| | | private AFERectifierHistoryMapper historyMapper; |
| | | |
| | | @Resource |
| | | private CommonMapper commonMapper; |
| | | |
| | | /**分页*/ |
| | | public Response<IPage<AFERectifierState>> getAll(int pageNum,int pageSize) { |
| | | IPage<AFERectifierState> afeRectifierStateIPage = mapper.selectPage(new Page<>(pageNum, pageSize), null); |
| | | return new Response<IPage<AFERectifierState>>().set(1,afeRectifierStateIPage); |
| | | } |
| | | |
| | | public Response<AFERectifierState> getInfoByDevId(int devId) { |
| | | QueryWrapper<AFERectifierState> query = Wrappers.query(); |
| | | query.eq("dev_id",devId); |
| | | AFERectifierState afeRectifierState = mapper.selectOne(query); |
| | | return new Response<AFERectifierState>().set(1,afeRectifierState); |
| | | } |
| | | |
| | | public Response<PageInfo<AFERectifierState>> getHistory(int pageNum, int pageSize, int devId) { |
| | | List<String> tableNames = commonMapper.getTableName("db_3.5mw_motor_history", "tb_afe_rectifier_state_" + devId); |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<AFERectifierState> afeInverterStates = historyMapper.getHistory(tableNames); |
| | | PageInfo<AFERectifierState> afeInverterStatePageInfo = new PageInfo<>(afeInverterStates); |
| | | return new Response<PageInfo<AFERectifierState>>().set(1,afeInverterStatePageInfo); |
| | | } |
| | | |
| | | |
| | | public Response updateState1(int devId, int rectifierRun) { |
| | | UpdateWrapper<AFERectifierState> wrapper = Wrappers.update(); |
| | | wrapper.set("rectifier_run",rectifierRun).eq("dev_id",devId); |
| | | mapper.update(null,wrapper); |
| | | return new Response().setMsg(1,"更新成功"); |
| | | } |
| | | |
| | | public Response updateState2(int devId, int inverterRun) { |
| | | UpdateWrapper<AFERectifierState> wrapper = Wrappers.update(); |
| | | wrapper.set("inverter_run",inverterRun).eq("dev_id",devId); |
| | | mapper.update(null,wrapper); |
| | | return new Response().setMsg(1,"更新成功"); |
| | | } |
| | | } |