From d1c75efb17ace31aef2fe4e2bf3856ecfc1c29a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E7=90=A6=E6=B6=9B?= Date: Fri, 11 Oct 2024 16:19:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=B3=E9=94=AE=E9=9B=B6=E9=83=A8=E4=BB=B6?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E5=85=B3=E7=B3=BB=E7=AE=A1=E7=90=86=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=B4=A3=E4=BB=BB=E9=83=A8=E9=97=A8=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../laws/part/entity/LawsPartRelevance.java | 2 +- .../impl/LawsPartRelevanceServiceImpl.java | 89 +++++++++++++++++++ 2 files changed, 90 insertions(+), 1 deletion(-) diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartRelevance.java b/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartRelevance.java index 64c72a95..4cc02bbc 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartRelevance.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/entity/LawsPartRelevance.java @@ -117,7 +117,7 @@ public class LawsPartRelevance implements Serializable { @NotBlank(message = "责任部门不能为空") @Dict(dictTable = "sys_depart", dicCode = "id", dicText = "depart_name") @ApiModelProperty(value = "责任部门") - @Excel(name = "责任部门", width = 15, dictTable = "sys_depart", dicCode = "id", dicText = "depart_name") + @Excel(name = "责任部门", width = 15) private String responsibleDepartment; /** * 责任部门专业模块 diff --git a/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartRelevanceServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartRelevanceServiceImpl.java index 7acf0178..8ee82e87 100644 --- a/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartRelevanceServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/laws/part/service/impl/LawsPartRelevanceServiceImpl.java @@ -1,5 +1,6 @@ package com.jero.modules.laws.part.service.impl; +import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -7,12 +8,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.jero.common.api.vo.Result; import com.jero.common.api.vo.ResultCommon; +import com.jero.common.constant.enums.LanguageEnum; import com.jero.common.exception.JeroBootException; import com.jero.common.system.base.controller.JeroController; import com.jero.common.system.query.QueryGenerator; import com.jero.common.system.vo.LoginUser; import com.jero.common.util.ImportExcelUtil; import com.jero.common.util.MessageUtils; +import com.jero.modules.laws.common.service.ILawsCommonService; import com.jero.modules.laws.part.constans.PartConstants; import com.jero.modules.laws.part.entity.LawsPartPmmPartitionInfo; import com.jero.modules.laws.part.entity.LawsPartRelevance; @@ -20,6 +23,8 @@ import com.jero.modules.laws.part.mapper.LawsPartRelevanceMapper; import com.jero.modules.laws.part.service.ILawsPartPmmPartitionInfoService; import com.jero.modules.laws.part.service.ILawsPartRelevanceService; import com.jero.modules.laws.utils.ValidUtil; +import com.jero.modules.system.entity.SysDepart; +import com.jero.modules.system.service.ISysDepartService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -52,6 +57,10 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl listLawsPartRelevance, StringBuilder m, List listOld, List lawsPartPmmPartitionInfoList, Set setAlready) { + // 组织结构 + List departList = sysDepartService.list(); + Map> departMap = departList.stream().collect(Collectors.groupingBy(SysDepart::getDepartName)); + Map departPartMap = SysDepart.buildPaths(departList); for (int i = 0; i < listLawsPartRelevance.size(); i++) { LawsPartRelevance lawsPartRelevance = listLawsPartRelevance.get(i); StringBuilder s = new StringBuilder(); @@ -234,6 +247,14 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl"); @@ -241,6 +262,74 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl> departMap, Map departPartMap, LawsPartRelevance lawsPartRelevance, StringBuilder s) { + if (StringUtils.isNotBlank(lawsPartRelevance.getResponsibleDepartment())){ + String value = lawsPartRelevance.getResponsibleDepartment(); + List departName = new ArrayList<>(); + for (String v : value.split(",")) { + String[] splitValue = v.split("/"); + List sysDeparts = departMap.get(splitValue[splitValue.length - 1]); + if (sysDeparts != null) { + if (sysDeparts.size() > 1) { + // 叶子节点名称重复,需要寻找全路径 + String nodeId = departPartMap.get(v); + if (StrUtil.isBlank(nodeId)) { + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) { + s.append("责任部门").append(v).append("存在多个;"); + } else { + s.append("责任部门").append(v).append("Exist in multiple;"); + } + } + } + } else { + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) { + s.append("责任部门").append(v).append("不存在;"); + } else { + s.append("责任部门").append(v).append("Not exist;"); + } + } + String cellValue = this.convertMultiOrgId(v, departMap, departPartMap); + if(StringUtils.isEmpty(cellValue)){ + if(MessageUtils.getLanguage().getValue().equals(LanguageEnum.CN.getValue())) { + s.append("责任部门").append(v).append("不存在;"); + } else { + s.append("责任部门").append(v).append("Not exist;"); + } + } + departName.add(cellValue); + } + if(!CollectionUtils.isEmpty(departName)){ + lawsPartRelevance.setResponsibleDepartment(String.join(",",departName)); + } + } + } + + + // 多选部门转换 + public String convertMultiOrgId(String cellValue, Map> sysDepartMap, Map sysDepartPathMap) { + if (StrUtil.isBlank(cellValue)) { + return null; + } + StringBuilder result = new StringBuilder(); + String[] cellValues = cellValue.split(","); + for (String value : cellValues) { + String[] splitValue = value.split("/"); + List sysDeparts = sysDepartMap.get(splitValue[splitValue.length - 1]); + if (sysDeparts != null) { + if (sysDeparts.size() == 1) { + result.append(sysDeparts.get(0).getId()).append(","); + } + if (sysDeparts.size() > 1) { + // 叶子节点名称重复,需要寻找全路径 + String nodeId = sysDepartPathMap.get(value); + result.append(nodeId).append(","); + } + } + } + // 去除掉最后的逗号 + return result.substring(0, result.length() - 1); + } + private void checkCode(List listOld, Set setAlready, LawsPartRelevance lawsPartRelevance, StringBuilder s, String code) { if(!CollectionUtils.isEmpty(listOld)){ long l = listOld.stream().filter(o->