| | |
| | | |
| | | /** |
| | | * 直绑模板订单的页签来源是订单模板快照,而不是已生成的检验项。 |
| | | * |
| | | * <p> |
| | | * 仍保留每个模板下已有的检验项记录;如果某个模板没有“检验项”标记,补一条仅用于 |
| | | * 承载模板内容的返回对象,使前端也能展示、填写该模板。 |
| | | */ |
| | | private List<InsProduct> mergeDirectTemplateSnapshots(InsOrder order, Integer sampleId, |
| | | String laboratory, List<InsProduct> products) { |
| | | String laboratory, List<InsProduct> products) { |
| | | List<InsProduct> source = products == null ? new ArrayList<>() : products; |
| | | List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list( |
| | | Wrappers.<InsOrderStandardTemplate>lambdaQuery() |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String,Object> checkSubmitPlan(Integer orderId, String laboratory) { |
| | | public Map<String, Object> checkSubmitPlan(Integer orderId, String laboratory) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<String> collect = new ArrayList<>(); |
| | | if (isDirectTemplateOrder(orderId)) { |
| | |
| | | |
| | | JSONObject recordValues = StrUtil.isBlank(snapshot.getRecordValues()) |
| | | ? new JSONObject() : JSON.parseObject(snapshot.getRecordValues()); |
| | | // 保存时同样只取模板中的第一个导出值,提交校验与保存口径保持一致。 |
| | | String coordinate = coordinates.get(0); |
| | | JSONObject cell = recordValues.getJSONObject(coordinate); |
| | | Object value = cell == null ? null : cell.get("v"); |
| | | if (value == null || StringUtils.isBlank(String.valueOf(value))) { |
| | | missing.add(templateName + "(" + coordinate + ")"); |
| | | for (String coordinate : coordinates) { |
| | | JSONObject cell = recordValues.getJSONObject(coordinate); |
| | | Object value = cell == null ? null : cell.get("v"); |
| | | if (value == null || StringUtils.isBlank(String.valueOf(value))) { |
| | | missing.add(templateName + "(" + coordinate + ")"); |
| | | } |
| | | } |
| | | } |
| | | return missing; |
| | |
| | | throw new ErrorException("检验单不存在"); |
| | | } |
| | | Set<Integer> deviceIds = dto.getDeviceIds() == null ? Collections.emptySet() : dto.getDeviceIds().stream() |
| | | .filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | .filter(Objects::nonNull).collect(Collectors.toSet()); |
| | | List<InsOrderDeviceRecord> oldRecords = insOrderDeviceRecordMapper.selectList( |
| | | Wrappers.<InsOrderDeviceRecord>lambdaQuery().eq(InsOrderDeviceRecord::getInsOrderId, dto.getOrderId())); |
| | | Set<Integer> oldIds = oldRecords.stream().map(InsOrderDeviceRecord::getDeviceId).collect(Collectors.toSet()); |
| | |
| | | |
| | | /** |
| | | * 查询模板内容 |
| | | * |
| | | * @param order |
| | | * @param insProducts |
| | | */ |
| | |
| | | |
| | | /** |
| | | * todo: 原始记录模板清除没有使用的检验项(暂时有bug无法使用) |
| | | * |
| | | * @param sheet |
| | | * @param itemNameList |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 坐标拼接 |
| | | * |
| | | * @param r 横坐标 |
| | | * @param c 纵坐标 |
| | | * @return |
| | |
| | | int count = 0; |
| | | for (InsProduct product : insProducts) { |
| | | count++; |
| | | str += (count != 0 ? "\n" : "") + count + ":" + |
| | | str += (count != 0 ? "\n" : "") + count + ":" + |
| | | product.getInspectionItemClass() + " " + |
| | | product.getInspectionItem() + " " + |
| | | product.getInspectionItemSubclass(); |
| | |
| | | // 登记检验结果 |
| | | // 判断是否有不合格, 有不合格不能移库 |
| | | // todo: ifs移库 |
| | | insReportService.isRawMaterial(order,registerInsResults,false); |
| | | insReportService.isRawMaterial(order, registerInsResults, false); |
| | | |
| | | // 14 判断当前样品是否为原材料, 原材料需要进行数据分析, 判断之前10条数据同一个供应商, 同一个检验项的偏差是否超过10% |
| | | // 查询ifs信息获取获取前10个供应商一样的, 检验项一样信息 |
| | |
| | | |
| | | /** |
| | | * *****添加分析数据****** |
| | | * |
| | | * @param productList |
| | | * @param ifsInventoryQuantity |
| | | * @param order |
| | |
| | | |
| | | /** |
| | | * *****计算偏差**** |
| | | * |
| | | * @param data |
| | | * @param targetStr |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * *****计算偏差(要求值)**** |
| | | * |
| | | * @param asked |
| | | * @param targetStr |
| | | * @return |
| | | */ |
| | | public static double isDeviationOverTenPercentByAsked(String asked, String targetStr) { |
| | | if(!isNumeric(asked)) return 0; |
| | | if (!isNumeric(asked)) return 0; |
| | | double average = Double.parseDouble(asked); |
| | | double target = Double.parseDouble(targetStr); |
| | | double deviationPercent = Math.abs(target - average) / average * 100; |
| | |
| | | |
| | | /** |
| | | * ******原始记录模板复制***** |
| | | * |
| | | * @param orderId |
| | | * @param ids |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 检验任务复核 |
| | | * |
| | | * @param orderId |
| | | * @param laboratory |
| | | * @param type |
| | |
| | | .collect(Collectors.toList()); |
| | | if (templateResults.isEmpty() |
| | | || templateResults.stream().anyMatch(result -> !Objects.equals(result, 0) |
| | | && !Objects.equals(result, 1))) { |
| | | && !Objects.equals(result, 1))) { |
| | | throw new ErrorException("请先填写全部模板的检验结论"); |
| | | } |
| | | Integer aggregateResult = templateResults.stream().allMatch(result -> Objects.equals(result, 1)) |
| | |
| | | |
| | | /** |
| | | * 生成报告 |
| | | * |
| | | * @param orderId |
| | | */ |
| | | private void generateReport(Integer orderId, Integer reportType, Integer writeUserId) { |
| | |
| | | //这里的insSamples是订单下的所有样品包括("/") |
| | | List<InsSample> insSamples = insSampleMapper.selectList(Wrappers.<InsSample>lambdaQuery().eq(InsSample::getInsOrderId, orderId)); |
| | | if (Objects.equals(reportType, INSPECTION_REPORT)) { |
| | | for (InsSample insSample : insSamples) { |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getState, 1) |
| | | .ne(InsProduct::getIsBinding, 1)); |
| | | List<Integer> results = insProducts.stream().map(InsProduct::getInsResult).filter(Objects::nonNull).collect(Collectors.toList()); |
| | | if (results.contains(0)) { |
| | | insSample.setInsResult(0); |
| | | } else { |
| | | insSample.setInsResult(1); |
| | | for (InsSample insSample : insSamples) { |
| | | List<InsProduct> insProducts = insProductMapper.selectList(Wrappers.<InsProduct>lambdaQuery() |
| | | .eq(InsProduct::getInsSampleId, insSample.getId()) |
| | | .eq(InsProduct::getState, 1) |
| | | .ne(InsProduct::getIsBinding, 1)); |
| | | List<Integer> results = insProducts.stream().map(InsProduct::getInsResult).filter(Objects::nonNull).collect(Collectors.toList()); |
| | | if (results.contains(0)) { |
| | | insSample.setInsResult(0); |
| | | } else { |
| | | insSample.setInsResult(1); |
| | | } |
| | | insSampleMapper.updateById(insSample); |
| | | } |
| | | insSampleMapper.updateById(insSample); |
| | | } |
| | | } |
| | | InsOrder insOrder = insOrderMapper.selectById(orderId); |
| | | // 抽检变成委托检验 |
| | |
| | | |
| | | /** |
| | | * 电缆配置, 查看配置标识 |
| | | * |
| | | * @param id |
| | | * @param laboratory |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 原材料查看标识 |
| | | * |
| | | * @param id |
| | | * @param laboratory |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 查看重复标识 |
| | | * |
| | | * @param id |
| | | * @param laboratory |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 新增不合格复测内容 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | |
| | | /** |
| | | * 查询进货原始记录 |
| | | * |
| | | * @param insOrderId |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 保存原材料进货验证 |
| | | * |
| | | * @param factoryVerify |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 设置表格样式 |
| | | * |
| | | * @param max 标识最大个数 |
| | | * @return |
| | | */ |
| | | private TableStyle setTableStyle(int max, boolean showResult){ |
| | | private TableStyle setTableStyle(int max, boolean showResult) { |
| | | //设置样式 |
| | | TableStyle tableStyle = new TableStyle(); |
| | | if (!showResult) { |
| | | switch (max) { |
| | | case 1: tableStyle.setColWidths(new int[]{650, 3000, 850, 2400, 3100}); break; |
| | | case 2: tableStyle.setColWidths(new int[]{650, 2800, 850, 2200, 1750, 1750}); break; |
| | | case 3: tableStyle.setColWidths(new int[]{650, 2600, 850, 1800, 1400, 1400, 1400}); break; |
| | | case 4: tableStyle.setColWidths(new int[]{650, 2400, 850, 1600, 1125, 1125, 1125, 1125}); break; |
| | | case 5: tableStyle.setColWidths(new int[]{650, 2200, 850, 1500, 960, 960, 960, 960, 960}); break; |
| | | default: break; |
| | | case 1: |
| | | tableStyle.setColWidths(new int[]{650, 3000, 850, 2400, 3100}); |
| | | break; |
| | | case 2: |
| | | tableStyle.setColWidths(new int[]{650, 2800, 850, 2200, 1750, 1750}); |
| | | break; |
| | | case 3: |
| | | tableStyle.setColWidths(new int[]{650, 2600, 850, 1800, 1400, 1400, 1400}); |
| | | break; |
| | | case 4: |
| | | tableStyle.setColWidths(new int[]{650, 2400, 850, 1600, 1125, 1125, 1125, 1125}); |
| | | break; |
| | | case 5: |
| | | tableStyle.setColWidths(new int[]{650, 2200, 850, 1500, 960, 960, 960, 960, 960}); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } else if(max<=5){ |
| | | } else if (max <= 5) { |
| | | for (int i = 1; i <= max; i++) { |
| | | // 根据检验结果个数修改长度 |
| | | switch (i) { |
| | |
| | | |
| | | /** |
| | | * 处理有电缆颜色标识的检测项 |
| | | * @param cableTags 电缆颜色标识 |
| | | * @param collect 检测项列表 |
| | | * |
| | | * @param cableTags 电缆颜色标识 |
| | | * @param collect 检测项列表 |
| | | * @param startIndex 起始下标 |
| | | * @param endIndex 结束下标 |
| | | * @return |
| | | */ |
| | | private List<SampleProductExportDto> transformSampleProduct(List<String> cableTags,Map<String, List<SampleProductExportDto>> collect,int startIndex,int endIndex){ |
| | | private List<SampleProductExportDto> transformSampleProduct(List<String> cableTags, Map<String, List<SampleProductExportDto>> collect, int startIndex, int endIndex) { |
| | | List<SampleProductExportDto> sampleProductExportDtos = new ArrayList<>(); |
| | | for (String s : collect.keySet()) { |
| | | List<String> lastValueList = new ArrayList<>(); |
| | | SampleProductExportDto dto = new SampleProductExportDto(); |
| | | BeanUtil.copyProperties(collect.get(s).get(0),dto); |
| | | BeanUtil.copyProperties(collect.get(s).get(0), dto); |
| | | Set<String> tellSet = new HashSet<>(); |
| | | for (int i = startIndex; i < endIndex; i++) { |
| | | String cableTag = cableTags.get(i); |
| | | for (SampleProductExportDto sDto : collect.get(s)) { |
| | | tellSet.add(sDto.getTell()); |
| | | if(sDto.getCableTag().equals(cableTag)){ |
| | | if (sDto.getCableTag().equals(cableTag)) { |
| | | lastValueList.add(sDto.getLastValue()); |
| | | } |
| | | } |
| | | } |
| | | //切割电缆配置项 |
| | | dto.setTell(String.join("\n",tellSet)); |
| | | dto.setTell(String.join("\n", tellSet)); |
| | | dto.setLastValueList(lastValueList); |
| | | sampleProductExportDtos.add(dto); |
| | | } |
| | |
| | | |
| | | /** |
| | | * 检测项排序 |
| | | * |
| | | * @param sourceMap |
| | | * @param targetMap |
| | | */ |
| | | private void sortSampleProduct(Map<String, List<SampleProductExportDto>> sourceMap,Map<String, List<SampleProductExportDto>> targetMap){ |
| | | private void sortSampleProduct(Map<String, List<SampleProductExportDto>> sourceMap, Map<String, List<SampleProductExportDto>> targetMap) { |
| | | List<Map.Entry<String, List<SampleProductExportDto>>> entries = new ArrayList<>(sourceMap.entrySet()); |
| | | entries.sort(Comparator.comparingInt(o -> (o.getValue().get(0).getSort() == null ? 0 : o.getValue().get(0).getSort()))); |
| | | for (Map.Entry<String, List<SampleProductExportDto>> entry : entries) { |
| | |
| | | |
| | | /** |
| | | * 小报告生成 |
| | | * |
| | | * @param orderId |
| | | * @param insOrder |
| | | * @param insSamples |
| | |
| | | //查询零件属性 |
| | | IfsPartPropsRecord ifsPartPropsRecord = ifsPartPropsRecordMapper.selectOne(Wrappers.<IfsPartPropsRecord>lambdaQuery() |
| | | .eq(IfsPartPropsRecord::getIfsInventoryId, ifsInventoryQuantity.getId())); |
| | | if(Objects.nonNull(ifsPartPropsRecord)){ |
| | | if (Objects.nonNull(ifsPartPropsRecord)) { |
| | | enterFactoryReport.setOuterColor(ifsPartPropsRecord.getOuterColor()); |
| | | } |
| | | enterFactoryReport.setQtyArrived(ifsInventoryQuantity.getQtyArrived() == null ? "" : |
| | |
| | | List<RowRenderData> rows = new ArrayList<>(); |
| | | List<TextRenderData> text = new ArrayList<>(); |
| | | RowRenderData rowRenderData = null; |
| | | List<Map<String,Object>> cableTagEnclosureTables = new ArrayList<>(); |
| | | List<Map<String, Object>> cableTagEnclosureTables = new ArrayList<>(); |
| | | |
| | | // 查询检验内容 |
| | | List<SampleProductExportDto> sampleProductDto2s = insOrderMapper.selectSampleBySampleId(insSamples.stream() |
| | |
| | | Integer max = insSamples.stream().mapToInt(InsSample::getQuantity).sum(); |
| | | TableRenderData tableRenderData = new TableRenderData(); |
| | | String templateName; |
| | | if(StringUtils.equals(OrderType.WG.getValue(),ifsInventoryQuantity.getOrderType())){ |
| | | if (StringUtils.equals(OrderType.WG.getValue(), ifsInventoryQuantity.getOrderType())) { |
| | | //过滤不判定的检测项 |
| | | List<SampleProductExportDto> filterItems = sampleProductDto2s.stream() |
| | | .filter(f -> !showResult || f.getInsResult() != 3) |
| | |
| | | templateName = showResult ? "/static/small-wg-report-template.docx" : "/static/small-wg-detection-template.docx"; |
| | | //查询检验单消息 |
| | | InsSampleUserVO insSampleUser = insSampleUserMapper.selectUserNameByOrderId(orderId); |
| | | if(Objects.nonNull(insSampleUser)){ |
| | | if (Objects.nonNull(insSampleUser)) { |
| | | enterFactoryReport.setPartDesc(insSampleUser.getModel()); |
| | | enterFactoryReport.setInspector(insSampleUser.getInspector()); |
| | | enterFactoryReport.setInspectDate(insSampleUser.getInspectDate()); |
| | |
| | | |
| | | AtomicInteger finalIndex = new AtomicInteger(1); |
| | | List<String> cableTags = insOrderMapper.selectSampleCableTag(insSample.getId()); |
| | | max = Math.max(cableTags.size(),1); |
| | | max = Math.max(cableTags.size(), 1); |
| | | //处理电缆配置检测项 |
| | | Map<String, List<SampleProductExportDto>> tempMap = new HashMap<>(); |
| | | Map<String, List<SampleProductExportDto>> tempMap2 = new HashMap<>(); |
| | |
| | | List<SampleProductExportDto> sampleProductExportDtos2; |
| | | //处理电缆配置项 |
| | | Map<String, List<SampleProductExportDto>> collect = listMap2.get(key).stream().collect(Collectors.groupingBy(SampleProductExportDto::getInspectionItemSubclass)); |
| | | if(cableTags.size()>maxCableTag){ |
| | | sampleProductExportDtos = transformSampleProduct(cableTags,collect,0,maxCableTag); |
| | | sampleProductExportDtos2 = transformSampleProduct(cableTags,collect,maxCableTag,cableTags.size()); |
| | | tempMap2.put(key,sampleProductExportDtos2); |
| | | }else{ |
| | | sampleProductExportDtos = transformSampleProduct(cableTags,collect,0,cableTags.size()); |
| | | if (cableTags.size() > maxCableTag) { |
| | | sampleProductExportDtos = transformSampleProduct(cableTags, collect, 0, maxCableTag); |
| | | sampleProductExportDtos2 = transformSampleProduct(cableTags, collect, maxCableTag, cableTags.size()); |
| | | tempMap2.put(key, sampleProductExportDtos2); |
| | | } else { |
| | | sampleProductExportDtos = transformSampleProduct(cableTags, collect, 0, cableTags.size()); |
| | | } |
| | | cableTagItem.put(key,sampleProductExportDtos); |
| | | cableTagItem.put(key, sampleProductExportDtos); |
| | | } |
| | | //处理非电缆配置检测项 |
| | | Map<String, List<SampleProductExportDto>> listMap = filterItems.stream() |
| | | .filter(f -> StringUtils.isBlank(f.getCableTag()) && StringUtils.isNotBlank(f.getInspectionItem())) |
| | | .collect(Collectors.groupingBy(s->s.getInspectionItem()+"&")); |
| | | .collect(Collectors.groupingBy(s -> s.getInspectionItem() + "&")); |
| | | //合并检测项列表 |
| | | tempMap.putAll(cableTagItem); |
| | | tempMap.putAll(listMap); |
| | | sortSampleProduct(tempMap,totalItem); |
| | | int tagNum = Math.min(max,maxCableTag); |
| | | List<String> tagList = cableTags.isEmpty()?new ArrayList<>():cableTags.subList(0,tagNum); |
| | | sortSampleProduct(tempMap, totalItem); |
| | | int tagNum = Math.min(max, maxCableTag); |
| | | List<String> tagList = cableTags.isEmpty() ? new ArrayList<>() : cableTags.subList(0, tagNum); |
| | | handlerSampleItems(OrderType.WG.getValue(), totalItem, finalIndex, sampleList, tagNum, text, rows, rowRenderData, resultCh, tagList, true, showResult); |
| | | |
| | | if(CollectionUtil.isNotEmpty(tempMap2)){ |
| | | sortSampleProduct(tempMap2,cableTagEnclosureItem); |
| | | if (CollectionUtil.isNotEmpty(tempMap2)) { |
| | | sortSampleProduct(tempMap2, cableTagEnclosureItem); |
| | | //生成附件电缆表格 |
| | | TableRenderData tableRenderData2 = new TableRenderData(); |
| | | List<String> newCableTags = cableTags.subList(maxCableTag,cableTags.size()); |
| | | List<String> newCableTags = cableTags.subList(maxCableTag, cableTags.size()); |
| | | AtomicInteger finalIndex2 = new AtomicInteger(1); |
| | | List<TextRenderData> newText = new ArrayList<TextRenderData>(); |
| | | List<RowRenderData> newRows = new ArrayList<>(); |
| | | RowRenderData newRowRenderData = null; |
| | | handlerSampleItems(OrderType.WG.getValue(), cableTagEnclosureItem, finalIndex2, new ArrayList<>(), newCableTags.size(), newText, newRows, newRowRenderData, resultCh, newCableTags, true, showResult); |
| | | tableRenderData2.setRows(newRows); |
| | | tableRenderData2.setTableStyle(setTableStyle(newCableTags.size(), showResult)); |
| | | tableRenderData2.setTableStyle(setTableStyle(newCableTags.size(), showResult)); |
| | | HashMap<String, Object> tableMap = new HashMap<>(); |
| | | tableMap.put("enclosureTable",tableRenderData2); |
| | | tableMap.put("enclosureTable", tableRenderData2); |
| | | tableMap.put("resultCh", resultCh); |
| | | tableMap.put("writeUrl", null); |
| | | tableMap.put("examineUrl", null); |
| | |
| | | resultCh.set("本产品符合相关标准要求,经检验合格准予出厂(盖章有效)"); |
| | | } |
| | | |
| | | }else{ |
| | | } else { |
| | | templateName = showResult ? "/static/small-report-template.docx" : "/static/small-detection-template.docx"; |
| | | // 转成Mpa进行排序 |
| | | Map<String, List<SampleProductExportDto>> sortedMap = sampleProductDto2s.stream() |
| | |
| | | .collect(Collectors.groupingBy(SampleProductExportDto::getInspectionItem)); |
| | | // // 创建一个 LinkedHashMap 来保持插入顺序 |
| | | Map<String, List<SampleProductExportDto>> item = new LinkedHashMap<>(); |
| | | sortSampleProduct(sortedMap,item); |
| | | sortSampleProduct(sortedMap, item); |
| | | |
| | | |
| | | AtomicInteger finalIndex = new AtomicInteger(1); |
| | |
| | | put("standardMethod", standardMethod2.toString().equals("null") ? "" : standardMethod2); |
| | | put("orderType", orderType); |
| | | put("table", tableRenderData); |
| | | put("enclosureTables", cableTagEnclosureTables.isEmpty()?null:cableTagEnclosureTables); |
| | | put("enclosureTables", cableTagEnclosureTables.isEmpty() ? null : cableTagEnclosureTables); |
| | | put("resultCh", resultCh); |
| | | put("writeUrl", null); |
| | | put("examineUrl", null); |
| | |
| | | |
| | | /** |
| | | * 处理常规检测项 |
| | | * |
| | | * @param item |
| | | * @param finalIndex |
| | | * @param sampleList |
| | |
| | | String productName = productDto2.getInspectionItemClass() + productDto2.getInspectionItem() + productDto2.getCableTag(); |
| | | if (map.containsKey(productName)) { |
| | | // 如果名称已经存在,添加 lastValue 值到 lastValueList 列表 |
| | | if(CollectionUtil.isEmpty(map.get(productName).getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(),orderType)){ |
| | | if (CollectionUtil.isEmpty(map.get(productName).getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(), orderType)) { |
| | | map.get(productName) |
| | | .getLastValueList() |
| | | .add(productDto2.getLastValue()); |
| | |
| | | .add(productDto2.getInsResult()); |
| | | } else { |
| | | // 如果名称不存在,直接放入 map |
| | | if(CollectionUtil.isEmpty(productDto2.getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(),orderType)){ |
| | | if (CollectionUtil.isEmpty(productDto2.getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(), orderType)) { |
| | | productDto2.setLastValueList(new ArrayList<>()); // 检验内容 |
| | | productDto2.getLastValueList().add(productDto2.getLastValue()); |
| | | } |
| | |
| | | String productName = productDto2.getInspectionItemClass() + productDto2.getInspectionItem() + productDto2.getInspectionItemSubclass() + productDto2.getCableTag(); |
| | | if (map.containsKey(productName)) { |
| | | // 如果名称已经存在,添加 lastValue 值到 lastValueList 列表 |
| | | if(CollectionUtil.isEmpty(map.get(productName).getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(),orderType)){ |
| | | if (CollectionUtil.isEmpty(map.get(productName).getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(), orderType)) { |
| | | map.get(productName) |
| | | .getLastValueList() |
| | | .add(productDto2.getLastValue()); |
| | |
| | | .add(productDto2.getInsResult()); |
| | | } else { |
| | | // 如果名称不存在,直接放入 map |
| | | if(CollectionUtil.isEmpty(productDto2.getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(),orderType)){ |
| | | if (CollectionUtil.isEmpty(productDto2.getLastValueList()) || StringUtils.equals(OrderType.RAW.getValue(), orderType)) { |
| | | productDto2.setLastValueList(new ArrayList<>()); // 检验内容 |
| | | productDto2.getLastValueList().add(productDto2.getLastValue()); |
| | | } |
| | |
| | | }); |
| | | |
| | | // 添加小报告表头 |
| | | if(hasAddHead){ |
| | | if (hasAddHead) { |
| | | text = addSmallHead(text, max, rows, cableTagList, showResult); |
| | | } |
| | | |
| | |
| | | // 检验项目 |
| | | TextRenderData middleRenderData2 = new TextRenderData(); |
| | | String[] split = sample.getInspectionName().split("&"); |
| | | String itemName = split.length>0?split[0]:sample.getInspectionName(); |
| | | middleRenderData2.setText(itemName+"∑"+itemName+i+"_"+finalIndex); |
| | | String itemName = split.length > 0 ? split[0] : sample.getInspectionName(); |
| | | middleRenderData2.setText(itemName + "∑" + itemName + i + "_" + finalIndex); |
| | | Style middleStyle2 = new Style(); |
| | | middleStyle2.setFontFamily("宋体"); |
| | | middleStyle2.setColor("000000"); |
| | |
| | | TextRenderData middleRenderData6 = new TextRenderData(); |
| | | middleRenderData6.setText((StringUtils.isNotEmpty(sample.getLastValue()) ? |
| | | sample.getLastValue() : "") |
| | | + "∑" + (finalIndex.get() +"_"+ i)); |
| | | + "∑" + (finalIndex.get() + "_" + i)); |
| | | Style middleStyle6 = new Style(); |
| | | middleStyle6.setFontFamily("宋体"); |
| | | middleStyle6.setColor("000000"); |
| | |
| | | } |
| | | |
| | | if (showResult) { |
| | | TextRenderData middleRenderData7 = new TextRenderData(); |
| | | middleRenderData7.setText(result); |
| | | Style middleStyle7 = new Style(); |
| | | middleStyle7.setFontFamily("宋体"); |
| | | middleStyle7.setColor("000000"); |
| | | middleRenderData7.setStyle(middleStyle7); |
| | | text.add(middleRenderData7); |
| | | TextRenderData middleRenderData7 = new TextRenderData(); |
| | | middleRenderData7.setText(result); |
| | | Style middleStyle7 = new Style(); |
| | | middleStyle7.setFontFamily("宋体"); |
| | | middleStyle7.setColor("000000"); |
| | | middleRenderData7.setStyle(middleStyle7); |
| | | text.add(middleRenderData7); |
| | | } |
| | | |
| | | TextRenderData[] text2 = text.toArray(new TextRenderData[0]); |
| | |
| | | |
| | | /** |
| | | * 添加小报告表头 |
| | | * |
| | | * @param text |
| | | * @param max |
| | | * @param rows |
| | |
| | | text.add(headRenderData6); |
| | | } |
| | | if (showResult) { |
| | | TextRenderData headRenderData7 = new TextRenderData(); |
| | | headRenderData7.setText("单项判断"); |
| | | Style headStyle7 = new Style(); |
| | | headStyle7.setFontFamily("宋体"); |
| | | headStyle7.setColor("000000"); |
| | | headRenderData7.setStyle(headStyle7); |
| | | text.add(headRenderData7); |
| | | TextRenderData headRenderData7 = new TextRenderData(); |
| | | headRenderData7.setText("单项判断"); |
| | | Style headStyle7 = new Style(); |
| | | headStyle7.setFontFamily("宋体"); |
| | | headStyle7.setColor("000000"); |
| | | headRenderData7.setStyle(headStyle7); |
| | | text.add(headRenderData7); |
| | | } |
| | | |
| | | TextRenderData[] text3 = text.toArray(new TextRenderData[0]); |
| | |
| | | text.add(tagRenderData6); |
| | | } |
| | | if (showResult) { |
| | | TextRenderData tagRenderData7 = new TextRenderData(); |
| | | tagRenderData7.setText(""); |
| | | Style tagStyle7 = new Style(); |
| | | tagStyle7.setFontFamily("宋体"); |
| | | tagStyle7.setColor("000000"); |
| | | tagRenderData7.setStyle(tagStyle7); |
| | | text.add(tagRenderData7); |
| | | TextRenderData tagRenderData7 = new TextRenderData(); |
| | | tagRenderData7.setText(""); |
| | | Style tagStyle7 = new Style(); |
| | | tagStyle7.setFontFamily("宋体"); |
| | | tagStyle7.setColor("000000"); |
| | | tagRenderData7.setStyle(tagStyle7); |
| | | text.add(tagRenderData7); |
| | | } |
| | | |
| | | TextRenderData[] text4 = text.toArray(new TextRenderData[0]); |
| | |
| | | |
| | | } |
| | | //如果有电缆颜色,生成颜色标识行 |
| | | if(CollectionUtil.isNotEmpty(cableTagList)){ |
| | | if (CollectionUtil.isNotEmpty(cableTagList)) { |
| | | TextRenderData tagRenderData1 = new TextRenderData(); |
| | | tagRenderData1.setText(""); |
| | | Style tagStyle1 = new Style(); |
| | |
| | | text.add(tagRenderData6); |
| | | } |
| | | if (showResult) { |
| | | TextRenderData tagRenderData7 = new TextRenderData(); |
| | | tagRenderData7.setText("/"); |
| | | Style tagStyle7 = new Style(); |
| | | tagStyle7.setFontFamily("宋体"); |
| | | tagStyle7.setColor("000000"); |
| | | tagRenderData7.setStyle(tagStyle7); |
| | | text.add(tagRenderData7); |
| | | TextRenderData tagRenderData7 = new TextRenderData(); |
| | | tagRenderData7.setText("/"); |
| | | Style tagStyle7 = new Style(); |
| | | tagStyle7.setFontFamily("宋体"); |
| | | tagStyle7.setColor("000000"); |
| | | tagRenderData7.setStyle(tagStyle7); |
| | | text.add(tagRenderData7); |
| | | } |
| | | |
| | | TextRenderData[] text4 = text.toArray(new TextRenderData[0]); |
| | |
| | | |
| | | /** |
| | | * 创建大报告 |
| | | * |
| | | * @param orderId |
| | | * @param insOrder |
| | | * @param |
| | |
| | | private void addBitReport(Integer orderId, InsOrder insOrder, Integer reportType, Integer writeUserId) { |
| | | //samples是不包括带有"/"的样品 |
| | | List<SampleProductDto> samples = insSampleMapper.selectSampleProductListByOrderId(orderId); |
| | | boolean directTemplateOrder = isDirectTemplateOrder(orderId); |
| | | if (!directTemplateOrder && CollectionUtils.isEmpty(samples)) { |
| | | throw new ErrorException("当前订单未找到可生成报告的有效检验项目"); |
| | | } |
| | | InsReport insReport = new InsReport(); |
| | | insReport.setCode(insOrder.getEntrustCode()); |
| | | insReport.setInsOrderId(orderId); |
| | |
| | | } |
| | | } |
| | | |
| | | Map<String, String> codeStr = new HashMap<>(); |
| | | codeStr.put("报告编号", insReport.getCode()); |
| | | codeStr.put("样品名称", defaultReportText(insOrder.getSampleView(), insOrder.getSample())); |
| | | codeStr.put("规格型号", samples.get(0).getModel()); |
| | | codeStr.put("发放日期", LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
| | | |
| | | String modelStr = CollUtil.join(models, "\n"); |
| | | |
| | | // 检测类型 |
| | |
| | | List<Map<String, String>> finalDeviceList = deviceList; |
| | | String finalModelStr = modelStr; |
| | | |
| | | List<Map<String, String>> detectionResultRows = buildDetectionResultRows(orderId, samples); |
| | | // 直绑模板订单没有 ins_product,检测项目、单位和结果均从订单模板快照中获取。 |
| | | List<Map<String, String>> detectionResultRows = directTemplateOrder |
| | | ? buildTemplateDetectionResultRows(orderId) |
| | | : buildDetectionResultRows(samples); |
| | | String productName = defaultReportText(insOrder.getSampleView(), insOrder.getSample()); |
| | | String customerName = defaultReportText(custom == null ? null : custom.getCompany(), insOrder.getCompany()); |
| | | String detectionCategory = defaultReportText(finalOrderType, "委托检测"); |
| | |
| | | Wrappers.<InsOrderStandardTemplate>lambdaQuery() |
| | | .eq(InsOrderStandardTemplate::getInsOrderId, orderId) |
| | | .orderByAsc(InsOrderStandardTemplate::getSort, InsOrderStandardTemplate::getId)); |
| | | boolean newJuTemplateOrder = !templateSnapshots.isEmpty() && isDirectTemplateOrder(orderId); |
| | | boolean newJuTemplateOrder = !templateSnapshots.isEmpty() && directTemplateOrder; |
| | | if (newJuTemplateOrder) { |
| | | productName = defaultReportText(insOrder.getSampleView(), insOrder.getSample()); |
| | | finalModelStr = "/"; |
| | |
| | | /** |
| | | * 新版检测报告的结果表固定为四列:序号、检测项目、单位、检测结果。 |
| | | */ |
| | | private List<Map<String, String>> buildDetectionResultRows(Integer orderId, List<SampleProductDto> samples) { |
| | | if (isDirectTemplateOrder(orderId)) { |
| | | return buildTemplateDetectionResultRows(orderId); |
| | | } |
| | | private List<Map<String, String>> buildDetectionResultRows(List<SampleProductDto> samples) { |
| | | List<Map<String, String>> rows = new ArrayList<>(); |
| | | if (CollectionUtils.isEmpty(samples)) { |
| | | return rows; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新聚直绑模板订单:一个模板页签在报告中只对应一条检测项目。 |
| | | * 新聚直绑模板订单:模板中每一个“导出值”批注都对应报告中的一条检测项目。 |
| | | */ |
| | | private List<Map<String, String>> buildTemplateDetectionResultRows(Integer orderId) { |
| | | List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list( |
| | |
| | | List<Map<String, String>> rows = new ArrayList<>(); |
| | | int sequence = 1; |
| | | for (InsOrderStandardTemplate snapshot : snapshots) { |
| | | TemplateExportCell exportCell = getFirstTemplateExportCell(snapshot.getThing()); |
| | | List<TemplateExportCell> exportCells = getTemplateExportCells(snapshot.getThing()); |
| | | JSONObject recordValues = StrUtil.isBlank(snapshot.getRecordValues()) |
| | | ? new JSONObject() : JSON.parseObject(snapshot.getRecordValues()); |
| | | String result = readTemplateCellText(recordValues, exportCell.resultCoordinate, exportCell.templateValues); |
| | | if (StringUtils.isBlank(result)) { |
| | | throw new ErrorException("模板“" + defaultReportText(snapshot.getName(), "模板ID " + snapshot.getTemplateId()) |
| | | + "”的导出值不能为空"); |
| | | } |
| | | String unit = exportCell.unitCoordinate == null ? null |
| | | : readTemplateCellText(recordValues, exportCell.unitCoordinate, exportCell.templateValues); |
| | | String itemName = exportCell.itemCoordinate == null ? null |
| | | : readTemplateCellText(recordValues, exportCell.itemCoordinate, exportCell.templateValues); |
| | | for (TemplateExportCell exportCell : exportCells) { |
| | | String result = readTemplateCellText(recordValues, exportCell.resultCoordinate, exportCell.templateValues); |
| | | if (StringUtils.isBlank(result)) { |
| | | throw new ErrorException("模板“" + defaultReportText(snapshot.getName(), "模板ID " + snapshot.getTemplateId()) |
| | | + "”的导出值不能为空(" + exportCell.resultCoordinate + ")"); |
| | | } |
| | | String unit = exportCell.unitCoordinate == null ? null |
| | | : readTemplateCellText(recordValues, exportCell.unitCoordinate, exportCell.templateValues); |
| | | String itemName = exportCell.itemCoordinate == null ? null |
| | | : readTemplateCellText(recordValues, exportCell.itemCoordinate, exportCell.templateValues); |
| | | |
| | | Map<String, String> row = new LinkedHashMap<>(); |
| | | row.put("seq", String.valueOf(sequence++)); |
| | | 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); |
| | | Map<String, String> row = new LinkedHashMap<>(); |
| | | row.put("seq", String.valueOf(sequence++)); |
| | | 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 (rows.isEmpty()) { |
| | | throw new ErrorException("当前订单未找到可生成报告的原始记录模板"); |
| | |
| | | return rows; |
| | | } |
| | | |
| | | private TemplateExportCell getFirstTemplateExportCell(String compressedThing) { |
| | | private List<TemplateExportCell> getTemplateExportCells(String compressedThing) { |
| | | if (StrUtil.isBlank(compressedThing)) { |
| | | throw new ErrorException("原始记录模板为空"); |
| | | } |
| | |
| | | throw new ErrorException("模板必须至少配置一个导出值批注"); |
| | | } |
| | | exportCells.sort(Comparator.comparingInt((int[] cell) -> cell[0]).thenComparingInt(cell -> cell[1])); |
| | | int[] firstExport = exportCells.get(0); |
| | | int resultColumnForRow = resultColumn == null ? firstExport[1] : resultColumn; |
| | | // 通常“导出值”批注配置在项目名称单元格;若配置在结果单元格,则回到“检测项目”列取名称。 |
| | | Integer itemColumnForRow = !Objects.equals(firstExport[1], resultColumnForRow) |
| | | ? firstExport[1] : itemColumn; |
| | | TemplateExportCell result = new TemplateExportCell(); |
| | | result.resultCoordinate = firstExport[0] + "-" + resultColumnForRow; |
| | | result.itemCoordinate = itemColumnForRow == null ? null : firstExport[0] + "-" + itemColumnForRow; |
| | | result.unitCoordinate = unitColumn == null ? null : firstExport[0] + "-" + unitColumn; |
| | | result.templateValues = templateValues; |
| | | return result; |
| | | List<TemplateExportCell> results = new ArrayList<>(); |
| | | for (int[] exportCell : exportCells) { |
| | | int resultColumnForRow = resultColumn == null ? exportCell[1] : resultColumn; |
| | | // 通常“导出值”批注配置在项目名称单元格;若配置在结果单元格,则回到“检测项目”列取名称。 |
| | | Integer itemColumnForRow = !Objects.equals(exportCell[1], resultColumnForRow) |
| | | ? exportCell[1] : itemColumn; |
| | | TemplateExportCell result = new TemplateExportCell(); |
| | | result.resultCoordinate = exportCell[0] + "-" + resultColumnForRow; |
| | | result.itemCoordinate = itemColumnForRow == null ? null : exportCell[0] + "-" + itemColumnForRow; |
| | | result.unitCoordinate = unitColumn == null ? null : exportCell[0] + "-" + unitColumn; |
| | | result.templateValues = templateValues; |
| | | results.add(result); |
| | | } |
| | | return results; |
| | | } |
| | | |
| | | private String readTemplateCellText(JSONObject recordValues, String coordinate, Map<String, String> templateValues) { |
| | |
| | | return minimumText + "~" + maximum.stripTrailingZeros().toPlainString() + unit; |
| | | } |
| | | |
| | | /** 报告项目名称不展示模板计算过程中的“平均值”字样及其后的分隔逗号。 */ |
| | | /** |
| | | * 报告项目名称不展示模板计算过程中的“平均值”字样及其后的分隔逗号。 |
| | | */ |
| | | private static String formatExportItemName(String itemName) { |
| | | if (StringUtils.isBlank(itemName)) { |
| | | return itemName; |
| | |
| | | |
| | | /** |
| | | * 计算表格列宽度 |
| | | * |
| | | * @param max 最大检验个数 |
| | | * @return |
| | | */ |
| | | private static int[] calcTableColWidths(int max, boolean showResult){ |
| | | private static int[] calcTableColWidths(int max, boolean showResult) { |
| | | if (!showResult) { |
| | | switch (max) { |
| | | case 1: return new int[]{650, 2200, 2200, 850, 2300, 1800}; |
| | | case 2: return new int[]{650, 1600, 1600, 850, 1900, 1700, 1700}; |
| | | case 3: return new int[]{650, 1400, 1400, 850, 1600, 1375, 1375, 1375}; |
| | | case 4: return new int[]{650, 1250, 1250, 850, 1450, 1140, 1140, 1140, 1140}; |
| | | case 5: return new int[]{650, 1150, 1150, 850, 1300, 980, 980, 980, 980, 980}; |
| | | default: return new int[0]; |
| | | case 1: |
| | | return new int[]{650, 2200, 2200, 850, 2300, 1800}; |
| | | case 2: |
| | | return new int[]{650, 1600, 1600, 850, 1900, 1700, 1700}; |
| | | case 3: |
| | | return new int[]{650, 1400, 1400, 850, 1600, 1375, 1375, 1375}; |
| | | case 4: |
| | | return new int[]{650, 1250, 1250, 850, 1450, 1140, 1140, 1140, 1140}; |
| | | case 5: |
| | | return new int[]{650, 1150, 1150, 850, 1300, 980, 980, 980, 980, 980}; |
| | | default: |
| | | return new int[0]; |
| | | } |
| | | } |
| | | int[] colWidths = null; |
| | |
| | | colWidths = new int[]{650, 1100, 1100, 850, 1350, 750, 750, 750, 750, 750, 1200}; |
| | | break; |
| | | } |
| | | if(ObjectUtils.isNull(colWidths)){ |
| | | if (ObjectUtils.isNull(colWidths)) { |
| | | List<Integer> defaultColWidths = new ArrayList<>(Arrays.asList(650, 1100, 1100, 850, 1350)); |
| | | int totalWidth = 3000;//总宽度 |
| | | int byOneWidth = totalWidth/max;//每一个的宽度 |
| | | int byOneWidth = totalWidth / max;//每一个的宽度 |
| | | int realWidth = 0;//实际宽度 |
| | | for (int i = 0; i < max; i++) { |
| | | realWidth+=byOneWidth; |
| | | realWidth += byOneWidth; |
| | | defaultColWidths.add(byOneWidth); |
| | | } |
| | | defaultColWidths.add(1200+(totalWidth-realWidth)); |
| | | defaultColWidths.add(1200 + (totalWidth - realWidth)); |
| | | return defaultColWidths.stream().mapToInt(Integer::intValue).toArray(); |
| | | } |
| | | return colWidths; |
| | |
| | | |
| | | /** |
| | | * 调整高度 |
| | | * |
| | | * @param row |
| | | * @param rowHeight |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 添加报告表头 |
| | | * |
| | | * @param sample |
| | | * @param text |
| | | * @param rowRenderData |
| | | * @param rows |
| | | * @param max |
| | | * @param cableTags 线芯颜色 |
| | | * @param cableTags 线芯颜色 |
| | | */ |
| | | private static void addHead(SampleProductDto sample, List<TextRenderData> text, RowRenderData rowRenderData, List<RowRenderData> rows, int max, List<String> cableTags, boolean showResult) { |
| | | // 第一行 |
| | |
| | | text.add(headRenderData6); |
| | | } |
| | | if (showResult) { |
| | | TextRenderData headRenderData7 = new TextRenderData(); |
| | | headRenderData7.setText("结论@Conclusion"); |
| | | Style headStyle7 = new Style(); |
| | | headStyle7.setFontFamily("宋体"); |
| | | headStyle7.setColor("000000"); |
| | | headRenderData7.setStyle(headStyle7); |
| | | text.add(headRenderData7); |
| | | TextRenderData headRenderData7 = new TextRenderData(); |
| | | headRenderData7.setText("结论@Conclusion"); |
| | | Style headStyle7 = new Style(); |
| | | headStyle7.setFontFamily("宋体"); |
| | | headStyle7.setColor("000000"); |
| | | headRenderData7.setStyle(headStyle7); |
| | | text.add(headRenderData7); |
| | | } |
| | | |
| | | TextRenderData[] text3 = text.toArray(new TextRenderData[0]); |
| | |
| | | text.add(cableRenderData6); |
| | | } |
| | | if (showResult) { |
| | | TextRenderData cableRenderData7 = new TextRenderData(); |
| | | cableRenderData7.setText("-"); |
| | | Style cableStyle7 = new Style(); |
| | | cableStyle7.setFontFamily("宋体"); |
| | | cableStyle7.setColor("000000"); |
| | | cableRenderData7.setStyle(cableStyle7); |
| | | text.add(cableRenderData7); |
| | | TextRenderData cableRenderData7 = new TextRenderData(); |
| | | cableRenderData7.setText("-"); |
| | | Style cableStyle7 = new Style(); |
| | | cableStyle7.setFontFamily("宋体"); |
| | | cableStyle7.setColor("000000"); |
| | | cableRenderData7.setStyle(cableStyle7); |
| | | text.add(cableRenderData7); |
| | | } |
| | | |
| | | TextRenderData[] text4 = text.toArray(new TextRenderData[0]); |
| | |
| | | |
| | | /** |
| | | * 添加检测值 |
| | | * @param a 当前样品 |
| | | * |
| | | * @param a 当前样品 |
| | | * @param text |
| | | * @param rowRenderData |
| | | * @param rows |
| | | * @param max 检验数量 |
| | | * @param max 检验数量 |
| | | * @param resultChList 不符合信息中文 |
| | | * @param resultEhList 不符合信息英文 |
| | | * @param insSamples |
| | | * @param cableTags 线芯颜色 |
| | | * @param isOneSample 判断是否是只有一个样品 |
| | | * @param cableTags 线芯颜色 |
| | | * @param isOneSample 判断是否是只有一个样品 |
| | | */ |
| | | private int addTestValue(SampleProductDto a, |
| | | List<TextRenderData> text, |
| | |
| | | } |
| | | // 判定结果 |
| | | if (showResult) { |
| | | String result = ""; |
| | | if (sample.getInsResult() != null) { |
| | | switch (sample.getInsResult()) { |
| | | case 1: |
| | | result = "√"; |
| | | break; |
| | | case 2: |
| | | result = "×"; |
| | | break; |
| | | case 3: |
| | | result = "-"; |
| | | break; |
| | | } |
| | | } |
| | | if (CollectionUtils.isNotEmpty(sample.getLastValueList())) { |
| | | // 判断是否有一个错误 |
| | | if (sample.getInsResultList().stream().anyMatch(s -> Objects.equals(s, 3))) { |
| | | result = "-"; |
| | | } else { |
| | | boolean error = sample.getInsResultList().stream().anyMatch(s -> Objects.equals(s, 0)); |
| | | if (error) { |
| | | List<String> collect = new ArrayList<>(); |
| | | int index = 0; |
| | | for (Integer count : sample.getInsResultList()) { |
| | | String type; |
| | | if (Objects.equals(count, 0)) { |
| | | String itemCh = ""; |
| | | String itemEn = ""; |
| | | // 添加不合格描述 |
| | | // 判断长度是否为1 |
| | | if (sample.getLastValueList().size() == 1) { |
| | | this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn); |
| | | } else if (CollectionUtils.isNotEmpty(cableTags)) { |
| | | // 判断是否有电缆配置, 不是的话可能为原材料 |
| | | // 添加不合格描述 |
| | | itemCh = (max == 1 ? "" : cableTags.get(index)); |
| | | itemEn = (max == 1 ? "" : "The " + Integer.toString(index + 1) + " time "); |
| | | this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn); |
| | | } else { |
| | | // 添加不合格描述 |
| | | itemCh = (max == 1 ? "" : "第" + Integer.toString(index + 1) + "次"); |
| | | itemEn = (max == 1 ? "" : "The " + Integer.toString(index + 1) + " time "); |
| | | this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn); |
| | | } |
| | | type = "×"; |
| | | } else { |
| | | type = "√"; |
| | | } |
| | | collect.add(type); |
| | | index++; |
| | | } |
| | | result = CollUtil.join(collect, " "); |
| | | ; |
| | | } else { |
| | | result = "√"; |
| | | String result = ""; |
| | | if (sample.getInsResult() != null) { |
| | | switch (sample.getInsResult()) { |
| | | case 1: |
| | | result = "√"; |
| | | break; |
| | | case 2: |
| | | result = "×"; |
| | | break; |
| | | case 3: |
| | | result = "-"; |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if (CollectionUtils.isNotEmpty(sample.getLastValueList())) { |
| | | // 判断是否有一个错误 |
| | | if (sample.getInsResultList().stream().anyMatch(s -> Objects.equals(s, 3))) { |
| | | result = "-"; |
| | | } else { |
| | | boolean error = sample.getInsResultList().stream().anyMatch(s -> Objects.equals(s, 0)); |
| | | if (error) { |
| | | List<String> collect = new ArrayList<>(); |
| | | int index = 0; |
| | | for (Integer count : sample.getInsResultList()) { |
| | | String type; |
| | | if (Objects.equals(count, 0)) { |
| | | String itemCh = ""; |
| | | String itemEn = ""; |
| | | // 添加不合格描述 |
| | | // 判断长度是否为1 |
| | | if (sample.getLastValueList().size() == 1) { |
| | | this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn); |
| | | } else if (CollectionUtils.isNotEmpty(cableTags)) { |
| | | // 判断是否有电缆配置, 不是的话可能为原材料 |
| | | // 添加不合格描述 |
| | | itemCh = (max == 1 ? "" : cableTags.get(index)); |
| | | itemEn = (max == 1 ? "" : "The " + Integer.toString(index + 1) + " time "); |
| | | this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn); |
| | | } else { |
| | | // 添加不合格描述 |
| | | itemCh = (max == 1 ? "" : "第" + Integer.toString(index + 1) + "次"); |
| | | itemEn = (max == 1 ? "" : "The " + Integer.toString(index + 1) + " time "); |
| | | this.fillReportErrorResult(errorClassItemMapCn, errorClassItemMapEn, sample, itemCh, itemEn); |
| | | } |
| | | type = "×"; |
| | | } else { |
| | | type = "√"; |
| | | } |
| | | collect.add(type); |
| | | index++; |
| | | } |
| | | result = CollUtil.join(collect, " "); |
| | | ; |
| | | } else { |
| | | result = "√"; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (showResult) { |
| | | TextRenderData headRenderData7 = new TextRenderData(); |
| | | headRenderData7.setText(result); |
| | | Style headStyle7 = new Style(); |
| | | headStyle7.setFontFamily("宋体"); |
| | | headStyle7.setColor("000000"); |
| | | headRenderData7.setStyle(headStyle7); |
| | | text.add(headRenderData7); |
| | | } |
| | | if (showResult) { |
| | | TextRenderData headRenderData7 = new TextRenderData(); |
| | | headRenderData7.setText(result); |
| | | Style headStyle7 = new Style(); |
| | | headStyle7.setFontFamily("宋体"); |
| | | headStyle7.setColor("000000"); |
| | | headRenderData7.setStyle(headStyle7); |
| | | text.add(headRenderData7); |
| | | } |
| | | } |
| | | |
| | | TextRenderData[] text2 = text.toArray(new TextRenderData[0]); |
| | |
| | | |
| | | /** |
| | | * NBSP(非间断空格) 转成 普通空格 |
| | | * |
| | | * @param oldStr |
| | | * @return |
| | | */ |
| | | private String normalizedSpaces(String oldStr){ |
| | | if(StringUtils.isBlank(oldStr)){ |
| | | private String normalizedSpaces(String oldStr) { |
| | | if (StringUtils.isBlank(oldStr)) { |
| | | return oldStr; |
| | | } |
| | | return oldStr.replaceAll("\u00A0", " ").trim(); |
| | |
| | | |
| | | /** |
| | | * 添加报告结论中英文 |
| | | * |
| | | * @param sample |
| | | * @param itemCh |
| | | * @param itemEn |
| | |
| | | |
| | | /** |
| | | * 格式化修改检验项 |
| | | * |
| | | * @param sampleProductDto2s |
| | | */ |
| | | private void formatProducts(List<SampleProductExportDto> sampleProductDto2s) { |
| | |
| | | |
| | | /** |
| | | * 添加结尾 |
| | | * |
| | | * @param text |
| | | * @param rowRenderData |
| | | * @param rows |
| | |
| | | |
| | | /** |
| | | * 判断当前内容是否是科学计数法 |
| | | * |
| | | * @param str |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 修改要求描述的科学计数法 |
| | | * |
| | | * @param input |
| | | */ |
| | | public static String convertToScientificNotation(String input) { |
| | |
| | | |
| | | /** |
| | | * 展示成科学计数法 |
| | | * |
| | | * @param number |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据要求描述保留结果小数点位数 |
| | | * |
| | | * @param reference |
| | | * @param value |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * 保留位数, 如果等于0 返回找到的一个非0位数 |
| | | * |
| | | * @param number 当前数字 |
| | | * @param scale 原本保留的位数 |
| | | * @return |
| | |
| | | |
| | | /** |
| | | * *****保存元此阿里进货验证原始记录***** |
| | | * @param insOrderId 订单Id |
| | | * @param examineUserId 复核人Id |
| | | * @param writeUserId 检验员Id |
| | | * |
| | | * @param insOrderId 订单Id |
| | | * @param examineUserId 复核人Id |
| | | * @param writeUserId 检验员Id |
| | | */ |
| | | private void reportFactoryVerify(Integer insOrderId, Integer examineUserId, Integer writeUserId) { |
| | | // 查询进货验证原始记录 |
| | |
| | | |
| | | /** |
| | | * ***格式化进厂验证内容**** |
| | | * |
| | | * @param basicType |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * ***word转换pdf*** |
| | | * |
| | | * @param path |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * *****修改成品抽样状态****** |
| | | * |
| | | * @param insSamples |
| | | * @param order |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 添加工时 |
| | | * |
| | | * @param userId |
| | | * @param insProduct |
| | | * @param insOrder |