hjg
2024-02-05 301115d5e96b56cd093eee3fcff2d60a15184162
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
package com.mandi.fendan.controller;
 
import com.mandi.common.Jacksonmethod;
import com.mandi.common.RequestParam;
import com.mandi.common.SessionMethod;
import com.mandi.dao.common.ObjectResult;
import com.mandi.dao.common.PageRequest;
import com.mandi.dao.common.PageResult;
import com.mandi.fendan.mapper.FdVehicleRemarkMapper;
import com.mandi.fendan.persist.FdVehicleRemark;
import com.mandi.fendan.persist.Fd_Vehicle;
import com.mandi.fendan.service.Ifd_vehicleService;
import com.mandi.system.persist.Login;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.Map;
 
 
@Controller("fd_vehicle_con")
@RequestMapping(value="/vehicle",method={RequestMethod.POST})
public class Fd_VehicleController {
    private Logger log=Logger.getLogger(Fd_VehicleController.class);
    @Resource
    private Ifd_vehicleService ivs;
    @Resource
    private FdVehicleRemarkMapper fdVehicleRemarkMapper;
 
    @RequestMapping(value = "/saveRemark.htm", method = {RequestMethod.POST })
    @ResponseBody
    public void saveRemark(HttpServletRequest r,HttpServletResponse re,String numberplates,String bsNo,String remark){
        FdVehicleRemark fdVehicleRemark = new FdVehicleRemark();
        fdVehicleRemark.setRemark(remark);
        fdVehicleRemark.setBusinessNO(bsNo);
        fdVehicleRemark.setVehicle(numberplates);
        ObjectResult<Boolean> orr=new ObjectResult<>();
        try {
            FdVehicleRemark fdVehicleRemarkTemp = fdVehicleRemarkMapper.selectByBusinessNo(bsNo);
            if(fdVehicleRemarkTemp!=null) {
                int i = fdVehicleRemarkMapper.update(fdVehicleRemark);
                if (i <= 0) {
                    orr.setCode(1);
                    orr.setErrmsg("添加失败,请检查数据!");
                }
            }else {
                fdVehicleRemarkMapper.insert(fdVehicleRemark);
            }
            orr.setCode(0);
            orr.setErrmsg("添加成功!");
        }catch (Exception e) {
            log.error(e.getMessage(),e);
            orr.setCode(1);
            orr.setErrmsg("添加失败,请联系管理员!");
        }
        SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
    }
 
    @RequestMapping(value = "/getDetail.htm", method = {RequestMethod.POST })
    @ResponseBody
    public void getDetail(HttpServletRequest r,HttpServletResponse re,String numberplates,String bsNo){
        ObjectResult<FdVehicleRemark> orr=new ObjectResult<>();
        try {
            FdVehicleRemark fdVehicleRemark = fdVehicleRemarkMapper.selectByBusinessNo(bsNo);
            orr.setItem(fdVehicleRemark);
        }catch (Exception e) {
            orr.setCode(1);
            orr.setErrmsg("查询失败!");
        }
        SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
    }
    
    @RequestMapping(value = "/saveItem.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String saveItem(HttpServletRequest r,HttpServletResponse re){
        Fd_Vehicle fvc = RequestParam.getobj(r, new Fd_Vehicle());
        ObjectResult<Fd_Vehicle> orr=new ObjectResult<Fd_Vehicle>();
        Login lg=SessionMethod.getlogin(r.getSession());
        try {
            orr = ivs.saveFd_Vehicle(fvc,lg);
        } catch (Exception e) {
            orr.setCode(1);
            orr.setErrmsg(e.getMessage());
        }
 
        SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
        return null;
    }
    @RequestMapping(value = "/getallList.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String getallList(HttpServletRequest r,HttpServletResponse re){
        String companyNo=RequestParam.getSqlString(r, "companyNo");
        String vehicleId=RequestParam.getSqlString(r, "searchword");//车牌号
        int page=RequestParam.getInt(r, "page");
        int pagesize=RequestParam.getInt(r, "pagesize");
        int pages=RequestParam.getInt(r, "pages");
        PageRequest pr=new PageRequest(page, pagesize, null);
        if(pages>0)
            pr.setNeedPages(true);
        else
            pr.setNeedPages(false);
        Map<String, Object> map = new HashMap<String,Object>();
        if(StringUtils.isNotBlank(companyNo)){
            map.put("companyNo", companyNo);
        }
        if (StringUtils.isNotBlank(vehicleId)) {
            map.put("vehicleId", vehicleId);
        }
        PageResult<Map<String, Object>> prr = new PageResult<Map<String,Object>>();
        try {
            prr = ivs.getList(map, pr);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String str=Jacksonmethod.tojson(prr, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
    
    @RequestMapping(value = "/getList.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String getList(HttpServletRequest r,HttpServletResponse re){
        String vehicleId=RequestParam.getSqlString(r, "searchword");//车牌号
        int page=RequestParam.getInt(r, "page");
        int pagesize=RequestParam.getInt(r, "pagesize");
        int pages=RequestParam.getInt(r, "pages");
        PageRequest pr=new PageRequest(page, pagesize, null);
        if(pages>0)
            pr.setNeedPages(true);
        else
            pr.setNeedPages(false);
        Map<String, Object> map = new HashMap<String,Object>();
        map.put("vehicleId", vehicleId);
        PageResult<Map<String, Object>> prr = new PageResult<Map<String,Object>>();
        try {
            prr = ivs.getList(map, pr);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        String str=Jacksonmethod.tojson(prr, false);
        SessionMethod.writeresp(re, str);
        return null;
    }
    @RequestMapping(value = "/getItem.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String getItem(HttpServletRequest r,HttpServletResponse re){
        String vehicleId=RequestParam.getSqlString(r, "vehicleId");
 
        
        ObjectResult<Fd_Vehicle> orr=new ObjectResult<Fd_Vehicle>();
        try {
            orr = ivs.getFd_VehicleByFd_VehicleId(vehicleId);
        } catch (Exception e) {
            orr.setCode(1);
            orr.setErrmsg(e.getMessage());
        }
 
        SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
        return null;
    }
    @RequestMapping(value = "/changeState.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String changeState(HttpServletRequest r,HttpServletResponse re){
        String id=RequestParam.getSqlString(r, "vehicleId");
        boolean state=RequestParam.getBool(r, "state");
        
        Login lg=SessionMethod.getlogin(r.getSession());
        ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
        try {
            orr = ivs.changeState(id, lg, state);
        } catch (Exception e) {
            orr.setCode(1);
            orr.setErrmsg(e.getMessage());
        }
        
        SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
        return null;
    }
    @RequestMapping(value = "/delItem.htm", method = {RequestMethod.POST })
    @ResponseBody
    public String delItem(HttpServletRequest r,HttpServletResponse re){
        String vehicleId=RequestParam.getSqlString(r, "vehicleId");
        
        ObjectResult<Boolean> orr=new ObjectResult<Boolean>();
        try {
            orr = ivs.delFd_Vehicle(vehicleId);
        } catch (Exception e) {
            orr.setCode(1);
            orr.setErrmsg(e.getMessage());
        }
 
        SessionMethod.writeresp(re, Jacksonmethod.tojson(orr, false));
        return null;
    }
 
 
    
}