关键零部件绑定关系管理添加责任部门验证
This commit is contained in:
@@ -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;
|
||||
/**
|
||||
* 责任部门专业模块
|
||||
|
||||
+89
@@ -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<LawsPartRelevanceM
|
||||
|
||||
@Resource
|
||||
private ILawsPartPmmPartitionInfoService lawsPartPmmPartitionInfoService;
|
||||
@Resource
|
||||
private ILawsCommonService lawsCommonService;
|
||||
@Resource
|
||||
private ISysDepartService sysDepartService;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -215,6 +224,10 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
}
|
||||
|
||||
private void checkData(List<LawsPartRelevance> listLawsPartRelevance, StringBuilder m, List<LawsPartRelevance> listOld, List<LawsPartPmmPartitionInfo> lawsPartPmmPartitionInfoList, Set<String> setAlready) {
|
||||
// 组织结构
|
||||
List<SysDepart> departList = sysDepartService.list();
|
||||
Map<String, List<SysDepart>> departMap = departList.stream().collect(Collectors.groupingBy(SysDepart::getDepartName));
|
||||
Map<String, String> 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<LawsPartRelevanceM
|
||||
checkCode(listOld, setAlready, lawsPartRelevance, s, code);
|
||||
setAlready.add(code);
|
||||
|
||||
// 验证字典值是否满足条件
|
||||
StringBuilder dict = lawsCommonService.validateFieldByDict(lawsPartRelevance);
|
||||
if(!StringUtils.isBlank(dict)){
|
||||
s.append(dict);
|
||||
}
|
||||
// 检查责任部门部门是否存在
|
||||
checkDepart(departMap, departPartMap, lawsPartRelevance, s);
|
||||
|
||||
if(!StringUtils.isBlank(s.toString())){
|
||||
m.append(MessageUtils.getMessage(ResultCommon.ROW_N_IMPORT,i + 4)).append(",")
|
||||
.append(s.toString(), 0, s.toString().length() - 1).append("<br>");
|
||||
@@ -241,6 +262,74 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
|
||||
}
|
||||
}
|
||||
|
||||
private void checkDepart(Map<String, List<SysDepart>> departMap, Map<String, String> departPartMap, LawsPartRelevance lawsPartRelevance, StringBuilder s) {
|
||||
if (StringUtils.isNotBlank(lawsPartRelevance.getResponsibleDepartment())){
|
||||
String value = lawsPartRelevance.getResponsibleDepartment();
|
||||
List<String> departName = new ArrayList<>();
|
||||
for (String v : value.split(",")) {
|
||||
String[] splitValue = v.split("/");
|
||||
List<SysDepart> 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<String, List<SysDepart>> sysDepartMap, Map<String, String> sysDepartPathMap) {
|
||||
if (StrUtil.isBlank(cellValue)) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
String[] cellValues = cellValue.split(",");
|
||||
for (String value : cellValues) {
|
||||
String[] splitValue = value.split("/");
|
||||
List<SysDepart> 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<LawsPartRelevance> listOld, Set<String> setAlready, LawsPartRelevance lawsPartRelevance, StringBuilder s, String code) {
|
||||
if(!CollectionUtils.isEmpty(listOld)){
|
||||
long l = listOld.stream().filter(o->
|
||||
|
||||
Reference in New Issue
Block a user