From ff057092893a5c3852d66d2423cfeb5463106079 Mon Sep 17 00:00:00 2001 From: 李林 <z1292839451@163.com> Date: 星期一, 08 四月 2024 18:03:19 +0800 Subject: [PATCH] 费用统计 --- inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 44 insertions(+), 5 deletions(-) diff --git a/inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java b/inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java index 7532034..c580fc2 100644 --- a/inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java +++ b/inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java @@ -1,29 +1,36 @@ package com.yuanchu.mom.controller; +import cn.hutool.core.lang.UUID; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.yuanchu.mom.annotation.ValueAuth; import com.yuanchu.mom.dto.ReportPageDto; import com.yuanchu.mom.dto.SampleOrderDto; +import com.yuanchu.mom.exception.ErrorException; import com.yuanchu.mom.service.InsReportService; import com.yuanchu.mom.utils.JackSonUtil; import com.yuanchu.mom.vo.Result; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; +import javax.annotation.Resource; +import java.io.File; +import java.util.HashMap; import java.util.Map; -@AllArgsConstructor @RestController @RequestMapping("/insReport") @Api("妫�楠屾姤鍛�") public class InsReportController { + @Resource private InsReportService insReportService; + + @Value("${wordUrl}") + private String wordUrl; @ApiOperation(value = "鏌ヨ妫�楠屾姤鍛婃暟鎹�") @PostMapping("/pageInsReport") @@ -40,4 +47,36 @@ return Result.success("杞崲鎴愬姛", insReportService.wordToHtml(path)); } + @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 = UUID.randomUUID() + "_" + 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(Integer id) { + return Result.success(insReportService.upReportUrl(id)); + } + + @ApiOperation(value = "鎶ュ憡鍦ㄧ嚎缂栧埗") + @GetMapping("/upReportFile") + public Result upReportFile() { + return Result.success(); + } + } -- Gitblit v1.9.3