Browse Source

征拆保存接口

qianxb 1 year ago
parent
commit
5f06c4f371

+ 16 - 0
blade-service/blade-business/src/main/java/org/springblade/business/controller/ContractTreeDrawingsController.java

@@ -16,6 +16,7 @@
  */
 package org.springblade.business.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
@@ -83,4 +84,19 @@ public class ContractTreeDrawingsController extends BladeController {
         }
     }
 
+    /**
+     * 根据节点pkeyId查看图纸
+     */
+    @GetMapping("/getTreeDrawings")
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "获取节点图纸,传入接单PkeyId")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "primaryKeyId", value = "节点primaryKeyId", required = true)
+    })
+    public R<String> getTreeDrawings(Long primaryKeyId){
+        ContractTreeDrawings one = contractTreeDrawingsService.getOne(new LambdaQueryWrapper<ContractTreeDrawings>()
+                .eq(ContractTreeDrawings::getProcessId, primaryKeyId));
+        return R.data(one.getFileUrl());
+    }
+
 }

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

@@ -60,7 +60,7 @@ public class AgreementFileController {
             @ApiImplicitParam(name = "agreementId", value = "协议id", required = true)
     })
     public R<List<AgreementFile>> getFileList(Long agreementId) {
-        return R.data(fileService.list(new LambdaQueryWrapper<AgreementFile>().eq(AgreementFile::getAgreementId,agreementId)));
+        return R.data(fileService.getFileList(agreementId));
     }
 
 

+ 48 - 11
blade-service/blade-land/src/main/java/org/springblade/land/controller/CompensationInfoController.java

@@ -38,18 +38,33 @@ public class CompensationInfoController extends BladeController {
     private final ICompensationInfoService compensationInfoService;
 
 
+//    /**
+//     * 新增协议
+//     */
+//    @GetMapping("/add")
+//    @ApiOperationSupport(order = 1)
+//    @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<Long> add(Long projectId,Long areaId,Integer type){
+//        return R.data(compensationInfoService.add(projectId,areaId,type));
+//    }
+
     /**
      * 新增协议
      */
     @GetMapping("/add")
     @ApiOperationSupport(order = 1)
-    @ApiOperation(value = "新增协议", notes = "返回协议id")
+    @ApiOperation(value = "新增协议", notes = "返回协议列表")
     @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<Long> add(Long projectId,Long areaId,Integer type){
+    public R<List<AgreementLinkTable>> add(Long projectId,Long areaId,Integer type){
         return R.data(compensationInfoService.add(projectId,areaId,type));
     }
 
@@ -74,10 +89,10 @@ public class CompensationInfoController extends BladeController {
     @ApiOperationSupport(order = 3)
     @ApiOperation(value = "协议表单-生成html", notes = "协议表单-生成html")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "id", value = "当前表单id", required = true)
+            @ApiImplicitParam(name = "tableId", value = "当前表单tableId", required = true)
     })
-    public R getExcelHtmlByBuss(Long id) throws Exception {
-        return compensationInfoService.getExcelHtmlByBuss(id);
+    public R getExcelHtmlByBuss(Long tableId) throws Exception {
+        return compensationInfoService.getExcelHtmlByBuss(tableId);
     }
 
 
@@ -88,10 +103,10 @@ public class CompensationInfoController extends BladeController {
     @ApiOperationSupport(order = 4)
     @ApiOperation(value = "协议表单-获取坐标位置", notes = "协议表单-获取坐标位置")
     @ApiImplicitParams(value = {
-            @ApiImplicitParam(name = "id", value = "当前表单id", required = true)
+            @ApiImplicitParam(name = "tableId", value = "当前表单的tableId", required = true)
     })
-    public R getHtmlBussCols(Long id) throws Exception {
-        return compensationInfoService.getHtmlBussCols(id);
+    public R getHtmlBussCols(Long tableId) throws Exception {
+        return compensationInfoService.getHtmlBussCols(tableId);
     }
 
     /**
@@ -102,11 +117,33 @@ public class CompensationInfoController extends BladeController {
     @ApiOperation(value = "协议表单-获取用户保存数据", notes = "协议表单-获取用户保存数据")
     @ApiImplicitParams(value = {
             @ApiImplicitParam(name = "id", value = "当前表单的id", required = true),
+            @ApiImplicitParam(name = "tableId", value = "当前表单的tableId", required = true),
     })
-    public R getBussDataInfo(Long id) throws FileNotFoundException {
-        return compensationInfoService.getBussDataInfo(id);
+    public R getBussDataInfo(Long id,Long tableId)  {
+        return compensationInfoService.getBussDataInfo(id,tableId);
     }
 
+//    /**
+//     * 用户保存接口
+//     * @param dataInfo
+//     * @return
+//     * @throws Exception
+//     */
+//    @PostMapping("/save_buss_data")
+//    @ApiOperationSupport(order = 6)
+//    @ApiOperation(value = "填报页面数据保存", notes = "填报页面数据保存,返回当前协议id")
+//    @ApiImplicitParams(value = {
+//            @ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+//            @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)
+//    })
+//    public R saveBussData(@Valid @RequestBody JSONObject dataInfo) throws Exception {
+//        return compensationInfoService.saveBussData(dataInfo);
+//    }
+
+
     /**
      * 用户保存接口
      * @param dataInfo
@@ -123,7 +160,7 @@ public class CompensationInfoController extends BladeController {
             @ApiImplicitParam(name = "areaId", value = "当前树节点id", required = true),
             @ApiImplicitParam(name = "tableId", value = "表单的tableId", required = true)
     })
-    public R saveBussData(@Valid @RequestBody JSONObject dataInfo) throws Exception {
+    public R saveBussData(@RequestBody JSONObject dataInfo){
         return compensationInfoService.saveBussData(dataInfo);
     }
 

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

@@ -81,4 +81,7 @@ public interface CompensationInfoMapper extends BaseMapper<CompensationInfo> {
     List<Long> getPdfIsNull(@Param("projectId") Long projectId);
 
     void deleteBatch(@Param("ids") List<Long> ids);
+
+    //根据tableId直接获取项目下表单
+    WbsTreePrivate getTableInfo(@Param("tableId") Long id);
 }

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

@@ -105,6 +105,9 @@
     <select id="getPdfIsNull" resultType="java.lang.Long">
         select id from l_compensation_info where project_id = #{projectId} and merge_pdf_url is null
     </select>
+    <select id="getTableInfo" resultType="org.springblade.manager.entity.WbsTreePrivate">
+        SELECT * FROM m_wbs_tree_private WHERE init_table_id = #{tableId} limit 1
+    </select>
 
 
 </mapper>

+ 3 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/IAgreementFileService.java

@@ -23,6 +23,8 @@ import org.springblade.land.dto.SettlementIntervalDTO;
 import org.springblade.land.entity.AgreementFile;
 import org.springblade.land.entity.SettlementInterval;
 
+import java.util.List;
+
 
 /**
  *  服务类
@@ -33,4 +35,5 @@ import org.springblade.land.entity.SettlementInterval;
 public interface IAgreementFileService extends IService<AgreementFile> {
 
 
+    List<AgreementFile> getFileList(Long agreementId);
 }

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

@@ -50,9 +50,9 @@ public interface ICompensationInfoService extends BaseService<CompensationInfo>
 
     R getHtmlBussCols(Long id) throws Exception;
 
-    R getBussDataInfo(Long linkId);
+    R getBussDataInfo(Long linkId,Long tableId);
 
-    R saveBussData(JSONObject dataInfo) throws Exception;
+    R saveBussData(JSONObject dataInfo);
 
     R getBussPdfDataInfo(Long id);
 
@@ -66,7 +66,7 @@ public interface ICompensationInfoService extends BaseService<CompensationInfo>
 
     IPage<CompensationInfo> page (Query query,CompensationInfo info);
 
-    Long add(Long projectId, Long areaId, Integer type);
+    List<AgreementLinkTable> add(Long projectId, Long areaId, Integer type);
 
     void remove(List<Long> ids);
 

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

@@ -1,6 +1,7 @@
 package org.springblade.land.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.AllArgsConstructor;
 import org.springblade.core.log.exception.ServiceException;
@@ -22,4 +23,12 @@ import java.util.List;
 public class AgreementFileServiceImpl extends ServiceImpl<AgreementFileMapper, AgreementFile> implements IAgreementFileService {
 
 
+    @Override
+    public List<AgreementFile> getFileList(Long agreementId) {
+        if (agreementId == null){
+            throw new ServiceException("请先保存一次资料再上传附件");
+        }else {
+            return this.list(new LambdaQueryWrapper<AgreementFile>().eq(AgreementFile::getAgreementId,agreementId));
+        }
+    }
 }

+ 101 - 48
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/CompensationInfoServiceImpl.java

@@ -96,7 +96,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
     @Override
     public R getExcelHtmlByBuss(Long id) throws Exception {
         //获取表单信息
-        AgreementLinkTable linkTable = linkTableService.getById(id);
+        WbsTreePrivate linkTable = baseMapper.getTableInfo(id);
         if (StringUtils.isBlank(linkTable.getHtmlUrl())){
             return R.fail("没有获取到表单!");
         }
@@ -111,7 +111,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         Document doc = Jsoup.parse(htmlString);
         Element table = doc.select("table").first();
         // 添加标题显示
-        ProjectInfo projectInfo = baseMapper.getProjectInfo(linkTable.getProjectId());
+        ProjectInfo projectInfo = baseMapper.getProjectInfo(Long.parseLong(linkTable.getProjectId()));
         Elements trs = table.select("tr");
         for (int i = 1; i < 6; i++) {
             Element tr = trs.get(i);
@@ -140,7 +140,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
         String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
         //获取表单信息
-        AgreementLinkTable linkTable = linkTableService.getById(id);
+        WbsTreePrivate linkTable = baseMapper.getTableInfo(id);
         String fileUrl = linkTable.getHtmlUrl();
         if (StringUtils.isBlank(fileUrl)){
             return R.fail("没有获取到表单!");
@@ -195,7 +195,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
      * 协议表单获取用户保存数据
      */
     @Override
-    public R getBussDataInfo(Long linkId) {
+    public R getBussDataInfo(Long linkId,Long tableId) {
         Map<String, Object> reData = new HashMap<>();
         //获取表单数据
         List<Map<String, Object>> mapList = baseMapper.getBussDataInfo(linkId);
@@ -207,10 +207,21 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         }
         //需要自动生成的字典集合,项目名称197
         List<Integer> buildDict = Arrays.asList(197);
+        String htmlUrl;
+        Long projectId;
         //获取当前表单
         AgreementLinkTable linkTable = linkTableService.getById(linkId);
+        //如果是新增,中间表是空的,就直接去获取项目下的表单配置
+        if (linkTable == null){
+            WbsTreePrivate wbs = baseMapper.getTableInfo(tableId);
+            htmlUrl = wbs.getHtmlUrl();
+            projectId = Long.parseLong(wbs.getProjectId());
+        }else {
+            htmlUrl = linkTable.getHtmlUrl();
+            projectId = linkTable.getProjectId();
+        }
         //获取当前表单配置字典
-        List<WbsFormElement> tableElement = baseMapper.getTableElement(Arrays.asList(linkTable.getTableId()));
+        List<WbsFormElement> tableElement = baseMapper.getTableElement(Arrays.asList(tableId));
         Map<Integer, List<WbsFormElement>> map = tableElement.stream().collect(Collectors.groupingBy(WbsFormElement::getDynamicDict));
         List<Integer> list = tableElement.stream().map(l -> l.getDynamicDict()).collect(Collectors.toList());
         //获取当前表单内需要自动生成的字典
@@ -219,7 +230,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         if (list.size() > 0) {
             Document doc = null;
             try {
-                doc = Jsoup.parse(new File(linkTable.getHtmlUrl()), "utf-8");
+                doc = Jsoup.parse(new File(htmlUrl), "utf-8");
 //                doc = Jsoup.parse(new File("C:\\Users\\泓创研发01\\Desktop\\privateUrl\\1704045947043971072.html"), "utf-8");
             } catch (IOException e) {
                 throw new ServiceException("解析表单html出错");
@@ -242,7 +253,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
                 switch (dict){
                     case 197 :
                         //项目名称
-                        String projectName = jdbcTemplate.queryForObject("select project_name from m_project_info where id = " + linkTable.getProjectId(), String.class);
+                        String projectName = jdbcTemplate.queryForObject("select project_name from m_project_info where id = " + projectId, String.class);
                         reData.put(key,projectName);
                         break;
                 }
@@ -256,7 +267,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
      */
     @Override
     @Transactional
-    public R saveBussData(JSONObject dataInfo) throws Exception {
+    public R saveBussData(JSONObject dataInfo){
         JSONArray dataArray = new JSONArray();
         if (dataInfo.containsKey("dataInfo")) { //节点保存
             JSONObject jsonObject = dataInfo.getJSONObject("dataInfo");
@@ -267,6 +278,61 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         JSONObject tableInfo1 = dataArray.getJSONObject(0);
         Long id = tableInfo1.getLong("agreementId");
         Long areaId = tableInfo1.getLong("areaId");
+        Long projectId = tableInfo1.getLong("projectId");
+        Integer agreeType = Math.toIntExact(tableInfo1.getLong("type"));
+        //如果id为null证明从来没保存过,先新增
+        if (id == null){
+            //补偿id
+            Long agreeId = SnowFlakeUtil.getId();
+            //先新增中间表
+            List<WbsTreePrivate> tables = baseMapper.getTables(projectId, agreeType);
+            //ExcelId与中间表id的映射
+            Map<Long,Long> map = new HashMap<>();
+            for (int i = 0; i < dataArray.size(); i++) {
+                JSONObject jsonObject = dataArray.getJSONObject(i);
+                map.put(jsonObject.getLong("tableId"),jsonObject.getLong("linkId"));
+            }
+            List<AgreementLinkTable> linkTables = tables.stream().map(l -> {
+                AgreementLinkTable table = new AgreementLinkTable();
+                table.setTableId(Long.parseLong(l.getInitTableId()));
+                table.setProjectId(projectId);
+                table.setTableDataId(SnowFlakeUtil.getId());
+                if (map.get(Long.parseLong(l.getInitTableId())) != null){
+                    table.setId(map.get(Long.parseLong(l.getInitTableId())));
+                }else {
+                    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());
+            id = agreeId;
+            linkTableService.saveBatch(linkTables);
+            for (int i = 0; i < dataArray.size(); i++) {
+                JSONObject jsonObject = dataArray.getJSONObject(i);
+                jsonObject.put("linkId",map.get(jsonObject.getLong("tableId")));
+            }
+            //再保存协议
+            CompensationInfo info = new CompensationInfo();
+            info.setId(agreeId);
+            info.setName("默认名称");
+            //获取当前节点名称
+            RegionTreeInfo treeInfo = treeInfoService.getById(areaId);
+            //获取编号
+            String num = getNumber(areaId);
+            info.setNumber(treeInfo.getAreaName()+num);
+            info.setAreaId(areaId);
+            info.setProjectId(projectId);
+            info.setType(agreeType);
+            info.setLandMoney(new BigDecimal(0));
+            info.setCropsMoney(new BigDecimal(0));
+            info.setAllMoney(new BigDecimal(0));
+            this.save(info);
+        }
         //中间表tableId与dataId的映射
         Map<Long,Long> linkMap = new HashMap<>();
         //获取表单id与数据id的映射
@@ -276,14 +342,18 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         }
         linkTables.stream().forEach(l->linkMap.put(l.getTableDataId(),l.getTableId()));
 
-        for (int i=0; i<dataArray.size();i++) {
-            JSONObject jsonObject = dataArray.getJSONObject(i);
-            //删除原来保存的数据
-            baseMapper.deleteOldData(jsonObject.getLong("linkId"));
-            this.SaveOneTabInfo(jsonObject);
+        try {
+            for (int i = 0; i < dataArray.size(); i++) {
+                JSONObject jsonObject = dataArray.getJSONObject(i);
+                //删除原来保存的数据
+                baseMapper.deleteOldData(jsonObject.getLong("linkId"));
+                this.SaveOneTabInfo(jsonObject);
+            }
+            //合并PDF
+            this.mergePdfs(id);
+        }catch (Exception e){
+            throw new ServiceException("合并PDF出现异常");
         }
-        //合并PDF
-        this.mergePdfs(id);
         //地类补偿金额
         BigDecimal b1 = new BigDecimal(0);
         //青苗
@@ -450,7 +520,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
         }
         //保存协议信息
         this.updateById(info);
-        return R.success("保存成功");
+        return R.data(200,id,"保存成功");
     }
 
     @Override
@@ -498,6 +568,9 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
     @Override
     public R updateCopeTab(Long id) {
         AgreementLinkTable linkTable = linkTableService.getById(id);
+        if (linkTable == null){
+            throw new ServiceException("请先保存一次表单再复制");
+        }
         AgreementLinkTable table = new AgreementLinkTable();
         BeanUtils.copyProperties(linkTable,table);
         table.setId(null);
@@ -514,53 +587,33 @@ 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);
-        }
+//        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);
     }
 
+
     @Override
-    public Long add(Long projectId, Long areaId, Integer type) {
-        //新增复制
-        Long agreeId = SnowFlakeUtil.getId();
-        //先新增中间表,再复制
+    public List<AgreementLinkTable> add(Long projectId, Long areaId, Integer type) {
+        //获取列表
         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(projectId);
-            table.setTableDataId(SnowFlakeUtil.getId());
-            table.setId(SnowFlakeUtil.getId());
-            table.setAgreementId(agreeId);
             table.setPrivateId(l.getId());
             table.setSort(l.getSort());
+            table.setId(SnowFlakeUtil.getId());
             table.setExcelId(l.getExcelId());
             table.setHtmlUrl(l.getHtmlUrl());
             table.setTableName(l.getNodeName());
             return table;
         }).collect(Collectors.toList());
-        linkTableService.saveBatch(linkTables);
-        //再保存协议
-        CompensationInfo info = new CompensationInfo();
-        info.setId(agreeId);
-        info.setName("默认名称");
-        //获取当前节点名称
-        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 agreeId;
+        return linkTables;
     }
 
     /**
@@ -625,7 +678,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
     public void unSave(Long agreementId) {
         CompensationInfo info = this.getById(agreementId);
         //如果从未保存过,直接删除
-        if (StringUtils.isBlank(info.getMergePdfUrl())){
+        if (info != null && StringUtils.isBlank(info.getMergePdfUrl())){
             List<Long> list = Arrays.asList(agreementId);
             //删除中间表数据
             linkTableService.deleteByAgreementIds(list);
@@ -965,7 +1018,7 @@ public class CompensationInfoServiceImpl extends BaseServiceImpl<CompensationInf
             return R.fail("未获取到清表信息");
         }
         if (DataInfo == null) {
-            DataInfo = (Map<String, Object>) getBussDataInfo(id).getData();
+            DataInfo = (Map<String, Object>) getBussDataInfo(id,linkTable.getTableId()).getData();
         }
 
         //获取excel流 和 html流