| | |
| | | package com.whyc.service; |
| | | |
| | | import com.alibaba.druid.pool.WrapperAdapter; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | 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.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.Collection; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Service |
| | | public class PowerInfService { |
| | | @Resource |
| | | private PowerInfMapper mapper; |
| | | |
| | | public void add(PowerInf powerInf){ |
| | | mapper.insert(powerInf); |
| | | public int add(PowerInf powerInf){ |
| | | return mapper.insert(powerInf); |
| | | } |
| | | |
| | | public void updateByPowerDeviceId(PowerInf powerInf){ |
| | |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | | public PageInfo<PowerInf> getPowerDevicesPage(int pageNum,int pageSize,Long uId,String stationId, String stationName1,String stationName2,String stationName5){ |
| | | public Response getPowerDevicesPage(int pageNum,int pageSize,Long uId,String stationId, String stationName1,String stationName2,String stationName5){ |
| | | PageHelper.startPage(pageNum,pageSize); |
| | | List<PowerInf> list = mapper.getPowerDevicesPage(uId,stationId, stationName1, stationName2,stationName5); |
| | | PageInfo<PowerInf> pageInfo = new PageInfo<>(list); |
| | | return pageInfo; |
| | | return new Response().set(1,pageInfo,"查询成功"); |
| | | } |
| | | |
| | | public Response getPowerDevices(String stationId){ |
| | | QueryWrapper<PowerInf> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("stationid",stationId); |
| | | List<PowerInf> list = mapper.selectList(queryWrapper); |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | | //查询某个电源的详细信息 |
| | | public Response getInfoById(int powerDeviceId) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("PowerDeviceId",powerDeviceId); |
| | | List list=mapper.selectList(wrapper); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().set(1,pageInfo); |
| | | } |
| | | |
| | | //在线监测-实时监控-获取配电柜的实时数据 |
| | | public Response getPowerInfoById(int powerDeviceId) { |
| | | //acdcinfMapper.getInfo(powerDeviceId); |
| | | return new Response().set(1); |
| | | } |
| | | |
| | | public int getNum(int userId) { |
| | | return mapper.getNum(userId); |
| | | } |
| | | |
| | | //管理员首页:电源信息 |
| | | public List<PowerInf> getPwrdevInfAnalysis(int userId) { |
| | | List<PowerInf> list = mapper.getPwrdevInfAnalysis(userId); |
| | | return list; |
| | | } |
| | | |
| | | public Response updateExceptionCause(PowerInf powerInf) { |
| | | //非空校验 |
| | | if(powerInf.getExceptionCause()==null || powerInf.getExceptionCause().isEmpty()){ |
| | | return new Response().set(1,false,"异常原因不能为空"); |
| | | } |
| | | mapper.updateById(powerInf); |
| | | return new Response().set(1,true,"填写完成"); |
| | | } |
| | | |
| | | public Response updateCancelExceptionCause(int num) { |
| | | UpdateWrapper<PowerInf> update = Wrappers.update(); |
| | | update.set("exception_cause",null).set("exception_cause_analysis",null).eq("num",num); |
| | | mapper.update(null,update); |
| | | return new Response().setII(1,"取消成功"); |
| | | } |
| | | |
| | | public Response getExceptionCause(int num) { |
| | | QueryWrapper<PowerInf> query = Wrappers.query(); |
| | | query.select("StationName","PowerProducer","exception_cause","exception_cause_analysis").eq("num",num); |
| | | PowerInf powerInf = mapper.selectOne(query); |
| | | return new Response().set(1,powerInf); |
| | | } |
| | | } |