fei.wang
2024-05-09 871d4095b07cedacb7fbef4c38d64982f539c404
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package com.flow.controller;
 
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.flow.mapper.OperationLogMapper;
import com.flow.mapper.TbFuwuqiMapper;
import com.flow.pojo.Card;
import com.flow.pojo.OperationLog;
import com.flow.pojo.TbFuwuqi;
import com.flow.service.CompanyService;
import com.flow.service.OperationLogService;
import com.flow.service.TbFuwuqiService;
import com.flow.util.result;
import com.flow.util.resultutil;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
 
@RestController
@RequestMapping({"/hxzk"})
public class TbFuwuqiController {
 
    @Autowired
    TbFuwuqiService tbFuwuqiService;
    @Autowired
    CompanyService companyService;
 
    @Autowired
    OperationLogService operationLogService;
    @Autowired
    TbFuwuqiMapper tbFuwuqiMapper;
    @Autowired
    OperationLogMapper operationLogMapper;
    @GetMapping({"findTbFuwuqi"})
    result<List<TbFuwuqi>> findBangZhu(Integer page, Integer limit) throws ParseException {
        PageInfo<TbFuwuqi> cz = this.tbFuwuqiService.FindTbFuwuqi(page, limit);
        for(int i = 0; i < cz.getSize(); ++i) {
            if (((TbFuwuqi)cz.getList().get(i)).getCompany() != null) {
                SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
                Date date = new Date();
                Date endDay = date2.parse(cz.getList().get(i).getEnddate());//结束时间
                Long starTime = date.getTime();
                Long endTime = endDay.getTime();
                Long num11 = endTime - starTime;//时间戳
                if ((num11/24/60/60/1000)<0){
                    ((TbFuwuqi)cz.getList().get(i)).setRemainingdays("0天");
                }else{
                    ((TbFuwuqi)cz.getList().get(i)).setRemainingdays(+num11/24/60/60/1000+"天");
                }
                if (!((TbFuwuqi)cz.getList().get(i)).getRemainingdays().equals("0天") || !((TbFuwuqi)cz.getList().get(i)).getRemainingdays().equals(+num11/24/60/60/1000+"天") ){
                    System.out.println("打印数据==========》》》》》》》》》》");
                    this.tbFuwuqiService.UpdateTbFuwuqi((TbFuwuqi)cz.getList().get(i));
                }
//
            }
        }
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @GetMapping({"findTbFuwuqiZi"})
    result<List<TbFuwuqi>> findTbFuwuqiZi(String Zong, Integer page, Integer limit) throws ParseException {
        PageInfo<TbFuwuqi> cz = this.tbFuwuqiService.findTbFuwuqiZi(Zong, page, limit);
        for(int i = 0; i < cz.getSize(); ++i) {
            if (((TbFuwuqi)cz.getList().get(i)).getCompany() != null) {
                SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
                Date date = new Date();
                Date endDay = date2.parse(cz.getList().get(i).getEnddate());//结束时间
                Long starTime = date.getTime();
                Long endTime = endDay.getTime();
                Long num11 = endTime - starTime;//时间戳
                if ((num11/24/60/60/1000)<0){
                    ((TbFuwuqi)cz.getList().get(i)).setRemainingdays("0天");
                }else{
                    ((TbFuwuqi)cz.getList().get(i)).setRemainingdays(+num11/24/60/60/1000+"天");
                }
                if (!((TbFuwuqi)cz.getList().get(i)).getRemainingdays().equals("0天") || !((TbFuwuqi)cz.getList().get(i)).getRemainingdays().equals(+num11/24/60/60/1000+"天") ){
                    System.out.println("222222222222");
                    this.tbFuwuqiService.UpdateTbFuwuqi((TbFuwuqi)cz.getList().get(i));
                }
            }
        }
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @PostMapping({"addTbFuwuqi"})
    public ModelAndView addBang(TbFuwuqi tbFuwuqi) throws Exception {
        ModelAndView modelAndView = new ModelAndView();
        tbFuwuqi.setId(null);
        this.tbFuwuqiService.addTbFuwuqi(tbFuwuqi);
        modelAndView.addObject("suoshu", this.companyService.findSuoShu());
        modelAndView.setViewName("/page/Fuwuqi.jsp");
        return modelAndView;
    }
 
    @PostMapping({"UpdateTbFuwuqi"})
    public ModelAndView UpdateCard(TbFuwuqi tbFuwuqi) {
        this.tbFuwuqiService.UpdateTbFuwuqi(tbFuwuqi);
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("id", tbFuwuqi.getId());
        TbFuwuqi tbFuwuqi1 = tbFuwuqiMapper.selectOne(queryWrapper);
        OperationLog operationLog = new OperationLog();
        operationLog.setCaozuotype("修改");
        operationLog.setCaozuocontent("修改服务器:"+tbFuwuqi1.getServername());
        operationLog.setCaozuoname(tbFuwuqi1.getCaozuoname());
        operationLogService.addOperationLog(operationLog);
        Date date = new Date();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        operationLog.setCaozuodate(formatter.format(date));
        operationLogMapper.insert(operationLog);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/page/Fuwuqi.jsp");
        return modelAndView;
    }
 
    @PostMapping({"DeleteTbFuwuqi"})
    public int DeleteCard(String num,String caozuoname) {
        return this.tbFuwuqiService.DeleteTbFuwuqi(num,caozuoname);
    }
 
    @PostMapping({"tbFuwuqiSearch"})
    public result<List<TbFuwuqi>> tableSearch(TbFuwuqi tbFuwuqi, int page, int limit) throws Exception {
        PageInfo<TbFuwuqi> cz = this.tbFuwuqiService.tableSearch(tbFuwuqi, page, limit);
        for(int i = 0; i < cz.getSize(); ++i) {
            if (((TbFuwuqi)cz.getList().get(i)).getCompany() != null) {
                SimpleDateFormat date2 = new SimpleDateFormat("yyyy-MM-dd");
                Date date = new Date();
                Date endDay = date2.parse(cz.getList().get(i).getEnddate());//结束时间
                Long starTime = date.getTime();
                Long endTime = endDay.getTime();
                Long num11 = endTime - starTime;//时间戳
 
                if ((num11/24/60/60/1000)<0){
                    ((TbFuwuqi)cz.getList().get(i)).setRemainingdays("0天");
                }else{
                    ((TbFuwuqi)cz.getList().get(i)).setRemainingdays(+num11/24/60/60/1000+"天");
                }
//                this.cardService.UpdateCard((Card)cz.getList().get(i));
//                this.cardService.UpdateCard((Card)cz.getList().get(i));
            }
        }
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
    @PostMapping({"ifFuwuqi"})
    public TbFuwuqi ifFuwuqi(TbFuwuqi tbFuwuqi) {
        return this.tbFuwuqiService.ifFuwuqi(tbFuwuqi);
    }
 
 
}