fei.wang
2024-03-21 ab64b09ce3020b376af1e6ee0326ea71330d34ad
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package com.flow.service.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.flow.mapper.CardMapper;
import com.flow.mapper.TbFuwuqiMapper;
import com.flow.pojo.Card;
import com.flow.pojo.TbFuwuqi;
import com.flow.service.TbFuwuqiService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
 
import static com.baomidou.mybatisplus.extension.toolkit.SimpleQuery.selectList;
 
@Service
public class TbFuwuqiServiceImpl extends ServiceImpl<TbFuwuqiMapper, TbFuwuqi> implements TbFuwuqiService {
 
    @Autowired
    TbFuwuqiMapper tbFuwuqiMapper;
 
    @Override
    public PageInfo<TbFuwuqi> FindTbFuwuqi(Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<TbFuwuqi> cardList = this.tbFuwuqiMapper.findAllUsers();
        PageInfo<TbFuwuqi> info = new PageInfo(cardList);
        return info;
    }
 
    public PageInfo<TbFuwuqi> findTbFuwuqiZi(String Zong, Integer page, Integer limit) {
 
        PageHelper.startPage(page, limit);
        List<TbFuwuqi> tbFuwuqiistList = this.tbFuwuqiMapper.findTbFuwuqiZi(Zong);
        PageInfo<TbFuwuqi> info = new PageInfo(tbFuwuqiistList);
        return info;
    }
 
    public int addTbFuwuqi(TbFuwuqi tbFuwuqi) {
        return ((TbFuwuqiMapper) this.baseMapper).insert(tbFuwuqi);
    }
 
    public int UpdateTbFuwuqi(TbFuwuqi tbFuwuqi) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id", tbFuwuqi.getId());
        return ((TbFuwuqiMapper) this.baseMapper).update(tbFuwuqi, queryWrapper);
    }
 
    public int DeleteTbFuwuqi(String id) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id", id);
        TbFuwuqi tbFuwuqi = new TbFuwuqi();
        tbFuwuqi.setNone("1");
        return ((TbFuwuqiMapper) this.baseMapper).update(tbFuwuqi, queryWrapper);
    }
 
 
    public PageInfo<TbFuwuqi> tableSearch(TbFuwuqi tbFuwuqi, int page, int limit) throws Exception {
        QueryWrapper queryWrapper = new QueryWrapper();
        PageHelper.startPage(page, limit);
        PageInfo<TbFuwuqi> info = null;
         if (tbFuwuqi.getCompany() != "") {
            if (tbFuwuqi.getCompany().equals("华星智控")) {
                info = new PageInfo(this.tbFuwuqiMapper.FindSearch(tbFuwuqi.getCompany(),tbFuwuqi.getServername()));
            } else {
                queryWrapper.like("company", tbFuwuqi.getCompany());
                queryWrapper.eq("none", 0);
                info = new PageInfo(((TbFuwuqiMapper) this.baseMapper).selectList(queryWrapper));
            }
        } else {
            queryWrapper.eq("company", tbFuwuqi.getCompany());
            queryWrapper.eq("none", 0);
            info = new PageInfo(((TbFuwuqiMapper) this.baseMapper).selectList(queryWrapper));
        }
 
        return info;
    }
 
    public List<TbFuwuqi> proxyfindTbFuwuqi() {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("none", 0);
 
        return ((TbFuwuqiMapper) this.baseMapper).selectList(queryWrapper);
    }
 
    public int Updatefuwuqi(TbFuwuqi tbFuwuqi) throws ParseException {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("company", tbFuwuqi.getCompany());
        TbFuwuqi tbFuwuqi1 = ((TbFuwuqiMapper) this.baseMapper).selectOne(queryWrapper);
        DateFormat df=new SimpleDateFormat("yyyy-MM-dd");// date format
        Date date=df.parse(tbFuwuqi1.getEnddate());// parse String to date
        Calendar calendar=Calendar.getInstance();
        calendar.setTime(date); // set calender instance to date value
        calendar.add(Calendar.YEAR,1); // add one year to current
        System.out.println(df.format(calendar.getTime()));
        tbFuwuqi.setEnddate(df.format(calendar.getTime()));
        SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
        Date endDay = date2.parse(df.format(calendar.getTime()));//结束时间
        Long starTime = date.getTime();
        Long endTime = endDay.getTime();
        Long num11 = endTime - starTime;//时间戳
        tbFuwuqi.setRemainingdays(+num11/24/60/60/1000+"天");
        return ((TbFuwuqiMapper)this.baseMapper).update(tbFuwuqi, queryWrapper);
    }
 
    public TbFuwuqi ifFuwuqi(TbFuwuqi tbFuwuqi) {
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("servername", tbFuwuqi.getServername());
        queryWrapper.eq("none", 0);
        return (TbFuwuqi)((TbFuwuqiMapper)this.baseMapper).selectOne(queryWrapper);
    }
}