| | |
| | | |
| | | JSONObject values = JSON.parseObject(JSON.toJSONString(dto.getValues() == null |
| | | ? Collections.emptyMap() : dto.getValues())); |
| | | List<String> exportValueCoordinates = getExportValueCoordinates(snapshot.getThing()).values().stream() |
| | | // 检验期间页面展示的是标准维护中的最新模板,保存校验必须使用同一份模板, |
| | | // 避免模板新增“导出值”批注后仍按下单时的旧快照误报未配置。 |
| | | String currentTemplateThing = getCurrentTemplateThing(snapshot); |
| | | List<String> exportValueCoordinates = getExportValueCoordinates(currentTemplateThing).values().stream() |
| | | .flatMap(Collection::stream) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 检验保存、提交校验读取标准维护中的实时模板;模板已被删除或内容为空时才回退订单快照。 |
| | | * 检验完成后的展示和报告仍由订单快照负责,不会随标准模板后续修改而变化。 |
| | | */ |
| | | private String getCurrentTemplateThing(InsOrderStandardTemplate snapshot) { |
| | | if (snapshot != null && snapshot.getTemplateId() != null) { |
| | | StandardTemplate currentTemplate = standardTemplateService.getById(snapshot.getTemplateId()); |
| | | if (currentTemplate != null && StrUtil.isNotBlank(currentTemplate.getThing())) { |
| | | return currentTemplate.getThing(); |
| | | } |
| | | } |
| | | return snapshot == null ? null : snapshot.getThing(); |
| | | } |
| | | |
| | | /** |
| | | * 直绑模板订单只校验模板中标记为“导出值”的单元格,不使用检验项状态或 last_value 判定。 |
| | | */ |
| | | private List<String> getMissingTemplateExportValues(Integer orderId) { |
| | |
| | | } |
| | | for (InsOrderStandardTemplate snapshot : snapshots) { |
| | | Integer templateId = snapshot.getTemplateId(); |
| | | List<String> coordinates = getExportValueCoordinates(snapshot.getThing()).values().stream() |
| | | List<String> coordinates = getExportValueCoordinates(getCurrentTemplateThing(snapshot)).values().stream() |
| | | .flatMap(Collection::stream) |
| | | .distinct() |
| | | .collect(Collectors.toList()); |
| | |
| | | // 来样方式 |
| | | String formType = iSysDictTypeService.selectLabelByDict(DictDataConstants.FORM_TYPE, insOrder.getFormType()); |
| | | |
| | | // 样品状态 |
| | | String sampleStatus = iSysDictTypeService.selectLabelByDict(DictDataConstants.SAMPLE_STATUS_LIST, insOrder.getSampleStatus()); |
| | | ; |
| | | // 样品外观优先展示字典名称;历史数据或直接保存文本时,回退展示订单原值。 |
| | | String sampleStatus = defaultReportText( |
| | | iSysDictTypeService.selectLabelByDict( |
| | | DictDataConstants.SAMPLE_STATUS_LIST, insOrder.getSampleStatus()), |
| | | insOrder.getSampleStatus()); |
| | | |
| | | // 公司信息 |
| | | Custom custom = customMapper.selectById(insOrder.getCompanyId()); |
| | |
| | | |
| | | Map<String, String> row = new LinkedHashMap<>(); |
| | | row.put("seq", String.valueOf(sequence++)); |
| | | row.put("itemName", defaultReportText(itemName, |
| | | defaultReportText(snapshot.getName(), "模板ID " + snapshot.getTemplateId()))); |
| | | String reportItemName = defaultReportText(itemName, |
| | | defaultReportText(snapshot.getName(), "模板ID " + snapshot.getTemplateId())); |
| | | row.put("itemName", formatExportItemName(reportItemName)); |
| | | row.put("unit", defaultReportText(unit, "/")); |
| | | row.put("result", result); |
| | | rows.add(row); |
| | |
| | | } |
| | | } |
| | | if (numbers.isEmpty()) { |
| | | return StringUtils.isBlank(fallback) ? "" : fallback + unit; |
| | | // “/”表示模板明确填写了不适用,不能再按空值处理或追加单位。 |
| | | return candidates.stream() |
| | | .filter(StringUtils::isNotBlank) |
| | | .map(String::trim) |
| | | .distinct() |
| | | .collect(Collectors.joining("~")); |
| | | } |
| | | BigDecimal minimum = Collections.min(numbers); |
| | | BigDecimal maximum = Collections.max(numbers); |
| | |
| | | return minimumText + "~" + maximum.stripTrailingZeros().toPlainString() + unit; |
| | | } |
| | | |
| | | /** 报告项目名称不展示模板计算过程中的“平均值”字样及其后的分隔逗号。 */ |
| | | private static String formatExportItemName(String itemName) { |
| | | if (StringUtils.isBlank(itemName)) { |
| | | return itemName; |
| | | } |
| | | return itemName.replaceAll("平均值\\s*[,,]?\\s*", ""); |
| | | } |
| | | |
| | | private static String getMapText(Map<String, String> map, String... keys) { |
| | | if (map == null) { |
| | | return null; |