whyclxw
2025-05-28 e16302f9d475c7cc4dd18c5abf1a23cb5502e362
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
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.SubInfMapper;
import com.whyc.pojo.CircleInf;
import com.whyc.pojo.SubInf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
 
@Service
public class SubInfService {
    @Autowired(required = false)
    private SubInfMapper mapper;
 
    //添加子件信息
    public void addSubList(String devId,List<SubInf> subList) {
        subList.stream().forEach(sinf->sinf.setDeviceId(devId));
        mapper.insertBatchSomeColumn(subList);
    }
    //获取子件信息
    public Response getSub(SubInf sub, int pageCurr, int pageSize) {
        PageHelper.startPage(pageCurr,pageSize);
        QueryWrapper wrapper=new QueryWrapper();
        if(sub.getSubType()!=null){
            wrapper.eq("sub_type",sub.getSubType());
        }
 
        if(sub.getSubPropertyName()!=null){
            wrapper.eq("sub_property_name",sub.getSubPropertyName());
        }
 
        if(sub.getStartTime()!=null){
            wrapper.ge("sub_inuse_date",sub.getStartTime());
        }
        if(sub.getEndTime()!=null){
            wrapper.le("sub_inuse_date",sub.getEndTime());
        }
        List<SubInf> list=mapper.selectList(wrapper);
        PageInfo pageInfo=new PageInfo(list);
        return new Response().setII(1,list!=null,pageInfo,"获取子件信息");
    }
    //添加动环
    public void addSub(SubInf sub) {
        mapper.insert(sub);
    }
    //更新电源
    public void updateSub(SubInf sub) {
        UpdateWrapper<SubInf> wrapper = new UpdateWrapper<SubInf>().eq("sub_id",sub.getSubId());
        mapper.update(sub,wrapper);
    }
    //删除电源
    public void deleteSub(Integer subId) {
        QueryWrapper<SubInf> wrapper = new QueryWrapper<SubInf>().eq("sub_id",subId);
        mapper.delete(wrapper);
    }
}