Explorar o código

Merge remote-tracking branch 'origin/master' into master

yangyj hai 1 ano
pai
achega
217e1df0ac
Modificáronse 30 ficheiros con 868 adicións e 159 borrados
  1. 4 0
      blade-ops/blade-resource/src/main/java/org/springblade/resource/builder/oss/AliOssBuilder.java
  2. 2 2
      blade-ops/blade-resource/src/main/java/org/springblade/resource/service/impl/OssServiceImpl.java
  3. 8 8
      blade-ops/blade-resource/src/main/resources/application.yml
  4. 3 0
      blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/FixedFlowVO.java
  5. 4 1
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/ClearingAgreementInfo.java
  6. 13 1
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/CompensationInfo.java
  7. 17 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/vo/AreaPictureVO.java
  8. 11 6
      blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileTaskController.java
  9. 15 2
      blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveMeasurementController.java
  10. 2 1
      blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java
  11. 3 0
      blade-service/blade-business/src/main/java/org/springblade/business/controller/EVisaTaskCheckController.java
  12. 11 6
      blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java
  13. 6 9
      blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java
  14. 1 1
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TaskMapper.java
  15. 15 10
      blade-service/blade-business/src/main/java/org/springblade/business/mapper/TaskMapper.xml
  16. 4 4
      blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java
  17. 125 1
      blade-service/blade-land/src/main/java/org/springblade/land/controller/ClearingAgreementInfoController.java
  18. 20 4
      blade-service/blade-land/src/main/java/org/springblade/land/controller/CompensationInfoController.java
  19. 5 6
      blade-service/blade-land/src/main/java/org/springblade/land/controller/SettlementIntervalController.java
  20. 4 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/ClearingAgreementInfoMapper.java
  21. 11 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/ClearingAgreementInfoMapper.xml
  22. 8 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/CompensationInfoMapper.java
  23. 27 1
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/CompensationInfoMapper.xml
  24. 20 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/IClearingAgreementInfoService.java
  25. 16 1
      blade-service/blade-land/src/main/java/org/springblade/land/service/ICompensationInfoService.java
  26. 316 2
      blade-service/blade-land/src/main/java/org/springblade/land/service/impl/ClearingAgreementInfoServiceImpl.java
  27. 159 85
      blade-service/blade-land/src/main/java/org/springblade/land/service/impl/CompensationInfoServiceImpl.java
  28. 20 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java
  29. 1 0
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeContractServiceImpl.java
  30. 17 4
      blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

+ 4 - 0
blade-ops/blade-resource/src/main/java/org/springblade/resource/builder/oss/AliOssBuilder.java

