|
@@ -1,5 +1,6 @@
|
|
|
package com.dayou.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONArray;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
@@ -11,17 +12,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.dayou.common.BaseEntity;
|
|
|
import com.dayou.config.FileNetConfig;
|
|
|
+import com.dayou.doc.house.ConditionDO;
|
|
|
import com.dayou.doc.house.ConsignorLetterDO;
|
|
|
import com.dayou.dto.HouseGuarantyTableDTO;
|
|
|
import com.dayou.dto.HouseGuarantyTargetDTO;
|
|
|
import com.dayou.entity.DocumentProduction;
|
|
|
import com.dayou.entity.HouseGuarantyProcess;
|
|
|
+import com.dayou.entity.HouseGuarantyTarget;
|
|
|
+import com.dayou.entity.TmplHouseParagraph;
|
|
|
import com.dayou.enums.DocumentType;
|
|
|
import com.dayou.enums.BusinessEnum;
|
|
|
import com.dayou.exception.ErrorCode;
|
|
|
-import com.dayou.service.DocumentProductionService;
|
|
|
-import com.dayou.service.HouseGuarantyProcessService;
|
|
|
-import com.dayou.service.HouseGuarantyService;
|
|
|
+import com.dayou.service.*;
|
|
|
import com.dayou.utils.AsposeWordUtil;
|
|
|
import com.dayou.utils.EasyExcelUtil;
|
|
|
import com.dayou.utils.HouseDocumentUtil;
|
|
@@ -34,6 +36,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileOutputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.util.ArrayList;
|
|
@@ -43,6 +46,8 @@ import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import static com.dayou.constants.HouseGuarantyDoc.*;
|
|
|
+import static com.dayou.enums.BusinessEnum.HouseGuarantyChapter.ORDINARY_ASSUMPTION;
|
|
|
+import static com.dayou.enums.BusinessEnum.HouseSubBusiness.GUARANTY;
|
|
|
import static com.dayou.enums.HouseTargetTableColumn.ID;
|
|
|
import static java.lang.Thread.sleep;
|
|
|
|
|
@@ -62,6 +67,12 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
@Autowired
|
|
|
private DocumentProductionService documentProductionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private HouseGuarantyTargetService houseGuarantyTargetService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TmplHouseParagraphService tmplHouseParagraphService;
|
|
|
+
|
|
|
@Override
|
|
|
public Long createTableWord(HouseGuarantyTableDTO houseGuarantyTableDTO) {
|
|
|
try {
|
|
@@ -124,8 +135,8 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
XSSFWorkbook workbook = new XSSFWorkbook(home + COLLECT1_XLSX);
|
|
|
Map<String, String> valueMap = EasyExcelUtil.getExcelCellValue(workbook, BASE_INFO_ZH);
|
|
|
String projectName = HouseDocumentUtil.getProjectName(array);
|
|
|
- String docNo = valueMap.get("docNo");
|
|
|
- String consignor = valueMap.get("consignor");
|
|
|
+ String docNo = valueMap.get("docNo");
|
|
|
+ String consignor = valueMap.get("consignor");
|
|
|
|
|
|
ConsignorLetterDO clDO = JSON.parseObject(JSON.toJSONString(valueMap), ConsignorLetterDO.class);
|
|
|
|
|
@@ -158,7 +169,7 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
byte[] tmplWordByte = Files.readAllBytes(Paths.get(baseDir
|
|
|
+ fileNetConfig.getHouseGuarantyTemplatePath() + CONSIGNOR_LETTER_TEMPLATE));
|
|
|
byte[] resultWordByte = AsposeWordUtil.fillWordDataByDomain(tmplWordByte, clDO);
|
|
|
- String consignorLetterName = process.getHome() + System.currentTimeMillis() + ".docx";
|
|
|
+ String consignorLetterName = process.getHome() +"CONSIGNOR_LETTER_TEMPLATE"+ System.currentTimeMillis() + ".docx";
|
|
|
File resultFile = new File(baseDir + consignorLetterName);
|
|
|
FileOutputStream fos = new FileOutputStream(resultFile);
|
|
|
fos.write(resultWordByte);
|
|
@@ -188,7 +199,7 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
Map<String, List<HouseGuarantyTargetDTO>> collect = houseGuarantyTargetDTOS.stream().collect(Collectors.groupingBy(HouseGuarantyTargetDTO::getId));
|
|
|
for (Map.Entry<String, List<HouseGuarantyTargetDTO>> entry : collect.entrySet()) {
|
|
|
HouseTargetVO houseTargetVO = new HouseTargetVO();
|
|
|
- houseTargetVO.setId(entry.getKey());
|
|
|
+ houseTargetVO.setTId(entry.getKey());
|
|
|
houseTargetVO.setList(entry.getValue());
|
|
|
houseTargetVOList.add(houseTargetVO);
|
|
|
}
|
|
@@ -199,6 +210,66 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public String genConditionLetter(Long id) {
|
|
|
+
|
|
|
+ DocumentProduction dp = documentProductionService.getById(id);
|
|
|
+ HouseGuarantyProcess process = houseGuarantyProcessService.getById(dp.getBusinessId());
|
|
|
+ String baseDir = fileNetConfig.getBaseDir();
|
|
|
+ String home = baseDir + process.getHome();
|
|
|
+
|
|
|
+ try {
|
|
|
+ //获取文件数据
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook(home + COLLECT1_XLSX);
|
|
|
+ Map<String, String> valueMap = EasyExcelUtil.getExcelCellValue(workbook, BASE_INFO_ZH);
|
|
|
+ ConditionDO conditionDO = JSON.parseObject(JSON.toJSONString(valueMap), ConditionDO.class);
|
|
|
+
|
|
|
+ //获取估价对象补充信息
|
|
|
+ List<HouseGuarantyTarget> targets = houseGuarantyTargetService.list(new LambdaQueryWrapper<HouseGuarantyTarget>().eq(HouseGuarantyTarget::getDocId, id).eq(BaseEntity::getDeleteStatus, Boolean.FALSE));
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //组合一般假设内容
|
|
|
+ String ybjsResult = tmplHouseParagraphService.findYBJSResult(targets,valueMap.get("isCheckOriginCertificate"), valueMap.get("hasImmovableCertificate"));
|
|
|
+ conditionDO.setYBJS(ybjsResult);
|
|
|
+
|
|
|
+ //组合未定事项假设内容
|
|
|
+ tmplHouseParagraphService.findWDSXJSResult(targets,valueMap.get("hasImmovableCertificate"));
|
|
|
+
|
|
|
+
|
|
|
+ byte[] tmplWordByte = Files.readAllBytes(Paths.get(baseDir
|
|
|
+ + fileNetConfig.getHouseGuarantyTemplatePath() + CONDITION_LETTER_TEMPLATE));
|
|
|
+
|
|
|
+ byte[] resultWordByte = AsposeWordUtil.fillWordDataByDomain(tmplWordByte, conditionDO);
|
|
|
+
|
|
|
+ String conditionLetterName = process.getHome() +"CONDITION_LETTER_TEMPLATE"+System.currentTimeMillis() + ".docx";
|
|
|
+ File resultFile = new File(baseDir + conditionLetterName);
|
|
|
+ FileOutputStream fos = new FileOutputStream(resultFile);
|
|
|
+ fos.write(resultWordByte);
|
|
|
+ fos.close();
|
|
|
+ //更新过程文档url
|
|
|
+ HouseGuarantyProcess houseGuarantyProcess = new HouseGuarantyProcess();
|
|
|
+ houseGuarantyProcess.setProcessName("《估价的假设和限制条件及使用报告说明》");
|
|
|
+ houseGuarantyProcess.setDocUrl(conditionLetterName);
|
|
|
+ houseGuarantyProcess.setHome(process.getHome());
|
|
|
+ houseGuarantyProcess.setParentId(process.getId());
|
|
|
+ houseGuarantyProcessService.save(houseGuarantyProcess);
|
|
|
+ return conditionLetterName;
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new RuntimeException(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, String> getBaseInfoFromFile(Long id) throws IOException {
|
|
|
+ HouseGuarantyProcess process = houseGuarantyProcessService.getById(id);
|
|
|
+ String baseDir = fileNetConfig.getBaseDir();
|
|
|
+ String home = baseDir + process.getHome();
|
|
|
+ //读取基本信息
|
|
|
+ XSSFWorkbook workbook = new XSSFWorkbook(home + COLLECT1_XLSX);
|
|
|
+ return EasyExcelUtil.getExcelCellValue(workbook, BASE_INFO_ZH);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 插入估价结果一览表word文件
|
|
|
* @param mainWordPath
|
|
@@ -248,7 +319,7 @@ public class HouseGuarantyServiceImpl implements HouseGuarantyService {
|
|
|
private DocumentProduction buildDocumentProduction(Long id,String docName,String docNo,String consignor){
|
|
|
DocumentProduction dp = new DocumentProduction();
|
|
|
dp.setBusinessType(BusinessEnum.HOUSE_BUSINESS.getMsg());
|
|
|
- dp.setBusinessCate(BusinessEnum.HouseSubBusiness.GUARANTY.getMsg());
|
|
|
+ dp.setBusinessCate(GUARANTY.getMsg());
|
|
|
dp.setBusinessId(id);
|
|
|
dp.setDocName(docName);
|
|
|
dp.setDocType(DocumentType.REPORT.getName());
|