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> <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> <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);
|
}
|
|
|
}
|