@@ -53,6 +53,10 @@ public class AliOssBuilder {
         conf.setMaxErrorRetry(5);
         OssProperties ossProperties = new OssProperties();
         ossProperties.setEndpoint(oss.getEndpoint());
+
+        //本地测试
+        //ossProperties.setEndpoint("https://oss-cn-hangzhou.aliyuncs.com/");
+
         ossProperties.setAccessKey(oss.getAccessKey());
         ossProperties.setSecretKey(oss.getSecretKey());
         ossProperties.setBucketName(oss.getBucketName());

+ 2 - 2
blade-ops/blade-resource/src/main/java/org/springblade/resource/service/impl/OssServiceImpl.java

@@ -58,9 +58,9 @@ public class OssServiceImpl extends BaseServiceImpl<OssMapper, Oss> implements I
     @Transactional(rollbackFor = Exception.class)
     public boolean enable(Long id) {
         // 先禁用
-        boolean temp1 = this.update(Wrappers.<Oss>update().lambda().set(Oss::getStatus, 1));
+        boolean temp1 = this.update(Wrappers.<Oss>update().lambda().set(Oss::getStatus, 0).eq(Oss::getId, id));
         // 在启用
-        boolean temp2 = this.update(Wrappers.<Oss>update().lambda().set(Oss::getStatus, 2).eq(Oss::getId, id));
+        boolean temp2 = this.update(Wrappers.<Oss>update().lambda().set(Oss::getStatus, 1).eq(Oss::getId, id));
         return temp1 && temp2;
     }
 

+ 8 - 8
blade-ops/blade-resource/src/main/resources/application.yml

@@ -3,11 +3,11 @@ server:
   port: 8099
 
 #默认对象存储配置
-oss:
-  enabled: true
-  name: minio
-  tenant-mode: true
-  endpoint: http://127.0.0.1:9000
-  access-key: D99KGE6ZTQXSATTJWU24
-  secret-key: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ
-  bucket-name: bladex
+#oss:
+#  enabled: true
+#  name: minio
+#  tenant-mode: true
+#  endpoint: http://127.0.0.1:9000
+#  access-key: D99KGE6ZTQXSATTJWU24
+#  secret-key: QyVqGnhIQQE734UYSUFlGOZViE6+ZlDEfUG3NjhJ
+#  bucket-name: bladex

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/vo/FixedFlowVO.java

@@ -52,6 +52,9 @@ public class FixedFlowVO extends FixedFlow {
     @ApiModelProperty("是否可选")
     private boolean disabled;
 
+    @ApiModelProperty("提示信息")
+    private String tips;
+
     private Query query;
 
     public Query getQuery(Integer current, Integer size) {

+ 4 - 1
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/ClearingAgreementInfo.java

@@ -21,7 +21,10 @@ public class ClearingAgreementInfo extends BaseEntity {
     private Long projectId;
 
     @ApiModelProperty(value = "计量期")
-    private Long periodId;
+    private String stage;
+
+    @ApiModelProperty(value = "计量期id")
+    private Long stageId;
 
     @ApiModelProperty(value = "协议名称")
     private String name;

+ 13 - 1
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/CompensationInfo.java

@@ -76,7 +76,19 @@ public class CompensationInfo extends BaseEntity {
     private String partyC;
 
     @ApiModelProperty(value = "是否引用0否1是")
-    private String isQuote;
+    private Integer isQuote;
+
+    @ApiModelProperty(value = "农用地面积")
+    private BigDecimal areaA;
+
+    @ApiModelProperty(value = "建设用地面积")
+    private BigDecimal areaB;
+
+    @ApiModelProperty(value = "未利用地面积")
+    private BigDecimal areaC;
+
+    @ApiModelProperty(value = "总面积")
+    private BigDecimal areaAll;
 
 
 }

+ 17 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/vo/AreaPictureVO.java

@@ -0,0 +1,17 @@
+package org.springblade.land.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2023/10/9 16:24
+ **/
+@Data
+public class AreaPictureVO {
+    private String name;
+    private List<BigDecimal> value;
+}

+ 11 - 6
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveFileTaskController.java

@@ -73,8 +73,8 @@ public class ArchiveFileTaskController extends BladeController {
                 //固定水印图片章
                 String pngQzUrl = "https://bladex-chongqing-info.oss-cn-hangzhou.aliyuncs.com//upload/20230911/5b42583d931664b785ebf481c37d17bc.png";
                 for (ArchiveFile archiveFile : archiveFileList) {
-                    if (!archiveFile.getStatus().equals(0)) {
-                        throw new ServiceException("只有【未上报】状态的业务数据才能认证!");
+                    if (Arrays.asList(1, 2).contains(archiveFile.getStatus())) {
+                        throw new ServiceException("只有【未上报 或 已废除】状态的业务数据才能认证!");
                     }
                     if (!archiveFile.getIsCertification().equals(0)) {
                         throw new ServiceException("只有【未认证】状态的业务数据才能认证!");
@@ -104,10 +104,15 @@ public class ArchiveFileTaskController extends BladeController {
                         }
                         eVISATaskArchiveDTO.setSealStrategy(signList);
 
-                        //TODO ============= 电签认证 =============
-                        eVISATaskArchiveDTO.setTaskId(archiveFile.getId().toString());
-                        eVISATaskArchiveDTO.setType(2); //认证
-                        this.eVisaClient.eVisaCustom(eVISATaskArchiveDTO);
+                        try {
+                            //TODO ============= 电签认证 =============
+                            eVISATaskArchiveDTO.setTaskId(archiveFile.getId().toString());
+                            eVISATaskArchiveDTO.setType(2); //认证
+                            this.eVisaClient.eVisaCustom(eVISATaskArchiveDTO);
+                        } catch (Exception e) {
+                            e.getStackTrace();
+                            throw new ServiceException("电签服务器调用失败,请联系管理员,原因:" + e.getMessage());
+                        }
                     }
                 }
                 return R.data(true);

+ 15 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchiveMeasurementController.java

@@ -89,6 +89,11 @@ public class ArchiveMeasurementController {
             if (StringUtils.isNotEmpty(dutyUser)) {
                 dutyUser = URLDecoder.decode(dutyUser, StandardCharsets.UTF_8.toString());
             }
+            if (StringUtils.isNotEmpty(fileTime) && fileTime.contains(".")) {
+                fileTime = fileTime.replace(".","");
+            }
+
+
 
         } catch (UnsupportedEncodingException e) {
             e.printStackTrace();
@@ -127,10 +132,18 @@ public class ArchiveMeasurementController {
                 List<ArchiveFile> archiveFiles = archiveFileClient.getListByNodeIDName(periodNode.getId().toString(),fileName);
                 if (archiveFiles == null || archiveFiles.size() == 0) {
                     ArchiveFile archiveFile = new ArchiveFile();
+                    archiveFile.setFileUrl(fileUrl);
+                    archiveFile.setPdfFileUrl(fileUrl);
+                    archiveFile.setFilePage(Integer.valueOf(pdfPage));
+                    archiveFile.setFileSize(pdfSize);
                     archiveFile.setProjectId(periodNode.getProjectId().toString());
                     archiveFile.setContractId(periodNode.getContractId().toString());
                     archiveFile.setIsDeleted(0);
                     archiveFile.setIsArchive(0);
+                    archiveFile.setFileNumber("\\");
+                    archiveFile.setIsApproval(1);
+                    archiveFile.setIsCertification(0);
+                    archiveFile.setIsNeedCertification(1);
                     archiveFile.setNodeId(periodNode.getId().toString());
                     archiveFile.setPageNum(pdfPage);
                     archiveFile.setFileSize(pdfSize);
@@ -141,7 +154,7 @@ public class ArchiveMeasurementController {
                     if (periodNode.getStorageType() !=  null ) {
                         archiveFile.setFileType(periodNode.getStorageType().longValue());
                     }
-
+                    archiveFile.setStatus(0);
                     List<ArchiveFile> archiveFileList = new ArrayList<>();
                     archiveFileList.add(archiveFile);
                     archiveFileClient.addArchiveFile(archiveFileList);
@@ -152,7 +165,7 @@ public class ArchiveMeasurementController {
                     if (StringUtils.isNotEmpty(archiveFile.getPdfFileUrl())) {
                         iossClient.removeFile(archiveFile.getPdfFileUrl());
                     }
-
+                    archiveFile.setFileUrl(fileUrl);
                     archiveFile.setPdfFileUrl(fileUrl);
                     archiveFile.setFilePage(Integer.valueOf(pdfPage));
                     archiveFile.setFileSize(pdfSize);

+ 2 - 1
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchiveAutoPdfServiceImpl.java

@@ -877,7 +877,8 @@ public class ArchiveAutoPdfServiceImpl implements IArchiveAutoPdfService {
 
             //上传到oss
             String absoluteFileName = FileUtils.getOssPath(OssConstant.ARCHIVE_DIRECTORY,fileName,projectId);
-            BladeFile file = newIOSSClient.uploadFile(absoluteFileName + ".pdf", localPdf);
+
+            BladeFile file = newIOSSClient.uploadFile(absoluteFileName, localPdf);
 
             url = file.getLink();
         } catch (Exception e) {

+ 3 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/EVisaTaskCheckController.java

@@ -305,6 +305,9 @@ public class EVisaTaskCheckController {
                         if (!eVisaRoleList.contains(userRole.getString("roleId"))) {
                             //但凡有个不符合条件,禁选
                             next.setDisabled(true);
+                            //设置提示信息
+                            String name = jdbcTemplate.queryForObject(" select name from blade_user WHERE id = " + userRole.get("userId"), String.class);
+                            next.setTips(name+"没有电签权限,请检查电签配置或查看表单是否隐藏");
                             break;
                         }
                     }

+ 11 - 6
blade-service/blade-business/src/main/java/org/springblade/business/controller/InformationWriteQueryController.java

@@ -1052,8 +1052,8 @@ public class InformationWriteQueryController extends BladeController {
                     if (new Integer("1").equals(task.getStatus())) {
                         //正在审批,调用废除
                         this.taskClient.abolishTask(task);
-                    } else if (new Integer("2").equals(task.getStatus())) {
-                        //已审批的任务,修改业务数据的审批状态为未上报并撤签即可
+                    } else if (new Integer("2").equals(task.getStatus()) || new Integer("3").equals(task.getStatus())) {
+                        //已审批、已撤销的任务,修改业务数据的审批状态为未上报并撤签即可
                         LambdaUpdateWrapper<InformationQuery> wrapper = Wrappers.lambdaUpdate();
                         //更改状态为未上报
                         wrapper.set(InformationQuery::getStatus, 0);
@@ -1207,7 +1207,8 @@ public class InformationWriteQueryController extends BladeController {
                 return R.data(300, false, "废除失败");
             }
         }
-        return R.data(300, false, "废除失败");
+
+        return R.data(300, false, "未获取到任务信息,废除失败");
     }
 
     /**
@@ -1354,10 +1355,14 @@ public class InformationWriteQueryController extends BladeController {
     public R<Boolean> diySort(@RequestBody DiySortVO vo) {
         List<String> sortLists = vo.getSortList();
         boolean b = wbsTreeContractClient.diySort(sortLists);
-        if (sortLists != null) {
-            WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(sortLists.get(0));
+        if (sortLists != null && b) {
             //获取父节点信息
-            informationQueryService.AsyncWbsTree(needCopyNode.getParentId() + "", needCopyNode.getParentId() + "", needCopyNode.getContractId(), "", "1");
+            WbsTreeContract needCopyNode = this.wbsTreeContractClient.getContractNodeByPrimaryKeyId(sortLists.get(0));
+
+            //更新Redis缓存
+            if (needCopyNode != null && ObjectUtil.isNotEmpty(needCopyNode.getContractId())) {
+                informationQueryService.delAsyncWbsTree(needCopyNode.getContractId());
+            }
         }
         return R.status(b);
     }

+ 6 - 9
blade-service/blade-business/src/main/java/org/springblade/business/controller/TaskController.java

@@ -379,8 +379,8 @@ public class TaskController extends BladeController {
         List<ArchiveFile> archiveFiles = jdbcTemplate.query("select * from u_archive_file where id in (" + archiveTaskBatchReportDTO.getDataIds() + ")", new BeanPropertyRowMapper<>(ArchiveFile.class));
         if (archiveFiles.size() > 0) {
             for (ArchiveFile archive : archiveFiles) {
-                if (!archive.getStatus().equals(0)) {
-                    throw new ServiceException("只有【未上报】状态的业务数据才能上报!");
+                if (Arrays.asList(1, 2).contains(archive.getStatus())) {
+                    throw new ServiceException("只有【未上报 或 已废除】状态的业务数据才能上报!");
                 }
                 if (!archive.getIsCertification().equals(0)) {
                     throw new ServiceException("只有【未认证】状态的业务数据才能上报!");
@@ -477,17 +477,14 @@ public class TaskController extends BladeController {
     @ApiOperationSupport(order = 8)
     @ApiOperation(value = "批量撤销(废除)-档案")
     public R<Object> batchRepealTaskArchive(@RequestBody ArchiveTaskBatchRepealDTO repealDTO) throws IOException {
-        if (repealDTO.getType().equals(1)) { //文件收集废除
+        if (repealDTO.getType().equals(1)) { //文件收集废除(有可能是 认证废除 或 上报任务废除)
             String[] archiveIds = repealDTO.getIds().split(",");
             for (String archiveId : archiveIds) {
                 //判断现在的数据是否是待审批数据,只有上报状态、未认证状态的数据才能撤销
                 ArchiveFile archiveFile = jdbcTemplate.queryForObject("select * from u_archive_file where id = " + archiveId, new BeanPropertyRowMapper<>(ArchiveFile.class));
-                if (archiveFile != null && !archiveFile.getIsCertification().equals(0) && (!archiveFile.getStatus().equals(1) || !archiveFile.getStatus().equals(2))) {
-                    throw new ServiceException("当前数据不是未认证,并且处于上报状态,无法进行废除操作!");
-                }
                 if (archiveFile != null) {
                     //修改档案文件收集业务数据状态=已废除
-                    jdbcTemplate.execute("update u_archive_file set status = 3 where id = " + archiveId);
+                    jdbcTemplate.execute("update u_archive_file set status = 3,is_certification = 0,e_visa_file = null where id = " + archiveId);
                     Task task = jdbcTemplate.query("select id,status,process_instance_id from u_task where form_data_id = " + archiveId, new BeanPropertyRowMapper<>(Task.class)).stream().findAny().orElse(null);
                     if (task != null && task.getStatus().equals(1)) {
                         //待审批审批任务=已废除
@@ -525,7 +522,7 @@ public class TaskController extends BladeController {
                     //审批任务详情=已废除
                     jdbcTemplate.execute("update u_task_parallel set status = 3 where process_instance_id = '" + task.getProcessInstanceId() + "'");
                     //修改档案文件收集业务数据状态
-                    jdbcTemplate.execute("update u_archive_file set status = 3 where id = " + task.getFormDataId());
+                    jdbcTemplate.execute("update u_archive_file set status = 3,e_visa_file = null where id = " + task.getFormDataId());
                 }
             }
             //WebSocket推送
@@ -585,7 +582,7 @@ public class TaskController extends BladeController {
                             this.eVisaClient.eVisaCustom(eVisaObj);
                         } catch (Exception e) {
                             e.printStackTrace();
-                            throw new ServiceException("电签失败,原因:" + e.getMessage());
+                            throw new ServiceException("电签服务器调用失败,请联系管理员,原因:" + e.getMessage());
                         }
 
                         //获取审批任务关联用户的详情

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TaskMapper.java

@@ -30,7 +30,7 @@ import java.util.List;
  */
 public interface TaskMapper extends BaseMapper<Task> {
 
-    Task queryTaskListByFormDataId(@Param("formDataId") String formDataId);
+    Task queryTaskListByFormDataId(@Param("formDataId") String formDataId, int type);
 
     List<Task> queryBatchList(@Param("projectId") String projectId, @Param("contractId") String contractId);
 

+ 15 - 10
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TaskMapper.xml

@@ -31,18 +31,23 @@
     </resultMap>
 
     <select id="queryTaskListByFormDataId" resultMap="taskResultMap">
-        select id,
-               form_data_id,
-               process_instance_id,
-               approval_type,
-               status,
-               batch,
-               project_id,
-               contract_id
+        select  id,
+                form_data_id,
+                process_instance_id,
+                approval_type,
+                status,
+                batch,
+                project_id,
+                contract_id
         from u_task
         where form_data_id like concat('%', #{formDataId}, '%')
-          and status in (1, 2)
-          and is_deleted = 0
+        <if test="type == 1">
+            and status in (1, 2, 3)
+        </if>
+        <if test="type == 2">
+            and status in (1, 2)
+        </if>
+        and is_deleted = 0
         order by create_time DESC limit 1
     </select>
 

+ 4 - 4
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -138,7 +138,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
         String[] formDataIdArray = formDataIds.split(",");
         List<Long> taskIds = new ArrayList<>();
         for (String formDataId : formDataIdArray) {
-            Task task = this.baseMapper.queryTaskListByFormDataId(formDataId);
+            Task task = this.baseMapper.queryTaskListByFormDataId(formDataId, 2);
             if (!taskIds.contains(task.getId())) {
                 //查询审批人
                 List<TaskParallel> parallels = this.taskParallelService.queryApprovalUser(task.getProcessInstanceId());
@@ -333,7 +333,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
 
         String[] formDataIdArray = formDataIds.split(",");
         for (String formDataId : formDataIdArray) {
-            Task task = this.baseMapper.queryTaskListByFormDataId(formDataId);
+            Task task = this.baseMapper.queryTaskListByFormDataId(formDataId, 1);
             if (task != null && !record.contains(task.getId())) {
                 record.add(task.getId());
                 result.add(task);
@@ -609,7 +609,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
         RedisTemplate.opsForValue().set("sign-" + taskApprovalVO.getFormDataId(), "1", 60, TimeUnit.SECONDS);
 
         String pdfUrlEVisa = this.completeApprovalTask(taskApprovalVO);
-        System.out.println("电签操作成功buss-----"+pdfUrlEVisa);
+        System.out.println("电签操作成功buss-----" + pdfUrlEVisa);
         //TODO ============== 电签成功,修改试验状态,关联工程部位信息pdf(只有电签成功,才修改) liuYc 2023-03-16 ==============
         if ("OK".equals(taskApprovalVO.getFlag()) && StringUtils.isNotEmpty(pdfUrlEVisa)) {
             //已审批
@@ -651,7 +651,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
             //todo ============================ 执行电签区域 ============================
             //电签状态
             String eVisaStatus = this.eVisaClient.eVisa(JSONObject.parseObject(JSONObject.toJSONString(taskApprovalVO), EVisaTaskApprovalVO.class));
-            System.out.println("+++++"+eVisaStatus);
+            System.out.println("+++++" + eVisaStatus);
             //todo ============================ 执行电签区域 ============================
 
             //电签状态分为success/notPfxOrFile/error,当状态为error时就需要重新提交请求

+ 125 - 1
blade-service/blade-land/src/main/java/org/springblade/land/controller/ClearingAgreementInfoController.java

@@ -1,10 +1,23 @@
 package org.springblade.land.controller;
 
-import io.swagger.annotations.Api;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
+import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.land.entity.AgreementLinkTable;
+import org.springblade.land.entity.ClearingAgreementInfo;
+import org.springblade.land.entity.CompensationInfo;
+import org.springblade.land.service.IClearingAgreementInfoService;
+import org.springblade.land.vo.AreaPictureVO;
+import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 /**
  * @Param
  * @Author wangwl
@@ -16,4 +29,115 @@ import org.springframework.web.bind.annotation.RestController;
 @Api(value = "结算协议", tags = "结算协议接口")
 public class ClearingAgreementInfoController {
 
+    private final IClearingAgreementInfoService infoService;
+
+    /**
+     * 新增结算协议
+     */
+    @GetMapping("/addOrUpdate")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "新增或修改结算协议", notes = "新增或修改结算协议")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+            @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
+            @ApiImplicitParam(name = "stage", value = "结算期", required = true),
+            @ApiImplicitParam(name = "stageId", value = "结算期id", required = true),
+            @ApiImplicitParam(name = "agreementIds", value = "补偿协议id数组,逗号分隔", required = true),
+            @ApiImplicitParam(name = "type", value = "协议类型1征地补偿2坟地补偿3专项设施", required = true),
+            @ApiImplicitParam(name = "id", value = "结算id,修改时传入代表修改", required = false)
+    })
+    public R<Long> add(ClearingAgreementInfo info) throws Exception {
+        infoService.add(info);
+        return R.success("保存成功");
+    }
+
+    /**
+     * 分页
+     */
+    @GetMapping("/page")
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "分页查询结算", notes = "分页查询结算")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+            @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
+            @ApiImplicitParam(name = "current", value = "当前页", required = true),
+            @ApiImplicitParam(name = "size", value = "每页的数量", required = true),
+            @ApiImplicitParam(name = "type", value = "协议类型1征地补偿2坟地补偿3专项设施", required = false),
+            @ApiImplicitParam(name = "periodId", value = "结算期", required = false)
+    })
+    public R<IPage<ClearingAgreementInfo>> page(Query query, ClearingAgreementInfo info)  {
+        IPage<ClearingAgreementInfo> page = infoService.page(query, info);
+        return R.data(page);
+    }
+
+
+    /**
+     * 查看文件列表
+     */
+    @GetMapping("/getFileList")
+    @ApiOperationSupport(order = 4)
+    @ApiOperation(value = "查看文件列表", notes = "查看文件列表")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "id", value = "结算id", required = true),
+    })
+    public R<List<AgreementLinkTable>> getFileList(Long id)  {
+        List<AgreementLinkTable> fileList = infoService.getFileList(id);
+        return R.data(fileList);
+    }
+
+    /**
+     * 批量删除
+     */
+    @GetMapping("/remove")
+    @ApiOperationSupport(order = 6)
+    @ApiOperation(value = "批量逻辑删除", notes = "传入ids")
+    public R remove(@ApiParam(value = "主键集合", required = true)String ids) {
+        infoService.remove(ids);
+        return R.success("删除成功");
+    }
+
+
+    /**
+     * 结算统计-面积进度
+     */
+    @GetMapping("/statArea")
+    @ApiOperationSupport(order = 7)
+    @ApiOperation(value = "结算统计面积进度", notes = "返回字符串数组")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+            @ApiImplicitParam(name = "areaId", value = "区域id", required = true)
+    })
+    public R statArea(Long projectId,Long areaId)  {
+        return infoService.statArea(projectId,areaId);
+    }
+
+    /**
+     * 结算统计-面积进度柱状图
+     */
+    @GetMapping("/statAreaPicture")
+    @ApiOperationSupport(order = 7)
+    @ApiOperation(value = "结算统计-面积进度柱状图", notes = "结算统计-面积进度柱状图")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+            @ApiImplicitParam(name = "areaId", value = "区域id", required = true)
+    })
+    public R<List<AreaPictureVO>> statAreaPicture(Long projectId, Long areaId)  {
+        return infoService.statAreaPicture(projectId,areaId);
+    }
+
+    /**
+     * 结算统计-金额进度
+     */
+    @GetMapping("/statMoney")
+    @ApiOperationSupport(order = 7)
+    @ApiOperation(value = "结算统计-金额进度", notes = "结算统计-金额进度")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+            @ApiImplicitParam(name = "areaId", value = "区域id", required = true)
+    })
+    public R<List<AreaPictureVO>> statMoney(Long projectId, Long areaId)  {
+        return infoService.statMoney(projectId,areaId);
+    }
+
+
 }

+ 20 - 4
blade-service/blade-land/src/main/java/org/springblade/land/controller/CompensationInfoController.java

@@ -194,16 +194,32 @@ public class CompensationInfoController extends BladeController {
      */
     @GetMapping("/getAgreementList")
     @ApiOperationSupport(order = 12)
-    @ApiOperation(value = "结算查询补偿协议", notes = "结算查询补偿协议")
+    @ApiOperation(value = "结算获取补偿协议列表", notes = "结算获取补偿协议列表")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
             @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
             @ApiImplicitParam(name = "type", value = "协议类型1征地补偿2坟地补偿3专项设施", required = true),
-            @ApiImplicitParam(name = "number", value = "编号搜索值", required = false)
+            @ApiImplicitParam(name = "number", value = "编号搜索值", required = false),
+            @ApiImplicitParam(name = "agreementIds", value = "补偿协议id数组,修改时传入,回显已经选择的", required = false)
+
     })
-    public R<List<CompensationInfo>> getAgreementList(CompensationInfo info)  {
-        List<CompensationInfo> list = compensationInfoService.getAgreementList(info);
+    public R<List<CompensationInfo>> getAgreementList(CompensationInfo info,String agreementIds)  {
+        List<CompensationInfo> list = compensationInfoService.getAgreementList(info,agreementIds);
         return R.data(list);
     }
 
+    /**
+     * 取消保存
+     */
+    @GetMapping("/unSave")
+    @ApiOperationSupport(order = 12)
+    @ApiOperation(value = "取消保存补偿协议", notes = "取消保存补偿协议")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "agreementId", value = "协议的id", required = true),
+    })
+    public R unSave(Long agreementId)  {
+        compensationInfoService.unSave(agreementId);
+        return R.success("取消成功");
+    }
+
 }

