From f0afb2b17f2f6e13925ffe1b6fd8c8ae724aec0e Mon Sep 17 00:00:00 2001
From: chenrui <1187576398@qq.com>
Date: 星期四, 13 三月 2025 10:46:24 +0800
Subject: [PATCH] 分支合并冲突解决
---
inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java | 203 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 203 insertions(+), 0 deletions(-)
diff --git a/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java
new file mode 100644
index 0000000..922213e
--- /dev/null
+++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java
@@ -0,0 +1,203 @@
+package com.ruoyi.inspect.controller;
+
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.http.HttpUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson2.JSON;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.domain.Result;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.JackSonUtil;
+import com.ruoyi.framework.exception.ErrorException;
+import com.ruoyi.inspect.dto.BatchApprovalReportDTO;
+import com.ruoyi.inspect.dto.ReportPageDto;
+import com.ruoyi.inspect.pojo.InsReport;
+import com.ruoyi.inspect.service.InsReportService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.logging.log4j.util.Strings;
+import org.apache.poi.hssf.record.SSTRecord;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Map;
+import java.util.Objects;
+import java.util.Scanner;
+
+@RestController
+@RequestMapping("/insReport")
+@Api(tags = "妫�楠屾姤鍛�")
+public class InsReportController {
+
+
+ @Resource
+ private InsReportService insReportService;
+
+ @Value("${wordUrl}")
+ private String wordUrl;
+
+ @ApiOperation(value = "鏌ョ湅妫�楠屾姤鍛婂垪琛�")
+ @GetMapping("/pageInsReport")
+ public Result pageInsReport(Page page,ReportPageDto reportPageDto) throws Exception {
+ return Result.success(insReportService.pageInsReport(page, reportPageDto));
+ }
+
+
+ @ApiOperation(value = "涓�閿鎵规寜閽�")
+ @PostMapping("/batchApprovalReport")
+ public Result batchApprovalReport(@RequestBody BatchApprovalReportDTO batchApprovalReportDTO){
+ try {
+ insReportService.batchApprovalReport(batchApprovalReportDTO.getIds());
+ }catch (Exception e){
+ throw new RuntimeException(e);
+ }
+ return Result.success();
+ }
+
+ @ApiOperation(value = "鑾峰彇瀹℃壒杩涘害")
+ @GetMapping("/getBatchApprovalProgress")
+ public Result getBatchApprovalProgress(){
+ return Result.success(insReportService.getBatchApprovalProgress());
+ }
+
+
+ @ApiOperation(value = "鏌ョ湅妫�楠屾姤鍛婃暟閲忎俊鎭�")
+ @GetMapping("/getReportCountInfo")
+ public Result getReportCountInfo(ReportPageDto reportPageDto) throws Exception {
+ return Result.success(insReportService.getReportCountInfo(reportPageDto));
+ }
+
+ @ApiOperation(value = "涓婁紶鎸夐挳")
+ @PostMapping("/inReport")
+ public Result inReport(MultipartFile file, Integer id) {
+ String urlString;
+ String pathName;
+ try {
+ String path = wordUrl;
+ File realpath = new File(path);
+ if (!realpath.exists()) {
+ realpath.mkdirs();
+ }
+ InsReport insReport = insReportService.getById(id);
+ // 濡傛灉URLS鏈夊�� 鍏堝皢璇ユ枃浠跺垹闄�
+ if(Strings.isNotEmpty(insReport.getUrlS())){
+ String url = wordUrl + File.separator + insReport.getUrlS().replace("/word/", "");
+ File file1 = new File(url);
+ if(file1.exists()) {
+ file1.delete();
+ }
+ }
+ String code = insReport.getCode().replace("/", "") + ".docx";
+ pathName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + code;
+ urlString = realpath + "/" + pathName;
+ file.transferTo(new File(urlString));
+ return Result.success(insReportService.inReport("/word/" + pathName, id));
+ } catch (Exception e) {
+ throw new ErrorException("鏂囦欢涓婁紶澶辫触");
+ }
+ }
+ //涓嬭浇
+ @GetMapping("/downReport")
+ public void downReport(@RequestParam("id") Integer id,@RequestParam("type") Integer type, HttpServletResponse response) {
+ insReportService.downReport(id,type, response);
+ }
+
+
+
+ @ApiOperation(value = "杩樺師鎸夐挳")
+ @PostMapping("/upReportUrl")
+ public Result upReportUrl(Integer id) {
+ return Result.success(insReportService.upReportUrl(id));
+ }
+
+ @ApiOperation(value = "缂栧埗鎸夐挳")
+ @GetMapping("/upReportFile")
+ public Result upReportFile() {
+ return Result.success();
+ }
+
+ @ApiOperation(value = "鎻愪氦鎸夐挳")
+ @PostMapping("/writeReport")
+ public Result writeReport(Integer id) {
+
+ return Result.success(insReportService.writeReport(id));
+ }
+
+ @ApiOperation(value = "瀹℃牳鎸夐挳")
+ @PostMapping("/examineReport")
+ public Result examineReport(Integer id, Integer isExamine, String examineTell) {
+ return Result.success(insReportService.examineReport(id, isExamine, examineTell));
+ }
+
+ @ApiOperation(value = "鎵瑰噯鎸夐挳")
+ @PostMapping("/ratifyReport")
+ public Result ratifyReport(Integer id, Integer isRatify, String ratifyTell) {
+ return Result.success(insReportService.ratifyReport(id, isRatify, ratifyTell));
+ }
+
+ @RequestMapping("/onlyOffice/save")
+ public void saveFile(@RequestParam String fileName, HttpServletRequest request, HttpServletResponse response) {
+ PrintWriter writer = null;
+ try {
+ writer = response.getWriter();
+ // 鑾峰彇浼犺緭鐨刯son鏁版嵁
+ Scanner scanner = new Scanner(request.getInputStream()).useDelimiter("\\A");
+ String body = scanner.hasNext() ? scanner.next() : "";
+ JSONObject jsonObject = JSONObject.parseObject(body);
+
+ if (jsonObject.containsKey("url")) {
+ String jsonArray = jsonObject.get("lastsave").toString(); // 鏇存柊鏃堕棿
+ String fileUrl = jsonObject.get("url").toString(); // 鏇存柊鏂囦欢url
+ HttpUtil.downloadFile(fileUrl, FileUtil.file(wordUrl + "/" + fileName));
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ writer.write("{\"error\":-1}");
+ return;
+ }
+ /*
+ * status = 1锛屾垜浠粰onlyOffice鐨勬湇鍔¤繑鍥瀧"error":"0"}鐨勪俊鎭��
+ * 杩欐牱onlyOffice浼氳涓哄洖璋冩帴鍙f槸娌¢棶棰樼殑锛岃繖鏍峰氨鍙互鍦ㄧ嚎缂栬緫鏂囨。浜嗭紝鍚﹀垯鐨勮瘽浼氬脊鍑虹獥鍙h鏄�
+ */
+ if (Objects.nonNull(writer)) {
+ writer.write("{\"error\":0}");
+ }
+ }
+
+ @ApiOperation(value = "鎵归噺涓嬭浇鎸夐挳")
+ @GetMapping("/downAll")
+ public Result downAll(String ids) {
+ return Result.success(insReportService.downAll(ids));
+ }
+
+ @ApiOperation(value = "鎵归噺涓婁紶鎸夐挳")
+ @PostMapping("/upAll")
+ public Result upAll(MultipartFile file) throws IOException {
+ return Result.success(insReportService.upAll(file));
+ }
+
+ @ApiOperation(value = "鎾ゅ洖鎸夐挳")
+ @PostMapping("/withdraw")
+ public Result withdraw(@RequestBody Map<String,Object> map) {
+ insReportService.withdraw(map);
+ return Result.success();
+ }
+
+ @GetMapping("/getLaboratoryByReportId")
+ public Result getLaboratoryByReportId(Integer id) {
+ return Result.success(insReportService.getLaboratoryByReportId(id));
+ }
+
+
+
+}
--
Gitblit v1.9.3