liding
5 小时以前 51786b723d0a91d11476776d9ce50af7994dc4bd
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsOrderPlanServiceImpl.java
@@ -46,6 +46,7 @@
import com.ruoyi.inspect.service.*;
import com.ruoyi.inspect.util.HackLoopTableRenderPolicy;
import com.ruoyi.inspect.util.PreserveReportPicturePlaceholderHandler;
import com.ruoyi.inspect.util.ReportSignaturePictureUtils;
import com.ruoyi.inspect.vo.InsOrderPlanTaskSwitchVo;
import com.ruoyi.inspect.vo.InsOrderPlanVO;
import com.ruoyi.inspect.vo.InsSampleUserVO;
@@ -273,11 +274,11 @@
        // 查询订单Id
        InsOrder order = insOrderMapper.selectFirstSubmit(dto.getId());
        if (order == null) {
            return BeanUtil.isEmpty(insProducts) ? null : insProducts;
            return BeanUtil.isEmpty(insProducts) ? Collections.emptyList() : insProducts;
        }
        insProducts = mergeDirectTemplateSnapshots(order, dto.getId(), dto.getLaboratory(), insProducts);
        if (BeanUtil.isEmpty(insProducts)) {
            return null;
            return Collections.emptyList();
        }
        getTemplateThing(order, insProducts, dto.getLaboratory());
        return insProducts;
@@ -299,14 +300,6 @@
        if (snapshots.isEmpty()) {
            return source;
        }
        InsSample sample = insSampleMapper.selectById(sampleId);
        boolean directTemplateOrder = source.stream()
                .anyMatch(product -> product.getTemplateRowIndex() != null)
                || isDirectTemplateSample(order, sample);
        if (!directTemplateOrder) {
            return source;
        }
        Map<Integer, List<InsProduct>> productsByTemplate = source.stream()
                .filter(product -> product.getTemplateId() != null)
                .collect(Collectors.groupingBy(InsProduct::getTemplateId, LinkedHashMap::new, Collectors.toList()));
@@ -1217,13 +1210,12 @@
                .last("FOR UPDATE"));
        boolean isInspectionReport = Objects.equals(INSPECTION_REPORT, reportType);
        registerInsResults = isInspectionReport && Boolean.TRUE.equals(registerInsResults);
        // 1. 判断是否有重复编号, 有重复编号做提醒
        // 1. 委托编号全局唯一,提交复核时再次校验,防止并发或历史数据绕过生成校验。
        Long codeCount = insOrderMapper.selectCount(Wrappers.<InsOrder>lambdaQuery()
                .ne(InsOrder::getState, -1)
                .ne(InsOrder::getIfsInventoryId, order.getIfsInventoryId())
                .ne(InsOrder::getId, orderId)
                .eq(InsOrder::getEntrustCode, order.getEntrustCode()));
        if (codeCount > 0) {
            throw new ErrorException("当前编号有重复, 请先去修改重复编号");
            throw new ErrorException("样品/委托单已存在,请确认样品编号");
        }
        // 2. 判断该订单是否是第一次生产(后续报告生成只取第一次提交时间)
