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
package com.hxzk.controller;
 
 
import com.github.pagehelper.PageInfo;
import com.hxzk.pojo.TbZypElectricity;
import com.hxzk.service.TbZypElectricityService;
import com.hxzk.util.result;
import com.hxzk.util.resultutil;
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 javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
 
/**
 * <p>
 * 航锦化工临时用电安全作业证 前端控制器
 * </p>
 *
 * @author wangfei
 * @since 2024-04-23
 */
@RestController
@RequestMapping("/")
public class TbZypElectricityController {
 
 
 
    @Autowired
    TbZypElectricityService tbZypElectricityService;
 
    @GetMapping("findZypElectricity")
    result<List<TbZypElectricity>> findLifting(Integer page, Integer limit){
        PageInfo<TbZypElectricity> cz= tbZypElectricityService.findAll(page, limit);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @PostMapping("findZypElectricitySearch")
    result<List<TbZypElectricity>> findZypElectricitySearch(Integer page, Integer limit,String applicant,String code){
        PageInfo<TbZypElectricity> cz= tbZypElectricityService.findSearch(page, limit, applicant, code);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
 
    @GetMapping("findtIdZypElectricity")
    public TbZypElectricity findtIdZypElectricity(Integer id){
        return tbZypElectricityService.findtagidZypElectricity(id);
    }
 
    @PostMapping("addZypElectricity")
    public void addZypElectricity(TbZypElectricity tbZypElectricity, HttpServletResponse response) throws IOException {
        if (tbZypElectricity.getStartDate()!="" &&  tbZypElectricity.getEndDate()!=""){
            tbZypElectricity.setHottime("自"+tbZypElectricity.getStartDate()+"至"+tbZypElectricity.getEndDate()+"止");
 
        }
if (tbZypElectricity.getId()!=null){
    tbZypElectricityService.updateZypElectricity(tbZypElectricity);
 
}else{
    tbZypElectricityService.addZypElectricity(tbZypElectricity);
 
}
 
 
 
//        Calendar calendar = Calendar.getInstance();
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        String dateStr = sdf.format(calendar.getTime());
//        company.setAddtime(dateStr);
//        TbScreenSettings screenSettings = new TbScreenSettings();
//        screenSettings.setCompanyname(company.getCompanyname());
//        screenService.AddScreen(screenSettings);
//        TbSystemOperationLog systemOperationLog = new TbSystemOperationLog();
//        systemOperationLog.setName(UserController.username);
//        systemOperationLog.setTime(gettime());
//        systemOperationLog.setContent("增加了一个公司,该公司名称为:"+company.getCompanyname());
//        systemLogService.insertSystem(systemOperationLog);
        response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Electricity.jsp");
    }
 
    @PostMapping("updateZypElectricity")
    public void updateZypElectricity(TbZypElectricity tbZypElectricity,HttpServletResponse response) throws IOException {
//        smsReminder.setAddtime(gettime());
        tbZypElectricityService.updateZypElectricity(tbZypElectricity);
        response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Electricity.jsp");
    }
 
    @GetMapping("deleteZypElectricity")
    public void deleteZypElectricity(Integer id,HttpServletResponse response) throws IOException {
        tbZypElectricityService.deleteZypElectricity(id);
        response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Electricity.jsp");
    }
}