| | |
| | | String userName = null; |
| | | Integer userId = null; |
| | | if (ObjectUtil.isNotEmpty(insOrderPlanDTO.getUserId())) { |
| | | userId = SecurityUtils.getUserId().intValue(); |
| | | userName = userMapper.selectById(userId).getName(); |
| | | Integer currentUserId = SecurityUtils.getUserId().intValue(); |
| | | // 管理员可以查看并复核全部待复核任务,普通用户仍只查看分配给自己的任务。 |
| | | if (!SecurityUtils.isAdmin(currentUserId.longValue())) { |
| | | userId = currentUserId; |
| | | userName = userMapper.selectById(userId).getName(); |
| | | } |
| | | insOrderPlanDTO.setUserId(null); |
| | | } |
| | | Integer isCheck = insOrderPlanDTO.getIsCheck(); |
| | |
| | | |
| | | /** |
| | | * 直绑模板订单的页签来源是订单模板快照,而不是已生成的检验项。 |
| | | * |
| | | * <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)) { |
| | |
| | | } catch (Exception ignored) { |
| | | thing = compressedThing; |
| | | } |
| | | JSONArray cellData = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0).getJSONArray("celldata"); |
| | | JSONObject sheet = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0); |
| | | JSONArray cellData = sheet.getJSONArray("celldata"); |
| | | NavigableMap<Integer, List<String>> result = new TreeMap<>(); |
| | | Integer inspectionResultColumn = null; |
| | | for (Object item : cellData) { |
| | | JSONObject cell = JSON.parseObject(JSON.toJSONString(item)); |
| | | Integer column = cell.getInteger("c"); |
| | | JSONObject value = cell.getJSONObject("v"); |
| | | String displayValue = value == null ? null : value.getString("v"); |
| | | if (inspectionResultColumn == null && "检验结果".equals(StringUtils.trim(displayValue))) { |
| | | inspectionResultColumn = column; |
| | | } |
| | | } |
| | | for (Object item : cellData) { |
| | | JSONObject cell = JSON.parseObject(JSON.toJSONString(item)); |
| | | JSONObject value = cell.getJSONObject("v"); |
| | |
| | | Integer row = cell.getInteger("r"); |
| | | Integer column = cell.getInteger("c"); |
| | | if (row != null && column != null) { |
| | | // “导出值”标在检测项目标题单元格时,真正导出的值是同一行“检验结果”列的单元格。 |
| | | String coordinate = row + "-" + column; |
| | | String resultCoordinate = row + "-" + inspectionResultColumn; |
| | | if (inspectionResultColumn != null && !Objects.equals(column, inspectionResultColumn)) { |
| | | coordinate = resultCoordinate; |
| | | } |
| | | // 批注单元格可能横向合并,右侧结果单元格也可能纵向合并;最终读取结果区域的左上角存储坐标。 |
| | | String coordinate = getRightAdjacentCoordinate(sheet, row, column); |
| | | result.computeIfAbsent(row, ignored -> new ArrayList<>()).add(coordinate); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 返回指定单元格(或其所在合并区域)右侧紧邻列的下标。 |
| | | * Luckysheet 的合并信息通常保存在 config.merge;部分历史模板只在单元格 v.mc 中保留, |
| | | * 因此两种结构都要兼容。 |
| | | */ |
| | | private int getRightAdjacentColumn(JSONObject sheet, int row, int column) { |
| | | int rightEdge = column; |
| | | JSONObject config = sheet == null ? null : sheet.getJSONObject("config"); |
| | | JSONObject merges = config == null ? null : config.getJSONObject("merge"); |
| | | if (merges != null) { |
| | | for (Object rawMerge : merges.values()) { |
| | | rightEdge = extendMergedRightEdge(rightEdge, row, column, rawMerge); |
| | | } |
| | | } |
| | | |
| | | JSONArray cellData = sheet == null ? null : sheet.getJSONArray("celldata"); |
| | | if (cellData != null) { |
| | | for (Object rawCell : cellData) { |
| | | JSONObject cell = JSON.parseObject(JSON.toJSONString(rawCell)); |
| | | JSONObject value = cell == null ? null : cell.getJSONObject("v"); |
| | | JSONObject merge = value == null ? null : value.getJSONObject("mc"); |
| | | rightEdge = extendMergedRightEdge(rightEdge, row, column, merge); |
| | | } |
| | | } |
| | | return rightEdge + 1; |
| | | } |
| | | |
| | | private String getRightAdjacentCoordinate(JSONObject sheet, int row, int column) { |
| | | int adjacentColumn = getRightAdjacentColumn(sheet, row, column); |
| | | int[] anchor = findMergedAnchor(sheet, row, adjacentColumn); |
| | | return anchor[0] + "-" + anchor[1]; |
| | | } |
| | | |
| | | /** |
| | | * Luckysheet 只在合并区域左上角保存实际值。若目标单元格位于合并区域内部, |
| | | * 将其转换为该区域的左上角坐标;未合并则返回原坐标。 |
| | | */ |
| | | private int[] findMergedAnchor(JSONObject sheet, int row, int column) { |
| | | JSONObject config = sheet == null ? null : sheet.getJSONObject("config"); |
| | | JSONObject merges = config == null ? null : config.getJSONObject("merge"); |
| | | if (merges != null) { |
| | | for (Object rawMerge : merges.values()) { |
| | | int[] anchor = findMergedAnchor(row, column, rawMerge); |
| | | if (anchor != null) { |
| | | return anchor; |
| | | } |
| | | } |
| | | } |
| | | |
| | | JSONArray cellData = sheet == null ? null : sheet.getJSONArray("celldata"); |
| | | if (cellData != null) { |
| | | for (Object rawCell : cellData) { |
| | | JSONObject cell = JSON.parseObject(JSON.toJSONString(rawCell)); |
| | | JSONObject value = cell == null ? null : cell.getJSONObject("v"); |
| | | int[] anchor = findMergedAnchor(row, column, |
| | | value == null ? null : value.getJSONObject("mc")); |
| | | if (anchor != null) { |
| | | return anchor; |
| | | } |
| | | } |
| | | } |
| | | return new int[]{row, column}; |
| | | } |
| | | |
| | | private int[] findMergedAnchor(int row, int column, Object rawMerge) { |
| | | if (rawMerge == null) { |
| | | return null; |
| | | } |
| | | JSONObject merge = rawMerge instanceof JSONObject |
| | | ? (JSONObject) rawMerge : JSON.parseObject(JSON.toJSONString(rawMerge)); |
| | | Integer startRow = merge.getInteger("r"); |
| | | Integer startColumn = merge.getInteger("c"); |
| | | Integer rowSpan = merge.getInteger("rs"); |
| | | Integer columnSpan = merge.getInteger("cs"); |
| | | if (startRow == null || startColumn == null || rowSpan == null || columnSpan == null |
| | | || rowSpan < 1 || columnSpan < 1) { |
| | | return null; |
| | | } |
| | | if (row >= startRow && row < startRow + rowSpan |
| | | && column >= startColumn && column < startColumn + columnSpan) { |
| | | return new int[]{startRow, startColumn}; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private int extendMergedRightEdge(int currentRightEdge, int row, int column, Object rawMerge) { |
| | | if (rawMerge == null) { |
| | | return currentRightEdge; |
| | | } |
| | | JSONObject merge = rawMerge instanceof JSONObject |
| | | ? (JSONObject) rawMerge : JSON.parseObject(JSON.toJSONString(rawMerge)); |
| | | Integer startRow = merge.getInteger("r"); |
| | | Integer startColumn = merge.getInteger("c"); |
| | | Integer rowSpan = merge.getInteger("rs"); |
| | | Integer columnSpan = merge.getInteger("cs"); |
| | | if (startRow == null || startColumn == null || rowSpan == null || columnSpan == null |
| | | || rowSpan < 1 || columnSpan < 1) { |
| | | return currentRightEdge; |
| | | } |
| | | int endRow = startRow + rowSpan - 1; |
| | | int endColumn = startColumn + columnSpan - 1; |
| | | if (row >= startRow && row <= endRow && column >= startColumn && column <= endColumn) { |
| | | return Math.max(currentRightEdge, endColumn); |
| | | } |
| | | return currentRightEdge; |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | /** |
| | | * 直绑模板订单只校验模板中标记为“导出值”的单元格,不使用检验项状态或 last_value 判定。 |
| | | * 直绑模板订单只校验每个“导出值”批注所在区域右侧紧邻单元格,不使用检验项状态或 last_value 判定。 |
| | | */ |
| | | private List<String> getMissingTemplateExportValues(Integer orderId) { |
| | | List<InsOrderStandardTemplate> snapshots = insOrderStandardTemplateService.list( |
| | |
| | | |
| | | 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 |
| | | */ |
| | |
| | | refreshed.setRecordValues(templateRecordValuesMap.get(templateId)); |
| | | refreshed.setTemperature(templateTemperatureMap.get(templateId)); |
| | | refreshed.setHumidity(templateHumidityMap.get(templateId)); |
| | | // 刷新模板结构时必须保留检验阶段填写的业务数据,避免进入复核后回显为空。 |
| | | refreshed.setDetectionTime(oldSnapshot == null ? null : oldSnapshot.getDetectionTime()); |
| | | refreshed.setDetectionPlace(oldSnapshot == null ? null : oldSnapshot.getDetectionPlace()); |
| | | refreshed.setInsResult(oldSnapshot == null ? null : oldSnapshot.getInsResult()); |
| | | Integer templateSort = templateSortMap.get(templateId); |
| | | refreshed.setSort(templateSort == null ? nextTemplateSort++ : templateSort); |
| | | refreshedSnapshots.add(refreshed); |
| | |
| | | |
| | | /** |
| | | * 检验任务复核 |
| | | * |
| | | * @param orderId |
| | | * @param laboratory |
| | | * @param type |
| | |
| | | InsReport existingReport = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getInsOrderId, orderId) |
| | | .last("limit 1")); |
| | | boolean directTemplateOrder = isDirectTemplateOrder(orderId); |
| | | if (currentState != null && Objects.equals(currentState.getInsState(), 5) |
| | | && existingReport != null && StringUtils.isNotBlank(existingReport.getUrl())) { |
| | | && existingReport != null && StringUtils.isNotBlank(existingReport.getUrl()) |
| | | && (!directTemplateOrder || StringUtils.isNotBlank(existingReport.getInspectionUrl()))) { |
| | | // 防止复核页面重复点击或网络重试重复生成报告、重复发起报告审批。 |
| | | return 1; |
| | | } |
| | | boolean directTemplateOrder = isDirectTemplateOrder(orderId); |
| | | if (directTemplateOrder && Objects.equals(type, 1) |
| | | && !Objects.equals(dto.getInsResult(), 0) && !Objects.equals(dto.getInsResult(), 1)) { |
| | | throw new ErrorException("请选择检验单结论"); |
| | |
| | | .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)) |
| | |
| | | .eq(InsOrder::getId, orderId) |
| | | .set(InsOrder::getInsState, 5)); |
| | | |
| | | // 检验人员提交复核时不再生成报告;仅在全部试验室复核通过后生成检测报告。 |
| | | // 检验人员提交复核时不生成报告;全部试验室复核通过后生成报告。 |
| | | if (report == null || StringUtils.isBlank(report.getUrl())) { |
| | | this.generateReport(orderId, DETECTION_REPORT, writeUserId); |
| | | report = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getInsOrderId, orderId) |
| | | .last("limit 1")); |
| | | } |
| | | // 直绑模板订单同时生成检验报告,两份文件共用同一条审批记录。 |
| | | if (directTemplateOrder && (report == null || StringUtils.isBlank(report.getInspectionUrl()))) { |
| | | this.generateReport(orderId, INSPECTION_REPORT, writeUserId); |
| | | } |
| | | report = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getInsOrderId, orderId) |
| | | .last("limit 1")); |
| | | if (report == null || StringUtils.isBlank(report.getUrl())) { |
| | | throw new ErrorException("检测报告生成失败"); |
| | | } |
| | | if (directTemplateOrder && StringUtils.isBlank(report.getInspectionUrl())) { |
| | | throw new ErrorException("检验报告生成失败"); |
| | | } |
| | | if (report.getTempUrlPdf() == null) { |
| | | String tempUrlPdf = this.wordToPdfTemp(report.getUrl().replace("/word", wordUrl)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 重新生成尚未批准的系统报告,并恢复已存在的编制、审核签名。 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void regenerateReport(Integer reportId, Integer createOrderUser) { |
| | | if (reportId == null) { |
| | | throw new ErrorException("报告不能为空"); |
| | | } |
| | | InsReport accessibleReport = insReportMapper.selectDownloadableReport(reportId, createOrderUser); |
| | | if (accessibleReport == null) { |
| | | throw new ErrorException("报告不存在、尚未生成或无权操作"); |
| | | } |
| | | // 数据库行锁避免同一报告被多人同时重新生成并覆盖。 |
| | | InsReport report = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getId, reportId) |
| | | .last("FOR UPDATE")); |
| | | if (report == null) { |
| | | throw new ErrorException("报告不存在"); |
| | | } |
| | | if (Objects.equals(report.getIsRatify(), 1)) { |
| | | throw new ErrorException("已批准报告不能重新生成"); |
| | | } |
| | | if (StringUtils.isNotBlank(report.getUrlS())) { |
| | | throw new ErrorException("当前报告已手动上传,请先还原为系统报告后再重新生成"); |
| | | } |
| | | if (report.getInsOrderId() == null) { |
| | | throw new ErrorException("报告未关联检验单,无法重新生成"); |
| | | } |
| | | |
| | | Integer reportType = report.getReportType() == null ? DETECTION_REPORT : report.getReportType(); |
| | | Integer writeUserId = report.getWriteUserId() == null |
| | | ? SecurityUtils.getUserId().intValue() : report.getWriteUserId(); |
| | | boolean directTemplateOrder = isDirectTemplateOrder(report.getInsOrderId()); |
| | | if (directTemplateOrder) { |
| | | generateReport(report.getInsOrderId(), DETECTION_REPORT, writeUserId); |
| | | generateReport(report.getInsOrderId(), INSPECTION_REPORT, writeUserId); |
| | | } else { |
| | | generateReport(report.getInsOrderId(), reportType, writeUserId); |
| | | } |
| | | |
| | | InsReport regenerated = insReportMapper.selectById(reportId); |
| | | if (regenerated == null || StringUtils.isBlank(regenerated.getUrl())) { |
| | | throw new ErrorException("报告重新生成失败"); |
| | | } |
| | | if (directTemplateOrder && StringUtils.isBlank(regenerated.getInspectionUrl())) { |
| | | throw new ErrorException("检验报告重新生成失败"); |
| | | } |
| | | String reportPath = regenerated.getUrl().replace("/word", wordUrl); |
| | | Map<String, Object> marks = buildExistingReportMarks(report); |
| | | if (!marks.isEmpty()) { |
| | | insReportService.wordInsertUrl(marks, reportPath); |
| | | if (StringUtils.isNotBlank(regenerated.getInspectionUrl())) { |
| | | insReportService.wordInsertUrl(marks, |
| | | regenerated.getInspectionUrl().replace("/word", wordUrl)); |
| | | } |
| | | } |
| | | String tempPdfName = wordToPdfTemp(reportPath); |
| | | if (StringUtils.isBlank(tempPdfName)) { |
| | | throw new ErrorException("报告预览文件生成失败"); |
| | | } |
| | | // generateReport 会写入当前时间;重新生成不应改变原审批记录时间。 |
| | | insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() |
| | | .eq(InsReport::getId, reportId) |
| | | .set(InsReport::getWriteTime, report.getWriteTime()) |
| | | .set(InsReport::getTempUrlPdf, "/word/" + tempPdfName)); |
| | | } |
| | | |
| | | private Map<String, Object> buildExistingReportMarks(InsReport report) { |
| | | Map<String, Object> marks = new HashMap<>(); |
| | | boolean submitted = Objects.equals(report.getState(), 1) |
| | | || report.getIsExamine() != null |
| | | || report.getExamineTime() != null; |
| | | if (submitted) { |
| | | User writer = getReportSigner(report.getWriteUserId(), "编制人"); |
| | | marks.put("writeUrl", Pictures.ofLocal(imgUrl + "/" + writer.getSignatureUrl()).create()); |
| | | marks.put("writeDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(report.getWriteTime())).create()); |
| | | marks.put("insUrl", Pictures.ofLocal(imgUrl + "/" + writer.getSignatureUrl()).create()); |
| | | } |
| | | if (Objects.equals(report.getIsExamine(), 1)) { |
| | | User examiner = getReportSigner(report.getExamineUserId(), "审核人"); |
| | | marks.put("examineUrl", Pictures.ofLocal(imgUrl + "/" + examiner.getSignatureUrl()).create()); |
| | | marks.put("examineDateUrl", Pictures.ofStream(DateImageUtil.createDateImage(report.getExamineTime())).create()); |
| | | } |
| | | return marks; |
| | | } |
| | | |
| | | private User getReportSigner(Integer userId, String roleName) { |
| | | User user = userId == null ? null : userMapper.selectById(userId); |
| | | if (user == null || StringUtils.isBlank(user.getSignatureUrl())) { |
| | | throw new ErrorException("找不到" + roleName + "的签名"); |
| | | } |
| | | return user; |
| | | } |
| | | |
| | | /** |
| | | * 生成报告 |
| | | * |
| | | * @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); |
| | |
| | | } |
| | | } |
| | | } |
| | | // 新版检测报告直接使用固定四列结果行,不再构造旧版可变列 TableRenderData。 |
| | | // 检验报告仍沿用下方原有的大表格逻辑。 |
| | | if (!showResult) { |
| | | // 直绑模板的检测报告、检验报告都使用新版固定结果行,不再进入旧版检验项表格逻辑。 |
| | | // 直绑模板中的承载记录没有旧检验项字段,进入旧逻辑会在格式化时产生空指针。 |
| | | if (!showResult || directTemplateOrder) { |
| | | return; |
| | | } |
| | | // 收样日期 |
| | |
| | | } |
| | | } |
| | | |
| | | 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 = "/"; |
| | |
| | | ? "微库仑法,有机氯含量小于0.005%时,以未检出报出。" |
| | | : defaultReportText(insOrder.getRemark(), "/"); |
| | | |
| | | // 检测报告和检验报告统一使用新版报告模板 |
| | | String templateName = "/static/detection-report-template-v2.docx"; |
| | | String templateName = showResult |
| | | ? "/static/inspection-report-template-v2.docx" |
| | | : "/static/detection-report-template-v2.docx"; |
| | | InputStream inputStream = this.getClass().getResourceAsStream(templateName); |
| | | if (inputStream == null) { |
| | | throw new RuntimeException("找不到报告模板: " + templateName); |
| | |
| | | put("resultNote", finalResultRemark); |
| | | }}); |
| | | try { |
| | | String name = insReport.getCode().replace("/", "") + (showResult ? ".docx" : "-C.docx"); |
| | | String name = insReport.getCode().replace("/", "") + (showResult ? "-J.docx" : "-C.docx"); |
| | | Files.createDirectories(Paths.get(wordUrl)); |
| | | template.writeAndClose(Files.newOutputStream(Paths.get(wordUrl, name))); |
| | | insReport.setUrl("/word/" + name); |
| | |
| | | InsReport existing = insReportMapper.selectOne(Wrappers.<InsReport>lambdaQuery() |
| | | .eq(InsReport::getInsOrderId, report.getInsOrderId()) |
| | | .last("limit 1")); |
| | | if (Objects.equals(report.getReportType(), INSPECTION_REPORT)) { |
| | | String inspectionUrl = report.getUrl(); |
| | | if (existing == null) { |
| | | report.setReportType(DETECTION_REPORT); |
| | | report.setUrl(null); |
| | | report.setInspectionUrl(inspectionUrl); |
| | | insReportMapper.insert(report); |
| | | } else { |
| | | insReportMapper.update(null, Wrappers.<InsReport>lambdaUpdate() |
| | | .eq(InsReport::getId, existing.getId()) |
| | | .set(InsReport::getInspectionUrl, inspectionUrl) |
| | | .set(InsReport::getWriteUserId, report.getWriteUserId()) |
| | | .set(InsReport::getWriteTime, report.getWriteTime())); |
| | | } |
| | | return; |
| | | } |
| | | if (existing == null) { |
| | | insReportMapper.insert(report); |
| | | return; |
| | |
| | | /** |
| | | * 新版检测报告的结果表固定为四列:序号、检测项目、单位、检测结果。 |
| | | */ |
| | | 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; |
| | |
| | | row.put("itemName", itemName); |
| | | row.put("unit", defaultReportText(product.getUnit(), "/")); |
| | | row.put("result", defaultReportText(product.getLastValue(), "/")); |
| | | row.put("inspectionConclusion", formatInspectionConclusion(product.getInsResult())); |
| | | rows.add(row); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * 新聚直绑模板订单:一个模板页签在报告中只对应一条检测项目。 |
| | | * 新聚直绑模板订单:模板中每一个“导出值”批注都对应报告中的一条检测项目。 |
| | | */ |
| | | 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); |
| | | row.put("inspectionConclusion", formatInspectionConclusion(snapshot.getInsResult())); |
| | | rows.add(row); |
| | | } |
| | | } |
| | | if (rows.isEmpty()) { |
| | | throw new ErrorException("当前订单未找到可生成报告的原始记录模板"); |
| | |
| | | return rows; |
| | | } |
| | | |
| | | private TemplateExportCell getFirstTemplateExportCell(String compressedThing) { |
| | | private static String formatInspectionConclusion(Integer insResult) { |
| | | if (Objects.equals(insResult, 1)) { |
| | | return "合格"; |
| | | } |
| | | if (Objects.equals(insResult, 0)) { |
| | | return "不合格"; |
| | | } |
| | | return "/"; |
| | | } |
| | | |
| | | private List<TemplateExportCell> getTemplateExportCells(String compressedThing) { |
| | | if (StrUtil.isBlank(compressedThing)) { |
| | | throw new ErrorException("原始记录模板为空"); |
| | | } |
| | |
| | | } catch (Exception ignored) { |
| | | thing = compressedThing; |
| | | } |
| | | JSONArray cellData = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0).getJSONArray("celldata"); |
| | | Integer resultColumn = null; |
| | | Integer itemColumn = null; |
| | | JSONObject sheet = JSON.parseObject(thing).getJSONArray("data").getJSONObject(0); |
| | | JSONArray cellData = sheet.getJSONArray("celldata"); |
| | | Integer unitColumn = null; |
| | | List<int[]> exportCells = new ArrayList<>(); |
| | | Map<String, String> templateValues = new HashMap<>(); |
| | |
| | | } |
| | | String displayValue = value.get("v") == null ? null : String.valueOf(value.get("v")); |
| | | templateValues.put(row + "-" + column, displayValue); |
| | | if (resultColumn == null && "检验结果".equals(StringUtils.trim(displayValue))) { |
| | | resultColumn = column; |
| | | } |
| | | if (itemColumn == null && ("检测项目".equals(StringUtils.trim(displayValue)) |
| | | || "检验项目".equals(StringUtils.trim(displayValue)))) { |
| | | itemColumn = column; |
| | | } |
| | | if (unitColumn == null && "单位".equals(StringUtils.trim(displayValue))) { |
| | | unitColumn = column; |
| | | } |
| | |
| | | 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) { |
| | | TemplateExportCell result = new TemplateExportCell(); |
| | | result.resultCoordinate = getRightAdjacentCoordinate(sheet, exportCell[0], exportCell[1]); |
| | | result.itemCoordinate = exportCell[0] + "-" + exportCell[1]; |
| | | 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) { |
| | |
| | | } |
| | | } |
| | | // 判断是否是数字类型 |
| | | if (sampleProductDto2.getInspectionValueType().equals("1")) { |
| | | if ("1".equals(sampleProductDto2.getInspectionValueType())) { |
| | | // 把检验内容如果正硫化点和焦烧时间把 . 切割成 : |
| | | String lastValue = sampleProductDto2.getLastValue(); |
| | | if (sampleProductDto2.getInspectionItem().contains("正硫化点") || sampleProductDto2.getInspectionItem().contains("焦烧时间")) { |
| | |
| | | |
| | | /** |
| | | * 添加结尾 |
| | | * |
| | | * @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 |