zss
2024-04-16 c219f11b51903d5aeb4c7ca261df593597aa7fe2
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsReportServiceImpl.java
@@ -1,6 +1,7 @@
package com.yuanchu.mom.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -12,6 +13,7 @@
import com.yuanchu.mom.dto.ReportPageDto;
import com.yuanchu.mom.dto.SampleOrderDto;
import com.yuanchu.mom.exception.ErrorException;
import com.yuanchu.mom.mapper.UserMapper;
import com.yuanchu.mom.pojo.InsReport;
import com.yuanchu.mom.service.InsReportService;
import com.yuanchu.mom.mapper.InsReportMapper;
@@ -24,6 +26,7 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
@@ -38,6 +41,9 @@
    @Resource
    private GetLook getLook;
    @Resource
    private UserMapper userMapper;
    @Resource
    private InsReportMapper insReportMapper;
@@ -79,6 +85,71 @@
    public int upReportUrl(Integer id) {
        return insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate().eq(InsReport::getId, id).set(InsReport::getUrlS, null));
    }
    //提交
    @Override
    public int writeReport(Integer id) {
        InsReport insReport = insReportMapper.selectById(id);
        insReport.setId(id);
        insReport.setState(1);
        insReport.setWriteUserId(getLook.selectPowerByMethodAndUserId(null).get("userId"));//提交人
        insReport.setWriteTime(LocalDateTime.now());//提交时间
        //获取提交人的签名地址
        String signatureUrl = userMapper.selectById(insReport.getWriteUserId()).getSignatureUrl();
        //系统生成报告地址
        String url = insReport.getUrl();
        //手动上传报告地址
        String urlS = insReport.getUrlS();
        return insReportMapper.updateById(insReport);
    }
    //审核
    @Override
    public int examineReport(Integer id, Integer isExamine, String examineTell) {
        InsReport insReport = insReportMapper.selectById(id);
        insReport.setIsExamine(isExamine);
        if (ObjectUtils.isNotEmpty(examineTell)) {
            insReport.setExamineTell(examineTell);
        }
        insReport.setExamineUserId(getLook.selectPowerByMethodAndUserId(null).get("userId"));//审核人
        insReport.setExamineTime(LocalDateTime.now());//审核时间
        if (isExamine==0){
            //如果审核不通过
            insReport.setState(0);//提交状态改为待提交
        }
        //获取审核人的签名地址
        String signatureUrl = userMapper.selectById(insReport.getExamineUserId()).getSignatureUrl();
        //系统生成报告地址
        String url = insReport.getUrl();
        //手动上传报告地址
        String urlS = insReport.getUrlS();
        return insReportMapper.updateById(insReport);
    }
    //批准
    @Override
    public int ratifyReport(Integer id, Integer isRatify, String ratifyTell) {
        InsReport insReport = insReportMapper.selectById(id);
        insReport.setIsRatify(isRatify);
        if (ObjectUtils.isNotEmpty(ratifyTell)) {
            insReport.setRatifyTell(ratifyTell);
        }
        insReport.setRatifyUserId(getLook.selectPowerByMethodAndUserId(null).get("userId"));//批准人
        insReport.setRatifyTime(LocalDateTime.now());//批准时间
        if (isRatify==0){
            //如果批准不通过
            insReport.setState(0);//提交状态改为待提交
        }
        //获取审核人的签名地址
        String signatureUrl = userMapper.selectById(insReport.getRatifyUserId()).getSignatureUrl();
        //系统生成报告地址
        String url = insReport.getUrl();
        //手动上传报告地址
        String urlS = insReport.getUrlS();
        return insReportMapper.updateById(insReport);
    }
}