浏览代码

导出的数据包,图片的长度和宽度字段值,由字符串改为数值

xiatian 10 月之前
父节点
当前提交
586ff9a0d7

+ 46 - 8
examcloud-core-questions-service/src/main/java/cn/com/qmth/examcloud/core/questions/service/impl/ExportThemisPaperServiceImpl.java

@@ -439,13 +439,19 @@ public class ExportThemisPaperServiceImpl implements ExportThemisPaperService {
 				List<String> strHeightList = getImg(rowStr, "height");
 				List<String> strHeightList = getImg(rowStr, "height");
 				if (strHeightList.size() > 0) {
 				if (strHeightList.size() > 0) {
 					String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
 					String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
-					param.put("height", strHeight);
+					Integer px=getIntFromString(strHeight);
+					if(px!=null) {
+						param.put("height", px);
+					}
 				}
 				}
 				// 获取图片的宽度
 				// 获取图片的宽度
 				List<String> strWidthList = getImg(rowStr, "width");
 				List<String> strWidthList = getImg(rowStr, "width");
 				if (strHeightList.size() > 0) {
 				if (strHeightList.size() > 0) {
 					String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
 					String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
-					param.put("width", strWidth);
+					Integer px=getIntFromString(strWidth);
+					if(px!=null) {
+						param.put("width", px);
+					}
 				}
 				}
 				block.setParam(param);
 				block.setParam(param);
 				blocks.add(block);
 				blocks.add(block);
@@ -503,13 +509,19 @@ public class ExportThemisPaperServiceImpl implements ExportThemisPaperService {
 				List<String> strHeightList = getImg(rowStr, "height");
 				List<String> strHeightList = getImg(rowStr, "height");
 				if (strHeightList.size() > 0) {
 				if (strHeightList.size() > 0) {
 					String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
 					String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
-					param.put("height", strHeight);
+					Integer px=getIntFromString(strHeight);
+					if(px!=null) {
+						param.put("height", px);
+					}
 				}
 				}
 				// 获取图片的宽度
 				// 获取图片的宽度
 				List<String> strWidthList = getImg(rowStr, "width");
 				List<String> strWidthList = getImg(rowStr, "width");
 				if (strHeightList.size() > 0) {
 				if (strHeightList.size() > 0) {
 					String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
 					String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
-					param.put("width", strWidth);
+					Integer px=getIntFromString(strWidth);
+					if(px!=null) {
+						param.put("width", px);
+					}
 				}
 				}
 				block.setParam(param);
 				block.setParam(param);
 				blocks.add(block);
 				blocks.add(block);
@@ -567,6 +579,20 @@ public class ExportThemisPaperServiceImpl implements ExportThemisPaperService {
 		return blocks;
 		return blocks;
 	}
 	}
 	
 	
+	private Integer getIntFromString(String s) {
+		if(StringUtils.isBlank(s)) {
+			return null;
+		}
+		s=s.trim();
+		s=s.replace("px", "");
+		try {
+			Integer i=Integer.valueOf(s);
+			return i;
+		} catch (NumberFormatException e) {
+			return null;
+		}
+	}
+	
 
 
 	private List<ThemisBlock> disposeQuestionBodyOrOption(String questionRow, ThemisPaper computerTestPaper) {
 	private List<ThemisBlock> disposeQuestionBodyOrOption(String questionRow, ThemisPaper computerTestPaper) {
 		List<ThemisBlock> blocks = new ArrayList<>();
 		List<ThemisBlock> blocks = new ArrayList<>();
@@ -594,13 +620,19 @@ public class ExportThemisPaperServiceImpl implements ExportThemisPaperService {
 				List<String> strHeightList = getImg(rowStr, "height");
 				List<String> strHeightList = getImg(rowStr, "height");
 				if (strHeightList.size() > 0) {
 				if (strHeightList.size() > 0) {
 					String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
 					String strHeight = strHeightList.get(0).replaceAll("height=\"", "").replaceAll("\"", "");
-					param.put("height", strHeight);
+					Integer px=getIntFromString(strHeight);
+					if(px!=null) {
+						param.put("height", px);
+					}
 				}
 				}
 				// 获取图片的宽度
 				// 获取图片的宽度
 				List<String> strWidthList = getImg(rowStr, "width");
 				List<String> strWidthList = getImg(rowStr, "width");
 				if (strHeightList.size() > 0) {
 				if (strHeightList.size() > 0) {
 					String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
 					String strWidth = strWidthList.get(0).replaceAll("width=\"", "").replaceAll("\"", "");
-					param.put("width", strWidth);
+					Integer px=getIntFromString(strWidth);
+					if(px!=null) {
+						param.put("width", px);
+					}
 				}
 				}
 				block.setParam(param);
 				block.setParam(param);
 				blocks.add(block);
 				blocks.add(block);
@@ -775,8 +807,14 @@ public class ExportThemisPaperServiceImpl implements ExportThemisPaperService {
 						String w = el.attr("width");
 						String w = el.attr("width");
 						if (StringUtils.isNotBlank(w) && StringUtils.isNotBlank(h)) {
 						if (StringUtils.isNotBlank(w) && StringUtils.isNotBlank(h)) {
 							Map<String, Object> param = new HashMap<String, Object>();
 							Map<String, Object> param = new HashMap<String, Object>();
-							param.put("height", h);
-							param.put("width", w);
+							Integer hpx=getIntFromString(h);
+							if(hpx!=null) {
+								param.put("height", hpx);
+							}
+							Integer wpx=getIntFromString(w);
+							if(wpx!=null) {
+								param.put("width", wpx);
+							}
 							block.setParam(param);
 							block.setParam(param);
 						}
 						}
 					} else {
 					} else {