Pārlūkot izejas kodu

征拆整个补偿协议

qianxb 1 gadu atpakaļ
vecāks
revīzija
6a1cb81a43

+ 55 - 46
blade-service/blade-land/src/main/java/org/springblade/land/controller/CompensationInfoController.java

@@ -36,26 +36,28 @@ public class CompensationInfoController extends BladeController {
 
     private final ICompensationInfoService compensationInfoService;
 
+
     /**
-     * 新增时获取补偿协议表单
+     * 新增协议
      */
-    @GetMapping("addGetTables")
+    @GetMapping("/add")
     @ApiOperationSupport(order = 1)
-    @ApiOperation(value = "新增获取补偿协议表单", notes = "传入项目id和协议类型1征地补偿2坟地补偿3专项设施")
+    @ApiOperation(value = "新增协议", notes = "返回协议id")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+            @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
             @ApiImplicitParam(name = "type", value = "协议类型1征地补偿2坟地补偿3专项设施", required = true)
     })
-    public R<List<WbsTreePrivate>> addGetTables(Long projectId,Integer type){
-        return R.data(compensationInfoService.getTables(projectId,type));
+    public R<Long> add(Long projectId,Long areaId,Integer type){
+        return R.data(compensationInfoService.add(projectId,areaId,type));
     }
 
     /**
-     * 修改时获取补偿协议表单
+     * 获取补偿协议表单
      */
     @GetMapping("updateGetTables")
     @ApiOperationSupport(order = 2)
-    @ApiOperation(value = "修改获取补偿协议表单", notes = "传入协议id")
+    @ApiOperation(value = "获取补偿协议表单", notes = "传入协议id")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "agreementId", value = "协议id", required = true),
     })
@@ -71,11 +73,10 @@ public class CompensationInfoController extends BladeController {
     @ApiOperationSupport(order = 3)
     @ApiOperation(value = "协议表单-生成html", notes = "协议表单-生成html")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "pkeyId", value = "新增传pkeyId,编辑传id", required = true),
-            @ApiImplicitParam(name = "type", value = "新增1编辑2", required = true)
+            @ApiImplicitParam(name = "id", value = "当前表单id", required = true)
     })
-    public R getExcelHtmlByBuss(Long pkeyId,Integer type) throws Exception {
-        return compensationInfoService.getExcelHtmlByBuss(pkeyId,type);
+    public R getExcelHtmlByBuss(Long id) throws Exception {
+        return compensationInfoService.getExcelHtmlByBuss(id);
     }
 
 
@@ -86,11 +87,10 @@ public class CompensationInfoController extends BladeController {
     @ApiOperationSupport(order = 4)
     @ApiOperation(value = "协议表单-获取坐标位置", notes = "协议表单-获取坐标位置")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "pkeyId", value = "当前表单pkeyId", required = true),
-            @ApiImplicitParam(name = "type", value = "新增1编辑2", required = true)
+            @ApiImplicitParam(name = "id", value = "当前表单id", required = true)
     })