@@ -1985,13 +1977,13 @@
                || report.getExamineTime() != null;
        if (submitted) {
            User writer = getReportSigner(report.getWriteUserId(), "编制人");
            marks.put("writeUrl", Pictures.ofLocal(imgUrl + "/" + writer.getSignatureUrl()).create());
            marks.put("writeUrl", ReportSignaturePictureUtils.create(imgUrl, writer.getSignatureUrl()));
            marks.put("writeDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(report.getWriteTime())).create());
            marks.put("insUrl", Pictures.ofLocal(imgUrl + "/" + writer.getSignatureUrl()).create());
            marks.put("insUrl", ReportSignaturePictureUtils.create(imgUrl, writer.getSignatureUrl()));
        }
        if (Objects.equals(report.getIsExamine(), 1)) {
            User examiner = getReportSigner(report.getExamineUserId(), "审核人");
            marks.put("examineUrl", Pictures.ofLocal(imgUrl + "/" + examiner.getSignatureUrl()).create());
            marks.put("examineUrl", ReportSignaturePictureUtils.create(imgUrl, examiner.getSignatureUrl()));
            marks.put("examineDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(report.getExamineTime())).create());
        }
        return marks;
@@ -2536,13 +2528,18 @@
        enterFactoryReport.setLotBatchNo(ifsInventoryQuantity.getUpdateBatchNo());
        // 检测依据
        Set<String> standardMethod = new HashSet<>();
        Set<String> standardMethod = new LinkedHashSet<>();
        StringBuilder standardMethod2 = new StringBuilder();
        standardMethod.add(baseMapper.getStandardMethodCode(insSample.getStandardMethodListId()));
        String reportStandardMethod = baseMapper.getStandardMethodReportText(insSample.getStandardMethodListId());
        if (StringUtils.isNotBlank(reportStandardMethod)) {
            standardMethod.add(reportStandardMethod);
        }
        for (String s : standardMethod) {
            standardMethod2.append("、").append(s);
        }
        standardMethod2.replace(0, 1, "");
        if (standardMethod2.length() > 0) {
            standardMethod2.deleteCharAt(0);
        }
        // 样品类型
        String orderType = iSysDictTypeService.selectLabelByDict(DictDataConstants.CHECK_TYPE, insOrder.getOrderType());
@@ -3214,7 +3211,7 @@
        insReport.setReportType(reportType);
        boolean showResult = Objects.equals(reportType, INSPECTION_REPORT);
        List<Map<String, Object>> tables = new ArrayList<>();
        Set<String> standardMethod = new HashSet<>();
        Set<String> standardMethod = new LinkedHashSet<>();
        Set<String> deviceSet = new HashSet<>();
        Set<String> models = new HashSet<>();
        // 查询检验项数量
@@ -3227,11 +3224,13 @@
        /*基础报告(根据绘制的原始记录模版形成)*/
        samples.forEach(a -> {
            models.add(a.getModel());
            String standardMethodCode = baseMapper.getStandardMethodCode(a.getStandardMethodListId());
            if (StrUtil.isNotBlank(a.getSpecialStandardMethod())) {
                standardMethodCode = standardMethodCode + "+" + a.getSpecialStandardMethod();
            String standardMethodCode = baseMapper.getStandardMethodReportText(a.getStandardMethodListId());
            if (StrUtil.isNotBlank(standardMethodCode)) {
                if (StrUtil.isNotBlank(a.getSpecialStandardMethod())) {
                    standardMethodCode = standardMethodCode + "+" + a.getSpecialStandardMethod();
                }
                standardMethod.add(standardMethodCode);
            }
            standardMethod.add(standardMethodCode);
            for (InsProduct b : a.getInsProduct()) {
                if (b.getInsProductResult() != null) {
                    List<JSONObject> jsonObjects = JSON.parseArray(b.getInsProductResult().getEquipValue(), JSONObject.class);
@@ -3577,9 +3576,11 @@
        if (firstInspectDate == null) {
            firstInspectDate = insOrder.getSendTime();
        }
        if (firstInspectDate == null) {
            firstInspectDate = submitTime;
        }
        String insTime = firstInspectDate.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")) + "-"
                + submitTime.format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
        String insTime = formatReportTestDate(firstInspectDate, submitTime);
        String insTimeEn = monthNames[firstInspectDate.getMonthValue() - 1] + " " + firstInspectDate.format(DateTimeFormatter.ofPattern("dd, yyyy")) + "-"
                + monthNames[submitTime.getMonthValue() - 1] + " " + submitTime.format(DateTimeFormatter.ofPattern("dd, yyyy"));
@@ -3636,11 +3637,8 @@
                productionDate = insOrder.getProductionDate().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日"));
            }
            batchNo = defaultReportText(insOrder.getProductionBatch(), "/");
            standardMethodText = templateSnapshots.stream()
                    .map(InsOrderStandardTemplate::getRemark)
                    .filter(StringUtils::isNotBlank)
                    .distinct()
                    .collect(Collectors.joining(";"));
            standardMethodText = defaultReportText(
                    baseMapper.getStandardMethodReportTextByCode(insOrder.getSample()), insOrder.getSample());
        }
        boolean containsOrganicChlorine = detectionResultRows.stream()
                .map(row -> row.get("itemName"))
@@ -3943,16 +3941,21 @@
        if (CollectionUtils.isEmpty(deviceList)) {
            return "/";
        }
        Set<String> lines = new LinkedHashSet<>();
        int sequence = 1;
        Set<String> equipmentItems = new LinkedHashSet<>();
        for (Map<String, String> device : deviceList) {
            String name = getMapText(device, "deviceName", "device_name");
            String managementNumber = getMapText(device, "managementNumber", "management_number");
            String line = sequence++ + ". " + defaultReportText(name, "/");
            String item = defaultReportText(name, "/");
            if (StringUtils.isNotBlank(managementNumber)) {
                line += ":" + managementNumber;
                item += ":" + managementNumber;
            }
            lines.add(line);
            equipmentItems.add(item);
        }
        List<String> items = new ArrayList<>(equipmentItems);
        List<String> lines = new ArrayList<>();
        for (int i = 0; i < items.size(); i++) {
            String punctuation = i == items.size() - 1 ? "。" : ";";
            lines.add((i + 1) + ". " + items.get(i) + punctuation);
        }
        return String.join("\n", lines);
    }
@@ -3973,7 +3976,7 @@
                .collect(Collectors.toList());
        String temperature = formatConditionRange(temperatures, order.getTemperature(), "℃");
        String humidity = formatConditionRange(humidities, order.getHumidity(), "%");
        String humidity = formatConditionRange(humidities, order.getHumidity(), "%RH");
        return Stream.of(temperature, humidity)
                .filter(StringUtils::isNotBlank)
                .collect(Collectors.joining(" "));
@@ -4046,6 +4049,14 @@
        return StringUtils.isNotBlank(fallback) ? fallback : "/";
    }
    private static String formatReportTestDate(LocalDateTime startTime, LocalDateTime endTime) {
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        if (startTime.toLocalDate().equals(endTime.toLocalDate())) {
            return startTime.format(formatter);
        }
        return startTime.format(formatter) + "至" + endTime.format(formatter);
    }
    /**
     * 计算表格列宽度
     *