From 4be2f81508b2e9dfb858ba082a4e1ae6e2a872a2 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 20 Aug 2021 17:08:07 +0800
Subject: [PATCH] 派遣单位新增字段,工作汇报接收人接口修改
---
src/main/java/org/springblade/modules/directive/service/impl/DirectiveServiceImpl.java | 1
src/main/java/org/springblade/modules/dispatcher/entity/DispatcherUnit.java | 19 ++
src/main/java/org/springblade/modules/system/mapper/DeptMapper.java | 32 ++++
src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml | 183 ++++++++++++++++++++++++++
src/main/java/org/springblade/modules/system/controller/DeptController.java | 11 +
src/main/java/org/springblade/modules/system/node/TreeNode.java | 38 +++++
src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java | 60 ++++++++
src/main/java/org/springblade/modules/dispatcher/mapper/DispatcherUnitMapper.xml | 3
src/main/java/org/springblade/modules/system/service/IDeptService.java | 7 +
src/main/java/org/springblade/modules/system/node/TreeNodes.java | 43 ++++++
src/main/java/org/springblade/modules/system/entity/User.java | 2
11 files changed, 398 insertions(+), 1 deletions(-)
diff --git a/src/main/java/org/springblade/modules/directive/service/impl/DirectiveServiceImpl.java b/src/main/java/org/springblade/modules/directive/service/impl/DirectiveServiceImpl.java
index 00bc1bd..002f57b 100644
--- a/src/main/java/org/springblade/modules/directive/service/impl/DirectiveServiceImpl.java
+++ b/src/main/java/org/springblade/modules/directive/service/impl/DirectiveServiceImpl.java
@@ -37,7 +37,6 @@
IPage<DirectiveVo> directiveVoIPage = page.setRecords(baseMapper.selectDirectivePage(page, directive));
//去除接收人ids,查询出接收人名字
List<DirectiveVo> records = directiveVoIPage.getRecords();
- System.out.println("records = " + records);
if (records.size()>0) {
for (DirectiveVo record : records) {
String[] receiveDirectiveIds = record.getReceiveDirectiveIds().toString().split(",");
diff --git a/src/main/java/org/springblade/modules/dispatcher/entity/DispatcherUnit.java b/src/main/java/org/springblade/modules/dispatcher/entity/DispatcherUnit.java
index 2c059c6..cc3af25 100644
--- a/src/main/java/org/springblade/modules/dispatcher/entity/DispatcherUnit.java
+++ b/src/main/java/org/springblade/modules/dispatcher/entity/DispatcherUnit.java
@@ -84,4 +84,23 @@
private Long jurisdiction;
+ /**
+ * 合同生效时间
+ */
+ @TableField("start_time")
+ @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private Date startTime;
+
+
+
+ /**
+ * 合同到期时间
+ */
+ @TableField("end_time")
+ @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8")
+ @DateTimeFormat(pattern = "yyyy-MM-dd")
+ private Date endTime;
+
+
}
diff --git a/src/main/java/org/springblade/modules/dispatcher/mapper/DispatcherUnitMapper.xml b/src/main/java/org/springblade/modules/dispatcher/mapper/DispatcherUnitMapper.xml
index 072ed43..fa68e96 100644
--- a/src/main/java/org/springblade/modules/dispatcher/mapper/DispatcherUnitMapper.xml
+++ b/src/main/java/org/springblade/modules/dispatcher/mapper/DispatcherUnitMapper.xml
@@ -29,6 +29,9 @@
<if test="dispatcherUnit.province!=null">
and sdu.province = #{dispatcherUnit.province}
</if>
+ <if test="dispatcherUnit.deptId!=null and dispatcherUnit.deptId!=''">
+ and sdu.dept_id = #{dispatcherUnit.deptId}
+ </if>
<if test="dispatcherUnit.city!=null">
and sdu.city = #{dispatcherUnit.city}
</if>
diff --git a/src/main/java/org/springblade/modules/system/controller/DeptController.java b/src/main/java/org/springblade/modules/system/controller/DeptController.java
index ba91200..c926730 100644
--- a/src/main/java/org/springblade/modules/system/controller/DeptController.java
+++ b/src/main/java/org/springblade/modules/system/controller/DeptController.java
@@ -35,6 +35,7 @@
import org.springblade.core.tool.support.Kv;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.system.entity.Dept;
+import org.springblade.modules.system.node.TreeNodes;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.vo.DeptVO;
import org.springblade.modules.system.wrapper.DeptWrapper;
@@ -150,6 +151,16 @@
}
/**
+ * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
+ * @return
+ */
+ @GetMapping("/lazy-tree-users")
+ public R<List<TreeNodes>> lazyTreeUsers(Integer type, Long deptId) {
+ List<TreeNodes> tree = deptService.lazyTreeUsers(type,deptId);
+ return R.data(tree);
+ }
+
+ /**
* 新增或修改
*/
@PostMapping("/submit")
diff --git a/src/main/java/org/springblade/modules/system/entity/User.java b/src/main/java/org/springblade/modules/system/entity/User.java
index bace1d3..e79d1ca 100644
--- a/src/main/java/org/springblade/modules/system/entity/User.java
+++ b/src/main/java/org/springblade/modules/system/entity/User.java
@@ -176,6 +176,8 @@
* 是否缴社保
*/
private String soil;
+
+
/**
* 健康状态 0:健康 1:良好 2:一般 3:较差
*/
diff --git a/src/main/java/org/springblade/modules/system/mapper/DeptMapper.java b/src/main/java/org/springblade/modules/system/mapper/DeptMapper.java
index 00b950c..fc9df70 100644
--- a/src/main/java/org/springblade/modules/system/mapper/DeptMapper.java
+++ b/src/main/java/org/springblade/modules/system/mapper/DeptMapper.java
@@ -18,7 +18,10 @@
import com.baomidou.mybatisplus.annotation.SqlParser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.MapKey;
+import org.apache.ibatis.annotations.Param;
import org.springblade.modules.system.entity.Dept;
+import org.springblade.modules.system.node.TreeNodes;
import org.springblade.modules.system.vo.DeptVO;
import java.util.List;
@@ -92,4 +95,33 @@
*/
@SqlParser(filter=true)
List<DeptVO> lazyTreeUser(String tenantId, Long parentId);
+
+ /**
+ * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
+ * @return
+ */
+ @MapKey(value = "id")
+ @SqlParser(filter=true)
+ Map<Long, TreeNodes> lazyTreeUsers(@Param("type") Integer type,
+ @Param("deptId") Long deptId,
+ @Param("jurisdiction")String jurisdiction);
+
+ /**
+ * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
+ * @return
+ */
+ @MapKey(value = "id")
+ @SqlParser(filter=true)
+ Map<Long, TreeNodes> lazyTreeUsersPublicSecurity(@Param("type") Integer type,
+ @Param("deptId") Long deptId,
+ @Param("jurisdiction")String jurisdiction);
+ /**
+ * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
+ * @return
+ */
+ @MapKey(value = "id")
+ @SqlParser(filter=true)
+ Map<Long, TreeNodes> lazyTreeUsersPublicSecuritys(@Param("type") Integer type,
+ @Param("deptId") Long deptId,
+ @Param("jurisdiction")String jurisdiction);
}
diff --git a/src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml b/src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
index 3bd13d1..56918a8 100644
--- a/src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
+++ b/src/main/java/org/springblade/modules/system/mapper/DeptMapper.xml
@@ -139,6 +139,189 @@
)c
</select>
+ <!--懒加载获取部门树形结构(包含用户数据)-->
+ <select id="lazyTreeUsers" resultType="org.springblade.modules.system.node.TreeNodes" >
+ select DISTINCT
+ *
+ from (
+ (SELECT
+ dept.id,
+ dept.parent_id parentId,
+ dept.dept_name AS title,
+ dept.id AS "value",
+ dept.id AS "key",
+ (
+ SELECT
+ CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
+ FROM
+ blade_dept
+ WHERE
+ parent_id = dept.id and is_deleted = 0
+ ) AS "has_children"
+ FROM
+ blade_dept dept
+ left join
+ sys_information si
+ on
+ si.departmentid = dept.id
+ WHERE
+ dept.is_deleted = 0
+ <if test="type==1">
+ and dept_category=1
+ </if>
+ <if test="deptId!=null and deptId!=''">
+ and dept.id = #{deptId}
+ </if>
+ )
+
+ union
+
+ (select
+ bu.id,
+ bu.dept_id parentId,
+ bu.real_name AS title,
+ bu.id AS "value",
+ bu.id AS "key",
+ 0 as "has_children"
+ from blade_user bu
+ left join
+ blade_dept bd
+ on
+ bd.id = bu.dept_id
+ where 1=1
+ and bu.is_deleted = 0
+ <if test="type==1">
+ and dept_category=1
+ </if>
+ <if test="type==2 or type==3">
+ and dept_category=2
+ </if>
+ <if test="deptId!=null and deptId!=''">
+ and bu.dept_id = #{deptId}
+ </if>
+ <if test="jurisdiction!=null and jurisdiction!=''">
+ and bu.jurisdiction = #{jurisdiction}
+ </if>
+ )
+ )c
+ </select>
+
+ <!--懒加载获取部门树形结构(包含用户数据)-->
+ <select id="lazyTreeUsersPublicSecurity" resultType="org.springblade.modules.system.node.TreeNodes" >
+ select DISTINCT
+ *
+ from (
+ (SELECT
+ dept.id,
+ dept.parent_id parentId,
+ dept.dept_name AS title,
+ dept.id AS "value",
+ dept.id AS "key",
+ (
+ SELECT
+ CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
+ FROM
+ blade_dept
+ WHERE
+ parent_id = dept.id and is_deleted = 0
+ ) AS "has_children"
+ FROM
+ blade_dept dept
+ left join
+ sys_information si
+ on
+ si.departmentid = dept.id
+ WHERE
+ dept.is_deleted = 0
+ <if test="type==2 or type==3">
+ and dept_category=2
+ </if>
+ <if test="deptId!=null and deptId!=''">
+ and (dept.parent_id = #{deptId} or dept.id = #{deptId})
+ </if>
+ )
+
+ union
+
+ (select
+ bu.id,
+ bu.dept_id parentId,
+ bu.real_name AS title,
+ bu.id AS "value",
+ bu.id AS "key",
+ 0 as "has_children"
+ from blade_user bu
+ left join
+ blade_dept bd
+ on
+ bd.id = bu.dept_id
+ where 1=1
+ and bu.is_deleted = 0
+ <if test="type==2 or type==3">
+ and dept_category=2
+ </if>
+ <if test="deptId!=null and deptId!=''">
+ and (bd.parent_id = #{deptId} or bd.id = #{deptId})
+ </if>
+ )
+ )c
+ </select>
+
+ <!--懒加载获取部门树形结构(包含用户数据)-->
+ <select id="lazyTreeUsersPublicSecuritys" resultType="org.springblade.modules.system.node.TreeNodes" >
+ select DISTINCT
+ *
+ from (
+ (SELECT
+ dept.id,
+ dept.parent_id parentId,
+ dept.dept_name AS title,
+ dept.id AS "value",
+ dept.id AS "key",
+ (
+ SELECT
+ CASE WHEN count(1) > 0 THEN 1 ELSE 0 END
+ FROM
+ blade_dept
+ WHERE
+ parent_id = dept.id and is_deleted = 0
+ ) AS "has_children"
+ FROM
+ blade_dept dept
+ left join
+ sys_information si
+ on
+ si.departmentid = dept.id
+ WHERE
+ dept.is_deleted = 0
+ <if test="type==2 or type==3">
+ and dept_category=2
+ </if>
+ )
+
+ union
+
+ (select
+ bu.id,
+ bu.dept_id parentId,
+ bu.real_name AS title,
+ bu.id AS "value",
+ bu.id AS "key",
+ 0 as "has_children"
+ from blade_user bu
+ left join
+ blade_dept bd
+ on
+ bd.id = bu.dept_id
+ where 1=1
+ and bu.is_deleted = 0
+ <if test="type==2 or type==3">
+ and dept_category=2
+ </if>
+ )
+ )c
+ </select>
+
<select id="lazyTrees" resultMap="treeNodeResultMap">
SELECT
diff --git a/src/main/java/org/springblade/modules/system/node/TreeNode.java b/src/main/java/org/springblade/modules/system/node/TreeNode.java
new file mode 100644
index 0000000..ffd904f
--- /dev/null
+++ b/src/main/java/org/springblade/modules/system/node/TreeNode.java
@@ -0,0 +1,38 @@
+package org.springblade.modules.system.node;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author zhongrj
+ */
+@Data
+public class TreeNode {
+
+ /**
+ * id
+ */
+ private Long id;
+
+ /**
+ * 父id
+ */
+ private Long parentId;
+
+ /**
+ * 树节点名称
+ */
+ private String name;
+
+ /**
+ * 子节点
+ */
+ private List<TreeNode> children = new ArrayList<>();
+
+ /**
+ * 是否有子节点
+ */
+ private Boolean hasChildren;
+}
diff --git a/src/main/java/org/springblade/modules/system/node/TreeNodes.java b/src/main/java/org/springblade/modules/system/node/TreeNodes.java
new file mode 100644
index 0000000..0f6c33e
--- /dev/null
+++ b/src/main/java/org/springblade/modules/system/node/TreeNodes.java
@@ -0,0 +1,43 @@
+package org.springblade.modules.system.node;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author zhongrj
+ * avue 返回格式
+ */
+@Data
+public class TreeNodes {
+ /**
+ * id
+ */
+ private Long id;
+
+ /**
+ * key
+ */
+ private Long key;
+
+ /**
+ * 父id
+ */
+ private Long parentId;
+
+ /**
+ * 树节点名称
+ */
+ private String title;
+
+ /**
+ * 子节点
+ */
+ private List<TreeNodes> children = new ArrayList<>();
+
+ /**
+ * 是否有子节点
+ */
+ private Boolean hasChildren;
+}
diff --git a/src/main/java/org/springblade/modules/system/service/IDeptService.java b/src/main/java/org/springblade/modules/system/service/IDeptService.java
index 466810c..1b1a3d1 100644
--- a/src/main/java/org/springblade/modules/system/service/IDeptService.java
+++ b/src/main/java/org/springblade/modules/system/service/IDeptService.java
@@ -18,6 +18,7 @@
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.modules.system.entity.Dept;
+import org.springblade.modules.system.node.TreeNodes;
import org.springblade.modules.system.vo.DeptVO;
import java.util.List;
@@ -133,4 +134,10 @@
* @return
*/
List<DeptVO> lazyTreeUser(String tenantId, Long parentId);
+
+ /**
+ * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
+ * @return
+ */
+ List<TreeNodes> lazyTreeUsers(Integer type, Long deptId);
}
diff --git a/src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java b/src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
index adf630d..4f1cad3 100644
--- a/src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
+++ b/src/main/java/org/springblade/modules/system/service/impl/DeptServiceImpl.java
@@ -19,20 +19,29 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.AllArgsConstructor;
import org.springblade.common.cache.SysCache;
import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.support.Condition;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.node.ForestNodeMerger;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.StringPool;
+import org.springblade.modules.information.entity.Information;
+import org.springblade.modules.information.service.IInformationService;
+import org.springblade.modules.jurisdiction.entity.Jurisdiction;
+import org.springblade.modules.jurisdiction.service.JurisdictionService;
import org.springblade.modules.system.entity.Dept;
import org.springblade.modules.system.mapper.DeptMapper;
+import org.springblade.modules.system.node.TreeNodes;
import org.springblade.modules.system.service.IDeptService;
import org.springblade.modules.system.vo.DeptVO;
import org.springblade.modules.system.wrapper.DeptWrapper;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -43,9 +52,14 @@
* @author Chill
*/
@Service
+@AllArgsConstructor
public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements IDeptService {
private static final String TENANT_ID = "tenantId";
private static final String PARENT_ID = "parentId";
+
+ private final IInformationService iInformationService;
+
+ private final JurisdictionService jurisdictionService;
@Override
public List<DeptVO> lazyList(String tenantId, Long parentId, Map<String, Object> param) {
@@ -211,4 +225,50 @@
return ForestNodeMerger.merge(baseMapper.lazyTreeUser(tenantId, parentId));
}
+ /**
+ * 懒加载获取部门树形结构(包含用户数据),只查下一级的数据
+ * @return
+ */
+ @Override
+ public List<TreeNodes> lazyTreeUsers(Integer type, Long deptId) {
+ Map<Long,TreeNodes> map = new HashMap<>();
+ //保安向保安汇报
+ if(type==1){
+ map = baseMapper.lazyTreeUsers(type,deptId,null);
+ }
+ //保安向民警汇报
+ if(type==2){
+ //查询当前保安所在的辖区
+ Information information = new Information();
+ information.setDepartmentid(deptId.toString());
+
+ Information one = iInformationService.getOne(Condition.getQueryWrapper(information));
+ if (null!=one) {
+ //找辖区对应的组织机构id
+ Jurisdiction jurisdiction = jurisdictionService.getById(one.getJurisdiction());
+ if (null != jurisdiction) {
+ Dept dept = new Dept();
+ dept.setDeptName(jurisdiction.getDeptName());
+ Dept dept1 = this.getOne(Condition.getQueryWrapper(dept));
+ map = baseMapper.lazyTreeUsersPublicSecurity(type, dept1.getId(), one.getJurisdiction());
+ }
+ }
+ }
+ //民警向民警汇报,需要南昌市及当前民警所在辖区的部门数据
+ if(type==3){
+ //当前取所有的民警数据
+ map = baseMapper.lazyTreeUsersPublicSecuritys(type,null,null);
+ }
+ List<TreeNodes> tree = new ArrayList<>();
+ Map<Long, TreeNodes> finalMap = map;
+ map.forEach((id, treeNodes) ->{
+ if (finalMap.containsKey(treeNodes.getParentId())){
+ finalMap.get(treeNodes.getParentId()).getChildren().add(treeNodes);
+ }else {
+ tree.add(treeNodes);
+ }
+ });
+ return tree;
+ }
+
}
--
Gitblit v1.9.3