whyclxw
2024-11-14 cd58b7308836e6ed423972b3c6fc04dbe5b8d81c
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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.BattInfMapper;
import com.whyc.mapper.CircleInfMapper;
import com.whyc.pojo.Battinf;
import com.whyc.pojo.CircleInf;
import com.whyc.pojo.PowerInf;
import com.whyc.pojo.StationInf;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service
public class CircleInfService {
 
    @Resource
    private CircleInfMapper mapper;
 
    @Resource
    private BattInfMapper battInfMapper;
 
    public int add(CircleInf circleInf){
        return mapper.insert(circleInf);
    }
 
    public void updateByDeviceId(CircleInf circleInf){
        UpdateWrapper<CircleInf> wrapper = new UpdateWrapper<CircleInf>().eq("device_id",circleInf.getDeviceId());
        mapper.update(circleInf,wrapper);
    }
 
    public void deleteByDeviceId(Integer deviceId){
        QueryWrapper<CircleInf> wrapper = new QueryWrapper<CircleInf>().eq("device_id",deviceId);
        mapper.delete(wrapper);
    }
    //获取动环的设备id
    public String getDeviceId() {
        Integer devId = mapper.getMaxDeviceId();
        if(devId==null||devId==0){
            devId = 120*1000000;
        }
        devId+=1;
        return String.valueOf(devId);
    }
 
    //获取动环信息
    public Response getCinf(CircleInf cinf,int pageCurr,int pageSize) {
        PageHelper.startPage(pageCurr,pageSize);
        List<CircleInf> list=mapper.getCinf(cinf);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"获取动环信息");
    }
    //获取动环下拉资产信息
    public Response getConditionCid() {
        List<CircleInf> list=mapper.selectList(null);
        return new Response().setII(1,list!=null,list,"获取动环下拉资产信息");
    }
 
    /**
     * 新:从站点表校验站点是否存在
     * 旧:电源添加前校验是否站点存在,从电池表+电源表查询,弃用
     * */
    public Battinf judgeBattStationName3(CircleInf cinf){
        Battinf battinf = new Battinf();
        battinf.setStationName1(cinf.getStationName1());
        battinf.setStationName2(cinf.getStationName2());
        battinf.setStationName3(cinf.getStationName3());
        battinf.setStationName5(cinf.getStationName5());
 
        return battInfMapper.judgeBattStationName3(battinf);
    }
    //根据id获取动环信息
    public Response getCinfById(int deviceId) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("device_id",deviceId);
        wrapper.last("limit 1");
        CircleInf cinf=mapper.selectOne(wrapper);
        return new Response().setII(1,cinf!=null,cinf,"根据id获取动环信息");
    }
}