| ¶Ô±ÈÐÂÎļþ |
| | |
| | | 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(); |
| | | // è·åä¼ è¾çjsonæ°æ® |
| | | 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ä¼è®¤ä¸ºåè°æ¥å£æ¯æ²¡é®é¢çï¼è¿æ ·å°±å¯ä»¥å¨çº¿ç¼è¾ææ¡£äºï¼å¦åçè¯ä¼å¼¹åºçªå£è¯´æ |
| | | */ |
| | | 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)); |
| | | } |
| | | |
| | | |
| | | |
| | | } |