zhitong.yu
2024-10-11 4f58a93c95ff123d51adcb8fa2e521333e8ab022
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package com.hxzk.controller;
 
import com.github.pagehelper.PageInfo;
import com.hxzk.deo.HangJingPerSon;
import com.hxzk.pojo.TbHjperson;
import com.hxzk.pojo.TbTag;
import com.hxzk.service.HjPersonService;
import com.hxzk.util.MyFile;
import com.hxzk.util.result;
import com.hxzk.util.resultutil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
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.multipart.MultipartFile;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
 
@RestController
@RequestMapping("/")
public class HjPersonController {
    @Autowired
    HjPersonService personService;
    @GetMapping("findHjPerson")
    result<List<HangJingPerSon>> findTag(Integer page, Integer limit){
        PageInfo<HangJingPerSon> cz= personService.findAll(page, limit);
        return resultutil.returnSuccess(cz.getTotal(), cz.getList());
    }
 
    @GetMapping("findHjchejian")
    public List<HangJingPerSon> findchejian(int id){
        return personService.findchejian(id);
    }
    @GetMapping("findHjfenchang")
    public List<HangJingPerSon> findfenchang(){
        return personService.findfenchang();
    }
    @GetMapping("findHjbumen")
    public List<HangJingPerSon> findbumen(int id){
        return personService.findbumen(id);
    }
 
    @PostMapping("addHangJinPerson")
    public void addHangJinPerson(TbHjperson hjperson, HttpServletResponse response) throws IOException {
        long timestamp = System.currentTimeMillis();
        hjperson.setCaozuo("<button type=button onclick=StateUp(" + timestamp + ") style=font-size:14px class=\"layui-btn layui-btn-primary layui-btn-sm\">删除</button>&nbsp;<button type=button onclick=StateUpdate(" + timestamp + "," + hjperson.getPhone() + ",\"" + hjperson.getName() +"\","+"\"" + hjperson.getZhiwu() + "\") style=font-size:14px class=\"layui-btn layui-btn-primary layui-btn-sm\">修改</button>");
        hjperson.setXuanze("<button type=button onclick=StateUpdate(" + hjperson.getPhone() + ",\"" + hjperson.getName() +"\","+hjperson.getTimestamp()+") style=font-size:14px class=\"layui-btn layui-btn-warm layui-btn-sm\">选择</button>");
        hjperson.setTimestamp(String.valueOf(timestamp));
        personService.addHjPerson(hjperson);
        response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Person.jsp");
    }
 
    @GetMapping("DeleteHangJinPerson")
    public void DeleteHangJinPerson(TbHjperson hjperson) throws IOException {
 
        personService.DeleteHangJinPerson(hjperson);
    }
 
