From 4f3a98f19143865cdc1de4791e8a95d96bd40c65 Mon Sep 17 00:00:00 2001 From: maven <2163098428@qq.com> Date: 星期五, 01 八月 2025 13:27:59 +0800 Subject: [PATCH] yys 密码已重置 --- inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java | 184 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 184 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..a60e47d --- /dev/null +++ b/inspect-server/src/main/java/com/ruoyi/inspect/controller/InsReportController.java @@ -0,0 +1,184 @@ +package com.ruoyi.inspect.controller; + +import cn.hutool.core.io.FileUtil; +import cn.hutool.http.HttpUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.ruoyi.basic.dto.IfsInventoryQuantitySupplierDto; +import com.ruoyi.common.annotation.Anonymous; +import com.ruoyi.common.annotation.PersonalScope; +import com.ruoyi.common.core.domain.Result; +import com.ruoyi.framework.exception.ErrorException; +import com.ruoyi.inspect.dto.ReportPageDto; +import com.ruoyi.inspect.service.InsReportService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.security.access.prepost.PreAuthorize; +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") + @PreAuthorize("@ss.hasPermi('business:reportPreparation')") + @PersonalScope(permsName = "business:reportPreparation", objectName = ReportPageDto.class, paramName = "createOrderUser") + public Result pageInsReport(Page page, ReportPageDto reportPageDto){ + return Result.success(insReportService.pageInsReport(page, 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(); + } + pathName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyMMddHHmmss")) + "_" + file.getOriginalFilename(); + urlString = realpath + "/" + pathName; + file.transferTo(new File(urlString)); + return Result.success(insReportService.inReport("/word/" + pathName, id)); + } catch (Exception e) { + throw new ErrorException("鏂囦欢涓婁紶澶辫触"); + } + } + + @ApiOperation(value = "鎶ュ憡杩樺師") + @PostMapping("/upReportUrl") + public Result upReportUrl(@RequestBody Map<String, Object> param) { + Integer id = (Integer) param.get("id"); + return Result.success(insReportService.upReportUrl(id)); + } + + @ApiOperation(value = "鎶ュ憡鍦ㄧ嚎缂栧埗") + @GetMapping("/upReportFile") + public Result upReportFile() { + return Result.success(); + } + + @ApiOperation(value = "鎻愪氦") + @PostMapping("/writeReport") + public Result writeReport(@RequestBody Map<String, Object> param) { + Integer id = (Integer) param.get("id"); + Integer userId = (Integer) param.get("userId"); + return Result.success(insReportService.writeReport(id, userId, null)); + } + + /** + * @param userId 闇�瑕佺殑鎵瑰噯浜� + * @return + */ + + @ApiOperation(value = "瀹℃牳") + @PostMapping("/examineReport") + public Result examineReport(@RequestBody Map<String, Object> param) { + Integer id = (Integer) param.get("id"); + Integer isExamine = (Integer) param.get("isExamine"); + String examineTell = (String) param.get("examineTell"); + Integer userId = (Integer) param.get("userId"); + return Result.success(insReportService.examineReport(id, isExamine, examineTell, userId)); + } + + @ApiOperation(value = "鎵瑰噯") + @PostMapping("/ratifyReport") + public Result ratifyReport(@RequestBody Map<String, Object> param) { + Integer id = (Integer) param.get("id"); + Integer isRatify = (Integer) param.get("isRatify"); + String ratifyTell = (String) param.get("ratifyTell"); + return Result.success(insReportService.ratifyReport(id, isRatify, ratifyTell)); + } + + @Anonymous + @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)); + } + + /** + * 閫�鍥炲埌妫�楠屼换鍔� + * @param id + * @return + */ + @ApiOperation(value = "閫�鍥炲埌妫�楠屼换鍔�") + @PostMapping("/sendBackTask") + public Result sendBackTask(@RequestBody Map<String, Object> param){ + Integer id = (Integer) param.get("id"); + return Result.success(insReportService.sendBackTask(id)); + } + + /** + * 鎶ュ憡瀵煎嚭 + * @param dto + * @param response + * @throws Exception + */ + @ApiOperation(value = "鎶ュ憡瀵煎嚭") + @GetMapping("/reportAllExport") + @PreAuthorize("@ss.hasPermi('business:reportPreparation')") + @PersonalScope(permsName = "business:reportPreparation", objectName = ReportPageDto.class, paramName = "createOrderUser") + public void reportAllExport(ReportPageDto dto, HttpServletResponse response) throws Exception { + insReportService.reportAllExport(dto,response); + } +} -- Gitblit v1.9.3