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;
|
}
|
|
|
|
}
|