package com.noa.service.impl;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import com.noa.mapper.SysMapper;
import com.noa.po.EmployeeCustom;
import com.noa.po.SysDepartment;
import com.noa.po.SysPosition;
import com.noa.service.SysService;
@Service
public class SysServiceImpl implements SysService {
@Autowired
private SysMapper sysMapper;
public List<SysDepartment> getAllDepartment() throws Exception {
return sysMapper.getAllDepartment();
}
public List<SysPosition> getAllPosition() throws Exception {
return sysMapper.getAllPosition();
}
public List<String> getPermissionByEmpId(Integer empId) throws Exception {
return sysMapper.getPermissionByEmpId(empId);
}
public List<Integer> getSubDepByMain(Integer mainDep) throws Exception {
List<SysDepartment> allDep = getAllDepartment();
List<Integer> subDepList = new ArrayList<Integer>();
for (SysDepartment dep : allDep) {
int depId = dep.getDepartmentId();
if ((depId / 10) * 10 == mainDep) {
// 是mainDep下的部门 (包括main)
subDepList.add(depId);
}
}
// subDepList = {main,sub1,sub2,...}
return subDepList;
}
public List<SysDepartment> getDepsByDepIds(List<Integer> depIds) throws Exception {
return sysMapper.getDepByDepIds(depIds);
}
// 获取可布置任务的对象
public List<SysDepartment> getAbleToPostDeps() throws Exception {
// 获取权限
Subject subject = SecurityUtils.getSubject();
EmployeeCustom activeEmp = (EmployeeCustom) subject.getPrincipal();
int activeEmpDep = activeEmp.getDepartmentId();
List<Integer> depIds = new ArrayList<Integer>();
// 根据权限添加,可布置任务的对象
if (subject.isPermitted("mission:create:all")) { // 有发布全体的的权限
depIds.add(0);
}
if (subject.isPermitted("mission:create:main")) {
depIds.addAll(getSubDepByMain((activeEmpDep / 10) * 10));
} else if (subject.isPermitted("mission:create:sub")) {// 只有发布自己的子部门的权限
if (activeEmpDep % 10 != 0) {
depIds.add(activeEmpDep);
}
}
if (depIds.isEmpty()) {
return null;
}
return getDepsByDepIds(depIds);
}
// 获取可发布公告的对象
public List<SysDepartment> getAbleToAnnounceDeps() throws Exception {
// 获取权限
Subject subject = SecurityUtils.getSubject();
EmployeeCustom activeEmp = (EmployeeCustom) subject.getPrincipal();
int activeEmpDep = activeEmp.getDepartmentId();
List<Integer> depIds = new ArrayList<Integer>();
// 根据权限添加,可发布公告的对象
if (subject.isPermitted("announce:create:all")) { // 有发布全体的的权限
depIds.add(0);
}
if (subject.isPermitted("announce:create:main")) {
depIds.addAll(getSubDepByMain((activeEmpDep / 10) * 10));
} else if (subject.isPermitted("announce:create:sub")) {// 只有发布自己的子部门的权限
if (activeEmpDep % 10 != 0) {
depIds.add(activeEmpDep);
}
}
if (depIds.isEmpty()) {
return null;
}
return getDepsByDepIds(depIds);
}
// 获取可注册的岗位
public List<SysPosition> getAbleToRegPos() throws Exception {
List<SysPosition> allPositions = getAllPosition();
List<SysPosition> resultList = new ArrayList<SysPosition>();
// 截掉不可注册的
for (SysPosition posistion : allPositions) {
if (posistion.getAvailable() != 0) {
resultList.add(posistion);
}
}
return resultList;
}
// 获取可注册的部门
public List<SysDepartment> getAbleToRegDep(Integer posId) throws Exception {
List<SysDepartment> allDepartments = getAllDepartment();
List<SysDepartment> resultList = new ArrayList<SysDepartment>();
// 截掉不可注册的
for (SysDepartment department : allDepartments) {
if (department.getAvailable() == 1) { // 可注册的部门
if (department.getDepartmentId() % 10 != 0 && posId <= 1) { // 无或组长
// 只能注册子部门
resultList.add(department);
} else if (department.getDepartmentId() % 10 == 0 && posId > 1) { // 总监或经理,只能注册大部门
resultList.add(department);
}
}
}
return resultList;
}
// 上传图片
public String uploadPic(String dir, MultipartFile pic) throws Exception {
// 上传图片
// 原始名称
String originalFilename = pic.getOriginalFilename();
// 存储图片的物理路径
String pic_path = "D:\\Util\\develop\\upload\\" + dir + "\\";
// 新的图片名称 : 随机数 + 扩展名
String newfileNStringame = UUID.randomUUID() + originalFilename.substring(originalFilename.lastIndexOf("."));
// 新图片
File newfile = new File(pic_path + newfileNStringame);
// 将内存中的数据写入磁盘
pic.transferTo(newfile);
return newfileNStringame;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【项目资源】: 包含前端、后端、移动开发、操作系统、人工智能、物联网、信息化管理、数据库、硬件开发、大数据、课程资源、音视频、网站开发等各种技术项目的源码。 包括STM32、ESP8266、PHP、QT、Linux、iOS、C++、Java、python、web、C#、EDA、proteus、RTOS等项目的源码。 【项目质量】: 所有源码都经过严格测试,可以直接运行。 功能在确认正常工作后才上传。 【适用人群】: 适用于希望学习不同技术领域的小白或进阶学习者。 可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【附加价值】: 项目具有较高的学习借鉴价值,也可直接拿来修改复刻。 对于有一定基础或热衷于研究的人来说,可以在这些基础代码上进行修改和扩展,实现其他功能。 【沟通交流】: 有任何使用上的问题,欢迎随时与博主沟通,博主会及时解答。 鼓励下载和使用,并欢迎大家互相学习,共同进步。
资源推荐
资源详情
资源评论
收起资源包目录
毕设&课设&项目&实训-基于ssm的Web端OA系统.zip (1204个子文件)
MissionServiceImpl.class 6KB
MissionController.class 6KB
SysServiceImpl.class 6KB
AccountController.class 5KB
MailController.class 5KB
EmployeeServiceImpl.class 5KB
HomeController.class 4KB
CustomRealm.class 3KB
AnnouncementServiceImpl.class 3KB
AttendanceServiceImpl.class 3KB
Employee.class 3KB
EmployeeController.class 3KB
Mission.class 2KB
MailServiceImpl.class 2KB
Mail.class 2KB
Mail.class 2KB
Employee.class 2KB
Announcement.class 2KB
Attendance.class 2KB
Announcement.class 2KB
Mission.class 2KB
Attendance.class 1KB
SysService.class 1KB
MailCustom.class 1KB
MissionVo.class 1KB
MissionService.class 1KB
SysDepartment.class 1KB
SysPosition.class 1022B
AnnouncementCustom.class 994B
MissionMapper.class 959B
Department.class 937B
CustomFormAuthenticationFilter.class 879B
AnnouncementCustom.class 859B
MissionCustom.class 839B
EmployeeService.class 833B
EmployeeMapper.class 827B
MailMapper.class 797B
EmployeeCustom.class 778B
AnnouncementService.class 761B
AnnouncementMapper.class 731B
SysMapper.class 684B
AttendanceMapper.class 675B
AnnouncementMapper.class 652B
MailService.class 621B
CustomException.class 589B
EmployeeCustom.class 572B
MailCustom.class 568B
MailMapper.class 401B
AttendanceService.class 389B
EmployeeMapper.class 201B
.classpath 1KB
org.eclipse.wst.common.component 723B
org.eclipse.wst.jsdt.ui.superType.container 49B
app.min.css 303KB
bootstrap.css 149KB
core.css 87KB
material-design-iconic-font.css 83KB
app.css 82KB
material-design-iconic-font.min.css 69KB
animate.min.css 52KB
hamburgers.css 43KB
font-awesome.css 34KB
font-awesome.min.css 28KB
fullcalendar.css 28KB
bootstrap-datepicker3.standalone.css 23KB
bootstrap-datepicker3.css 22KB
bootstrap-datepicker3.standalone.min.css 21KB
bootstrap-datepicker3.min.css 21KB
bootstrap-datepicker.standalone.css 18KB
select2.css 17KB
bootstrap-datepicker.css 17KB
datatables.min.css 17KB
bootstrap-datepicker.standalone.min.css 16KB
bootstrap-datepicker.min.css 15KB
select2.min.css 15KB
fullcalendar.min.css 13KB
summernote.css 13KB
landing-page.css 11KB
dropzone.min.css 9KB
bootstrap-datetimepicker.css 9KB
daterangepicker.css 8KB
bootstrap-datetimepicker.min.css 8KB
bootstrap-select.css 7KB
jquery-jvectormap.css 6KB
bootstrap-select.min.css 6KB
perfect-scrollbar.css 6KB
fullcalendar.print.css 5KB
lightbox.css 4KB
lightbox.min.css 3KB
misc-pages.css 2KB
bootstrap-datetimepicker-standalone.css 2KB
owl.carousel.css 1KB
bootstrap-tagsinput.css 1KB
bootstrap-tagsinput-typeahead.css 1017B
jquery.bootstrap-touchspin.css 1016B
switchery.css 994B
jquery.bootstrap-touchspin.min.css 899B
switchery.min.css 682B
.DS_Store 6KB
fontawesome-webfont.eot 75KB
共 1204 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
妄北y
- 粉丝: 1w+
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功