zhuo
2025-04-23 1f075ff6fdf2cdd4d15532b408ceb3420bcc1004
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsReportServiceImpl.java
@@ -22,11 +22,12 @@
import com.ruoyi.basic.mapper.IfsInventoryQuantityMapper;
import com.ruoyi.basic.pojo.IfsInventoryQuantity;
import com.ruoyi.common.constant.InsOrderTypeConstants;
import com.ruoyi.common.constant.MenuJumpPathConstants;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.common.core.domain.entity.InformationNotification;
import com.ruoyi.common.core.domain.entity.User;
import com.ruoyi.common.properties.WechatProperty;
import com.ruoyi.common.config.WechatProperty;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.api.IfsApiUtils;
import com.ruoyi.framework.exception.ErrorException;
import com.ruoyi.inspect.dto.ReportPageDto;
import com.ruoyi.inspect.mapper.*;
@@ -36,8 +37,10 @@
import com.ruoyi.inspect.mapper.InsUnqualifiedHandlerMapper;
import com.ruoyi.system.mapper.UserMapper;
import com.ruoyi.system.service.InformationNotificationService;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.*;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -65,6 +68,7 @@
 * @createDate 2024-03-17 22:10:02
 */
@Service
@Slf4j
public class InsReportServiceImpl extends ServiceImpl<InsReportMapper, InsReport>
        implements InsReportService {
    @Resource
@@ -81,8 +85,7 @@
    private String wordUrl;
    @Value("${file.path}")
    private String imgUrl;
    @Value("${file.licenseUrl}")
    private String licenseUrl;
    @Resource
    private InsOrderMapper insOrderMapper;
    @Resource
@@ -111,9 +114,11 @@
        // todo: 仅看自己
        //获取当前人所属实验室id
        String laboratory = null;
        Integer createOrderUser = null;
        Integer createOrderUser = reportPageDto.getCreateOrderUser();
        String queryStatus = reportPageDto.getQueryStatus();
        reportPageDto.setQueryStatus(null);
        reportPageDto.setCreateOrderUser(null);
        map.put("body", insReportMapper.pageInsReport(page,
                QueryWrappers.queryWrappers(reportPageDto),
@@ -185,7 +190,7 @@
        info.setSenderId(submitUserId);    //发送人
        info.setConsigneeId(userId);     //收件人
        info.setViewStatus(false);
        info.setJumpPath("b1-report-preparation");
        info.setJumpPath(MenuJumpPathConstants.REPORT_PREPARATION);
        informationNotificationService.addInformationNotification(info);
        //系统生成报告地址
        String url = insReport.getUrl();
@@ -257,7 +262,7 @@
                IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId());
                String message = "";
                message += "报告编制审核退回通知";
                message += "耐丝系统报告编制审核退回通知";
                message += "\n审核人: " + checkUserName;
                message += "\n委托编号: " + order.getEntrustCode();
                message += "\n样品名称: " + insSample.getModel();
@@ -306,7 +311,7 @@
        info.setSenderId(checkUserId);    //发送人
        info.setConsigneeId(userId);     //收件人
        info.setViewStatus(false);
        info.setJumpPath("b1-report-preparation");
        info.setJumpPath(MenuJumpPathConstants.REPORT_PREPARATION);
        informationNotificationService.addInformationNotification(info);
        //系统生成报告地址
        String url = insReport.getUrl();
@@ -332,7 +337,7 @@
            IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId());
            String message = "";
            message += "报告编制批准通知";
            message += "耐丝系统报告编制批准通知";
            message += "\n检验人: " + userName;
            message += "\n复核人: " + checkUserName;
            message += "\n委托编号: " + order.getEntrustCode();
@@ -394,7 +399,7 @@
                IfsInventoryQuantity ifsInventoryQuantity = ifsInventoryQuantityMapper.selectById(order.getIfsInventoryId());
                String message = "";
                message += "报告编制批准退回通知";
                message += "耐丝系统报告编制批准退回通知";
                message += "\n批准人: " + ratifyUserName;
                message += "\n委托编号: " + order.getEntrustCode();
                message += "\n样品名称: " + insSample.getModel();
@@ -535,12 +540,16 @@
            }
            // 压缩临时文件夹
            zipFilePath = wordUrl + "/zip/output.zip";
            // 判断zip路径是否存在
            File zipDir = new File(wordUrl + "/zip");
            if(!zipDir.isDirectory()){
                zipDir.mkdirs();
            }
            zipDirectory(tempFolderPath, zipFilePath);
            // 清理临时文件夹
            deleteDirectory(tempFolder);
            System.out.println("ZIP文件创建完成!");
        } catch (IOException e) {
            e.printStackTrace();
        }
@@ -675,13 +684,11 @@
        FileOutputStream os = null;
        try {
            //凭证 不然切换后有水印
//            InputStream is = this.getClass().getResourceAsStream("/lib/license.xml");
//            InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream("license.xml");
            InputStream is = Files.newInputStream(new File(licenseUrl).toPath());
            InputStream is = new ClassPathResource("/lib/license.xml").getInputStream();
            License license = new License();
            license.setLicense(is);
            if (!license.getIsLicensed()) {
                System.out.println("License验证不通过...");
                log.info("License验证不通过...");
                return null;
            }
            //生成一个空的PDF文件
@@ -1116,11 +1123,11 @@
        FileOutputStream os = null;
        try {
            //凭证 不然切换后有水印
            InputStream is = Files.newInputStream(new File(licenseUrl).toPath());
            InputStream is = new ClassPathResource("/lib/license.xml").getInputStream();
            License license = new License();
            license.setLicense(is);
            if (!license.getIsLicensed()) {
                System.out.println("License验证不通过...");
                log.info("License验证不通过...");
                return null;
            }
            //生成一个空的PDF文件
@@ -1131,7 +1138,6 @@
            //要转换的word文件
            com.aspose.words.Document doc = new com.aspose.words.Document(wordPath);
            doc.save(os, SaveFormat.PDF);
            String name = file.getName();
            return file.getName();
        } catch (Exception e) {
            e.printStackTrace();