LjzController.java
4.1 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
package com.thinkgem.jeesite.modules.title.web;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
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.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseC;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseH;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseLjz;
import com.thinkgem.jeesite.modules.reg.entity.base.RegBaseZrz;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseCService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseHService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseLjzService;
import com.thinkgem.jeesite.modules.reg.service.base.RegBaseZrzService;
@Controller
@RequestMapping(value = "${adminPath}/title/web/ljzController")
public class LjzController {
protected Logger logger = Logger.getLogger(getClass());
@Autowired
private RegBaseZrzService regBaseZrzService;
@Autowired
private RegBaseHService hService;
@Autowired
private RegBaseCService cService;
@Autowired
private RegBaseLjzService ljzService;
@RequiresPermissions("title:web:titleController:view")
@RequestMapping(value = "Ljz")
@ResponseBody
public ModelMap getZrz(HttpServletRequest request, HttpServletResponse response, Model model) {
ModelMap modelmap = new ModelMap();
List<RegBaseZrz> zrzList = new ArrayList<RegBaseZrz>();
RegBaseZrz regBaseZrz = new RegBaseZrz();
if(StringUtils.isNotBlank(request.getParameter("zddm"))){
regBaseZrz.setZddm(request.getParameter("zddm"));
}
zrzList = regBaseZrzService.findList(regBaseZrz);
if(zrzList.size()>0) {
for(int i=0;i<zrzList.size();i++) {
RegBaseH h = new RegBaseH();
h.setBdcdyh(zrzList.get(i).getBdcdyh().substring(0, 24));
h.setZddm(zrzList.get(i).getZddm());
List<RegBaseH> hlist = hService.findList(h);
if(hlist.size()>0) {
Double scjzmj = 0.0;
for(int j=0;j<hlist.size();j++) {
h = hlist.get(j);
RegBaseLjz ljz = new RegBaseLjz();
ljz.setFwyt1(h.getFwyt1());
ljz.setZrzh(h.getZrzh());
List<RegBaseLjz> ljzlist = ljzService.findList(ljz);
if(ljzlist.size()>0) {
ljz = ljzlist.get(0);
RegBaseC c = cService.get(h.getCid());
if(StringUtils.isBlank(c.getLjzh())) {
c.setZrzh(h.getZrzh());
c.setLjzh(ljzlist.get(0).getLjzh());
ljz.setZcs(Integer.parseInt(ljz.getZcs())+1+"");
if(c.getIsnegativelayer().equals("0")) {
ljz.setDscs(Integer.parseInt(ljz.getDscs())+1+"");
}else {
ljz.setDscs(Integer.parseInt(ljz.getDxcs())+1+"");
}
}
cService.save(c);
ljzService.save(ljz);
}else {
scjzmj = scjzmj + h.getScjzmj();
ljz.setLjzh(h.getBdcdyh().substring(4, 24).replace("F", "")+nextZh(h.getZrzh()));
logger.debug(ljz.getLjzh());
ljz.setJgrq(zrzList.get(i).getJgrq());
ljz.setYtmc(h.getFwyt1());
ljz.setZcs("0");
ljz.setDscs("0");
ljz.setDxcs("0");
ljzService.save(ljz);
}
}
}
}
}
return modelmap;
}
private String nextZh(String zrzh) {
String maxZh = ljzService.MaxZh(zrzh);
int ljzh = 1;
String zh ="01";
if(StringUtils.isNotBlank(maxZh) ) {
ljzh = Integer.parseInt(maxZh)+1;
}else {
ljzh = ljzh;
}
if(ljzh <10) {
zh = "0"+ljzh;
}else {
zh = ljzh+"";
}
return zh;
}
}