|
@@ -5,13 +5,12 @@ import cn.hutool.json.JSONObject;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
import com.aspose.cells.SaveFormat;
|
|
|
import com.aspose.cells.Workbook;
|
|
|
-import com.aspose.words.Document;
|
|
|
-import com.aspose.words.DocumentBuilder;
|
|
|
-import com.aspose.words.Paragraph;
|
|
|
+import com.aspose.words.*;
|
|
|
import com.dayou.config.FileNetConfig;
|
|
|
import com.dayou.doc.house.ConsignorLetterDO;
|
|
|
import com.dayou.entity.HouseGuarantyProcess;
|
|
|
import com.dayou.exception.ErrorCode;
|
|
|
+import com.dayou.mapper.HouseGuarantyProcessMapper;
|
|
|
import com.dayou.service.HouseGuarantyProcessService;
|
|
|
import com.dayou.service.HouseGuarantyService;
|
|
|
import com.dayou.utils.AsposeWordUtil;
|
|
@@ -49,14 +48,18 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
@Autowired
|
|
|
private FileNetConfig fileNetConfig;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private HouseGuarantyProcessMapper houseGuarantyProcessMapper;
|
|
|
+
|
|
|
@Override
|
|
|
- public String createTableWord(String html,String homePath) {
|
|
|
+ public Long createTableWord(String html,String homePath) {
|
|
|
html = wordTableHelper.htmlTableFormat(html);
|
|
|
HouseGuarantyProcess hgp = new HouseGuarantyProcess();
|
|
|
hgp.setHome(homePath);
|
|
|
hgp.setTargetsHtml(html);
|
|
|
houseGuarantyProcessService.save(hgp);
|
|
|
- return wordTableHelper.createTableWord(html, fileNetConfig.getBaseDir() + homePath);
|
|
|
+ wordTableHelper.createTableWord(html, fileNetConfig.getBaseDir() + homePath);
|
|
|
+ return hgp.getId();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -89,6 +92,9 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
//读取基本信息
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(home + COLLECT1_XLSX);
|
|
|
Map<String, String> valueMap = EasyExcelUtil.getExcelCellValue(workbook, BASE_INFO_ZH);
|
|
|
+ //更新文档编号
|
|
|
+ houseGuarantyProcessMapper.updateDocNo(id,valueMap.get("docNo"));
|
|
|
+
|
|
|
ConsignorLetterDO clDO = JSON.parseObject(JSON.toJSONString(valueMap), ConsignorLetterDO.class);
|
|
|
clDO.setProjectName(HouseDocumentUtil.getProjectName(array));
|
|
|
Map<Object, List<Object>> collect = array.stream().collect(Collectors.groupingBy(x -> ((JSONObject) x).get(ID.getZhName())));
|
|
@@ -109,10 +115,12 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
clDO.setActDesc(actDesc);
|
|
|
String ownShipUser = HouseDocumentUtil.getOwnShipUser(array);
|
|
|
|
|
|
+ Boolean removeBlank = true;
|
|
|
if (!"".equals(ownShipUser) && !ownShipUser.contains(clDO.getConsignor())){
|
|
|
- clDO.setBlank("");
|
|
|
+ clDO.setOwnshipBlank("");
|
|
|
clDO.setOwnship("不动产权利人:");
|
|
|
clDO.setOwnshipUser(ownShipUser);
|
|
|
+ removeBlank = false;
|
|
|
}
|
|
|
byte[] tmplWordByte = Files.readAllBytes(Paths.get(fileNetConfig.getBaseDir()
|
|
|
+ fileNetConfig.getHouseGuarantyTemplatePath() + CONSIGNOR_LETTER_TEMPLATE));
|
|
@@ -122,7 +130,7 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
FileOutputStream fos = new FileOutputStream(resultFile);
|
|
|
fos.write(resultWordByte);
|
|
|
fos.close();
|
|
|
- insetTargetTableWord(consignorLetterName,home + TARGETS_DOCX);
|
|
|
+ insetTargetTableWord(consignorLetterName,home + TARGETS_DOCX,removeBlank);
|
|
|
return consignorLetterName;
|
|
|
} catch (Exception e) {
|
|
|
throw new RuntimeException(e);
|
|
@@ -135,20 +143,37 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
* @param tableWordPath
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- private void insetTargetTableWord(String mainWordPath,String tableWordPath) throws Exception{
|
|
|
+ private void insetTargetTableWord(String mainWordPath,String tableWordPath,Boolean removeBlank) throws Exception{
|
|
|
// 主word文件
|
|
|
Document mainDoc = new Document(mainWordPath);
|
|
|
+ if (removeBlank){
|
|
|
+ removeBlank(mainDoc);
|
|
|
+ }
|
|
|
+ // 需要插入的word文件
|
|
|
+ Document subDoc = new Document(tableWordPath);
|
|
|
+
|
|
|
+ mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, "targetTable", false);
|
|
|
+ // 保存文件
|
|
|
+ mainDoc.save(mainWordPath);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 删除空白域
|
|
|
+ * @param mainDoc
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ private void removeBlank(Document mainDoc ) throws Exception {
|
|
|
//删除空白行
|
|
|
DocumentBuilder builder = new DocumentBuilder(mainDoc);
|
|
|
- builder.moveToMergeField("blank");
|
|
|
- Paragraph currentParagraph2 = builder.getCurrentParagraph();
|
|
|
+ builder.moveToMergeField("ownshipBlank");
|
|
|
+ Node currentParagraph2 = builder.getCurrentParagraph();
|
|
|
if (currentParagraph2.getParentNode() != null){
|
|
|
currentParagraph2.remove();
|
|
|
}
|
|
|
builder.moveToMergeField("ownship");
|
|
|
Paragraph currentParagraph = builder.getCurrentParagraph();
|
|
|
- if (currentParagraph.getParentNode() != null){
|
|
|
+ CompositeNode parentNode = currentParagraph.getParentNode();
|
|
|
+ if (parentNode != null){
|
|
|
currentParagraph.remove();
|
|
|
}
|
|
|
builder.moveToMergeField("ownshipUser");
|
|
@@ -156,12 +181,5 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
if (currentParagraph1.getParentNode() != null){
|
|
|
currentParagraph1.remove();
|
|
|
}
|
|
|
-
|
|
|
- // 需要插入的word文件
|
|
|
- Document subDoc = new Document(tableWordPath);
|
|
|
-
|
|
|
- mainDoc = AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, subDoc, "targetTable", false);
|
|
|
- // 保存文件
|
|
|
- mainDoc.save(mainWordPath);
|
|
|
}
|
|
|
}
|