| | |
| | | continue; |
| | | } |
| | | Integer row = cell.getInteger("r"); |
| | | String item = value.getString("v"); |
| | | if (!StringUtils.hasText(item)) { |
| | | item = value.getString("m"); |
| | | } |
| | | String item = getCellText(value); |
| | | if (row == null || !StringUtils.hasText(item)) { |
| | | throw new BaseException("“检验项”标记所在单元格必须填写检验项名称"); |
| | | } |
| | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 读取 Luckysheet 单元格文本,兼容普通文本和 inlineStr 富文本。 |
| | | */ |
| | | private static String getCellText(JSONObject value) { |
| | | String text = value.getString("v"); |
| | | if (StringUtils.hasText(text)) { |
| | | return text; |
| | | } |
| | | text = value.getString("m"); |
| | | if (StringUtils.hasText(text)) { |
| | | return text; |
| | | } |
| | | |
| | | JSONObject cellType = value.getJSONObject("ct"); |
| | | JSONArray segments = cellType == null ? null : cellType.getJSONArray("s"); |
| | | if (segments == null || segments.isEmpty()) { |
| | | return text; |
| | | } |
| | | StringBuilder richText = new StringBuilder(); |
| | | for (Object segmentObject : segments) { |
| | | if (segmentObject instanceof JSONObject) { |
| | | String segmentText = ((JSONObject) segmentObject).getString("v"); |
| | | if (segmentText != null) { |
| | | richText.append(segmentText); |
| | | } |
| | | } |
| | | } |
| | | return richText.toString(); |
| | | } |
| | | |
| | | private static boolean isInspectionItem(JSONObject value) { |
| | | JSONObject ps = value.getJSONObject("ps"); |
| | | return ps != null && INSPECTION_ITEM_MARK.equals(ps.getString("value")); |