qianxb hai 1 ano
pai
achega
41383e4a28

+ 10 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/vo/TableDataVO.java

@@ -22,4 +22,14 @@ public class TableDataVO {
 
     @ApiModelProperty(value = "表单字段值")
     private String tabVal;
+
+    @ApiModelProperty(value = "配置key")
+    private String dictKey;
+
+    @ApiModelProperty(value = "行")
+    private Integer dictRow;
+
+    @ApiModelProperty(value = "字典值")
+    private Integer dictValue;
+
 }

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

@@ -20,9 +20,13 @@ 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.AgreementLinkTable;
 import org.springblade.land.entity.ClearingAgreementInfo;
 import org.springblade.land.entity.CompensationInfo;
 import org.springblade.land.entity.SettlementInterval;
+import org.springblade.manager.entity.WbsFormElement;
+
+import java.util.List;
 
 
 /**
@@ -35,4 +39,8 @@ public interface ClearingAgreementInfoMapper extends BaseMapper<ClearingAgreemen
 
 
     IPage<ClearingAgreementInfo> page(IPage<ClearingAgreementInfo> iPage,@Param("info") ClearingAgreementInfo info);
+
+    List<WbsFormElement> getTableElement(@Param("tableId") Long tableId);
+
+    List<AgreementLinkTable> getAllAssignTable(@Param("ids") List<Long> ids, @Param("tableName") String tableName);
 }

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

@@ -13,4 +13,15 @@
             and name like CONCAT(CONCAT('%', #{info.name}), '%')
         </if>
     </select>
+    <select id="getTableElement" resultType="org.springblade.manager.entity.WbsFormElement">
+        select * from m_wbs_form_element
+        where is_deleted = 0 and f_id = #{tableId} and dynamic_dict > 0
+    </select>
+    <select id="getAllAssignTable" resultType="org.springblade.land.entity.AgreementLinkTable">
+        select * from l_agreement_link_table where  is_deleted = 0 and agreement_id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+        and table_name like CONCAT(CONCAT('%', #{tableName}), '%')
+    </select>
 </mapper>

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

@@ -77,4 +77,8 @@ public interface CompensationInfoMapper extends BaseMapper<CompensationInfo> {
     List<CompensationInfo> getAllAgreementList(@Param("projectId") Long projectId,@Param("areaId") Long areaId);
 
     List<CompensationInfo> getQuote(@Param("info") CompensationInfo info,@Param("ids") List<Long> ids);
+
+    List<Long> getPdfIsNull(@Param("projectId") Long projectId);
+
+    void deleteBatch(@Param("ids") List<Long> ids);
 }

+ 15 - 3
blade-service/blade-land/src/main/java/org/springblade/land/mapper/CompensationInfoMapper.xml

@@ -16,7 +16,13 @@
         delete from l_compensation_info
         where id = #{id}
     </delete>
-
+    <delete id="deleteBatch">
+        delete from l_compensation_info
+        where id in
+        <foreach collection="ids" item="id" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+    </delete>
 
     <select id="getTables" resultType="org.springblade.manager.entity.WbsTreePrivate">
         SELECT * FROM m_wbs_tree_private
@@ -39,13 +45,16 @@
     </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 and dynamic_dict > 0 and f_id in
+        where is_deleted = 0 and dynamic_dict > 0 and f_id in
         <foreach collection="ids" item="id" open="(" close=")" separator=",">
             #{id}
         </foreach>
     </select>
     <select id="getBussDataInfoByDataIds" resultType="org.springblade.land.vo.TableDataVO">
-        select p_key_id as pKeyId,tab_key as tabKey,key_val as tabVal from table_data_info
+        select p_key_id as pKeyId,tab_key as tabKey,key_val as tabVal,
+               SUBSTRING_INDEX(tab_key,"__",1) as dictKey,
+               SUBSTRING_INDEX( SUBSTRING_INDEX(tab_key,"__",-1),"_",1) as dictRow
+        from table_data_info
         where p_key_id in
         <foreach collection="ids" item="id" open="(" close=")" separator=",">
             #{id}
@@ -93,6 +102,9 @@
             #{id}
         </foreach>
     </select>
+    <select id="getPdfIsNull" resultType="java.lang.Long">
+        select id from l_compensation_info where project_id = #{projectId} and merge_pdf_url is null
+    </select>
 
 
 </mapper>

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

@@ -32,6 +32,7 @@ import org.springblade.manager.entity.WbsTreePrivate;
 
 import java.io.FileNotFoundException;
 import java.util.List;
+import java.util.Map;
 
 
 /**
@@ -82,7 +83,7 @@ public interface ICompensationInfoService extends BaseService<CompensationInfo>
     void mergePdfs(Long agreementId) throws Exception;
 
     //获取单个PDF
-    R getBussPdfInfo(Long id) throws Exception;
+    R getBussPdfInfo(Long id, Map<String, Object> DataInfo) throws Exception;
 
     void unSave(Long agreementId);
 }

+ 256 - 29
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/ClearingAgreementInfoServiceImpl.java

@@ -5,7 +5,11 @@ 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 lombok.Data;
 import org.apache.commons.lang.StringUtils;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.jsoup.nodes.Element;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
@@ -17,13 +21,13 @@ import org.springblade.core.tool.utils.ResourceUtil;
 import org.springblade.land.dto.SettlementIntervalDTO;
 import org.springblade.land.entity.*;
 import org.springblade.land.mapper.ClearingAgreementInfoMapper;
+import org.springblade.land.mapper.CompensationInfoMapper;
 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.service.*;
 import org.springblade.land.utils.FileUtils;
 import org.springblade.land.vo.AreaPictureVO;
+import org.springblade.land.vo.TableDataVO;
+import org.springblade.manager.entity.WbsFormElement;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springblade.resource.feign.NewIOSSClient;
 import org.springframework.stereotype.Service;
@@ -32,8 +36,8 @@ 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.time.format.DateTimeFormatter;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
@@ -41,11 +45,14 @@ import java.util.stream.Collectors;
 public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAgreementInfoMapper, ClearingAgreementInfo> implements IClearingAgreementInfoService {
 
     private final ICompensationInfoService compensationInfoService;
+    private final CompensationInfoMapper compensationInfoMapper;
     private final IAgreementLinkTableService linkTableService;
     private final NewIOSSClient newIOSSClient;
+    private final IRegionTreeInfoService treeInfoService;
 
     /**
      * 新增或修改结算协议
+     *
      * @param info
      */
     @Override
