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> findTag(Integer page, Integer limit){ PageInfo cz= personService.findAll(page, limit); return resultutil.returnSuccess(cz.getTotal(), cz.getList()); } @GetMapping("findHjchejian") public List findchejian(int id){ return personService.findchejian(id); } @GetMapping("findHjfenchang") public List findfenchang(){ return personService.findfenchang(); } @GetMapping("findHjbumen") public List findbumen(int id){ return personService.findbumen(id); } @PostMapping("addHangJinPerson") public void addHangJinPerson(TbHjperson hjperson, HttpServletResponse response) throws IOException { long timestamp = System.currentTimeMillis(); hjperson.setCaozuo(" "); hjperson.setXuanze(""); 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(" "); hjperson.setXuanze(""); personService.updateHangJinPerson(hjperson); response.sendRedirect("/hxzkuwb/HouTai/JobTicket/Person.jsp"); } @PostMapping("ExportPdfDongHuo") public ResponseEntity 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 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 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 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 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 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 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 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); } }