liding
7 天以前 3728fa293e1faf4bf4f9bf41105b84ddb43dc82e
inspect-server/src/main/java/com/ruoyi/inspect/service/impl/InsProductServiceImpl.java
@@ -77,7 +77,24 @@
            if (snapshot == null) {
                throw new ErrorException("未找到当前模板的原始记录快照");
            }
            boolean hasSnapshotField = dto.isTemperaturePresent() || dto.isDetectionTimePresent()
            boolean hasDetectionRange = dto.isDetectionTimePresent() || dto.isDetectionEndTimePresent();
            if (hasDetectionRange) {
                if (!dto.isDetectionTimePresent()) {
                    throw new ErrorException("请选择完整的检测时间范围");
                }
                // 兼容旧客户端只提交单个日期;新客户端必须同时提交起止日期或同时清空。
                if (!dto.isDetectionEndTimePresent()) {
                    dto.setDetectionEndTime(dto.getDetectionTime());
                }
                if ((dto.getDetectionTime() == null) != (dto.getDetectionEndTime() == null)) {
                    throw new ErrorException("请选择完整的检测时间范围");
                }
                if (dto.getDetectionTime() != null
                        && dto.getDetectionEndTime().isBefore(dto.getDetectionTime())) {
                    throw new ErrorException("检测结束日期不能早于开始日期");
                }
            }
            boolean hasSnapshotField = dto.isTemperaturePresent() || hasDetectionRange
                    || dto.isDetectionPlacePresent()
                    || dto.isInsResultPresent();
            if (hasSnapshotField) {
@@ -88,12 +105,19 @@
                                        InsOrderStandardTemplate::getTemperature, dto.getTemperature())
                                .set(dto.isDetectionTimePresent(),
                                        InsOrderStandardTemplate::getDetectionTime, dto.getDetectionTime())
                                .set(hasDetectionRange,
                                        InsOrderStandardTemplate::getDetectionEndTime, dto.getDetectionEndTime())
                                .set(dto.isDetectionPlacePresent(),
                                        InsOrderStandardTemplate::getDetectionPlace, dto.getDetectionPlace())
                                .set(dto.isInsResultPresent(),
                                        InsOrderStandardTemplate::getInsResult, dto.getInsResult()));
            }
            if (dto.isDeviceIdsPresent()) {
                // 手动选择或清空都视为已初始化,后续进入任务不得再次套用标准库默认值。
                insOrderStandardTemplateMapper.update(null,
                        Wrappers.<InsOrderStandardTemplate>lambdaUpdate()
                                .eq(InsOrderStandardTemplate::getId, snapshot.getId())
                                .set(InsOrderStandardTemplate::getDeviceDefaultsInitialized, 1));
                insOrderTemplateDeviceMapper.delete(
                        Wrappers.<InsOrderTemplateDevice>lambdaQuery()
                                .eq(InsOrderTemplateDevice::getInsOrderId, dto.getId())