From d4776113950b58d447bc3cfc5ed57ab4d8e1ee3e Mon Sep 17 00:00:00 2001
From: liyj <15602261488@163.com>
Date: Tue, 24 Sep 2024 14:35:51 +0800
Subject: [PATCH] 1、大厅来访登记,添加当事人法人信息,选择企业接口2
---
dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/service/SyCauseService.java | 72 ++++++++++++++++++++++++++++++++++-
1 files changed, 69 insertions(+), 3 deletions(-)
diff --git a/dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/service/SyCauseService.java b/dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/service/SyCauseService.java
index 3ff313d..27375bd 100644
--- a/dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/service/SyCauseService.java
+++ b/dyh-service/dyh-sys/src/main/java/cn/huge/module/kind/service/SyCauseService.java
@@ -4,19 +4,23 @@
import cn.huge.base.common.utils.DateUtils;
import cn.huge.base.common.utils.IdUtils;
import cn.huge.module.client.api.impl.UtilsClientImpl;
+import cn.huge.module.constant.BaseConsts;
import cn.huge.module.kind.dao.mapper.SyCauseMapper;
+import cn.huge.module.kind.domain.dto.CauseSelectJSDTO;
import cn.huge.module.kind.domain.po.SyCause;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Maps;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.transaction.annotation.Transactional;
-import javax.annotation.PostConstruct;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -26,7 +30,7 @@
* @Description 纠纷类型表业务逻辑处理
* @company hugeinfo
* @author liyj
- * @Time 2024-08-28 20:06:20
+ * @Time 2024-09-09 14:31:21
* @version 1.0.0
*/
@Slf4j
@@ -130,4 +134,66 @@
}
}
+ /**
+ * 查询js树形结构
+ * @return
+ */
+ public List<CauseSelectJSDTO> listSelectJS(){
+ try{
+ List<CauseSelectJSDTO> causeSelectJSDTOList = mapper.listSelectJS();
+ return this.createTree(causeSelectJSDTOList, null);
+ }catch (Exception e){
+ log.error("[SyCauseService.listSelectJS]调用失败,异常信息:"+e, e);
+ throw new ServiceException("SyCauseService.listSelectJS", e);
+ }
+ }
+
+ /**
+ * 创建某一级树形结构
+ * @param allList 所有集合
+ * @param firstId 某一级编号
+ * @return List
+ */
+ public List<CauseSelectJSDTO> createTree(List<CauseSelectJSDTO> allList, String firstId) {
+ List<CauseSelectJSDTO> firstMapList = new ArrayList<>();
+ for (CauseSelectJSDTO causeSelectJSDTO : allList) {
+ for (CauseSelectJSDTO currentParam : allList) {
+ if (currentParam.getValue().equals(causeSelectJSDTO.getParentId())) {
+ addToMBean(currentParam, causeSelectJSDTO);
+ break;
+ }
+ }
+ }
+ //取第一级节点
+ for (CauseSelectJSDTO causeSelectJSDTO : allList) {
+ if (StringUtils.isNotEmpty(firstId)) {
+ if (firstId.equals(causeSelectJSDTO.getValue())) {
+ firstMapList.add(causeSelectJSDTO);
+ }
+ } else {
+ if (BaseConsts.ROOT.equals(causeSelectJSDTO.getParentId()) || StringUtils.isEmpty(causeSelectJSDTO.getParentId())) {
+ firstMapList.add(causeSelectJSDTO);
+ }
+ }
+ }
+ return firstMapList;
+ }
+
+ /**
+ * 获取子级数组
+ * @param target 目标
+ * @param child 子级
+ */
+ public void addToMBean(CauseSelectJSDTO target, CauseSelectJSDTO child) {
+ List<CauseSelectJSDTO> childListObj = target.getChildren();
+ List<CauseSelectJSDTO> childList = null;
+ if (CollectionUtils.isEmpty(childListObj)) {
+ childList = new ArrayList();
+ target.setChildren(childList);
+ } else {
+ childList = childListObj;
+ }
+ childList.add(child);
+ }
+
}
--
Gitblit v1.8.0