提交 | 用户 | 时间
|
58d006
|
1 |
package com.mandi.fendan.controller; |
A |
2 |
|
1c4e40
|
3 |
import com.mandi.common.Jacksonmethod; |
A |
4 |
import com.mandi.common.RequestParam; |
|
5 |
import com.mandi.common.SessionMethod; |
|
6 |
import com.mandi.dao.common.ObjectResult; |
|
7 |
import com.mandi.dao.common.PageRequest; |
|
8 |
import com.mandi.dao.common.PageResult; |
|
9 |
import com.mandi.fendan.mapper.FdVehicleRemarkMapper; |
|
10 |
import com.mandi.fendan.persist.FdVehicleRemark; |
|
11 |
import com.mandi.fendan.persist.Fd_Vehicle; |
|
12 |
import com.mandi.fendan.service.Ifd_vehicleService; |
|
13 |
import com.mandi.system.persist.Login; |
58d006
|
14 |
import org.apache.commons.lang3.StringUtils; |
A |
15 |
import org.apache.log4j.Logger; |
|
16 |
import org.springframework.stereotype.Controller; |
|
17 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
18 |
import org.springframework.web.bind.annotation.RequestMethod; |
|
19 |
import org.springframework.web.bind.annotation.ResponseBody; |
|
20 |
|
1c4e40
|
21 |
import javax.annotation.Resource; |
A |
22 |
import javax.servlet.http.HttpServletRequest; |
|
23 |
import javax.servlet.http.HttpServletResponse; |
|
24 |
import java.util.HashMap; |
|
25 |
import java.util.Map; |
58d006
|
26 |
|
A |
27 |
|
|
28 |
@Controller("fd_vehicle_con") |
|
29 |
@RequestMapping(value="/vehicle",method={RequestMethod.POST}) |
|
30 |
public class Fd_VehicleController { |
|
31 |
private Logger log=Logger.getLogger(Fd_VehicleController.class); |
|
32 |
@Resource |
|
33 |
private Ifd_vehicleService ivs; |
1c4e40
|
34 |
@Resource |
A |
35 |
private FdVehicleRemarkMapper fdVehicleRemarkMapper; |
|
36 |
|
|
37 |
@RequestMapping(value = "/saveRemark.htm", method = {RequestMethod.POST }) |
|
38 |
@ResponseBody |
|
39 |
public void saveRemark(HttpServletRequest r,HttpServletResponse re,String numberplates,String bsNo,String remark){ |
|
40 |
FdVehicleRemark fdVehicleRemark = new FdVehicleRemark(); |
|
41 |
fdVehicleRemark.setRemark(remark); |
|
42 |
fdVehicleRemark.setBusinessNO(bsNo); |
|
43 |
fdVehicleRemark.setVehicle(numberplates); |
|
44 |
ObjectResult<Boolean> orr=new ObjectResult<>(); |
|
45 |
try { |
|
46 |
FdVehicleRemark fdVehicleRemarkTemp = fdVehicleRemarkMapper.selectByBusinessNo(bsNo); |
|
47 |
if(fdVehicleRemarkTemp!=null) { |
|
48 |
int i = fdVehicleRemarkMapper.update(fdVehicleRemark); |
|
49 |
if (i <= 0) { |
|
50 |
orr.setCode(1); |
|
51 |
orr.setErrmsg("添加失败,请检查数据!"); |
|
52 |
} |
|
53 |
}else { |
|
54 |
fdVehicleRemarkMapper.insert(fdVehicleRemark); |
|
55 |
} |
|
56 |
orr.setCode(0); |
|
57 |
orr.setErrmsg("添加成功!"); |
|
58 |
}catch (Exception e) { |
|
59 |
log.error(e.getMessage(),e); |
|
60 |
orr.setCode(1); |
|
61 |
orr.setErrmsg("添加失败,请联系管理员!"); |
|
62 |
} |
|
63 |
SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false)); |
|
64 |
} |
|
65 |
|
|
66 |
@RequestMapping(value = "/getDetail.htm", method = {RequestMethod.POST }) |
|
67 |
@ResponseBody |
|
68 |
public void getDetail(HttpServletRequest r,HttpServletResponse re,String numberplates,String bsNo){ |
|
69 |
ObjectResult<FdVehicleRemark> orr=new ObjectResult<>(); |
|
70 |
try { |
|
71 |
FdVehicleRemark fdVehicleRemark = fdVehicleRemarkMapper.selectByBusinessNo(bsNo); |
|
72 |
orr.setItem(fdVehicleRemark); |
|
73 |
}catch (Exception e) { |
|
74 |
orr.setCode(1); |
|
75 |
orr.setErrmsg("查询失败!"); |
|
76 |
} |
|
77 |
SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false)); |
|
78 |
} |
58d006
|
79 |
|
A |
80 |
@RequestMapping(value = "/saveItem.htm", method = {RequestMethod.POST }) |
|
81 |
@ResponseBody |
|
82 |
public String saveItem(HttpServletRequest r,HttpServletResponse re){ |
|
83 |
Fd_Vehicle fvc = RequestParam.getobj(r, new Fd_Vehicle()); |
|
84 |
ObjectResult<Fd_Vehicle> orr=new ObjectResult<Fd_Vehicle>(); |
|
85 |
Login lg=SessionMethod.getlogin(r.getSession()); |
|
86 |
try { |
|
87 |
orr = ivs.saveFd_Vehicle(fvc,lg); |
|
88 |
} catch (Exception e) { |
|
89 |
orr.setCode(1); |
|
90 |
orr.setErrmsg(e.getMessage()); |
|
91 |
} |
|
92 |
|
|
93 |
SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false)); |
|
94 |
return null; |
|
95 |
} |
|
96 |
@RequestMapping(value = "/getallList.htm", method = {RequestMethod.POST }) |
|
97 |
@ResponseBody |
|
98 |
public String getallList(HttpServletRequest r,HttpServletResponse re){ |
|
99 |
String companyNo=RequestParam.getSqlString(r, "companyNo"); |
|
100 |
String vehicleId=RequestParam.getSqlString(r, "searchword");//车牌号 |
|
101 |
int page=RequestParam.getInt(r, "page"); |
|
102 |
int pagesize=RequestParam.getInt(r, "pagesize"); |
|
103 |
int pages=RequestParam.getInt(r, "pages"); |
|
104 |
PageRequest pr=new PageRequest(page, pagesize, null); |
|
105 |
if(pages>0) |
|
106 |
pr.setNeedPages(true); |
|
107 |
else |
|
108 |
pr.setNeedPages(false); |
|
109 |
Map<String, Object> map = new HashMap<String,Object>(); |
|
110 |
if(StringUtils.isNotBlank(companyNo)){ |
|
111 |
map.put("companyNo", companyNo); |
|
112 |
} |
|
113 |
if (StringUtils.isNotBlank(vehicleId)) { |
|
114 |
map.put("vehicleId", vehicleId); |
|
115 |
} |
|
116 |
PageResult<Map<String, Object>> prr = new PageResult<Map<String,Object>>(); |
|
117 |
try { |
|
118 |
prr = ivs.getList(map, pr); |
|
119 |
} catch (Exception e) { |
|
120 |
e.printStackTrace(); |
|
121 |
} |
|
122 |
String str=Jacksonmethod.tojson(prr, false); |
|
123 |
SessionMethod.writeresp(re, str); |
|
124 |
return null; |
|
125 |
} |
|
126 |
|
|
127 |
@RequestMapping(value = "/getList.htm", method = {RequestMethod.POST }) |
|
128 |
@ResponseBody |
|
129 |
public String getList(HttpServletRequest r,HttpServletResponse re){ |
|
130 |
String vehicleId=RequestParam.getSqlString(r, "searchword");//车牌号 |
|
131 |
int page=RequestParam.getInt(r, "page"); |
|
132 |
int pagesize=RequestParam.getInt(r, "pagesize"); |
|
133 |
int pages=RequestParam.getInt(r, "pages"); |
|
134 |
PageRequest pr=new PageRequest(page, pagesize, null); |
|
135 |
if(pages>0) |
|
136 |
pr.setNeedPages(true); |
|
137 |
else |
|
138 |
pr.setNeedPages(false); |
|
139 |
Map<String, Object> map = new HashMap<String,Object>(); |
|
140 |
map.put("vehicleId", vehicleId); |
|
141 |
PageResult<Map<String, Object>> prr = new PageResult<Map<String,Object>>(); |
|
142 |
try { |
|
143 |
prr = ivs.getList(map, pr); |
|
144 |
} catch (Exception e) { |
|
145 |
// TODO Auto-generated catch block |
|
146 |
e.printStackTrace(); |
|
147 |
} |
|
148 |
String str=Jacksonmethod.tojson(prr, false); |
|
149 |
SessionMethod.writeresp(re, str); |
|
150 |
return null; |
|
151 |
} |
|
152 |
@RequestMapping(value = "/getItem.htm", method = {RequestMethod.POST }) |
|
153 |
@ResponseBody |
|
154 |
public String getItem(HttpServletRequest r,HttpServletResponse re){ |
|
155 |
String vehicleId=RequestParam.getSqlString(r, "vehicleId"); |
|
156 |
|
|
157 |
|
|
158 |
ObjectResult<Fd_Vehicle> orr=new ObjectResult<Fd_Vehicle>(); |
|
159 |
try { |
|
160 |
orr = ivs.getFd_VehicleByFd_VehicleId(vehicleId); |
|
161 |
} catch (Exception e) { |
|
162 |
orr.setCode(1); |
|
163 |
orr.setErrmsg(e.getMessage()); |
|
164 |
} |
|
165 |
|
|
166 |
SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false)); |
|
167 |
return null; |
|
168 |
} |
|
169 |
@RequestMapping(value = "/changeState.htm", method = {RequestMethod.POST }) |
|
170 |
@ResponseBody |
|
171 |
public String changeState(HttpServletRequest r,HttpServletResponse re){ |
|
172 |
String id=RequestParam.getSqlString(r, "vehicleId"); |
|
173 |
boolean state=RequestParam.getBool(r, "state"); |
|
174 |
|
|
175 |
Login lg=SessionMethod.getlogin(r.getSession()); |
|
176 |
ObjectResult<Boolean> orr=new ObjectResult<Boolean>(); |
|
177 |
try { |
|
178 |
orr = ivs.changeState(id, lg, state); |
|
179 |
} catch (Exception e) { |
|
180 |
orr.setCode(1); |
|
181 |
orr.setErrmsg(e.getMessage()); |
|
182 |
} |
|
183 |
|
|
184 |
SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false)); |
|
185 |
return null; |
|
186 |
} |
|
187 |
@RequestMapping(value = "/delItem.htm", method = {RequestMethod.POST }) |
|
188 |
@ResponseBody |
|
189 |
public String delItem(HttpServletRequest r,HttpServletResponse re){ |
|
190 |
String vehicleId=RequestParam.getSqlString(r, "vehicleId"); |
|
191 |
|
|
192 |
ObjectResult<Boolean> orr=new ObjectResult<Boolean>(); |
|
193 |
try { |
|
194 |
orr = ivs.delFd_Vehicle(vehicleId); |
|
195 |
} catch (Exception e) { |
|
196 |
orr.setCode(1); |
|
197 |
orr.setErrmsg(e.getMessage()); |
|
198 |
} |
|
199 |
|
|
200 |
SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false)); |
|
201 |
return null; |
|
202 |
} |
|
203 |
|
|
204 |
|
|
205 |
|
|
206 |
} |