From d0191ea7bc8c25aed57168de6ceffa284c072f36 Mon Sep 17 00:00:00 2001
From: heheng <475597332@qq.com>
Date: Tue, 10 Feb 2026 09:09:40 +0800
Subject: [PATCH] 条款区分公司
---
multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java | 170 ++++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 120 insertions(+), 50 deletions(-)
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
index f9ccb38..f9fa206 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java
@@ -16,15 +16,10 @@
import com.gkhy.exam.common.utils.PageUtils;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.common.utils.SpringUtils;
-import com.gkhy.exam.system.domain.SysDeptManage;
-import com.gkhy.exam.system.domain.SysDeptResponsibility;
-import com.gkhy.exam.system.domain.SysFunctionalDistribution;
+import com.gkhy.exam.system.domain.*;
import com.gkhy.exam.system.domain.req.SysDeptPageReq;
import com.gkhy.exam.system.domain.vo.*;
-import com.gkhy.exam.system.mapper.SysDeptMapper;
-import com.gkhy.exam.system.mapper.SysDeptResponsibilityMapper;
-import com.gkhy.exam.system.mapper.SysFunctionalDistributionMapper;
-import com.gkhy.exam.system.mapper.SysRoleMapper;
+import com.gkhy.exam.system.mapper.*;
import com.gkhy.exam.system.service.ISysDeptService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -55,10 +50,16 @@
@Autowired
private SysFunctionalDistributionMapper sysFunctionalDistributionMapper;
- public static final String[] DEPT_ROOT = {"4.1", "4.2", "4.3", "4.4", "5.1", "5.2", "5.3","6.1", "6.2", "6.3",
- "7.1.1", "7.1.2", "7.1.3", "7.1.4", "7.1.5", "7.1.6","7.2", "7.3", "7.4", "7.5", "7.6","8.1","8.2","8.2.1","8.2.2", "8.2.3", "8.2.4", "8.3", "8.3.1", "8.3.2", "8.3.3", "8.3.4", "8.3.5", "8.3.6", "8.3.7", "8.3.8", "8.4",
- "8.4.1", "8.4.2", "8.4.3", "8.5", "8.5.1", "8.5.2", "8.5.3", "8.5.4", "8.5.5", "8.5.6", "8.5.7", "8.6","8.7","9.1","9.1.1","9.1.2","9.1.3","9.2", "9.3","10.1"
+
+ @Autowired
+ private SysFunctionalRemarkMapper sysFunctionalRemarkMapper;
+
+ public static final String[] DEPT_ROOT = {"4","4.1", "4.2", "4.3", "4.4","5", "5.1","5.1.1","5.1.2", "5.2", "5.3","6","6.1", "6.2", "6.3"
+ ,"7","7.1","7.1.1", "7.1.2", "7.1.3", "7.1.4", "7.1.5", "7.1.6","7.2", "7.3", "7.4", "7.5", "7.6","8","8.1","8.2","8.2.1","8.2.2", "8.2.3", "8.2.4", "8.3", "8.3.1", "8.3.2", "8.3.3", "8.3.4", "8.3.5", "8.3.6", "8.3.7", "8.3.8", "8.4",
+ "8.4.1", "8.4.2", "8.4.3", "8.5", "8.5.1", "8.5.2", "8.5.3", "8.5.4", "8.5.5", "8.5.6", "8.5.7", "8.6","8.7","9","9.1","9.1.1","9.1.2","9.1.3","9.2", "9.3","10","10.1"
,"10.2", "10.3"};
+ @Autowired
+ private SysClauseManagementMapper sysClauseManagementMapper;
@Override
public CommonPage selectDeptPageList(SysDeptPageReq req) {
@@ -122,19 +123,6 @@
public List<TreeSelect> selectDeptTreeList(SysDept dept)
{
List<SysDept> depts = SpringUtils.getAopProxy(this).getOutDeptList(dept);
-
-// List<SysDeptManage> allManage = deptMapper.getAllManage(dept.getCompanyId());
-// // 构建父部门到子部门的映射
-// Map<Long, List<Long>> parentToChildrenMap = new HashMap<>();
-// for (SysDeptManage responsibility : allManage) {
-// parentToChildrenMap.computeIfAbsent(responsibility.getDeptId(), k -> new ArrayList<>())
-// .add(responsibility.getSubDeptId());
-// }
-//
-// // 构建部门ID到部门对象的映射
-// Map<Long, SysDept> deptMap = depts.stream()
-// .collect(Collectors.toMap(SysDept::getDeptId, Function.identity()));
-
return buildDeptTreeSelect(depts);
}
@@ -391,7 +379,7 @@
}
@Override
- @Transactional
+ @Transactional(rollbackFor = RuntimeException.class)
public int saveDeptResponsibility(SysDeptResponsibilityReqVo reqVo) {
// Long companyId = SecurityUtils.getCompanyId();
// if (!companyId.equals(reqVo.getCompanyId())){
@@ -427,14 +415,11 @@
}
@Override
- @Transactional
+ @Transactional(rollbackFor = RuntimeException.class)
public int initFunctionalDistribution(Long companyId) {
-// if (!companyId.equals(SecurityUtils.getCompanyId())){
-// throw new ApiException("无权操作!");
-// }
-
sysFunctionalDistributionMapper.delByCompanyId(companyId);
+ sysFunctionalRemarkMapper.delByCompanyId(companyId);
SysDept sysDept = new SysDept();
sysDept.setCompanyId(companyId);
sysDept.setResponsType("1");
@@ -442,6 +427,8 @@
if (deptVos != null && !deptVos.isEmpty()){
List<SysFunctionalDistribution> sysFunctionalDistributions = new ArrayList<>();
Map<String, CaluseVO1> clauseNumMap = new HashMap<>();
+ Map<String, Integer> clauseNumSetNum = new HashMap<>();
+ Set<String> clauseNumSet = new HashSet<>();
for (DeptVo deptVo : deptVos) {
List<CaluseVO1> caluseVO1List = deptVo.getCaluseVO1List();
if (ObjectUtil.isNotEmpty(caluseVO1List)){
@@ -453,26 +440,89 @@
(existing, replacement) -> existing // 如果有重复 key,保留现有的值
));
}
- for (String s : DEPT_ROOT) {
- SysFunctionalDistribution sysFunctionalDistribution = new SysFunctionalDistribution();
- sysFunctionalDistribution.setDeptId(deptVo.getDeptId());
- sysFunctionalDistribution.setCompanyId(companyId);
- sysFunctionalDistribution.setCreateBy(SecurityUtils.getUsername());
- sysFunctionalDistribution.setCreateTime(LocalDateTime.now());
- sysFunctionalDistribution.setClauseNum(s);
- if (clauseNumMap.isEmpty()){
- sysFunctionalDistribution.setChooseLab(0);
- }else if (clauseNumMap.containsKey(s)){
- sysFunctionalDistribution.setChooseLab(1);
- }else {
- sysFunctionalDistribution.setChooseLab(0);
- }
+ //加入职能
+ LambdaQueryWrapper<SysClauseManagement> queryWrapper = new LambdaQueryWrapper<>();
+ queryWrapper.select(SysClauseManagement::getClauseNum).eq(SysClauseManagement::getDelFlag, "0")
+ .eq(SysClauseManagement::getCompanyId, companyId).orderByAsc(SysClauseManagement::getClauseNum);
+ List<SysClauseManagement> sysClauseManagements = sysClauseManagementMapper.selectList(queryWrapper);
+ if (ObjectUtil.isNotEmpty(sysClauseManagements)){
+ Set<String> clauseNumSetSt = sysClauseManagements.stream()
+ .map(SysClauseManagement::getClauseNum)
+ .collect(Collectors.toSet());
- sysFunctionalDistributions.add(sysFunctionalDistribution);
+ for (String s : clauseNumSetSt) {
+ SysFunctionalDistribution sysFunctionalDistribution = new SysFunctionalDistribution();
+ sysFunctionalDistribution.setDeptId(deptVo.getDeptId());
+ sysFunctionalDistribution.setCompanyId(companyId);
+ sysFunctionalDistribution.setCreateBy(SecurityUtils.getUsername());
+ sysFunctionalDistribution.setCreateTime(LocalDateTime.now());
+ sysFunctionalDistribution.setClauseNum(s);
+ if (clauseNumMap.isEmpty()){
+ sysFunctionalDistribution.setChooseLab(0);
+ }else if (clauseNumMap.containsKey(s)){
+ sysFunctionalDistribution.setChooseLab(1);
+ if (deptVo.getDeptType().equals("0")){
+ Integer i = clauseNumSetNum.get(s);
+ if (i == null){
+ i = 0;
+ clauseNumSetNum.put(s, ++i);
+ }else {
+ clauseNumSetNum.put(s, ++i);
+ clauseNumSet.add(s);
+ }
+ }
+ }else {
+ sysFunctionalDistribution.setChooseLab(0);
+ }
+
+ sysFunctionalDistributions.add(sysFunctionalDistribution);
+ }
+ }else {
+ throw new ApiException("请先初始化条款!");
}
+// for (String s : DEPT_ROOT) {
+// SysFunctionalDistribution sysFunctionalDistribution = new SysFunctionalDistribution();
+// sysFunctionalDistribution.setDeptId(deptVo.getDeptId());
+// sysFunctionalDistribution.setCompanyId(companyId);
+// sysFunctionalDistribution.setCreateBy(SecurityUtils.getUsername());
+// sysFunctionalDistribution.setCreateTime(LocalDateTime.now());
+// sysFunctionalDistribution.setClauseNum(s);
+// if (clauseNumMap.isEmpty()){
+// sysFunctionalDistribution.setChooseLab(0);
+// }else if (clauseNumMap.containsKey(s)){
+// sysFunctionalDistribution.setChooseLab(1);
+// if (deptVo.getDeptType().equals("0")){
+// Integer i = clauseNumSetNum.get(s);
+// if (i == null){
+// i = 0;
+// clauseNumSetNum.put(s, ++i);
+// }else {
+// clauseNumSetNum.put(s, ++i);
+// clauseNumSet.add(s);
+// }
+// }
+// }else {
+// sysFunctionalDistribution.setChooseLab(0);
+// }
+//
+// sysFunctionalDistributions.add(sysFunctionalDistribution);
+// }
}
int i = sysFunctionalDistributionMapper.batchInsert(sysFunctionalDistributions);
+ if (clauseNumSet.size() > 0){
+ List<SysFunctionalRemark> sysFunctionalRemarks = new ArrayList<>();
+ for (String clauseNum : clauseNumSet) {
+ SysFunctionalRemark sysFunctionalRemark = new SysFunctionalRemark();
+ sysFunctionalRemark.setCompanyId(companyId);
+ sysFunctionalRemark.setClauseNum(clauseNum);
+ sysFunctionalRemark.setRemark(" ");
+ sysFunctionalRemark.setCreateBy(SecurityUtils.getUsername());
+ sysFunctionalRemark.setCreateTime(LocalDateTime.now());
+ sysFunctionalRemarks.add(sysFunctionalRemark);
+ }
+ int j = sysFunctionalRemarkMapper.batchInsert(sysFunctionalRemarks);
+ }
if (i < 1){
throw new ApiException("初始化失败!");
}
@@ -482,6 +532,7 @@
}
@Override
+ @Transactional(rollbackFor = RuntimeException.class)
public int saveFunctionalDistribution(FunctionalDistributionVo reqVo) {
// Long companyId = SecurityUtils.getCompanyId();
// if (!companyId.equals(reqVo.getCompanyId())){
@@ -490,17 +541,36 @@
List<SysFunctionalDistribution> list = reqVo.getList();
if (list != null && !list.isEmpty())
{
- for (SysFunctionalDistribution sysFunctionalDistribution : list) {
- sysFunctionalDistribution.setCompanyId(reqVo.getCompanyId());
- sysFunctionalDistribution.setUpdateBy(SecurityUtils.getUsername());
- sysFunctionalDistribution.setUpdateTime(LocalDateTime.now());
- }
+ list.forEach(e ->{
+ e.setCompanyId(reqVo.getCompanyId());
+ e.setUpdateBy(SecurityUtils.getUsername());
+ e.setUpdateTime(LocalDateTime.now());
+ });
+ int i = sysFunctionalDistributionMapper.batchUpdate(list);
}
- int i = sysFunctionalDistributionMapper.batchUpdate(list);
+
+ List<SysFunctionalRemark> remarks = reqVo.getRemarks();
+ if (remarks != null && !remarks.isEmpty())
+ {
+ sysFunctionalRemarkMapper.delByCompanyId(reqVo.getCompanyId());
+
+ remarks.forEach(e ->{
+ e.setCompanyId(reqVo.getCompanyId());
+ e.setCreateBy(SecurityUtils.getUsername());
+ e.setCreateTime(LocalDateTime.now());
+ });
+
+ int i1 = sysFunctionalRemarkMapper.batchInsert(remarks);
+ }
return 1;
}
+ @Override
+ public List<SysFunctionalRemark> getFunctionalRemarkList(Long companyId) {
+ return sysFunctionalRemarkMapper.selectListVo(companyId);
+ }
+
private void batchSaveRespon(SysDeptResponsibilityReqVo reqVo) {
List<Long> delData = reqVo.getDelData();
--
Gitblit v1.9.2