Administrator
2022-09-14 58d006e05dcf2a20d0ec5367dd03d66a61db6849
提交 | 用户 | 时间
58d006 1 package com.mandi.fendan.controller;
A 2
3 import java.util.HashMap;
4 import java.util.Map;
5
6 import javax.annotation.Resource;
7 import javax.servlet.http.HttpServletRequest;
8 import javax.servlet.http.HttpServletResponse;
9
10 import org.apache.commons.lang3.StringUtils;
11 import org.apache.log4j.Logger;
12 import org.springframework.stereotype.Controller;
13 import org.springframework.web.bind.annotation.RequestMapping;
14 import org.springframework.web.bind.annotation.RequestMethod;
15 import org.springframework.web.bind.annotation.ResponseBody;
16
17 import com.mandi.common.Jacksonmethod;
18 import com.mandi.common.RequestParam;
19 import com.mandi.common.SessionMethod;
20 import com.mandi.dao.common.ObjectResult;
21 import com.mandi.dao.common.PageRequest;
22 import com.mandi.dao.common.PageResult;
23 import com.mandi.fendan.persist.Fd_Vehicle;
24 import com.mandi.fendan.service.Ifd_vehicleService;
25 import com.mandi.system.persist.Login;
26
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;
34     
35     @RequestMapping(value = "/saveItem.htm", method = {RequestMethod.POST })
36     @ResponseBody
37     public String saveItem(HttpServletRequest r,HttpServletResponse re){
38         Fd_Vehicle fvc = RequestParam.getobj(r, new Fd_Vehicle());
39         ObjectResult<Fd_Vehicle> orr=new ObjectResult<Fd_Vehicle>();
40         Login lg=SessionMethod.getlogin(r.getSession());
41         try {
42             orr = ivs.saveFd_Vehicle(fvc,lg);
43         } catch (Exception e) {
44             orr.setCode(1);
45             orr.setErrmsg(e.getMessage());
46         }
47
48         SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
49         return null;
50     }
51     @RequestMapping(value = "/getallList.htm", method = {RequestMethod.POST })
52     @ResponseBody
53     public String getallList(HttpServletRequest r,HttpServletResponse re){
54         String companyNo=RequestParam.getSqlString(r, "companyNo");
55         String vehicleId=RequestParam.getSqlString(r, "searchword");//车牌号
56         int page=RequestParam.getInt(r, "page");
57         int pagesize=RequestParam.getInt(r, "pagesize");
58         int pages=RequestParam.getInt(r, "pages");
59         PageRequest pr=new PageRequest(page, pagesize, null);
60         if(pages>0)
61             pr.setNeedPages(true);
62         else
63             pr.setNeedPages(false);
64         Map<String, Object> map = new HashMap<String,Object>();
65         if(StringUtils.isNotBlank(companyNo)){
66             map.put("companyNo", companyNo);
67         }
68         if (StringUtils.isNotBlank(vehicleId)) {
69             map.put("vehicleId", vehicleId);
70         }
71         PageResult<Map<String, Object>> prr = new PageResult<Map<String,Object>>();
72         try {
73             prr = ivs.getList(map, pr);
74         } catch (Exception e) {
75             e.printStackTrace();
76         }
77         String str=Jacksonmethod.tojson(prr, false);
78         SessionMethod.writeresp(re, str);
79         return null;
80     }
81     
82     @RequestMapping(value = "/getList.htm", method = {RequestMethod.POST })
83     @ResponseBody
84     public String getList(HttpServletRequest r,HttpServletResponse re){
85         String vehicleId=RequestParam.getSqlString(r, "searchword");//车牌号
86         int page=RequestParam.getInt(r, "page");
87         int pagesize=RequestParam.getInt(r, "pagesize");
88         int pages=RequestParam.getInt(r, "pages");
89         PageRequest pr=new PageRequest(page, pagesize, null);
90         if(pages>0)
91             pr.setNeedPages(true);
92         else
93             pr.setNeedPages(false);
94         Map<String, Object> map = new HashMap<String,Object>();
95         map.put("vehicleId", vehicleId);
96         PageResult<Map<String, Object>> prr = new PageResult<Map<String,Object>>();
97         try {
98             prr = ivs.getList(map, pr);
99         } catch (Exception e) {
100             // TODO Auto-generated catch block
101             e.printStackTrace();
102         }
103         String str=Jacksonmethod.tojson(prr, false);
104         SessionMethod.writeresp(re, str);
105         return null;
106     }
107     @RequestMapping(value = "/getItem.htm", method = {RequestMethod.POST })
108     @ResponseBody
109     public String getItem(HttpServletRequest r,HttpServletResponse re){
110         String vehicleId=RequestParam.getSqlString(r, "vehicleId");
111
112         
113         ObjectResult<Fd_Vehicle> orr=new ObjectResult<Fd_Vehicle>();
114         try {
115             orr = ivs.getFd_VehicleByFd_VehicleId(vehicleId);
116         } catch (Exception e) {
117             orr.setCode(1);
118             orr.setErrmsg(e.getMessage());
119         }
120
121         SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
122         return null;
123     }
124     @RequestMapping(value = "/changeState.htm", method = {RequestMethod.POST })
125     @ResponseBody
126     public String changeState(HttpServletRequest r,HttpServletResponse re){
127         String id=RequestParam.getSqlString(r, "vehicleId");
128         boolean state=RequestParam.getBool(r, "state");
129         
130         Login lg=SessionMethod.getlogin(r.getSession());
131         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
132         try {
133             orr = ivs.changeState(id, lg, state);
134         } catch (Exception e) {
135             orr.setCode(1);
136             orr.setErrmsg(e.getMessage());
137         }
138         
139         SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
140         return null;
141     }
142     @RequestMapping(value = "/delItem.htm", method = {RequestMethod.POST })
143     @ResponseBody
144     public String delItem(HttpServletRequest r,HttpServletResponse re){
145         String vehicleId=RequestParam.getSqlString(r, "vehicleId");
146         
147         ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
148         try {
149             orr = ivs.delFd_Vehicle(vehicleId);
150         } catch (Exception e) {
151             orr.setCode(1);
152             orr.setErrmsg(e.getMessage());
153         }
154
155         SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
156         return null;
157     }
158
159
160     
161 }