@@ -53,7 +60,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
     public void add(ClearingAgreementInfo info) throws Exception {
         //修改选择的补偿协议的引用状态
         String agreementIds = info.getAgreementIds();
-        if (StringUtils.isBlank(agreementIds)){
+        if (StringUtils.isBlank(agreementIds)) {
             throw new ServiceException("请选择补偿协议");
         }
         //是新增还是修改
@@ -82,14 +89,16 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
             }).collect(Collectors.toList());
             linkTableService.saveBatch(linkTables);
             info.setId(agreeId);
-        }else {
+        } else {
+            //存在则直接获取所有结算表单
             linkTables = linkTableService.getByAgreementId(info.getId());
+            //删除已经生成的单个pdf(待定)
             //修改则先还原之前补偿协议的状态
             ClearingAgreementInfo agreementInfo = this.getById(info.getId());
-            compensationInfoService.batchUpdateStatus(Func.toLongList(agreementInfo.getAgreementIds()),0);
+            compensationInfoService.batchUpdateStatus(Func.toLongList(agreementInfo.getAgreementIds()), 0);
         }
         //批量修改选中的状态
-        compensationInfoService.batchUpdateStatus(ids,1);
+        compensationInfoService.batchUpdateStatus(ids, 1);
         //获取所有选中的补偿协议
         List<CompensationInfo> compensationInfos = compensationInfoService.listByIds(ids);
         //统计补偿协议的统计字段
@@ -103,45 +112,259 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
                 allCount = allCount.add(fo.getAllMoney());
             }
             //名称拼接
-            str.append(fo.getName()+"、");
+            str.append(fo.getName() + "、");
         }
         info.setAgreementMoney(allCount);
         String names = str.toString();
