bcc72e6b39428a7583e02992ada12db751f61492.svn-base
8.15 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
211
212
213
214
/**
* Copyright © 2015-2018 <a href="#">J-Site</a> All rights reserved.
*/
package com.thinkgem.jeesite.modules.reg.base.web;
import java.util.ArrayList;
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.transaction.annotation.Transactional;
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.base.entity.RegBaseZsglbSub;
import com.thinkgem.jeesite.modules.reg.base.service.RegBaseZsglbSubService;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZsglb;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusBdcqzsdjxx;
import com.thinkgem.jeesite.modules.reg.entity.bus.RegBusSz;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZsglbService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusBdcqzsdjxxService;
import com.thinkgem.jeesite.modules.reg.service.bus.RegBusSzService;
import com.thinkgem.jeesite.modules.reg.web.bus.RegBusSlsqController;
/**
* 证书基础子表管理Controller
* @author jiangdb
* @version 2018-01-09
*/
@Controller
@RequestMapping(value = "${adminPath}/reg/base/regBaseZsglbSub")
public class RegBaseZsglbSubController extends BaseController {
@Autowired
private RegBaseZsglbSubService regBaseZsglbSubService;
@Autowired
private RegBaseZsglbService regBaseZsglbService;
@Autowired
private RegBusSzService regBusSzService;
@Autowired
private RegBusSlsqController regBusSlsqController;
@Autowired
private RegBusBdcqzsdjxxService regBusBdcqzsdjxxService;
@ModelAttribute
public RegBaseZsglbSub get(@RequestParam(required=false) String id) {
RegBaseZsglbSub entity = null;
if (StringUtils.isNotBlank(id)){
entity = regBaseZsglbSubService.get(id);
}
if (entity == null){
entity = new RegBaseZsglbSub();
}
return entity;
}
@RequiresPermissions("reg.base:regBaseZsglbSub:view")
@RequestMapping(value = {"list", ""})
public String list(RegBaseZsglbSub regBaseZsglbSub, HttpServletRequest request, HttpServletResponse response, Model model) {
Page<RegBaseZsglbSub> page = regBaseZsglbSubService.findPage(new Page<RegBaseZsglbSub>(request, response), regBaseZsglbSub);
model.addAttribute("page", page);
return "modules/reg.base/regBaseZsglbSubList";
}
@RequiresPermissions("reg.base:regBaseZsglbSub:view")
@RequestMapping(value = "form")
public String form(RegBaseZsglbSub regBaseZsglbSub, Model model) {
model.addAttribute("regBaseZsglbSub", regBaseZsglbSub);
return "modules/reg.base/regBaseZsglbSubForm";
}
@RequiresPermissions("reg.base:regBaseZsglbSub:edit")
@RequestMapping(value = "save")
public String save(RegBaseZsglbSub regBaseZsglbSub, Model model, RedirectAttributes redirectAttributes) {
if (!beanValidator(model, regBaseZsglbSub)){
return form(regBaseZsglbSub, model);
}
regBaseZsglbSubService.save(regBaseZsglbSub);
addMessage(redirectAttributes, "保存证书基础子表成功");
return "redirect:"+Global.getAdminPath()+"/reg.base/regBaseZsglbSub/?repage";
}
@RequiresPermissions("reg.base:regBaseZsglbSub:edit")
@RequestMapping(value = "delete")
public String delete(RegBaseZsglbSub regBaseZsglbSub, RedirectAttributes redirectAttributes) {
regBaseZsglbSubService.delete(regBaseZsglbSub);
addMessage(redirectAttributes, "删除证书基础子表成功");
return "redirect:"+Global.getAdminPath()+"/reg.base/regBaseZsglbSub/?repage";
}
@RequestMapping(value = "checkData")
@ResponseBody
@Transactional
public ModelMap checkData(HttpServletRequest request,HttpServletResponse response) {
ModelMap model1 = new ModelMap();
String newbm = request.getParameter("newbm");//new:修改后
String oldbm = request.getParameter("oldbm");//old:修改前编
String oldqlsx = request.getParameter("oldqlsx");
String newqlsx = request.getParameter("newqlsx");
String ywh = request.getParameter("ywh");
String newmainid = "";
String oldmainid = "";
String newszzh = "";
String newbdcqzh = "";
RegBaseZsglb newzsglb = new RegBaseZsglb();
RegBaseZsglbSub newzsglbSub = new RegBaseZsglbSub();
newzsglb.setZsbm(Long.valueOf(newbm));
newzsglb.setIsdj("jc");
newzsglb.setIsbf("1");
List<RegBaseZsglb> zsglblist = regBaseZsglbService.findList(newzsglb);
if(zsglblist.size()>0){
newzsglb = zsglblist.get(0);
newmainid = newzsglb.getId();
newszzh = newzsglb.getSzzh();
newbdcqzh = newzsglb.getBdcqzh();
}
if(StringUtils.isNotBlank(newmainid)){
newzsglbSub.setMainId(newmainid);
newzsglbSub.setBdcqlsx(newqlsx);
List<RegBaseZsglbSub> newsubs = regBaseZsglbSubService.findList(newzsglbSub);
if(Integer.valueOf(newqlsx)>1){
newzsglbSub.setBdcqlsx(String.valueOf(Integer.valueOf(newqlsx)-1));
List<RegBaseZsglbSub> newsubs1 = regBaseZsglbSubService.findList(newzsglbSub);
if(newsubs.size()>0){//大于0说明当前证书页已经有信息,返回false
model1.addAttribute("successbj","1");
model1.addAttribute("msg", "所选证书权利页已被占用,请确定。");
}else if(newsubs1.size()==0){
model1.addAttribute("successbj","1");
model1.addAttribute("msg", "所选证书上一权利页为空,请选择。");
}else{//查询原始证书数据,更新到新证书
model1.addAttribute("successbj","0");
RegBaseZsglb oldzsglb = new RegBaseZsglb();
oldzsglb.setZsbm(Long.valueOf(oldbm));
oldzsglb.setIsdj("jc");
oldzsglb.setIsbf("1");
List<RegBaseZsglb> ozsglblist = regBaseZsglbService.findList(oldzsglb);
if(ozsglblist.size()>0){
oldzsglb = ozsglblist.get(0);
oldmainid = oldzsglb.getId();
RegBaseZsglbSub zsglbsub = new RegBaseZsglbSub();
zsglbsub.setMainId(oldmainid);
zsglbsub.setBdcqlsx(oldqlsx);
List<RegBaseZsglbSub> subs = regBaseZsglbSubService.findList(zsglbsub);
RegBusBdcqzsdjxx djxx = new RegBusBdcqzsdjxx();
for(int i=0;i<subs.size();i++){
newzsglbSub = subs.get(i);
newzsglbSub.setMainId(newmainid);
newzsglbSub.setBdcqlsx(newqlsx);
regBaseZsglbSubService.save(newzsglbSub);
djxx.setBdcdyh(newzsglbSub.getBdcdyh());
djxx.setYwh(ywh);
djxx.setDbsj("NOTNULL");
djxx.setIslogout("0");
List<RegBusBdcqzsdjxx> djxxlist = regBusBdcqzsdjxxService.findList(djxx);//ywh+bdcdyh+有效标记,确定唯一一条信息
djxx = djxxlist.get(0);
djxx.setBdcqzbh(newszzh);
djxx.setBdcqzh(newbdcqzh);
djxx.setYsxlh(newbm);
regBusBdcqzsdjxxService.save(djxx);
//更新对应权属中的证号或者证明号
regBusSlsqController.updateRightsOnSz(ywh, djxx.getBdcdyh(),
djxx.getDjlx(), newbdcqzh);
}
String idtmp = "";
RegBusSz sz = new RegBusSz();
sz.setYwh(ywh);
sz.setYsxlh(Long.valueOf(oldbm));
List<RegBusSz> szlist = regBusSzService.findList(sz);
if(szlist.size()>0){//逻辑上应该是一条数据
sz = szlist.get(0);
idtmp = sz.getId();
sz.setId("");
sz.setSzzh(newszzh);
sz.setYsxlh(Long.valueOf(newbm));
regBusSzService.save(sz);
}
List<RegBaseZsglbSub> Sublisttmp = regBaseZsglbSubService.findbymainid(oldmainid);
if(Sublisttmp.size()==0){
oldzsglb.setSzr(null);
oldzsglb.setSzzh(null);
oldzsglb.setYwh(null);
oldzsglb.setBdcdyh(null);
oldzsglb.setIsbf("0");
regBaseZsglbService.save(oldzsglb);
sz = new RegBusSz();
sz.setId(idtmp);
regBusSzService.delete(sz);
}
}
}
}
}
return model1;
}
}