| | |
| | | |
| | | |
| | | 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.*; |
| | |
| | | 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.*; |
| | |
| | | |
| | | public List<DeptVo> selectDeptList(SysDept dept) |
| | | { |
| | | if (dept.getCompanyId() == null){ |
| | | dept.setCompanyId(SecurityUtils.getCompanyId()); |
| | | } |
| | | return deptMapper.selectDeptList(dept); |
| | | } |
| | | |
| | |
| | | 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()) |
| | |
| | | @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); |
| | |
| | | } |
| | | |
| | | @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("部门名称已存在!"); |
| | |
| | | delCaluse(sysDept.getDeptId(), delCaluseIds); |
| | | } |
| | | //处理条款 |
| | | batchSaveCaluse(sysDept.getDeptId(), companyId, dept.getCaluseVO1List()); |
| | | batchSaveCaluse(sysDept.getDeptId(), dept.getCompanyId(), dept.getCaluseVO1List()); |
| | | |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @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(); |
| | |
| | | |
| | | @Override |
| | | public List<SysFunctionalDistribution> getFunctionalDistributionList(Long companyId) { |
| | | if (companyId != null){ |
| | | companyId = SecurityUtils.getCompanyId(); |
| | | } |
| | | 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); |
| | |
| | | |
| | | @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("保存失败!"); |
| | |
| | | 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("部门条款编码重复!"); |
| | | } |
| | |
| | | .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) { |
| | |
| | | .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("部门条款编码重复!"); |
| | | } |
| | |
| | | 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()); |