-        if (StringUtils.isNotBlank(names)){
-            info.setName(names.substring(0, names.length() - 1)+"结算");
-        }else {
+        if (StringUtils.isNotBlank(names)) {
+            info.setName(names.substring(0, names.length() - 1) + "结算");
+        } else {
             info.setName("未找到用户名称");
         }
         if (isAdd) {
             this.save(info);
-        }else {
+        } else {
             this.updateById(info);
         }
         //循环结算协议的统计字段,把补偿协议统计出来的字段设置到结算协议
         //生成封面
+        buildPdf1(linkTables.get(0), info.getStage());
         //生成补偿结算表
+        buildPdf2(linkTables.get(1),info.getAreaId());
         //生成补偿费发放统计表
+        buildPdf3(linkTables.get(2),ids);
         //生成补偿费明细表
         //生成补偿资金数量分配表
         //生成面积统计明细表
         //合并PDF
 //        try {
-            this.mergePdfs(info.getId());
+        this.mergePdfs(info.getId());
 //        }catch (Exception e){
 //            throw new ServiceException("合并PDF失败");
 //        }
     }
 
+    private void buildPdf3(AgreementLinkTable linkTable,List<Long> ids) {
+        try {
+            List<WbsFormElement> list = baseMapper.getTableElement(linkTable.getTableId());
+            Map<String, Object> DataInfo = new HashMap<>();
+            //获取所有的补偿协议映射表中的发放表
+            List<AgreementLinkTable> assignTable = baseMapper.getAllAssignTable(ids, "发放表");
+            List<Long> longs = assignTable.stream().map(l -> l.getTableDataId()).collect(Collectors.toList());
+            //获取发放表的配置
+            List<WbsFormElement> dataElements = baseMapper.getTableElement(assignTable.get(0).getTableId());
+            if (dataElements == null || dataElements.size() == 0){
+                compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+            }
+            Map<String, Integer> dataMap = dataElements.stream().collect(Collectors.toMap(WbsFormElement::getEKey, WbsFormElement::getDynamicDict));
+            //获取所有补偿费发放表中的数据
+            List<TableDataVO> dataVOS = compensationInfoMapper.getBussDataInfoByDataIds(longs);
+            dataVOS = dataVOS.stream().filter(l -> dataMap.get(l.getDictKey()) != null).collect(Collectors.toList());
+            if (dataVOS.size() == 0){
+                compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+            }
+            dataVOS.stream().forEach(l->l.setDictValue(dataMap.get(l.getDictKey())));
+            Map<Integer, List<TableDataVO>> listMap = dataVOS.stream().collect(Collectors.groupingBy(TableDataVO::getDictValue));
+
+            if (list != null && list.size() > 0) {
+                //字典为key,位置为value
+                Map<Integer, String> elementMap = list.stream().collect(Collectors.toMap(WbsFormElement::getDynamicDict, WbsFormElement::getEKey));
+                //位置为key,字典为value
+                Map<String, Integer> overMap = list.stream().collect(Collectors.toMap(WbsFormElement::getEKey, WbsFormElement::getDynamicDict));
+                //解析html获取所以实际的key
+                Document doc = Jsoup.parse(new File(linkTable.getHtmlUrl()), "utf-8");
+//                Document doc = Jsoup.parse(new File("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704076712393834496.html"), "utf-8");
+                Element table = doc.select("table").first();
+                //此表key重复,直接获取所有
+                List<TableDataVO> allKey = table.getElementsByAttribute("id").stream().map(l -> {
+                    TableDataVO vo = new TableDataVO();
+                    String s = l.attr("id");
+                    vo.setTabKey(s);
+                    if (s.contains("__")) {
+                        String[] s1 = s.split("__");
+                        vo.setDictKey(s1[0]);
+                        String[] s2 = s1[1].split("_");
+                        vo.setDictRow(Integer.parseInt(s2[0]));
+                    }
+                    return vo;
+                }).collect(Collectors.toList());
+                allKey = allKey.stream().filter(l -> overMap.get(l.getDictKey()) != null).collect(Collectors.toList());
+                if (allKey.size() == 0){
+                    compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+                }
+                allKey.stream().forEach(l->l.setDictValue(overMap.get(l.getDictKey())));
+                Map<Integer, List<TableDataVO>> listMap2 = allKey.stream().collect(Collectors.groupingBy(TableDataVO::getDictValue));
+                for (Integer dict : elementMap.keySet()) {
+//                    switch (dict){
+//                        case 99:
+//                            //当天日期
+//                            break;
+//                        case 4:
+                            //户主姓名
+                            //取出数据集合
+                            List<TableDataVO> voList = listMap.get(dict);
+                            //重置数据顺序,先按表单分组,再按照行顺序重新装入集合
+                            Map<Long, List<TableDataVO>> map = voList.stream().collect(Collectors.groupingBy(TableDataVO::getPKeyId));
+                            List<Long> collect = map.keySet().stream().sorted().collect(Collectors.toList());
+                            List<Object> data = new ArrayList<>();
+                            for (Long aLong : collect) {
+                                List<TableDataVO> vos = map.get(aLong);
+                                data.addAll(vos.stream().sorted(Comparator.comparing(TableDataVO::getDictRow)).map(l->l.getTabVal()).collect(Collectors.toList()));
+                            }
+                            //取出位置集合
+                            List<TableDataVO> voList2 = listMap2.get(dict);
+                            List<String> keys = new ArrayList<>();
+                            keys.addAll(voList2.stream().sorted(Comparator.comparing(TableDataVO::getDictRow)).map(l->l.getTabKey()).collect(Collectors.toList()));
+                            //重置key位置,按照行从小到大
+                            //!!暂时没判断多页,到时候要分隔集合
+                            for (int i = 0; i < data.size(); i++) {
+                                DataInfo.put(keys.get(i),data.get(i));
+                            }
+//                            break;
+//                        case 10:
+//                            //身份证号
+//
+//                            break;
+//                        case 11:
+//                            //银行卡号
+//
+//                            break;
+//                        case 5:
+//                            //补偿总计
+//
+//                            break;
+//                    }
+                }
+            }
+            compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+        } catch (Exception e) {
+            throw new ServiceException("补偿费发放统计表生成失败");
+        }
+    }
+
+    private void buildPdf2(AgreementLinkTable linkTable,Long areaId) {
+        List<WbsFormElement> list = baseMapper.getTableElement(linkTable.getTableId());
+        Map<String, Object> DataInfo = new HashMap<>();
+        try {
+            if (list != null && list.size() > 0) {
+                //字典为key,位置为value
+                Map<Integer, String> elementMap = list.stream().collect(Collectors.toMap(WbsFormElement::getDynamicDict, WbsFormElement::getEKey));
+                //解析html获取所以实际的key
+                Document doc = Jsoup.parse(new File(linkTable.getHtmlUrl()), "utf-8");
+//                Document doc = Jsoup.parse(new File("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1711593963032412160.html"), "utf-8");
+                Element table = doc.select("table").first();
+                //因为此表的key不会重复,所以直接转map
+                Map<String,String> tableKeys = new HashMap<>();
+                table.getElementsByAttribute("id").stream().forEach(l -> {
+                    String s = l.attr("id");
+                    if (s.contains("__")) {
+                        String[] s1 = s.split("__");
+                        tableKeys.put(s1[0], s);
+                    }
+                });
+                for (Integer dict : elementMap.keySet()) {
+                    String s1 = tableKeys.get(elementMap.get(dict));
+                    switch (dict){
+                        case 99:
+                            //当天日期
+                            DataInfo.put(s1,LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
+                            break;
+                        case 200:
+                            //申请单位
+                            DataInfo.put(s1,"重庆申请单位");
+                            break;
+                        case 201:
+                            //申请次数
+                            DataInfo.put(s1,5);
+                            break;
+                        case 202:
+                            //被征收土地桩号
+                            RegionTreeInfo treeInfo = treeInfoService.getById(areaId);
+                            if (StringUtils.isBlank(treeInfo.getStakeMark())){
+                                DataInfo.put(s1,"当前区域未配置桩号");
+                            }else {
+                                DataInfo.put(s1, treeInfo.getStakeMark());
+                            }
+                            break;
+                        case 203:
+                            //被征收土地单位
+                            DataInfo.put(s1,"重庆被征收单位");
+                            break;
+                        case 204:
+                            //本期补偿金额
+                            DataInfo.put(s1,"9000");
+                            break;
+                        case 205:
+                            //累计补偿金额
+                            DataInfo.put(s1,"15000");
+                            break;
+                    }
+                }
+            }
+            compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+        } catch (Exception e) {
+            throw new ServiceException("补偿结算表生成失败");
+        }
+    }
+
+
+    /**
+     * 生成封面
+     *
+     * @param linkTable 表单信息
+     * @param stage              第几期
+     */
+    private void buildPdf1(AgreementLinkTable linkTable, String stage) {
+        List<WbsFormElement> list = baseMapper.getTableElement(linkTable.getTableId());
+        Map<String, Object> DataInfo = new HashMap<>();
+        try {
+            if (list != null && list.size() > 0) {
+                //字典为key,位置为value
+                Map<Integer, String> elementMap = list.stream().collect(Collectors.toMap(WbsFormElement::getDynamicDict, WbsFormElement::getEKey));
+                //解析html获取所以实际的key
+                Document doc = Jsoup.parse(new File(linkTable.getHtmlUrl()), "utf-8");
+//                Document doc = Jsoup.parse(new File("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1711593963032412160.html"), "utf-8");
+                Element table = doc.select("table").first();
+                //因为此表的key不会重复,所以直接转map
+                Map<String,String> tableKeys = new HashMap<>();
+                table.getElementsByAttribute("id").stream().forEach(l -> {
+                    String s = l.attr("id");
+                    if (s.contains("__")) {
+                        String[] s1 = s.split("__");
+                        tableKeys.put(s1[0], s);
+                    }
+                });
+                for (Integer dict : elementMap.keySet()) {
+                    String s1 = tableKeys.get(elementMap.get(dict));
+                    switch (dict){
+                        case 99:
+                            //当天日期
+                            DataInfo.put(s1,LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
+                            break;
+                        case 100:
+                            //周期
+                            DataInfo.put(s1,stage);
+                            break;
+                    }
+                }
+            }
+            compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+        } catch (Exception e) {
+            throw new ServiceException("生成封面失败");
+        }
+    }
+
     /**
      * 分页查询结算周期
+     *
      * @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);
+        IPage<ClearingAgreementInfo> iPage = new Page<>(query.getCurrent(), query.getSize());
+        return baseMapper.page(iPage, info);
     }
 
     /**
@@ -154,6 +377,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
 
     /**
      * 结算统计面积
+     *
      * @param projectId
      * @param areaId
      * @return
@@ -163,17 +387,17 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         List<String> list = new ArrayList<>();
         //获取当前项目下,当前节点下所有补偿协议
         List<CompensationInfo> infoList = compensationInfoService.getAllAgreementList(projectId, areaId);
-        if (infoList == null || infoList.size() == 0){
+        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(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+"");
+        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);
@@ -181,6 +405,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
 
     /**
      * 结算统计面积柱状图
+     *
      * @param projectId
      * @param areaId
      * @return
@@ -190,7 +415,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         List<AreaPictureVO> vo = new ArrayList<>();
         //获取当前项目下,当前节点下所有补偿协议
         List<CompensationInfo> infoList = compensationInfoService.getAllAgreementList(projectId, areaId);
-        if (infoList == null || infoList.size() == 0){
+        if (infoList == null || infoList.size() == 0) {
             return R.data(vo);
         }
         //已签面积
@@ -220,6 +445,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
 
     /**
      * 结算统计-金额进度
+     *
      * @param projectId
      * @param areaId
      * @return
@@ -229,7 +455,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         List<AreaPictureVO> vo = new ArrayList<>();
         //获取当前项目下,当前节点下所有补偿协议
         List<CompensationInfo> infoList = compensationInfoService.getAllAgreementList(projectId, areaId);
-        if (infoList == null || infoList.size() == 0){
+        if (infoList == null || infoList.size() == 0) {
             return R.data(vo);
         }
         BigDecimal zero = new BigDecimal(0);
@@ -241,7 +467,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         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);
+        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);
@@ -262,7 +488,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         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);
+        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);
@@ -278,6 +504,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
 
     /**
      * 批量删除
+     *
      * @param ids
      */
     @Override
@@ -292,9 +519,9 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         List<Long> li = new ArrayList<>();
         List<ClearingAgreementInfo> list = this.listByIds(id);
         for (ClearingAgreementInfo info : list) {
-            li.addAll( Func.toLongList(info.getAgreementIds()));
+            li.addAll(Func.toLongList(info.getAgreementIds()));
         }
-        compensationInfoService.batchUpdateStatus(li,0);
+        compensationInfoService.batchUpdateStatus(li, 0);
         //最后删除结算协议
         this.deleteLogic(id);
 
@@ -311,7 +538,7 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
             if (StringUtils.isNotEmpty(table.getPdfUrl())) {
                 data.add(table.getPdfUrl());
             } else {
-                R bussPdfInfo = compensationInfoService.getBussPdfInfo(table.getId());
+                R bussPdfInfo = compensationInfoService.getBussPdfInfo(table.getId(), null);
                 if (bussPdfInfo.getCode() == 200) {
                     if (StringUtils.isNotBlank(bussPdfInfo.getData() + "")) {
                         data.add(bussPdfInfo.getData() + "");

+ 14 - 6
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/CompensationInfoServiceImpl.java

@@ -443,6 +443,12 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
 
     @Override
     public IPage<CompensationInfo> page(Query query, CompensationInfo info) {
+        //查看列表先删除之前未保存的补偿协议
+        List<Long> ids = baseMapper.getPdfIsNull(info.getProjectId());
+        if (ids != null && ids.size() > 0){
+            linkTableService.deleteByAgreementIds(ids);
+            baseMapper.deleteBatch(ids);
+        }
         IPage<CompensationInfo> iPage = new Page<>(query.getCurrent(),query.getSize());
         return baseMapper.page(iPage,info);
     }
@@ -814,12 +820,13 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         List<String> data = new ArrayList<>();
         //获取协议所有的表单
         List<AgreementLinkTable> list = linkTableService.list(new LambdaQueryWrapper<AgreementLinkTable>()
-                .eq(AgreementLinkTable::getAgreementId, agreementId));
+                .eq(AgreementLinkTable::getAgreementId, agreementId)
+                .orderByAsc(AgreementLinkTable::getSort,AgreementLinkTable::getId));
         for (AgreementLinkTable table : list) {
             if (StringUtils.isNotEmpty(table.getPdfUrl())) {
                 data.add(table.getPdfUrl());
             } else {
-                R bussPdfInfo = this.getBussPdfInfo(table.getId());
+                R bussPdfInfo = this.getBussPdfInfo(table.getId(),null);
                 if (bussPdfInfo.getCode() == 200) {
                     if (StringUtils.isNotBlank(bussPdfInfo.getData() + "")) {
                         data.add(bussPdfInfo.getData() + "");
@@ -854,12 +861,12 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
     }
 
     /**
-     * 获取单个PDF,传入映射表主键
+     * 获取单个PDF,传入映射表主键,如果DataInfo为null会去查,如果不为null则直接使用
      * @param id
      * @return
      * @throws Exception
      */
-    public R getBussPdfInfo(Long id) throws Exception {
+    public R getBussPdfInfo(Long id,Map<String, Object> DataInfo) throws Exception {
         String file_path = FileUtils.getSysLocalFileUrl();
 
         AgreementLinkTable linkTable = linkTableService.getById(id);
@@ -884,8 +891,9 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         if (excelTab == null) {
             return R.fail("未获取到清表信息");
         }
-
-        Map<String, Object> DataInfo = (Map<String, Object>) getBussDataInfo(id).getData();
+        if (DataInfo == null) {
+            DataInfo = (Map<String, Object>) getBussDataInfo(id).getData();
+        }
 
         //获取excel流 和 html流
         InputStream exceInp = CommonUtil.getOSSInputStream(excelTab.getFileUrl());