new-dev
parent
de244978b6
commit
54a79af122
File diff suppressed because one or more lines are too long
@ -0,0 +1,258 @@ |
||||
package com.cweb.controller.Blx; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
|
||||
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.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")); |
||||
|
||||
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); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,67 @@ |
||||
package com.hai.blx.service; |
||||
|
||||
import com.hai.entity.BlxCarInfo; |
||||
import com.hai.entity.GoodsPresent; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @serviceName .java |
||||
* @author Sum1Dream |
||||
* @version 1.0.0 |
||||
* @Description // 比邻星车辆业务
|
||||
* @createTime 11:28 2023/9/5 |
||||
**/ |
||||
public interface BlxCarService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name insertCar |
||||
* @Description // 新增车辆信息
|
||||
* @Date 11:29 2023/9/5 |
||||
* @Param carInfo |
||||
* @return void |
||||
*/ |
||||
void insertCar(BlxCarInfo carInfo); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name updateCar |
||||
* @Description // 更新车辆信息
|
||||
* @Date 11:29 2023/9/5 |
||||
* @Param carInfo |
||||
* @return void |
||||
*/ |
||||
void updateCar(BlxCarInfo carInfo); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getCarInfoList |
||||
* @Description // 查询车辆信息列表
|
||||
* @Date 11:30 2023/9/5 |
||||
* @Param map |
||||
* @return java.util.List<com.hai.entity.BlxCarInfo> |
||||
*/ |
||||
List<BlxCarInfo> getCarInfoList(Map<String , Object> map); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findCarInfoByMap |
||||
* @Description //TODO
|
||||
* @Date 14:14 2023/9/5 |
||||
* @Param map |
||||
* @return com.hai.entity.BlxCarInfo |
||||
*/ |
||||
BlxCarInfo findCarInfoByMap(Map<String , Object> map); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name findCarInfoById |
||||
* @Description // 根据ID查询详情
|
||||
* @Date 15:13 2023/9/5 |
||||
* @Param id |
||||
* @return com.hai.entity.BlxCarInfo |
||||
*/ |
||||
BlxCarInfo findCarInfoById(Long id); |
||||
} |
@ -0,0 +1,88 @@ |
||||
package com.hai.blx.service.impl; |
||||
|
||||
import com.hai.blx.service.BlxCarService; |
||||
import com.hai.dao.BlxCarInfoMapper; |
||||
import com.hai.entity.BlxCarInfo; |
||||
import com.hai.entity.BlxCarInfoExample; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("blxCarService") |
||||
public class BlxCarServiceImpl implements BlxCarService { |
||||
|
||||
@Resource |
||||
private BlxCarInfoMapper blxCarInfoMapper; |
||||
|
||||
@Override |
||||
public void insertCar(BlxCarInfo carInfo) { |
||||
blxCarInfoMapper.insert(carInfo); |
||||
} |
||||
|
||||
@Override |
||||
public void updateCar(BlxCarInfo carInfo) { |
||||
blxCarInfoMapper.updateByPrimaryKey(carInfo); |
||||
} |
||||
|
||||
@Override |
||||
public List<BlxCarInfo> getCarInfoList(Map<String, Object> map) { |
||||
BlxCarInfoExample example = new BlxCarInfoExample(); |
||||
BlxCarInfoExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getString(map, "carNo") != null) { |
||||
criteria.andCarNoEqualTo(MapUtils.getString(map, "carNo")); |
||||
} |
||||
if (MapUtils.getInteger(map, "carNoType") != null) { |
||||
criteria.andCarNoTypeEqualTo(MapUtils.getInteger(map, "carNoType") ); |
||||
} |
||||
if (MapUtils.getLong(map, "userId") != null) { |
||||
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId") ); |
||||
} |
||||
if (MapUtils.getInteger(map, "status") != null) { |
||||
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status") ); |
||||
} else { |
||||
criteria.andStatusEqualTo(1); |
||||
} |
||||
|
||||
return blxCarInfoMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
public BlxCarInfo findCarInfoByMap(Map<String, Object> map) { |
||||
|
||||
BlxCarInfoExample example = new BlxCarInfoExample(); |
||||
BlxCarInfoExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
if (MapUtils.getString(map, "carNo") != null) { |
||||
criteria.andCarNoEqualTo(MapUtils.getString(map, "carNo")); |
||||
} |
||||
if (MapUtils.getInteger(map, "carNoType") != null) { |
||||
criteria.andCarNoTypeEqualTo(MapUtils.getInteger(map, "carNoType") ); |
||||
} |
||||
if (MapUtils.getLong(map, "userId") != null) { |
||||
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId") ); |
||||
} |
||||
if (MapUtils.getLong(map, "id") != null) { |
||||
criteria.andIdEqualTo(MapUtils.getLong(map, "id") ); |
||||
} |
||||
if (MapUtils.getInteger(map, "status") != null) { |
||||
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status") ); |
||||
} |
||||
|
||||
List<BlxCarInfo> list = blxCarInfoMapper.selectByExample(example); |
||||
|
||||
if (list.size() > 0) { |
||||
return list.get(0); |
||||
} |
||||
|
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public BlxCarInfo findCarInfoById(Long id) { |
||||
return blxCarInfoMapper.selectByPrimaryKey(id); |
||||
} |
||||
} |
Loading…
Reference in new issue