fei.wang
2024-03-07 80c20bb65f4b73d8beb817e0d595889cd44479dd
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
package com.flow.controller;
 
 
import com.flow.pojo.Card;
import com.flow.pojo.TbFuwuqi;
import com.flow.service.CompanyService;
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;
 
    @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+"天") ){
                    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+"天") ){
                    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);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/page/Fuwuqi.jsp");
        return modelAndView;
    }
 
    @PostMapping({"DeleteTbFuwuqi"})
    public int DeleteCard(String num) {
        return this.tbFuwuqiService.DeleteTbFuwuqi(num);
    }
 
    @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);
    }
 
}