|
@@ -1,6 +1,7 @@
|
|
|
package org.springblade.land.service.impl;
|
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -9,24 +10,26 @@ import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.core.tool.utils.ResourceUtil;
|
|
|
import org.springblade.land.dto.SettlementIntervalDTO;
|
|
|
-import org.springblade.land.entity.AgreementLinkTable;
|
|
|
-import org.springblade.land.entity.ClearingAgreementInfo;
|
|
|
-import org.springblade.land.entity.CompensationInfo;
|
|
|
-import org.springblade.land.entity.SettlementInterval;
|
|
|
+import org.springblade.land.entity.*;
|
|
|
import org.springblade.land.mapper.ClearingAgreementInfoMapper;
|
|
|
import org.springblade.land.mapper.SettlementIntervalMapper;
|
|
|
import org.springblade.land.service.IAgreementLinkTableService;
|
|
|
import org.springblade.land.service.IClearingAgreementInfoService;
|
|
|
import org.springblade.land.service.ICompensationInfoService;
|
|
|
import org.springblade.land.service.ISettlementIntervalService;
|
|
|
+import org.springblade.land.utils.FileUtils;
|
|
|
import org.springblade.land.vo.AreaPictureVO;
|
|
|
import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.File;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.ArrayList;
|
|
@@ -37,9 +40,9 @@ import java.util.stream.Collectors;
|
|
|
@AllArgsConstructor
|
|
|
public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAgreementInfoMapper, ClearingAgreementInfo> implements IClearingAgreementInfoService {
|
|
|
|
|
|
- private final ICompensationInfoService compensationInfoService;
|
|
|
-
|
|
|
- private final IAgreementLinkTableService linkTableService;
|
|
|
+ private final ICompensationInfoService compensationInfoService;
|
|
|
+ private final IAgreementLinkTableService linkTableService;
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
|
|
|
/**
|
|
|
* 新增结算协议
|
|
@@ -53,37 +56,62 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
|
|
|
if (StringUtils.isBlank(agreementIds)){
|
|
|
throw new ServiceException("请选择补偿协议");
|
|
|
}
|
|
|
+ //是新增还是修改
|
|
|
+ Boolean isAdd = false;
|
|
|
List<Long> ids = Func.toLongList(agreementIds);
|
|
|
compensationInfoService.batchUpdateStatus(ids,1);
|
|
|
- //复制一份当前合同下对应的结算协议到中间表
|
|
|
- Long agreeId = SnowFlakeUtil.getId();
|
|
|
- //先新增中间表,
|
|
|
- List<WbsTreePrivate> tables = compensationInfoService.getTables(info.getProjectId(), info.getType()+3);
|
|
|
- List<AgreementLinkTable> linkTables = tables.stream().map(l -> {
|
|
|
- AgreementLinkTable table = new AgreementLinkTable();
|
|
|
- table.setTableId(Long.parseLong(l.getInitTableId()));
|
|
|
- table.setProjectId(info.getProjectId());
|
|
|
+ List<AgreementLinkTable> linkTables = new ArrayList<>();
|
|
|
+ if (info.getId() == null) {
|
|
|
+ isAdd = true;
|
|
|
+ //复制一份当前合同下对应的结算协议到中间表
|
|
|
+ Long agreeId = SnowFlakeUtil.getId();
|
|
|
+ //先新增中间表,
|
|
|
+ List<WbsTreePrivate> tables = compensationInfoService.getTables(info.getProjectId(), info.getType() + 3);
|
|
|
+ linkTables = tables.stream().map(l -> {
|
|
|
+ AgreementLinkTable table = new AgreementLinkTable();
|
|
|
+ table.setTableId(Long.parseLong(l.getInitTableId()));
|
|
|
+ table.setProjectId(info.getProjectId());
|
|
|
// table.setTableDataId(SnowFlakeUtil.getId());
|
|
|
// table.setId(SnowFlakeUtil.getId());
|
|
|
- table.setAgreementId(agreeId);
|
|
|
- table.setPrivateId(l.getId());
|
|
|
- table.setSort(l.getSort());
|
|
|
- table.setExcelId(l.getExcelId());
|
|
|
- table.setHtmlUrl(l.getHtmlUrl());
|
|
|
- table.setTableName(l.getNodeName());
|
|
|
- return table;
|
|
|
- }).collect(Collectors.toList());
|
|
|
- linkTableService.saveBatch(linkTables);
|
|
|
- info.setId(agreeId);
|
|
|
+ table.setAgreementId(agreeId);
|
|
|
+ table.setPrivateId(l.getId());
|
|
|
+ table.setSort(l.getSort());
|
|
|
+ table.setExcelId(l.getExcelId());
|
|
|
+ table.setHtmlUrl(l.getHtmlUrl());
|
|
|
+ table.setTableName(l.getNodeName());
|
|
|
+ return table;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ linkTableService.saveBatch(linkTables);
|
|
|
+ info.setId(agreeId);
|
|
|
+ }else {
|
|
|
+ linkTables = linkTableService.getByAgreementId(info.getId());
|
|
|
+ }
|
|
|
//获取所有选中的补偿协议
|
|
|
List<CompensationInfo> compensationInfos = compensationInfoService.listByIds(ids);
|
|
|
//统计补偿协议的统计字段
|
|
|
//总补偿金额
|
|
|
BigDecimal allCount = new BigDecimal(0);
|
|
|
+ //结算协议名称
|
|
|
+ StringBuilder str = new StringBuilder("");
|
|
|
for (CompensationInfo fo : compensationInfos) {
|
|
|
+ //金额统计
|
|
|
if (fo.getAllMoney() != null) {
|
|
|
allCount = allCount.add(fo.getAllMoney());
|
|
|
}
|
|
|
+ //名称拼接
|
|
|
+ str.append(fo.getName()+"、");
|
|
|
+ }
|
|
|
+ info.setAgreementMoney(allCount);
|
|
|
+ String names = str.toString();
|
|
|
+ if (StringUtils.isNotBlank(names)){
|
|
|
+ info.setName(names.substring(0, names.length() - 1)+"结算");
|
|
|
+ }else {
|
|
|
+ info.setName("未找到用户名称");
|
|
|
+ }
|
|
|
+ if (isAdd) {
|
|
|
+ this.save(info);
|
|
|
+ }else {
|
|
|
+ this.updateById(info);
|
|
|
}
|
|
|
//循环结算协议的统计字段,把补偿协议统计出来的字段设置到结算协议
|
|
|
//生成封面
|
|
@@ -93,6 +121,11 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
|
|
|
//生成补偿资金数量分配表
|
|
|
//生成面积统计明细表
|
|
|
//合并PDF
|
|
|
+ try {
|
|
|
+ this.mergePdfs(info.getId());
|
|
|
+ }catch (Exception e){
|
|
|
+ throw new ServiceException("合并PDF失败");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -238,4 +271,40 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
|
|
|
vo.add(vo3);
|
|
|
return R.data(vo);
|
|
|
}
|
|
|
+
|
|
|
+ //合并pdf
|
|
|
+ public void mergePdfs(Long agreementId) throws Exception {
|
|
|
+ String file_path = FileUtils.getSysLocalFileUrl();
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ //获取协议所有的表单
|
|
|
+ List<AgreementLinkTable> list = linkTableService.list(new LambdaQueryWrapper<AgreementLinkTable>()
|
|
|
+ .eq(AgreementLinkTable::getAgreementId, agreementId));
|
|
|
+ for (AgreementLinkTable table : list) {
|
|
|
+ if (StringUtils.isNotEmpty(table.getPdfUrl())) {
|
|
|
+ data.add(table.getPdfUrl());
|
|
|
+ } else {
|
|
|
+ R bussPdfInfo = compensationInfoService.getBussPdfInfo(table.getId());
|
|
|
+ if (bussPdfInfo.getCode() == 200) {
|
|
|
+ if (StringUtils.isNotBlank(bussPdfInfo.getData() + "")) {
|
|
|
+ data.add(bussPdfInfo.getData() + "");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String listPdf = file_path + "/pdf/" + agreementId + ".pdf";
|
|
|
+ File tabpdf2 = ResourceUtil.getFile(listPdf);
|
|
|
+ if (tabpdf2.exists()) {
|
|
|
+ tabpdf2.delete();
|
|
|
+ }
|
|
|
+ if (data.size() >= 1) {
|
|
|
+ //资料填报原始pdf合并
|
|
|
+ FileUtils.mergePdfPublicMethods(data, listPdf);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(agreementId + ".pdf", listPdf);
|
|
|
+ ClearingAgreementInfo info = new ClearingAgreementInfo();
|
|
|
+ info.setId(agreementId);
|
|
|
+ info.setMergePdfUrl(bladeFile.getLink());
|
|
|
+ this.updateById(info);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|