Fixiaobai
2023-09-04 dd2554435b9ced61e2a6a06627145fca3bf2685b
inspection-server/src/main/java/com/yuanchu/limslaboratory/controller/ReportController.java
@@ -3,18 +3,22 @@
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuanchu.limslaboratory.annotation.AuthHandler;
import com.yuanchu.limslaboratory.enums.InterfaceType;
import com.yuanchu.limslaboratory.enums.MenuEnums;
import com.yuanchu.limslaboratory.pojo.vo.ReportVo;
import com.yuanchu.limslaboratory.service.ReportService;
import com.yuanchu.limslaboratory.utils.JackSonUtil;
import com.yuanchu.limslaboratory.utils.MyUtil;
import com.yuanchu.limslaboratory.utils.RedisUtil;
import com.yuanchu.limslaboratory.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
@@ -31,10 +35,8 @@
@RestController
@RequestMapping("/report")
public class ReportController {
    /**
     * 服务对象
     */
    @Autowired
    @Resource
    private ReportService reportService;
    @ApiOperation("查询检验报告")
@@ -45,6 +47,7 @@
            @ApiImplicitParam(name = "name", value = "搜索信息", dataTypeClass = String.class)
    })
    @GetMapping("/selectAllReport")
    @AuthHandler
    public Result selectAllReport(Integer page, Integer pageSize, Integer status, String name) {
        IPage<ReportVo> reportPage = reportService.selectAllReport(new Page<Object>(page, pageSize), status, name);
        Map<String, Object> map = new HashMap<>();
@@ -53,5 +56,55 @@
        return Result.success(map);
    }
    @ApiOperation("提交")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验报告id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/submit")
    @AuthHandler
    public Result submit(Integer id) {
        return Result.success(reportService.submit(id));
    }
    @ApiOperation("审核")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验报告id", dataTypeClass = Integer.class, required = true),
            @ApiImplicitParam(name = "result", value = "审核结论", dataTypeClass = String.class, required = true)
    })
    @PostMapping("/check")
    @AuthHandler
    public Result check(@RequestHeader("X-Token") String token, Integer id, Integer result) throws Exception {
        Object object = RedisUtil.get(token);
        Map<String, Object> unmarshal = JackSonUtil.unmarshal(JackSonUtil.marshal(object), Map.class);
        MyUtil.PrintLog(unmarshal + "-------id" + id + "=========" + result);
        return Result.success(reportService.check((String) unmarshal.get("name"), id, result));
    }
    @ApiOperation("删除")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "id", value = "检验报告id", dataTypeClass = Integer.class, required = true)
    })
    @PostMapping("/delreport")
    @AuthHandler
    public Result delreport(Integer id) {
        return Result.success(reportService.delreport(id));
    }
    @ApiOperation("获取报告内的数据")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "code", value = "报告单号", dataTypeClass = String.class, required = true)
    })
    @PostMapping("/getReportContext")
    @AuthHandler
    public Result getReportContext(String code) {
        return Result.success(reportService.getReportContext(code));
    }
    @GetMapping("/getEnterprise")
    @ApiOperation("获取企业信息")
    @AuthHandler(type = InterfaceType.SELECT,menuId = MenuEnums.checkTheReport,isAdd = true)
    public Result getEnterprise() {
        return Result.success(reportService.getEnterprise());
    }
}