| | |
| | | } |
| | | |
| | | /** |
| | | * 使用正则表达式去除字符串最后一个"-"及其后面的所有内容 |
| | | * @param str 待处理的字符串(允许为null) |
| | | * @return 处理后的字符串,null返回null,无"-"返回原字符串 |
| | | */ |
| | | public static String removeLastHyphenAndContent(String str) { |
| | | // 空值校验:避免NullPointerException |
| | | if (str == null || str.isEmpty()) { |
| | | return str; |
| | | } |
| | | // 正则表达式:匹配最后一个"-"及其后面的所有内容 |
| | | String regex = "-[^-]*$"; |
| | | // 替换匹配的内容为空字符串 |
| | | return str.replaceAll(regex, ""); |
| | | } |
| | | |
| | | /** |
| | | * 小报告生成 |
| | | * |
| | | * @param orderId |
| | |
| | | //查询检验单消息 |
| | | InsSampleUserVO insSampleUser = insSampleUserMapper.selectUserNameByOrderId(orderId); |
| | | if (Objects.nonNull(insSampleUser)) { |
| | | enterFactoryReport.setPartDesc(removeLastHyphenAndContent(insSampleUser.getModel())); |
| | | enterFactoryReport.setPartDesc(insSampleUser.getModel()); |
| | | enterFactoryReport.setInspector(insSampleUser.getInspector()); |
| | | enterFactoryReport.setInspectDate(insSampleUser.getInspectDate()); |
| | | } |