    @PostMapping("updateHangJinPerson")
    public void updateHangJinPerson(TbHjperson hjperson, HttpServletResponse response) throws IOException {
        hjperson.setCaozuo("<button type=button onclick=StateUp(" + hjperson.getTimestamp() + ") style=font-size:14px class=\"layui-btn layui-btn-primary layui-btn-sm\">删除</button>&nbsp;<button type=button onclick=StateUpdate(" + hjperson.getTimestamp() + "," + hjperson.getPhone() + ",\"" + hjperson.getName() +"\","+"\"" + hjperson.getZhiwu() + "\") style=font-size:14px class=\"layui-btn layui-btn-primary layui-btn-sm\">修改</button>");
        hjperson.setXuanze("<button type=button onclick=StateUpdate(" + hjperson.getPhone() + ",\"" + hjperson.getName() +"\","+hjperson.getTimestamp()+") style=font-size:14px class=\"layui-btn layui-btn-warm layui-btn-sm\">选择</button>");
        personService.updateHangJinPerson(hjperson);
        response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Person.jsp");
    }
    @PostMapping("ExportPdfDongHuo")
    public ResponseEntity<String> ExportPdf(MultipartFile pdfs, String zypcode, HttpServletRequest request,HttpServletResponse response) throws IOException {
//        MyFile.addPdfDongHuo(pdfs,request,zypcode);
        if (pdfs.isEmpty()) {
            return ResponseEntity.badRequest().body("PDF 文件为空");
        }
 
        try {
            byte[] bytes = pdfs.getBytes();
            Path path = Paths.get("C:\\Users\\Administrator\\Desktop\\BS\\webapps\\hxzkuwb\\HouTai\\zuoyepiao\\动火作业\\" + pdfs.getOriginalFilename());
            Files.write(path, bytes);
            return ResponseEntity.ok().body("PDF 文件已接收并保存");
        } catch (IOException e) {
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("上传 PDF 文件时发生错误");
        }
    }
    //受限
    @PostMapping("ExportPdfShouXian")
    public ResponseEntity<String> ExportPdfShouXian(MultipartFile pdfs, String zypcode, HttpServletRequest request,HttpServletResponse response) throws IOException {
//        MyFile.addPdfDongHuo(pdfs,request,zypcode);
        if (pdfs.isEmpty()) {
            return ResponseEntity.badRequest().body("PDF 文件为空");
        }
 
        try {
            byte[] bytes = pdfs.getBytes();
            Path path = Paths.get("C:\\Users\\Administrator\\Desktop\\BS\\webapps\\hxzkuwb\\HouTai\\zuoyepiao\\受限空间作业\\" + pdfs.getOriginalFilename());
            Files.write(path, bytes);
            return ResponseEntity.ok().body("PDF 文件已接收并保存");
        } catch (IOException e) {
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("上传 PDF 文件时发生错误");
        }
    }
    //高处
    @PostMapping("ExportPdfGaoChu")
    public ResponseEntity<String> ExportPdfGaoChu(MultipartFile pdfs, String zypcode, HttpServletRequest request,HttpServletResponse response) throws IOException {
//        MyFile.addPdfDongHuo(pdfs,request,zypcode);
        if (pdfs.isEmpty()) {
            return ResponseEntity.badRequest().body("PDF 文件为空");
        }
 
        try {
            byte[] bytes = pdfs.getBytes();
            Path path = Paths.get("C:\\Users\\Administrator\\Desktop\\BS\\webapps\\hxzkuwb\\HouTai\\zuoyepiao\\高处安全作业\\" + pdfs.getOriginalFilename());
            Files.write(path, bytes);
            return ResponseEntity.ok().body("PDF 文件已接收并保存");
        } catch (IOException e) {
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("上传 PDF 文件时发生错误");
        }
    }
    //吊装
    @PostMapping("ExportPdfDiaoZhuang")
    public ResponseEntity<String> ExportPdfDiaoZhuang(MultipartFile pdfs, String zypcode, HttpServletRequest request,HttpServletResponse response) throws IOException {
//        MyFile.addPdfDongHuo(pdfs,request,zypcode);
        if (pdfs.isEmpty()) {
            return ResponseEntity.badRequest().body("PDF 文件为空");
        }
 
        try {
            byte[] bytes = pdfs.getBytes();
            Path path = Paths.get("C:\\Users\\Administrator\\Desktop\\BS\\webapps\\hxzkuwb\\HouTai\\zuoyepiao\\吊装安全作业\\" + pdfs.getOriginalFilename());
            Files.write(path, bytes);
            return ResponseEntity.ok().body("PDF 文件已接收并保存");
        } catch (IOException e) {
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("上传 PDF 文件时发生错误");
        }
    }
    //用电
    @PostMapping("ExportPdfYongDian")
    public ResponseEntity<String> ExportPdfYongDian(MultipartFile pdfs, String zypcode, HttpServletRequest request,HttpServletResponse response) throws IOException {
//        MyFile.addPdfDongHuo(pdfs,request,zypcode);
        if (pdfs.isEmpty()) {
            return ResponseEntity.badRequest().body("PDF 文件为空");
        }
 
        try {
            byte[] bytes = pdfs.getBytes();
            Path path = Paths.get("C:\\Users\\Administrator\\Desktop\\BS\\webapps\\hxzkuwb\\HouTai\\zuoyepiao\\临时用电安全作业\\" + pdfs.getOriginalFilename());
            Files.write(path, bytes);
            return ResponseEntity.ok().body("PDF 文件已接收并保存");
        } catch (IOException e) {
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("上传 PDF 文件时发生错误");
        }
    }
        //动土
    @PostMapping("ExportPdfDongTu")
    public ResponseEntity<String> ExportPdfDongTu(MultipartFile pdfs, String zypcode, HttpServletRequest request,HttpServletResponse response) throws IOException {
//        MyFile.addPdfDongHuo(pdfs,request,zypcode);
        if (pdfs.isEmpty()) {
            return ResponseEntity.badRequest().body("PDF 文件为空");
        }
 
        try {
            byte[] bytes = pdfs.getBytes();
            Path path = Paths.get("C:\\Users\\Administrator\\Desktop\\BS\\webapps\\hxzkuwb\\HouTai\\zuoyepiao\\动土安全作业\\" + pdfs.getOriginalFilename());
            Files.write(path, bytes);
            return ResponseEntity.ok().body("PDF 文件已接收并保存");
        } catch (IOException e) {
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("上传 PDF 文件时发生错误");
        }
    }
    //断路
    @PostMapping("ExportPdfDuanLu")
    public ResponseEntity<String> ExportPdfDuanLu(MultipartFile pdfs, String zypcode, HttpServletRequest request,HttpServletResponse response) throws IOException {
//        MyFile.addPdfDongHuo(pdfs,request,zypcode);
        if (pdfs.isEmpty()) {
            return ResponseEntity.badRequest().body("PDF 文件为空");
        }
 
        try {
            byte[] bytes = pdfs.getBytes();
            Path path = Paths.get("C:\\Users\\Administrator\\Desktop\\BS\\webapps\\hxzkuwb\\HouTai\\zuoyepiao\\断路安全作业\\" + pdfs.getOriginalFilename());
            Files.write(path, bytes);
            return ResponseEntity.ok().body("PDF 文件已接收并保存");
        } catch (IOException e) {
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("上传 PDF 文件时发生错误");
        }
    }
 
    //盲板
    @PostMapping("ExportPdfMangBan")
    public ResponseEntity<String> ExportPdfMangBan(MultipartFile pdfs, String zypcode, HttpServletRequest request,HttpServletResponse response) throws IOException {
//        MyFile.addPdfDongHuo(pdfs,request,zypcode);
        if (pdfs.isEmpty()) {
            return ResponseEntity.badRequest().body("PDF 文件为空");
        }
        try {
            byte[] bytes = pdfs.getBytes();
            Path path = Paths.get("C:\\Users\\Administrator\\Desktop\\BS\\webapps\\hxzkuwb\\HouTai\\zuoyepiao\\盲板抽堵安全作业\\" + pdfs.getOriginalFilename());
            Files.write(path, bytes);
            return ResponseEntity.ok().body("PDF 文件已接收并保存");
        } catch (IOException e) {
            e.printStackTrace();
            return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("上传 PDF 文件时发生错误");
        }
    }
 
 
 
    @PostMapping("PDFInServer")
    public void PDFInServer(MultipartFile pdfs, String zypcode, HttpServletRequest request) throws IOException {
      MyFile.addPdfDongHuo(pdfs,request,zypcode);
    }
 
 
}