基于javaweb+mysql的ssm+mavenoa办公管理系统(java+layui+ssm+maven+mysql+jsp)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SSM+Mavenoa办公管理系统(java+layui+ssm+maven+mysql+jsp)
一、项目运行 环境配置:
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
项目技术:
JSP +Spring + SpringMVC + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
}
@Override
public JSONObject historicTaskInstanceQuery(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
/** 从SecurityUtils中获取自身的工号*/
String number = SecurityUtils.getSubject().getPrincipal().toString();
if (number == null) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
return json;
}
/** 获取进程引擎*/
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
List<ProcessTask> processTaskList = new ArrayList<>();
/** 得到历史的服务*/
HistoryService historyService = processEngine.getHistoryService();
List<HistoricTaskInstance> list = historyService.createHistoricTaskInstanceQuery().taskAssignee(number).finished().list();
for (HistoricTaskInstance hti : list) {
ProcessTask processTask = new ProcessTask();
processTask.setProcessTaskId(hti.getId());
processTask.setProcessTaskName(hti.getName());
processTask.setProcessTaskExecutionId(hti.getExecutionId());
processTask.setCreateTime(hti.getCreateTime());
processTask.setProcessTaskAssignee(hti.getAssignee());
processTask.setProcessTaskTenantId(hti.getTenantId());
Leave leave = leaveDao.selectLeaveByProcessInstanceId(hti.getExecutionId());
if (leave != null) processTask.setLeave(leave);
processTaskList.add(processTask);
}
json.put("type", "success");
json.put("msg", "获取数据成功!");
json.put("code", 0);
json.put("count", processTaskList.size());
json.put("data", processTaskList);
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
}
json.put("msg", "删除菜单成功!");
return json;
}
} catch (Exception e) {
json.put("tpe", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "删除菜单失败!");
return json;
}
/**
* 获取全部菜单树型信息
* @param request
* @return
*/
@RequestMapping("/getMenuAllTree")
@ResponseBody
public List<Menu> getMenuAllTree(HttpServletRequest request){
List<Menu> menuList = new ArrayList<>();
int roleId = Integer.parseInt(request.getParameter("roleId"));
List<Menu> menuByRoleId = menuService.getMenuByRoleId(roleId);
List<Menu> menuAll = menuService.getMenuAll(0, 999);
for(Menu menu : menuAll){
menu.setDisabled(!menu.isStart()); //是否禁用
for(Menu menu1: menuByRoleId){
if(menu.getId().equals(menu1.getId())){
//如果相等
menu.setSpread(true); //展开
menu.setChecked(true); //选中
//是否是一级
for(Menu menu2 : menuAll){
if(menu.getId().equals(menu2.getPid())){
menu.setChecked(false); //取消勾选
}
}
}
}
}
//整理成树型
for(Menu menu : menuAll){
if(menu.getPid().equals(-1)){
List<Menu> menuList1 = new ArrayList<>();
@Transactional
@Service("/processService")
public class ProcessServiceImpl implements ProcessService {
@Autowired
private LeaveDao leaveDao;
@Override
public JSONObject getHistoricProcessInstanceAll(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
/**
* 分页处理
*/
String page = request.getParameter("page");
String limit = request.getParameter("limit");
if (page == null || limit == null) {
json.put("type", "error");
json.put("msg", "获取分页数据失败!");
return json;
}
int pageInt = Integer.parseInt(page);
int limitInt = Integer.parseInt(limit);
/**
* 流程处理
*/
/** 1.创建进程引擎*/
ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine();
/** 2.获取进程历史服务*/
HistoryService historyService = processEngine.getHistoryService();
/** 3.创建历史流程实例查询,按进程定义Id排序,降序排列,集合分页*/
List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().orderByProcessDefinitionId().desc().listPage((pageInt - 1) * limitInt, limitInt);
/**
* json封装
*/
* @return
*/
@RequestMapping("/addNotice")
@ResponseBody
public JSONObject addNotice(HttpServletRequest request) {
return noticeService.addNotice(request);
}
/**
* 删除系统公告信息
*
* @param request
* @return
*/
@RequestMapping("/deleteNotice")
@ResponseBody
public JSONObject deleteNotice(HttpServletRequest request) {
return noticeService.deleteNotice(request);
}
/**
* 修改系统公告信息
*
* @param request
* @return
*/
@RequestMapping("/updateNotice")
@ResponseBody
public JSONObject updateNotice(HttpServletRequest request) {
return noticeService.updateNotice(request);
}
/**
* 已阅读系统公告
*
* @param request
* @return
*/
@RequestMapping("/flagNotice")
@ResponseBody
public JSONObject flagNotice(HttpServletRequest request) {
return noticeService.flagNotice(request);
}
/**
* 批量发布系统公告
*
* @param request
* @return
*/
@RequestMapping("/bulkReleaseNotice")
@ResponseBody
public JSONObject bulkReleaseNotice(HttpServletRequest request) {
return noticeService.bulkReleaseNotice(request);
* @return
*/
@RequestMapping("/updateMenu")
@ResponseBody
public JSONObject updateMenu(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
Menu menu = JSONObject.parseObject(request.getParameter("menu"), Menu.class);
if (menuService.updateMenu(menu) > 0) {
json.put("type", "success");
json.put("msg", "修改菜单成功!");
return json;
}
} catch (Exception e) {
json.put("tpe", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "修改菜单失败!");
return json;
}
/**
* 删除菜单
*
* @param request
* @return
*/
@RequestMapping("/deleteMenu")
@ResponseBody
public JSONObject deleteMenu(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
int menuId = Integer.parseInt(request.getParameter("menuId"));
if (menuService.deleteMenu(menuId) > 0) {
json.put("type", "success");
json.put("msg", "删除菜单成功!");
return json;
}
} catch (Exception e) {
json.put("tpe", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "删除菜单失败!");
if (employeeDao.verifyEmployeeNumber(employee) > 0) {
json.put("type", "error");
json.put("msg", "该工号已被使用,请使用别的工号");
return json;
}
if (employeeDao.verifyEmployeePhone(employee) > 0) {
json.put("type", "error");
json.put("msg", "该手机号已被使用,请使用别的手机号");
return json;
}
if (employeeDao.updateEmployeeAdmin(employee) > 0) {
json.put("type", "success");
json.put("msg", "修改雇员成功");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "修改雇员失败");
return json;
}
@Override
public JSONObject deleteEmployee(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String employeeId = request.getParameter("employeeId");
if (employeeDao.deleteEmployee(Integer.parseInt(employeeId)) > 0) {
json.put("type", "success");
json.put("msg", "删除雇员成功");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "删除雇员失败");
return json;
}
int limit = Integer.parseInt(request.getParameter("limit"));
List<Leave> leaves = leaveDao.selectLeaveAllApproval(approved, (page - 1) * limit, limit);
json.put("type", "success");
json.put("msg", "获取数据成功!");
json.put("code", 0);
json.put("count", leaveDao.selectLeaveAllApprovalCount(approved));
json.put("data", leaves);
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
@Override
public JSONObject updateLeaveApproval(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String leaveStr = request.getParameter("leave");
if (leaveStr == null) {
json.put("type", "error");
json.put("msg", "数据获取失败!");
return json;
}
Leave leave = JSONObject.parseObject(leaveStr, Leave.class);
if (leaveDao.updateLeaveApproval(leave) > 0) {
json.put("type", "success");
json.put("msg", "审批成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "审批失败!");
return json;
}
}
* @param request
* @return
*/
@RequestMapping("/getHistoricProcessInstanceAll")
@ResponseBody
public JSONObject getHistoricProcessInstanceAll(HttpServletRequest request) {
return processService.getHistoricProcessInstanceAll(request);
}
/**
* 查看流程状态
*
* @param request
* @return
*/
@RequestMapping("/checkProcessStatus")
@ResponseBody
public JSONObject checkProcessStatus(HttpServletRequest request) {
return processService.checkProcessStatus(request);
}
/**
* 流程实例开关
*
* @param request
* @return
*/
@RequestMapping("/switchProcessInstance")
@ResponseBody
public JSONObject switchProcessInstance(HttpServletRequest request) {
return processService.switchProcessInstance(request);
}
/**
* 历史任务实例查询
*
* @param request
* @return
*/
@RequestMapping("/historicTaskInstanceQuery")
@ResponseBody
//整理成树型
for(Menu menu : menuAll){
if(menu.getPid().equals(-1)){
List<Menu> menuList1 = new ArrayList<>();
for(Menu menu1 : menuAll){
if(menu.getId().equals(menu1.getPid())){
menuList1.add(menu1);
}
}
if(menuList1.size() > 0){
menu.setChildren(menuList1);
}
menuList.add(menu);
}
}
return menuList;
}
}
@Transactional
@Service("/permissionsService")
public class PermissionsServiceImpl implements PermissionsService {
@Autowired
private PermissionsDao permissionsDao;
@Override
return json;
}
@Override
public JSONObject queryingSystemMessages(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String employeeNumber = SecurityUtils.getSubject().getPrincipal().toString(); //得到自身工号
if (employeeNumber == null) {
json.put("type", "error");
json.put("msg", "获取数据失败!");
return json;
}
List<Notice> notices = noticeDao.queryingSystemMessages(employeeNumber);
json.put("type", "success");
json.put("msg", "获取数据成功!");
json.put("code", 0);
json.put("count", notices.size());
json.put("data", notices);
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
@Override
public JSONObject noticeRead(HttpServletRequest request) {
JSONObject json = new JSONObject();
try{
int nerId;
String nerIdStr = request.getParameter("nerId");
if(nerIdStr == null){
json.put("type","error");
json.put("msg","获取数据失败!");
return json;
}
nerId = Integer.parseInt(nerIdStr);
if( noticeDao.noticeRead(nerId) > 0){
json.put("type","success");
json.put("msg","阅读成功!");
return json;
}
}catch (Exception e){
json.put("type","error");
json.put("msg",MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type","error");
*/
@RequestMapping("/getRoleAll")
@ResponseBody
public JSONObject getRoleAll() {
JSONObject json = new JSONObject();
List<Role> roles = roleService.selectRoleAll();
json.put("code", 0);
json.put("msg", "");
json.put("count", roles.size());
json.put("data", roles);
return json;
}
/**
* 设置角色菜单
*
* @param request
* @return
*/
@RequestMapping("/setRoleJurisdiction")
@ResponseBody
public JSONObject setRoleJurisdiction(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
/** 角色ID*/
String roleId = request.getParameter("roleId");
/** 菜单ID数组*/
Integer[] menuIds = JSONObject.parseObject(request.getParameter("menuIdList"), Integer[].class);
roleService.batchDeleteRoleByMenu(Integer.parseInt(roleId)); //先删除
if (roleService.batchAddRoleByMenu(Integer.parseInt(roleId), menuIds) > 0) { // 后添加
json.put("type", "success");
json.put("msg", "设置角色菜单成功");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", "系统错误!请联系管理员");
System.out.println(e.getMessage());
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); //回滚
}
json.put("type", "error");
json.put("msg", "设置角色菜单失败!");
return json;
}
/**
* 设置角色权限
*
* @param request
* @return
*/
@RequestMapping("/setRolePermissions")
@Transactional
@Service("/permissionsService")
public class PermissionsServiceImpl implements PermissionsService {
@Autowired
private PermissionsDao permissionsDao;
@Override
public JSONObject getPermissionsAll(HttpServletRequest request) {
JSONObject json = new JSONObject();
int page = Integer.parseInt(request.getParameter("page"));
int limit = Integer.parseInt(request.getParameter("limit"));
List<Permissions> permissions = permissionsDao.selectPermissionsAll((page - 1) * limit, limit);
json.put("code", 0);
json.put("msg", "");
json.put("count", permissionsDao.selectPermissionsAllCount());
json.put("data", permissions);
return json;
}
@Override
public JSONObject updatePermissions(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String permissionsJSON = request.getParameter("permissions");
if (permissionsJSON == null) {
json.put("type", "error");
json.put("msg", "获取数据为空!");
return json;
}
Permissions permissions = JSONObject.parseObject(permissionsJSON, Permissions.class);
if (permissionsDao.updatePermissions(permissions) > 0) {
json.put("type", "success");
json.put("msg", "修改权限成功!");
return json;
}
if (menuList2.size() > 0) menu.setChildren(menuList2);
menuList.add(menu);
}
}
return menuList;
}
}
@Controller
@RequestMapping("/role")
public class RoleController {
@Autowired
private RoleService roleService;
/**
* 页面跳转
*
* @param request
* @return
*/
@RequestMapping("/toPage")
public String toPage(HttpServletRequest request) {
String url = "sys/role/role";
String page = request.getParameter("page");
if (page != null) {
url = page;
}
return url;
}
/**
* 添加角色
json.put("msg", "修改权限成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "修改权限失败!");
return json;
}
@Override
public JSONObject addPermissions(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String permissionsJSON = request.getParameter("permissions");
if (permissionsJSON == null) {
json.put("type", "error");
json.put("msg", "获取数据为空!");
return json;
}
Permissions permissions = JSONObject.parseObject(permissionsJSON, Permissions.class);
if (permissionsDao.addPermissions(permissions) > 0) {
json.put("type", "success");
json.put("msg", "添加权限成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "添加权限失败!");
return json;
}
@Override
public JSONObject deletePermissions(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String permissionsIdList = request.getParameter("permissionsIdList");
if (permissionsIdList == null) {
json.put("type", "error");
json.put("msg", "获取数据为空!");
return json;
}
Integer[] integers = JSONObject.parseObject(permissionsIdList, Integer[].class);
if (permissionsDao.deletePermissions(integers) > 0) {
json.put("type", "success");
String limitStr = request.getParameter("limit");
if (pageStr == null || limitStr == null) {
json.put("type", "error");
json.put("msg", "获取数据失败!");
return json;
}
page = Integer.parseInt(pageStr);
limit = Integer.parseInt(limitStr);
List<Stationery> stationeries = stationeryDao.selectStationeryAll((page - 1) * limit, limit);
json.put("type", "success");
json.put("msg", "获取数据成功!");
json.put("code", 0);
json.put("count", stationeryDao.selectStationeryAllCount());
json.put("data", stationeries);
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
return json;
}
@Override
public JSONObject getHistoryOfOfficeSupplies(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
int page;
int limit;
String pageStr = request.getParameter("page");
String limitStr = request.getParameter("limit");
String employeeNumber = SecurityUtils.getSubject().getPrincipal().toString(); //得到自身工号
if (pageStr == null || limitStr == null || employeeNumber == null) {
json.put("type", "error");
json.put("msg", "获取数据失败!");
return json;
}
page = Integer.parseInt(pageStr);
limit = Integer.parseInt(limitStr);
List<StationeryProposer> stationeryProposers = stationeryDao.selectStationeryByEmployeeNumber(employeeNumber, (page - 1) * limit, limit);
json.put("type", "success");
json.put("msg", "获取数据成功!");
return json;
}
@Override
public JSONObject deleteEmployee(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String employeeId = request.getParameter("employeeId");
if (employeeDao.deleteEmployee(Integer.parseInt(employeeId)) > 0) {
json.put("type", "success");
json.put("msg", "删除雇员成功");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
}
json.put("type", "error");
json.put("msg", "删除雇员失败");
return json;
}
@Override
public JSONObject updateRole(HttpServletRequest request) {
JSONObject json = new JSONObject();
try {
String employeeIdList = request.getParameter("employeeIdList");
String roleId = request.getParameter("roleId");
if (employeeIdList == null || roleId == null) {
json.put("type", "error");
json.put("msg", "null");
return json;
}
Integer[] employeeIdLists = JSONObject.parseObject(employeeIdList, Integer[].class);
if (employeeDao.batchUpdateEmployeeByRoleId(employeeIdLists, Integer.parseInt(roleId)) > 0) {
json.put("type", "success");
json.put("msg", "修改角色成功!");
return json;
}
} catch (Exception e) {
json.put("type", "error");
json.put("msg", MessageError.SYSTEM_ERROR);
System.out.println(e.getMessage());
return json;
@ResponseBody
public JSONObject addStationery(HttpServletRequest request) {
return stationeryService.addStationery(request);
}
/**
* 修改办公用品信息
*
* @param request
* @return
*/
@RequestMapping("/updateStationery")
@ResponseBody
public JSONObject updateStationery(HttpServletRequest request) {
return stationeryService.updateStationery(request);
}
/**
* 删除办公用品
*
* @param request
* @return
*/
@RequestMapping("/deleteStationery")
@ResponseBody
public JSONObject deleteStationery(HttpServletRequest request) {
return stationeryService.deleteStationery(request);
}
/**
* 添加新办公用品数量
*
* @param request
* @return
*/
@RequestMapping("/addStationeryAdd")
@ResponseBody
public JSONObject addStationeryAdd(HttpServletRequest request) {
return stationeryService.addStationeryAdd(request);
}
/**
* 获取添加新办公用品数量历史信息
*
* @param request
* @return
*/
@RequestMapping("/getStationeryAddHistory")
@ResponseBody