Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
wios
概览
Overview
详情
活动
周期分析
版本库
存储库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
苗卫卫
wios
Commits
266729b1
提交
266729b1
authored
11月 07, 2023
作者:
“chaining”
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
墙盒申请
父级
92ac644e
隐藏空白字符变更
内嵌
并排
正在显示
9 个修改的文件
包含
751 行增加
和
2 行删除
+751
-2
lib/dop-sdk-0.0.1-SNAPSHOT.jar
+0
-0
pom.xml
+7
-0
src/main/java/com/starcharge/wios/Import/v2/ImportControllerV2.java
+67
-0
src/main/java/com/starcharge/wios/client/DepponClient.java
+25
-0
src/main/java/com/starcharge/wios/client/DopInterceptor.java
+74
-0
src/main/java/com/starcharge/wios/controller/WallboxApplyController.java
+278
-0
src/main/java/com/starcharge/wios/convert/WallboxApplyConvert.java
+30
-0
src/main/java/com/starcharge/wios/service/SupplierService.java
+7
-2
src/main/java/com/starcharge/wios/service/WallboxApplyService.java
+263
-0
没有找到文件。
lib/dop-sdk-0.0.1-SNAPSHOT.jar
0 → 100644
查看文件 @
266729b1
File added
pom.xml
查看文件 @
266729b1
...
...
@@ -290,6 +290,13 @@
<artifactId>
commons-httpclient
</artifactId>
<version>
3.1
</version>
</dependency>
<dependency>
<groupId>
org.deppon.com
</groupId>
<artifactId>
dop-sdk
</artifactId>
<version>
0.0.1-SNAPSHOT
</version>
<scope>
system
</scope>
<systemPath>
${project.basedir}/lib/dop-sdk-0.0.1-SNAPSHOT.jar
</systemPath>
</dependency>
</dependencies>
<dependencyManagement>
...
...
src/main/java/com/starcharge/wios/Import/v2/ImportControllerV2.java
0 → 100644
查看文件 @
266729b1
package
com
.
starcharge
.
wios
.
Import
.
v2
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.ihidea.component.api.v2.BaseResponse
;
import
com.starcharge.wios.dao.OrderDao
;
import
com.starcharge.wios.dao.entity.Order
;
import
com.starcharge.wios.service.WallboxApplyService
;
import
com.starcharge.wios.utils.ExcelUtils
;
import
com.starcharge.wios.validation.CreateEntityGroup
;
import
com.starcharge.wios.vo.WallboxApplyExcelVO
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.validation.ConstraintViolation
;
import
javax.validation.Validator
;
import
java.util.List
;
import
java.util.Set
;
import
java.util.stream.Collectors
;
@RestController
public
class
ImportControllerV2
{
@Autowired
private
Validator
validator
;
@Autowired
private
WallboxApplyService
wallboxApplyService
;
@Autowired
private
OrderDao
orderDao
;
@PostMapping
(
"/wallbox-apply/import"
)
@ApiOperation
(
"导入墙盒申请"
)
public
BaseResponse
<
List
<
WallboxApplyExcelVO
>>
importExcel
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
)
throws
Exception
{
List
<
WallboxApplyExcelVO
>
list
=
ExcelUtils
.
read
(
file
,
WallboxApplyExcelVO
.
class
);
for
(
WallboxApplyExcelVO
vo
:
list
)
{
Set
<
ConstraintViolation
<
WallboxApplyExcelVO
>>
violations
=
validator
.
validate
(
vo
,
CreateEntityGroup
.
class
);
if
(!
violations
.
isEmpty
())
{
String
errorMessage
=
violations
.
stream
()
.
map
(
ConstraintViolation:
:
getMessage
)
.
collect
(
Collectors
.
joining
(
";"
));
vo
.
setErrorMessage
(
errorMessage
);
}
if
(
StringUtils
.
isNotBlank
(
vo
.
getOrderId
())){
Order
order
=
orderDao
.
selectById
(
vo
.
getOrderId
());
if
(
ObjectUtil
.
isNull
(
order
))
{
vo
.
setErrorMessage
(
"不存在安装订单号"
);
}
if
(
ObjectUtil
.
isNotNull
(
order
))
{
vo
.
setWallboxModel
(
order
.
getWallboxModel
());
}
if
(
ObjectUtil
.
isNotNull
(
wallboxApplyService
.
selectWallboxDetail
(
vo
.
getOrderId
())))
{
vo
.
setErrorMessage
(
"重复订单申请"
);
}
}
}
return
new
BaseResponse
<>(
list
);
}
}
src/main/java/com/starcharge/wios/client/DepponClient.java
0 → 100644
查看文件 @
266729b1
package
com
.
starcharge
.
wios
.
client
;
import
com.dtflys.forest.annotation.BaseRequest
;
import
com.dtflys.forest.annotation.Body
;
import
com.dtflys.forest.annotation.Post
;
/**
* <p>
* 德邦物流clinet,注意入参使用Map或者对象实体
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@BaseRequest
(
baseURL
=
"http://dpsanbox.deppon.com/sandbox-web/standard-order/"
,
interceptor
=
DopInterceptor
.
class
)
public
interface
DepponClient
{
/**
* 新标准轨迹查询
* http://dop.deppon.com/#/wantAccess/myApiConfig
* @param {"mailNo":"7503587254"}
* @return 字符串
*/
@Post
(
"newTraceQuery.action"
)
String
newTraceQuery
(
@Body
(
"params"
)
String
params
);
}
src/main/java/com/starcharge/wios/client/DopInterceptor.java
0 → 100644
查看文件 @
266729b1
package
com
.
starcharge
.
wios
.
client
;
import
com.deppon.dop.module.sdk.shared.util.SecurityUtil
;
import
com.dtflys.forest.exceptions.ForestRuntimeException
;
import
com.dtflys.forest.http.ForestRequest
;
import
com.dtflys.forest.http.ForestResponse
;
import
com.dtflys.forest.interceptor.Interceptor
;
import
com.dtflys.forest.reflection.ForestMethod
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.codec.digest.DigestUtils
;
/**
* <p>
* 德邦物流请求拦截器,实现自动注入companyCode、digest、timestamp参数
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
public
class
DopInterceptor
<
T
>
implements
Interceptor
<
T
>
{
private
final
String
companyCode
=
"EWBXRCHSZX"
;
private
final
String
appkey
=
"fe38a755ce4f7629717342e441cdedff"
;
/**
* 该方法在被调用时,检测token是否过期,并在beforeExecute前被调用
* @Param request Forest请求对象
* @Param args 方法被调用时传入的参数数组
*/
@Override
public
void
onInvokeMethod
(
ForestRequest
request
,
ForestMethod
method
,
Object
[]
args
)
{
}
@Override
public
boolean
beforeExecute
(
ForestRequest
request
)
{
request
.
addHeader
(
"Content-Type"
,
"application/x-www-form-urlencoded;charset=utf-8"
);
String
params
=
request
.
getBody
().
get
(
0
).
toString
();
// String timestamp=System.currentTimeMillis()+"";
String
timestamp
=
"1697877426621"
;
//params+appkey+timestamp,,,ZDU0NzYzZWJkODRhZjBlZjcyYjEwZDYxYTNlNzRkNWQ=
String
digest
=
SecurityUtil
.
getStandardDigest
(
params
+
appkey
+
timestamp
);
request
.
addBody
(
"companyCode"
,
companyCode
);
request
.
addBody
(
"digest"
,
digest
);
request
.
addBody
(
"timestamp"
,
timestamp
);
return
true
;
// 继续执行请求返回true
}
/**
* 该方法在请求成功响应时被调用
*/
@Override
public
void
onSuccess
(
T
data
,
ForestRequest
req
,
ForestResponse
res
)
{
}
/**
* 该方法在请求发送失败时被调用
*/
@Override
public
void
onError
(
ForestRuntimeException
ex
,
ForestRequest
req
,
ForestResponse
res
)
{
// 执行发送请求失败后处理的代码
int
status
=
res
.
getStatusCode
();
// 获取请求响应状态码
String
content
=
res
.
getContent
();
}
/**
* 该方法在请求发送之后被调用
*/
@Override
public
void
afterExecute
(
ForestRequest
req
,
ForestResponse
res
)
{
}
private
String
getDigest
(
String
plainText
)
{
return
Base64
.
encodeBase64String
(
DigestUtils
.
md5Hex
(
plainText
).
getBytes
());
}
}
src/main/java/com/starcharge/wios/controller/WallboxApplyController.java
0 → 100644
查看文件 @
266729b1
package
com
.
starcharge
.
wios
.
controller
;
import
cn.hutool.core.date.LocalDateTimeUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.ihidea.component.api.v2.BaseResponse
;
import
com.ihidea.core.support.exception.ServiceException
;
import
com.ihidea.core.support.session.SessionInfo
;
import
com.starcharge.base.util.Assert
;
import
com.starcharge.wios.auth.service.TokenService
;
import
com.starcharge.wios.client.DepponClient
;
import
com.starcharge.wios.convert.WallboxApplyConvert
;
import
com.starcharge.wios.dao.entity.Order
;
import
com.starcharge.wios.dao.entity.Supplier
;
import
com.starcharge.wios.dao.entity.SupplierStaff
;
import
com.starcharge.wios.dao.entity.WallboxApply
;
import
com.starcharge.wios.dto.WallboxApplyBatchCheckDTO
;
import
com.starcharge.wios.enums.OrderStatus
;
import
com.starcharge.wios.service.OrderService
;
import
com.starcharge.wios.service.SupplierService
;
import
com.starcharge.wios.service.SupplierStaffService
;
import
com.starcharge.wios.service.WallboxApplyService
;
import
com.starcharge.wios.utils.ExcelUtils
;
import
com.starcharge.wios.vo.*
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
import
io.swagger.annotations.ApiImplicitParams
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.time.Duration
;
import
java.time.LocalDateTime
;
import
java.util.Arrays
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* <p>
* 墙盒申请Controller
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@RestController
@Api
(
tags
=
"墙盒申请接口"
)
@RequestMapping
(
"api/wallbox/apply"
)
public
class
WallboxApplyController
{
@Autowired
private
WallboxApplyService
wallboxApplyService
;
@Autowired
private
OrderService
orderService
;
@Autowired
private
TokenService
tokenService
;
@Autowired
private
SupplierStaffService
supplierStaffService
;
@Autowired
private
SupplierService
supplierService
;
@Resource
private
DepponClient
depponClient
;
@ApiOperation
(
value
=
"墙盒申请"
)
@PostMapping
(
"/add"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"orderId"
,
value
=
"订单id"
,
dataType
=
"string"
,
paramType
=
"query"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"ifEmergency"
,
value
=
"是否紧急0否,1是"
,
dataType
=
"int"
,
paramType
=
"query"
,
required
=
true
),})
public
BaseResponse
<
Object
>
applyInstallation
(
String
orderId
,
Integer
ifEmergency
)
{
Assert
.
notNull
(
orderId
,
"订单id不能为空"
);
Order
order
=
orderService
.
get
(
orderId
);
if
(
ObjectUtil
.
isNull
(
order
))
{
throw
new
ServiceException
(
"订单不存在"
);
}
Integer
status
=
order
.
getStatus
();
// 检查订单状态是否在0-43之间
if
(
status
>=
OrderStatus
.
DISPATCHING
.
getType
()
&&
status
<=
OrderStatus
.
INSTALLING
.
getType
())
{
SessionInfo
loginUser
=
tokenService
.
getUser
();
String
userId
=
loginUser
.
getUserId
();
SupplierStaff
infoByAccount
=
supplierStaffService
.
getByAccountId
(
Integer
.
valueOf
(
userId
));
Supplier
supplier
=
supplierService
.
getById
(
infoByAccount
.
getSupplierId
());
if
(
supplier
==
null
)
{
throw
new
ServiceException
(
"供应商不存在"
);
}
WallboxApply
wa
=
new
WallboxApply
();
wa
.
setSupplierId
(
Long
.
valueOf
(
supplier
.
getId
()));
wa
.
setSupplierTeam
(
supplier
.
getName
());
wa
.
setOrderId
(
orderId
);
wa
.
setIfEmergency
(
ifEmergency
);
wa
.
setCreateAccount
(
tokenService
.
getUser
().
getUserId
());
wallboxApplyService
.
insertWallboxApply
(
wa
);
return
new
BaseResponse
<>(
true
);
}
throw
new
ServiceException
(
"订单已在安装中,无法申请"
);
}
/**
* 查询墙盒申请列表
*/
@GetMapping
(
"/list"
)
@ApiOperation
(
value
=
"分页查询墙盒申请列表"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"一页显示数量"
,
dataType
=
"int"
,
paramType
=
"query"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"pagecount"
,
value
=
"页码"
,
dataType
=
"int"
,
paramType
=
"query"
,
required
=
true
)})
public
BaseResponse
<
List
<
WallboxApplyInstallListVO
>>
list
(
WallboxApplyReqVO
req
)
{
List
<
WallboxApplyInstallListVO
>
list
=
wallboxApplyService
.
selectWallboxApplyListFromOrder
(
WallboxApplyConvert
.
INSTANCE
.
convert
(
req
));
return
new
BaseResponse
<>(
list
);
}
@GetMapping
(
"/get-import-template"
)
@ApiOperation
(
"获得导入模板"
)
public
void
importTemplate
(
HttpServletResponse
response
)
throws
IOException
{
// 手动创建导出 demo
WallboxApplyExcelVO
excelDemo
=
new
WallboxApplyExcelVO
();
excelDemo
.
setIfEmergency
(
0
);
excelDemo
.
setOrderId
(
"CA20201204044558"
);
List
<
WallboxApplyExcelVO
>
list
=
Arrays
.
asList
(
excelDemo
);
// 输出
ExcelUtils
.
write
(
response
,
"墙盒申请导入模板.xls"
,
"墙盒申请"
,
WallboxApplyExcelVO
.
class
,
list
);
}
@PostMapping
(
"/import"
)
@ApiOperation
(
"导入墙盒申请"
)
public
BaseResponse
<
WallboxApplyExcelVO
>
importExcel
(
@RequestParam
(
value
=
"file"
)
MultipartFile
file
)
throws
Exception
{
List
<
WallboxApplyExcelVO
>
list
=
ExcelUtils
.
read
(
file
,
WallboxApplyExcelVO
.
class
);
return
new
BaseResponse
<>();
}
/**
* 导出墙盒申请模板
*/
@PostMapping
(
"/export"
)
@ApiOperation
(
"导出墙盒申请"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"page"
,
value
=
"一页显示数量"
,
dataType
=
"int"
,
paramType
=
"query"
,
required
=
true
),
@ApiImplicitParam
(
name
=
"pagecount"
,
value
=
"页码"
,
dataType
=
"int"
,
paramType
=
"query"
,
required
=
true
)})
public
void
export
(
HttpServletResponse
response
,
WallboxApplyReqVO
req
)
throws
IOException
{
List
<
WallboxApplyInstallListVO
>
list
=
wallboxApplyService
.
selectWallboxApplyListFromOrder
(
WallboxApplyConvert
.
INSTANCE
.
convert
(
req
));
ExcelUtils
.
write
(
response
,
"墙盒申请数据导出.xls"
,
"墙盒申请数据"
,
WallboxApplyInstallListVO
.
class
,
list
);
}
/**
* 获取墙盒申请详细信息
*/
@ApiOperation
(
value
=
"获取墙盒详细信息"
)
@GetMapping
(
value
=
"/{id}"
)
public
BaseResponse
<
Object
>
getInfo
(
@PathVariable
(
"id"
)
Long
id
)
{
return
new
BaseResponse
<>(
wallboxApplyService
.
selectWallboxApplyById
(
id
));
}
/**
* 获取墙盒详细信息
*/
@ApiOperation
(
value
=
"墙盒状态"
)
@PostMapping
(
value
=
"/status"
)
public
BaseResponse
<
Object
>
wallboxStatus
(
@RequestParam
(
"orderId"
)
String
orderId
)
{
WallboxApplyDetailVO
rest
=
wallboxApplyService
.
selectWallboxDetail
(
orderId
);
return
new
BaseResponse
<>(
rest
);
}
@ApiOperation
(
value
=
"获取物流信息"
)
@GetMapping
(
value
=
"/trace/{id}"
)
public
BaseResponse
<
Object
>
getTrace
(
@PathVariable
(
"id"
)
String
id
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"mailNo"
,
"7503587254"
);
String
rest
=
depponClient
.
newTraceQuery
(
JSON
.
toJSONString
(
paramMap
));
return
new
BaseResponse
<>(
rest
);
}
/**
* 新增墙盒申请
*/
@ApiOperation
(
value
=
"批量新增"
)
@PostMapping
public
BaseResponse
<
Object
>
add
(
@RequestBody
List
<
WallboxApply
>
tWallboxApply
)
{
tWallboxApply
.
forEach
(
t
->{
wallboxApplyService
.
insertWallboxApply
(
t
);
});
return
new
BaseResponse
<>();
}
@ApiOperation
(
value
=
"查询当前账号所属团队"
)
@GetMapping
(
"/get-team"
)
public
BaseResponse
<
Object
>
getTeamInfo
()
{
SessionInfo
loginUser
=
tokenService
.
getUser
();
String
userId
=
loginUser
.
getUserId
();
SupplierStaff
infoByAccount
=
supplierStaffService
.
getByAccountId
(
Integer
.
valueOf
(
userId
));
Supplier
supplier
=
supplierService
.
getById
(
infoByAccount
.
getSupplierId
());
if
(
supplier
==
null
)
{
throw
new
ServiceException
(
"供应商不存在"
);
}
return
new
BaseResponse
<>(
supplier
);
}
/**
* 修改墙盒申请
*/
@PutMapping
public
BaseResponse
<
Object
>
edit
(
@RequestBody
WallboxApply
tWallboxApply
)
{
//TODO 判断是否超时
return
new
BaseResponse
<>(
wallboxApplyService
.
updateWallboxApply
(
tWallboxApply
));
}
@ApiOperation
(
value
=
"申请审核"
)
@PostMapping
(
"/check"
)
public
BaseResponse
<
Object
>
check
(
@RequestBody
@Validated
WallboxApplyCheckVO
req
)
{
wallboxApplyService
.
checkWallboxApply
(
req
);
return
new
BaseResponse
<>();
}
@ApiOperation
(
value
=
"同订单多申请情况"
)
@PostMapping
(
"/unapproved"
)
public
BaseResponse
<
Object
>
hasUnapprovedOrders
(
@RequestBody
@Validated
WallboxApplyCheckVO
req
)
{
WallboxApply
cond
=
new
WallboxApply
();
cond
.
setOrderId
(
req
.
getOrderId
());
long
count
=
wallboxApplyService
.
selectWallboxApplyList
(
cond
).
stream
().
filter
(
l
->
l
.
getCheckStatus
()
==
1
).
count
();
if
(
count
>
0
)
{
throw
new
ServiceException
(
"该安装订单号存在多个申请"
);
}
return
new
BaseResponse
<>();
}
@ApiOperation
(
value
=
"批量申请审核"
)
@PostMapping
(
"/check-batch"
)
public
BaseResponse
<
Object
>
checkBatch
(
@RequestBody
WallboxApplyBatchCheckDTO
req
)
{
return
new
BaseResponse
<>(
wallboxApplyService
.
checkBatch
(
req
));
}
@ApiOperation
(
value
=
"墙盒申请状态统计"
)
@PostMapping
(
"/count"
)
public
BaseResponse
<
Object
>
count
()
{
//查询当前团队的已审批、未审批、已发货、未发货数据
String
currentLogin
=
tokenService
.
getUser
().
getUserId
();
WallboxApply
cond
=
new
WallboxApply
();
cond
.
setCreateAccount
(
currentLogin
);
List
<
WallboxApply
>
list
=
wallboxApplyService
.
selectWallboxApplyList
(
cond
);
// 使用 Lambda 表达式统计每种情况的数据数量
long
unapprovedCount
=
list
.
stream
()
.
filter
(
apply
->
apply
.
getCheckStatus
()
==
1
)
.
count
();
LocalDateTime
currentDateTime
=
LocalDateTime
.
now
();
long
timeoutCount
=
list
.
stream
()
.
filter
(
apply
->
apply
.
getCheckStatus
()
==
1
&&
Duration
.
between
(
LocalDateTimeUtil
.
of
(
apply
.
getCreatedTime
()),
currentDateTime
).
toHours
()
>
24
)
.
count
();
long
awaitingDeliveryCount
=
list
.
stream
()
.
filter
(
apply
->
"0"
.
equals
(
apply
.
getTrackingStatus
()))
.
count
();
long
deliveredCount
=
list
.
stream
()
.
filter
(
apply
->
"1"
.
equals
(
apply
.
getTrackingStatus
()))
.
count
();
Map
<
String
,
Object
>
rest
=
new
HashMap
<>();
rest
.
put
(
"unapprovedCount"
,
unapprovedCount
);
rest
.
put
(
"timeoutCount"
,
timeoutCount
);
rest
.
put
(
"awaitingDeliveryCount"
,
awaitingDeliveryCount
);
rest
.
put
(
"deliveredCount"
,
deliveredCount
);
return
new
BaseResponse
<>(
rest
);
}
}
src/main/java/com/starcharge/wios/convert/WallboxApplyConvert.java
0 → 100644
查看文件 @
266729b1
package
com
.
starcharge
.
wios
.
convert
;
import
com.starcharge.wios.dao.entity.WallboxApply
;
import
com.starcharge.wios.vo.WallboxApplyInstallInfoVO
;
import
com.starcharge.wios.vo.WallboxApplyInstallListVO
;
import
com.starcharge.wios.vo.WallboxApplyReqVO
;
import
org.mapstruct.Mapper
;
import
org.mapstruct.factory.Mappers
;
import
java.util.List
;
/**
* <p>
* description
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Mapper
public
interface
WallboxApplyConvert
{
WallboxApplyConvert
INSTANCE
=
Mappers
.
getMapper
(
WallboxApplyConvert
.
class
);
WallboxApply
convert
(
WallboxApplyReqVO
bean
);
WallboxApplyInstallInfoVO
convert2Info
(
WallboxApply
bean
);
WallboxApplyInstallListVO
convert
(
WallboxApply
bean
);
List
<
WallboxApplyInstallListVO
>
convertList
(
List
<
WallboxApply
>
bean
);
}
src/main/java/com/starcharge/wios/service/SupplierService.java
查看文件 @
266729b1
...
...
@@ -126,8 +126,9 @@ public class SupplierService {
public
List
<
SupplierVo
>
getList
(
SupplierBo
condition
)
{
SessionInfo
sessionInfo
=
tokenService
.
getUser
();
if
(
sessionInfo
!=
null
&&
!
StringUtils
.
isEmpty
(
sessionInfo
.
getAttribute
().
get
(
"installSupplierId"
)))
if
(
sessionInfo
!=
null
&&
!
StringUtils
.
isEmpty
(
sessionInfo
.
getAttribute
().
get
(
"installSupplierId"
)))
{
condition
.
setId
(
sessionInfo
.
getAttribute
().
get
(
"installSupplierId"
));
}
if
(
condition
.
getServiceRegionId
()
!=
null
)
{
Region
region
=
regionDao
.
selectById
(
condition
.
getServiceRegionId
());
List
<
String
>
regionIdList
=
Arrays
.
asList
(
region
.
getIdTree
().
split
(
"_"
));
...
...
@@ -137,7 +138,11 @@ public class SupplierService {
}
return
supplierDao
.
getList
(
condition
);
}
public
Supplier
getById
(
Integer
id
){
return
supplierDao
.
selectById
(
id
);
}
public
void
update
(
int
id
,
SupplierBo
supplierBo
)
{
supplierDao
.
update
(
id
,
supplierBo
);
}
...
...
src/main/java/com/starcharge/wios/service/WallboxApplyService.java
0 → 100644
查看文件 @
266729b1
package
com
.
starcharge
.
wios
.
service
;
import
cn.hutool.core.util.ObjectUtil
;
import
cn.hutool.core.util.StrUtil
;
import
com.ihidea.core.support.exception.ServiceException
;
import
com.ihidea.core.support.session.SessionInfo
;
import
com.starcharge.wios.auth.service.TokenService
;
import
com.starcharge.wios.dao.OrderDao
;
import
com.starcharge.wios.dao.OrderInstallDao
;
import
com.starcharge.wios.dao.SupplierDao
;
import
com.starcharge.wios.dao.SupplierStaffDao
;
import
com.starcharge.wios.dao.entity.Order
;
import
com.starcharge.wios.dao.entity.OrderInstall
;
import
com.starcharge.wios.dao.entity.SupplierStaff
;
import
com.starcharge.wios.dao.entity.WallboxApply
;
import
com.starcharge.wios.dao.mappers.WallboxApplyMapper
;
import
com.starcharge.wios.dto.WallboxApplyBatchCheckDTO
;
import
com.starcharge.wios.dto.WallboxApplyCheckDTO
;
import
com.starcharge.wios.dto.WallboxApplyDetailQueryDTO
;
import
com.starcharge.wios.vo.WallboxApplyCheckVO
;
import
com.starcharge.wios.vo.WallboxApplyDetailVO
;
import
com.starcharge.wios.vo.WallboxApplyInstallInfoVO
;
import
com.starcharge.wios.vo.WallboxApplyInstallListVO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.stream.Collectors
;
/**
* <p>
* description
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Service
public
class
WallboxApplyService
{
@Autowired
private
WallboxApplyMapper
wallboxApplyMapper
;
@Autowired
private
OrderDao
orderDao
;
@Autowired
private
OrderInstallDao
orderInstallDao
;
@Autowired
private
TokenService
tokenService
;
@Autowired
private
SupplierDao
supplierDao
;
@Autowired
private
SupplierStaffDao
supplierStaffDao
;
private
final
Integer
CHECK_STATUS_REJECT
=
2
;
/**
* 查询墙盒申请
*
* @param id 墙盒申请主键
* @return 墙盒申请
*/
public
WallboxApplyInstallInfoVO
selectWallboxApplyById
(
Long
id
)
{
return
wallboxApplyMapper
.
selectWallboxApplyById
(
id
);
}
/**
* 墙盒详情(墙盒状态)
*
* @param orderId 订单id
* @return 墙盒申请
*/
public
WallboxApplyDetailVO
selectWallboxDetail
(
String
orderId
)
{
SessionInfo
loginUser
=
tokenService
.
getUser
();
String
userId
=
loginUser
.
getUserId
();
List
<
SupplierStaff
>
supplier
=
supplierStaffDao
.
selectByAccountId
(
Integer
.
valueOf
(
userId
));
WallboxApplyDetailQueryDTO
query
=
new
WallboxApplyDetailQueryDTO
();
query
.
setOrderId
(
orderId
);
query
.
setSupplierId
(
supplier
.
stream
().
findFirst
().
get
().
getSupplierId
().
toString
());
return
wallboxApplyMapper
.
selectWallboxDetail
(
query
);
}
/**
* 查询墙盒申请列表
*
* @param WallboxApply 墙盒申请
* @return 墙盒申请
*/
public
List
<
WallboxApply
>
selectWallboxApplyList
(
WallboxApply
WallboxApply
)
{
return
wallboxApplyMapper
.
selectWallboxApplyList
(
WallboxApply
);
}
/**
* 根据订单表查询墙盒申请列表
*
* @param WallboxApply 墙盒申请
* @return 墙盒申请
*/
public
List
<
WallboxApplyInstallListVO
>
selectWallboxApplyListFromOrder
(
WallboxApply
WallboxApply
)
{
List
<
WallboxApplyInstallListVO
>
list
=
wallboxApplyMapper
.
selectWallboxApplyListFromOrder
(
WallboxApply
);
list
.
stream
().
map
(
l
->{
return
l
;
});
return
list
;
}
public
WallboxApply
calculateTimeRemaining
(
WallboxApply
wallboxApply
)
{
return
wallboxApply
;
}
/**
* 新增墙盒申请
*
* @param req 墙盒申请
* @return 结果
*/
public
int
insertWallboxApply
(
WallboxApply
req
)
{
//判断是否可以新增
//validateApplyExists(req.getOrderId());
WallboxApply
condition
=
new
WallboxApply
();
condition
.
setOrderId
(
req
.
getOrderId
());
condition
.
setCheckStatus
(
1L
);
List
<
WallboxApply
>
retList
=
wallboxApplyMapper
.
selectWallboxApplyList
(
condition
);
if
(
CollectionUtils
.
isNotEmpty
(
retList
)){
throw
new
ServiceException
(
"存在已审核通过的安装单,无法重复申请"
);
}
condition
.
setSupplierId
(
req
.
getSupplierId
());
List
<
WallboxApply
>
retList2
=
wallboxApplyMapper
.
selectWallboxApplyList
(
condition
);
if
(
CollectionUtils
.
isNotEmpty
(
retList2
)){
throw
new
ServiceException
(
"该订单已申请"
);
}
//补全相关信息
Order
order
=
orderDao
.
selectById
(
req
.
getOrderId
());
req
.
setRegionId
(
order
.
getRegionId
());
String
wallboxModel
=
order
.
getWallboxModel
();
if
(
StrUtil
.
isBlank
(
wallboxModel
))
{
throw
new
ServiceException
(
"订单数据异常,缺失墙盒信息,请联系系统管理员"
);
}
req
.
setWallboxItemId
(
order
.
getWallboxModel
());
req
.
setWallboxModel
(
order
.
getWallboxModel
()
==
null
?
""
:
order
.
getWallboxModel
());
req
.
setOutOrderId
(
order
.
getOutOrderId
());
req
.
setInstallReserveTime
(
order
.
getInstallReserveTime
());
req
.
setAddress
(
order
.
getAddress
());
req
.
setTrackingNumber
(
order
.
getShipno
());
req
.
setInstallProcess
(
Integer
.
toUnsignedLong
(
order
.
getStatus
()));
req
.
setInstallStatus
(
Integer
.
toString
(
order
.
getStatus
()));
req
.
setOutOrderId
(
order
.
getOutOrderId
());
return
wallboxApplyMapper
.
insertWallboxApply
(
req
);
}
/**
* 新增墙盒申请
*
* @param orderId 订单号
* @return 结果
*/
public
int
insertWallboxApply
(
int
orderId
)
{
//判断订单状态
// orderInstallDao.selectByOrderId()
return
0
;
}
/**
* 修改墙盒申请
*
* @return 结果
*/
public
int
updateWallboxApply
(
WallboxApply
wallboxApply
)
{
WallboxApply
record
=
wallboxApplyMapper
.
selectWallboxApplyByOrderId
(
wallboxApply
.
getOutOrderId
());
// if (!CHECK_STATUS_REJECT.equals(record.getCheckStatus())) {
// throw new ServiceException("非驳回状态订单无法修改信息!");
// }
wallboxApply
.
setCheckTime
(
new
Date
());
return
wallboxApplyMapper
.
updateWallboxApply
(
wallboxApply
);
}
/**
* 审核
* @param req
* @return
*/
public
int
checkWallboxApply
(
WallboxApplyCheckVO
req
){
WallboxApply
cond
=
new
WallboxApply
();
cond
.
setOrderId
(
req
.
getOrderId
());
List
<
WallboxApply
>
list
=
wallboxApplyMapper
.
selectWallboxApplyList
(
cond
);
List
<
WallboxApply
>
filteredList
=
list
.
stream
()
.
filter
(
l
->
l
.
getCheckStatus
()
==
2
)
.
collect
(
Collectors
.
toList
());
if
(!
filteredList
.
isEmpty
())
{
throw
new
ServiceException
(
"同订单已审核"
);
}
WallboxApply
update
=
new
WallboxApply
();
update
.
setId
(
req
.
getId
());
update
.
setOrderId
(
req
.
getOrderId
());
update
.
setCheckStatus
(
req
.
getCheckStatus
());
update
.
setCheckRemarks
(
req
.
getCheckRemarks
());
update
.
setCheckTime
(
new
Date
());
update
.
setCheckAccount
(
tokenService
.
getUser
().
getUserId
());
return
wallboxApplyMapper
.
updateWallboxApply
(
update
);
}
/**
* 批量审核
*/
public
WallboxApplyBatchCheckDTO
checkBatch
(
WallboxApplyBatchCheckDTO
req
)
{
List
<
WallboxApplyCheckDTO
>
checkList
=
req
.
getCheckList
();
List
<
WallboxApply
>
toUpdateList
=
new
ArrayList
<>();
boolean
allowedUpdate
=
true
;
for
(
WallboxApplyCheckDTO
wallboxApply
:
checkList
)
{
WallboxApply
cond
=
new
WallboxApply
();
cond
.
setOrderId
(
wallboxApply
.
getOrderId
());
List
<
WallboxApply
>
list
=
wallboxApplyMapper
.
selectWallboxApplyList
(
cond
);
List
<
WallboxApply
>
filteredList
=
list
.
stream
()
.
filter
(
l
->
l
.
getCheckStatus
()
==
2
)
.
collect
(
Collectors
.
toList
());
if
(!
filteredList
.
isEmpty
())
{
wallboxApply
.
setDataStatus
(
"0"
);
wallboxApply
.
setErrorMessage
(
"该订单已审核通过"
);
allowedUpdate
=
false
;
}
if
(
allowedUpdate
){
WallboxApply
update
=
new
WallboxApply
();
update
.
setId
(
wallboxApply
.
getId
());
update
.
setCheckStatus
(
req
.
getCheckStatus
());
update
.
setCheckRemarks
(
req
.
getCheckRemarks
());
update
.
setCheckAccount
(
tokenService
.
getUser
().
getUserId
());
toUpdateList
.
add
(
update
);
}
}
if
(
allowedUpdate
){
// 批量更新操作
toUpdateList
.
forEach
(
l
->
wallboxApplyMapper
.
updateWallboxApply
(
l
));
}
return
req
;
}
void
validateApplyExists
(
String
id
)
{
OrderInstall
orderInstall
=
orderInstallDao
.
selectByOrderId
(
id
);
if
(
ObjectUtil
.
isNull
(
orderInstall
))
{
throw
new
ServiceException
(
"不存在安装单号"
);
}
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论