Commit 3040c163 authored by hezhen's avatar hezhen

Merge branch 'dev' of http://113.105.137.151:22280/youjj/cloud-platform into dev

parents 39ed4d6f 9a4d9f64
package com.github.wxiaoqi.security.common.util; package com.github.wxiaoqi.security.common.util;
import java.util.HashSet;
import java.util.Random; import java.util.Random;
import java.util.Set;
/** /**
* 随机数工具 * 随机数工具
...@@ -32,9 +34,40 @@ public class RandomUtil ...@@ -32,9 +34,40 @@ public class RandomUtil
return String.valueOf((int) (random * num)); return String.valueOf((int) (random * num));
} }
/**
* 获取随机数字集合
* @param max
* @param n
* @param set
*/
public static void randomSet(int max, int n, Set<Integer> set) {
if (n > (max + 1) || max < 0) {
return;
}
for (int i = 0; i < n; i++) {
int num = (int) (Math.random() * (max));
set.add(num);
}
int setSize = set.size();
// 如果存入的数小于指定生成的个数,则调用递归再生成剩余个数的随机数,如此循环,直到达到指定大小
if (setSize < n) {
randomSet( max, n-setSize, set);// 递归
}
}
public static synchronized String gencRan(){ public static synchronized String gencRan(){
Random ran = new Random(System.nanoTime()); Random ran = new Random(System.nanoTime());
double nextDouble = ran.nextDouble(); double nextDouble = ran.nextDouble();
return String.valueOf(nextDouble).substring(2, 6); return String.valueOf(nextDouble).substring(2, 6);
} }
public static void main(String[] args) {
int max = 20;
int n = 5;
Set<Integer> set = new HashSet<>();
randomSet(max, n, set);
for(Integer a : set) {
System.out.println(a);
}
}
} }
...@@ -16,7 +16,7 @@ spring: ...@@ -16,7 +16,7 @@ spring:
cloud: cloud:
nacos: nacos:
config: config:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848,10.1.37.166:8848
#共用配置,暂定一个 #共用配置,暂定一个
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
--- ---
......
package com.xxfc.platform.campsite.feign; package com.xxfc.platform.campsite.feign;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.vo.GoodDataVO; import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
...@@ -20,5 +21,6 @@ public interface CampsiteFeign { ...@@ -20,5 +21,6 @@ public interface CampsiteFeign {
@GetMapping(value = "/campsiteShop/app/shopList") @GetMapping(value = "/campsiteShop/app/shopList")
public List<GoodDataVO> goodList(@RequestParam(value = "page", defaultValue = "1") Integer page, public List<GoodDataVO> goodList(@RequestParam(value = "page", defaultValue = "1") Integer page,
@RequestParam(value = "limit",defaultValue = "4") Integer limit); @RequestParam(value = "limit",defaultValue = "4") Integer limit);
@GetMapping(value = "/campsiteShop/app/unauth/findRandomVehicle")
public ObjectRestResponse findRandomVehicle(@RequestParam(value = "number")Integer number);
} }
...@@ -2,6 +2,8 @@ package com.xxfc.platform.campsite.biz; ...@@ -2,6 +2,8 @@ package com.xxfc.platform.campsite.biz;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference; import com.alibaba.fastjson.TypeReference;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.RandomUtil;
import com.github.wxiaoqi.security.common.vo.GoodDataVO; import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.campsite.dto.*; import com.xxfc.platform.campsite.dto.*;
...@@ -336,6 +338,28 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> { ...@@ -336,6 +338,28 @@ public class CampsiteShopBiz extends BaseBiz<CampsiteShopMapper, CampsiteShop> {
.toEpochMilli(); .toEpochMilli();
} }
/**
* 获取指定数量的随机旅游路线
* @return
*/
public ObjectRestResponse findRandomVehicle(Integer number) {
number = number == null ? 2 : number;
List<GoodDataVO> list = mapper.findAll();
Set<GoodDataVO> resultList = new HashSet<>();
if(CollectionUtils.isNotEmpty(list)) {
if(number == list.size()) {
return ObjectRestResponse.succ(list);
}
Set<Integer> set = new HashSet<>();
RandomUtil.randomSet(list.size(), number, set);
for(Integer i : set) {
resultList.add(list.get(i));
}
}
return ObjectRestResponse.succ(resultList);
}
private long transformEndTime(Long endTime) { private long transformEndTime(Long endTime) {
return LocalDateTime.ofInstant(new Date(endTime).toInstant(), ZoneOffset.ofHours(+8)) return LocalDateTime.ofInstant(new Date(endTime).toInstant(), ZoneOffset.ofHours(+8))
......
...@@ -35,6 +35,8 @@ public interface CampsiteShopMapper extends Mapper<CampsiteShop> { ...@@ -35,6 +35,8 @@ public interface CampsiteShopMapper extends Mapper<CampsiteShop> {
*/ */
List<GoodDataVO> findAllByHome(@Param("start") Integer start, @Param("size") Integer size); List<GoodDataVO> findAllByHome(@Param("start") Integer start, @Param("size") Integer size);
List<GoodDataVO> findAll();
/** /**
* 根据店铺id查询 * 根据店铺id查询
* @param id * @param id
...@@ -72,4 +74,6 @@ public interface CampsiteShopMapper extends Mapper<CampsiteShop> { ...@@ -72,4 +74,6 @@ public interface CampsiteShopMapper extends Mapper<CampsiteShop> {
* @return * @return
*/ */
int checkNameExist(@Param("id") Integer id,@Param("name") String name); int checkNameExist(@Param("id") Integer id,@Param("name") String name);
} }
...@@ -59,5 +59,10 @@ public class CampsiteShopController extends BaseController<CampsiteShopBiz, Camp ...@@ -59,5 +59,10 @@ public class CampsiteShopController extends BaseController<CampsiteShopBiz, Camp
return getBaseBiz().getAllByHome(page,limit); return getBaseBiz().getAllByHome(page,limit);
} }
@ApiOperation("随机获取营地")
@GetMapping(value = "/app/unauth/findRandomVehicle")
public ObjectRestResponse findRandomVehicle(Integer number) {
return baseBiz.findRandomVehicle(number);
}
} }
\ No newline at end of file
...@@ -56,6 +56,13 @@ ...@@ -56,6 +56,13 @@
limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER} limit #{start,jdbcType=INTEGER},#{size,jdbcType=INTEGER}
</select> </select>
<select id="findAll" resultType="com.github.wxiaoqi.security.common.vo.GoodDataVO">
select cs.id as `id`,cs.name as `name`,cs.logo as `imgUrl`,cs.province_name as `name1`,cs.longitude,cs.latitude
FROM `campsite_shop` cs
where cs.sale_state=1 and cs.is_del=0
order by cs.hot desc
</select>
<!--根据id查询详情--> <!--根据id查询详情-->
<select id="findCampsiteShopDetailById" resultType="com.xxfc.platform.campsite.dto.CampsiteShopDetailDTO"> <select id="findCampsiteShopDetailById" resultType="com.xxfc.platform.campsite.dto.CampsiteShopDetailDTO">
select `name` as `name`,`province_name` as `provinceName`,`city_name` as `cityName`,`address` as `address`,`service_phone` as `phone`,`logo` as `logo`,`poster_background` as `posterBackground` , select `name` as `name`,`province_name` as `provinceName`,`city_name` as `cityName`,`address` as `address`,`service_phone` as `phone`,`logo` as `logo`,`poster_background` as `posterBackground` ,
......
...@@ -162,6 +162,9 @@ public class OrderCancelBiz { ...@@ -162,6 +162,9 @@ public class OrderCancelBiz {
} }
//退款流程 //退款流程
orderRefundBiz.rentRefundProcess(hasUpdateOrder, timeLag, APP_ORDER+ "_"+ key); orderRefundBiz.rentRefundProcess(hasUpdateOrder, timeLag, APP_ORDER+ "_"+ key);
//站点总人数减少
tourFeign.updateTourGoodPersonNum(otd.getVerificationId(), TourFeign.TOTAL_PERSON, (otd.getTotalNumber() * -1));
} }
} }
......
...@@ -13,7 +13,7 @@ spring: ...@@ -13,7 +13,7 @@ spring:
cloud: cloud:
nacos: nacos:
config: config:
server-addr: 127.0.0.1:8848, 10.1.37.166:8848 server-addr: 127.0.0.1:8848
#共用配置,+ mongodb日志配置 #共用配置,+ mongodb日志配置
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
......
...@@ -104,4 +104,7 @@ public interface TourFeign { ...@@ -104,4 +104,7 @@ public interface TourFeign {
@GetMapping("/spe/departure_date") @GetMapping("/spe/departure_date")
Date selectDepartureDataBySpeId(@RequestParam(value = "speIds") Integer speIds); Date selectDepartureDataBySpeId(@RequestParam(value = "speIds") Integer speIds);
@GetMapping(value = "/tourGood/app/unauth/findRandomVehicle")
public ObjectRestResponse findRandomVehicle(@RequestParam(value = "number")Integer number);
} }
...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign; ...@@ -9,6 +9,7 @@ import com.github.wxiaoqi.security.admin.feign.UserFeign;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.constant.RestCode; import com.github.wxiaoqi.security.common.constant.RestCode;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.RandomUtil;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.GoodDataVO; import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
...@@ -18,15 +19,13 @@ import com.xxfc.platform.tour.mapper.*; ...@@ -18,15 +19,13 @@ import com.xxfc.platform.tour.mapper.*;
import com.xxfc.platform.tour.vo.TourGoodVo; import com.xxfc.platform.tour.vo.TourGoodVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.beanutils.BeanUtils;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* 旅游商品表 * 旅游商品表
...@@ -325,6 +324,27 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> { ...@@ -325,6 +324,27 @@ public class TourGoodBiz extends BaseBiz<TourGoodMapper, TourGood> {
return mapper.findAllByHome((page-1)*limit,limit); return mapper.findAllByHome((page-1)*limit,limit);
}; };
/**
* 获取指定数量的随机旅游路线
* @return
*/
public ObjectRestResponse findRandomVehicle(Integer number) {
number = number == null ? 2 : number;
Map<String, Object> param = new HashMap<>();
List<TourGood> list = mapper.getCoordinateList(param);
Set<TourGood> resultList = new HashSet<>();
if(CollectionUtils.isNotEmpty(list)) {
if(number == list.size()) {
return ObjectRestResponse.succ(list);
}
Set<Integer> set = new HashSet<>();
RandomUtil.randomSet(list.size(), number, set);
for(Integer i : set) {
resultList.add(list.get(i));
}
}
return ObjectRestResponse.succ(resultList);
}
} }
...@@ -52,5 +52,10 @@ public class TourGoodController extends BaseController<TourGoodBiz, TourGood> { ...@@ -52,5 +52,10 @@ public class TourGoodController extends BaseController<TourGoodBiz, TourGood> {
return baseBiz.getAllByHome(page,limit); return baseBiz.getAllByHome(page,limit);
} }
@ApiOperation("随机获取旅游路线")
@GetMapping(value = "/app/unauth/findRandomVehicle")
public ObjectRestResponse findRandomVehicle(Integer number) {
return baseBiz.findRandomVehicle(number);
}
} }
\ No newline at end of file
...@@ -69,3 +69,5 @@ public class DictionaryController { ...@@ -69,3 +69,5 @@ public class DictionaryController {
return ObjectRestResponse.succ(); return ObjectRestResponse.succ();
} }
} }
...@@ -39,6 +39,9 @@ public interface VehicleFeign { ...@@ -39,6 +39,9 @@ public interface VehicleFeign {
@PostMapping("/active/small/arrival") @PostMapping("/active/small/arrival")
public RestResponse arrivalBySmall(@RequestBody VehicleArrivalVo arrivalVo); public RestResponse arrivalBySmall(@RequestBody VehicleArrivalVo arrivalVo);
@GetMapping(value = "/vehicleModel/app/unauth/findRandomVehicle")
public ObjectRestResponse findRandomVehicle(@RequestParam(value="number")Integer number);
//修改评分 //修改评分
@RequestMapping(value = "/vehicleModel/app/addScore", method = RequestMethod.GET) @RequestMapping(value = "/vehicleModel/app/addScore", method = RequestMethod.GET)
public RestResponse addScore(@RequestParam(value="id")Integer id, @RequestParam(value="score")Integer score); public RestResponse addScore(@RequestParam(value="id")Integer id, @RequestParam(value="score")Integer score);
......
...@@ -54,6 +54,9 @@ public class UsableVeicleDTO extends PageParam { ...@@ -54,6 +54,9 @@ public class UsableVeicleDTO extends PageParam {
@ApiModelProperty(hidden = true) @ApiModelProperty(hidden = true)
Boolean yearNo4Where; Boolean yearNo4Where;
@ApiModelProperty(hidden = true)
Integer withoutRecordWhere = 1;
public void setStartDateTamp(Long startDateTamp) { public void setStartDateTamp(Long startDateTamp) {
this.startDateTamp = startDateTamp; this.startDateTamp = startDateTamp;
this.startDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8))); this.startDate = DEFAULT_DATE_TIME_FORMATTER.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(startDateTamp), ZoneOffset.ofHours(8)));
......
...@@ -464,6 +464,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -464,6 +464,7 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_NOT_EXIST.getDesc(), ResCode.VEHICLE_BOOKED_RECORD_NOT_EXIST.getCode()); throw new BaseException(ResCode.VEHICLE_BOOKED_RECORD_NOT_EXIST.getDesc(), ResCode.VEHICLE_BOOKED_RECORD_NOT_EXIST.getCode());
} else { } else {
//先取消预定,然后再修改 //先取消预定,然后再修改
//先取消之前预定时间,然后再修改
bookVehicleVo.setUnbookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DATE_TIME_FORMATTER)); bookVehicleVo.setUnbookStartDate(new DateTime(vehicleBookRecord.getBookStartDate()).toString(DATE_TIME_FORMATTER));
bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER)); bookVehicleVo.setUnbookEndDate(new DateTime(vehicleBookRecord.getBookEndDate()).toString(DATE_TIME_FORMATTER));
unbookVehicle(bookVehicleVo); unbookVehicle(bookVehicleVo);
...@@ -531,8 +532,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -531,8 +532,6 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
((vehicleBookInfo.getBookedDate() & andOperationFactor) != andOperationRs)){//已经被预定 ((vehicleBookInfo.getBookedDate() & andOperationFactor) != andOperationRs)){//已经被预定
//当天已经被预定检查小时是否也被预定 //当天已经被预定检查小时是否也被预定
return filterHourInfoBooked(vehicleId, hourInfo); return filterHourInfoBooked(vehicleId, hourInfo);
} else if (vehicleBookInfo != null && vehicleBookInfo.getBookedDate() != null &&(vehicleBookInfo.getBookedDate() & andOperationFactor) == 0){//未被预定,查看时间是否被预定
return filterHourInfoBooked(vehicleId, hourInfo);
} }
return Boolean.TRUE; return Boolean.TRUE;
} }
...@@ -543,8 +542,17 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR ...@@ -543,8 +542,17 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto(); VehicleBookHourInfoDto vehicleBookHourInfoDto = new VehicleBookHourInfoDto();
vehicleBookHourInfoDto.setYearMonthDay(entry.getKey()); vehicleBookHourInfoDto.setYearMonthDay(entry.getKey());
vehicleBookHourInfoDto.setVehicleId(vehicleId); vehicleBookHourInfoDto.setVehicleId(vehicleId);
if(entry.getValue() == 0) {//0点 查询是否有已经预约的记录
Map<String, Object> param = new HashMap<>();
param.put("vehicleId", vehicleId);
param.put("bookedEndDate", DateTime.parse(entry.getKey() + " 00:00:00", DATE_TIME_FORMATTER));
List<VehicleBookRecordVo> vehicleBookRecordVos = vehicleBookRecordBiz.selectZeroHourRecord(param);
if(vehicleBookRecordVos != null && vehicleBookRecordVos.size() > 0) {
return false;
}
}
List<VehicleBookHourInfo> vehicleBookHourInfos = vehicleBookHourInfoBiz.selectByVehicleAndDate(vehicleBookHourInfoDto); List<VehicleBookHourInfo> vehicleBookHourInfos = vehicleBookHourInfoBiz.selectByVehicleAndDate(vehicleBookHourInfoDto);
if(vehicleBookHourInfos != null && vehicleBookHourInfos.size() >0) { if(vehicleBookHourInfos != null && vehicleBookHourInfos.size() > 0) {
if((vehicleBookHourInfos.get(0).getBookedHour() & entry.getValue()) != 0) { // 已经被预定 if((vehicleBookHourInfos.get(0).getBookedHour() & entry.getValue()) != 0) { // 已经被预定
log.info(entry.getKey() + "预定的时间段已经被预约!"); log.info(entry.getKey() + "预定的时间段已经被预约!");
return Boolean.FALSE; return Boolean.FALSE;
......
...@@ -70,19 +70,24 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V ...@@ -70,19 +70,24 @@ public class VehicleBookHourInfoBiz extends BaseBiz<VehicleBookHourInfoMapper, V
endPredictableHour |= 1 << (curentHour); endPredictableHour |= 1 << (curentHour);
} }
} }
DateTime startDay = DateTime.parse(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
DateTime endDay = DateTime.parse(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
if(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER).equals(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER))) {//同一天预定 if(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER).equals(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER))) {//同一天预定
//如果开始时间是0点开始
if(startPredictableHour == 0 || endPredictableHour == 0) { if(startPredictableHour == 0 || endPredictableHour == 0) {
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour | endPredictableHour); predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour | endPredictableHour);
} else { } else {
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour & endPredictableHour); predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour & endPredictableHour);
} }
} else { } else { //非同一天开始
if(startPredictableHour == 0) { //如果是0点就直接预订全天
startPredictableHour = 16777215;
}
predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour); predictableHours.put(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), startPredictableHour);
predictableHours.put(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), endPredictableHour); predictableHours.put(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), endPredictableHour);
} }
DateTime startDay = DateTime.parse(DateTime.parse(bookStartDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER); if(endDay.getDayOfMonth() - startDay.getDayOfMonth() > 1){ //
DateTime endDay = DateTime.parse(DateTime.parse(bookEndDate, DEFAULT_DATE_TIME_FORMATTER).toString(DATE_TIME_FORMATTER), DATE_TIME_FORMATTER);
if(endDay.getDayOfMonth() - startDay.getDayOfMonth() >1){ //
for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) { for (DateTime curDate = startDay.plusDays(1); curDate.compareTo(endDay) < 0; curDate = curDate.plusDays(1)) {
String curDateStr = curDate.toString(DATE_TIME_FORMATTER); String curDateStr = curDate.toString(DATE_TIME_FORMATTER);
//全天预定 //全天预定
......
...@@ -93,6 +93,12 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic ...@@ -93,6 +93,12 @@ public class VehicleBookRecordBiz extends BaseBiz<VehicleBookRecordMapper, Vehic
return list; return list;
} }
public List<VehicleBookRecordVo> selectZeroHourRecord(Map<String, Object> param) {
List<VehicleBookRecordVo> list = mapper.selectZeroHourRecord(param);
removeStatus2(list);
return list;
}
public int changeRecordStatus(Map<String, Object> updateParam) { public int changeRecordStatus(Map<String, Object> updateParam) {
return mapper.changeRecordStatus(updateParam); return mapper.changeRecordStatus(updateParam);
} }
......
...@@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper; ...@@ -5,6 +5,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.RandomUtil;
import com.github.wxiaoqi.security.common.vo.GoodDataVO; import com.github.wxiaoqi.security.common.vo.GoodDataVO;
import com.github.wxiaoqi.security.common.vo.PageDataVO; import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.constant.ResCode.ResCode; import com.xxfc.platform.vehicle.constant.ResCode.ResCode;
...@@ -20,8 +21,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport; ...@@ -20,8 +21,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.weekend.WeekendSqls; import tk.mybatis.mapper.weekend.WeekendSqls;
import java.util.ArrayList; import java.util.*;
import java.util.List;
/** /**
* 车型 * 车型
...@@ -71,7 +71,28 @@ public class VehicleModelBiz extends BaseBiz<VehicleModelMapper, VehicleModel> { ...@@ -71,7 +71,28 @@ public class VehicleModelBiz extends BaseBiz<VehicleModelMapper, VehicleModel> {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
} }
return null; return null;
}
/**
* 获取指定数量的随机车型
* @return
*/
public ObjectRestResponse findRandomVehicle(Integer number) {
number = number == null ? 2 : number;
VehicleModelQueryCondition vmqc = new VehicleModelQueryCondition();
List<VehicleModelVo> list = mapper.findVehicleModelPage(vmqc);
Set<VehicleModelVo> resultList = new HashSet<>();
if(CollectionUtils.isNotEmpty(list)) {
if(number == list.size()) {
return ObjectRestResponse.succ(list);
}
Set<Integer> set = new HashSet<>();
RandomUtil.randomSet(list.size(), number, set);
for(Integer i : set) {
resultList.add(list.get(i));
}
}
return ObjectRestResponse.succ(resultList);
} }
/** /**
......
...@@ -51,7 +51,7 @@ public class VehicleJobHandler extends IJobHandler { ...@@ -51,7 +51,7 @@ public class VehicleJobHandler extends IJobHandler {
int betweenMonth = Integer.valueOf(dictionary.getDetail()).intValue(); int betweenMonth = Integer.valueOf(dictionary.getDetail()).intValue();
int month = nowMonth + betweenMonth> 12 ? (betweenMonth + nowMonth) - 12 : nowMonth + betweenMonth; int month = nowMonth + betweenMonth> 12 ? (betweenMonth + nowMonth) - 12 : nowMonth + betweenMonth;
year = month > nowMonth ? year : year + 1; year = month > nowMonth ? year : year + 1;
String yearAndMonth = String.format("%d-%s", year, month>10?month:"0"+month); String yearAndMonth = String.format("%d-%s", year, month>=10?month:"0"+month);
XxlJobLogger.log("----查询到的车型ids:【{}】",existVehicleIds); XxlJobLogger.log("----查询到的车型ids:【{}】",existVehicleIds);
if (CollectionUtils.isNotEmpty(existVehicleIds)) { if (CollectionUtils.isNotEmpty(existVehicleIds)) {
List<VehicleBookInfo> bookInfos = existVehicleIds.stream().map(vehicleId -> { List<VehicleBookInfo> bookInfos = existVehicleIds.stream().map(vehicleId -> {
......
...@@ -37,4 +37,7 @@ public interface VehicleBookRecordMapper extends Mapper<VehicleBookRecord> { ...@@ -37,4 +37,7 @@ public interface VehicleBookRecordMapper extends Mapper<VehicleBookRecord> {
public List<VehicleBookRecordVo> getBookRecordInfo(Map<String, Object> param); public List<VehicleBookRecordVo> getBookRecordInfo(Map<String, Object> param);
public List<VehicleBookRecordVo> selectByVehicleIdAndTime(Map<String, Object> param); public List<VehicleBookRecordVo> selectByVehicleIdAndTime(Map<String, Object> param);
public List<VehicleBookRecordVo> selectZeroHourRecord(Map<String, Object> param);
} }
\ No newline at end of file
...@@ -125,6 +125,13 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi ...@@ -125,6 +125,13 @@ public class VehicleModelController extends BaseController<VehicleModelBiz, Vehi
return vehicleModelBiz.findVehicleModelPage(vmqc); return vehicleModelBiz.findVehicleModelPage(vmqc);
} }
@GetMapping(value = "/app/unauth/findRandomVehicle")
@IgnoreUserToken
@ApiOperation("获取随机车型")
public ObjectRestResponse findRandomVehicle(Integer number) {
return vehicleModelBiz.findRandomVehicle(number);
}
/** /**
* 添加车型 * 添加车型
......
...@@ -23,7 +23,7 @@ spring: ...@@ -23,7 +23,7 @@ spring:
cloud: cloud:
nacos: nacos:
config: config:
server-addr: 127.0.0.1:8848 server-addr: 127.0.0.1:8848,10.1.37.166:8848
#共用配置,暂定一个 #共用配置,暂定一个
shared-dataids: common-dev.yaml,mongodb-log-dev.yaml shared-dataids: common-dev.yaml,mongodb-log-dev.yaml
......
...@@ -330,6 +330,13 @@ ...@@ -330,6 +330,13 @@
where v1.vehicle_id = #{vehicleId} and v1.book_end_date &lt;= #{bookedEndDate} and v1.status BETWEEN 1 and 2 where v1.vehicle_id = #{vehicleId} and v1.book_end_date &lt;= #{bookedEndDate} and v1.status BETWEEN 1 and 2
</select> </select>
<select id="selectZeroHourRecord" resultMap="searchBookRecord" parameterType="java.util.Map">
select v1.* from vehicle_book_record v1
where v1.vehicle_id = #{vehicleId}
and (v1.book_end_date = #{bookedEndDate} or v1.book_start_date = #{bookedEndDate})
and v1.status BETWEEN 1 and 2
</select>
<select id="getById" parameterType="java.util.Map" resultType="com.xxfc.platform.vehicle.entity.VehicleBookRecord"> <select id="getById" parameterType="java.util.Map" resultType="com.xxfc.platform.vehicle.entity.VehicleBookRecord">
select select
vbr.`id`, vbr.`id`,
......
...@@ -522,11 +522,17 @@ ...@@ -522,11 +522,17 @@
</if> </if>
<!-- yearNo4Where 标识时间参数不用于where条件,用于select部分 --> <!-- yearNo4Where 标识时间参数不用于where条件,用于select部分 -->
<if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true"> <if test=" yearMonthAndParam !=null and yearNo4Where != null and yearNo4Where == true">
,max( ,(max(
<foreach collection="yearMonthAndParam" index="yearMonth" item="andOperation" separator="and"> <foreach collection="yearMonthAndParam" index="yearMonth" item="andOperation" separator="and">
<include refid="yearMonthAndParamSql"></include> <include refid="yearMonthAndParamSql"></include>
</foreach> </foreach>
) as hasVehicle <!-- 租车列表 不过滤前后预约记录不符的车辆 但是合并标示车型是否有车 即 hasVehicle-->
<if test="withoutRecordWhere != null and withoutRecordWhere = 1 and startCompanyId != null and endCompanyId != null ">
and (abr.to_lift_company is null or abr.to_lift_company = #{startCompanyId})
and (abr.to_return_company is null or abr.to_return_company = #{endCompanyId})
</if>
)
)as hasVehicle
</if> </if>
<if test="lon != null and lat != null"> <if test="lon != null and lat != null">
,st_distance_sphere(point(#{lon}, #{lat}), point(bc.longitude, bc.latitude)) as distance ,st_distance_sphere(point(#{lon}, #{lat}), point(bc.longitude, bc.latitude)) as distance
...@@ -557,7 +563,7 @@ ...@@ -557,7 +563,7 @@
) > 0 ) > 0
</if> </if>
) )
<!-- union 所有车型 --> <!-- union 所有下架车型 -->
<if test="startCompanyId != null or parkBranchCompanyId != null "> <if test="startCompanyId != null or parkBranchCompanyId != null ">
union union
(select vm.id as model_id, bc.id as company_id (select vm.id as model_id, bc.id as company_id
...@@ -635,15 +641,16 @@ ...@@ -635,15 +641,16 @@
</foreach> </foreach>
</if> </if>
<!-- 若需根据预定日期条件查询,针对换为位操作 --> <!-- 根据前后record 过滤车辆 -->
<!-- yearNo4Where 标识时间参数是否用于where条件 -->
<if test="startCompanyId != null and endCompanyId != null "> <if test="startCompanyId != null and endCompanyId != null ">
<if test="withoutRecordWhere == null">
and ( and (
(abr.to_lift_company is null or abr.to_lift_company = #{startCompanyId}) (abr.to_lift_company is null or abr.to_lift_company = #{startCompanyId})
and and
(abr.to_return_company is null or abr.to_return_company = #{endCompanyId}) (abr.to_return_company is null or abr.to_return_company = #{endCompanyId})
) )
</if> </if>
</if>
<if test=" modelId != null "> <if test=" modelId != null ">
and v.model_id = #{modelId} and v.model_id = #{modelId}
</if> </if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment