瀏覽代碼

Merge remote-tracking branch 'origin/master'

liuyc 1 年之前
父節點
當前提交
bcd0283b5a
共有 14 個文件被更改,包括 667 次插入49 次删除
  1. 4 1
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/ClearingAgreementInfo.java
  2. 13 1
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/CompensationInfo.java
  3. 17 0
      blade-service-api/blade-land-api/src/main/java/org/springblade/land/vo/AreaPictureVO.java
  4. 113 0
      blade-service/blade-land/src/main/java/org/springblade/land/controller/ClearingAgreementInfoController.java
  5. 14 0
      blade-service/blade-land/src/main/java/org/springblade/land/controller/CompensationInfoController.java
  6. 2 5
      blade-service/blade-land/src/main/java/org/springblade/land/controller/SettlementIntervalController.java
  7. 4 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/ClearingAgreementInfoMapper.java
  8. 11 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/ClearingAgreementInfoMapper.xml
  9. 6 0
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/CompensationInfoMapper.java
  10. 18 1
      blade-service/blade-land/src/main/java/org/springblade/land/mapper/CompensationInfoMapper.xml
  11. 18 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/IClearingAgreementInfoService.java
  12. 15 0
      blade-service/blade-land/src/main/java/org/springblade/land/service/ICompensationInfoService.java
  13. 288 2
      blade-service/blade-land/src/main/java/org/springblade/land/service/impl/ClearingAgreementInfoServiceImpl.java
  14. 144 39
      blade-service/blade-land/src/main/java/org/springblade/land/service/impl/CompensationInfoServiceImpl.java

+ 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;
+}

+ 113 - 0
blade-service/blade-land/src/main/java/org/springblade/land/controller/ClearingAgreementInfoController.java

@@ -1,10 +1,25 @@
 package org.springblade.land.controller;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
+import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
+import org.springblade.core.mp.support.Query;
+import org.springblade.core.tool.api.R;
+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 +31,102 @@ 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) {
+        infoService.add(info);
+        return R.success("新增成功");
+    }
+
+    /**
+     * 分页
+     */
+    @GetMapping("/page")
+    @ApiOperationSupport(order = 7)
+    @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 = 7)
+    @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("/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);
+    }
+
+
 }

+ 14 - 0
blade-service/blade-land/src/main/java/org/springblade/land/controller/CompensationInfoController.java

@@ -206,4 +206,18 @@ public class CompensationInfoController extends BladeController {
         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("取消成功");
+    }
+
 }

+ 2 - 5
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;
 
@@ -50,7 +47,7 @@ public class SettlementIntervalController {
     /**
      * 新增或修改周期
      */
-    @GetMapping("/addOrUpdate")
+    @PostMapping("/addOrUpdate")
     @ApiOperationSupport(order = 2)
     @ApiOperation(value = "新增或修改周期", notes = "传入周期集合")
     @ApiImplicitParams({

+ 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>

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

@@ -69,4 +69,10 @@ 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);
 }

+ 18 - 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,11 @@
             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>
 
 
 </mapper>

+ 18 - 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,15 @@ import org.springblade.land.entity.SettlementInterval;
 public interface IClearingAgreementInfoService extends BaseService<ClearingAgreementInfo> {
 
 
+    void add(ClearingAgreementInfo info);
+
+    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);
 }

+ 15 - 0
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> 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);
 }

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

@@ -1,24 +1,310 @@
 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) {
+        //修改选择的补偿协议的引用状态
+        String agreementIds = info.getAgreementIds();
+        if (StringUtils.isBlank(agreementIds)){
+            throw new ServiceException("请选择补偿协议");
+        }
+        //是新增还是修改
+        Boolean isAdd = false;
+        List<Long> ids = Func.toLongList(agreementIds);
+        compensationInfoService.batchUpdateStatus(ids,1);
+        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());
+        }
+        //获取所有选中的补偿协议
+        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);
+    }
+
+    //合并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);
+        }
+
+    }
 }

+ 144 - 39
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);
             }
         }
         //保存协议信息
@@ -485,6 +555,41 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         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);