-    public R getHtmlBussCols(Long pkeyId,Integer type) throws Exception {
-        return compensationInfoService.getHtmlBussCols(pkeyId,type);
+    public R getHtmlBussCols(Long id) throws Exception {
+        return compensationInfoService.getHtmlBussCols(id);
     }
 
     /**
@@ -100,10 +100,10 @@ public class CompensationInfoController extends BladeController {
     @ApiOperationSupport(order = 5)
     @ApiOperation(value = "协议表单-获取用户保存数据", notes = "协议表单-获取用户保存数据")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "linkId", value = "当前表单的id,新增的传null", required = true),
+            @ApiImplicitParam(name = "id", value = "当前表单的id", required = true),
     })
-    public R getBussDataInfo(Long linkId) throws FileNotFoundException {
-        return compensationInfoService.getBussDataInfo(linkId);
+    public R getBussDataInfo(Long id) throws FileNotFoundException {
+        return compensationInfoService.getBussDataInfo(id);
     }
 
     /**
@@ -117,11 +117,10 @@ public class CompensationInfoController extends BladeController {
     @ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存,返回当前协议id")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
-            @ApiImplicitParam(name = "agreementId", value = "协议的id,新增协议为null", required = false),
-            @ApiImplicitParam(name = "linkId", value = "当前表单的id,新增协议为null", required = false),
+            @ApiImplicitParam(name = "agreementId", value = "协议的id,修改时放的agreementId", required = true),
+            @ApiImplicitParam(name = "linkId", value = "当前表单的id,修改时返回的id", required = true),
             @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
-            @ApiImplicitParam(name = "tableId", value = "表单的tableId", required = true),
-            @ApiImplicitParam(name = "nodeType", value = "新增返回的nodeType,修改传null", required = false)
+            @ApiImplicitParam(name = "tableId", value = "表单的tableId", required = true)
     })
     public R saveBussData(@Valid @RequestBody JSONObject dataInfo) throws Exception {
         return compensationInfoService.saveBussData(dataInfo);
@@ -129,7 +128,7 @@ public class CompensationInfoController extends BladeController {
 
     @GetMapping("/page")
     @ApiOperationSupport(order = 7)
-    @ApiOperation(value = "单表pdf预览", notes = "单表pdf预览")
+    @ApiOperation(value = "分页查询补偿协议", notes = "分页查询补偿协议")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
             @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
@@ -142,48 +141,58 @@ public class CompensationInfoController extends BladeController {
         return R.data(page);
     }
 
+    /**
+     * 批量删除
+     */
+    @PostMapping("/remove")
+    @ApiOperationSupport(order = 8)
+    @ApiOperation(value = "批量逻辑删除", notes = "传入ids")
+    public R remove(@ApiParam(value = "主键集合", required = true) @RequestBody List<Long> ids) {
+        compensationInfoService.remove(ids);
+        return R.success("删除成功");
+    }
+
     @GetMapping("/get-buss-pdfInfo")
     @ApiOperationSupport(order = 18)
     @ApiOperation(value = "单表pdf预览", notes = "单表pdf预览")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "agreementId", value = "协议的id,新增的传null", required = true),
-            @ApiImplicitParam(name = "tableId", value = "表单的tableId", required = true)
+            @ApiImplicitParam(name = "id", value = "当前表单的id", required = true)
     })
-    public R getBussPdfDataInfo(Long agreementId,Long tableId)  {
-        return compensationInfoService.getBussPdfDataInfo(agreementId,tableId);
+    public R getBussPdfDataInfo(Long id)  {
+        return compensationInfoService.getBussPdfDataInfo(id);
     }
 
     @GetMapping("/get-buss-pdfs")
     @ApiOperationSupport(order = 21)
     @ApiOperation(value = "多表预览", notes = "多表预览")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "agreementId", value = "协议的id,新增的传null", required = true),
+            @ApiImplicitParam(name = "agreementId", value = "协议的id", required = true),
     })
     public R getPdfS(Long agreementId) {
         return compensationInfoService.getPdfS(agreementId);
     }
 
-    @PostMapping("/add-cope-tab")
-    @ApiOperationSupport(order = 19)
-    @ApiOperation(value = "表单新增复制", notes = "表单新增复制,,返回协议id")
-    @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
-            @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
-            @ApiImplicitParam(name = "tableId", value = "表单的tableId", required = true),
-            @ApiImplicitParam(name = "nodeType", value = "新增返回的nodeType", required = true)
-    })
-    public R addCopeTab(@RequestBody TableCopyVO vo) {
-        return compensationInfoService.addCopeTab(vo);
-    }
-
-    @PostMapping("/update-cope-tab")
+//    @PostMapping("/add-cope-tab")
+//    @ApiOperationSupport(order = 19)
+//    @ApiOperation(value = "表单新增复制", notes = "表单新增复制,,返回协议id")
+//    @ApiImplicitParams(value = {
+//            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+//            @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
+//            @ApiImplicitParam(name = "tableId", value = "表单的tableId", required = true),
+//            @ApiImplicitParam(name = "nodeType", value = "新增返回的nodeType", required = true)
+//    })
+//    public R addCopeTab(@RequestBody TableCopyVO vo) {
+//        return compensationInfoService.addCopeTab(vo);
+//    }
+
+    @PostMapping("/cope-tab")
     @ApiOperationSupport(order = 19)
-    @ApiOperation(value = "表单修改复制", notes = "表单修改复制,,返回协议id")
+    @ApiOperation(value = "表单复制", notes = "表单复制,传入当前表id,返回协议id")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "linkId", value = "当前表单的id,新增协议为null", required = true)
+            @ApiImplicitParam(name = "id", value = "当前表单的id", required = true)
     })
