From d7471cff04678b91271bdc566bcbddf2f4ab04b7 Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: 星期五, 04 七月 2025 15:17:08 +0800
Subject: [PATCH] 修改
---
multi-system/src/main/java/com/gkhy/exam/system/service/impl/SysDeptServiceImpl.java | 77 ++++++++++++++++++++++++--------------
1 files changed, 49 insertions(+), 28 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 a35cc97..4f5bd1a 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
@@ -2,21 +2,17 @@
import cn.hutool.core.convert.Convert;
-import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.gkhy.exam.common.constant.Constants;
import com.gkhy.exam.common.constant.UserConstant;
import com.gkhy.exam.common.domain.TreeSelect;
import com.gkhy.exam.common.domain.entity.SysDept;
import com.gkhy.exam.common.domain.entity.SysRole;
-import com.gkhy.exam.common.domain.entity.SysUser;
import com.gkhy.exam.common.exception.ApiException;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.common.utils.SpringUtils;
-import com.gkhy.exam.system.domain.ExPaperStudent;
import com.gkhy.exam.system.domain.SysDeptResponsibility;
import com.gkhy.exam.system.domain.SysFunctionalDistribution;
import com.gkhy.exam.system.domain.vo.*;
@@ -28,6 +24,7 @@
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.*;
@@ -64,6 +61,9 @@
public List<DeptVo> selectDeptList(SysDept dept)
{
+ if (dept.getCompanyId() == null){
+ dept.setCompanyId(SecurityUtils.getCompanyId());
+ }
return deptMapper.selectDeptList(dept);
}
@@ -208,7 +208,7 @@
public boolean checkDeptNameUnique(SysDept dept)
{
Long deptId = ObjectUtil.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
- Long companyId = SecurityUtils.getLoginUser().getUser().getCompanyId();
+ Long companyId = SecurityUtils.getCompanyId();
SysDept info = deptMapper.checkDeptNameUnique(companyId,dept.getDeptName(), dept.getParentId());
if (ObjectUtil.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
@@ -226,7 +226,7 @@
@Override
public void checkDeptDataScope(Long deptId)
{
- if (!SecurityUtils.isAdmin(SecurityUtils.getUserId()) && ObjectUtil.isNotNull(deptId))
+ if (!SecurityUtils.adminUser() && ObjectUtil.isNotNull(deptId))
{
SysDept dept = new SysDept();
dept.setDeptId(deptId);
@@ -258,14 +258,14 @@
}
@Override
+ @Transactional
public int saveDept(SysDeptSaveDTOReq dept) {
- Long companyId = SecurityUtils.getLoginUser().getUser().getCompanyId();
- if (!companyId.equals(dept.getCompanyId())){
- throw new ApiException("无权操作!");
- }
+// Long companyId = SecurityUtils.getCompanyId();
+// if (!companyId.equals(dept.getCompanyId())){
+// throw new ApiException("无权操作!");
+// }
SysDept sysDept = new SysDept();
BeanUtils.copyProperties(dept, sysDept);
- sysDept.setCompanyId(companyId);
boolean b = checkDeptNameUnique(sysDept);
if (!b){
throw new ApiException("部门名称已存在!");
@@ -286,7 +286,7 @@
delCaluse(sysDept.getDeptId(), delCaluseIds);
}
//处理条款
- batchSaveCaluse(sysDept.getDeptId(), companyId, dept.getCaluseVO1List());
+ batchSaveCaluse(sysDept.getDeptId(), dept.getCompanyId(), dept.getCaluseVO1List());
}
@@ -294,16 +294,17 @@
}
@Override
+ @Transactional
public int saveDeptResponsibility(SysDeptResponsibilityReqVo reqVo) {
- Long companyId = SecurityUtils.getLoginUser().getUser().getCompanyId();
- if (!companyId.equals(reqVo.getCompanyId())){
- throw new ApiException("无权操作!");
- }
+// Long companyId = SecurityUtils.getCompanyId();
+// if (!companyId.equals(reqVo.getCompanyId())){
+// throw new ApiException("无权操作!");
+// }
SysDept sysDept = deptMapper.selectDeptById(reqVo.getDeptId());
if (null == sysDept){
throw new ApiException("部门不存在!");
}
- if (!companyId.equals(sysDept.getCompanyId())){
+ if (!reqVo.getCompanyId().equals(sysDept.getCompanyId())){
throw new ApiException("无权操作!");
}
SysDept dept = new SysDept();
@@ -324,17 +325,19 @@
@Override
public List<SysFunctionalDistribution> getFunctionalDistributionList(Long companyId) {
+
return sysFunctionalDistributionMapper.selectListVo(companyId);
}
@Override
+ @Transactional
public int initFunctionalDistribution(Long companyId) {
- if (!companyId.equals(SecurityUtils.getLoginUser().getUser().getCompanyId())){
- throw new ApiException("无权操作!");
- }
- sysFunctionalDistributionMapper.delete(new LambdaQueryWrapper<SysFunctionalDistribution>().eq(SysFunctionalDistribution::getCompanyId, SecurityUtils.getLoginUser().getUser().getCompanyId()));
+// if (!companyId.equals(SecurityUtils.getCompanyId())){
+// throw new ApiException("无权操作!");
+// }
+ sysFunctionalDistributionMapper.delByCompanyId(companyId);
SysDept sysDept = new SysDept();
sysDept.setCompanyId(companyId);
List<DeptVo> deptVos = deptMapper.selectDeptList(sysDept);
@@ -364,11 +367,19 @@
@Override
public int saveFunctionalDistribution(FunctionalDistributionVo reqVo) {
- Long companyId = SecurityUtils.getLoginUser().getUser().getCompanyId();
- if (!companyId.equals(reqVo.getCompanyId())){
- throw new ApiException("无权操作!");
- }
+// Long companyId = SecurityUtils.getCompanyId();
+// if (!companyId.equals(reqVo.getCompanyId())){
+// throw new ApiException("无权操作!");
+// }
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());
+ }
+ }
int i = sysFunctionalDistributionMapper.batchUpdate(list);
if (i < 1){
throw new ApiException("保存失败!");
@@ -396,9 +407,16 @@
if (emptyIdClauseNumSet.size() != emptyIdClauseNums.size()){
throw new ApiException("部门条款编码重复!");
}
+ List<Long> emptyIdClauseIds = sysDeptResponsibilityList.stream()
+ .filter(item -> item.getId() != null)
+ .map(SysDeptResponsibility::getId)
+ .collect(Collectors.toList());
+
if (!emptyIdClauseNums.isEmpty()){
List<SysDeptResponsibility> sysDeptResponsibilities = deptResponsibilityMapper.selectList(new LambdaQueryWrapper<SysDeptResponsibility>()
- .eq(SysDeptResponsibility::getDeptId, reqVo.getDeptId()).in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums));
+ .eq(SysDeptResponsibility::getDeptId, reqVo.getDeptId())
+ .in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums)
+ .notIn(SysDeptResponsibility::getId, emptyIdClauseIds).eq(SysDeptResponsibility::getDelFlag, "0"));
if (!sysDeptResponsibilities.isEmpty()){
throw new ApiException("部门条款编码重复!");
}
@@ -426,7 +444,7 @@
.update(new SysDeptResponsibility(),
new LambdaUpdateWrapper<SysDeptResponsibility>().set(SysDeptResponsibility::getDelFlag, UserConstant.DEPT_DISABLE)
.set(SysDeptResponsibility::getUpdateTime, LocalDateTime.now()).set(SysDeptResponsibility::getUpdateBy, SecurityUtils.getUsername())
- .eq(SysDeptResponsibility::getDeptId, deptId));
+ .eq(SysDeptResponsibility::getDeptId, deptId).in(SysDeptResponsibility::getId, delCaluseIds));
}
private void batchSaveCaluse(Long deptId,Long companyId, List<CaluseVO1> caluseVO1List) {
@@ -437,7 +455,8 @@
.collect(Collectors.toList());
if (!emptyIdClauseNums.isEmpty()){
List<SysDeptResponsibility> sysDeptResponsibilities = deptResponsibilityMapper.selectList(new LambdaQueryWrapper<SysDeptResponsibility>()
- .eq(SysDeptResponsibility::getDeptId, deptId).in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums));
+ .eq(SysDeptResponsibility::getDeptId, deptId).in(SysDeptResponsibility::getClauseNum, emptyIdClauseNums)
+ .eq(SysDeptResponsibility::getCompanyId, companyId).eq(SysDeptResponsibility::getDelFlag, "0"));
if (!sysDeptResponsibilities.isEmpty()){
throw new ApiException("部门条款编码重复!");
}
@@ -449,9 +468,11 @@
sysDeptResponsibility.setCompanyId(companyId);
sysDeptResponsibility.setDeptId(deptId);
+
if (sysDeptResponsibility.getId() == null){
sysDeptResponsibility.setCreateBy(SecurityUtils.getUsername());
sysDeptResponsibility.setCreateTime(LocalDateTime.now());
+ sysDeptResponsibility.setDataType("2");
deptResponsibilityMapper.insert(sysDeptResponsibility);
}else {
sysDeptResponsibility.setUpdateBy(SecurityUtils.getUsername());
--
Gitblit v1.9.2