265 lines
9.0 KiB
265 lines
9.0 KiB
package com.cweb.controller.Blx;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
import com.alibaba.fastjson.JSONPObject;
|
|
import com.hai.blx.service.BlxCarService;
|
|
import com.hai.common.exception.ErrorCode;
|
|
import com.hai.common.exception.ErrorHelp;
|
|
import com.hai.common.exception.SysCode;
|
|
import com.hai.common.security.SessionObject;
|
|
import com.hai.common.security.UserCenter;
|
|
import com.hai.common.utils.ResponseMsgUtil;
|
|
import com.hai.entity.BlxCarInfo;
|
|
|
|
import com.hai.model.HighUserModel;
|
|
import com.hai.model.ResponseData;
|
|
import com.hai.openApi.config.BlxConfig;
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.ApiOperation;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Controller;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import java.math.BigDecimal;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
@Controller
|
|
@RequestMapping(value = "/blxCar")
|
|
@Api(value = "比邻星车辆业务")
|
|
public class BlxCarController {
|
|
|
|
Logger log = LoggerFactory.getLogger(BlxCarController.class);
|
|
|
|
@Autowired
|
|
private UserCenter userCenter;
|
|
|
|
@Resource
|
|
private BlxConfig blxConfig;
|
|
|
|
@Resource
|
|
private BlxCarService blxCarService;
|
|
|
|
@RequestMapping(value = "/queryJsParking", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "查询附近停车场")
|
|
public ResponseData queryJsParking(
|
|
@RequestParam(value = "gps", required = true) String gps,
|
|
HttpServletRequest request
|
|
) {
|
|
try {
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("range" , 10);
|
|
jsonObject.put("gps" , gps);
|
|
|
|
JSONObject data = blxConfig.queryJsParking(jsonObject);
|
|
|
|
if (data.getInteger("code") != 1) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, data.getString("msg"));
|
|
}
|
|
|
|
return ResponseMsgUtil.success(data.getJSONObject("data").getJSONArray("parkList"));
|
|
|
|
} catch (Exception e) {
|
|
log.error("GoodsDetailController --> getListUser() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value="/insertCarInfo",method = RequestMethod.POST)
|
|
@ResponseBody
|
|
@ApiOperation(value = "增加车辆信息")
|
|
public ResponseData insertCarInfo(@RequestBody BlxCarInfo carInfo, HttpServletRequest request) {
|
|
try {
|
|
|
|
// 用户
|
|
SessionObject sessionObject = userCenter.getSessionObject(request);
|
|
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
|
|
|
|
if (carInfo.getCarNoType() == null
|
|
|| StringUtils.isBlank(carInfo.getCarNo())) {
|
|
log.error("HighCouponController -> insertCoupon() error!","参数错误");
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
|
|
}
|
|
|
|
carInfo.setCreateTime(new Date());
|
|
carInfo.setStatus(1);
|
|
carInfo.setUpdateTime(new Date());
|
|
carInfo.setUserId(userInfoModel.getHighUser().getId());
|
|
|
|
blxCarService.insertCar(carInfo);
|
|
|
|
return ResponseMsgUtil.success("新增成功");
|
|
|
|
|
|
} catch (Exception e) {
|
|
log.error("GoodsDetailController --> getListUser() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value="/updateCarInfo",method = RequestMethod.POST)
|
|
@ResponseBody
|
|
@ApiOperation(value = "修改车辆信息")
|
|
public ResponseData updateCarInfo(@RequestBody BlxCarInfo carInfo) {
|
|
try {
|
|
|
|
if (carInfo.getId() == null ||
|
|
carInfo.getCarNoType() == null
|
|
|| StringUtils.isBlank(carInfo.getCarNo())) {
|
|
log.error("HighCouponController -> insertCoupon() error!","参数错误");
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
|
|
}
|
|
|
|
BlxCarInfo blxCarInfo = blxCarService.findCarInfoById(carInfo.getId());
|
|
|
|
blxCarInfo.setStatus(1);
|
|
blxCarInfo.setCarNoType(carInfo.getCarNoType());
|
|
blxCarInfo.setCarNo(carInfo.getCarNo());
|
|
blxCarInfo.setUpdateTime(new Date());
|
|
|
|
blxCarService.updateCar(blxCarInfo);
|
|
|
|
return ResponseMsgUtil.success("修改成功");
|
|
|
|
|
|
} catch (Exception e) {
|
|
log.error("GoodsDetailController --> getListUser() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/deleteCarNoInfo", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "删除车辆车牌信息")
|
|
public ResponseData deleteCarNoInfo(
|
|
@RequestParam(value = "id", required = true) Long id,
|
|
HttpServletRequest request
|
|
) {
|
|
try {
|
|
|
|
BlxCarInfo blxCarInfo = blxCarService.findCarInfoById(id);
|
|
|
|
blxCarInfo.setStatus(0);
|
|
blxCarService.updateCar(blxCarInfo);
|
|
|
|
return ResponseMsgUtil.success("删除成功!");
|
|
|
|
} catch (Exception e) {
|
|
log.error("GoodsDetailController --> getListUser() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
|
|
@RequestMapping(value = "/getCarInfoList", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "查询用户车辆")
|
|
public ResponseData getCarInfoList(HttpServletRequest request) {
|
|
try {
|
|
|
|
|
|
// 用户
|
|
SessionObject sessionObject = userCenter.getSessionObject(request);
|
|
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
|
|
|
|
Map<String , Object> map = new HashMap<>();
|
|
map.put("userId" , userInfoModel.getHighUser().getId());
|
|
|
|
return ResponseMsgUtil.success(blxCarService.getCarInfoList(map));
|
|
|
|
} catch (Exception e) {
|
|
log.error("GoodsDetailController --> getListUser() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/getCarNoByOrder", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "根据车牌查询订单")
|
|
public ResponseData getCarNoByOrder(
|
|
@RequestParam(value = "carNo", required = true) String carNo,
|
|
HttpServletRequest request
|
|
) {
|
|
try {
|
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("carNo" , carNo);
|
|
jsonObject.put("orderStatus" , "03");
|
|
|
|
JSONObject data = blxConfig.queryJsOrderList(jsonObject);
|
|
|
|
JSONObject jsonObject04 = new JSONObject();
|
|
jsonObject04.put("carNo" , carNo);
|
|
jsonObject04.put("orderStatus" , "04");
|
|
|
|
JSONObject data04 = blxConfig.queryJsOrderList(jsonObject04);
|
|
|
|
|
|
if (data.getInteger("code") != 1) {
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, data.getString("msg"));
|
|
}
|
|
|
|
JSONArray jsonArray = data.getJSONObject("data").getJSONArray("ordlist");
|
|
jsonArray.addAll(data04.getJSONObject("data").getJSONArray("ordlist"));
|
|
|
|
for (Object object : jsonArray) {
|
|
JSONObject jsonpObject = (JSONObject) object;
|
|
jsonpObject.put("currentamt" , jsonpObject.getBigDecimal("currentamt").divide(new BigDecimal(100)));
|
|
}
|
|
|
|
return ResponseMsgUtil.success(jsonArray);
|
|
|
|
} catch (Exception e) {
|
|
log.error("GoodsDetailController --> getListUser() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
@RequestMapping(value = "/defaultCarNoInfo", method = RequestMethod.GET)
|
|
@ResponseBody
|
|
@ApiOperation(value = "默认车牌")
|
|
public ResponseData defaultCarNoInfo(
|
|
@RequestParam(value = "id", required = true) Long id,
|
|
HttpServletRequest request
|
|
) {
|
|
try {
|
|
|
|
// 用户
|
|
SessionObject sessionObject = userCenter.getSessionObject(request);
|
|
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
|
|
|
|
Map<String , Object> map = new HashMap<>();
|
|
map.put("userId" , userInfoModel.getHighUser().getId());
|
|
|
|
List<BlxCarInfo> list = blxCarService.getCarInfoList(map);
|
|
|
|
for (BlxCarInfo carInfo : list) {
|
|
carInfo.setDefaultCarNo(false);
|
|
blxCarService.updateCar(carInfo);
|
|
}
|
|
|
|
BlxCarInfo blxCarInfo = blxCarService.findCarInfoById(id);
|
|
|
|
blxCarInfo.setDefaultCarNo(true);
|
|
blxCarService.updateCar(blxCarInfo);
|
|
|
|
return ResponseMsgUtil.success("设置成功!");
|
|
|
|
} catch (Exception e) {
|
|
log.error("GoodsDetailController --> getListUser() error!", e);
|
|
return ResponseMsgUtil.exception(e);
|
|
}
|
|
}
|
|
|
|
}
|
|
|