7325ff87a9ce38ae8141f70d776bde9a1ab8b6a7.svn-base
4.97 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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/**
* Copyright © 2015-2018 ODM All rights reserved.
*/
package com.thinkgem.jeesite.modules.oa.web;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.modules.sys.entity.User;
import com.thinkgem.jeesite.modules.sys.utils.UserUtils;
import com.thinkgem.jeesite.modules.oa.entity.TestAudit;
import com.thinkgem.jeesite.modules.oa.service.TestAuditService;
/**
* 审批Controller
* @author thinkgem
* @version 2014-05-16
*/
@Controller
@RequestMapping(value = "${adminPath}/oa/testAudit")
public class TestAuditController extends BaseController {
@Autowired
private TestAuditService testAuditService;
@ModelAttribute
public TestAudit get(@RequestParam(required=false) String id){//,
// @RequestParam(value="act.procInsId", required=false) String procInsId) {
TestAudit testAudit = null;
if (StringUtils.isNotBlank(id)){
testAudit = testAuditService.get(id);
// }else if (StringUtils.isNotBlank(procInsId)){
// testAudit = testAuditService.getByProcInsId(procInsId);
}
if (testAudit == null){
testAudit = new TestAudit();
}
return testAudit;
}
@RequiresPermissions("oa:testAudit:view")
@RequestMapping(value = {"list", ""})
public String list(TestAudit testAudit, HttpServletRequest request, HttpServletResponse response, Model model) {
User user = UserUtils.getUser();
if (!user.isAdmin()){
testAudit.setCreateBy(user);
}
Page<TestAudit> page = testAuditService.findPage(new Page<TestAudit>(request, response), testAudit);
model.addAttribute("page", page);
return "modules/oa/testAuditList";
}
/**
* 申请单填写
* @param testAudit
* @param model
* @return
*/
@RequiresPermissions("oa:testAudit:view")
@RequestMapping(value = "form")
public String form(TestAudit testAudit, Model model) {
String view = "testAuditForm";
// 查看审批申请单
if (StringUtils.isNotBlank(testAudit.getId())){//.getAct().getProcInsId())){
// 环节编号
String taskDefKey = testAudit.getAct().getTaskDefKey();
// 查看工单
if(testAudit.getAct().isFinishTask()){
view = "testAuditView";
}
// 修改环节
else if ("modify".equals(taskDefKey)){
view = "testAuditForm";
}
// 审核环节
else if ("audit".equals(taskDefKey)){
view = "testAuditAudit";
// String formKey = "/oa/testAudit";
// return "redirect:" + ActUtils.getFormUrl(formKey, testAudit.getAct());
}
// 审核环节2
else if ("audit2".equals(taskDefKey)){
view = "testAuditAudit";
}
// 审核环节3
else if ("audit3".equals(taskDefKey)){
view = "testAuditAudit";
}
// 审核环节4
else if ("audit4".equals(taskDefKey)){
view = "testAuditAudit";
}
// 兑现环节
else if ("apply_end".equals(taskDefKey)){
view = "testAuditAudit";
}
}
model.addAttribute("testAudit", testAudit);
return "modules/oa/" + view;
}
/**
* 申请单保存/修改
* @param testAudit
* @param model
* @param redirectAttributes
* @return
*/
@RequiresPermissions("oa:testAudit:edit")
@RequestMapping(value = "save")
public String save(TestAudit testAudit, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, testAudit)){
return form(testAudit, model);
}
testAuditService.save(testAudit);
addMessage(redirectAttributes, "提交审批'" + testAudit.getUser().getName() + "'成功");
return "redirect:" + adminPath + "/act/task/todo/";
}
/**
* 工单执行(完成任务)
* @param testAudit
* @param model
* @return
*/
@RequiresPermissions("oa:testAudit:edit")
@RequestMapping(value = "saveAudit")
public String saveAudit(TestAudit testAudit, Model model) {
if (StringUtils.isBlank(testAudit.getAct().getFlag())
|| StringUtils.isBlank(testAudit.getAct().getComment())){
addMessage(model, "请填写审核意见。");
return form(testAudit, model);
}
testAuditService.auditSave(testAudit);
return "redirect:" + adminPath + "/act/task/todo/";
}
/**
* 删除工单
* @param id
* @param redirectAttributes
* @return
*/
@RequiresPermissions("oa:testAudit:edit")
@RequestMapping(value = "delete")
public String delete(TestAudit testAudit, RedirectAttributes redirectAttributes) {
testAuditService.delete(testAudit);
addMessage(redirectAttributes, "删除审批成功");
return "redirect:" + adminPath + "/oa/testAudit/?repage";
}
}