4eefb9050a862311914c438b1c494201fcf285ba.svn-base
3.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* There are <a href="">JeeSite</a> code generation
*/
package com.thinkgem.jeesite.modules.oa.web;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.common.collect.Maps;
import com.thinkgem.jeesite.common.mapper.JsonMapper;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.oa.entity.Leave;
import com.thinkgem.jeesite.modules.oa.service.LeaveService;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
/**
* 请假Controller
* @author liuj
* @version 2013-04-05
*/
@Controller
@RequestMapping(value = "${adminPath}/oa/leave")
public class LeaveController extends BaseController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
protected LeaveService leaveService;
@Autowired
protected RuntimeService runtimeService;
@Autowired
protected TaskService taskService;
@RequiresPermissions("oa:leave:view")
@RequestMapping(value = {"form"})
public String form(Leave leave, Model model) {
model.addAttribute("leave", leave);
return "modules/oa/leaveForm";
}
/**
* 启动请假流程
* @param leave
*/
@RequiresPermissions("oa:leave:edit")
@RequestMapping(value = "save", method = RequestMethod.POST)
public String save(Leave leave, RedirectAttributes redirectAttributes) {
try {
Map<String, Object> variables = Maps.newHashMap();
leaveService.save(leave, variables);
addMessage(redirectAttributes, "流程已启动,流程ID:" + leave.getProcessInstanceId());
} catch (Exception e) {
logger.error("启动请假流程失败:", e);
addMessage(redirectAttributes, "系统内部错误!");
}
return "redirect:" + adminPath + "/oa/leave/form";
}
/**
* 任务列表
* @param leave
*/
@RequiresPermissions("oa:leave:view")
@RequestMapping(value = {"list/task",""})
public String taskList(HttpSession session, Model model) {
String userId = UserUtils.getUser().getLoginName();//ObjectUtils.toString(UserUtils.getUser().getId());
List<Leave> results = leaveService.findTodoTasks(userId);
model.addAttribute("leaves", results);
return "modules/oa/leaveTask";
}
/**
* 读取所有流程
* @return
*/
@RequiresPermissions("oa:leave:view")
@RequestMapping(value = {"list"})
public String list(Leave leave, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<Leave> page = leaveService.find(new Page<Leave>(request, response), leave);
model.addAttribute("page", page);
return "modules/oa/leaveList";
}
/**
* 读取详细数据
* @param id
* @return
*/
@RequestMapping(value = "detail/{id}")
@ResponseBody
public String getLeave(@PathVariable("id") String id) {
Leave leave = leaveService.get(id);
return JsonMapper.getInstance().toJson(leave);
}
/**
* 读取详细数据
* @param id
* @return
*/
@RequestMapping(value = "detail-with-vars/{id}/{taskId}")
@ResponseBody
public String getLeaveWithVars(@PathVariable("id") String id, @PathVariable("taskId") String taskId) {
Leave leave = leaveService.get(id);
Map<String, Object> variables = taskService.getVariables(taskId);
leave.setVariables(variables);
return JsonMapper.getInstance().toJson(leave);
}
}