value
2024-04-16 01af9cb1c94e459184ad4d9836662094f14bac7e
inspect-server/src/main/java/com/yuanchu/mom/controller/InsReportController.java
@@ -1,28 +1,39 @@
package com.yuanchu.mom.controller;
import cn.hutool.core.lang.UUID;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
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.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
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")
@@ -32,4 +43,49 @@
        return Result.success(insReportService.pageInsReport(page, reportPageDto));
    }
    @ApiOperation(value = "Word转HTML")
    @PostMapping("/wordToHtml")
    @ValueAuth
    public Result wordToHtml(String path) {
        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 = 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(Integer id) {
        return Result.success(insReportService.upReportUrl(id));
    }
    @ApiOperation(value = "报告在线编制")
    @GetMapping("/upReportFile")
    public Result upReportFile() {
        return Result.success();
    }
    @ApiOperation(value = "提交编制内容")
    @PostMapping("/upReportWriteState")
    public Result<?> upReportWriteState(Integer id){
        return null;
    }
}