YcslGxrController.java
7.41 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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/**
* Copyright © 2015-2018 <a href="#">J-Site</a> All rights reserved.
*/
package com.thinkgem.jeesite.modules.ycsl.web;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
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.ui.ModelMap;
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.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBasePerson;
import com.thinkgem.jeesite.modules.reg.service.base.RegBasePersonService;
import com.thinkgem.jeesite.modules.sys.utils.DictUtils;
import com.thinkgem.jeesite.modules.ycsl.entity.YcslGxr;
import com.thinkgem.jeesite.modules.ycsl.service.YcslGxrService;
/**
* 一窗受理-关系人Controller
* @author lzj
* @version 2020-12-24
*/
@Controller
@RequestMapping(value = "${adminPath}/ycsl/ycslGxr")
public class YcslGxrController extends BaseController {
@Autowired
private YcslGxrService ycslGxrService;
@Autowired
private RegBasePersonService regBasePersonService;
@ModelAttribute
public YcslGxr get(@RequestParam(required=false) String id) {
YcslGxr entity = null;
if (StringUtils.isNotBlank(id)){
entity = ycslGxrService.get(id);
}
if (entity == null){
entity = new YcslGxr();
}
return entity;
}
@RequiresPermissions("ycsl:ycslGxr:view")
@RequestMapping(value = {"list", ""})
public String list(YcslGxr ycslGxr, HttpServletRequest request, HttpServletResponse response, Model model) {
model.addAttribute("gxrlx", ycslGxr.getGxrlx());
if(StringUtils.isNotBlank(request.getParameter("view"))) {
model.addAttribute("view", request.getParameter("view"));
}
Page<YcslGxr> page = ycslGxrService.findPage(new Page<YcslGxr>(request, response), ycslGxr);
model.addAttribute("page", page);
return "modules/ycsl/ycslGxrList";
}
@RequiresPermissions("ycsl:ycslGxr:view")
@RequestMapping(value = "form")
public String form(YcslGxr ycslGxr, Model model,HttpServletRequest request) {
if(StringUtils.isNotBlank(request.getParameter("proid"))) {
model.addAttribute("proid", request.getParameter("proid"));
if(StringUtils.isBlank(request.getParameter("update"))) {//新增进入
YcslGxr YcslGxr1 = new YcslGxr();
YcslGxr1.setProid(request.getParameter("proid"));
YcslGxr1.setGxrlx("qlr");
List<YcslGxr> findList = ycslGxrService.findList(YcslGxr1);
if(findList.size() > 0) {
for (int i = 0; i < findList.size(); i++) {
if("0".equals(findList.get(i).getGyfs())) {
model.addAttribute("msg", "转入放信息共有方式存在单独所有,不符合多个共有人业务逻辑。");
break;
}
ycslGxr.setGyfs(findList.get(i).getGyfs());
}
}
}
// 计算当前顺序号【注意:只有新增时才需要这个值】
if (StringUtils.isBlank(ycslGxr.getId()) && StringUtils.isBlank(request.getParameter("SXH"))) {
model.addAttribute("SXH", getQlrmcOrderNumber(request.getParameter("proid")));
}else {
model.addAttribute("SXH", ycslGxr.getSxh());
model.addAttribute("gxrid", ycslGxr.getId());
}
if(StringUtils.isNotBlank(request.getParameter("SXH"))) {
model.addAttribute("SXH", request.getParameter("SXH"));
model.addAttribute("gxrid", request.getParameter("gxrid"));
}
if(StringUtils.isNotBlank(request.getParameter("ids"))) {
String ids = request.getParameter("ids");
RegBasePerson person = regBasePersonService.get(ids);
ycslGxr.setGxrlx("qlr");
ycslGxr.setGxrmc(person.getRymc());
ycslGxr.setGxrsfzjzl(person.getZjzl());
ycslGxr.setGxrzjh(person.getZjh());
ycslGxr.setProid(request.getParameter("proid"));
ycslGxr.setGxrlxdh(person.getDh());
ycslGxr.setGxrtxdz(person.getDz());
ycslGxr.setGxrdlr(person.getDlrymc());
ycslGxr.setRylx(person.getRylx());
ycslGxr.setPcode(person.getPcode());
ycslGxr.setGj(person.getGj());
}
}else {
model.addAttribute("proid", ycslGxr.getProid());
}
if(StringUtils.isNotBlank(request.getParameter("view"))) {
model.addAttribute("view", request.getParameter("view"));
}
model.addAttribute("ycslGxr", ycslGxr);
return "modules/ycsl/ycslGxrForm";
}
@RequiresPermissions("ycsl:ycslGxr:edit")
@RequestMapping(value = "save")
@ResponseBody
public ModelMap save(YcslGxr ycslGxr,HttpServletRequest request, Model model, RedirectAttributes redirectAttributes) {
ModelMap modelmap = new ModelMap();
ycslGxr.setGyqk(DictUtils.getDictLabel(ycslGxr.getGyfs(), "reg_bus_gyfs", ""));
if(StringUtils.isNotBlank(request.getParameter("gxrid"))) {
YcslGxr gxr = ycslGxrService.get(request.getParameter("gxrid"));
ycslGxrService.delete(gxr);
}
ycslGxr.setId("");
ycslGxrService.saveGxr(ycslGxr);
return modelmap;
}
@RequiresPermissions("ycsl:ycslGxr:edit")
@RequestMapping(value = "delete")
public String delete(YcslGxr ycslGxr, RedirectAttributes redirectAttributes) {
YcslGxr ycslGxr1 = new YcslGxr();
ycslGxr1.setProid(ycslGxr.getProid());
ycslGxr1.setGxrlx("qlr");
List<YcslGxr> ycslGxrlist = ycslGxrService.findList(ycslGxr1);
ycslGxr1 = ycslGxrService.get(ycslGxr.getId());
if (ycslGxrlist.size() > 0) {
ycslGxr1 = ycslGxrlist.get(ycslGxrlist.size() - 1);
if (ycslGxr1.getSxh() > ycslGxr.getSxh()) {// 判断当前顺序号是否是最大顺序号
addMessage(redirectAttributes, "请先删除最大顺序号关系人!");
}else {
ycslGxrService.delete(ycslGxr);
}
}else {
addMessage(redirectAttributes, "删除关系人信息失败!");
}
return "redirect:"+Global.getAdminPath()+"/ycsl/ycslGxr/list?id="+ycslGxr.getId();
}
/***
* @Title: issjed
* @Description: 判断是否有权利人
* @param @param request
* @param @return 设定文件
* @return ModelMap 返回类型
* @throws
*/
@RequestMapping(value = "qlrinfoquery")
@ResponseBody
public ModelMap issjed(HttpServletRequest request) {
String ywh = request.getParameter("proid");
YcslGxr ycslGxr = new YcslGxr();
ycslGxr.setProid(ywh);
ycslGxr.setGxrlx("qlr");
List<YcslGxr> findList = ycslGxrService.findList(ycslGxr);
ModelMap modelMap = new ModelMap();
if(findList.size()>0){
modelMap.put("data", "1");//已经有权利人记录
}else{
modelMap.put("data", "0");
}
return modelMap;
}
/***
* @Title: getQlrmcOrderNumber @Description: 通过proid获取当前关系人的顺序号 @param @param
* ywhStr @param @return 设定文件 @return String 返回类型 @throws
*/
public int getQlrmcOrderNumber(String proid) {
int qlrmcOrderNumber = 1;// 默认为001
if (StringUtils.isBlank(proid)) {
return qlrmcOrderNumber;
}
// 首先获取权利人 ID个数
YcslGxr gxr = new YcslGxr();
gxr.setProid(proid);
gxr.setGxrlx("qlr");
List<YcslGxr> gxrlist = ycslGxrService.findList(gxr);
int count = gxrlist.size();
if (count > 0) {
qlrmcOrderNumber = gxrlist.size() + 1;
}
return qlrmcOrderNumber;
}
}