-    public R updateCopeTab(@RequestBody TableCopyVO vo) {
-        return compensationInfoService.updateCopeTab(vo);
+    public R updateCopeTab(@RequestBody Long id) {
+        return compensationInfoService.updateCopeTab(id);
     }
 
 }

+ 5 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/AgreementLinkTableMapper.java

@@ -23,6 +23,8 @@ import org.springblade.land.dto.PolicyInfoSearchDTO;
 import org.springblade.land.entity.AgreementLinkTable;
 import org.springblade.land.entity.PolicyInfo;
 
+import java.util.List;
+
 
 /**
  *  Mapper 接口
@@ -33,4 +35,7 @@ import org.springblade.land.entity.PolicyInfo;
 public interface AgreementLinkTableMapper extends BaseMapper<AgreementLinkTable> {
 
 
+    void deleteTableData(@Param("ids") List<Long> ids);
+
+    void deleteByAgreementIds(@Param("ids") List<Long> ids);
 }

+ 15 - 1
blade-service/blade-land/src/main/java/org/springblade/land/mapper/AgreementLinkTableMapper.xml

@@ -3,5 +3,19 @@
 <mapper namespace="org.springblade.land.mapper.AgreementLinkTableMapper">
 
 
-
+    <delete id="deleteTableData">
+        delete from table_data_info
+        where p_key_id in
+              (select table_data_id from l_agreement_link_table where agreement_id in
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>)
+    </delete>
+    <delete id="deleteByAgreementIds">
+        delete from l_agreement_link_table
+        where agreement_id in
+        <foreach collection="ids" item="id" open="(" separator="," close=")">
+            #{id}
+        </foreach>
+    </delete>
 </mapper>

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

@@ -65,4 +65,6 @@ public interface CompensationInfoMapper extends BaseMapper<CompensationInfo> {
     Integer getTableCount(@Param("agreementId") Long agreementId,@Param("tableId") Long tableId);
 
     IPage<CompensationInfo> page(IPage<CompensationInfo> iPage,@Param("info") CompensationInfo info);
+
+    Integer getNumber(@Param("areaId") Long areaId);
 }

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

@@ -54,6 +54,10 @@
             and name like CONCAT(CONCAT('%', #{info.name}), '%')
         </if>
     </select>
+    <select id="getNumber" resultType="java.lang.Integer">
+        select count(1)
+        from l_compensation_info where area_id = #{areaId}
+    </select>
 
 
 </mapper>

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

@@ -39,4 +39,8 @@ public interface IAgreementLinkTableService extends BaseService<AgreementLinkTab
 
 
     List<AgreementLinkTable> getByAgreementId(Long id);
+
+    void deleteTableData(List<Long> ids);
+
+    void deleteByAgreementIds(List<Long> ids);
 }

+ 9 - 5
blade-service/blade-land/src/main/java/org/springblade/land/service/ICompensationInfoService.java

@@ -45,23 +45,27 @@ public interface ICompensationInfoService extends BaseService<CompensationInfo>
 
     List<WbsTreePrivate> getTables(Long projectId, Integer type);
 
-    R getExcelHtmlByBuss(Long pkeyId,Integer type) throws Exception;
+    R getExcelHtmlByBuss(Long id) throws Exception;
 
-    R getHtmlBussCols(Long pkeyId,Integer type) throws Exception;
+    R getHtmlBussCols(Long id) throws Exception;
 
     R getBussDataInfo(Long linkId);
 
     R saveBussData(JSONObject dataInfo) throws Exception;
 
-    R getBussPdfDataInfo(Long agreementId, Long tableId);
+    R getBussPdfDataInfo(Long id);
 
     List<AgreementLinkTable> updateGetTables(Long agreementId);
 
     R getPdfS(Long agreementId);
 
-    R addCopeTab(TableCopyVO vo);
+//    R addCopeTab(TableCopyVO vo);
 
-    R updateCopeTab(TableCopyVO vo);
+    R updateCopeTab(Long id);
 
     IPage<CompensationInfo> page (Query query,CompensationInfo info);
+
+    Long add(Long projectId, Long areaId, Integer type);
+
+    void remove(List<Long> ids);
 }

+ 18 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/AgreementLinkTableServiceImpl.java

@@ -44,4 +44,22 @@ public class AgreementLinkTableServiceImpl extends BaseServiceImpl<AgreementLink
         return baseMapper.selectList(new LambdaQueryWrapper<AgreementLinkTable>()
                             .eq(AgreementLinkTable::getAgreementId,id));
     }
+
+    /**
+     * 删除表单填报的数据,根据补偿协议id
+     * @param ids
+     */
+    @Override
+    public void deleteTableData(List<Long> ids) {
+        baseMapper.deleteTableData(ids);
+    }
+
+    /**
+     * 删除中间表的数据,根据补偿协议id
+     * @param ids
+     */
+    @Override
+    public void deleteByAgreementIds(List<Long> ids) {
+        baseMapper.deleteByAgreementIds(ids);
+    }
 }

