Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
3acd0fc7
Commit
3acd0fc7
authored
Aug 23, 2019
by
jiaorz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
车辆预定重新排班bug
parent
49341425
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
10 deletions
+94
-10
RandomUtil.java
...a/com/github/wxiaoqi/security/common/util/RandomUtil.java
+34
-1
TourGoodBiz.java
...src/main/java/com/xxfc/platform/tour/biz/TourGoodBiz.java
+24
-4
TourGoodController.java
.../java/com/xxfc/platform/tour/rest/TourGoodController.java
+5
-0
VehicleBiz.java
...c/main/java/com/xxfc/platform/vehicle/biz/VehicleBiz.java
+1
-3
VehicleModelBiz.java
...n/java/com/xxfc/platform/vehicle/biz/VehicleModelBiz.java
+23
-2
VehicleModelController.java
...om/xxfc/platform/vehicle/rest/VehicleModelController.java
+7
-0
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/RandomUtil.java
View file @
3acd0fc7
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
;
/**
/**
* 随机数工具
* 随机数工具
...
@@ -31,10 +33,41 @@ public class RandomUtil
...
@@ -31,10 +33,41 @@ 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
);
}
}
}
}
xx-tour/xx-tour-server/src/main/java/com/xxfc/platform/tour/biz/TourGoodBiz.java
View file @
3acd0fc7
...
@@ -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
?
3
:
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
);
}
}
}
xx-tour/xx-tour-server/src/main/java/com/xxfc/platform/tour/rest/TourGoodController.java
View file @
3acd0fc7
...
@@ -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
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleBiz.java
View file @
3acd0fc7
...
@@ -528,11 +528,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
...
@@ -528,11 +528,9 @@ public class VehicleBiz extends BaseBiz<VehicleMapper, Vehicle> implements UserR
Integer
andOperationFactor
=
andOpratorParam
.
get
(
"andOperationFactor"
);
Integer
andOperationFactor
=
andOpratorParam
.
get
(
"andOperationFactor"
);
Integer
andOperationRs
=
andOpratorParam
.
get
(
"andOperationRs"
);
Integer
andOperationRs
=
andOpratorParam
.
get
(
"andOperationRs"
);
if
(
vehicleBookInfo
!=
null
&&
vehicleBookInfo
.
getBookedDate
()
!=
null
&&
if
(
vehicleBookInfo
!=
null
&&
vehicleBookInfo
.
getBookedDate
()
!=
null
&&
((
vehicleBookInfo
.
getBookedDate
()
&
andOperationFactor
)
!=
andOperationRs
)){
//已经被预定
((
vehicleBookInfo
.
getBookedDate
()
&
andOperationFactor
)
!=
0
)){
//已经被预定
//当天已经被预定检查小时是否也被预定
//当天已经被预定检查小时是否也被预定
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
;
}
}
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/biz/VehicleModelBiz.java
View file @
3acd0fc7
...
@@ -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
?
3
:
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
);
}
}
/**
/**
...
...
xx-vehicle/xx-vehicle-server/src/main/java/com/xxfc/platform/vehicle/rest/VehicleModelController.java
View file @
3acd0fc7
...
@@ -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
);
}
/**
/**
* 添加车型
* 添加车型
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment