Browse Source

Merge remote-tracking branch 'origin/master'

liuyc 1 year ago
parent
commit
44f5d04282

+ 1 - 1
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/LandRole.java

@@ -32,5 +32,5 @@ public class LandRole extends BaseEntity {
     private String allUser;
 
     @ApiModelProperty(value = "区域id")
-    private Long areaId;
+    private String allAreaId;
 }

+ 40 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/entity/RegionTreeInfo.java

@@ -0,0 +1,40 @@
+package org.springblade.land.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.mp.base.BaseEntity;
+
+/**
+ * @Param   征拆区域树
+ * @Author wangwl
+ * @Date 2023/9/20 15:43
+ **/
+@Data
+@TableName("l_region_tree_info")
+@EqualsAndHashCode(callSuper = true)
+public class RegionTreeInfo extends BaseEntity {
+
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
+    @ApiModelProperty(value = "父主键")
+    private Long parentId;
+
+    @ApiModelProperty(value = "祖级列表")
+    private String ancestors;
+
+    @ApiModelProperty(value = "区域名称")
+    private String areaName;
+
+    @ApiModelProperty(value = "征拆桩号")
+    private String stakeMark;
+
+    @ApiModelProperty(value = "节点类型")
+    private Integer nodeType;
+
+    @ApiModelProperty(value = "备注")
+    private String remark;
+
+}

+ 2 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/vo/LandRoleVO.java

@@ -23,5 +23,7 @@ public class LandRoleVO extends LandRole {
     @ApiModelProperty(value = "用户集合")
     private List<User> allUserList;
 
+    @ApiModelProperty(value = "用户集合")
+    private List<RegionTreeInfoVO> allAreaTree;
 
 }

+ 58 - 0
blade-service-api/blade-land-api/src/main/java/org/springblade/land/vo/RegionTreeInfoVO.java

@@ -0,0 +1,58 @@
+package org.springblade.land.vo;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.springblade.core.tool.node.INode;
+import org.springblade.land.entity.RegionTreeInfo;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2023/9/20 15:49
+ **/
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class RegionTreeInfoVO extends RegionTreeInfo implements INode<RegionTreeInfoVO> {
+
+    /**
+     * 主键ID
+     */
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
+    /**
+     * 父节点ID
+     */
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long parentId;
+
+    /**
+     * 子孙节点
+     */
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    private List<RegionTreeInfoVO> children;
+
+    /**
+     * 是否有子孙节点
+     */
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    private Boolean hasChildren;
+
+    @Override
+    public List<RegionTreeInfoVO> getChildren() {
+        if (this.children == null) {
+            this.children = new ArrayList<>();
+        }
+        return this.children;
+    }
+
+    @ApiModelProperty(value = "是否选择0否1是")
+    private Integer isSelect;
+}

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

@@ -53,7 +53,7 @@ public class LandRoleController extends BladeController {
      */
     @PostMapping("/addOrUpdate")
     @ApiOperationSupport(order = 1)
-    @ApiOperation(value = "新增或修改", notes = "传入对象")
+    @ApiOperation(value = "新增或修改", notes = "传入对象,用户id逗号分隔,区域id逗号分隔")
     public R addOrUpdate(@Valid @RequestBody LandRole landRole) {
         roleService.addOrUpdate(landRole);
         return R.success("操作成功");

+ 103 - 0
blade-service/blade-land/src/main/java/org/springblade/land/controller/RegionTreeInfoController.java

@@ -0,0 +1,103 @@
+package org.springblade.land.controller;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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.tool.api.R;
+
+import org.springblade.land.entity.LandRole;
+import org.springblade.land.entity.RegionTreeInfo;
+import org.springblade.land.service.IRegionTreeInfoService;
+import org.springblade.land.utils.ForestNodeMerger;
+import org.springblade.land.vo.LandRoleVO;
+import org.springblade.land.vo.RegionTreeInfoVO;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+ * @author yangyj
+ * @Date 2023/2/17 10:40
+ * @description TODO
+ */
+@RestController
+@AllArgsConstructor
+@RequestMapping("/regionTreeInfo")
+@Api(value = "征拆区域树", tags = "征拆区域树")
+public class RegionTreeInfoController extends BladeController {
+
+    private final IRegionTreeInfoService treeInfoService;
+
+    /**
+     * 懒加载区域树
+     */
+    @GetMapping("lazyTree")
+    @ApiOperationSupport(order = 1)
+    @ApiOperation(value = "懒加载区域树", notes = "懒加载区域树")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "id", value = "当前节点id,首次传0", required = true),
+            @ApiImplicitParam(name = "projectId", value = "projectId", required = true)
+    })
+    public R<List<RegionTreeInfoVO>> lazyTree(Long projectId,Long id){
+        List<RegionTreeInfoVO> treeAll = treeInfoService.lazyTree(projectId,id);
+        return R.data(treeAll);
+    }
+
+    /**
+     * 新增或修改
+     */
+    @PostMapping("/addOrUpdate")
+    @ApiOperationSupport(order = 2)
+    @ApiOperation(value = "新增或修改", notes = "新增第一个节点parentId传0,否则传父节点id")
+    public R addOrUpdate(@Valid @RequestBody RegionTreeInfo regionTreeInfo) {
+        treeInfoService.addOrUpdate(regionTreeInfo);
+        return R.success("操作成功");
+    }
+
+    /**
+     * 查询单个详情
+     */
+    @GetMapping("detail")
+    @ApiOperationSupport(order = 3)
+    @ApiOperation(value = "查询单个详情", notes = "传入单个id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "id", required = true)
+    })
+    public R<RegionTreeInfo> detail(Long id){
+        return R.data(treeInfoService.getById(id));
+    }
+
+    /**
+     * 删除节点
+     */
+    @GetMapping("delete")
+    @ApiOperationSupport(order = 4)
+    @ApiOperation(value = "删除当前节点以及子节点", notes = "传入节点id")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "节点", required = true)
+    })
+    public R delete(Long id){
+        treeInfoService.delete(id);
+        return R.success("删除成功");
+    }
+
+    /**
+     * 获取县区域
+     */
+    @GetMapping("/getAllCounty")
+    @ApiOperationSupport(order = 9)
+    @ApiOperation(value = "获取区域", notes = "政策法规-双方协议选择区域")
+    @ApiImplicitParams(value = {
+            @ApiImplicitParam(name = "projectId", value = "项目id", required = true)
+    })
+    public R<List<RegionTreeInfo>> getAllCounty(Long projectId){
+        return R.data(treeInfoService.list(new LambdaQueryWrapper<RegionTreeInfo>()
+                .eq(RegionTreeInfo::getProjectId,projectId)
+                .eq(RegionTreeInfo::getNodeType,4)));
+    }
+}

+ 44 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/RegionTreeInfoMapper.java

@@ -0,0 +1,44 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.land.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.apache.ibatis.annotations.Param;
+import org.springblade.land.dto.PolicyInfoSearchDTO;
+import org.springblade.land.entity.PolicyInfo;
+import org.springblade.land.entity.RegionTreeInfo;
+import org.springblade.land.vo.RegionTreeInfoVO;
+
+import java.util.List;
+
+
+/**
+ *  Mapper 接口
+ *
+ * @author BladeX
+ * @since 2023-02-17
+ */
+public interface RegionTreeInfoMapper extends BaseMapper<RegionTreeInfo> {
+
+
+    List<RegionTreeInfoVO> getTreeAll(@Param("projectId") Long projectId);
+
+    List<RegionTreeInfoVO> lazyTree(@Param("projectId") Long projectId,@Param("id") Long id);
+
+    void deleteNode(@Param("id") Long id);
+}

+ 19 - 0
blade-service/blade-land/src/main/java/org/springblade/land/mapper/RegionTreeInfoMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.land.mapper.RegionTreeInfoMapper">
+    <delete id="deleteNode">
+        delete from l_region_tree_info
+        where is_deleted = 0 and ( id = #{id} or
+                                   ancestors like concat('%', #{id}, '%') )
+    </delete>
+
+
+    <select id="getTreeAll" resultType="org.springblade.land.vo.RegionTreeInfoVO">
+        select * from l_region_tree_info where project_id = #{projectId} and is_deleted = 0
+    </select>
+
+    <select id="lazyTree" resultType="org.springblade.land.vo.RegionTreeInfoVO">
+        select * from l_region_tree_info
+        where is_deleted = 0 and project_id = #{projectId} and parent_id = #{id}
+    </select>
+</mapper>

+ 43 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/IRegionTreeInfoService.java

@@ -0,0 +1,43 @@
+/*
+ *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
+ *
+ *  Redistribution and use in source and binary forms, with or without
+ *  modification, are permitted provided that the following conditions are met:
+ *
+ *  Redistributions of source code must retain the above copyright notice,
+ *  this list of conditions and the following disclaimer.
+ *  Redistributions in binary form must reproduce the above copyright
+ *  notice, this list of conditions and the following disclaimer in the
+ *  documentation and/or other materials provided with the distribution.
+ *  Neither the name of the dreamlu.net developer nor the names of its
+ *  contributors may be used to endorse or promote products derived from
+ *  this software without specific prior written permission.
+ *  Author: Chill 庄骞 (smallchill@163.com)
+ */
+package org.springblade.land.service;
+
+
+import org.springblade.core.mp.base.BaseService;
+import org.springblade.land.entity.LandRole;
+import org.springblade.land.entity.RegionTreeInfo;
+import org.springblade.land.vo.LandRoleVO;
+import org.springblade.land.vo.RegionTreeInfoVO;
+import java.util.List;
+
+
+/**
+ *  服务类
+ *
+ * @author BladeX
+ * @since 2023-02-17
+ */
+public interface IRegionTreeInfoService extends BaseService<RegionTreeInfo> {
+
+    List<RegionTreeInfoVO> getTreeAll(Long projectId,String allAreaId);
+
+    List<RegionTreeInfoVO> lazyTree(Long projectId, Long id);
+
+    void addOrUpdate(RegionTreeInfo regionTreeInfo);
+
+    void delete(Long id);
+}

+ 18 - 1
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/LandRoleServiceImpl.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
+import org.springblade.core.log.exception.ServiceException;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.utils.Func;
@@ -14,7 +15,9 @@ import org.springblade.land.entity.LandRole;
 import org.springblade.land.entity.LandTypeInfo;
 import org.springblade.land.mapper.LandRoleMapper;
 import org.springblade.land.service.ILandRoleService;
+import org.springblade.land.service.IRegionTreeInfoService;
 import org.springblade.land.vo.LandRoleVO;
+import org.springblade.land.vo.RegionTreeInfoVO;
 import org.springblade.system.user.entity.User;
 import org.springframework.stereotype.Service;
 
@@ -25,9 +28,17 @@ import java.util.List;
 @AllArgsConstructor
 public class LandRoleServiceImpl extends BaseServiceImpl<LandRoleMapper, LandRole> implements ILandRoleService {
 
+    private final IRegionTreeInfoService treeInfoService;
+
 
     @Override
     public void addOrUpdate(LandRole landRole) {
+        if (StringUtils.isBlank(landRole.getAllUser())){
+            throw new ServiceException("请选择用户");
+        }
+        if (StringUtils.isBlank(landRole.getAllAreaId())){
+            throw new ServiceException("请选择区域");
+        }
         this.saveOrUpdate(landRole);
     }
 
@@ -35,12 +46,18 @@ public class LandRoleServiceImpl extends BaseServiceImpl<LandRoleMapper, LandRol
     public LandRoleVO detail(Long id) {
         LandRoleVO vo = baseMapper.detail(id);
         String allUser = vo.getAllUser();
+        //插入用户集合
         if (StringUtils.isNotBlank(allUser)){
-//            String[] split = allUser.split(",");
             List<Long> userIdList = Func.toLongList(allUser);
             List<User> userList = baseMapper.getUserList(userIdList);
             vo.setAllUserList(userList);
         }
+        //插入区域树
+        String allAreaId = vo.getAllAreaId();
+        if (StringUtils.isNotBlank(allAreaId)){
+            List<RegionTreeInfoVO> treeAll = treeInfoService.getTreeAll(vo.getProjectId(),allAreaId);
+            vo.setAllAreaTree(treeAll);
+        }
         return vo;
     }
 

+ 82 - 0
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/RegionTreeInfoServiceImpl.java

@@ -0,0 +1,82 @@
+package org.springblade.land.service.impl;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import lombok.AllArgsConstructor;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.base.BaseServiceImpl;
+import org.springblade.core.tool.utils.Func;
+import org.springblade.land.entity.LandRole;
+import org.springblade.land.entity.RegionTreeInfo;
+import org.springblade.land.mapper.RegionTreeInfoMapper;
+import org.springblade.land.service.IRegionTreeInfoService;
+import org.springblade.land.utils.ForestNodeMerger;
+import org.springblade.land.vo.LandRoleVO;
+import org.springblade.land.vo.RegionTreeInfoVO;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+@AllArgsConstructor
+public class RegionTreeInfoServiceImpl extends BaseServiceImpl<RegionTreeInfoMapper, RegionTreeInfo> implements IRegionTreeInfoService {
+
+
+    @Override
+    public List<RegionTreeInfoVO> getTreeAll(Long projectId,String allAreaId) {
+        List<RegionTreeInfoVO> treeAll = baseMapper.getTreeAll(projectId);
+        if (treeAll != null && treeAll.size() > 0){
+            //标记被选中的区域
+            treeAll.stream().forEach(l->{
+                if (allAreaId.contains(l.getId()+"")){
+                    l.setIsSelect(1);
+                }else {
+                    l.setIsSelect(0);
+                }
+            });
+            return ForestNodeMerger.merge(treeAll);
+        }
+        return null;
+    }
+
+    /**
+     * 懒加载树
+     * @param projectId
+     * @param id
+     * @return
+     */
+    @Override
+    public List<RegionTreeInfoVO> lazyTree(Long projectId, Long id) {
+        List<RegionTreeInfoVO> vos = baseMapper.lazyTree(projectId, id);
+        return vos;
+    }
+
+    /**
+     * 新增或修改
+     * @param regionTreeInfo
+     */
+    @Override
+    public void addOrUpdate(RegionTreeInfo regionTreeInfo) {
+        if (regionTreeInfo.getParentId() == 0){
+            regionTreeInfo.setAncestors("0");
+        }else {
+            //查询父节点类型
+            RegionTreeInfo parent = this.getById(regionTreeInfo.getParentId());
+            //如果父节点类型小于等于子节点,则提示
+            if (parent.getNodeType() >= regionTreeInfo.getNodeType()) {
+                throw new ServiceException("请重新选择节点类型,不能大于等于父节点");
+            }
+            regionTreeInfo.setAncestors(parent.getAncestors()+","+parent.getId());
+        }
+        this.saveOrUpdate(regionTreeInfo);
+    }
+
+    /**
+     * 删除当前节点已经子节点
+     * @param id
+     */
+    @Override
+    public void delete(Long id) {
+        baseMapper.deleteNode(id);
+    }
+}

+ 57 - 0
blade-service/blade-land/src/main/java/org/springblade/land/utils/ForestNodeMerger.java

@@ -0,0 +1,57 @@
+package org.springblade.land.utils;
+
+import org.springblade.common.utils.INodeEx;
+import org.springblade.core.tool.node.ForestNodeManager;
+import org.springblade.core.tool.node.INode;
+
+import java.util.List;
+
+public class ForestNodeMerger {
+    public static <T extends INode<T>> List<T> merge(List<T> items) {
+        ForestNodeManager<T> forestNodeManager = new ForestNodeManager(items);
+        items.forEach((forestNode) -> {
+            if (forestNode.getParentId() != null && forestNode.getParentId() != 0L) {
+                INode<T> node = forestNodeManager.getTreeNodeAt(forestNode.getParentId());
+                if (node != null) {
+                    node.getChildren().add(forestNode);
+                } else {
+                    forestNodeManager.addParentId(forestNode.getId());
+                }
+            }
+
+        });
+        return forestNodeManager.getRoot();
+    }
+
+    public static <T extends INode<T>> void getTreeList(T tree, List<T> nodes) {
+        if (tree == null) {
+            return;
+        }
+
+        nodes.add(tree);
+
+        List<T> childrens = tree.getChildren();
+        if (childrens != null) {
+            for (T child : childrens) {
+                getTreeList(child, nodes);
+            }
+        }
+    }
+
+    public static <T extends INodeEx<T>> void getTreeListEx(T tree, List<T> nodes) {
+        if (tree == null) {
+            return;
+        }
+
+        nodes.add(tree);
+
+        List<T> childrens = tree.getChildren();
+        if (childrens != null) {
+            for (T child : childrens) {
+                getTreeListEx(child, nodes);
+            }
+        }
+    }
+
+
+}

+ 20 - 4
blade-service/blade-manager/src/main/java/org/springblade/manager/formula/impl/FormulaTurnPoint.java

@@ -85,7 +85,7 @@ public class FormulaTurnPoint implements FormulaStrategy {
            /* 分组计算*/
             List<List<TurnPoint>> result = total.stream().map(e->ITurnPointCalculator.create(e, configMap,info)).collect(Collectors.toList());
             /*附加属性如:顶面和底面高程判断*/
-            forG8(result.stream().flatMap(Collection::stream).collect(Collectors.toList()), (Map<String, Object>)tec.getConstantMap().computeIfAbsent("G8", k -> new HashMap<>()),tec);
+            forG8(cur,result, (Map<String, Object>)tec.getConstantMap().computeIfAbsent("G8", k -> new HashMap<>()),tec);
            /*插值分页*/
             List<Object> data = paginate(cur,result,configMap);
             /*数据回写*/
@@ -173,7 +173,8 @@ public class FormulaTurnPoint implements FormulaStrategy {
             });
         }
     }
-    private void forG8(List<TurnPoint> data, Map<String, Object> g8,TableElementConverter tec) {
+    private void forG8(FormData cur,List<List<TurnPoint>> result, Map<String, Object> g8,TableElementConverter tec) {
+        List<TurnPoint> data=result.stream().flatMap(Collection::stream).collect(Collectors.toList());
         g8.put("dx", data.stream().filter(e -> TurnPoint.CE.equals(e.getType())).map(tp -> CustomFunction.xN(tp.getDx(), 1000)).collect(Collectors.toList()));
         g8.put("dxv", data.stream().filter(e -> TurnPoint.CE.equals(e.getType()) && e.getVertical()).map(tp -> CustomFunction.xN(tp.getDx(), 1000)).collect(Collectors.toList()));
         g8.put("dxnv", data.stream().filter(e -> TurnPoint.CE.equals(e.getType()) && !e.getVertical()).map(tp -> CustomFunction.xN(tp.getDx(), 1000)).collect(Collectors.toList()));
@@ -188,9 +189,9 @@ public class FormulaTurnPoint implements FormulaStrategy {
         g8.put("cdnv", data.stream().filter(e -> TurnPoint.CE.equals(e.getType()) && !e.getVertical()).map(TurnPoint::getName).collect(Collectors.toList()));
         List<NodeTable> nodeTableList=tec.getTableAll();
         /*c8.103*/
-        c8103( data,nodeTableList, tec);
+        c8103(data,nodeTableList, tec);
         /*统计*/
-
+        fh6n( cur, result, tec);
     }
 
     public void c8103(List<TurnPoint> data,List<NodeTable> nodeTableList,TableElementConverter tec){
@@ -238,6 +239,21 @@ public class FormulaTurnPoint implements FormulaStrategy {
             }
         });
     }
+    private void fh6n(FormData cur,List<List<TurnPoint>> result,TableElementConverter tec){
+        /*误差计算(mm):_∑h理=_fh允=±6√n=*/
+        tec.formDataMap.values().stream().filter(fd->fd.getTableName().equals(cur.getTableName())&&fd.getEName().contains("fh允")&&fd.getCoordsList().size()>0).findFirst().ifPresent(t->{
+            double rowSize=cur.getCoordsList().size();
+            List<Object> tmp=new ArrayList<>();
+            for(List<TurnPoint> list:result){
+                double n=list.size();
+                double x=  Math.sqrt(list.stream().filter(s-> StringUtils.isNumber(s.getBmd())).count())*6;
+                int m= (int) Math.ceil(n/rowSize);
+                tmp.addAll(Collections.nCopies(m,x));
+            }
+            tmp=tmp.stream().map(v->StringUtils.number2String(v,1)).collect(Collectors.toList());
+            FormulaUtils.write(t,tmp,false);
+        });
+    }
 
     private String c(String name,List<String> args) {
         if (Func.isNotEmpty(name) && Func.isNotEmpty(args)) {