whyclxw
2024-07-30 ed04733e15a5304c68ac16c121fd2989c851a57b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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获取机房内阻定期");
    }
}