package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageInfo;
|
import com.whyc.dto.PowerDto;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.PowerInfMapper;
|
import com.whyc.mapper.StationInfMapper;
|
import com.whyc.pojo.db_station.PowerInf;
|
import com.whyc.pojo.db_station.StationInf;
|
import org.apache.commons.math3.analysis.function.Power;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
|
@Service
|
public class PowerInfService {
|
@Autowired(required = false)
|
private PowerInfMapper mapper;
|
|
@Autowired(required = false)
|
private StationInfMapper sinfMapper;
|
|
//添加电源
|
public Response addPower(PowerInf addpinf) {
|
/* //判断添加锁的时候机房是不是新机房
|
String fullName=addpinf.getProvice()+"_"+addpinf.getCity()+"_"+addpinf.getCountry()+"_"+addsinf.getStationName();
|
//判断机房是否存在
|
QueryWrapper wrapper=new QueryWrapper();
|
wrapper.eq("full_name",fullName);
|
wrapper.last("limit 1");
|
PowerInf pinf=mapper.selectOne(wrapper);
|
int stationId=0;
|
if(pinf!=null){
|
return new Response().set(1,false,"机房已存在");
|
}else {
|
//获取对应的机房id
|
stationId=sinfMapper.getMaxStationId();
|
if(stationId==0){//数据库中没有站点
|
stationId=40000001;
|
}else{
|
stationId+=1;
|
}
|
StationInf newSinf=new StationInf();
|
newSinf.setStationId(stationId);
|
newSinf.setStationName(fullName);
|
newSinf.setProvice(addsinf.getProvice());
|
newSinf.setCity(addsinf.getCity());
|
newSinf.setCountry(addsinf.getCountry());
|
newSinf.setStationName(addsinf.getStationName());
|
mapper.insert(newSinf);*/
|
return new Response().set(1,true,"添加电源");
|
}
|
//删除电源
|
public Response delPower(Integer pid) {
|
/* UpdateWrapper wrapper=new UpdateWrapper();
|
wrapper.eq("station_id",stationId);
|
mapper.delete(wrapper);*/
|
return new Response().set(1,true);
|
}
|
//修改电源
|
public Response updatePower(PowerInf pinf) {
|
UpdateWrapper wrapper=new UpdateWrapper();
|
/*wrapper.eq("station_id",sinf.getStationId());
|
if(sinf.getProvice()!=null){
|
wrapper.set("provice",sinf.getProvice());
|
}
|
if(sinf.getCity()!=null){
|
wrapper.set("city",sinf.getCity());
|
}
|
if(sinf.getCountry()!=null){
|
wrapper.set("country",sinf.getCountry());
|
}
|
if(sinf.getStationName()!=null){
|
wrapper.set("station_name",sinf.getStationName());
|
}
|
String fullName=sinf.getProvice()+"_"+sinf.getCity()+"_"+sinf.getCountry()+"_"+sinf.getStationName();
|
wrapper.set("full_name",fullName);
|
mapper.update((StationInf) ActionUtil.objeNull,wrapper);*/
|
return new Response().set(1,true);
|
}
|
//查询电源
|
public Response getPower(PowerDto dto) {
|
PageHelper.startPage(dto.getPageNum(),dto.getPageSize());
|
QueryWrapper wrapper=new QueryWrapper();
|
if(dto.getProvice()!=null){
|
wrapper.eq("provice",dto.getProvice());
|
}
|
if(dto.getCity()!=null){
|
wrapper.eq("city",dto.getCity());
|
}
|
if(dto.getCountry()!=null){
|
wrapper.eq("country",dto.getCountry());
|
}
|
if(dto.getStationName()!=null){
|
wrapper.eq("station_name",dto.getStationName());
|
}
|
List<StationInf> list=mapper.selectList(wrapper);
|
PageInfo pageInfo=new PageInfo(list);
|
return new Response().setII(1,list!=null,pageInfo,"查询电源");
|
}
|
|
}
|