Browse Source

补偿协议复制表与分页

qianxb 1 year ago
parent
commit
55c5ac1da7

+ 32 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/vo/TableCopyVO.java

@@ -0,0 +1,32 @@
+package org.springblade.land.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2023/9/27 14:58
+ **/
+@Data
+public class TableCopyVO {
+
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
+    @ApiModelProperty(value = "协议id")
+    private Long agreementId;
+
+    @ApiModelProperty(value = "表单id")
+    private Long linkId;
+
+    @ApiModelProperty(value = "树节点id")
+    private Long areaId;
+
+    @ApiModelProperty(value = "表单tableId")
+    private Long tableId;
+
+    @ApiModelProperty(value = "新增返回的nodeType,修改传null")
+    private Integer nodeType;
+
+}

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

@@ -2,15 +2,19 @@ package org.springblade.land.controller;
 
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
 import io.swagger.annotations.*;
 import lombok.AllArgsConstructor;
 import org.springblade.core.boot.ctrl.BladeController;
+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.CompensationInfo;
 import org.springblade.land.service.ICompensationInfoService;
+import org.springblade.land.vo.TableCopyVO;
 import org.springblade.manager.entity.WbsTreeContract;
 import org.springblade.manager.entity.WbsTreePrivate;
 import org.springframework.web.bind.annotation.*;
@@ -110,19 +114,34 @@ public class CompensationInfoController extends BladeController {
      */
     @PostMapping("/save_buss_data")
     @ApiOperationSupport(order = 6)
-    @ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存")
+    @ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存,返回当前协议id")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
-            @ApiImplicitParam(name = "agreementId", value = "协议的id,新增协议为null", required = true),
-            @ApiImplicitParam(name = "linkId", value = "当前表单的id,新增协议为null", required = true),
+            @ApiImplicitParam(name = "agreementId", value = "协议的id,新增协议为null", required = false),
+            @ApiImplicitParam(name = "linkId", value = "当前表单的id,新增协议为null", required = false),
             @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
             @ApiImplicitParam(name = "tableId", value = "表单的tableId", required = true),
-            @ApiImplicitParam(name = "nodeType", value = "新增有值,修改为null", required = true)
+            @ApiImplicitParam(name = "nodeType", value = "新增返回的nodeType,修改传null", required = false)
     })
     public R saveBussData(@Valid @RequestBody JSONObject dataInfo) throws Exception {
         return compensationInfoService.saveBussData(dataInfo);
     }
 
+    @GetMapping("/page")
+    @ApiOperationSupport(order = 7)
+    @ApiOperation(value = "单表pdf预览", notes = "单表pdf预览")
+    @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 = "name", value = "搜索值", required = false),
+    })
+    public R<IPage<CompensationInfo>> page(Query query, CompensationInfo info)  {
+        IPage<CompensationInfo> page = compensationInfoService.page(query, info);
+        return R.data(page);
+    }
+
     @GetMapping("/get-buss-pdfInfo")
     @ApiOperationSupport(order = 18)
     @ApiOperation(value = "单表pdf预览", notes = "单表pdf预览")
@@ -134,6 +153,37 @@ public class CompensationInfoController extends BladeController {
         return compensationInfoService.getBussPdfDataInfo(agreementId,tableId);
     }
 
+    @GetMapping("/get-buss-pdfs")
+    @ApiOperationSupport(order = 21)
+    @ApiOperation(value = "多表预览", notes = "多表预览")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "agreementId", value = "协议的id,新增的传null", 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")
+    @ApiOperationSupport(order = 19)
+    @ApiOperation(value = "表单修改复制", notes = "表单修改复制,,返回协议id")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "linkId", value = "当前表单的id,新增协议为null", required = true)
+    })
+    public R updateCopeTab(@RequestBody TableCopyVO vo) {
+        return compensationInfoService.updateCopeTab(vo);
+    }
 
 }

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

@@ -61,4 +61,8 @@ public interface CompensationInfoMapper extends BaseMapper<CompensationInfo> {
     List<TableDataVO> getBussDataInfoByDataIds(@Param("ids") List<Long> collect);
 
     List<AgreementLinkTable> getTablesByUpdate(@Param("id") Long agreementId);
+
+    Integer getTableCount(@Param("agreementId") Long agreementId,@Param("tableId") Long tableId);
+
+    IPage<CompensationInfo> page(IPage<CompensationInfo> iPage,@Param("info") CompensationInfo info);
 }

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