+ 117 - 133
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/CompensationInfoServiceImpl.java

@@ -91,30 +91,14 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
      * 协议表单 获取html接口
      */
     @Override
-    public R getExcelHtmlByBuss(Long pkeyId,Integer type) throws Exception {
+    public R getExcelHtmlByBuss(Long id) throws Exception {
         //获取表单信息
-        String fileUrl = "";
-        Long projectId = null;
-        if (type == 1) {
-            WbsTreePrivate wbsTreePrivate = baseMapper.getWbsPrivateTable(pkeyId);
-            if (wbsTreePrivate == null) {
-                return R.fail("该数据下无此节点!");
-            }
-            if (wbsTreePrivate.getHtmlUrl() == null) {
-                return R.fail("暂无表单!");
-            }
-            fileUrl = wbsTreePrivate.getHtmlUrl();
-            projectId = Long.parseLong(wbsTreePrivate.getProjectId());
-        }else if (type == 2){
-            AgreementLinkTable table = linkTableService.getById(pkeyId);
-            fileUrl = table.getHtmlUrl();
-            projectId = table.getProjectId();
-        }
+        AgreementLinkTable linkTable = linkTableService.getById(id);
 //        fileUrl = "C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html";
-        if (StringUtils.isBlank(fileUrl)){
+        if (StringUtils.isBlank(linkTable.getHtmlUrl())){
             return R.fail("没有获取到表单!");
         }
-        InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
+        InputStream fileInputStream = FileUtils.getInputStreamByUrl(linkTable.getHtmlUrl());
 
         String htmlString = IoUtil.readToString(fileInputStream);
         htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
@@ -124,7 +108,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         Document doc = Jsoup.parse(htmlString);
         Element table = doc.select("table").first();
         // 添加标题显示
-        ProjectInfo projectInfo = baseMapper.getProjectInfo(projectId);
+        ProjectInfo projectInfo = baseMapper.getProjectInfo(linkTable.getProjectId());
         Elements trs = table.select("tr");
         for (int i = 1; i < 6; i++) {
             Element tr = trs.get(i);
@@ -149,24 +133,12 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
      * 协议表单 获取坐标位置
      */
     @Override
-    public R getHtmlBussCols(Long pkeyId,Integer type) throws Exception {
+    public R getHtmlBussCols(Long id) throws Exception {
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
         //获取表单信息
-        String fileUrl = "";
-        if (type == 1) {
-            WbsTreePrivate wbsTreePrivate = baseMapper.getWbsPrivateTable(pkeyId);
-            if (wbsTreePrivate == null) {
-                return R.fail("该数据下无此节点!");
-            }
-            if (wbsTreePrivate.getHtmlUrl() == null) {
-                return R.fail("暂无表单!");
-            }
-            fileUrl = wbsTreePrivate.getHtmlUrl();
-        }else if (type == 2){
-            AgreementLinkTable table = linkTableService.getById(pkeyId);
-            fileUrl = table.getHtmlUrl();
-        }
+        AgreementLinkTable linkTable = linkTableService.getById(id);
+        String fileUrl = linkTable.getHtmlUrl();
         if (StringUtils.isBlank(fileUrl)){
             return R.fail("没有获取到表单!");
         }
@@ -221,10 +193,6 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
      */
     @Override
     public R getBussDataInfo(Long linkId) {
-        //当前是新增没有数据
-        if (linkId == null){
-            return R.data(null);
-        }
         Map<String, Object> reData = new HashMap<>();
         //获取表单数据
         List<Map<String, Object>> mapList = baseMapper.getBussDataInfo(linkId);
@@ -253,52 +221,15 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         }
         JSONObject tableInfo1 = dataArray.getJSONObject(0);
         Long id = tableInfo1.getLong("agreementId");
-        Long projectId = tableInfo1.getLong("projectId");
         Long areaId = tableInfo1.getLong("areaId");
-        Integer nodeType = tableInfo1.getInteger("nodeType");
-        Boolean isUpdate = true;
         List<AgreementLinkTable> linkTables = new ArrayList<>();
         //中间表tableId与dataId的映射
         Map<Long,Long> map = new HashMap<>();
-        //中间表tableId与linkId的映射
-        Map<Long,Long> map2 = new HashMap<>();
-        if (id == null){
-            Long agreeId = SnowFlakeUtil.getId();
-            isUpdate = false;
-            //新增建立协议与表单映射,新增复制时会直接在复制接口创建
-            List<WbsTreePrivate> tables = baseMapper.getTables(projectId, nodeType);
-            linkTables = tables.stream().map(l -> {
-                AgreementLinkTable table = new AgreementLinkTable();
-                table.setTableId(Long.parseLong(l.getInitTableId()));
-                table.setProjectId(projectId);
-                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(table.getTableId(),table.getTableDataId());
-                map2.put(table.getTableId(),table.getId());
-                return table;
-            }).collect(Collectors.toList());
-            linkTableService.saveBatch(linkTables);
-            id = agreeId;
-        }else {
-            //获取表单id与数据id的映射
-            linkTables = linkTableService.getByAgreementId(id);
-            linkTables.stream().forEach(l->map.put(l.getTableId(),l.getTableDataId()));
-        }
+
         for (int i=0; i<dataArray.size();i++) {
             JSONObject jsonObject = dataArray.getJSONObject(i);
-            if (isUpdate){
-                //是修改,就先去删除原来保存的数据
-                baseMapper.deleteOldData(jsonObject.getLong("linkId"));
-            }else {
-                //新增时没有linkId,需要手动设置
-                jsonObject.put("linkId",map2.get(jsonObject.getLong("tableId")));
-            }
+            //删除原来保存的数据
+            baseMapper.deleteOldData(jsonObject.getLong("linkId"));
             this.SaveOneTabInfo(jsonObject);
         }
         //合并PDF
@@ -316,9 +247,6 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         //获取当前节点名称
         RegionTreeInfo treeInfo = treeInfoService.getById(areaId);
         info.setNumber(treeInfo.getAreaName()+"默认编号");
-        info.setAreaId(areaId);
-        info.setProjectId(projectId);
-        info.setType(nodeType);
         if (elementList == null || elementList.size() == 0){
             info.setName("未找到用户名称");
             info.setLandMoney(b1);
@@ -365,20 +293,13 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
             }
         }
         //保存协议信息
-        if (isUpdate){
-            this.updateById(info);
-        }else {
-            this.save(info);
-        }
-
-        return R.data(200,id,"保存成功");
+        this.updateById(info);
+        return R.success("保存成功");
     }
 
     @Override
-    public R getBussPdfDataInfo(Long agreementId, Long tableId) {
-        AgreementLinkTable one = linkTableService.getOne(new LambdaQueryWrapper<AgreementLinkTable>()
-                .eq(AgreementLinkTable::getAgreementId, agreementId)
-                .eq(AgreementLinkTable::getTableDataId, tableId));
+    public R getBussPdfDataInfo(Long id) {
+        AgreementLinkTable one = linkTableService.getById(id);
         if (one == null){
             throw new ServiceException("未查询到表单,请联系管理员");
         }
@@ -405,9 +326,6 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
      */
     @Override
     public R getPdfS(Long agreementId) {
-        if (agreementId == null){
-            throw new ServiceException("当前节点还未保存过");
-        }
         CompensationInfo info = this.getById(agreementId);
         if (info == null || StringUtils.isBlank(info.getMergePdfUrl())){
             throw new ServiceException("当前节点还未保存过");
@@ -415,18 +333,86 @@ 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,"复制成功");
+//    }
+
+    /**
+     * 修改复制表单
+     * @param id
+     * @return
+     */
     @Override
-    @Transactional
-    public R addCopeTab(TableCopyVO vo) {
+    public R updateCopeTab(Long id) {
+        AgreementLinkTable linkTable = linkTableService.getById(id);
+        AgreementLinkTable table = new AgreementLinkTable();
+        BeanUtils.copyProperties(linkTable,table);
+        table.setId(null);
+        table.setTableDataId(SnowFlakeUtil.getId());
+        table.setPdfUrl(null);
+        //获取复制表单存在的数量
+        Integer count = baseMapper.getTableCount(table.getAgreementId(), table.getTableId());
+        String[] s = table.getTableName().split("__");
+        table.setTableName(s[0]+"__"+ count);
+        linkTableService.save(table);
+        return R.data(200,linkTable.getAgreementId(),"复制成功");
+    }
+
+    @Override
+    public IPage<CompensationInfo> page(Query query, CompensationInfo info) {
+        IPage<CompensationInfo> iPage = new Page<>(query.getCurrent(),query.getSize());
+        return baseMapper.page(iPage,info);
+    }
+
+    @Override
+    public Long add(Long projectId, Long areaId, Integer type) {
         //新增复制
         Long agreeId = SnowFlakeUtil.getId();
-        //先新增协议,再复制
-        List<WbsTreePrivate> tables = baseMapper.getTables(vo.getProjectId(), vo.getNodeType());
-        Map<Long,Long> map = new HashMap<>();
+        //先新增中间表,再复制
+        List<WbsTreePrivate> tables = baseMapper.getTables(projectId, type);
         List<AgreementLinkTable> linkTables = tables.stream().map(l -> {
             AgreementLinkTable table = new AgreementLinkTable();
             table.setTableId(Long.parseLong(l.getInitTableId()));
-            table.setProjectId(vo.getProjectId());
+            table.setProjectId(projectId);
             table.setTableDataId(SnowFlakeUtil.getId());
             table.setId(SnowFlakeUtil.getId());
             table.setAgreementId(agreeId);
@@ -435,54 +421,52 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
             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());
+        RegionTreeInfo treeInfo = treeInfoService.getById(areaId);
+        //获取编号
+        String num = getNumber(areaId);
+        info.setNumber(treeInfo.getAreaName()+num);
+        info.setAreaId(areaId);
+        info.setProjectId(projectId);
+        info.setType(type);
         info.setLandMoney(new BigDecimal(0));
         info.setCropsMoney(new BigDecimal(0));
         info.setAllMoney(new BigDecimal(0));
         this.save(info);
-        return R.data(200,agreeId,"复制成功");
+        return agreeId;
     }
 
     /**
-     * 修改复制表单
-     * @param vo
-     * @return
+     * 批量删除
+     * @param ids
      */
     @Override
-    public R updateCopeTab(TableCopyVO vo) {
-        AgreementLinkTable linkTable = linkTableService.getById(vo.getLinkId());
-        AgreementLinkTable table = new AgreementLinkTable();
-        BeanUtils.copyProperties(linkTable,table);
-        table.setId(null);
-        table.setTableDataId(SnowFlakeUtil.getId());
-        table.setPdfUrl(null);
-        //获取复制表单存在的数量
-        Integer count = baseMapper.getTableCount(table.getAgreementId(), table.getTableId());
-        String[] s = table.getTableName().split("__");
-        table.setTableName(s[0]+"__"+ count);
-        linkTableService.save(table);
-        return R.data(200,linkTable.getAgreementId(),"复制成功");
+    @Transactional
+    public void remove(List<Long> ids) {
+        //先删除表单数据
+        linkTableService.deleteTableData(ids);
+        //再删除中间表数据
+        linkTableService.deleteByAgreementIds(ids);
+        //最后删除补偿协议
+        this.deleteLogic(ids);
     }
 
-    @Override
-    public IPage<CompensationInfo> page(Query query, CompensationInfo info) {
-        IPage<CompensationInfo> iPage = new Page<>(query.getCurrent(),query.getSize());
-        return baseMapper.page(iPage,info);
+    //获取当前节点的补偿编号
+    private String getNumber(Long areaId) {
+        Integer number = baseMapper.getNumber(areaId);
+        number++;
+        if (number < 10){
+            return "0"+number;
+        }else {
+            return number + "";
+        }
     }
 
     // 保存单表