| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.dto.paramter.PowerInfPar; |
| | | import com.whyc.mapper.PowerInfMapper; |
| | | import com.whyc.pojo.PowerInf; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.util.Iterator; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | @Service |
| | | public class PowerInfService { |
| | |
| | | return new Response().set(1,list,"查询成功"); |
| | | } |
| | | |
| | | public Response getExistStations(String stationName1,String stationName2,String stationName5){ |
| | | List<PowerInf> list = mapper.getExistStations(stationName1,stationName2,stationName5); |
| | | return new Response().set(1,list,"查询成功"); |
| | | public Response getExistStations(String stationName1, String stationName2, String stationName5) { |
| | | List<PowerInf> list = mapper.getExistStations(stationName1, stationName2, stationName5); |
| | | return new Response().set(1, list, "查询成功"); |
| | | } |
| | | |
| | | public Response getStations(Long userId,String stationName5){ |
| | | List<PowerInf> list = mapper.getStations(userId,stationName5); |
| | | return new Response().set(1,list,"查询成功"); |
| | | public Response getStations(Long userId, String stationName5) { |
| | | List<PowerInf> list = mapper.getStations(userId, stationName5); |
| | | return new Response().set(1, list, "查询成功"); |
| | | } |
| | | |
| | | 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); |
| | | public Response getPowerDevicesPage(int pageNum, int pageSize, Long uId, PowerInfPar powerInfPar) { |
| | | PageHelper.startPage(pageNum, pageSize); |
| | | List<PowerInf> list = mapper.getPowerDevicesPage(uId, powerInfPar); |
| | | PageInfo<PowerInf> pageInfo = new PageInfo<>(list); |
| | | return new Response().set(1,pageInfo,"查询成功"); |
| | | return new Response().set(1, pageInfo, "查询成功"); |
| | | } |
| | | |
| | | public Response getPowerDevices(String stationId){ |
| | | public Response getPowerDevices(String stationId) { |
| | | QueryWrapper<PowerInf> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("stationid",stationId); |
| | | queryWrapper.eq("stationid", stationId); |
| | | List<PowerInf> list = mapper.selectList(queryWrapper); |
| | | return new Response().set(1,list,"查询成功"); |
| | | return new Response().set(1, list, "查询成功"); |
| | | } |
| | | |
| | | //查询某个电源的详细信息 |
| | |
| | | } |
| | | |
| | | //管理员首页:电源信息 |
| | | public Response<Map> getPwrdevInfAnalysis(int userId) { |
| | | return new Response().set(1); |
| | | 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); |
| | | } |
| | | |
| | | public Response getPwrInf(Long uId) { |
| | | List<PowerInf> list = mapper.getPwrInf(uId); |
| | | return new Response().set(1, list, "查询成功"); |
| | | } |
| | | |
| | | //获取所有的电源品牌 |
| | | public Response getPwrProducer() { |
| | | List<String> list = mapper.getPwrProducer(); |
| | | return new Response().setII(1, list.size() > 0 ? true : false, list, "获取所有的电源品牌"); |
| | | } |
| | | |
| | | public Response getModelList() { |
| | | QueryWrapper<PowerInf> query = Wrappers.query(); |
| | | query.select("distinct model"); |
| | | List<PowerInf> powerInfList = mapper.selectList(query); |
| | | List<String> modelList = powerInfList.stream().filter(model -> model != null).map(PowerInf::getModel).collect(Collectors.toList()); |
| | | return new Response().set(1, modelList); |
| | | |
| | | } |
| | | |
| | | //根据品牌查询型号 |
| | | public Response getModelListByPwrProducer(List<String> producer) { |
| | | QueryWrapper<PowerInf> query = Wrappers.query(); |
| | | query.select("distinct model"); |
| | | if (producer != null && producer.size() > 0) { |
| | | query.in("PowerProducer", producer); |
| | | } |
| | | List<PowerInf> powerInfList = mapper.selectList(query); |
| | | List<String> modelList = powerInfList.stream().filter(model -> model != null).map(PowerInf::getModel).collect(Collectors.toList()); |
| | | return new Response().set(1, modelList); |
| | | } |
| | | } |