@@ -42,6 +42,18 @@
     <select id="getTablesByUpdate" resultType="org.springblade.land.entity.AgreementLinkTable">
         select * from l_agreement_link_table where agreement_id = #{id} and is_deleted = 0
     </select>
+    <select id="getTableCount" resultType="java.lang.Integer">
+        select COUNT(1) from l_agreement_link_table
+        WHERE agreement_id = #{agreementId} and table_id =  #{tableId} and is_deleted = 0
+    </select>
+    <select id="page" resultType="org.springblade.land.entity.CompensationInfo">
+        select * from l_compensation_info
+        where project_id = #{info.projectId}
+          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>

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

@@ -27,6 +27,7 @@ import org.springblade.land.dto.PolicyInfoSearchDTO;
 import org.springblade.land.entity.AgreementLinkTable;
 import org.springblade.land.entity.CompensationInfo;
 import org.springblade.land.entity.PolicyInfo;
+import org.springblade.land.vo.TableCopyVO;
 import org.springblade.manager.entity.WbsTreePrivate;
 
 import java.io.FileNotFoundException;
@@ -55,4 +56,12 @@ public interface ICompensationInfoService extends BaseService<CompensationInfo>
     R getBussPdfDataInfo(Long agreementId, Long tableId);
 
     List<AgreementLinkTable> updateGetTables(Long agreementId);
+
+    R getPdfS(Long agreementId);
+
+    R addCopeTab(TableCopyVO vo);
+
+    R updateCopeTab(TableCopyVO vo);
+
+    IPage<CompensationInfo> page (Query query,CompensationInfo info);
 }

+ 96 - 2
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/CompensationInfoServiceImpl.java

@@ -16,6 +16,7 @@ import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.checkerframework.checker.units.qual.C;
 import org.jsoup.Jsoup;
 import org.jsoup.nodes.Document;
 import org.jsoup.nodes.Element;
@@ -37,6 +38,7 @@ import org.springblade.land.mapper.CompensationInfoMapper;
 import org.springblade.land.mapper.PolicyInfoMapper;
 import org.springblade.land.service.*;
 import org.springblade.land.utils.FileUtils;
+import org.springblade.land.vo.TableCopyVO;
 import org.springblade.land.vo.TableDataVO;
 import org.springblade.manager.entity.*;
 import org.springblade.manager.vo.AppWbsTreeContractVO;
@@ -109,6 +111,9 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
             projectId = table.getProjectId();
         }
 //        fileUrl = "C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html";
+        if (StringUtils.isBlank(fileUrl)){
+            return R.fail("没有获取到表单!");
+        }
         InputStream fileInputStream = FileUtils.getInputStreamByUrl(fileUrl);
 
         String htmlString = IoUtil.readToString(fileInputStream);
@@ -162,7 +167,9 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
             AgreementLinkTable table = linkTableService.getById(pkeyId);
             fileUrl = table.getHtmlUrl();
         }
-
+        if (StringUtils.isBlank(fileUrl)){
+            return R.fail("没有获取到表单!");
+        }
 //        fileUrl = "C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html";
         File file1 = ResourceUtil.getFile(fileUrl);
         InputStream fileInputStream = null;
@@ -364,7 +371,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
             this.save(info);
         }
 
-        return R.data("保存成功");
+        return R.data(200,id,"保存成功");
     }
 
     @Override
@@ -391,6 +398,93 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         return baseMapper.getTablesByUpdate(agreementId);
     }
 
+    /**
+     * 多表预览
+     * @param agreementId
+     * @return
+     */
+    @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("当前节点还未保存过");
+        }
+        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 vo
+     * @return
+     */
+    @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(),"复制成功");
+    }
+
+    @Override
+    public IPage<CompensationInfo> page(Query query, CompensationInfo info) {
+        IPage<CompensationInfo> iPage = new Page<>(query.getCurrent(),query.getSize());
+        return baseMapper.page(iPage,info);
+    }
+
     // 保存单表
     public void SaveOneTabInfo(JSONObject tableInfo) throws Exception {
         System.out.println("---------="+new Date().toLocaleString());