|
@@ -45,6 +45,7 @@ import com.rongwei.rwcommoncomponent.excel.aspose.ExcelExportUtil;
|
|
|
import com.rongwei.rwcommoncomponent.excel.aspose.ExcelUtils;
|
|
|
import com.rongwei.rwcommoncomponent.excel.utils.WordHelpUtils;
|
|
|
import com.rongwei.rwcommoncomponent.excel.vo.FormData;
|
|
|
+import com.rongwei.rwcommoncomponent.file.dto.SysFileItemParamDto;
|
|
|
import com.rongwei.rwcommoncomponent.file.service.SysFileItemService;
|
|
|
import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
|
|
|
import jodd.util.StringUtil;
|
|
@@ -55,6 +56,7 @@ import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.core.io.ClassPathResource;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -1779,10 +1781,13 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
Map<String, SysDictDo> dictMap = new HashMap<>(list.size());
|
|
|
list.stream().forEach(item -> dictMap.put(item.getName(), item));
|
|
|
|
|
|
+ final Map<String, List<String>> docImgMap = parseDocImage(doc); //word中图片
|
|
|
+
|
|
|
final ParseDocBO docBO = ParseDocBO.builder()
|
|
|
.id(importDto.getId())
|
|
|
.dictMap(dictMap)
|
|
|
.project(project)
|
|
|
+ .docImgMap(docImgMap)
|
|
|
.build();
|
|
|
|
|
|
//解析word文档
|
|
@@ -2458,6 +2463,60 @@ public class ZhcxCommissionCheckServiceImpl extends ServiceImpl<ZhcxCommissionCh
|
|
|
return R.ok();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 解析word中图片
|
|
|
+ *
|
|
|
+ * @param doc
|
|
|
+ * @return key:为标题,value: 系统图片格式
|
|
|
+ */
|
|
|
+ private Map<String, List<String>> parseDocImage(Document doc) {
|
|
|
+
|
|
|
+ // 创建一个 NodeCollection 对象,用于存储文档中的所有形状
|
|
|
+ NodeCollection shapes = doc.getChildNodes(NodeType.SHAPE, true);
|
|
|
+
|
|
|
+ Map<String, List<String>> docImgMap = new HashMap<>();
|
|
|
+ // 遍历所有形状
|
|
|
+ try {
|
|
|
+ for (int i = 0; i < shapes.getCount(); i++) {
|
|
|
+ Shape shape = (Shape) shapes.get(i);
|
|
|
+ // 检查形状是否包含图片
|
|
|
+ if (!shape.hasImage()) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 查找图片所在的标题
|
|
|
+ String title = ImportCommissionHelp.findTitleForImage(shape, doc);
|
|
|
+ if(ObjectUtil.isEmpty(title)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> imgList = docImgMap.get(title);
|
|
|
+ if(ObjectUtil.isNull(imgList)) {
|
|
|
+ imgList = new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ //图片名称
|
|
|
+ SysFileItemParamDto itemParamDto = SysFileItemParamDto.builder()
|
|
|
+ .fileName("img_word_".concat(String.valueOf(i)).concat(FileFormatUtil.imageTypeToExtension(shape.getImageData().getImageType())))
|
|
|
+ .folderCode("driveinspection_files")
|
|
|
+ .build();
|
|
|
+ final SysFileItemDo fileItemDo = sysFileItemService.assembleItem(itemParamDto, null);
|
|
|
+ fileItemDo.setFilename(String.format("img_word_%s.%s", fileItemDo.getId(), FileFormatUtil.imageTypeToExtension(shape.getImageData().getImageType())));
|
|
|
+ FileOutputStream out = new FileOutputStream(fileItemDo.getFullpath());
|
|
|
+ out.write(shape.getImageData().getImageBytes());
|
|
|
+ out.close();
|
|
|
+
|
|
|
+ imgList.add(fileItemDo.getFilename().concat("-;-").concat(fileItemDo.getId()));
|
|
|
+ docImgMap.put(title, imgList);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("图片解析失败, {}", e);
|
|
|
+ throw new CustomException("图片解析失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ return docImgMap;
|
|
|
+ }
|
|
|
+
|
|
|
private void insertDetailData(List<ZhcxCommissionCheckBaseInfoTreeDo> treeList, List<ZhcxCommissionCheckBaseInfoDetailDo> detailList) {
|
|
|
//设置标准库子表的三级分类的id和树的全路径treefullid字段
|
|
|
if (!treeList.isEmpty() && !detailList.isEmpty()) {
|