+ 5 - 6
blade-service/blade-land/src/main/java/org/springblade/land/controller/SettlementIntervalController.java

@@ -11,10 +11,7 @@ import org.springblade.core.tool.api.R;
 import org.springblade.land.dto.SettlementIntervalDTO;
 import org.springblade.land.entity.SettlementInterval;
 import org.springblade.land.service.ISettlementIntervalService;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import java.util.List;
 
@@ -44,13 +41,14 @@ public class SettlementIntervalController {
     public R<List<SettlementInterval>> getList(Long projectId,Integer type){
         return R.data(intervalService.list(new LambdaQueryWrapper<SettlementInterval>()
                 .eq(SettlementInterval::getProjectId,projectId)
-                .eq(SettlementInterval::getType,type)));
+                .eq(SettlementInterval::getType,type)
+                .orderByAsc(SettlementInterval::getStartDate)));
     }
 
     /**
      * 新增或修改周期
      */
-    @GetMapping("/addOrUpdate")
+    @PostMapping("/addOrUpdate")
     @ApiOperationSupport(order = 2)
     @ApiOperation(value = "新增或修改周期", notes = "传入周期集合")
     @ApiImplicitParams({
@@ -79,4 +77,5 @@ public class SettlementIntervalController {
     }
 
 
+
 }

+ 4 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/ClearingAgreementInfoMapper.java

@@ -17,8 +17,11 @@
 package org.springblade.land.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
+import org.springblade.core.mp.support.Query;
 import org.springblade.land.entity.ClearingAgreementInfo;
+import org.springblade.land.entity.CompensationInfo;
 import org.springblade.land.entity.SettlementInterval;
 
 
@@ -31,4 +34,5 @@ import org.springblade.land.entity.SettlementInterval;
 public interface ClearingAgreementInfoMapper extends BaseMapper<ClearingAgreementInfo> {
 
 
+    IPage<ClearingAgreementInfo> page(IPage<ClearingAgreementInfo> iPage,@Param("info") ClearingAgreementInfo info);
 }

+ 11 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/ClearingAgreementInfoMapper.xml

@@ -2,4 +2,15 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.springblade.land.mapper.ClearingAgreementInfoMapper">
 
+    <select id="page" resultType="org.springblade.land.entity.ClearingAgreementInfo">
+        select * from l_clearing_agreement_info
+        where project_id = #{info.projectId} and is_deleted = 0
+        <if test="info.type != null and info.type != ''">
+            and `type` = #{info.type}
+        </if>
+        and area_id in (select id from l_region_tree_info where is_deleted = 0 and (id = #{info.areaId} or ancestors like CONCAT(CONCAT('%', #{info.areaId}), '%')))
+        <if test="info.name != null and info.name != ''">
+            and name like CONCAT(CONCAT('%', #{info.name}), '%')
+        </if>
+    </select>
 </mapper>

+ 8 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/CompensationInfoMapper.java

@@ -69,4 +69,12 @@ public interface CompensationInfoMapper extends BaseMapper<CompensationInfo> {
     Integer getNumber(@Param("areaId") Long areaId);
 
     List<CompensationInfo> getAgreementList(@Param("info") CompensationInfo info);
+
+    void batchUpdateStatus(@Param("ids") List<Long> ids,@Param("status") int status);
+
+    void delete2(@Param("id") Long agreementId);
+
+    List<CompensationInfo> getAllAgreementList(@Param("projectId") Long projectId,@Param("areaId") Long areaId);
+
+    List<CompensationInfo> getQuote(@Param("info") CompensationInfo info,@Param("ids") List<Long> ids);
 }

+ 27 - 1
blade-service/blade-land/src/main/java/org/springblade/land/mapper/CompensationInfoMapper.xml

@@ -1,15 +1,27 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.springblade.land.mapper.CompensationInfoMapper">
+    <update id="batchUpdateStatus">
+        update l_compensation_info set is_quote = #{status}
+        where id in
+              <foreach collection="ids" item="id" open="(" close=")" separator=",">
+                #{id}
+              </foreach>
+    </update>
     <delete id="deleteOldData">
         delete from table_data_info
         where p_key_id = (select table_data_id from l_agreement_link_table where id = #{dataId} and is_deleted = 0)
     </delete>
+    <delete id="delete2">
+        delete from l_compensation_info
+        where id = #{id}
+    </delete>
 
 
     <select id="getTables" resultType="org.springblade.manager.entity.WbsTreePrivate">
         SELECT * FROM m_wbs_tree_private
         WHERE project_id = #{projectId} and wbs_type = 5 and `type` = 2 and node_type = #{nodeType}
+        order by sort
     </select>
     <select id="getWbsPrivateTable" resultType="org.springblade.manager.entity.WbsTreePrivate">
         select * from m_wbs_tree_private where p_key_id = #{pkeyId}
@@ -27,7 +39,7 @@
     </select>
     <select id="getTableElement" resultType="org.springblade.manager.entity.WbsFormElement">
         select * from m_wbs_form_element
-        where is_deleted = 0 and (dynamic_dict is not null or dynamic_dict > 0) and f_id in
+        where is_deleted = 0 and dynamic_dict is not null and dynamic_dict > 0 and f_id in
         <foreach collection="ids" item="id" open="(" close=")" separator=",">
             #{id}
         </foreach>
@@ -67,6 +79,20 @@
             and number like CONCAT(CONCAT('%', #{info.number}), '%')
         </if>
     </select>
+    <select id="getAllAgreementList" resultType="org.springblade.land.entity.CompensationInfo">
+        select * from l_compensation_info
+        where project_id = #{projectId} and is_deleted = 0
+          and area_id in (select id from l_region_tree_info where is_deleted = 0 and (id = #{areaId} or ancestors like CONCAT(CONCAT('%', #{areaId}), '%')))
+    </select>
+    <select id="getQuote" resultType="org.springblade.land.entity.CompensationInfo">
+        select id,number,name,all_money,is_quote from l_compensation_info
+        where project_id = #{info.projectId} and is_deleted = 0 and `type` = #{info.type}
+          and area_id in (select id from l_region_tree_info where is_deleted = 0 and (id = #{info.areaId} or ancestors like CONCAT(CONCAT('%', #{info.areaId}), '%')))
+          and id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+    </select>
 
 
 </mapper>

+ 20 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/IClearingAgreementInfoService.java

@@ -17,10 +17,17 @@
 package org.springblade.land.service;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.springblade.core.mp.base.BaseService;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
 import org.springblade.land.dto.SettlementIntervalDTO;
+import org.springblade.land.entity.AgreementLinkTable;
 import org.springblade.land.entity.ClearingAgreementInfo;
 import org.springblade.land.entity.SettlementInterval;
+import org.springblade.land.vo.AreaPictureVO;
+
+import java.util.List;
 
 
 /**
@@ -32,4 +39,17 @@ import org.springblade.land.entity.SettlementInterval;
 public interface IClearingAgreementInfoService extends BaseService<ClearingAgreementInfo> {
 
 
+    void add(ClearingAgreementInfo info) throws Exception;
+
+    IPage<ClearingAgreementInfo> page(Query query, ClearingAgreementInfo info);
+
+    List<AgreementLinkTable> getFileList(Long id);
+
+    R statArea(Long projectId, Long areaId);
+
+    R<List<AreaPictureVO>> statAreaPicture(Long projectId, Long areaId);
+
+    R<List<AreaPictureVO>> statMoney(Long projectId, Long areaId);
+
+    void remove(String ids);
 }

+ 16 - 1
blade-service/blade-land/src/main/java/org/springblade/land/service/ICompensationInfoService.java

@@ -69,5 +69,20 @@ public interface ICompensationInfoService extends BaseService<CompensationInfo>
 
     void remove(List<Long> ids);
 
-    List<CompensationInfo> getAgreementList(CompensationInfo info);
+    //获取没有引用的
+    List<CompensationInfo> getAgreementList(CompensationInfo info,String agreementIds);
+
+    //获取项目节点下所有的协议
+    List<CompensationInfo> getAllAgreementList(Long projectId,Long areaId);
+
+    //批量修改引用状态
+    void batchUpdateStatus(List<Long> ids,int status);
+
+    //合并PDF
+    void mergePdfs(Long agreementId) throws Exception;
+
+    //获取单个PDF
+    R getBussPdfInfo(Long id) throws Exception;
+
+    void unSave(Long agreementId);
 }

+ 316 - 2
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/ClearingAgreementInfoServiceImpl.java

@@ -1,24 +1,338 @@
 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;
+import org.apache.commons.lang.StringUtils;
+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.ClearingAgreementInfo;
-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;
 import java.util.List;
+import java.util.stream.Collectors;
 
 @Service
 @AllArgsConstructor
 public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAgreementInfoMapper, ClearingAgreementInfo> implements IClearingAgreementInfoService {
 
+    private final ICompensationInfoService compensationInfoService;
+    private final IAgreementLinkTableService linkTableService;
+    private final NewIOSSClient newIOSSClient;
 
+    /**
+     * 新增或修改结算协议
+     * @param info
+     */
+    @Override
+    @Transactional
+    public void add(ClearingAgreementInfo info) throws Exception {
+        //修改选择的补偿协议的引用状态
+        String agreementIds = info.getAgreementIds();
+        if (StringUtils.isBlank(agreementIds)){
+            throw new ServiceException("请选择补偿协议");
+        }
+        //是新增还是修改
+        Boolean isAdd = false;
+        List<Long> ids = Func.toLongList(agreementIds);
+        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);
+        }else {
+            linkTables = linkTableService.getByAgreementId(info.getId());
+            //修改则先还原之前补偿协议的状态
+            ClearingAgreementInfo agreementInfo = this.getById(info.getId());
+            compensationInfoService.batchUpdateStatus(Func.toLongList(agreementInfo.getAgreementIds()),0);
+        }
+        //批量修改选中的状态
+        compensationInfoService.batchUpdateStatus(ids,1);
+        //获取所有选中的补偿协议
+        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);
+        }
+        //循环结算协议的统计字段,把补偿协议统计出来的字段设置到结算协议
+        //生成封面
+        //生成补偿结算表
+        //生成补偿费发放统计表
+        //生成补偿费明细表
+        //生成补偿资金数量分配表
+        //生成面积统计明细表
+        //合并PDF
+//        try {
+            this.mergePdfs(info.getId());
+//        }catch (Exception e){
+//            throw new ServiceException("合并PDF失败");
+//        }
+    }
+
+    /**
+     * 分页查询结算周期
+     * @param query
+     * @param info
+     * @return
+     */
+    @Override
+    public IPage<ClearingAgreementInfo> page(Query query, ClearingAgreementInfo info) {
+        IPage<ClearingAgreementInfo> iPage = new Page<>(query.getCurrent(),query.getSize());
+        return  baseMapper.page(iPage,info);
+    }
+
+    /**
+     * 根据结算id查询下面的表单
+     */
+    @Override
+    public List<AgreementLinkTable> getFileList(Long id) {
+        return linkTableService.getByAgreementId(id);
+    }
+
+    /**
+     * 结算统计面积
+     * @param projectId
+     * @param areaId
+     * @return
+     */
+    @Override
+    public R statArea(Long projectId, Long areaId) {
+        List<String> list = new ArrayList<>();
+        //获取当前项目下,当前节点下所有补偿协议
+        List<CompensationInfo> infoList = compensationInfoService.getAllAgreementList(projectId, areaId);
+        if (infoList == null || infoList.size() == 0){
+            return R.data(list);
+        }
+        //已签协议面积
+        BigDecimal all = infoList.stream().map(l -> l.getAreaAll()).reduce(BigDecimal.valueOf(0), BigDecimal::add);
+        list.add(all+"");
+        //已签协议比例
+        list.add("0%");
+        //已结算面积
+        BigDecimal endAll = infoList.stream().filter(l->l.getIsQuote().equals(1)).map(l -> l.getAreaAll()).reduce(BigDecimal.valueOf(0), BigDecimal::add);
+        list.add(endAll+"");
+        //已结算比例
+        list.add("0%");
+        return R.data(list);
+    }
+
+    /**
+     * 结算统计面积柱状图
+     * @param projectId
+     * @param areaId
+     * @return
+     */
+    @Override
+    public R<List<AreaPictureVO>> statAreaPicture(Long projectId, Long areaId) {
+        List<AreaPictureVO> vo = new ArrayList<>();
+        //获取当前项目下,当前节点下所有补偿协议
+        List<CompensationInfo> infoList = compensationInfoService.getAllAgreementList(projectId, areaId);
+        if (infoList == null || infoList.size() == 0){
+            return R.data(vo);
+        }
+        //已签面积
+        AreaPictureVO vo1 = new AreaPictureVO();
+        vo1.setName("已签面积");
+        List<BigDecimal> ll = new ArrayList<>();
+        BigDecimal a1 = infoList.stream().map(l -> l.getAreaA()).reduce(BigDecimal.valueOf(0), BigDecimal::add);
+        BigDecimal a2 = infoList.stream().map(l -> l.getAreaB()).reduce(BigDecimal.valueOf(0), BigDecimal::add);
+        BigDecimal a3 = infoList.stream().map(l -> l.getAreaC()).reduce(BigDecimal.valueOf(0), BigDecimal::add);
+        ll.add(a1);
+        ll.add(a2);
+        ll.add(a3);
+        vo1.setValue(ll);
+        //设计面积
+        AreaPictureVO vo2 = new AreaPictureVO();
+        vo2.setName("设计面积");
+        List<BigDecimal> lb = new ArrayList<>();
+        lb.add(new BigDecimal(0));
+        lb.add(new BigDecimal(0));
+        lb.add(new BigDecimal(0));
+        vo2.setValue(lb);
+        vo.add(vo1);
+        vo.add(vo2);
+
+        return R.data(vo);
+    }
+
+    /**
+     * 结算统计-金额进度
+     * @param projectId
+     * @param areaId
+     * @return
+     */
+    @Override
+    public R<List<AreaPictureVO>> statMoney(Long projectId, Long areaId) {
+        List<AreaPictureVO> vo = new ArrayList<>();
+        //获取当前项目下,当前节点下所有补偿协议
+        List<CompensationInfo> infoList = compensationInfoService.getAllAgreementList(projectId, areaId);
+        if (infoList == null || infoList.size() == 0){
+            return R.data(vo);
+        }
+        BigDecimal zero = new BigDecimal(0);
+        //补偿
+        List<CompensationInfo> l1 = infoList.stream().filter(l -> l.getIsQuote().equals(0)).collect(Collectors.toList());
+        //结算
+        List<CompensationInfo> l2 = infoList.stream().filter(l -> l.getIsQuote().equals(1)).collect(Collectors.toList());
+        //实际补助总金额
+        AreaPictureVO vo1 = new AreaPictureVO();
+        vo1.setName("实际补助总金额");
+        List<BigDecimal> ll = new ArrayList<>();
+        BigDecimal a1 = infoList.stream().filter(l->l.getType().equals(1)).map(l -> l.getAllMoney()).reduce(BigDecimal.valueOf(0), BigDecimal::add);
+        ll.add(a1);
+        ll.add(zero);
+        ll.add(zero);
+        ll.add(zero);
+        ll.add(zero);
+        vo1.setValue(ll);
+        //设计补助总金额
+        AreaPictureVO vo2 = new AreaPictureVO();
+        vo2.setName("设计补助总金额");
+        List<BigDecimal> lb = new ArrayList<>();
+        lb.add(zero);
+        lb.add(zero);
+        lb.add(zero);
+        lb.add(zero);
+        lb.add(zero);
+        vo2.setValue(lb);
+        //已结算总金额
+        AreaPictureVO vo3 = new AreaPictureVO();
+        vo3.setName("已结算总金额");
+        List<BigDecimal> lbl = new ArrayList<>();
+        BigDecimal c1 = l2.stream().filter(l->l.getType().equals(1)).map(l -> l.getAllMoney()).reduce(BigDecimal.valueOf(0), BigDecimal::add);
+        lbl.add(c1);
+        lbl.add(zero);
+        lbl.add(zero);
+        lbl.add(zero);
+        lbl.add(zero);
+        vo3.setValue(lbl);
+        //保存
+        vo.add(vo1);
+        vo.add(vo2);
+        vo.add(vo3);
+        return R.data(vo);
+    }
+
+    /**
+     * 批量删除
+     * @param ids
+     */
+    @Override
+    @Transactional
+    public void remove(String ids) {
+        List<Long> id = Func.toLongList(ids);
+        //先删除表单数据
+        linkTableService.deleteTableData(id);
+        //再删除中间表数据
+        linkTableService.deleteByAgreementIds(id);
+        //释放所有补偿协议的引用
+        List<Long> li = new ArrayList<>();
+        List<ClearingAgreementInfo> list = this.listByIds(id);
+        for (ClearingAgreementInfo info : list) {
+            li.addAll( Func.toLongList(info.getAgreementIds()));
+        }
+        compensationInfoService.batchUpdateStatus(li,0);
+        //最后删除结算协议
+        this.deleteLogic(id);
+
+    }
+
+    //合并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);
+        }
+
+    }
 }

+ 159 - 85
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/CompensationInfoServiceImpl.java

@@ -79,7 +79,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
 
 
     /**
-     * 获取补偿表单
+     * 获取表单
      * @param projectId
      * @param
      * @return
@@ -96,11 +96,11 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
     public R getExcelHtmlByBuss(Long id) throws Exception {
         //获取表单信息
         AgreementLinkTable linkTable = linkTableService.getById(id);
-//        fileUrl = "C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html";
         if (StringUtils.isBlank(linkTable.getHtmlUrl())){
             return R.fail("没有获取到表单!");
         }
         InputStream fileInputStream = FileUtils.getInputStreamByUrl(linkTable.getHtmlUrl());
+//        InputStream fileInputStream = FileUtils.getInputStreamByUrl("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html");
 
         String htmlString = IoUtil.readToString(fileInputStream);
         htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
@@ -225,13 +225,13 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         Long id = tableInfo1.getLong("agreementId");
         Long areaId = tableInfo1.getLong("areaId");
         //中间表tableId与dataId的映射
-        Map<Long,Long> map = new HashMap<>();
+        Map<Long,Long> linkMap = new HashMap<>();
         //获取表单id与数据id的映射
         List<AgreementLinkTable> linkTables = linkTableService.getByAgreementId(id);
         if (linkTables == null || linkTables.size() == 0){
             throw new ServiceException("暂无表单");
         }
-        linkTables.stream().forEach(l->map.put(l.getTableId(),l.getTableDataId()));
+        linkTables.stream().forEach(l->linkMap.put(l.getTableDataId(),l.getTableId()));
 
         for (int i=0; i<dataArray.size();i++) {
             JSONObject jsonObject = dataArray.getJSONObject(i);
@@ -247,65 +247,135 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         BigDecimal b2 = new BigDecimal(0);
         //地面附着物
         BigDecimal b3 = new BigDecimal(0);
+        //金额总计
+        BigDecimal b4 = new BigDecimal(0);
+        //农用地面积
+        BigDecimal a1 = new BigDecimal(0);
+        //建设用地面积
+        BigDecimal a2 = new BigDecimal(0);
+        //未利用地面积
+        BigDecimal a3 = new BigDecimal(0);
+        //总面积
+        BigDecimal a4 = new BigDecimal(0);
         //户主姓名(协议名称)
         StringBuilder str = new StringBuilder("");
-        //计算统计值
-        List<WbsFormElement> elementList = baseMapper.getTableElement(linkTables.stream().map(l -> l.getTableId()).collect(Collectors.toList()));
         CompensationInfo info = new CompensationInfo();
         info.setId(id);
-        //获取当前节点名称
-        RegionTreeInfo treeInfo = treeInfoService.getById(areaId);
-        info.setNumber(treeInfo.getAreaName()+"默认编号");
+        //查看当前表单是否配置统计值
+        List<WbsFormElement> elementList = baseMapper.getTableElement(linkTables.stream().map(l -> l.getTableId()).collect(Collectors.toList()));
         if (elementList == null || elementList.size() == 0){
             info.setName("未找到用户名称");
             info.setLandMoney(b1);
             info.setCropsMoney(b2);
             info.setAllMoney(b3);
-
         }else {
-            //获取所有表单填报值
-            List<TableDataVO> list = baseMapper.getBussDataInfoByDataIds(linkTables.stream().map(l -> l.getTableDataId()).collect(Collectors.toList()));
-            if (list != null && list.size() > 0) {
-                //按照表单分组
-                Map<Long, List<TableDataVO>> listMap = list.stream()
+            //有配置统计值,获取所有表单填报值
+            List<TableDataVO> dataList = baseMapper.getBussDataInfoByDataIds(linkTables.stream().map(l -> l.getTableDataId()).collect(Collectors.toList()));
+            //表单有填报值
+            if (dataList != null && dataList.size() > 0) {
+                //按照数据id分组
+                Map<Long, List<TableDataVO>> dataMap = dataList.stream()
                         .collect(Collectors.groupingBy(TableDataVO::getPKeyId));
-                for (WbsFormElement element : elementList) {
-                    //获取统计字段
-                    String fId = element.getFId();
-                    String eKey = element.getEKey();
-                    Integer dict = element.getDynamicDict();
-                    Long dataId = map.get(Long.parseLong(fId));
-                    if (listMap.get(dataId) != null && listMap.get(dataId).size() > 0){
-                        //当前表单有保存数据,统计值
-                        List<TableDataVO> dataVOS = listMap.get(dataId);
-                        try {
-                            for (TableDataVO dataVO : dataVOS) {
-                                if (dataVO.getTabKey().contains(eKey)) {
-                                    if (dict.equals(1)){
-                                        b1 = b1.add(new BigDecimal(dataVO.getTabVal()));
-                                    }else if (dict.equals(2)){
-                                        b2 = b2.add(new BigDecimal(dataVO.getTabVal()));
-                                    }else if (dict.equals(3)){
-                                        b3 = b3.add(new BigDecimal(dataVO.getTabVal()));
-                                    }else if (dict.equals(4)){
-                                        str.append(dataVO.getTabVal()+"、");
-                                    }
+                //统计字段按照表单分组
+                Map<String, List<WbsFormElement>> elementMap = elementList.stream()
+                        .collect(Collectors.groupingBy(WbsFormElement::getFId));
+                //循环有数据的表单
+                for (Long dataId : dataMap.keySet()) {
+                    //通过数据id获取表单,然后通过表单获取配置
+                    List<WbsFormElement> elements = elementMap.get(linkMap.get(dataId)+"");
+                    //如果没有统计字段,则跳过
+                    if (elements == null || elements.size() == 0){
+                        continue;
+                    }
+                    //有统计字段,取出当前表的所有数据
+                    List<TableDataVO> dataS = dataMap.get(dataId);
+                    //循环统计字段
+                    for (WbsFormElement element : elements) {
+                        Integer dict = element.getDynamicDict();
+                        if (dict.equals(7)){
+                            continue;
+                        }
+                        //获取当前统计字段所有填写的值
+                        List<TableDataVO> vos = dataS.stream().filter(l -> l.getTabKey().contains(element.getEKey())).collect(Collectors.toList());
+                        //如果当前统计值没填写数据则直接跳过
+                        if (vos == null || vos.size() == 0){
+                            continue;
+                        }
+                        //单独计算面积
+                        if (dict.equals(6)) {
+                            //统计面积,去找到当前行的地类dict为7
+                            List<WbsFormElement> collect = elements.stream().filter(l -> l.getDynamicDict().equals(7)).collect(Collectors.toList());
+                            //获取dict为7的key,如果key不存在则提示未配置土地性质
+                            if (collect == null || collect.size() == 0){
+                                throw new ServiceException("未配置地类");
+                            }
+                            //获取土地性质的数据,如果不存在数据,或者长度和面积不相等,则提示地类和面积必须同时填写
+                            List<TableDataVO> typeList = dataS.stream().filter(l -> l.getTabKey().contains(collect.get(0).getEKey())).collect(Collectors.toList());
+                            if (typeList == null || typeList.size() == 0 || typeList.size() != vos.size()){
+                                throw new ServiceException("地类和面积必须同时填写");
+                            }
+                            Map<String,String> map = new HashMap<>();
+                            //把土地性质转换为map,位置为key
+                            for (TableDataVO t : typeList) {
+                                String[] s1 = t.getTabKey().split("__");
+                                String[] s2 = s1[1].split("_");
+                                map.put(s2[0],t.getTabVal());
+                            }
+                            for (TableDataVO vo : vos) {
+                                String[] s1 = vo.getTabKey().split("__");
+                                String[] s2 = s1[1].split("_");
+                                //获取到土地性质
+                                String type = map.get(s2[0]);
+                                if ("农用地".equals(type)){
+                                    a1 = a1.add(new BigDecimal(vo.getTabVal()));
+                                }else if ("建设用地".equals(type)){
+                                    a2 = a2.add(new BigDecimal(vo.getTabVal()));
+                                }else if ("未利用地".equals(type)){
+                                    a3 = a3.add(new BigDecimal(vo.getTabVal()));
+                                }else {
+                                    throw new ServiceException("土地性质为:"+type);
+                                }
+                                a4 = a4.add(new BigDecimal(vo.getTabVal()));
+                            }
+                        }else {
+                            //当前统计值
+                            try {
+                                if (dict.equals(1)) {
+                                    b1 = b1.add(vos.stream().map(l -> new BigDecimal(l.getTabVal())).reduce(BigDecimal.valueOf(0), BigDecimal::add));
+                                } else if (dict.equals(2)) {
+                                    b2 = b2.add(vos.stream().map(l -> new BigDecimal(l.getTabVal())).reduce(BigDecimal.valueOf(0), BigDecimal::add));
+                                } else if (dict.equals(3)) {
+                                    b3 = b3.add(vos.stream().map(l -> new BigDecimal(l.getTabVal())).reduce(BigDecimal.valueOf(0), BigDecimal::add));
+                                } else if (dict.equals(4)) {
+                                    str.append(StringUtils.join(vos.stream().map(l -> l.getTabVal()).collect(Collectors.toList()), "、") + "、");
+                                } else if (dict.equals(5)) {
+                                    b4 = b4.add(vos.stream().map(l -> new BigDecimal(l.getTabVal())).reduce(BigDecimal.valueOf(0), BigDecimal::add));
                                 }
+                            } catch (Exception e) {
+                                throw new ServiceException("金额字段不能包含其他字符,请重新填写");
                             }
-                        }catch (Exception e){
-                            throw new ServiceException("金额字段不能包含其他字符,请重新填写");
                         }
                     }
                 }
+                //设置名称
                 String names = str.toString();
                 if (StringUtils.isNotBlank(names)){
                     info.setName(names.substring(0, names.length() - 1));
                 }else {
                     info.setName("未找到用户名称");
                 }
+                //设置金额
                 info.setLandMoney(b1);
                 info.setCropsMoney(b2.add(b3));
-                info.setAllMoney(info.getLandMoney().add(info.getCropsMoney()));
+                if (!info.getLandMoney().add(info.getCropsMoney()).equals(b4)){
+                    throw new ServiceException("补偿金额合计不对,请校验土地、青苗、等金额之和,是否等于补偿金额合计");
+                }
+                info.setAllMoney(b4);
+                //设置面积
+                info.setAreaA(a1);
+                info.setAreaB(a2);
+                info.setAreaC(a3);
+                info.setAreaAll(a4);
             }
         }
         //保存协议信息
@@ -349,48 +419,6 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         return R.data(info.getMergePdfUrl());
     }
 
-//    @Override
-//    @Transactional
-//    public R addCopeTab(TableCopyVO vo) {
-//        //新增复制
-//        Long agreeId = SnowFlakeUtil.getId();
-//        //先新增协议,再复制
-//        List<WbsTreePrivate> tables = baseMapper.getTables(vo.getProjectId(), vo.getNodeType());
-//        Map<Long,Long> map = new HashMap<>();
-//        List<AgreementLinkTable> linkTables = tables.stream().map(l -> {
-//            AgreementLinkTable table = new AgreementLinkTable();
-//            table.setTableId(Long.parseLong(l.getInitTableId()));
-//            table.setProjectId(vo.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());
-//            map.put(Long.parseLong(l.getInitTableId()),table.getId());
-//            return table;
-//        }).collect(Collectors.toList());
-//        linkTableService.saveBatch(linkTables);
-//        vo.setLinkId(map.get(vo.getTableId()));
-//        this.updateCopeTab(vo);
-//        //保存协议
-//        CompensationInfo info = new CompensationInfo();
-//        info.setId(agreeId);
-//        info.setName("默认名称");
-//        //获取当前节点名称
-//        RegionTreeInfo treeInfo = treeInfoService.getById(vo.getAreaId());
-//        info.setNumber(treeInfo.getAreaName()+"默认编号");
-//        info.setAreaId(vo.getAreaId());
-//        info.setProjectId(vo.getProjectId());
-//        info.setType(vo.getNodeType());
-//        info.setLandMoney(new BigDecimal(0));
-//        info.setCropsMoney(new BigDecimal(0));
-//        info.setAllMoney(new BigDecimal(0));
-//        this.save(info);
-//        return R.data(200,agreeId,"复制成功");
-//    }
 
     /**
      * 修改复制表单
@@ -480,11 +508,56 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
      * @return
      */
     @Override
-    public List<CompensationInfo> getAgreementList(CompensationInfo info) {
-        List<CompensationInfo> list = baseMapper.getAgreementList(info);
+    public List<CompensationInfo> getAgreementList(CompensationInfo info,String agreementIds) {
+        List<CompensationInfo> list = new ArrayList<>();
+        if (StringUtils.isNotBlank(agreementIds)){
+            List<Long> ids = Func.toLongList(agreementIds);
+            //获取已经引用的补偿协议,并且要在当前区域中
+            List<CompensationInfo> quote = baseMapper.getQuote(info, ids);
+            list.addAll(quote);
+        }
+        List<CompensationInfo> l = baseMapper.getAgreementList(info);
+        if (l != null && l.size() > 0){
+            list.addAll(l);
+        }
         return list;
     }
 
+    /**
+     * 获取当前项目节点下所有补偿协议
+     * @param projectId
+     * @param areaId
+     * @return
+     */
+    @Override
+    public List<CompensationInfo> getAllAgreementList(Long projectId, Long areaId) {
+        List<CompensationInfo> list = baseMapper.getAllAgreementList(projectId, areaId);
+        return list;
+    }
+
+    /**
+     * 批量修改引用状态
+     * @param ids
+     * @param status
+     */
+    @Override
+    public void batchUpdateStatus(List<Long> ids, int status) {
+        baseMapper.batchUpdateStatus(ids,status);
+    }
+
+    @Override
+    public void unSave(Long agreementId) {
+        CompensationInfo info = this.getById(agreementId);
+        //如果从未保存过,直接删除
+        if (StringUtils.isBlank(info.getMergePdfUrl())){
+            List<Long> list = Arrays.asList(agreementId);
+            //删除中间表数据
+            linkTableService.deleteByAgreementIds(list);
+            //证明从未保存过直接删除补偿协议
+            baseMapper.delete2(agreementId);
+        }
+    }
+
     //获取当前节点的补偿编号
     private String getNumber(Long areaId) {
         Integer number = baseMapper.getNumber(areaId);
@@ -835,7 +908,8 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         ProjectInfo projectInfo = baseMapper.getProjectInfo(linkTable.getProjectId());
 
         int all = 0;
-        for (int i = 0; i < 10; i++) {
+       int num= sheet.getNumMergedRegions()>10?10:sheet.getNumMergedRegions();
+        for (int i = 0; i < num; i++) {
             CellRangeAddress mergedCell = sheet.getMergedRegion(i);
             int xx = mergedCell.getNumberOfCells();
             if (xx >= all) {
@@ -843,7 +917,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
             }
         }
 
-        for (int i = 0; i < 10; i++) {
+        for (int i = 0; i < num; i++) {
             CellRangeAddress mergedCell = sheet.getMergedRegion(i);
             int xx = mergedCell.getNumberOfCells() + 2;
             if (xx >= all) {

+ 20 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/WbsTreeContractController.java

@@ -30,6 +30,7 @@ import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.manager.dto.WbsTreeContractDTO2;
 import org.springblade.manager.entity.ContractInfo;
 import org.springblade.manager.entity.WbsTreeContract;
+import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.manager.feign.ContractClient;
 import org.springblade.manager.service.IWbsTreeContractService;
 import org.springblade.manager.service.impl.WbsTreeContractServiceImpl;
@@ -38,6 +39,7 @@ import org.springblade.manager.vo.*;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.StringRedisTemplate;
+import org.springframework.jdbc.core.BeanPropertyRowMapper;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -325,15 +327,29 @@ public class WbsTreeContractController extends BladeController {
     @ApiOperation(value = "客户端-下载元素表对应的excel模板", notes = "传入表的pKeyId")
     public void downloadExcel(@RequestParam String pKeyId, HttpServletResponse response) {
         com.spire.xls.Workbook workbook = null;
+        String htmlUrl = "";
+        String fileName = "";
         try {
             WbsTreeContract tab = iWbsTreeContractService.getBaseMapper().selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getPKeyId, pKeyId));
-            if (ObjectUtil.isEmpty(tab) || ObjectUtil.isEmpty(tab.getHtmlUrl())) {
-                throw new ServiceException("未获取到对应的表信息");
+            if (ObjectUtil.isEmpty(tab)) {
+                //如果合同段没查询到,那么有可能是试验的数据,试验从项目获取树的表信息
+                WbsTreePrivate treePrivateTab = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id = " + pKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
+                if (treePrivateTab != null && treePrivateTab.getHtmlUrl() != null) {
+                    htmlUrl = treePrivateTab.getHtmlUrl();
+                    fileName = ObjectUtil.isNotEmpty(treePrivateTab.getFullName()) ? treePrivateTab.getFullName() : treePrivateTab.getNodeName();
+                }
+            } else {
+                htmlUrl = tab.getHtmlUrl();
+                fileName = ObjectUtil.isNotEmpty(tab.getFullName()) ? tab.getFullName() : tab.getNodeName();
+            }
+
+            if (ObjectUtil.isEmpty(htmlUrl)) {
+                throw new ServiceException("未获取到对应的表的html信息");
             }
 
             //将html转换为excel
             ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
-            InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(tab.getHtmlUrl());
+            InputStream inputStreamByUrl = FileUtils.getInputStreamByUrl(htmlUrl);
             workbook = new com.spire.xls.Workbook();
             workbook.loadFromHtml(inputStreamByUrl);
             workbook.saveToStream(byteArrayOutputStream, FileFormat.Version2007);
@@ -394,7 +410,7 @@ public class WbsTreeContractController extends BladeController {
                 try (ServletOutputStream outputStream = response.getOutputStream();
                      ByteArrayOutputStream byteArrayOutputStreamResult = new ByteArrayOutputStream()) {
                     //设置响应头
-                    response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(ObjectUtil.isNotEmpty(tab.getFullName()) ? tab.getFullName() : tab.getNodeName(), "UTF-8") + ".xlsx");
+                    response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx");
                     response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
                     poiWorkbook.write(byteArrayOutputStreamResult);
                     byte[] excelBytesResult = byteArrayOutputStreamResult.toByteArray();

+ 1 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeContractServiceImpl.java

@@ -1178,6 +1178,7 @@ public class ArchiveTreeContractServiceImpl extends BaseServiceImpl<ArchiveTreeC
 			periodNode  = new ArchiveTreeContract();
 			periodNode.setProjectId(rootNode.getProjectId());
 			periodNode.setContractId(rootNode.getContractId());
+			periodNode.setTreeCode(rootNode.getContractId().toString());
 			periodNode.setIsDeleted(0);
 			periodNode.setIsInterfaceNode(1);
 			periodNode.setInterfaceType(2);

+ 17 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/WbsTreeContractServiceImpl.java

@@ -1909,20 +1909,33 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
     public String getHtmlString(String pkeyId) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
+
+        String htmlUrl = "";
+
         WbsTreeContract wbsTreeContract = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda()
                 .select(WbsTreeContract::getHtmlUrl)
                 .eq(WbsTreeContract::getPKeyId, pkeyId));
-        if (wbsTreeContract == null || wbsTreeContract.getHtmlUrl() == null) {
+
+        if (ObjectUtil.isEmpty(wbsTreeContract)) {
+            //如果合同段没查询到,那么有可能是试验的数据,试验从项目获取树的表信息
+            WbsTreePrivate treePrivateTab = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id = " + pkeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
+            if (treePrivateTab != null && treePrivateTab.getHtmlUrl() != null) {
+                htmlUrl = treePrivateTab.getHtmlUrl();
+            }
+        } else {
+            htmlUrl = wbsTreeContract.getHtmlUrl();
+        }
+
+        if (ObjectUtil.isEmpty(htmlUrl)) {
             return "";
         }
 
-        String fileUrl = wbsTreeContract.getHtmlUrl();
-        File file1 = ResourceUtil.getFile(fileUrl);
+        File file1 = ResourceUtil.getFile(htmlUrl);
         InputStream fileInputStream;
         if (file1.exists()) {
             fileInputStream = new FileInputStream(file1);
         } else {
-            String path = sys_file_net_url + fileUrl.replaceAll("//", "/").replaceAll(file_path, "");
+            String path = sys_file_net_url + htmlUrl.replaceAll("//", "/").replaceAll(file_path, "");
             fileInputStream = CommonUtil.getOSSInputStream(path);
         }