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.Response;
|
import com.whyc.mapper.RessetStationMapper;
|
import com.whyc.pojo.RessetStation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.Date;
|
import java.util.List;
|
|
@Service
|
public class RessetStationService {
|
|
@Autowired(required = false)
|
private RessetStationMapper mapper;
|
|
|
//添加机房时默认添加机房内阻定期
|
public Response setDefaultRessetStation(String stationId){
|
RessetStation ressetStation=new RessetStation();
|
ressetStation.setStationid(stationId);
|
ressetStation.setEnable(1);
|
ressetStation.setTimeInterval(720f);
|
ressetStation.setLastStartTime(new Date());
|
int flag = mapper.insert(ressetStation);
|
return new Response().set(1,flag>0,"添加机房时默认添加机房内阻定期");
|
}
|
//设置机房内阻定期
|
public Response updateResSet(RessetStation ressetStation) {
|
UpdateWrapper wrapper=new UpdateWrapper();
|
wrapper.eq("stationid",ressetStation.getStationid());
|
if(ressetStation.getTimeInterval()!=null){
|
wrapper.set("time_interval",ressetStation.getTimeInterval());
|
}
|
if(ressetStation.getEnable()!=null){
|
wrapper.set("enable",ressetStation.getEnable());
|
}
|
if(ressetStation.getLastStartTime()!=null){
|
wrapper.set("last_start_time",ressetStation.getLastStartTime());
|
}
|
int flag=mapper.update(null,wrapper);
|
return new Response().set(1,flag>0,"设置机房内阻定期");
|
}
|
//获取机房内阻定期
|
public Response getRessetStation(int pageNum, int pageSize) {
|
PageHelper.startPage(pageNum,pageSize);
|
List<RessetStation> list=mapper.getRessetStation();
|
PageInfo pageInfo=new PageInfo(list);
|
return new Response().setII(1,list.size()>0,pageInfo,"获取机房内阻定期");
|
}
|
//根据机房id获取机房内阻定期
|
public Response getDefaultRessetStationById(String stationId) {
|
RessetStation ressetStation=mapper.getDefaultRessetStationById(stationId);
|
return new Response().setII(1,ressetStation!=null,ressetStation,"根据机房id获取机房内阻定期");
|
}
|
}
|